public void Set(Guid associationGuid, string name, uint lower, UnlimitedInt upper) { AssociationGuid = associationGuid; Name = name; Lower = lower; Upper = upper; }
public acmdUpdatePIMAssociationEndCardinality(Controller c, Guid cardinalityOwnerGuid, uint lower, UnlimitedInt upper) : base(c) { ComponentGuid = cardinalityOwnerGuid; newLower = lower; newUpper = upper; }
public acmdUpdatePSMAttributeCardinality(Controller c, Guid cardinalityOwnerGuid, uint lower, UnlimitedInt upper) : base(c) { componentGuid = cardinalityOwnerGuid; newLower = lower; newUpper = upper; }
public void Set(Guid attributeGuid, Guid attributeTypeGuid, string name, uint lower, UnlimitedInt upper, string defaultValue) { AttributeGuid = attributeGuid; Name = name; Lower = lower; Upper = upper; AttributeTypeGuid = attributeTypeGuid; DefaultValue = defaultValue; }
public void Set(Guid psmClassGuid, Guid attributeTypeGuid, string name, uint lower, UnlimitedInt upper, bool element) { Name = name; Lower = lower; Upper = upper; AttributeTypeGuid = attributeTypeGuid; PSMClassGuid = psmClassGuid; Element = element; }
internal override void CommandOperation() { IHasCardinality owner = Project.TranslateComponent <Component>(ComponentGuid) as IHasCardinality; string oldCardinality = owner.CardinalityString; oldLower = owner.Lower; oldUpper = owner.Upper; owner.Lower = newLower; owner.Upper = newUpper; Report = new CommandReport(CommandReports.CARDINALITY_CHANGED, owner, oldCardinality, owner.CardinalityString); }
public static string EncodeValue(UnlimitedInt upper) { if (upper.IsInfinity) { return("*"); } else { return(EncodeValue(upper.Value)); } }
public void Set(string name, Guid pimClassGuid1, uint lower1, UnlimitedInt upper1, string role1, Guid pimClassGuid2, uint lower2, UnlimitedInt upper2, string role2) { Name = name; PIMClassGuid1 = pimClassGuid1; Lower1 = lower1; Upper1 = upper1; Role1 = role1; PIMClassGuid2 = pimClassGuid2; Lower2 = lower2; Upper2 = upper2; Role2 = role2; }
private bool ApplyAttributeChanges() { #region check for deleted attributes foreach (PSMAttribute psmAttribute in psmClass.PSMAttributes) { bool found = false; foreach (FakePSMAttribute fakeAttribute in fakeAttributes) { if (fakeAttribute.SourceAttribute == psmAttribute && fakeAttribute.Checked) { found = true; break; } else if (fakeAttribute.SourceAttribute == psmAttribute && !fakeAttribute.Checked) { fakeAttribute.SourceAttribute = null; } } if (!found) { Controller.Commands.Complex.PSM.cmdDeletePSMAttribute deleteCommand = new Controller.Commands.Complex.PSM.cmdDeletePSMAttribute(controller); deleteCommand.Set(psmAttribute); controller.CreatedMacro.Commands.Add(deleteCommand); } } #endregion // check for changes and new attributes var modified = from FakePSMAttribute a in fakeAttributes where a.SourceAttribute != null && a.SomethingChanged() select a; var added = from FakePSMAttribute a in fakeAttributes where a.SourceAttribute == null select a; #region editing exisiting attribute foreach (FakePSMAttribute modifiedAttribute in modified) { PSMAttribute sourceAttribute = modifiedAttribute.SourceAttribute; uint lower; UnlimitedInt upper; if ( !IHasCardinalityExt.ParseMultiplicityString(modifiedAttribute.Multiplicity, out lower, out upper)) { error = true; } cmdUpdatePSMAttribute updateCommand = new cmdUpdatePSMAttribute(controller); updateCommand.Set(sourceAttribute, modifiedAttribute.Type, modifiedAttribute.Name, lower, upper, modifiedAttribute.XFormElement, modifiedAttribute.DefaultValue); updateCommand.InterpretedAttribute = modifiedAttribute.RepresentedAttribute; controller.CreatedMacro.Commands.Add(updateCommand); } #endregion #region new attribute foreach (FakePSMAttribute addedAttribute in added) { if (!string.IsNullOrEmpty(addedAttribute.Name) && addedAttribute.Checked) { uint lower = 1; UnlimitedInt upper = 1; if (!String.IsNullOrEmpty(addedAttribute.Multiplicity)) { if (!IHasCardinalityExt.ParseMultiplicityString(addedAttribute.Multiplicity, out lower, out upper)) { error = true; } } Exolutio.Controller.Commands.Complex.PSM.cmdCreateNewPSMAttribute createNewPsmAttribute = new Exolutio.Controller.Commands.Complex.PSM.cmdCreateNewPSMAttribute(controller); createNewPsmAttribute.Set(psmClass, addedAttribute.Type, addedAttribute.Name, lower, upper, addedAttribute.XFormElement); createNewPsmAttribute.AttributeGuid = Guid.NewGuid(); addedAttribute.AddedAttributeID = createNewPsmAttribute.AttributeGuid; if (addedAttribute.RepresentedAttribute != null) { createNewPsmAttribute.InterpretedAttribute = addedAttribute.RepresentedAttribute; } controller.CreatedMacro.Commands.Add(createNewPsmAttribute); } } #endregion #region ordering { List <Guid> ordering = new List <Guid>(); foreach (FakePSMAttribute attribute in fakeAttributes) { if (attribute.SourceAttribute != null) { ordering.Add(attribute.SourceAttribute.ID); } else if (attribute.AddedAttributeID != Guid.Empty) { ordering.Add(attribute.AddedAttributeID); } } cmdReorderComponents <PSMAttribute> reorderCommand = new cmdReorderComponents <PSMAttribute>(controller) { ComponentGuids = ordering, OwnerCollection = psmClass.PSMAttributes }; controller.CreatedMacro.Commands.Add(reorderCommand); } #endregion return(!error); }
private bool ApplyAssociationChanges() { #region check for deleted associations foreach (PSMAssociation psmAssociation in psmClass.ChildPSMAssociations) { bool found = false; foreach (FakePSMAssociation fakeAssociation in fakeAssociations) { if (fakeAssociation.SourceAssociation == psmAssociation && fakeAssociation.Checked) { found = true; break; } else if (fakeAssociation.SourceAssociation == psmAssociation && !fakeAssociation.Checked) { fakeAssociation.SourceAssociation = null; } } if (!found) { MessageBoxResult result = ExolutioYesNoBox.Show("Cut or delete", string.Format("Click 'Yes' if you want to delete the association '{0}' with the whole subtree.\nClick 'No' if you want to delete the association and make the subtree a new tree. ", psmAssociation)); if (result == MessageBoxResult.No) { Exolutio.Controller.Commands.Complex.PSM.cmdDeletePSMAssociation deleteCommand = new Exolutio.Controller.Commands.Complex.PSM.cmdDeletePSMAssociation(controller); deleteCommand.Set(psmAssociation); controller.CreatedMacro.Commands.Add(deleteCommand); } else if (result == MessageBoxResult.Yes) { cmdDeletePSMAssociationRecursive deleteCommand = new cmdDeletePSMAssociationRecursive(controller); deleteCommand.Set(psmAssociation); controller.CreatedMacro.Commands.Add(deleteCommand); } else { return(false); } } } #endregion // check for changes and new associations var modified = from FakePSMAssociation a in fakeAssociations where a.SourceAssociation != null && a.SomethingChanged() select a; var added = from FakePSMAssociation a in fakeAssociations where a.SourceAssociation == null && a.Checked select a; #region editing exisiting association foreach (FakePSMAssociation modifiedAssociation in modified) { PSMAssociation sourceAssociation = modifiedAssociation.SourceAssociation; uint lower; UnlimitedInt upper; if ( !IHasCardinalityExt.ParseMultiplicityString(modifiedAssociation.Multiplicity, out lower, out upper)) { error = true; return(!error); } cmdUpdatePSMAssociation updateCommand = new cmdUpdatePSMAssociation(controller); updateCommand.Set(sourceAssociation, modifiedAssociation.Name, lower, upper); updateCommand.InterpretedAssociation = modifiedAssociation.RepresentedPIMAssociation; controller.CreatedMacro.Commands.Add(updateCommand); } #endregion #region new association foreach (FakePSMAssociation addedAssociation in added) { uint lower = 1; UnlimitedInt upper = 1; if (!String.IsNullOrEmpty(addedAssociation.Multiplicity)) { if (!IHasCardinalityExt.ParseMultiplicityString(addedAssociation.Multiplicity, out lower, out upper)) { error = true; return(!error); } } if (addedAssociation.RepresentedPIMAssociation == null) { cmdNewPSMClass createNewPSMClass = new cmdNewPSMClass(controller); createNewPSMClass.SchemaGuid = psmClass.Schema; createNewPSMClass.ClassGuid = Guid.NewGuid(); controller.CreatedMacro.Commands.Add(createNewPSMClass); cmdNewPSMAssociation createNewPSMAssociation = new cmdNewPSMAssociation(controller); addedAssociation.AddedAssociationID = Guid.NewGuid(); createNewPSMAssociation.AssociationGuid = addedAssociation.AddedAssociationID; createNewPSMAssociation.Set(psmClass, createNewPSMClass.ClassGuid, psmClass.Schema); controller.CreatedMacro.Commands.Add(createNewPSMAssociation); cmdUpdatePSMAssociation updateCommand = new cmdUpdatePSMAssociation(controller); updateCommand.Set(createNewPSMAssociation.AssociationGuid, addedAssociation.Name, lower, upper); controller.CreatedMacro.Commands.Add(updateCommand); } else { //ExolutioMessageBox.Show("Creating new association", addedAssociation.Name, ""); cmdCreateNewPSMClassAsIntChild createNewPSMAssociation = new cmdCreateNewPSMClassAsIntChild(controller); addedAssociation.AddedAssociationID = Guid.NewGuid(); if (addedAssociation.SourcePIMAssociationEnd == null) { foreach (PIMAssociationEnd otherEnd in addedAssociation.RepresentedPIMAssociation.PIMAssociationEnds) { if (otherEnd.PIMClass == psmClass.Interpretation) { continue; } addedAssociation.SourcePIMAssociationEnd = otherEnd; } } createNewPSMAssociation.Set(psmClass, addedAssociation.SourcePIMAssociationEnd, Guid.Empty, addedAssociation.AddedAssociationID); controller.CreatedMacro.Commands.Add(createNewPSMAssociation); cmdUpdatePSMAssociation updateCommand = new cmdUpdatePSMAssociation(controller); updateCommand.Set(addedAssociation.AddedAssociationID, addedAssociation.Name, lower, upper); controller.CreatedMacro.Commands.Add(updateCommand); } } #endregion #region ordering { List <Guid> ordering = new List <Guid>(); foreach (FakePSMAssociation association in fakeAssociations) { if (association.SourceAssociation != null) { ordering.Add(association.SourceAssociation.ID); } else if (association.AddedAssociationID != Guid.Empty) { ordering.Add(association.AddedAssociationID); } } cmdReorderComponents <PSMAssociation> reorderCommand = new cmdReorderComponents <PSMAssociation>(controller) { ComponentGuids = ordering, OwnerCollection = psmClass.ChildPSMAssociations }; controller.CreatedMacro.Commands.Add(reorderCommand); } #endregion return(!error); }
/// <summary> /// Writes minOccurs and maxOccurs attributes (if parameters are not equal to 1) /// </summary> /// <param name="lower">value for minOccurs attribute</param> /// <param name="upper">value for maxOccurs attribute</param> public static void CardinalityAttributes(this XElement parentElement, uint lower, UnlimitedInt upper) { if (lower != 1) { parentElement.AddAttributeWithValue("minOccurs", lower.ToString()); } if (upper.Value != 1) { if (upper.IsInfinity) { parentElement.AddAttributeWithValue("maxOccurs", "unbounded"); } else { parentElement.AddAttributeWithValue("maxOccurs", upper.ToString()); } } }
public void HandleCardinality(XElement parentElement, uint lower, UnlimitedInt upper) { XElement cardinalityElement = null; if (lower == 1 && upper == 1) { return; } else if (lower == 0 && upper == 1) { // optional cardinalityElement = new XElement(RNG_NAMESPACE + "optional"); } else if (lower == 0 && upper == UnlimitedInt.Infinity) { // zeroOrMore cardinalityElement = new XElement(RNG_NAMESPACE + "zeroOrMore"); } else if (lower == 1 && upper == UnlimitedInt.Infinity) { // oneOrMore cardinalityElement = new XElement(RNG_NAMESPACE + "oneOrMore"); } else { // nonDefaultCardinality // required occurences XElement prev = parentElement; XComment comment = new XComment(string.Format("Here follows expansion of occurence '{0}..{1}'.", lower, upper)); prev.AddBeforeSelf(comment); for (int i = 0; i < lower; i++) { XElement dupl = new XElement(parentElement); prev.AddAfterSelf(dupl); prev = dupl; } // optional occurences if (!upper.IsInfinity) { for (int i = 0; i < (upper.Value - lower); i++) { XElement optional = new XElement(RNG_NAMESPACE + "optional"); XElement dupl = new XElement(parentElement); optional.Add(dupl); prev.AddAfterSelf(optional); prev = optional; } } else { XElement optional = new XElement(RNG_NAMESPACE + "zeroOrMore"); XElement dupl = new XElement(parentElement); optional.Add(dupl); prev.AddAfterSelf(optional); prev = optional; } parentElement.Remove(); } if (cardinalityElement != null) { parentElement.ReplaceWith(cardinalityElement); cardinalityElement.Add(parentElement); } }
public void Set(Guid cardinalityOwnerGuid, uint lower, UnlimitedInt upper) { ComponentGuid = cardinalityOwnerGuid; NewLower = lower; NewUpper = upper; }
private void bApply_Click(object sender, RoutedEventArgs e) { bApply.Focus(); error = false; controller.BeginMacro(); //controller.CreatedMacro.Description = string.Format("PSM Classs '{0}' was updated. ", psmClass); if (tbName.ValueChanged) { acmdRenameComponent renameCommand = new acmdRenameComponent(controller, psmClass, tbName.Text); controller.CreatedMacro.Commands.Add(renameCommand); tbName.ForgetOldValue(); } //if (psmClass.IsAbstract != cbAbstract.IsChecked) //{ // psmClassController.ChangeAbstract(cbAbstract.IsChecked == true); //} //if (psmClass.AllowAnyAttribute != cbAnyAttribute.IsChecked) //{ // psmClassController.ChangeAllowAnyAttributeDefinition(cbAnyAttribute.IsChecked == true); //} #region check for deleted attributes List <PSMAttribute> removedAttributes = new List <PSMAttribute>(); List <FakePSMAttribute> addedAttributes = new List <FakePSMAttribute>(); foreach (PSMAttribute psmAttribute in psmClass.PSMAttributes) { bool found = false; foreach (FakePSMAttribute fakeAttribute in fakeAttributes) { if (fakeAttribute.SourceAttribute == psmAttribute && fakeAttribute.Checked) { found = true; break; } else if (fakeAttribute.SourceAttribute == psmAttribute && !fakeAttribute.Checked) { fakeAttribute.SourceAttribute = null; } } if (!found) { removedAttributes.Add(psmAttribute); cmdDeletePSMAttribute deleteCommand = new cmdDeletePSMAttribute(controller); deleteCommand.Set(psmAttribute); controller.CreatedMacro.Commands.Add(deleteCommand); } } #endregion #region remove dummy entries in fake collection List <FakePSMAttribute> toRemove = new List <FakePSMAttribute>(); foreach (FakePSMAttribute fakeAttribute in fakeAttributes) { if (String.IsNullOrEmpty(fakeAttribute.Name)) { if (fakeAttribute.SourceAttribute != null) { removedAttributes.Add(fakeAttribute.SourceAttribute); cmdDeletePSMAttribute deleteCommand = new cmdDeletePSMAttribute(controller); deleteCommand.Set(fakeAttribute.SourceAttribute); controller.CreatedMacro.Commands.Add(deleteCommand); } toRemove.Add(fakeAttribute); } } foreach (FakePSMAttribute attribute in toRemove) { fakeAttributes.Remove(attribute); } #endregion Dictionary <PSMAttribute, string> namesDict = new Dictionary <PSMAttribute, string>(); foreach (PSMAttribute a in psmClass.PSMAttributes) { if (!removedAttributes.Contains(a)) { namesDict.Add(a, a.Name); } } // check for changes and new attributes var modified = from FakePSMAttribute a in fakeAttributes where a.SourceAttribute != null && !removedAttributes.Contains(a.SourceAttribute) && a.SomethingChanged() select a; var added = from FakePSMAttribute a in fakeAttributes where a.SourceAttribute == null select a; // editing exisiting attribute foreach (FakePSMAttribute modifiedAttribute in modified) { PSMAttribute sourceAttribute = modifiedAttribute.SourceAttribute; uint lower; UnlimitedInt upper; if ( !IHasCardinalityExt.ParseMultiplicityString(modifiedAttribute.Multiplicity, out lower, out upper)) { error = true; } cmdUpdatePSMAttribute updateCommand = new cmdUpdatePSMAttribute(controller); updateCommand.Set(sourceAttribute, modifiedAttribute.Type, modifiedAttribute.Name, lower, upper, modifiedAttribute.XFormElement, modifiedAttribute.DefaultValue); updateCommand.InterpretedAttribute = modifiedAttribute.RepresentedAttribute; controller.CreatedMacro.Commands.Add(updateCommand); namesDict[sourceAttribute] = modifiedAttribute.Name; } List <string> names = namesDict.Values.ToList(); // new attribute foreach (FakePSMAttribute addedAttribute in added) { if (!string.IsNullOrEmpty(addedAttribute.Name) && addedAttribute.Checked) { uint lower = 1; UnlimitedInt upper = 1; if (!String.IsNullOrEmpty(addedAttribute.Multiplicity)) { if (!IHasCardinalityExt.ParseMultiplicityString(addedAttribute.Multiplicity, out lower, out upper)) { error = true; } } cmdCreateNewPSMAttribute createNewPsmAttribute = new cmdCreateNewPSMAttribute(controller); createNewPsmAttribute.Set(psmClass, addedAttribute.Type, addedAttribute.Name, lower, upper, addedAttribute.XFormElement); if (addedAttribute.RepresentedAttribute != null) { createNewPsmAttribute.InterpretedAttribute = addedAttribute.RepresentedAttribute; } controller.CreatedMacro.Commands.Add(createNewPsmAttribute); addedAttributes.Add(addedAttribute); names.Add(addedAttribute.Name); } } if (error) { controller.CancelMacro(); } else { CommandBase tmp = (CommandBase)controller.CreatedMacro; controller.CommitMacro(); if (string.IsNullOrEmpty(tmp.ErrorDescription)) { foreach (FakePSMAttribute attribute in addedAttributes) { if (attribute.RepresentedAttribute != null) { attribute.SourceAttribute = (PSMAttribute)psmClass.PSMAttributes.Where (property => ((PSMAttribute)property). Interpretation == attribute.RepresentedAttribute). SingleOrDefault(); } else { attribute.SourceAttribute = psmClass.PSMAttributes.Where (property => property.Name == attribute.Name).SingleOrDefault(); } //else //{ // attribute.SourceAttribute = (PSMAttribute)psmClassController.Class.AllAttributes.Where // (property => (property.RepresentedAttribute == attribute.RepresentedAttribute).SingleOrDefault(); //} //if (attribute.SourceAttribute.RepresentedAttribute != null) // attribute.RepresentedAttribute = attribute.SourceAttribute.RepresentedAttribute; } addedAttributes.RemoveAll(attribute => attribute.SourceAttribute == null); bApply.IsEnabled = false; dialogReady = true; error = false; } else { error = true; } } //gridAttributes.ItemsSource.Refresh(); }
public CardinalityToken(uint lower, UnlimitedInt upper) { Lower = lower; Upper = upper; }