internal override void GenerateSubCommands() { if (NewGuids == null) { List <Guid> guids = new List <Guid>(); for (int i = 0; i < Count; i++) { guids.Add(Guid.NewGuid()); } NewGuids = guids; } PIMAttribute original = Project.TranslateComponent <PIMAttribute>(PIMAttributeGuid); uint counter = 0; foreach (Guid newAttributeGuid in NewGuids) { counter++; Commands.Add(new acmdNewPIMAttribute(Controller, original.PIMClass, original.PIMSchema) { AttributeGuid = newAttributeGuid }); Commands.Add(new acmdRenameComponent(Controller, newAttributeGuid, original.Name + counter)); Commands.Add(new acmdUpdatePIMAttributeCardinality(Controller, newAttributeGuid, original.Lower, original.Upper)); Commands.Add(new acmdUpdatePIMAttributeType(Controller, newAttributeGuid, original.AttributeType)); } Commands.Add(new acmdSynchroPIMAttributes(Controller) { X1 = Enumerable.Repeat(original.ID, 1).ToList(), X2 = NewGuids.ToList() }); Commands.Add(new cmdDeletePIMAttribute(Controller) { AttributeGuid = original }); }
internal override void GenerateSubCommands() { if (NewGuids == null) { List <Tuple <Guid, Guid, Guid> > guids = new List <Tuple <Guid, Guid, Guid> >(); for (int i = 0; i < Count; i++) { guids.Add(new Tuple <Guid, Guid, Guid>(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid())); } NewGuids = guids; } PIMAssociation original = Project.TranslateComponent <PIMAssociation>(PIMAssociationGuid); PIMAssociationEnd originalEnd1 = original.PIMAssociationEnds.First(); PIMAssociationEnd originalEnd2 = original.PIMAssociationEnds.Last(); int counter = 0; foreach (Tuple <Guid, Guid, Guid> t in NewGuids) { counter++; Guid newAssociationGuid = t.Item1; Guid newAssociationEnd1Guid = t.Item2; Guid newAssociationEnd2Guid = t.Item3; Commands.Add(new acmdNewPIMAssociation(Controller, originalEnd1.PIMClass, newAssociationEnd1Guid, originalEnd2.PIMClass, newAssociationEnd2Guid, original.PIMSchema) { AssociationGuid = newAssociationGuid }); Commands.Add(new acmdRenameComponent(Controller, newAssociationGuid, original.Name + counter)); Commands.Add(new acmdRenameComponent(Controller, newAssociationEnd1Guid, originalEnd1.Name)); Commands.Add(new acmdRenameComponent(Controller, newAssociationEnd2Guid, originalEnd2.Name)); Commands.Add(new acmdUpdatePIMAssociationEndCardinality(Controller, newAssociationEnd1Guid, originalEnd1.Lower, originalEnd1.Upper)); Commands.Add(new acmdUpdatePIMAssociationEndCardinality(Controller, newAssociationEnd2Guid, originalEnd2.Lower, originalEnd2.Upper)); foreach (PIMDiagram d in Project.SingleVersion.PIMDiagrams) { if (d.PIMComponents.Contains(original)) { Commands.Add(new acmdAddComponentToDiagram(Controller, newAssociationGuid, d)); } } } Commands.Add(new acmdSynchroPIMAssociations(Controller) { X1 = Enumerable.Repeat(original.ID, 1).ToList(), X2 = NewGuids.Select(t => t.Item1).ToList() }); Commands.Add(new cmdDeletePIMAssociation(Controller) { AssociationGuid = original }); }
internal override void GenerateSubCommands() { if (NewGuids == null) { List <Tuple <Guid, Guid> > guids = new List <Tuple <Guid, Guid> >(); for (int i = 0; i < Count; i++) { guids.Add(new Tuple <Guid, Guid>(Guid.NewGuid(), Guid.NewGuid())); } NewGuids = guids; } PSMAssociation original = Project.TranslateComponent <PSMAssociation>(PSMAssociationGuid); PSMClass originalChild = original.Child as PSMClass; int counter = 0; foreach (Tuple <Guid, Guid> t in NewGuids) { counter++; Guid classGuid = t.Item1; Guid associationGuid = t.Item2; Commands.Add(new acmdNewPSMClass(Controller, original.PSMSchema) { ClassGuid = classGuid }); Commands.Add(new acmdRenameComponent(Controller, classGuid, originalChild.Name + counter)); Commands.Add(new acmdSetPSMClassInterpretation(Controller, classGuid, originalChild.Interpretation)); Commands.Add(new acmdSetRepresentedClass(Controller, classGuid, originalChild)); Commands.Add(new acmdNewPSMAssociation(Controller, original.Parent, classGuid, original.PSMSchema) { AssociationGuid = associationGuid }); Commands.Add(new acmdRenameComponent(Controller, associationGuid, original.Name + counter)); Commands.Add(new acmdUpdatePSMAssociationCardinality(Controller, associationGuid, original.Lower, original.Upper)); } if ((original.Parent is PSMContentModel) || ((original.Parent is PSMClass) && original.Parent.Interpretation == null)) { PSMClass nic = original.Parent.NearestInterpretedParentClass(); if (nic == null) { Commands.Add(new cmdReconnectPSMAssociation(Controller) { AssociationGuid = original, NewParentGuid = original.PSMSchema.PSMSchemaClass }); foreach (Tuple <Guid, Guid> t in NewGuids) { Guid associationGuid = t.Item2; Commands.Add(new cmdReconnectPSMAssociation(Controller) { AssociationGuid = associationGuid, NewParentGuid = original.PSMSchema.PSMSchemaClass }); } } else { Commands.Add(new cmdReconnectPSMAssociation(Controller) { AssociationGuid = original, NewParentGuid = nic }); foreach (Tuple <Guid, Guid> t in NewGuids) { Guid associationGuid = t.Item2; Commands.Add(new cmdReconnectPSMAssociation(Controller) { AssociationGuid = associationGuid, NewParentGuid = nic }); } } } Commands.Add(new acmdSynchroPSMAssociations(Controller) { X1 = Enumerable.Repeat(original.ID, 1).ToList(), X2 = NewGuids.Select(t => t.Item2).ToList() }); if ((original.Parent is PSMContentModel) || ((original.Parent is PSMClass) && original.Parent.Interpretation == null)) { Commands.Add(new cmdReconnectPSMAssociation(Controller) { AssociationGuid = original, NewParentGuid = original.Parent }); foreach (Tuple <Guid, Guid> t in NewGuids) { Guid associationGuid = t.Item2; Commands.Add(new cmdReconnectPSMAssociation(Controller) { AssociationGuid = associationGuid, NewParentGuid = original.Parent }); } } Commands.Add(new cmdDeletePSMAssociation(Controller) { AssociationGuid = original }); }