| 2139 |
ghuddy |
1 |
|
| 2151 |
ghuddy |
2 |
using System;
|
|
|
3 |
using System.Text;
|
|
|
4 |
using System.Globalization;
|
|
|
5 |
using System.Collections;
|
|
|
6 |
using System.Windows.Forms;
|
| 2141 |
ghuddy |
7 |
using ReqPro40;
|
| 2139 |
ghuddy |
8 |
|
|
|
9 |
namespace EA_ReqPro
|
|
|
10 |
{
|
|
|
11 |
/// <summary>
|
|
|
12 |
/// Summary description for EA_Utils.
|
|
|
13 |
/// </summary>
|
|
|
14 |
public class EA_Utilities
|
|
|
15 |
{
|
|
|
16 |
|
| 2151 |
ghuddy |
17 |
public EA_Utilities()
|
| 2139 |
ghuddy |
18 |
{
|
|
|
19 |
}
|
|
|
20 |
|
|
|
21 |
/// <summary>
|
|
|
22 |
/// This function is designed to parse EA models/packages in a predefined way, whilst allowing
|
|
|
23 |
/// a user to specify what processing is to be done upon or with each element found.
|
|
|
24 |
/// </summary>
|
|
|
25 |
/// <param name="thePackage"></param>
|
|
|
26 |
/// <param name="worker"></param>
|
|
|
27 |
/// <param name="recurse"></param>
|
|
|
28 |
public void findAndProcessPackageElements( EA.Package thePackage, EA_UtilitiesRecursionWorker worker, bool recurse)
|
|
|
29 |
{
|
|
|
30 |
worker.processPackage( thePackage );
|
|
|
31 |
|
|
|
32 |
foreach (EA.Element theElement in thePackage.Elements)
|
|
|
33 |
{
|
|
|
34 |
worker.processElement( theElement );
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
if (recurse == true)
|
|
|
38 |
{
|
|
|
39 |
foreach (EA.Package subPackage in thePackage.Packages)
|
|
|
40 |
{
|
|
|
41 |
// RECURSION
|
|
|
42 |
findAndProcessPackageElements( subPackage, worker, true);
|
|
|
43 |
}
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
|
| 2151 |
ghuddy |
49 |
public string ReadTag(EA.Element theElement, string tagName)
|
|
|
50 |
{
|
|
|
51 |
string result;
|
| 2139 |
ghuddy |
52 |
|
| 2151 |
ghuddy |
53 |
EA.TaggedValue tag = (EA.TaggedValue)theElement.TaggedValues.GetByName(tagName);
|
|
|
54 |
if (null != tag)
|
|
|
55 |
{
|
|
|
56 |
result = tag.Value;
|
|
|
57 |
}
|
|
|
58 |
else
|
|
|
59 |
{
|
|
|
60 |
result = "";
|
|
|
61 |
}
|
|
|
62 |
return result;
|
|
|
63 |
}
|
| 2139 |
ghuddy |
64 |
|
| 2151 |
ghuddy |
65 |
|
|
|
66 |
public bool WriteTag(EA.Element theElement, string tagName, string value)
|
|
|
67 |
{
|
|
|
68 |
bool result;
|
|
|
69 |
EA.TaggedValue tag;
|
|
|
70 |
|
|
|
71 |
tag = (EA.TaggedValue)theElement.TaggedValues.GetByName(tagName);
|
|
|
72 |
if (null != tag)
|
|
|
73 |
{
|
|
|
74 |
tag.Value = value;
|
|
|
75 |
}
|
|
|
76 |
else
|
|
|
77 |
{
|
|
|
78 |
tag = (EA.TaggedValue)theElement.TaggedValues.AddNew(tagName, value);
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
if (tag != null)
|
|
|
82 |
{
|
|
|
83 |
result = tag.Update();
|
|
|
84 |
}
|
|
|
85 |
else
|
|
|
86 |
{
|
|
|
87 |
result = false;
|
|
|
88 |
}
|
|
|
89 |
return result;
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
|
| 2145 |
ghuddy |
93 |
public EA.Package get_selected_package()
|
|
|
94 |
{
|
| 2151 |
ghuddy |
95 |
object o;
|
|
|
96 |
EA.ObjectType type;
|
| 2145 |
ghuddy |
97 |
|
| 2151 |
ghuddy |
98 |
type = Main.EA_Repository.GetTreeSelectedItem(out o);
|
|
|
99 |
if (type == EA.ObjectType.otElement)
|
|
|
100 |
{
|
|
|
101 |
return Main.EA_Repository.GetPackageByID( ((EA.Element)o).PackageID );
|
| 2145 |
ghuddy |
102 |
}
|
| 2151 |
ghuddy |
103 |
else if (type == EA.ObjectType.otPackage)
|
|
|
104 |
{
|
|
|
105 |
return (EA.Package)o;
|
|
|
106 |
}
|
| 2145 |
ghuddy |
107 |
return null;
|
|
|
108 |
}
|
|
|
109 |
|
| 2141 |
ghuddy |
110 |
/// <summary>
|
|
|
111 |
/// Creates a package under the specified parent package. the package is given a tree position
|
|
|
112 |
/// as specified in order for it to be ordered in the model as the caller requires.
|
|
|
113 |
/// </summary>
|
|
|
114 |
/// <param name="parentPackage"></param>
|
|
|
115 |
/// <param name="name"></param>
|
|
|
116 |
/// <param name="treePos"></param>
|
|
|
117 |
/// <returns></returns>
|
|
|
118 |
public EA.Package createPackage(EA.Package parentPackage, string name, int treePos)
|
|
|
119 |
{
|
|
|
120 |
EA.Package newobj = (EA.Package)parentPackage.Packages.AddNew(name, "Package");
|
|
|
121 |
newobj.TreePos = treePos;
|
|
|
122 |
newobj.Update();
|
|
|
123 |
return newobj;
|
|
|
124 |
}
|
|
|
125 |
|
| 2151 |
ghuddy |
126 |
public void DumpEAElement()
|
|
|
127 |
{
|
|
|
128 |
EA.Element ea_ele = (EA.Element)Main.EA_Repository.GetTreeSelectedObject();
|
| 2141 |
ghuddy |
129 |
|
| 2151 |
ghuddy |
130 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "EA Element : " + ea_ele.Name, ea_ele.ElementID);
|
|
|
131 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Author : " + ea_ele.Author, -1);
|
|
|
132 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "ClassfierID : " + ea_ele.ClassfierID.ToString(), -1);
|
|
|
133 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "ClassifierName : " + ea_ele.ClassifierName, -1);
|
|
|
134 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "ClassifierType : " + ea_ele.ClassifierType, -1);
|
|
|
135 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Complexity : " + ea_ele.Complexity, -1);
|
|
|
136 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Difficulty : " + ea_ele.Difficulty, -1);
|
|
|
137 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "ElementGUID : " + ea_ele.ElementGUID, -1);
|
|
|
138 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "ElementID : " + ea_ele.ElementID.ToString(), ea_ele.ElementID);
|
|
|
139 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "EventFlags : " + ea_ele.EventFlags, -1);
|
|
|
140 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "ExtensionPoints : " + ea_ele.ExtensionPoints, -1);
|
|
|
141 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Genfile : " + ea_ele.Genfile, -1);
|
|
|
142 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Genlinks : " + ea_ele.Genlinks, -1);
|
|
|
143 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Gentype : " + ea_ele.Gentype, -1);
|
|
|
144 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "GetLastError : " + ea_ele.GetLastError(), -1);
|
|
|
145 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "GetLinkedDocument : " + ea_ele.GetLinkedDocument(), -1);
|
|
|
146 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "GetStereotypeList : " + ea_ele.GetStereotypeList(), -1);
|
|
|
147 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "MetaType : " + ea_ele.MetaType, -1);
|
|
|
148 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Multiplicity : " + ea_ele.Multiplicity, -1);
|
|
|
149 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Notes : " + ea_ele.Notes, -1);
|
|
|
150 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "PackageID : " + ea_ele.PackageID.ToString(), ea_ele.PackageID);
|
|
|
151 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "ParentID : " + ea_ele.ParentID.ToString(), ea_ele.ParentID);
|
|
|
152 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Persistence : " + ea_ele.Persistence, -1);
|
|
|
153 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Phase : " + ea_ele.Phase, -1);
|
|
|
154 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Priority : " + ea_ele.Priority, -1);
|
|
|
155 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "PropertyType : " + ea_ele.PropertyType.ToString(), -1);
|
|
|
156 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "RunState : " + ea_ele.RunState, -1);
|
|
|
157 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Status : " + ea_ele.Status, -1);
|
|
|
158 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Stereotype : " + ea_ele.Stereotype, -1);
|
|
|
159 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "StereotypeEx : " + ea_ele.StereotypeEx, -1);
|
|
|
160 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "StyleEx : " + ea_ele.StyleEx, -1);
|
|
|
161 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Subtype : " + ea_ele.Subtype.ToString(), -1);
|
|
|
162 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Tablespace : " + ea_ele.Tablespace, -1);
|
|
|
163 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Tag : " + ea_ele.Tag, -1);
|
|
|
164 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "TreePos : " + ea_ele.TreePos.ToString(), -1);
|
|
|
165 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Type : " + ea_ele.Type, -1);
|
|
|
166 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Version : " + ea_ele.Version, -1);
|
|
|
167 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Visibility : " + ea_ele.Visibility, -1);
|
|
|
168 |
}
|
|
|
169 |
|
| 2141 |
ghuddy |
170 |
|
| 2139 |
ghuddy |
171 |
}
|
|
|
172 |
|
|
|
173 |
|
|
|
174 |
/// <summary>
|
|
|
175 |
/// A Base Class designed to work with the findAndProcessPackageElements method.
|
|
|
176 |
/// Users will normally derive their own classes from this and add real functionality
|
|
|
177 |
/// to the over-ridable methods the base class provides.
|
|
|
178 |
/// </summary>
|
|
|
179 |
public class EA_UtilitiesRecursionWorker
|
|
|
180 |
{
|
|
|
181 |
public EA_UtilitiesRecursionWorker()
|
|
|
182 |
{
|
|
|
183 |
}
|
|
|
184 |
|
|
|
185 |
public virtual void processElement( EA.Element theElement )
|
|
|
186 |
{
|
|
|
187 |
}
|
|
|
188 |
public virtual void processPackage( EA.Package thePackage )
|
|
|
189 |
{
|
|
|
190 |
}
|
|
|
191 |
}
|
|
|
192 |
|
|
|
193 |
|
| 2151 |
ghuddy |
194 |
|
|
|
195 |
/// <summary>
|
|
|
196 |
/// This class is one derived from the EA_UtilitiesRecursionWorker base class so that
|
|
|
197 |
/// an instance of it can be used as a parameter in the EA_Utilities.findAndProcessPackageElements
|
|
|
198 |
/// method which recursively parses a given package. Thus, clients can parse EA model structure but
|
|
|
199 |
/// specify their own functionality to be carried out on packages and elements found in the
|
|
|
200 |
/// parsing.
|
|
|
201 |
/// This particular derived class is designed to collect a list of element names from the
|
|
|
202 |
/// package, from elements that have a type that is acceptable.
|
|
|
203 |
/// </summary>
|
|
|
204 |
public class ElementAccumulator : EA_UtilitiesRecursionWorker
|
|
|
205 |
{
|
|
|
206 |
public ArrayList Elements = null;
|
|
|
207 |
public ArrayList ElementIDs = null;
|
|
|
208 |
private ArrayList validElementTypes = null;
|
|
|
209 |
|
|
|
210 |
public ElementAccumulator(ArrayList elementTypeList): base()
|
|
|
211 |
{
|
|
|
212 |
validElementTypes = elementTypeList;
|
|
|
213 |
Elements = new ArrayList();
|
|
|
214 |
ElementIDs = new ArrayList();
|
|
|
215 |
}
|
|
|
216 |
|
|
|
217 |
public override void processElement( EA.Element theElement )
|
|
|
218 |
{
|
|
|
219 |
if (validElementTypes.Contains( theElement.Type ))
|
|
|
220 |
{
|
|
|
221 |
Elements.Add( theElement );
|
|
|
222 |
ElementIDs.Add( theElement.ElementID );
|
|
|
223 |
}
|
|
|
224 |
}
|
| 2141 |
ghuddy |
225 |
}
|
|
|
226 |
|
| 2139 |
ghuddy |
227 |
}
|