コード例 #1
0
        protected override void TranslateSetContentModel(PSMContentModel setModel, DataGeneratorContext context)
        {
            TranslateComments(setModel, context);
            IEnumerable <PSMAssociation> shuffled = setModel.ChildPSMAssociations.Shuffle();
            IEnumerable <PSMAssociation> followedAssociations;

            uint lower = setModel.ParentAssociation.Lower;

            if (lower > 1)
            {
                Log.AddErrorFormat(LogMessages.Lower_cardinality_of_association__0__treated_as__1__because_the_child_element_is__set__content_model_, setModel.ParentAssociation);
            }
            if (setModel.ParentAssociation.Upper > 1)
            {
                Log.AddErrorFormat(LogMessages.Upper_cardinality_of_association__0__treated_as__1__because_the_child_element_is__set__content_model_, setModel.ParentAssociation);
            }

            if (setModel.ParentAssociation.Lower == 0)
            {
                followedAssociations = shuffled.RandomDelete();
            }
            else
            {
                followedAssociations = shuffled;
            }
            foreach (PSMAssociation followedAssociation in followedAssociations)
            {
                TranslateAssociation(followedAssociation, context);
            }
        }
コード例 #2
0
        public override bool CanExecute()
        {
            if (!(schemaGuid != Guid.Empty &&
                  Project.VerifyComponentType <PSMSchema>(schemaGuid) &&
                  cmodelGuid != Guid.Empty &&
                  Project.VerifyComponentType <PSMContentModel>(cmodelGuid)))
            {
                ErrorDescription = CommandErrors.CMDERR_INPUT_TYPE_MISMATCH;
                return(false);
            }

            PSMContentModel cm = Project.TranslateComponent <PSMContentModel>(cmodelGuid);

            if (cm.ChildPSMAssociations.Count > 0)
            {
                ErrorDescription = CommandErrors.CMDERR_CONTENT_MODEL_NOT_EMPTY;
                return(false);
            }
            if (cm.ParentAssociation != null)
            {
                ErrorDescription = CommandErrors.CMDERR_CONTENT_MODEL_NOT_ROOT;
                return(false);
            }

            return(true);
        }
コード例 #3
0
        public new static bool TestCandidate(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMContentModel psmContentModel  = (PSMContentModel)candidate;
            PSMContentModel psmContentModelO = (PSMContentModel)candidate.GetInVersion(oldVersion);

            return(ExistingTest(candidate, oldVersion, newVersion) && psmContentModel.Type != psmContentModelO.Type);
        }
コード例 #4
0
        protected override void TranslateChoiceContentModel(PSMContentModel choiceModel, DataGeneratorContext context)
        {
            TranslateComments(choiceModel, context);
            PSMAssociation chosenAssociation = choiceModel.ChildPSMAssociations.ChooseOneRandomly();

            TranslateAssociation(chosenAssociation, context);
        }
コード例 #5
0
ファイル: Normalizer.cs プロジェクト: mff-uk/exolutio
 private StackedCommand GetNormalizationCommand(PSMSchema schema)
 {
     // (d) Content model association normalization
     if (!modelVerifier.TestSchemaClassChildrenAreClasses(schema))
     {
         PSMContentModel         cm      = (PSMContentModel)modelVerifier.LastViolatingComponent;
         cmdDeletePSMAssociation command = new cmdDeletePSMAssociation(Controller);
         command.Set(cm.ParentAssociation.ID);
         return(command);
     } // (c) Empty name association
     else if (!modelVerifier.TestSchemaClassChildrenNames(schema))
     {
         PSMAssociation          a       = (PSMAssociation)modelVerifier.LastViolatingComponent;
         cmdDeletePSMAssociation command = new cmdDeletePSMAssociation(Controller);
         command.Set(a.ID);
         return(command);
     } // (e) Root content model normalization
     else if (!modelVerifier.TestRootsAreNotContentModels(schema))
     {
         PSMContentModel cm = (PSMContentModel)modelVerifier.LastViolatingComponent;
         MacroCommand    m  = new MacroCommand(Controller);
         foreach (PSMAssociation childPsmAssociation in cm.ChildPSMAssociations)
         {
             cmdDeletePSMAssociation delA = new cmdDeletePSMAssociation(Controller);
             delA.Set(childPsmAssociation.ID);
             m.Commands.Add(delA);
         }
         cmdDeletePSMContentModel delCM = new cmdDeletePSMContentModel(Controller);
         delCM.Set(cm.ID);
         m.Commands.Add(delCM);
         return(m);
     } // (f) Root class normalization
     else if (!modelVerifier.TestRootsAreReferenced(schema))
     {
         PSMClass c = (PSMClass)modelVerifier.LastViolatingComponent;
         cmdDeleteRootPSMClass command = new cmdDeleteRootPSMClass(Controller);
         command.Set(c.ID);
         return(command);
     } // (a) Cardinality normalization
     else if (!modelVerifier.TestSchemaClassChildrenCardinality(schema))
     {
         PSMAssociation a = (PSMAssociation)modelVerifier.LastViolatingComponent;
         cmdUpdatePSMAssociationCardinality command = new cmdUpdatePSMAssociationCardinality(Controller);
         command.Set(a.ID, 1, 1);
         return(command);
     } // (b) Name normalization
     else if (!modelVerifier.TestContentModelsAssociationNames(schema))
     {
         PSMAssociation     a       = (PSMAssociation)modelVerifier.LastViolatingComponent;
         cmdRenameComponent command = new cmdRenameComponent(Controller)
         {
             ComponentGuid = a.ID, NewName = String.Empty
         };
         return(command);
     }
     else
     {
         throw new InvalidOperationException("Schema is already normalized. ");
     }
 }
コード例 #6
0
        internal override CommandBase.OperationResult UndoOperation()
        {
            PSMContentModel cm = Project.TranslateComponent <PSMContentModel>(cmodelGuid);

            cm.Type = oldtype;
            return(OperationResult.OK);
        }
コード例 #7
0
        public new static bool TestCandidate(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMContentModel psmContentModel  = (PSMContentModel)candidate;
            PSMContentModel psmContentModelO = (PSMContentModel)candidate.GetInVersion(oldVersion);

            return(ExistingTest(candidate, oldVersion, newVersion) &&
                   !AreLinked(psmContentModelO.ParentAssociation, psmContentModel.ParentAssociation));
        }
コード例 #8
0
        internal override void CommandOperation()
        {
            PSMContentModel cm = Project.TranslateComponent <PSMContentModel>(cmodelGuid);

            oldtype = cm.Type;
            cm.Type = newtype;
            Report  = new CommandReport(CommandReports.PSM_component_deleted, cm);
        }
コード例 #9
0
 private RegularExpression RewriteDownCM(PSMContentModel contentModel, CompoundRegularExpression result)
 {
     foreach (PSMAssociation association in contentModel.ChildPSMAssociations)
     {
         result.Compounds.Add(RewriteDownAssociation(association));
     }
     return(result);
 }
コード例 #10
0
        public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMContentModel psmContentModel = ((PSMContentModel)candidate);

            return(new ContentModelAddedInstance(candidate, oldVersion, newVersion)
            {
                ParentAssociation = psmContentModel.ParentAssociation
            });
        }
コード例 #11
0
        internal override CommandBase.OperationResult UndoOperation()
        {
            PSMSchema       s  = Project.TranslateComponent <PSMSchema>(schemaGuid);
            PSMContentModel cm = Project.TranslateComponent <PSMContentModel>(ContentModelGuid);

            Project.TranslateComponent <PSMSchema>(schemaGuid).Roots.Remove(cm);
            Project.TranslateComponent <PSMSchema>(schemaGuid).PSMContentModels.Remove(cm);
            Project.mappingDictionary.Remove(cm);
            return(OperationResult.OK);
        }
コード例 #12
0
        internal override CommandBase.OperationResult UndoOperation()
        {
            PSMSchema       s  = Project.TranslateComponent <PSMSchema>(schemaGuid);
            PSMContentModel cm = new PSMContentModel(Project, cmodelGuid, s, rootIndex);

            cm.Type = type;

            //s.RegisterPSMRoot(cm, rootIndex); //Already done in the constructor

            return(OperationResult.OK);
        }
コード例 #13
0
        public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMContentModel psmContentModel  = (PSMContentModel)candidate;
            PSMContentModel psmContentModelO = (PSMContentModel)candidate.GetInVersion(oldVersion);

            return(new ContentModelMovedInstance(candidate, oldVersion, newVersion)
            {
                NewParentAssociation = psmContentModel.ParentAssociation,
                OldParentAssociation = psmContentModelO.ParentAssociation
            });
        }
コード例 #14
0
        public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMContentModel psmContentModel  = (PSMContentModel)candidate;
            PSMContentModel psmContentModelO = (PSMContentModel)candidate.GetInVersion(oldVersion);

            return(new ContentModelTypeChangedInstance(candidate, oldVersion, newVersion)
            {
                OldType = psmContentModelO.Type,
                NewType = psmContentModel.Type
            });
        }
コード例 #15
0
        private void ConvertPSMContentContainer(PSMContentContainer psmContentContainer, PSMElementViewHelper psmElementViewHelper)
        {
            PSMContentModel contentModel;

            if (!TranslatedAlready(psmContentContainer, out contentModel))
            {
                contentModel = new PSMContentModel(evoxProject, psmSchema, false);
                translatedElements[psmContentContainer] = contentModel;
            }

            contentModel.Type = PSMContentModelType.Sequence;
        }
コード例 #16
0
        internal override void GenerateSubCommands()
        {
            PSMContentModel contentModel = Project.TranslateComponent <PSMContentModel>(ContentModelGuid);

            foreach (PSMAssociation a in contentModel.ChildPSMAssociations)
            {
                cmdDeletePSMAssociationRecursive da = new cmdDeletePSMAssociationRecursive(Controller);
                da.Set(a);
                Commands.Add(da);
            }
            Commands.Add(new acmdDeletePSMContentModel(Controller, contentModel));
        }
コード例 #17
0
        private void ConvertPSMClassUnion(PSMClassUnion psmClassUnion, PSMElementViewHelper psmElementViewHelper)
        {
            PSMContentModel contentModel;

            if (!TranslatedAlready(psmClassUnion, out contentModel))
            {
                contentModel = new PSMContentModel(evoxProject, psmSchema, false);
                translatedElements[psmClassUnion] = contentModel;
            }

            contentModel.Type = PSMContentModelType.Choice;
        }
コード例 #18
0
        internal override void CommandOperation()
        {
            PSMSchema       s  = Project.TranslateComponent <PSMSchema>(schemaGuid);
            PSMContentModel cm = Project.TranslateComponent <PSMContentModel>(cmodelGuid);

            type = cm.Type;

            rootIndex = s.Roots.Remove(cm);

            Project.TranslateComponent <PSMSchema>(schemaGuid).PSMContentModels.Remove(cm);
            Project.mappingDictionary.Remove(cm);
            Report = new CommandReport(CommandReports.PSM_component_deleted, cm);
        }
コード例 #19
0
        internal override void CommandOperation()
        {
            if (ContentModelGuid == Guid.Empty)
            {
                ContentModelGuid = Guid.NewGuid();
            }

            PSMSchema       s  = Project.TranslateComponent <PSMSchema>(schemaGuid);
            PSMContentModel cm = new PSMContentModel(Project, ContentModelGuid, s);

            cm.Type = type;

            Report = new CommandReport(CommandReports.PSM_component_added, cm);
        }
コード例 #20
0
        ///// <summary>
        ///// Translates the specializations of <paramref name="generalClass"/>. Calls
        ///// <see cref="TranslateSpecialization"/> for each specialization of <paramref name="generalClass"/>.
        ///// </summary>
        ///// <seealso cref="Class.Specifications"/>
        ///// <param name="generalClass">The general class.</param>
        ///// <param name="generalTypeName">Name of the general type.</param>
        //protected void TranslateSpecializations(PSMClass generalClass, TypeIdentifier generalTypeName)
        //{
        //    foreach (Generalization specialization in generalClass.Specifications)
        //    {
        //        TranslateSpecialization(specialization, generalTypeName);
        //    }
        //}

        ///// <summary>
        ///// Translates the <paramref name="specialization"/>.
        ///// </summary>
        ///// <remarks>
        ///// Could call <see cref="TranslateClass"/> for <paramref name="specialization"/>'s
        ///// <see cref="Generalization.Specific"/> class to translate the specializing class the
        ///// same way general classes are translated. If this is not the desired behaviour,
        ///// all components of the specializing clases should be translated via
        ///// <see cref="TranslateSubordinateComponent"/> call.
        ///// </remarks>
        ///// <param name="specialization">The translated specialization.</param>
        ///// <param name="generalTypeName">Identifier of the general type.</param>
        //protected virtual void TranslateSpecialization(Generalization specialization, TypeIdentifier generalTypeName) { }

        #endregion

        #region content model

        /// <summary>
        /// Translates the content model component.
        /// </summary>
        /// <remarks>If not redefined, the default implementation calls one of the following according
        /// to the type of the component: <see cref="TranslateSequenceContentModel"/>,
        /// <see cref="TranslateChoiceContentModel"/> or <see cref="TranslateSetContentModel"/>.
        /// </remarks>
        /// <param name="contentModel">The component.</param>
        /// <param name="context">The translation context.</param>
        protected void TranslateContentModel(PSMContentModel contentModel, TContext context)
        {
            switch (contentModel.Type)
            {
            case PSMContentModelType.Sequence:
                TranslateSequenceContentModel(contentModel, context);
                break;

            case PSMContentModelType.Choice:
                TranslateChoiceContentModel(contentModel, context);
                break;

            case PSMContentModelType.Set:
                TranslateSetContentModel(contentModel, context);
                break;
            }
        }
コード例 #21
0
        private RegularExpression RewriteDownSequenceCM(PSMContentModel contentModel)
        {
            SequenceRegularExpression result = new SequenceRegularExpression();

            return(RewriteDownCM(contentModel, result));
        }
コード例 #22
0
ファイル: PSMBridgeClass.cs プロジェクト: mff-uk/exolutio
 public PSMBridgeClass(TypesTable.TypesTable tt, Namespace ns, PSMContentModel sourceContentModel, string registerName)
     : this(tt, ns, GetContentModelOCLName(sourceContentModel))
 {
     this.PSMSource     = sourceContentModel;
     this.PSMSourceType = SourceType.PSMContentModel;
 }
コード例 #23
0
 public virtual TResult ProcessPSMContentModel(PSMContentModel psmContentModel)
 {
     return(DefaultResult);
 }
コード例 #24
0
 /// <summary>
 /// Translates the 'choice' content model.
 /// </summary>
 /// <param name="choiceModel">The 'choice' content model.</param>
 /// <param name="context">The translation context.</param>
 /// <seealso cref="PSMContentModelType.Choice"/>
 protected virtual void TranslateChoiceContentModel(PSMContentModel choiceModel, TContext context)
 {
 }
コード例 #25
0
ファイル: AssociationsUtils.cs プロジェクト: mff-uk/exolutio
        /**
         * Vraci vsechny asociace, ktere nejak ovlivnuji konecny automat vytvareny pro asociaci topAssociation.
         **/
        public static List <PSMAssociation> getAllAssociations(PSMAssociation topAssociation)
        {
            List <PSMAssociation> resultAssociations = new List <PSMAssociation>();

            // 1. vytovrime fake set s vlastnimi @atributy child tridy
            if (topAssociation.Child is PSMClass)
            {
                PSMClass        firstClass = (PSMClass)topAssociation.Child;
                PSMContentModel fakeSet    = new PSMContentModel(topAssociation.Project, Guid.NewGuid());
                fakeSet.Type = PSMContentModelType.Set;
                PSMAssociation associationToSet = new PSMAssociation(topAssociation.Project, Guid.NewGuid());
                associationToSet.Name  = "";
                associationToSet.Lower = 1;
                associationToSet.Upper = 1;
                foreach (PSMAttribute attribute in firstClass.GetActualPSMAttributes())
                {
                    if (!attribute.Element)
                    {
                        PSMAssociation associationFromSet = new PSMAssociation(topAssociation.Project, Guid.NewGuid());
                        associationFromSet.Lower = 1;
                        associationFromSet.Upper = 1;
                        associationFromSet.Name  = "";
                        PSMClass fakeAttributeClass = new PSMClass(topAssociation.Project, Guid.NewGuid());
                        fakeAttributeClass.PSMAttributes.Add(attribute);
                        fakeAttributeClass.ParentAssociation = associationFromSet;
                        associationFromSet.Child             = fakeAttributeClass;
                        fakeSet.ChildPSMAssociations.Add(associationFromSet);
                    }
                }
                associationToSet.Child = fakeSet;
                if (fakeSet.ChildPSMAssociations.Count > 0)
                {
                    resultAssociations.Add(associationToSet);
                }
            }
            // 2. pridame asociace propagujci @atributy
            resultAssociations.AddRange(associationsPropagatingAttributes(topAssociation, false));
            resultAssociations.Add(null);
            // 3. pridame asociace na element atributy
            if (topAssociation.Child is PSMClass)
            {
                foreach (PSMAttribute attribute in ((PSMClass)topAssociation.Child).GetActualPSMAttributes())
                {
                    if (attribute.Element)
                    {
                        PSMAssociation association = new PSMAssociation(topAssociation.Project, Guid.NewGuid());
                        association.Lower = attribute.Lower;
                        association.Upper = attribute.Upper;
                        association.Name  = attribute.Name;
                        PSMClass fakeAttributeClass = new PSMClass(topAssociation.Project, Guid.NewGuid());
                        fakeAttributeClass.PSMAttributes.Add(attribute);
                        fakeAttributeClass.ParentAssociation = association;
                        association.Child = fakeAttributeClass;
                        resultAssociations.Add(association);
                    }
                }
            }
            // 4. pridame asociace propagujici element atributy
            resultAssociations.AddRange(associationsPropagatingAttributes(topAssociation, true));
            resultAssociations.Add(null);
            // 5. ostatni asociace
            resultAssociations.AddRange(associationsPropagatingElements(topAssociation));

            return(resultAssociations);
        }
コード例 #26
0
 private static void CheckPSMContentModel(PSMContentModel psmContentModel)
 {
     CheckPSMAssociationMember(psmContentModel);
 }
コード例 #27
0
 public virtual void ProcessPSMContentModel(PSMContentModel psmContentModel, ref TContext context)
 {
     ProcessPSMAssociationMember(psmContentModel, ref context);
 }
コード例 #28
0
 protected override void TranslateSequenceContentModel(PSMContentModel sequenceModel, DataGeneratorContext context)
 {
     TranslateComments(sequenceModel, context);
     TranslateContent(sequenceModel, context);
 }
コード例 #29
0
 /// <summary>
 /// Translates the 'sequence' content model.
 /// </summary>
 /// <param name="sequenceModel">The 'sequence' content model.</param>
 /// <param name="context">The translation context.</param>
 /// <seealso cref="PSMContentModelType.Choice"/>
 protected virtual void TranslateSequenceContentModel(PSMContentModel sequenceModel, TContext context)
 {
 }
コード例 #30
0
 /// <summary>
 /// Translates the 'set' content model.
 /// </summary>
 /// <param name="setModel">The 'set' content model.</param>
 /// <param name="context">The translation context.</param>
 /// <seealso cref="PSMContentModelType.Set"/>
 protected virtual void TranslateSetContentModel(PSMContentModel setModel, TContext context)
 {
 }