public FakeAttributeCollection(ObservableCollection <FakePSMAttribute> attributesList, PSMClass psmClass, TypeFinder typeFinder) : base(attributesList) { foreach (PSMAttribute psmAttribute in psmClass.PSMAttributes) { attributesList.Add(new FakePSMAttribute(psmAttribute)); } bool classEmpty = psmClass.PSMAttributes.Count == 0; PSMClass nearestInterpretedClass = psmClass.NearestInterpretedClass(); if (nearestInterpretedClass != null) { foreach (PIMAttribute attribute in ((PIMClass)nearestInterpretedClass.Interpretation).PIMAttributes) { if (!attributesList.Any(p => p.SourceAttribute != null && p.SourceAttribute.Interpretation == attribute)) { attributesList.Add(new FakePSMAttribute(attribute, typeFinder) { Checked = classEmpty }); } } } }
public override bool CanExecute() { if (!(representant != Guid.Empty && Project.VerifyComponentType <PSMClass>(representant))) { ErrorDescription = CommandErrors.CMDERR_INPUT_TYPE_MISMATCH; return(false); } if (represented == Guid.Empty) { return(true); } PSMClass representantClass = Project.TranslateComponent <PSMClass>(representant); PSMClass representedClass = Project.TranslateComponent <PSMClass>(represented); if (representantClass.Interpretation != representedClass.Interpretation) { ErrorDescription = CommandErrors.CMDERR_NOT_SAME_INTERPRETATION; return(false); } if (representedClass.RepresentedClass == representantClass || representedClass == representantClass || representedClass.GetSRs().Contains(representantClass)) { ErrorDescription = CommandErrors.CMDERR_CYCLIC_REPR; return(false); } PSMClass representedNIC = representedClass.NearestInterpretedClass(); PSMClass representantNIC = representantClass.NearestInterpretedClass(); if (representedNIC == null && representantNIC == null) { return(true); } if (representedNIC == null || representantNIC == null) { ErrorDescription = CommandErrors.CMDERR_REPR_DIFFERENT_CONTEXT; return(false); } if (representedNIC.Interpretation == representantNIC.Interpretation) { return(true); } else { ErrorDescription = CommandErrors.CMDERR_REPR_DIFFERENT_CONTEXT; return(false); } }
internal override PropagationMacroCommand PostPropagation() { PSMAttribute psmAttribute = Project.TranslateComponent <PSMAttribute>(attributeGuid); PSMClass oldClass = Project.TranslateComponent <PSMClass>(oldClassGuid); PSMClass newClass = Project.TranslateComponent <PSMClass>(newClassGuid); if (newClass.RepresentedClass == oldClass || oldClass.RepresentedClass == newClass) { return(null); } if (psmAttribute.Interpretation == null) { return(null); } PSMClass oldIntContext = oldClass.NearestInterpretedClass(); PSMClass newIntContext = newClass.NearestInterpretedClass(); if (oldIntContext == newIntContext) { return(null); } PropagationMacroCommand command = new PropagationMacroCommand(Controller) { CheckFirstOnlyInCanExecute = true }; command.Report = new CommandReport("Post-propagation (move PSM attribute)"); if (newIntContext == null) { command.Commands.Add(new acmdSetPSMAttributeInterpretation(Controller, psmAttribute, Guid.Empty)); } else { command.Commands.Add(new acmdMovePIMAttribute(Controller, psmAttribute.Interpretation, newIntContext.Interpretation) { PropagateSource = psmAttribute }); } return(command); }
public override bool CanExecute() { if (ParentPSMClassGuid == Guid.Empty || PIMAssociationEndGuid == Guid.Empty) { return(false); } PSMClass parent = Project.TranslateComponent <PSMClass>(ParentPSMClassGuid); PIMAssociationEnd associationEnd = Project.TranslateComponent <PIMAssociationEnd>(PIMAssociationEndGuid); PSMClass nic = parent.NearestInterpretedClass(); if (nic == null) { return(false); } if (!(nic.Interpretation as PIMClass).GetAssociationsWithIncludeInherited(associationEnd.PIMClass).Contains(associationEnd.PIMAssociation)) { return(false); } return(true); }
public FakeAssociationCollection(ObservableCollection <FakePSMAssociation> associationList, PSMClass psmClass) : base(associationList) { foreach (PSMAssociation psmAssociation in psmClass.ChildPSMAssociations) { associationList.Add(new FakePSMAssociation(psmAssociation)); } bool classEmpty = psmClass.ChildPSMAssociations.Count == 0; PSMClass nearestInterpretedClass = psmClass.NearestInterpretedClass(); if (nearestInterpretedClass != null) { foreach (PIMAssociationEnd associationEnd in ((PIMClass)nearestInterpretedClass.Interpretation).PIMAssociationEnds) { PIMAssociation pimAssociation = associationEnd.PIMAssociation; if (!associationList.Any(p => p.SourceAssociation != null && p.SourceAssociation.Interpretation == pimAssociation)) { foreach (PIMAssociationEnd otherEnd in pimAssociation.PIMAssociationEnds) { if (otherEnd.PIMClass == nearestInterpretedClass.Interpretation) { continue; } associationList.Add(new FakePSMAssociation(pimAssociation) { Checked = false, SourcePIMAssociationEnd = otherEnd }); } } } } }
public void Initialize(Controller.Controller controller, PSMClass psmClass, PSMAttribute initialSelectedAttribute = null) { this.controller = controller; this.psmClass = psmClass; this.Title = string.Format("PSM class: {0}", psmClass); tbName.Text = psmClass.Name; #region attributes typeColumn.ItemsSource = psmClass.PSMSchema.GetAvailablePSMTypes(); PSMClass nearestInterpretedClass = psmClass.NearestInterpretedClass(); if (nearestInterpretedClass != null) { CompositeCollection coll = new CompositeCollection(); //coll.Add("(None)"); coll.Add(new CollectionContainer { Collection = ((PIMClass)nearestInterpretedClass.Interpretation).PIMAttributes }); interpretationColumn.ItemsSource = coll; } ObservableCollection <FakePSMAttribute> fakeAttributesList = new ObservableCollection <FakePSMAttribute>(); TypeFinder tf = TryFindSuitablePIMType; fakeAttributes = new FakeAttributeCollection(fakeAttributesList, psmClass, tf); fakeAttributesList.CollectionChanged += delegate { UpdateApplyEnabled(); }; gridAttributes.ItemsSource = fakeAttributesList; #endregion #region associatiosn if (nearestInterpretedClass != null) { CompositeCollection coll = new CompositeCollection(); //coll.Add("(None)"); coll.Add(new CollectionContainer { Collection = ((PIMClass)nearestInterpretedClass.Interpretation).PIMAssociationEnds.Select(e => e.PIMAssociation) }); interpretationAssociation.ItemsSource = coll; } ObservableCollection <FakePSMAssociation> fakeAssociationsList = new ObservableCollection <FakePSMAssociation>(); fakeAssociations = new FakeAssociationCollection(fakeAssociationsList, psmClass); fakeAssociationsList.CollectionChanged += delegate { UpdateApplyEnabled(); }; gridAssociations.ItemsSource = fakeAssociationsList; #endregion if (initialSelectedAttribute != null) { gridAttributes.SelectedItem = fakeAttributesList.SingleOrDefault(fa => fa.SourceAttribute == initialSelectedAttribute); } dialogReady = true; }