public EAPackageCollections(EA.Package package) { this.connectors = new EABrowsableObjectsCollection<EA.Connector>(package.Connectors); this.element = package.Element; this.elements = new EABrowsableObjectsCollection<EA.Element>(package.Elements); this.packages = new EABrowsableObjectsCollection<EA.Package>(package.Packages); }
string _properties = ""; // the properties public Param(EA.Repository rep, EA.Element parTrgt) { _rep = rep; _parTrgt = parTrgt; // check if t_xref element is already present string query = @"SELECT XrefID As XREF_ID, description As DESCR FROM t_object o inner JOIN t_xref x on (o.ea_guid = x.client) where x.Name = 'CustomProperties' AND x.Type = 'element property' AND o.object_ID = " + _parTrgt.ElementID; string str = _rep.SQLQuery(query); var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(str); // get existing t_xref and remember GUID/XrefID XmlNode xrefGuid = xmlDoc.SelectSingleNode("//XREF_ID"); if (xrefGuid != null) { _xrefid = xrefGuid.InnerText;// GUID of xref // get description XmlNode xrefDesc = xmlDoc.SelectSingleNode("//DESCR"); _properties = null; if (xrefDesc != null) _properties = xrefDesc.InnerText; } }
public void LoadFromRepository(EA.Repository repository) { element = EAHelper.GetCurrentElement(repository); if (element != null) { field = element.TaggedValuesEx.GetByName("Markdown"); if(field == null) { field = element.TaggedValuesEx.AddNew("Markdown", "TaggedValue"); field.Value = "<memo>"; field.Update(); } style = element.TaggedValuesEx.GetByName("MarkdownStyle"); if(style == null) { style = element.TaggedValuesEx.AddNew("MarkdownStyle", "TaggedValue"); style.Value = ((MarkdownStyle)this.toolstripStyleBox.SelectedItem).CSSLink; style.Update(); } skin = element.TaggedValuesEx.GetByName("PrettifySkin"); if (skin == null) { skin = element.TaggedValuesEx.AddNew("PrettifySkin", "TaggedValue"); skin.Value = this.toolStripSkinBox.SelectedItem.ToString(); skin.Update(); } } this.markdownTextBox.Text = field.Notes; //UpdateWebBrowser(); }
public void LoadNotes(EA.Repository repo) { if (repo != null) { currentElement = repo.GetTreeSelectedObject(); this.richTextBox1.Text = currentElement.Notes; } }
public void RefreshWebBrowser() { element = EAHelper.GetCurrentElement(currentRepo); if (element != null) { field = element.TaggedValuesEx.GetByName("Markdown"); if (field == null) { field = element.TaggedValuesEx.AddNew("Markdown", "TaggedValue"); field.Value = "<memo>"; field.Update(); } style = element.TaggedValuesEx.GetByName("MarkdownStyle"); if (style == null) { style = element.TaggedValuesEx.AddNew("MarkdownStyle", "TaggedValue"); style.Value = ""; style.Update(); } skin = element.TaggedValuesEx.GetByName("PrettifySkin"); if (skin == null) { skin = element.TaggedValuesEx.AddNew("PrettifySkin", "TaggedValue"); skin.Value = "sunburst"; skin.Update(); } } StringBuilder sb = new StringBuilder(); sb.Append(String.Format("<link rel=\"stylesheet\" href=\"{0}\">", style.Value)); string s = skin.Value; if (s != "default") { s = "?skin=" + s; } else { s = ""; } string file = Path.GetTempPath() + "documentation.html"; using (FileStream fs = File.Open(file, FileMode.Create)) { StreamWriter writer = new StreamWriter(fs); writer.Write(Properties.Resources.HTMLHeader, sb.ToString(), s, md.Transform(field.Notes)); writer.Flush(); } this.webBrowser1.Navigate(file); }
private static void onTggRuleDoubleClicked(EA.Repository Repository, EA.Element doubleClickedElement) { EA.Diagram ruleDiag = doubleClickedElement.Diagrams.GetAt(0) as EA.Diagram; EA.Diagram currentDiag = Repository.GetCurrentDiagram(); if (currentDiag != null) { Navigator.addAnchorEntry(ruleDiag.DiagramID, Repository.GetCurrentDiagram().DiagramID); Repository.OpenDiagram(ruleDiag.DiagramID); } }
/// <summary> /// Delete all tagged values for Element /// </summary> /// <param name="el"></param> /// <returns></returns> public static bool DeleteTaggedValuesForElement(EA.Element el) { for (int i = el.TaggedValues.Count - 1; i >= 0; i--) { el.TaggedValues.DeleteAt((short)i, false); } el.TaggedValues.Refresh(); el.Update(); return(true); }
private static void appendSdmDiagram(String name, EA.Element parentElement) { if (parentElement.Diagrams.Count == 0) { EA.Diagram sdmDiagram = parentElement.Diagrams.AddNew(name, SDMModelingMain.SdmDiagramMetatype[0]) as EA.Diagram; sdmDiagram.Update(); parentElement.Diagrams.Refresh(); MainImport.getInstance().DiagramsToBeFilled.Add(sdmDiagram); } }
public void SortSelectedObjects() { // estimate sort criteria (left/right, top/bottom) bool isVerticalSorted = true; EA.DiagramObject obj1 = _dia.SelectedObjects.GetAt(0); EA.DiagramObject obj2 = _dia.SelectedObjects.GetAt(1); if (Math.Abs(obj1.left - obj2.left) > Math.Abs(obj1.top - obj2.top)) { isVerticalSorted = false; } // fill the diagram objects to sort by name / by position var lIdsByName = new List <DiagramObject>(); var lObjByPosition = new List <DiagramObjectSelected>(); foreach (EA.DiagramObject obj in _selectedObjects) { EA.Element el = _rep.GetElementByID(obj.ElementID); lIdsByName.Add(new DiagramObject(el.Name, el.ElementID)); int position = obj.left; if (isVerticalSorted) { position = obj.top; } lObjByPosition.Add(new DiagramObjectSelected(obj, position, obj.left)); } // sort name list and position list lIdsByName.Sort(new DiagramObjectComparer()); // sort diagram objects according to position and vertical / horizontal sorting if (isVerticalSorted) { lObjByPosition.Sort(new DiagramObjectSelectedVerticalComparer()); } else { lObjByPosition.Sort(new DiagramObjectSelectedHorizontalComparer()); } foreach (EA.DiagramObject obj in _dia.SelectedObjects) { // find position of element in sorted selected objects int pos = lIdsByName.FindIndex(x => x.Id == obj.ElementID); int length = obj.right - obj.left; int high = obj.top - obj.bottom; obj.left = lObjByPosition[pos].Left; obj.bottom = lObjByPosition[pos].Obj.bottom; obj.right = obj.left + length; obj.top = obj.bottom + high; obj.Update(); } }
public static string setOvMethodCallExpressionGui(ObjectVariable ov) { SQLTaggedValue mceVisTag = EAUtil.findTaggedValue(ov.sqlElement, ObjectVariable.MceVisualizationTaggedValueName); Expression BindingExpression = ov.BindingExpression; if (BindingExpression != null) { deletePossibleBindingConnectors(ov.sqlElement.getRealElement()); if (BindingExpression is MethodCallExpression) { var mcE = BindingExpression as MethodCallExpression; ObjectVariableExpression firstOvExpression = null; if (mcE.OwnedParameterBinding.Count == 1 && (mceVisTag == null || mceVisTag.Value == "true")) { foreach (ParameterBinding paramBinding in mcE.OwnedParameterBinding) { if (paramBinding.ValueExpression is ObjectVariableExpression) { firstOvExpression = paramBinding.ValueExpression as ObjectVariableExpression; } } if (firstOvExpression != null) { EA.Element firstOvEaElement = ov.Repository.GetOriginalRepository().GetElementByGuid(firstOvExpression.ObjectVariableGUID); if (firstOvEaElement.ParentID == ov.sqlElement.ParentID) { EA.Connector bindingLink = firstOvEaElement.Connectors.AddNew("", Main.EADependencyType) as EA.Connector; bindingLink.Stereotype = SDMModelingMain.BindingExpressionLinkStereotype; bindingLink.Name = mcE.Target + "." + mcE.MethodName; bindingLink.SupplierID = ov.sqlElement.ElementID; bindingLink.Update(); EA.Element realElement = ov.sqlElement.getRealElement(); realElement.Connectors.Refresh(); realElement.Notes = ""; realElement.Update(); EAUtil.setTaggedValue(ov.Repository, realElement, ObjectVariable.BindingExpressionOutputTaggedValueName, ""); return(""); } } } } return(BindingExpression.ToString()); } return(""); }
/// <summary> /// InitializeTable for search results using EA API /// </summary> /// <param name="rep"></param> /// <param name="searchText">Optional: List of packages, EA elements as a comma separated list</param> /// <returns></returns> private static DataTable AddinSearchObjectsNestedInitTable(EA.Repository rep, string searchText) { // get connection string of repository string connectionString = LinqUtil.GetConnectionString(rep, out var provider); _tv = new Dictionary <string, string>(); DataTable dt = new DataTable(); dt.Columns.Add("CLASSGUID", typeof(string)); dt.Columns.Add("CLASSTYPE", typeof(string)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("Alias", typeof(string)); dt.Columns.Add("Note", typeof(string)); if (searchText.Trim().StartsWith("{")) { // handle string string[] guidList = GetEaFromCommaSeparatedList(searchText); foreach (var guid in guidList) { EA.Element el = rep.GetElementByGuid(guid); if (el == null) { continue; } if (el.Type != "Package") { NestedElementsRecursive(connectionString, provider, dt, rep.GetPackageByID(el.PackageID).PackageGUID, el.ElementID); } if (el.Type == "Package") { NestedPackageElementsRecursive(connectionString, provider, dt, guid); } } EA.Package pkg = rep.GetPackageByGuid(searchText); if (pkg != null) { NestedPackageElementsRecursive(connectionString, provider, dt, pkg.PackageGUID); } } else { // handle context element rep.GetContextItem(out var item); if (item is EA.Element element) { NestedElementsRecursive(connectionString, provider, dt, rep.GetPackageByID(element.PackageID).PackageGUID, element.ElementID); } if (item is EA.Package package) { NestedPackageElementsRecursive(connectionString, provider, dt, package.PackageGUID); } } return(dt); }
private void addTGGLinkVariableCopyToRule(EA.Connector connectorToBeCopied) { EA.Element newSource = newElementIdToNewElement[oldElementIdToNewElementId[connectorToBeCopied.ClientID]]; EA.Element newTarget = newElementIdToNewElement[oldElementIdToNewElementId[connectorToBeCopied.SupplierID]]; EA.Connector newConnector = newSource.Connectors.AddNew("", connectorToBeCopied.Type) as EA.Connector; newConnector.Stereotype = TGGModelingMain.TggLinkVariableStereotype; newConnector.ClientEnd.Role = connectorToBeCopied.ClientEnd.Role; newConnector.SupplierEnd.Role = connectorToBeCopied.SupplierEnd.Role; newConnector.SupplierID = newTarget.ElementID; newConnector.ClientID = newSource.ElementID; newConnector.Update(); if (connectorToBeCopied.Stereotype == TGGModelingMain.TggLinkVariableStereotype) { foreach (EA.ConnectorTag tag in connectorToBeCopied.TaggedValues) { EA.ConnectorTag newTag = newConnector.TaggedValues.AddNew(tag.Name, "") as EA.ConnectorTag; if (!checkBoxExactCopy.Checked) { newTag.Value = tag.Value.Replace("create", "check_only"); newTag.Notes = tag.Notes.Replace("\"bindingOperator\" value=\"create", "\"bindingOperator\" value=\"check_only"); } else { newTag.Value = tag.Value; newTag.Notes = tag.Notes; } newTag.Update(); } } EA.DiagramLink newDiagramLink = newRuleDiagram.DiagramLinks.AddNew("", newConnector.Type) as EA.DiagramLink; newDiagramLink.ConnectorID = newConnector.ConnectorID; newDiagramLink.Update(); if (connectorToBeCopied.Stereotype != TGGModelingMain.TggLinkVariableStereotype) { LinkDialogueEntry linkEntry = new LinkDialogueEntry(); linkEntry.direction = LinkDialogueEntryDirection.RIGHT; linkEntry.CorrespondingConnectorGuid = connectorToBeCopied.ConnectorGUID; if (newConnector.ClientEnd.Role != "") { linkEntry.supplierRoleName = newConnector.ClientEnd.Role; } else if (newConnector.SupplierEnd.Role != "") { linkEntry.supplierRoleName = newConnector.SupplierEnd.Role; } TGGLinkVariable tggLv = new TGGLinkVariable(repository.GetConnectorByID(newConnector.ConnectorID), repository); tggLv.linkDialogueEntry = linkEntry; if (!checkBoxExactCopy.Checked) { tggLv.BindingOperator = SDMModeling.SDMExportWrapper.patterns.BindingOperator.CREATE; } tggLv.saveTreeToEATaggedValue(true); } }
/// <summary> /// Конструирует имя элемента для показа в UI /// </summary> public static string ElementDisplayName(object eaObject) { if (eaObject == null) { return("null"); } string result = ":"; if ((eaObject as EA.Element) != null) { EA.Element curElement = eaObject as EA.Element; { if (curElement.ClassfierID != 0) { result += ":(" + curElement.Type; EA.Element classifier = EARepository.GetElementByID(curElement.ClassfierID); result += curElement.Name + "/" + classifier.Name + "," + classifier.Stereotype + ")"; } else { result += "" + curElement.Type + "," + curElement.Name; } } } else if ((eaObject as EA.DiagramObject) != null) { EA.DiagramObject curDA = eaObject as EA.DiagramObject; { result += "da(" + (curDA.right - curDA.left).ToString() + "x" + Math.Abs(curDA.top - curDA.bottom).ToString() + ")(" + curDA.left.ToString() + "," + curDA.right.ToString() + "," + curDA.top.ToString() + "," + curDA.bottom.ToString() + ")"; EA.Element curElement = EARepository.GetElementByID(curDA.ElementID); if (curElement.ClassfierID != 0) { result += ":(" + curElement.Type; EA.Element classifier = EARepository.GetElementByID(curElement.ClassfierID); result += curElement.Name + "," + classifier.Name + "," + classifier.Stereotype + ")"; } else { result += "" + curElement.Type + curElement.Name; } } } else if ((eaObject as EA.Package) != null) { EA.Package curPackage = eaObject as EA.Package; result += "package(" + curPackage.Name + ")"; } else { result += eaObject.ToString() + ";"; } return(result); }
/// <summary> /// InitializeTable for search results using EA API /// </summary> /// <param name="rep"></param> /// <param name="searchText">Optional: List of packages, EA elements as a comma separated list</param> /// <returns></returns> private static DataTable AddinSearchObjectsNestedInitTableUsingEaApi(EA.Repository rep, string searchText) { _tv = new Dictionary <string, string>(); DataTable dt = new DataTable(); dt.Columns.Add("CLASSGUID", typeof(string)); dt.Columns.Add("CLASSTYPE", typeof(string)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("Alias", typeof(string)); dt.Columns.Add("Note", typeof(string)); int level = 0; if (searchText.Trim().StartsWith("{")) { // handle string string[] earchTextArr = GetEaFromCommaSeparatedList(searchText); foreach (var txt in earchTextArr) { EA.Element el = rep.GetElementByGuid(txt); if (el == null) { continue; } if (el.Type != "Package") { NestedElementsRecursiveUsingEaApi(dt, el, level); } if (el.Type == "Package") { NestedPackageElementsRecursiveUsingEaApi(dt, rep.GetPackageByGuid(txt), level); } } EA.Package pkg = rep.GetPackageByGuid(searchText); if (pkg != null) { NestedPackageElementsRecursiveUsingEaApi(dt, pkg, level); } } else { // handle context element rep.GetContextItem(out var item); if (item is EA.Element element) { NestedElementsRecursiveUsingEaApi(dt, element, level); } if (item is EA.Package package) { NestedPackageElementsRecursiveUsingEaApi(dt, package, level); } } return(dt); }
/// <summary> /// Delete undefined Reference (former ExternalReference).The element subtype is "1001". It searches for /// </summary> /// <returns></returns> /// Search for External references /// Select ea_guid As CLASSGUID, object_type As CLASSTYPE,ea_GUID As el_guid, name As el_name, * from t_object o where NType=1001 private static void DeleteUndefinedReference(EA.Repository repository, EA.Element el, Boolean dialog = true, Boolean completePackage = false) { //if (el.Type.Equals("Boundary")) if (el.Subtype == 1001 && completePackage == false) { EA.Package pkg = repository.GetPackageByID(el.PackageID); // Not version controlled, checked out to this user int versionControlState = pkg.VersionControlGetStatus(); if (versionControlState == 0 || versionControlState == 2) { // delete External Reference for (short idx = (short)(pkg.Elements.Count - 1); idx >= 0; idx--) { if ((el.ElementID == ((EA.Element)pkg.Elements.GetAt(idx)).ElementID) || (completePackage && el.Subtype == 1001)) { // with or without dialog try { if (dialog) { DialogResult res = MessageBox.Show("Delete element '" + el.Name + "'", "Delete element", MessageBoxButtons.YesNo); if (res == DialogResult.Yes) { pkg.Elements.DeleteAt(idx, false); if (completePackage == false) { break; } } } else { pkg.Elements.DeleteAt(idx, false); if (completePackage == false) { break; } } } catch { } } } pkg.Update(); } else { string s = String.Format("Delete element '{0}' Version control state={1} not possible!", el.Name, versionControlState); MessageBox.Show(s, "Package can't be changed, checked in?, break;"); } } return; }
public override void doEaGuiStuff() { if (this.EAEDataType.Stereotype != ECOREModelingMain.EDatatypeStereotype) { EA.Element realDatatype = Repository.GetOriginalRepository().GetElementByGuid(this.EAEDataType.ElementGUID); realDatatype.StereotypeEx = ECOREModelingMain.EDatatypeStereotype; realDatatype.Alias = this.InstanceTypeName; realDatatype.Name = this.Name; realDatatype.Update(); } }
public static void doRecursiveEl(EA.Repository rep, EA.Element el, FindAndReplace fr) { // perform element if (fr.isElementSearch) { fr.FindStringInItem(EA.ObjectType.otElement, el.ElementGUID); if (fr.isTagSearch) { FindMatchingElementTaggedValue(rep, el, fr); } } if (fr.isAttributeSearch) { foreach (EA.Attribute a in el.Attributes) { fr.FindStringInItem(EA.ObjectType.otAttribute, a.AttributeGUID); if (fr.isTagSearch) { FindMatchingAttributeTaggedValue(rep, a, fr); } } } if (fr.isOperationSearch) { foreach (EA.Method m in el.Methods) { fr.FindStringInItem(EA.ObjectType.otMethod, m.MethodGUID); if (fr.isTagSearch) { FindMatchingMethodTaggedValue(rep, m, fr); } } } // perform diagrams of package if (fr.isDiagramSearch) { foreach (EA.Diagram dia in el.Diagrams) { if (dia != null) { fr.FindStringInItem(EA.ObjectType.otDiagram, dia.DiagramGUID); } } } //run all elements foreach (EA.Element elTrgt in el.Elements) { doRecursiveEl(rep, elTrgt, fr); } return; }
private void importTGGCSP(SQLElement ruleElement, MocaNode cspInstanceNode) { EA.Element cspElement = MainImport.getInstance().EcoreImport.getOrCreateElement(ruleElement, cspInstanceNode, "Class"); CSPInstance cspIstance = new CSPInstance(sqlRep, sqlRep.GetElementByID(cspElement.ElementID)); cspIstance.deserializeFromMocaTree(cspInstanceNode); MainImport.getInstance().MocaTaggableElements.Add(cspIstance); MainImport.getInstance().ElementGuidToElement.Add(cspElement.ElementGUID, cspElement); }
protected override void Correct(IMyOperation elementToCorrect) { EA.Element theClass = Repository.GetElementByGuid(elementToCorrect.Owner.Guid); EA.Method theOperation = theClass.Methods.Cast <EA.Method>().SingleOrDefault(m => m.MethodGUID == elementToCorrect.Guid); if (theOperation == null) { return; } theOperation.Name = "_" + elementToCorrect.Name; theOperation.Update(); }
private void createRuleElementAndRuleDiagram() { this.newRuleElement = rulesPackage.Elements.AddNew(this.textBoxRuleName.Text, "Class") as EA.Element; this.newRuleElement.Stereotype = TGGModelingMain.TggRuleStereotype; this.newRuleElement.Update(); EA.Diagram rulesDiagram = rulesPackage.Diagrams.GetAt(0) as EA.Diagram; EA.DiagramObject newRuleDiagramObject = rulesDiagram.DiagramObjects.AddNew("", this.newRuleElement.Type) as EA.DiagramObject; if (this.addInheritanceLinkCheckBox.Checked) { EA.DiagramObject originalRuleDiagramObject = null; foreach (EA.DiagramObject diagramObject in rulesDiagram.DiagramObjects) { if (diagramObject.ElementID == this.originalRuleElement.ElementID) { originalRuleDiagramObject = diagramObject; break; } } if (originalRuleDiagramObject != null) { int verticalOffset = -(originalRuleDiagramObject.top - originalRuleDiagramObject.bottom + 40); newRuleDiagramObject.left = originalRuleDiagramObject.left - 10; newRuleDiagramObject.right = originalRuleDiagramObject.right + 10; newRuleDiagramObject.top = originalRuleDiagramObject.top + verticalOffset; newRuleDiagramObject.bottom = originalRuleDiagramObject.bottom + verticalOffset; } } else { newRuleDiagramObject.left = 10; newRuleDiagramObject.right = 110; newRuleDiagramObject.top = -10; newRuleDiagramObject.bottom = -80; } newRuleDiagramObject.ElementID = this.newRuleElement.ElementID; newRuleDiagramObject.Update(); if (this.addInheritanceLinkCheckBox.Checked) { addInheritanceLinkToOriginalRule(); } repository.ReloadDiagram(rulesDiagram.DiagramID); newRuleDiagram = newRuleElement.Diagrams.AddNew(this.textBoxRuleName.Text, TGGModelingMain.TggRuleDiagramMetatype[0]) as EA.Diagram; newRuleDiagram.Update(); TGGRule rule = new TGGRule(repository, repository.GetElementByID(newRuleElement.ElementID)); rule.saveTreeToEATaggedValue(true); }
private EA.Element createThisOv(EA.Element thisActivity) { EA.Element thisObject = thisActivity.Elements.AddNew("this", "Object") as EA.Element; thisObject.ClassifierID = this.oldSDMContainer.ParentID; thisObject.Update(); ObjectVariable ov = new ObjectVariable(sqlRepository.GetElementByID(thisObject.ElementID), sqlRepository); ov.BindingState = BindingState.BOUND; ov.saveTreeToEATaggedValue(true); return(thisObject); }
private static bool classifierIsValid(SQLRepository sqlRep, EA.Element newElement) { SQLElement newElementClassifier = sqlRep.GetElementByID(newElement.ClassifierID); if (newElementClassifier.Stereotype == ECOREModelingMain.EDatatypeStereotype) { MessageBox.Show("Object variables of type EDatatype cannot be created"); return(false); } return(true); }
public static void SetTaggedValue(EA.Element element, string name, string value, string notes = null) { DeleteTaggedValue(element, name); EA.TaggedValue tv = (EA.TaggedValue)element.TaggedValues.AddNew(name, "TaggedValue"); tv.Value = value; if (notes != null) { tv.Notes = notes; } tv.Update(); }
public static void setSingleOvMceVisualizationTag(Boolean toSet, EA.Element ov, SQLRepository rep) { if (toSet) { EAUtil.setTaggedValue(rep, ov, ObjectVariable.MceVisualizationTaggedValueName, "true"); } else { EAUtil.setTaggedValue(rep, ov, ObjectVariable.MceVisualizationTaggedValueName, "false"); } }
/// <summary> /// Check constraint C97 /// An AuthorizedRole, which participates in a BusinessRealization, must be /// the target of exactly one mapsTo dependency starting from a BusinessPartner. /// Furthermore the AuthorizedRole, which participates in the BusinessRealization /// must be the source of exactly one mapsTo dependency targeting an AuthorizedRole /// participating in a BusinessCollaborationUseCase. /// </summary> /// <param name="context"></param> /// <param name="brv"></param> /// <returns></returns> private void checkC97(IValidationContext context, EA.Package brv) { //Get the Authorized Roles IList <EA.Element> aroles = Utility.getAllElements(brv, new List <EA.Element>(), UMM.AuthorizedRole.ToString()); foreach (EA.Element ar in aroles) { int countTo = 0; int countFrom = 0; bool doesParticipate = doesParticipateInBR(context, ar); foreach (EA.Connector con in ar.Connectors) { if (doesParticipate) { if (con.Type == "Dependency" && con.Stereotype == UMM.mapsTo.ToString()) { //Count the mapsTo leading to this authorized role if (con.SupplierID == ar.ElementID) { EA.Element client = context.Repository.GetElementByID(con.ClientID); if (client.Stereotype == UMM.bPartner.ToString()) { countTo++; } } //Count the mapsTo emanating from this authorized role if (con.ClientID == ar.ElementID) { EA.Element supplier = context.Repository.GetElementByID(con.SupplierID); if (supplier.Stereotype == UMM.AuthorizedRole.ToString()) { if (doesParticipateinBC(context, supplier)) { countFrom++; } } } } } } if (doesParticipate && countTo != 1) { context.AddValidationMessage(new ValidationMessage("Violation of constraint C97.", "An AuthorizedRole, which participates in a BusinessRealization, must be the target of exactly one mapsTo dependency starting from a BusinessPartner. Furthermore the AuthorizedRole, which participates in the BusinessRealization must be the source of exactly one mapsTo dependency targeting an AuthorizedRole participating in a BusinessCollaborationUseCase. \n\nAuthorized Role " + ar.Name + " has an invalid number of incoming mapsTo dependencies: " + countTo, "BCV", ValidationMessage.errorLevelTypes.ERROR, brv.PackageID)); } if (doesParticipate && countFrom != 1) { context.AddValidationMessage(new ValidationMessage("Violation of constraint C97.", "An AuthorizedRole, which participates in a BusinessRealization, must be the target of exactly one mapsTo dependency starting from a BusinessPartner. Furthermore the AuthorizedRole, which participates in the BusinessRealization must be the source of exactly one mapsTo dependency targeting an AuthorizedRole participating in a BusinessCollaborationUseCase. \n\nAuthorized Role " + ar.Name + " has an invalid number of outgoing mapsTo dependencies: " + countFrom, "BCV", ValidationMessage.errorLevelTypes.ERROR, brv.PackageID)); } } }
private void addInheritanceLinkToOriginalRule() { EA.Element baseRule = this.newRuleElement; EA.Element parentRule = this.originalRuleElement.getRealElement(); EA.Connector refinementConnector = baseRule.Connectors.AddNew("", "TGGCustomGeneralization") as EA.Connector; refinementConnector.SupplierID = parentRule.ElementID; refinementConnector.Update(); baseRule.Update(); parentRule.Update(); }
/// <summary> /// Удаляет TaggedValue из элемента /// </summary> /// <param name="element"></param> /// <param name="tagName"></param> public static void TaggedValueRemove(EA.Element element, string tagName) { for (short i = 0; i < element.TaggedValues.Count; i++) { EA.TaggedValue tag = element.TaggedValues.GetAt(i); if (tag.Name == tagName) { element.TaggedValues.DeleteAt(i, true); } } }
private EA.Attribute getAttributeByName(EA.Element eaElement, string attName) { foreach (EA.Attribute eaAttribute in eaElement.Attributes) { if (attName.Equals(eaAttribute.Name)) { return(eaAttribute); } } return(null); }
// Find the operation from Activity / State Machine public static EA.Method GetOperationFromBrehavior(EA.Repository rep, EA.Element el) { EA.Method method = null; string query = ""; string conString = GetConnectionString(rep); // due to shortcuts if (conString.Contains("DBType=3")) { // Oracle DB query = @"select op.ea_guid AS EA_GUID from t_operation op where Cast(op.Behaviour As Varchar2(38)) = '" + el.ElementGUID + "' "; } if (conString.Contains("DBType=1")) // SQL Server { query = @"select op.ea_guid AS EA_GUID from t_operation op where Substring(op.Behaviour,1,38) = '" + el.ElementGUID + "'"; } if (conString.Contains(".eap")) // SQL Server { query = @"select op.ea_guid AS EA_GUID from t_operation op where op.Behaviour = '" + el.ElementGUID + "'"; } if ((!conString.Contains("DBType=1")) && // SQL Server, DBType=0 MySQL (!conString.Contains("DBType=3")) && // Oracle (!conString.Contains(".eap"))) // Access { query = @"select op.ea_guid AS EA_GUID from t_operation op where op.Behaviour = '" + el.ElementGUID + "'"; } string str = rep.SQLQuery(query); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(str); XmlNode operationGuidNode = xmlDoc.SelectSingleNode("//EA_GUID"); if (operationGuidNode != null) { string guid = operationGuidNode.InnerText; method = rep.GetMethodByGuid(guid); } return(method); }
protected override void Correct(IMyOperation elementToCorrect) { EA.Element theClass = Repository.GetElementByGuid(elementToCorrect.Owner.Guid); EA.Method theMethod = theClass.Methods.Cast <EA.Method>().SingleOrDefault(m => m.MethodGUID == elementToCorrect.Guid); if (theMethod == null) { return; } theMethod.Name = elementToCorrect.Name.FilterSpecialCharacters(); theMethod.Update(); }
static public bool isMeasureType(EA.Element type) { if (type == null || type.BaseClasses.Count != 1) { return(false); } EA.Element baseType = type.BaseClasses.GetAt(0); return(baseType.Name.Equals("Measure") || baseType.Name.Equals("AbstractMeasure")); }
static void reifyRunState(EA.Repository Repository, EA.Element e, YamlMappingNode map) { logger.log("Runstate:" + e.RunState); Dictionary <string, RunState> rs = ObjectManager.parseRunState(e.RunState); foreach (string key in rs.Keys) { logger.log("Adding:" + key + "=>" + rs[key].value); map.Add(key, rs[key].value); } }
public EA.Element GetByEALocalId(int id) { EA.Element result = null; foreach (EA.Package package in repository.Models) { result = getByEALocalId(package, id); } return(result); }
static YamlMappingNode reifyResponse(EA.Repository Repository, EA.Element e, EA.Connector con, EA.Element client) { YamlMappingNode body = new YamlMappingNode(); YamlMappingNode props = new YamlMappingNode(); visitOutboundConnectedElements(Repository, e, props, MetaDataManager.filterContentType, nameOfTargetElement, reifyContentType); if (props.Children.Count > 0) { body.Add("body", props); } return(body); }
private EA.Element createEAClass(EA.Package package, EAClass eAClass) { EA.Element element = package.Elements.AddNew(eAClass.Name, "Class"); element.Stereotype = eAClass.StereoType; if (EnumUtil.checkInEnumValues(eAClass.StereoType, typeof(PlatformDataTypeEnum))) { element.Stereotype = DATA_TYPE; EA.TaggedValue taggedValue = element.TaggedValues.AddNew("IDLType", eAClass.StereoType); taggedValue.Update(); } return(element); }
public FindAndReplaceItemElement(EA.Repository rep, string GUID) :base(rep, GUID) { this._el = rep.GetElementByGuid(GUID); this.load(rep); }