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); } }
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); }
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); }
protected override void TranslateChoiceContentModel(PSMContentModel choiceModel, DataGeneratorContext context) { TranslateComments(choiceModel, context); PSMAssociation chosenAssociation = choiceModel.ChildPSMAssociations.ChooseOneRandomly(); TranslateAssociation(chosenAssociation, context); }
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. "); } }
internal override CommandBase.OperationResult UndoOperation() { PSMContentModel cm = Project.TranslateComponent <PSMContentModel>(cmodelGuid); cm.Type = oldtype; return(OperationResult.OK); }
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)); }
internal override void CommandOperation() { PSMContentModel cm = Project.TranslateComponent <PSMContentModel>(cmodelGuid); oldtype = cm.Type; cm.Type = newtype; Report = new CommandReport(CommandReports.PSM_component_deleted, cm); }
private RegularExpression RewriteDownCM(PSMContentModel contentModel, CompoundRegularExpression result) { foreach (PSMAssociation association in contentModel.ChildPSMAssociations) { result.Compounds.Add(RewriteDownAssociation(association)); } return(result); }
public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion) { PSMContentModel psmContentModel = ((PSMContentModel)candidate); return(new ContentModelAddedInstance(candidate, oldVersion, newVersion) { ParentAssociation = psmContentModel.ParentAssociation }); }
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); }
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); }
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 }); }
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 }); }
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; }
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)); }
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; }
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); }
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); }
///// <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; } }
private RegularExpression RewriteDownSequenceCM(PSMContentModel contentModel) { SequenceRegularExpression result = new SequenceRegularExpression(); return(RewriteDownCM(contentModel, result)); }
public PSMBridgeClass(TypesTable.TypesTable tt, Namespace ns, PSMContentModel sourceContentModel, string registerName) : this(tt, ns, GetContentModelOCLName(sourceContentModel)) { this.PSMSource = sourceContentModel; this.PSMSourceType = SourceType.PSMContentModel; }
public virtual TResult ProcessPSMContentModel(PSMContentModel psmContentModel) { return(DefaultResult); }
/// <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) { }
/** * 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); }
private static void CheckPSMContentModel(PSMContentModel psmContentModel) { CheckPSMAssociationMember(psmContentModel); }
public virtual void ProcessPSMContentModel(PSMContentModel psmContentModel, ref TContext context) { ProcessPSMAssociationMember(psmContentModel, ref context); }
protected override void TranslateSequenceContentModel(PSMContentModel sequenceModel, DataGeneratorContext context) { TranslateComments(sequenceModel, context); TranslateContent(sequenceModel, context); }
/// <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) { }
/// <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) { }