/// <summary> /// Get list of package ids as comma separated list /// </summary> /// <param name="rep"></param> /// <param name="branch">The current Branch as comma separated list</param> /// <param name="pkgId">The current PackageID to add recursively to Branch</param> /// <returns></returns> public static string GetBranch(Repository rep, string branch, int pkgId) { if (pkgId > 0) { // add current package id if (branch == "") { branch = pkgId.ToString(); } else { branch = branch + ", " + pkgId; } EA.Package pkg = rep.GetPackageByID(pkgId); foreach (EA.Package p in pkg.Packages) { int newPkgId = p.PackageID; string s = newPkgId.ToString(); branch = GetBranch(rep, branch, newPkgId); } } return(branch); }
//Get a list of views from the selected root package. public static List <string> GetStringListOfROOTViews(string RootPackageOfInterest, EA.Repository m_Repository) { List <string> ListOfViewsToReturn = new List <string>(); //go through every root note for (short iRoot = 0; iRoot < m_Repository.Models.Count; iRoot++) { EA.Package MyRootNode = (EA.Package)m_Repository.Models.GetAt(iRoot); //If the root node if (RootPackageOfInterest == MyRootNode.Name) { //For every view in that root. for (short iPackage = 0; iPackage < MyRootNode.Packages.Count; iPackage++) { //If this is the right correct root node, lets store the views. EA.Package MyView = (EA.Package)MyRootNode.Packages.GetAt(iPackage); ListOfViewsToReturn.Add(MyView.Name); } //At this point we can assume we have all the views so let's exit return(ListOfViewsToReturn); } } return(ListOfViewsToReturn); }
private void exportAllGlobal(EA.Repository Repository) { { List <string> diagrams = DiagramManager.queryAPIDiagrams(Repository); foreach (string diagramId in diagrams) { EA.Diagram diagram = Repository.GetDiagramByGuid(diagramId); logger.log("Exporting Diagram:" + diagram.Name); APIManager.exportAPI(Repository, diagram); logger.log("Exported Diagram:" + diagram.Name); } } { List <string> diagrams = DiagramManager.querySchemaDiagrams(Repository); foreach (string diagramId in diagrams) { EA.Diagram diagram = Repository.GetDiagramByGuid(diagramId); logger.log("Exporting Schema Diagram:" + diagram.Name); SchemaManager.exportSchema(Repository, diagram); } } { List <string> diagrams = DiagramManager.querySampleDiagrams(Repository); foreach (string diagramId in diagrams) { EA.Diagram diagram = Repository.GetDiagramByGuid(diagramId); EA.Package samplePackage = Repository.GetPackageByID(diagram.PackageID); EA.Package apiPackage = Repository.GetPackageByID(samplePackage.ParentID); logger.log("Exporting Sample Diagram:" + diagram.Name + " from api package:" + apiPackage.Name); SampleManager.exportSample(Repository, diagram); } } }
public static PackageVO getPackageFromEAObject(EA.Package eaPackageObj) { PackageVO pacvo = new PackageVO(); pacvo.packageId = eaPackageObj.PackageID; pacvo.guid = eaPackageObj.PackageGUID; pacvo.name = excludeSpecialChar(eaPackageObj.Name); pacvo.alias = excludeSpecialChar(eaPackageObj.Alias); pacvo.stereoType = excludeSpecialChar(eaPackageObj.StereotypeEx); pacvo.treePos = eaPackageObj.TreePos; pacvo.isControlled = eaPackageObj.IsControlled; List <ElementVO> retElementList = new List <ElementVO>(); foreach (EA.Element elemObj in eaPackageObj.Elements) { retElementList.Add(getElementFromEAObject(elemObj)); } List <PackageVO> retPackageList = new List <PackageVO>(); foreach (EA.Package subPackObj in eaPackageObj.Packages) { retPackageList.Add(getPackageFromEAObject(subPackObj)); } pacvo.elements = retElementList; pacvo.childPackageList = retPackageList; return(pacvo); }
public List <Node> GetAllHierarchies() { List <Node> result = new List <Node>(); EAAPI.Collection searchResult = _repository.GetElementsByQuery("SpecificationPackages", ""); if (searchResult.Count > 0) { for (short counter = 0; counter < searchResult.Count; counter++) { EAAPI.Element packageElement = searchResult.GetAt(counter) as EAAPI.Element; EAAPI.Package package = _repository.GetPackageByGuid(packageElement.ElementGUID); CachedDataProvider eaCacheDataProvider = new CachedDataProvider(_repository); EADM.Element specificationPackageElement = eaCacheDataProvider.GetCachedSpecification(package); Node rootNode = new Node(); ConvertEaDataToSpecifNodeRecursively(specificationPackageElement, rootNode); result = rootNode.Nodes; } } return(result); }
private static List <EA.Package> GetObjectListOfROOTViews(string RootPackageOfInterest, EA.Repository m_Repository) { List <EA.Package> ListOfViewsToReturn = new List <EA.Package>(); //go through every root note for (short iRoot = 0; iRoot < m_Repository.Models.Count; iRoot++) { EA.Package MyRootNode = (EA.Package)m_Repository.Models.GetAt(iRoot); //If the root node if (RootPackageOfInterest == MyRootNode.Name) { //For every view in that root. for (short iPackage = 0; iPackage < MyRootNode.Packages.Count; iPackage++) { //If this is the right correct root node, lets store the views. EA.Package MyView = (EA.Package)MyRootNode.Packages.GetAt(iPackage); ListOfViewsToReturn.Add(MyView); } return(ListOfViewsToReturn); } } //Will be null if it gets to here return(ListOfViewsToReturn); }
//This is a sophisticated method that goes around the entire EA model looking for what ever was clicked. //The rest-ful nature means we don't know what type of thing was clicked, we only have the name. //This will use a recursive method to loop through every single layer. //Prepare for headaches! public static void GetViewsAndDiagrams(string ThingOfInterest, EA.Repository m_Repository, string[] cleanURL, out List <string> ListOfPackages, out List <string> ListOfDiagrams) { List <string> OutStringListOfViews = new List <string>(); //The final list of views to be returned. (As out paramter) List <string> OutStringListOfDiagrams = new List <string>(); //The final list of diagrams to be returned. (As out paramter) List <EA.Package> ListOfRootViews = new List <EA.Package>(); //Object list to store the results ListOfRootViews = GetObjectListOfROOTViews(cleanURL[2], m_Repository); //We can always figure out the root views //Look around the listroot views and see if one of these //is what has been selected foreach (EA.Package EA_Package in ListOfRootViews) { //Is this the view/package that was selected? if (EA_Package.Name == ThingOfInterest) { //If it does, then record the sub views as a string list foreach (EA.Package PackLoop in EA_Package.Packages) { OutStringListOfViews.Add(PackLoop.Name); } //Do we have any diagrams, if so, let's record them. foreach (EA.Diagram DiaLoop in EA_Package.Diagrams) { OutStringListOfDiagrams.Add(DiaLoop.Name); } } else { //If it isn't, we have to dive into a recursive routine and if it exists below..... //Get Packages from the deep recursiveloop // Package DeepPackage = new Package(); EA.Package DeepPackage = null; ThePackageRecursiveLoop(EA_Package, ThingOfInterest, out DeepPackage, false); if (DeepPackage != null) { foreach (EA.Package PkgLoop in DeepPackage.Packages) { OutStringListOfViews.Add(PkgLoop.Name); } foreach (EA.Diagram DiaLoop in DeepPackage.Diagrams) { OutStringListOfDiagrams.Add(DiaLoop.Name); } } } } ListOfPackages = OutStringListOfViews; ListOfDiagrams = OutStringListOfDiagrams; }
private void exportPackage(EA.Repository Repository, EA.Package pkg) { foreach (EA.Package p in pkg.Packages) { exportAPIPackage(Repository, p); exportPackage(Repository, p);//recurse } }
private void exportPackage(EA.Repository Repository, EA.Package pkg, DiagramCache diagramCache) { exportRoundTripPackage(Repository, pkg, diagramCache); foreach (EA.Package p in pkg.Packages) { exportPackage(Repository, p, diagramCache);//recurse } }
/// <summary> /// Initialize DoorsModule for usage with package. /// </summary> /// <param name="rep"></param> /// <param name="pkg"></param> /// <param name="reqIfLogList"></param> private void Init(EA.Repository rep, EA.Package pkg, List <ReqIfLog> reqIfLogList = null) { _pkg = pkg; _rep = rep; _reqIfDeserialized = null; _reqIfLogList = reqIfLogList; // get connection string of repository _connectionString = LinqUtil.GetConnectionString(_rep, out _provider); }
public Crozdz5(EA.Repository r, EA.Package p, Package dzialPckg, String sciezkaZrodlo, String sciezkaDocelowa, String nrRozdzialu, Word W, bool jezykPl) : base(sciezkaZrodlo, sciezkaDocelowa) { jezykPolski = jezykPl; word = W; Repo = r; // projekt = p; // wkladyPckg = EAUtils.dajPakietSciezkiP(ref dzialPckg, "Wkłady Systemowe"); NrRozdzialu = nrRozdzialu; }
public Crozdz6(EA.Repository r, EA.Package p, Package dzialPckg, String sciezkaZrodlo, String sciezkaDocelowa, String nrRozdzialu, Word W, Statystyki o, bool jezykPl) : base(sciezkaZrodlo, sciezkaDocelowa) { jezykPolski = jezykPl; word = W; rep = r; okno = o; koncepcjaPckg = EAUtils.dajPakietSciezkiP(ref dzialPckg, "Koncepcja"); NrRozdzialu = nrRozdzialu; }
private void PrintPackage(EA.Package package) { Trace(package.Name); EA.Collection packages = package.Packages; for (short ip = 0; ip < packages.Count; ip++) { EA.Package child = (EA.Package)packages.GetAt(ip); PrintPackage(child); } }
// constructor public Mks(Repository rep, EA.Package pkg) { _pkg = pkg; _rep = rep; _vcPath = ""; if (pkg.IsControlled) { _vcPath = Util.GetVccFilePath(rep, pkg); } }
private void exportAPIPackage(EA.Repository Repository, EA.Package apiPackage) { EA.Package samplePackage = null; EA.Package schemasPackage = null; foreach (EA.Package p in apiPackage.Packages) { //logger.log("Package:" + p.Name); if (p.Name.Equals(APIAddinClass.API_PACKAGE_SAMPLES)) { samplePackage = p; } else if (p.Name.Equals(APIAddinClass.API_PACKAGE_SCHEMAS)) { schemasPackage = p; } } if (samplePackage == null || schemasPackage == null) { logger.log("Not an api/model package:" + apiPackage.Name); return; } logger.log("Found api/model package:" + apiPackage.Name); if (samplePackage != null) { List <EA.Package> pkgs = new List <EA.Package>(); pkgs.Add(samplePackage); foreach (EA.Package child in samplePackage.Packages) { pkgs.Add(child); } foreach (EA.Package sp in pkgs) { logger.log("Exporting Samples:" + sp.Name); foreach (object obj in sp.Diagrams) { EA.Diagram samplediagram = (EA.Diagram)obj; logger.log("Exporting Schema Diagram:" + samplediagram.Name); SampleManager.exportSample(Repository, samplediagram); } } } if (schemasPackage != null) { logger.log("Exporting Schemas:" + schemasPackage.Name); foreach (EA.Diagram schemadiagram in schemasPackage.Diagrams) { logger.log("Exporting Sample Diagram:" + schemadiagram.Name); SchemaManager.exportSchema(Repository, schemadiagram); } } }
public EAPModels CollectClasses(string input, ref string err) { m_Repository = new EA.Repository(); try { m_Repository.OpenFile(input); } catch { err = err + "\nIt is not able to open EAP file. Check the instalation of EAP"; return(null); } eapModels = new EAPModels(); EAPModel model = null; EA.Package MyModel = (EA.Package)m_Repository.Models.GetAt(0); string packageAlias = MyModel.Packages.Count > 0 ? ((EA.Package)(MyModel.Packages.GetAt(0))).Alias : null; if (packageAlias == null || packageAlias == "") { model = new EAPModel(nameModel); eapModels.Models.Add(model); } for (short iPackage = 0; iPackage < MyModel.Packages.Count; iPackage++) { EA.Package package = (EA.Package)MyModel.Packages.GetAt(iPackage); MyModelCopy = package; DoPackage(package, false, model, true); } for (short iPackage = 0; iPackage < MyModel.Packages.Count; iPackage++) { EA.Package package = (EA.Package)MyModel.Packages.GetAt(iPackage); MyModelCopy = package; DoPackage(package, false, model, false); } FindAttributeEnumCode(); FixGroupClass(); m_Repository.CloseFile(); if (Validate) { //FindModelCodeIsNotEAP(); tw.Close(); } return(eapModels); }
public bool GetPackage(out EA.Package package) { package = null; int packageId; if (GetEAObjectId(PackageID, out packageId)) { package = repository.GetPackageByID(packageId); return(package != null); } return(false); }
public List <int> GetItemsRecursive(EA.Package pkg) { foreach (EA.Package pkgSub in pkg.Packages) { GetItemsRecursive(pkgSub); } foreach (EA.Element el in pkg.Elements) { GetItemEl(el); } return(_lElId); }
private void exportAll(EA.Repository Repository, DiagramCache diagramCache) { EA.Diagram diagram = null; if (Repository.GetContextItemType() == ObjectType.otDiagram) { diagram = Repository.GetContextObject(); } EA.Package apiPackage = Repository.GetPackageByID(diagram.PackageID); exportRoundTripPackage(Repository, apiPackage, diagramCache); }
/// <summary> /// Export all jobs of the current list number with the respectively defined settings. Currently only changed tagged values are exported/updated. /// </summary> /// <param name="listNumber"></param> /// <returns></returns> public bool ExportBySetting(int listNumber) { bool result = true; _level = -1; _count = 0; _countAll = 0; _countPkg = 0; _countItems = 0; // over all packages foreach (FileImportSettingsItem item in _importSettings) { if (Convert.ToInt32(item.ListNo) == listNumber) { _importModuleFile = item.ExportFile; // handle more than one package int subPackageIndex = -1; // handle zip files like foreach (var itemGuidList in item.PackageGuidList) { string guid = itemGuidList.Guid; subPackageIndex += 1; _pkg = _rep.GetPackageByGuid(guid); if (_pkg == null) { MessageBox.Show( $@"Package of export list {listNumber} with GUID='{guid}' not available. {item.Description} {item.Name} Check Import settings in Settings.Json.", @"Package to import into isn't available, break!"); return(false); } switch (item.ImportType) { case FileImportSettingsItem.ImportTypes.DoorsReqIf: case FileImportSettingsItem.ImportTypes.ReqIf: var reqIfExport = new ReqIfs.ReqIfExport(_rep, _pkg, _importModuleFile, item); result = result && reqIfExport.ExportRequirements(subPackageIndex); //await Task.Run(() => // doorsReqIf.ImportForFile(eaObjectType, eaStereotype, eaStatusNew, eaStatusChanged)); break; } } } } return(true); }
private void buttonOk_Click(object sender, EventArgs e) { if (!checkBoxCreateNew.Checked) { if (this.comboBoxCorrClasses.SelectedIndex != -1) { int i = 0; foreach (int corId in this.possibleCorrespondencesLinkWithConnectors.Keys) { if (i++ == this.comboBoxCorrClasses.SelectedIndex) { this.selectedCorrespondenceLinkId = corId; } } EA.Element selectedLink = sqlRepository.GetOriginalRepository().GetElementByID(selectedCorrespondenceLinkId); corrObject.getRealElement().ClassifierID = selectedLink.ElementID; corrObject.getRealElement().Name = textBoxObjectName.Text; corrObject.getRealElement().Update(); TGGCorrespondence tggCorrOv = new TGGCorrespondence(sqlRepository.GetElementByID(corrObject.ElementID), sqlRepository); tggCorrOv.BindingOperator = this.bo; tggCorrOv.saveTreeToEATaggedValue(true); Close(); } } else if (checkBoxCreateNew.Checked) { EA.Package tggOutermostPackage = EAUtil.sqlEAObjectToOriginalObject(sqlRepository, EAUtil.getOutermostPackage(corrObject, sqlRepository)) as EA.Package; EA.Connector connectorToSource; EA.Connector connectorToTarget; EA.Element selectedLink = createNewCorrespondenceLink(tggOutermostPackage, out connectorToSource, out connectorToTarget); this.corrObject.getRealElement().ClassifierID = selectedLink.ElementID; this.corrObject.getRealElement().Name = textBoxObjectName.Text; this.corrObject.getRealElement().Update(); TGGCorrespondence tggCorrOv = new TGGCorrespondence(sqlRepository.GetElementByID(corrObject.ElementID), sqlRepository); tggCorrOv.BindingOperator = this.bo; tggCorrOv.saveTreeToEATaggedValue(true); List <SQLConnector> references = new List <SQLConnector>(); references.Add(sqlRepository.GetConnectorByID(connectorToSource.ConnectorID)); references.Add(sqlRepository.GetConnectorByID(connectorToTarget.ConnectorID)); possibleCorrespondencesLinkWithConnectors.Add(selectedLink.ElementID, references); Close(); } }
public static List <string> GetStringListOfROOTPackages(string ThingOfInterest, EA.Repository m_Repository, string SP) { List <string> ListToReturn = new List <string>(); //Go aorund all the top level models for (short rootCounter = 0; rootCounter < m_Repository.Models.Count; rootCounter++) { //Let's open the top level root packages. EA.Package RootPackageLoop = (EA.Package)m_Repository.Models.GetAt(rootCounter); ListToReturn.Add(RootPackageLoop.Name); } return(ListToReturn); }
private void exportAll(EA.Repository Repository) { EA.Diagram diagram = null; if (Repository.GetContextItemType() == ObjectType.otDiagram) { diagram = Repository.GetContextObject(); } APIManager.exportAPI(Repository, diagram); EA.Package apiPackage = Repository.GetPackageByID(diagram.PackageID); exportAPIPackage(Repository, apiPackage); }
public Crozdz1(EA.Repository r, EA.Package p, String sciezkaZrodlo, String sciezkaDocelowa, Word W, Statystyki o, bool jezykPl) : base(sciezkaZrodlo, sciezkaDocelowa) { word = W; rep = r; projekt = p; okno = o; okno.Log(Statystyki.LogMsgType.Info, "Lokalizacja pakietów"); definicjePckg = EAUtils.dajPakietSciezkiP(ref projekt, "Definicje"); ITPckg = EAUtils.dajPakietSciezkiP(ref projekt, "IT", "Wkłady Systemowe"); NTPckg = EAUtils.dajPakietSciezkiP(ref projekt, "NT", "Wkłady Systemowe"); okno.Log(Statystyki.LogMsgType.WynikOK, " [ok]\n"); jezykPolski = jezykPl; }
private async void ExecuteAddSpecificationToSpecIfAsync() { EAAPI.Package treeSelectedPackage = _repository.GetTreeSelectedPackage(); if (treeSelectedPackage.Element.Stereotype == "specification") { CachedDataProvider eaCacheDataProvider = new CachedDataProvider(_repository); EADM.Element cachedSpecification = eaCacheDataProvider.GetCachedSpecification(treeSelectedPackage); List <EADM.Element> linearElementList = eaCacheDataProvider.GetSpecificationElementList(cachedSpecification); List <EADM.Element> cachedRequirements = linearElementList.FindAll(el => el.Type == "Requirement" && !el.TaggedValues.Exists(tv => tv.Name == "specifId")); if (cachedRequirements.Count > 0) { ProjectDescriptor project = ExecuteSelectProject(); if (project != null) { await Task.Run(() => { bool error = false; foreach (EADM.Element cachedElement in cachedRequirements) { EAAPI.Element element = _repository.GetElementByID(cachedElement.ElementID); if (element != null) { logger.Info("Integrating requirement " + cachedElement.Name + "..."); Resource repositoryResource = _projectIntegrator.AddRequirementToSpecIF(_requirementMasterDataWriter, element, project.ID); if (repositoryResource == null) { logger.Error("Error integrating requirement. Abort."); error = true; break; } } } if (!error) { logger.Info("Integration finished."); } }); } } } }
private string makePackagePathFromEAPackage(EA.Package pacObj) { EA.Repository repo = ProjectSetting.getEARepo(); if (pacObj.ParentID == 0) { return("/" + pacObj.Name); } else { EA.Package parentPacObj = repo.GetPackageByID(pacObj.ParentID); return(makePackagePathFromEAPackage(parentPacObj) + "/" + pacObj.Name); } }
private void ExportRequirementsToReqIfFile() { object item; if (repository.GetTreeSelectedItem(out item) == ObjectType.otPackage) { EA.Package package = (EA.Package)item; short numOfPackages = package.Packages.Count; for (short index = 0; index < numOfPackages; index++) { } } }
public static List <EA.Package> GetListOfRootNodes(string ThingOfInterest, EA.Repository m_Repository) { List <EA.Package> ListOfPackages = new List <Package>(); for (short rootCounter = 0; rootCounter < m_Repository.Models.Count; rootCounter++) { //Let's open the top level root packages. EA.Package RootPackageLoop = (EA.Package)m_Repository.Models.GetAt(rootCounter); ListOfPackages.Add(RootPackageLoop); } return(ListOfPackages); }
// diagram viewed, add to history public virtual void Add(EA.ObjectType ot, string guid) { if (ot.Equals(EA.ObjectType.otDiagram)) { EA.Diagram dia = (EA.Diagram)_rep.GetDiagramByGuid(guid); if (dia != null) { if (LPosition < 0 || L[LPosition].Guid != guid) { int position = AddEntry(ot, guid); if (position > -1) { UpdateDiagram(position, dia); } } } } if (ot.Equals(EA.ObjectType.otPackage)) { EA.Package pkg = _rep.GetPackageByGuid(guid); if (pkg != null) { // not already defined as bookmark if (this.FindIndex(pkg.PackageGUID) == -1) { int position = AddEntry(ot, guid); if (position > -1) { UpdatePackage(position, pkg); } } } } if (ot.Equals(EA.ObjectType.otElement)) { EA.Element el = _rep.GetElementByGuid(guid); if (el != null) { // not already defined as bookmark if (this.FindIndex(el.ElementGUID) == -1) { int position = AddEntry(ot, guid); if (position > -1) { UpdateElement(position, el); } } } } }
public string FindClassById(int id, EA.Package MyPackage) { for (short i = 0; i < MyPackage.Elements.Count; i++) { EA.Element MyElem = (EA.Element)MyPackage.Elements.GetAt(i); if (MyElem.Type.Equals("Class", StringComparison.InvariantCultureIgnoreCase)) { if (MyElem.ElementID == id) { return(MyElem.Name); } } } return(null); }
public static void SetDirectoryTaggedValues(Repository rep, Package pkg) { bool withCheckIn = false; string guid = pkg.PackageGUID; Element el = rep.GetElementByGuid(guid); if (IsTaggedValuesComplete(el)) return; if (pkg.IsVersionControlled) { int state = pkg.VersionControlGetStatus(); if (state == 4) { MessageBox.Show("", @"Package checked out by another user, break"); return; } if (state == 1) // checked in { CheckOut(rep, pkg); withCheckIn = true; } } pkg = rep.GetPackageByGuid(guid); SetSvnProperty(rep, pkg); // set tagged values el = rep.GetElementByGuid(guid); bool createSvnDate = true; bool createSvnRevision = true; foreach (EA.TaggedValue t in el.TaggedValues) { createSvnDate &= t.Name != "svnDate"; createSvnRevision &= t.Name != "svnRevision"; } EA.TaggedValue tag; if (createSvnDate) { tag = (EA.TaggedValue) el.TaggedValues.AddNew("svnDate", ""); tag.Value = "$Date: $"; el.TaggedValues.Refresh(); tag.Update(); } if (createSvnRevision) { tag = (EA.TaggedValue) el.TaggedValues.AddNew("svnRevision", ""); tag.Value = "$Revision: $"; el.TaggedValues.Refresh(); tag.Update(); } if (pkg.IsVersionControlled) { int state = pkg.VersionControlGetStatus(); if (state == 2 & withCheckIn) // checked out to this user { //EaService.checkIn(rep, pkg, ""); CheckIn(rep, pkg, withGetLatest: true, comment: @"svn tags added"); } } }
public static void SetSvnProperty(Repository rep, Package pkg) { // set SVN properties if (pkg.IsVersionControlled) { var svnHandle = new Svn(rep, pkg); svnHandle.SetProperty(); } }
public static void GotoSvnBrowser(Repository rep, Package pkg) { // set SVN properties if (pkg.IsVersionControlled) { var svnHandle = new Svn(rep, pkg); svnHandle.GotoRepoBrowser(); } }
static void UpdateOperationTypeForPackage(Repository rep, Package pkg) { foreach (Element el1 in pkg.Elements) { foreach (Method m in el1.Methods) { UpdateOperationType(rep, m); } } foreach (Package pkgSub in pkg.Packages) { UpdateOperationTypeForPackage(rep, pkgSub); } }
static void UpdateVcStateRecursive(Repository rep, Package pkg, bool recursive = true) { if (pkg.IsControlled) Util.UpdateVc(rep, pkg); if (recursive) { foreach (Package p in pkg.Packages) { if (p.IsControlled) Util.UpdateVc(rep, p); UpdateVcStateRecursive(rep, p); } } }
private static void CreateActivityForOperationsInPackage(Repository rep, Package pkg) { foreach (Element el in pkg.Elements) { CreateActivityForOperationsInElement(rep, el); } foreach (Package pkg1 in pkg.Packages) { CreateActivityForOperationsInPackage(rep, pkg1); } }
static void ChangeAuthorPackage(Repository rep, Package pkg, string[] args) { Element el = rep.GetElementByGuid(pkg.PackageGUID); el.Author = args[0]; el.Update(); }
private static void CheckOut(Repository rep, Package pkg = null) { if (pkg == null) pkg = rep.GetTreeSelectedPackage(); if (pkg == null) return; pkg = Util.GetFirstControlledPackage(rep, pkg); if (pkg == null) return; var svnHandle = new Svn(rep, pkg); string userNameLockedPackage = svnHandle.GetLockingUser(); if (userNameLockedPackage != "") { MessageBox.Show($"Package is checked out by '{userNameLockedPackage}'"); return; } // try { Cursor.Current = Cursors.WaitCursor; pkg.VersionControlCheckout(""); Cursor.Current = Cursors.Default; } catch (Exception e) { MessageBox.Show($"{e}\n\n{pkg.GetLastError()}", @"Error Checkout"); } finally { Cursor.Current = Cursors.Default; } }
static bool CheckTaggedValuePackage(Package pkg) { bool workForPackage = false; foreach (Package pkg1 in pkg.Packages) { if (pkg1.Name.Equals("Architecture") | pkg1.Name.Equals("Behavior")) { workForPackage = true; break; } } return workForPackage; }
static void SetDirectoryTaggedValueRecursive(Repository rep, Package pkg) { // remember Id, because of reloading package from xmi string pkgGuid = pkg.PackageGUID; if (CheckTaggedValuePackage(pkg)) SetDirectoryTaggedValues(rep, pkg); pkg = rep.GetPackageByGuid(pkgGuid); foreach (Package pkg1 in pkg.Packages) { SetDirectoryTaggedValueRecursive(rep, pkg1); } }
// ReSharper disable once UnusedMethodReturnValue.Local static bool UpdateActivityParameterForPackage(Repository rep, Package pkg) { foreach (Element el in pkg.Elements) { UpdateActivityParameterForElement(rep, el); } foreach (Package pkgSub in pkg.Packages) { // update all packages UpdateActivityParameterForPackage(rep, pkgSub); } return true; }
static void CreateTypeDefStructFromText(Repository rep, Diagram dia, Package pkg, Element el, string txt) { Element elTypedef = null; // delete comment txt = DeleteComment(txt); bool update = false; bool isStruct = true; string elType = "Class"; // find start string regex = @"[\s]*typedef[\s]+(struct|enum)[\s]*([^{]*){"; Match match = Regex.Match(txt, regex); if (!match.Success) return; if (txt.Contains(" enum")) { elType = "Enumeration"; isStruct = false; } txt = txt.Replace(match.Value, ""); // find name regex = @"}[\s]*([^;]*);"; match = Regex.Match(txt, regex); if (!match.Success) return; string name = match.Groups[1].Value.Trim(); if (name == "") return; txt = txt.Remove(match.Index, match.Length); // check if typedef already exists int targetId = Util.GetTypeId(rep, name); if (targetId != 0) { elTypedef = rep.GetElementByID(targetId); update = true; for (int i = elTypedef.Attributes.Count - 1; i > -1; i = i - 1) { elTypedef.Attributes.DeleteAt((short) i, true); } } // create typedef if (update == false) { if (el != null) { // create class below element if ("Interface Class Component".Contains(el.Type)) { elTypedef = (Element) el.Elements.AddNew(name, elType); el.Elements.Refresh(); } else { MessageBox.Show(@"Can't create element below selected Element"); } } else // create class in package { elTypedef = (Element) pkg.Elements.AddNew(name, elType); pkg.Elements.Refresh(); } } if (isStruct) { elTypedef.Stereotype = @"struct"; EA.TaggedValue tag = TaggedValue.AddTaggedValue(elTypedef, "typedef"); tag.Value = "true"; tag.Update(); } if (update == false) { elTypedef.Name = name; elTypedef.Update(); } // add elements if (isStruct) CreateClassAttributesFromText(rep, elTypedef, txt); else CreateEnumerationAttributesFromText(rep, elTypedef, txt); if (update) { rep.RefreshModelView(elTypedef.PackageID); rep.ShowInProjectView(elTypedef); } else { // put diagram object on diagram int left = 0; int right = left + 200; int top = 0; int bottom = top + 100; //int right = diaObj.right + 2 * (diaObj.right - diaObj.left); rep.SaveDiagram(dia.DiagramID); string position = "l=" + left + ";r=" + right + ";t=" + top + ";b=" + bottom + ";"; var diaObj = (DiagramObject) dia.DiagramObjects.AddNew(position, ""); dia.DiagramObjects.Refresh(); diaObj.ElementID = elTypedef.ElementID; diaObj.Update(); } rep.ReloadDiagram(dia.DiagramID); dia.SelectedObjects.AddNew(elTypedef.ElementID.ToString(), elTypedef.ObjectType.ToString()); dia.SelectedObjects.Refresh(); }
private static List<Element> GetInterfacesFromText(Repository rep, Package pkg, string s, bool createWarningNote = true) { var elList = new List<Element>(); s = DeleteComment(s); // string pattern = @"#include\s*[""<]([^.]*)\.h"; string patternPath = @"#include\s*[""<]([^"">]*)"; Match matchPath = Regex.Match(s, patternPath, RegexOptions.Multiline); while (matchPath.Success) { string includePath = matchPath.Groups[1].Value; // get includeName string includeName = Regex.Match(includePath, @"([\w-]*)\.h").Groups[1].Value; Element el = CallOperationAction.GetElementFromName(rep, includeName, "Interface"); if (el == null && createWarningNote) { // create a note el = (Element) pkg.Elements.AddNew("", "Note"); el.Notes = "Interface '" + includeName + "' not available!"; el.Update(); } elList.Add(el); matchPath = matchPath.NextMatch(); } return elList; }
/// <summary> /// Check in of a package. If there are the following package tagged values a get latest is performed to update keywords: /// -- svnDoc /// -- svnRevision /// </summary> /// <param name="rep">Repository</param> /// <param name="pkg">Package, default null</param> /// <param name="withGetLatest">false if you want to avoid a getLatest to update VC keywords /// Tagged Value "svnDoc" or "svnRevision" of package are true</param> /// <param name="comment">A check in comment, default="0" = aks for checkin comment</param> static void CheckIn(Repository rep, Package pkg = null, bool withGetLatest = false, string comment = "0") { if (pkg == null) pkg = rep.GetTreeSelectedPackage(); if (pkg == null) return; pkg = Util.GetFirstControlledPackage(rep, pkg); if (pkg == null) return; var svnHandle = new Svn(rep, pkg); string userNameLockedPackage = svnHandle.GetLockingUser(); if (userNameLockedPackage == "") { MessageBox.Show(@"Package isn't checked out"); return; } if (InputBox(@"Checkin comment", @"Checkin", ref comment) == DialogResult.OK) { // try { Cursor.Current = Cursors.WaitCursor; pkg.VersionControlCheckin(comment); Cursor.Current = Cursors.Default; } catch (Exception e) { MessageBox.Show($"{e} \n\n {pkg.GetLastError()}", @"Error Checkin"); return; } finally { Cursor.Current = Cursors.Default; } } if (withGetLatest) { // check if GetLatest is appropriate Element el = rep.GetElementByGuid(pkg.PackageGUID); foreach (EA.TaggedValue t in el.TaggedValues) { if (t.Name == "svnDoc" | t.Name == "svnRevision") { pkg.VersionControlResynchPkgStatus(false); if (pkg.Flags.Contains("Checkout")) { MessageBox.Show($"Flags={pkg.Flags}", @"Package Checked out, Break!"); return; } pkg.VersionControlGetLatest(true); return; } } } }