| 2139 |
ghuddy |
1 |
//-----------------------------------------------------------------------
|
|
|
2 |
// This is open source licensed under GPL
|
|
|
3 |
//
|
|
|
4 |
//
|
|
|
5 |
using System;
|
|
|
6 |
using System.Text;
|
|
|
7 |
using System.Globalization;
|
|
|
8 |
using System.Collections;
|
|
|
9 |
using System.Windows.Forms;
|
|
|
10 |
using ReqPro40;
|
|
|
11 |
|
|
|
12 |
namespace EA_ReqPro
|
|
|
13 |
{
|
|
|
14 |
public class Main
|
|
|
15 |
{
|
|
|
16 |
bool SyncMode = false;
|
|
|
17 |
|
|
|
18 |
public String EA_Connect(EA.Repository Repository)
|
|
|
19 |
{
|
|
|
20 |
return "a string";
|
|
|
21 |
}
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
public readonly static String GUI_OUTPUT_TAB_NAME = "EA_ReqPro";
|
|
|
25 |
|
|
|
26 |
ArrayList orphanedRequirements = new ArrayList();
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
/// <summary>
|
|
|
30 |
/// Called when EA initialised. Creates an output tab for the add in.
|
|
|
31 |
/// </summary>
|
|
|
32 |
/// <param name="repository"></param>
|
|
|
33 |
public void EA_OnPostInitialized(EA.Repository repository)
|
|
|
34 |
{
|
|
|
35 |
repository.CreateOutputTab(GUI_OUTPUT_TAB_NAME);
|
|
|
36 |
repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
/// <summary>
|
|
|
41 |
/// Event called when user clicks on an entry in the output
|
|
|
42 |
/// window. If an element has been associated with the message, it will
|
|
|
43 |
/// be automatically selected in the project browser.
|
|
|
44 |
/// </summary>
|
|
|
45 |
/// <param name="repository"></param>
|
|
|
46 |
/// <param name="outputTabNea"></param>
|
|
|
47 |
/// <param name="lineText"></param>
|
|
|
48 |
/// <param name="lineIdentifier"></param>
|
|
|
49 |
public void EA_OnOutputItemClicked( EA.Repository repository,
|
|
|
50 |
String outputTabName,
|
|
|
51 |
String lineText,
|
|
|
52 |
Int32 identifier)
|
|
|
53 |
{
|
|
|
54 |
if ((outputTabName == GUI_OUTPUT_TAB_NAME) && (identifier > 0))
|
|
|
55 |
{
|
|
|
56 |
EA.Element element = repository.GetElementByID(identifier);
|
|
|
57 |
repository.ShowInProjectView(element);
|
|
|
58 |
}
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
public object EA_GetMenuItems(EA.Repository repository, string location, string menu)
|
|
|
63 |
{
|
|
|
64 |
switch( menu )
|
|
|
65 |
{
|
|
|
66 |
case "":
|
|
|
67 |
return "-&EA_ReqPro";
|
|
|
68 |
|
|
|
69 |
case "-&Orphaned Elements":
|
|
|
70 |
string[] ar1 = { "&Display In Output Tab"
|
|
|
71 |
//"&Move to Orphaned Package"
|
|
|
72 |
};
|
|
|
73 |
return ar1;
|
|
|
74 |
|
|
|
75 |
case "-&EA_ReqPro":
|
|
|
76 |
string[] ar = {
|
|
|
77 |
"&Associate Package To ReqPro Database",
|
|
|
78 |
"&Export To ReqPro",
|
|
|
79 |
"&Import From ReqPro",
|
|
|
80 |
"&Sync With ReqPro",
|
|
|
81 |
//"&Display EA Element In Output Tab",
|
|
|
82 |
"&List ReqPro Requirement Info",
|
|
|
83 |
"-&Orphaned Elements"
|
|
|
84 |
|
|
|
85 |
};
|
|
|
86 |
return ar;
|
|
|
87 |
}
|
|
|
88 |
return "";
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
|
|
|
92 |
bool IsProjectOpen(EA.Repository Repository)
|
|
|
93 |
{
|
|
|
94 |
try
|
|
|
95 |
{
|
|
|
96 |
EA.Collection collection = Repository.Models;
|
|
|
97 |
return true;
|
|
|
98 |
}
|
|
|
99 |
catch
|
|
|
100 |
{
|
|
|
101 |
return false;
|
|
|
102 |
}
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
|
|
|
106 |
public void EA_GetMenuState(EA.Repository repository, string location, string menuName, string itemName, ref bool isEnabled, ref bool isChecked)
|
|
|
107 |
{
|
|
|
108 |
object o;
|
|
|
109 |
EA.ObjectType type;
|
|
|
110 |
|
|
|
111 |
isChecked = false;
|
|
|
112 |
|
|
|
113 |
if (IsProjectOpen(repository))
|
|
|
114 |
{
|
|
|
115 |
switch (itemName)
|
|
|
116 |
{
|
|
|
117 |
case "&Display EA Element In Output Tab":
|
|
|
118 |
isEnabled = repository.GetTreeSelectedItemType() == EA.ObjectType.otElement;
|
|
|
119 |
break;
|
|
|
120 |
|
|
|
121 |
case "&Associate Package To ReqPro Database":
|
|
|
122 |
type = repository.GetTreeSelectedItem(out o);
|
|
|
123 |
if (type == EA.ObjectType.otPackage)
|
|
|
124 |
{
|
|
|
125 |
isEnabled = true;
|
|
|
126 |
}
|
|
|
127 |
else
|
|
|
128 |
{
|
|
|
129 |
isEnabled = false;
|
|
|
130 |
}
|
|
|
131 |
break;
|
|
|
132 |
|
|
|
133 |
case "&Export To ReqPro":
|
|
|
134 |
case "&Import From ReqPro":
|
|
|
135 |
case "&Sync With ReqPro":
|
|
|
136 |
case "&List ReqPro Requirement Info":
|
|
|
137 |
type = repository.GetTreeSelectedItem(out o);
|
|
|
138 |
if ( (type == EA.ObjectType.otElement) && (((EA.Element)o).Stereotype == "ReqProDB"))
|
|
|
139 |
{
|
|
|
140 |
isEnabled = true;
|
|
|
141 |
}
|
|
|
142 |
else
|
|
|
143 |
{
|
|
|
144 |
isEnabled = false;
|
|
|
145 |
}
|
|
|
146 |
break;
|
|
|
147 |
|
|
|
148 |
case "-&Orphaned Elements":
|
|
|
149 |
case "&Display In Output Tab":
|
|
|
150 |
case "&Move to Orphaned Package":
|
|
|
151 |
if (orphanedRequirements.Count > 0)
|
|
|
152 |
{
|
|
|
153 |
isEnabled = true;
|
|
|
154 |
}
|
|
|
155 |
else
|
|
|
156 |
{
|
|
|
157 |
isEnabled = false;
|
|
|
158 |
}
|
|
|
159 |
break;
|
|
|
160 |
|
|
|
161 |
}
|
|
|
162 |
}
|
|
|
163 |
else
|
|
|
164 |
{
|
|
|
165 |
isEnabled = false;
|
|
|
166 |
}
|
|
|
167 |
}
|
|
|
168 |
|
|
|
169 |
|
|
|
170 |
public void EA_MenuClick(EA.Repository repository, string location, string menu, string itemName)
|
|
|
171 |
{
|
|
|
172 |
switch( itemName )
|
|
|
173 |
{
|
|
|
174 |
case "&Associate Package To ReqPro Database":
|
|
|
175 |
AssociatePackageToReqProDatabase(repository);
|
|
|
176 |
break;
|
|
|
177 |
|
|
|
178 |
case "&Export To ReqPro":
|
|
|
179 |
SyncMode = false;
|
|
|
180 |
ExportToReqPro(repository);
|
|
|
181 |
break;
|
|
|
182 |
|
|
|
183 |
case "&Import From ReqPro":
|
|
|
184 |
SyncMode = false;
|
|
|
185 |
ImportFromReqPro(repository);
|
|
|
186 |
break;
|
|
|
187 |
|
|
|
188 |
case "&Sync With ReqPro":
|
|
|
189 |
SyncMode = true;
|
|
|
190 |
ImportFromReqPro(repository);
|
|
|
191 |
break;
|
|
|
192 |
|
|
|
193 |
case "&List ReqPro Requirement Info":
|
|
|
194 |
ListReqProRequirementInfo(repository);
|
|
|
195 |
break;
|
|
|
196 |
|
|
|
197 |
case "&Display In Output Tab":
|
|
|
198 |
DisplayOrphanedRequirements(repository);
|
|
|
199 |
break;
|
|
|
200 |
|
|
|
201 |
case "&Move to Orphaned Package":
|
|
|
202 |
break;
|
|
|
203 |
|
|
|
204 |
case "&Display EA Element In Output Tab":
|
|
|
205 |
DumpEAElement(repository);
|
|
|
206 |
break;
|
|
|
207 |
}
|
|
|
208 |
}
|
|
|
209 |
|
|
|
210 |
private void ListReqProRequirementInfo(EA.Repository repository)
|
|
|
211 |
{
|
|
|
212 |
ReqPro40.Project rq_project = null;
|
|
|
213 |
try
|
|
|
214 |
{
|
|
|
215 |
EA.Element rq_artifact = (EA.Element)repository.GetTreeSelectedObject();
|
|
|
216 |
if (rq_artifact != null)
|
|
|
217 |
{
|
|
|
218 |
// Create a ReqPro connection object
|
|
|
219 |
RQConnection rq_connection = new RQConnection(repository, rq_artifact);
|
|
|
220 |
if (rq_connection != null)
|
|
|
221 |
{
|
|
|
222 |
// open the ReqPro data base
|
|
|
223 |
rq_project = rq_connection.OpenRqDB();
|
|
|
224 |
if (rq_project != null)
|
|
|
225 |
{
|
|
|
226 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "ReqPro Requirement Info", -1);
|
|
|
227 |
|
|
|
228 |
// Get ReqPro requirements collection
|
|
|
229 |
ReqPro40.Requirements rq_req_collection = get_rq_req_collection(rq_project);
|
|
|
230 |
|
|
|
231 |
int rq_collection_count = rq_req_collection.Count;
|
|
|
232 |
|
|
|
233 |
// loop through all of the ReqPro requirements
|
|
|
234 |
rq_req_collection.MoveFirst();
|
|
|
235 |
|
|
|
236 |
string rq_req_name = "";
|
|
|
237 |
|
|
|
238 |
for (int i = 0; i<rq_collection_count; i++)
|
|
|
239 |
{
|
|
|
240 |
try
|
|
|
241 |
{
|
|
|
242 |
ReqPro40.Requirement rq_req = rq_req_collection.GetCurrentRequirement();
|
|
|
243 |
if (rq_req != null)
|
|
|
244 |
{
|
|
|
245 |
rq_req_name = rq_req.Name;
|
|
|
246 |
|
|
|
247 |
//string rq_datetime = rq_req.VersionDateTime;
|
|
|
248 |
//DateTime rq_dt = new DateTime();
|
|
|
249 |
//rq_dt = DateTime.Parse(rq_datetime, cultureInfo, DateTimeStyles.NoCurrentDateDefault);
|
|
|
250 |
//rq_dt = rq_dt.ToUniversalTime();
|
|
|
251 |
//rq_req.AttrValues["Difficulty", ReqPro40.enumAttrValueLookups.eAttrValueLookup_Label].Text;
|
|
|
252 |
//rq_req.AttrValues["Priority", ReqPro40.enumAttrValueLookups.eAttrValueLookup_Label].Text;
|
|
|
253 |
//rq_req.AttrValues["Status", ReqPro40.enumAttrValueLookups.eAttrValueLookup_Label].Text;
|
|
|
254 |
//rq_req.VersionNumber;
|
|
|
255 |
|
|
|
256 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,
|
|
|
257 |
"ReqPro : "
|
|
|
258 |
+ rq_req.get_Tag(ReqPro40.enumTagFormat.eTagFormat_Tag)
|
|
|
259 |
+ ", "
|
|
|
260 |
+ rq_req_name
|
|
|
261 |
+ ", "
|
|
|
262 |
+ rq_req.GUID, -1 );
|
|
|
263 |
}
|
|
|
264 |
}
|
|
|
265 |
catch (Exception ex)
|
|
|
266 |
{
|
|
|
267 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Exception (ImportFromReqPro), " + ex.Message + ", " + rq_req_name, -1);
|
|
|
268 |
|
|
|
269 |
// Try an re-establish connection and requirement collection references
|
|
|
270 |
rq_project = rq_connection.ReOpenRqDB();
|
|
|
271 |
rq_req_collection = get_rq_req_collection(rq_project);
|
|
|
272 |
rq_collection_count = rq_req_collection.Count;
|
|
|
273 |
rq_req_collection.MoveFirst();
|
|
|
274 |
for (int i2 = 0; i2<i; i2++)
|
|
|
275 |
{
|
|
|
276 |
rq_req_collection.MoveNext();
|
|
|
277 |
}
|
|
|
278 |
i--;
|
|
|
279 |
continue;
|
|
|
280 |
}
|
|
|
281 |
|
|
|
282 |
rq_req_collection.MoveNext();
|
|
|
283 |
}
|
|
|
284 |
|
|
|
285 |
|
|
|
286 |
}
|
|
|
287 |
else
|
|
|
288 |
{
|
|
|
289 |
MessageBox.Show("ERROR: Cannot establish connection to ReqPro database.\n\n" +
|
|
|
290 |
"Check the tagged values in the artifact are correct.\n" +
|
|
|
291 |
"Check the database still exists or is not locked by\n" +
|
|
|
292 |
"another user, or has not been password protected." );
|
|
|
293 |
}
|
|
|
294 |
}
|
|
|
295 |
}
|
|
|
296 |
}
|
|
|
297 |
catch (Exception ex)
|
|
|
298 |
{
|
|
|
299 |
MessageBox.Show(ex.Message, "Error (ImportFromReqPro)", MessageBoxButtons.OK);
|
|
|
300 |
if (rq_project != null)
|
|
|
301 |
rq_project.CloseProject();
|
|
|
302 |
}
|
|
|
303 |
}
|
|
|
304 |
|
|
|
305 |
|
|
|
306 |
private void DumpEAElement(EA.Repository repository)
|
|
|
307 |
{
|
|
|
308 |
EA.Element ea_ele = (EA.Element)repository.GetTreeSelectedObject();
|
|
|
309 |
|
|
|
310 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "EA Element : " + ea_ele.Name, ea_ele.ElementID);
|
|
|
311 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Author : " + ea_ele.Author, -1);
|
|
|
312 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "ClassfierID : " + ea_ele.ClassfierID.ToString(), -1);
|
|
|
313 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "ClassifierName : " + ea_ele.ClassifierName, -1);
|
|
|
314 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "ClassifierType : " + ea_ele.ClassifierType, -1);
|
|
|
315 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Complexity : " + ea_ele.Complexity, -1);
|
|
|
316 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Difficulty : " + ea_ele.Difficulty, -1);
|
|
|
317 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "ElementGUID : " + ea_ele.ElementGUID, -1);
|
|
|
318 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "ElementID : " + ea_ele.ElementID.ToString(), ea_ele.ElementID);
|
|
|
319 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "EventFlags : " + ea_ele.EventFlags, -1);
|
|
|
320 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "ExtensionPoints : " + ea_ele.ExtensionPoints, -1);
|
|
|
321 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Genfile : " + ea_ele.Genfile, -1);
|
|
|
322 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Genlinks : " + ea_ele.Genlinks, -1);
|
|
|
323 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Gentype : " + ea_ele.Gentype, -1);
|
|
|
324 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "GetLastError : " + ea_ele.GetLastError(), -1);
|
|
|
325 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "GetLinkedDocument : " + ea_ele.GetLinkedDocument(), -1);
|
|
|
326 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "GetStereotypeList : " + ea_ele.GetStereotypeList(), -1);
|
|
|
327 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "MetaType : " + ea_ele.MetaType, -1);
|
|
|
328 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Multiplicity : " + ea_ele.Multiplicity, -1);
|
|
|
329 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Notes : " + ea_ele.Notes, -1);
|
|
|
330 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "PackageID : " + ea_ele.PackageID.ToString(), ea_ele.PackageID);
|
|
|
331 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "ParentID : " + ea_ele.ParentID.ToString(), ea_ele.ParentID);
|
|
|
332 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Persistence : " + ea_ele.Persistence, -1);
|
|
|
333 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Phase : " + ea_ele.Phase, -1);
|
|
|
334 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Priority : " + ea_ele.Priority, -1);
|
|
|
335 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "PropertyType : " + ea_ele.PropertyType.ToString(), -1);
|
|
|
336 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "RunState : " + ea_ele.RunState, -1);
|
|
|
337 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Status : " + ea_ele.Status, -1);
|
|
|
338 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Stereotype : " + ea_ele.Stereotype, -1);
|
|
|
339 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "StereotypeEx : " + ea_ele.StereotypeEx, -1);
|
|
|
340 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "StyleEx : " + ea_ele.StyleEx, -1);
|
|
|
341 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Subtype : " + ea_ele.Subtype.ToString(), -1);
|
|
|
342 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Tablespace : " + ea_ele.Tablespace, -1);
|
|
|
343 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Tag : " + ea_ele.Tag, -1);
|
|
|
344 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "TreePos : " + ea_ele.TreePos.ToString(), -1);
|
|
|
345 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Type : " + ea_ele.Type, -1);
|
|
|
346 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Version : " + ea_ele.Version, -1);
|
|
|
347 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Visibility : " + ea_ele.Visibility, -1);
|
|
|
348 |
}
|
|
|
349 |
|
|
|
350 |
private void DisplayOrphanedRequirements(EA.Repository repository)
|
|
|
351 |
{
|
|
|
352 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "EA Orphaned Requirements", -1 );
|
|
|
353 |
foreach (EA.Element theElement in orphanedRequirements)
|
|
|
354 |
{
|
|
|
355 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, theElement.Name, theElement.ElementID );
|
|
|
356 |
}
|
|
|
357 |
}
|
|
|
358 |
|
|
|
359 |
private void ImportFromReqPro(EA.Repository repository)
|
|
|
360 |
{
|
|
|
361 |
ReqPro40.Project rq_project = null;
|
|
|
362 |
try
|
|
|
363 |
{
|
|
|
364 |
EA.Element rq_artifact = (EA.Element)repository.GetTreeSelectedObject();
|
|
|
365 |
if (rq_artifact != null)
|
|
|
366 |
{
|
|
|
367 |
// Create a ReqPro connection object
|
|
|
368 |
RQConnection rq_connection = new RQConnection(repository, rq_artifact);
|
|
|
369 |
if (rq_connection != null)
|
|
|
370 |
{
|
|
|
371 |
// open the ReqPro data base
|
|
|
372 |
rq_project = rq_connection.OpenRqDB();
|
|
|
373 |
if (rq_project != null)
|
|
|
374 |
{
|
|
|
375 |
orphanedRequirements.Clear();
|
|
|
376 |
|
|
|
377 |
ImportFromReqPro(repository, rq_connection, rq_project, rq_artifact);
|
|
|
378 |
}
|
|
|
379 |
else
|
|
|
380 |
{
|
|
|
381 |
MessageBox.Show("ERROR: Cannot establish connection to ReqPro database.\n\n" +
|
|
|
382 |
"Check the tagged values in the artifact are correct.\n" +
|
|
|
383 |
"Check the database still exists or is not locked by\n" +
|
|
|
384 |
"another user, or has not been password protected." );
|
|
|
385 |
}
|
|
|
386 |
}
|
|
|
387 |
}
|
|
|
388 |
}
|
|
|
389 |
catch (Exception ex)
|
|
|
390 |
{
|
|
|
391 |
MessageBox.Show(ex.Message, "Error (ImportFromReqPro)", MessageBoxButtons.OK);
|
|
|
392 |
if (rq_project != null)
|
|
|
393 |
rq_project.CloseProject();
|
|
|
394 |
}
|
|
|
395 |
}
|
|
|
396 |
|
|
|
397 |
private ReqPro40.Requirements get_rq_req_collection(ReqPro40.Project rq_project)
|
|
|
398 |
{
|
|
|
399 |
return rq_project.GetRequirements(0,
|
|
|
400 |
enumRequirementsLookups.eReqsLookup_All,
|
|
|
401 |
enumRequirementsWeights.eReqWeight_Heavy,
|
|
|
402 |
enumRequirementFlags.eReqFlag_RetainHierarchy,
|
|
|
403 |
4095, 200);
|
|
|
404 |
}
|
|
|
405 |
|
|
|
406 |
/// <summary>
|
|
|
407 |
/// IMPORT requirements from a ReqPro database
|
|
|
408 |
/// </summary>
|
|
|
409 |
/// <param name="repository"></param>
|
|
|
410 |
private void ImportFromReqPro(EA.Repository repository, RQConnection rq_connection, ReqPro40.Project rq_project, EA.Element rq_artifact)
|
|
|
411 |
{
|
|
|
412 |
try
|
|
|
413 |
{
|
|
|
414 |
bool exportNeeded = false;
|
|
|
415 |
|
|
|
416 |
IFormatProvider cultureInfo = new CultureInfo("en-US", true);
|
|
|
417 |
|
|
|
418 |
string importDateTime = System.TimeZone.CurrentTimeZone.ToUniversalTime( System.DateTime.Now ).ToString();
|
|
|
419 |
|
|
|
420 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "EA Requirement import at " + importDateTime, -1 );
|
|
|
421 |
|
|
|
422 |
EA_Utilities EA_Utils = new EA_Utilities(repository);
|
|
|
423 |
|
|
|
424 |
// Update the ReqProDB stereotypes element with all the EA requirements in the package
|
|
|
425 |
UpdatePackageToReqProDatabaseAssociation(repository, rq_artifact);
|
|
|
426 |
|
|
|
427 |
// Get a list of EA requirements and their associated ReqPro GUIDs
|
|
|
428 |
ArrayList ea_reqs = new ArrayList();
|
|
|
429 |
ArrayList ea_GUIDs = new ArrayList();
|
|
|
430 |
ArrayList ea_req_matched = new ArrayList();
|
|
|
431 |
foreach (EA.Connector connector in rq_artifact.Connectors)
|
|
|
432 |
{
|
|
|
433 |
EA.Element ea_req = repository.GetElementByID( connector.SupplierID );
|
|
|
434 |
if (ea_req != null)
|
|
|
435 |
{
|
|
|
436 |
ea_reqs.Add(ea_req);
|
|
|
437 |
string GUID = EA_Utils.ReadTag(ea_req, "GUID");
|
|
|
438 |
ea_GUIDs.Add(GUID);
|
|
|
439 |
ea_req_matched.Add(false);
|
|
|
440 |
}
|
|
|
441 |
}
|
|
|
442 |
|
|
|
443 |
// Obtain the EA parent package so that we can create under it an import package
|
|
|
444 |
// if need be.
|
|
|
445 |
EA.Package parentPackage = repository.GetPackageByID( rq_artifact.PackageID );
|
|
|
446 |
EA.Package importPackage = null;
|
|
|
447 |
|
|
|
448 |
// Get ReqPro requirements collection
|
|
|
449 |
ReqPro40.Requirements rq_req_collection = get_rq_req_collection(rq_project);
|
|
|
450 |
|
|
|
451 |
int rq_collection_count = rq_req_collection.Count;
|
|
|
452 |
|
|
|
453 |
// loop through all of the ReqPro requirements
|
|
|
454 |
rq_req_collection.MoveFirst();
|
|
|
455 |
|
|
|
456 |
string rq_req_name = "";
|
|
|
457 |
|
|
|
458 |
for (int i = 0; i<rq_collection_count; i++)
|
|
|
459 |
{
|
|
|
460 |
try
|
|
|
461 |
{
|
|
|
462 |
ReqPro40.Requirement rq_req = rq_req_collection.GetCurrentRequirement();
|
|
|
463 |
if (rq_req != null)
|
|
|
464 |
{
|
|
|
465 |
rq_req_name = rq_req.Name;
|
|
|
466 |
|
|
|
467 |
// Find which EA requirement element refers to the current ReqPro GUID
|
|
|
468 |
int i_ea_req;
|
|
|
469 |
i_ea_req = ea_GUIDs.IndexOf( rq_req.GUID );
|
|
|
470 |
|
|
|
471 |
// If EA element was found
|
|
|
472 |
if (0 <= i_ea_req)
|
|
|
473 |
{
|
|
|
474 |
ea_req_matched[i_ea_req] = true;
|
|
|
475 |
|
|
|
476 |
EA.Element ea_req = ((EA.Element)ea_reqs[i_ea_req]);
|
|
|
477 |
|
|
|
478 |
string rq_datetime = rq_req.VersionDateTime;
|
|
|
479 |
DateTime rq_dt = new DateTime();
|
|
|
480 |
rq_dt = DateTime.Parse(rq_datetime, cultureInfo, DateTimeStyles.NoCurrentDateDefault);
|
|
|
481 |
rq_dt = rq_dt.ToUniversalTime();
|
|
|
482 |
//repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, rq_req.Name + " DATETIME: " + rq_dt.ToString(), -1);
|
|
|
483 |
|
|
|
484 |
DateTime ea_dt = ea_req.Modified.ToUniversalTime();
|
|
|
485 |
//repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, ea_req.Name + " DATETIME: " + ea_dt.ToString(), -1);
|
|
|
486 |
|
|
|
487 |
if (SyncMode && (0 <= ea_dt.CompareTo(rq_dt)))
|
|
|
488 |
{
|
|
|
489 |
exportNeeded = true;
|
|
|
490 |
//repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "ReqPro Requirement counterpart in EA was NOT updated (was newer): " + ea_req.Name, ea_req.ElementID );
|
|
|
491 |
}
|
|
|
492 |
else
|
|
|
493 |
{
|
|
|
494 |
// This ReqPro requirement already has a counterpart in EA, so we must simply
|
|
|
495 |
// update the counterpart.
|
|
|
496 |
ea_req.Name = rq_req.Name;
|
|
|
497 |
ea_req.Notes = rq_req.Text;
|
|
|
498 |
|
|
|
499 |
ea_req.Difficulty = rq_req.AttrValues["Difficulty", ReqPro40.enumAttrValueLookups.eAttrValueLookup_Label].Text;
|
|
|
500 |
ea_req.Priority = rq_req.AttrValues["Priority", ReqPro40.enumAttrValueLookups.eAttrValueLookup_Label].Text;
|
|
|
501 |
ea_req.Status = rq_req.AttrValues["Status", ReqPro40.enumAttrValueLookups.eAttrValueLookup_Label].Text;
|
|
|
502 |
ea_req.Version = rq_req.VersionNumber;
|
|
|
503 |
|
|
|
504 |
ea_req.Update();
|
|
|
505 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "ReqPro Requirement counterpart in EA was updated : " + ea_req.Name, ea_req.ElementID );
|
|
|
506 |
}
|
|
|
507 |
}
|
|
|
508 |
else
|
|
|
509 |
{
|
|
|
510 |
// This ReqPro requirement does not have a counterpart in EA, so we must create
|
|
|
511 |
// a new one.
|
|
|
512 |
|
|
|
513 |
// Create the import package if not already done
|
|
|
514 |
if (importPackage == null)
|
|
|
515 |
{
|
|
|
516 |
importPackage = (EA.Package )parentPackage.Packages.AddNew( "import " + importDateTime, "Package");
|
|
|
517 |
importPackage.Update();
|
|
|
518 |
}
|
|
|
519 |
|
|
|
520 |
// create the new EA requirement in the import package
|
|
|
521 |
EA.Element ea_req = (EA.Element)importPackage.Elements.AddNew( rq_req.Name, "Requirement");
|
|
|
522 |
ea_req.Notes = rq_req.Text;
|
|
|
523 |
|
|
|
524 |
ea_req.Difficulty = rq_req.AttrValues["Difficulty", ReqPro40.enumAttrValueLookups.eAttrValueLookup_Label].Text;
|
|
|
525 |
ea_req.Priority = rq_req.AttrValues["Priority", ReqPro40.enumAttrValueLookups.eAttrValueLookup_Label].Text;
|
|
|
526 |
ea_req.Status = rq_req.AttrValues["Status", ReqPro40.enumAttrValueLookups.eAttrValueLookup_Label].Text;
|
|
|
527 |
ea_req.Version = rq_req.VersionNumber;
|
|
|
528 |
|
|
|
529 |
EA_Utils.WriteTag(ea_req, "GUID", rq_req.GUID);
|
|
|
530 |
EA_Utils.WriteTag(ea_req, "TAG", rq_req.get_Tag(ReqPro40.enumTagFormat.eTagFormat_Tag));
|
|
|
531 |
ea_req.Update();
|
|
|
532 |
|
|
|
533 |
// Add the new requirement to the rq_artifact
|
|
|
534 |
add_connection(repository, rq_artifact, ea_req);
|
|
|
535 |
|
|
|
536 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "ReqPro Requirement counterpart in EA was created : " + ea_req.Name, ea_req.ElementID );
|
|
|
537 |
}
|
|
|
538 |
}
|
|
|
539 |
}
|
|
|
540 |
catch (Exception ex)
|
|
|
541 |
{
|
|
|
542 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Exception (ImportFromReqPro), " + ex.Message + ", " + rq_req_name, -1);
|
|
|
543 |
|
|
|
544 |
// Try an re-establish connection and requirement collection references
|
|
|
545 |
rq_project = rq_connection.ReOpenRqDB();
|
|
|
546 |
rq_req_collection = get_rq_req_collection(rq_project);
|
|
|
547 |
rq_collection_count = rq_req_collection.Count;
|
|
|
548 |
rq_req_collection.MoveFirst();
|
|
|
549 |
for (int i2 = 0; i2<i; i2++)
|
|
|
550 |
{
|
|
|
551 |
rq_req_collection.MoveNext();
|
|
|
552 |
}
|
|
|
553 |
i--;
|
|
|
554 |
continue;
|
|
|
555 |
}
|
|
|
556 |
|
|
|
557 |
rq_req_collection.MoveNext();
|
|
|
558 |
}
|
|
|
559 |
|
|
|
560 |
|
|
|
561 |
// Now check for orphaned EA requirements
|
|
|
562 |
for (int i = 0; i < ea_GUIDs.Count; i++)
|
|
|
563 |
{
|
|
|
564 |
string rq_GUID = (string)ea_GUIDs[i];
|
|
|
565 |
if (rq_GUID != "")
|
|
|
566 |
{
|
|
|
567 |
if ((bool)ea_req_matched[i] == false)
|
|
|
568 |
{
|
|
|
569 |
EA.Element ea_req = (EA.Element)ea_reqs[i];
|
|
|
570 |
orphanedRequirements.Add( ea_req );
|
|
|
571 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "EA Requirement Orphaned (counterpart in ReqPro was missing) : " + ea_req.Name, ea_req.ElementID );
|
|
|
572 |
}
|
|
|
573 |
}
|
|
|
574 |
}
|
|
|
575 |
|
|
|
576 |
if (exportNeeded && SyncMode)
|
|
|
577 |
{
|
|
|
578 |
ExportToReqPro(repository, rq_connection, rq_project, rq_artifact);
|
|
|
579 |
}
|
|
|
580 |
else if (exportNeeded)
|
|
|
581 |
{
|
|
|
582 |
MessageBox.Show("Some EA requirements were modified later than their ReqPro counterparts.\n" +
|
|
|
583 |
"You may need to perform an export following this import");
|
|
|
584 |
}
|
|
|
585 |
|
|
|
586 |
rq_project.CloseProject();
|
|
|
587 |
|
|
|
588 |
repository.RefreshModelView(parentPackage.PackageID);
|
|
|
589 |
|
|
|
590 |
if (importPackage == null)
|
|
|
591 |
{
|
|
|
592 |
if (orphanedRequirements.Count == 0)
|
|
|
593 |
MessageBox.Show("Import From ReqPro Complete.\n\n" +
|
|
|
594 |
"No new requirements were found.");
|
|
|
595 |
else
|
|
|
596 |
MessageBox.Show("Import From ReqPro Complete.\n\n" +
|
|
|
597 |
"No new requirements were found.\n\n" +
|
|
|
598 |
"Some EA requirements were orphaned.");
|
|
|
599 |
}
|
|
|
600 |
else
|
|
|
601 |
{
|
|
|
602 |
if (orphanedRequirements.Count == 0)
|
|
|
603 |
MessageBox.Show("Import From ReqPro Complete.\n\n" +
|
|
|
604 |
"New requirements were found\n" +
|
|
|
605 |
"and added under package \"" + importPackage.Name + "\"" );
|
|
|
606 |
else
|
|
|
607 |
MessageBox.Show("Import From ReqPro Complete.\n\n" +
|
|
|
608 |
"New requirements were found\n" +
|
|
|
609 |
"and added under package \"" + importPackage.Name + "\"\n\n" +
|
|
|
610 |
"Some EA requirements were orphaned.");
|
|
|
611 |
}
|
|
|
612 |
}
|
|
|
613 |
catch (Exception ex)
|
|
|
614 |
{
|
|
|
615 |
MessageBox.Show(ex.Message, "Error (ImportFromReqPro)", MessageBoxButtons.OK);
|
|
|
616 |
if (rq_project != null)
|
|
|
617 |
rq_project.CloseProject();
|
|
|
618 |
}
|
|
|
619 |
}
|
|
|
620 |
|
|
|
621 |
|
|
|
622 |
private void add_connection(EA.Repository repository, EA.Element rq_artifact, EA.Element ea_req)
|
|
|
623 |
{
|
|
|
624 |
// Add the new requirement to the rq_artifact
|
|
|
625 |
EA.Connector c = (EA.Connector)rq_artifact.Connectors.AddNew("", "Dependency");
|
|
|
626 |
c.SupplierID = ea_req.ElementID;
|
|
|
627 |
c.Stereotype = "trace";
|
|
|
628 |
c.Direction = "Destination -> Source";
|
|
|
629 |
if (false == c.Update())
|
|
|
630 |
{
|
|
|
631 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "New Connector Error : " + c.GetLastError(), ea_req.ElementID );
|
|
|
632 |
}
|
|
|
633 |
}
|
|
|
634 |
|
|
|
635 |
|
|
|
636 |
|
|
|
637 |
private void ExportAttr(EA.Repository repository, ReqPro40.Requirement rq_req, string EA_AttrLabel, string EA_AttrValue)
|
|
|
638 |
{
|
|
|
639 |
try
|
|
|
640 |
{
|
|
|
641 |
//repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,"EA_AttrLabel = " + EA_AttrLabel, -1);
|
|
|
642 |
//repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,"EA_AttrValue = " + EA_AttrValue, -1);
|
|
|
643 |
foreach(ReqPro40.AttrValue rq_AttrValue in rq_req.AttrValues)
|
|
|
644 |
{
|
|
|
645 |
//repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME," rq_AttrValue.Text = " + rq_AttrValue.Text,-1);
|
|
|
646 |
//repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME," rq_AttrValue.Label = " + rq_AttrValue.Label, -1);
|
|
|
647 |
|
|
|
648 |
if (rq_AttrValue.Label.StartsWith(EA_AttrLabel))
|
|
|
649 |
{
|
|
|
650 |
switch (rq_AttrValue.DataType)
|
|
|
651 |
{
|
|
|
652 |
case ReqPro40.enumAttrDataTypes.eAttrDataTypes_Text:
|
|
|
653 |
rq_AttrValue.Text = EA_AttrValue;
|
|
|
654 |
break;
|
|
|
655 |
|
|
|
656 |
case ReqPro40.enumAttrDataTypes.eAttrDataTypes_List:
|
|
|
657 |
case ReqPro40.enumAttrDataTypes.eAttrDataTypes_MultiSelect:
|
|
|
658 |
|
|
|
659 |
foreach( ReqPro40.ListItemValue rq_ListItemValue in rq_AttrValue.ListItemValues)
|
|
|
660 |
{
|
|
|
661 |
//repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, " rq_ListItemValue.Text = " + rq_ListItemValue.Text,-1);
|
|
|
662 |
//repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME," BEFORE: " + rq_ListItemValue.Selected.ToString(),-1);
|
|
|
663 |
|
|
|
664 |
if (rq_ListItemValue.Text == EA_AttrValue)
|
|
|
665 |
{
|
|
|
666 |
rq_ListItemValue.Selected = true;
|
|
|
667 |
}
|
|
|
668 |
else
|
|
|
669 |
{
|
|
|
670 |
rq_ListItemValue.Selected = false;
|
|
|
671 |
}
|
|
|
672 |
//repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME," AFTER: " + rq_ListItemValue.Selected.ToString(),-1);
|
|
|
673 |
|
|
|
674 |
}
|
|
|
675 |
break;
|
|
|
676 |
}
|
|
|
677 |
break;
|
|
|
678 |
}
|
|
|
679 |
}
|
|
|
680 |
}
|
|
|
681 |
catch
|
|
|
682 |
{
|
|
|
683 |
|
|
|
684 |
// do nothing
|
|
|
685 |
}
|
|
|
686 |
}
|
|
|
687 |
|
|
|
688 |
|
|
|
689 |
private void ExportToReqPro(EA.Repository repository)
|
|
|
690 |
{
|
|
|
691 |
ReqPro40.Project rq_project = null;
|
|
|
692 |
|
|
|
693 |
try
|
|
|
694 |
{
|
|
|
695 |
EA.Element rq_artifact = (EA.Element)repository.GetTreeSelectedObject();
|
|
|
696 |
if (rq_artifact != null)
|
|
|
697 |
{
|
|
|
698 |
// Create a ReqPro connection object
|
|
|
699 |
RQConnection rq_connection = new RQConnection(repository, rq_artifact);
|
|
|
700 |
if (rq_connection != null)
|
|
|
701 |
{
|
|
|
702 |
// open the ReqPro data base
|
|
|
703 |
rq_project = rq_connection.OpenRqDB();
|
|
|
704 |
if (rq_project != null)
|
|
|
705 |
{
|
|
|
706 |
orphanedRequirements.Clear();
|
|
|
707 |
|
|
|
708 |
ExportToReqPro(repository, rq_connection, rq_project, rq_artifact);
|
|
|
709 |
}
|
|
|
710 |
else
|
|
|
711 |
{
|
|
|
712 |
MessageBox.Show("ERROR: Cannot establish connection to ReqPro database.\n\n" +
|
|
|
713 |
"Check the tagged values in the artifact are correct.\n" +
|
|
|
714 |
"Check the database still exists or is not locked by\n" +
|
|
|
715 |
"another user, or has not been password protected." );
|
|
|
716 |
}
|
|
|
717 |
}
|
|
|
718 |
}
|
|
|
719 |
}
|
|
|
720 |
catch (Exception ex)
|
|
|
721 |
{
|
|
|
722 |
MessageBox.Show(ex.Message, "Error (ExportToReqPro)", MessageBoxButtons.OK);
|
|
|
723 |
if (rq_project != null)
|
|
|
724 |
rq_project.CloseProject();
|
|
|
725 |
}
|
|
|
726 |
}
|
|
|
727 |
|
|
|
728 |
/// <summary>
|
|
|
729 |
/// EXPORT requirements to ReqPro Database
|
|
|
730 |
/// </summary>
|
|
|
731 |
/// <param name="repository"></param>
|
|
|
732 |
private void ExportToReqPro(EA.Repository repository, RQConnection rq_connection, ReqPro40.Project rq_project, EA.Element rq_artifact)
|
|
|
733 |
{
|
|
|
734 |
ReqPro40.Requirements rq_req_collection;
|
|
|
735 |
|
|
|
736 |
try
|
|
|
737 |
{
|
|
|
738 |
IFormatProvider cultureInfo = new CultureInfo("en-US", true);
|
|
|
739 |
|
|
|
740 |
bool importNeeded = false;
|
|
|
741 |
|
|
|
742 |
string exportDateTime = System.TimeZone.CurrentTimeZone.ToUniversalTime( System.DateTime.Now ).ToString();
|
|
|
743 |
|
|
|
744 |
bool newReqMade = false;
|
|
|
745 |
|
|
|
746 |
EA_Utilities EA_Utils = new EA_Utilities(repository);
|
|
|
747 |
|
|
|
748 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "EA Requirement export at " + exportDateTime, -1 );
|
|
|
749 |
|
|
|
750 |
// Get ReqPro requirements collection
|
|
|
751 |
rq_req_collection = get_rq_req_collection(rq_project);
|
|
|
752 |
|
|
|
753 |
// Get a list of ReqPro requirements and GUIDs
|
|
|
754 |
//ArrayList rq_GUIDs = new ArrayList();
|
|
|
755 |
//ArrayList rq_reqs = new ArrayList();
|
|
|
756 |
//rq_req_collection.MoveFirst();
|
|
|
757 |
//for (int i = 0; i < rq_req_collection.Count; i++)
|
|
|
758 |
// {
|
|
|
759 |
// ReqPro40.Requirement rq_req = rq_req_collection.GetCurrentRequirement();
|
|
|
760 |
// rq_GUIDs.Add( rq_req.GUID );
|
|
|
761 |
// rq_reqs.Add(rq_req);
|
|
|
762 |
// rq_req_collection.MoveNext();
|
|
|
763 |
// }
|
|
|
764 |
|
|
|
765 |
// Update the ReqProDB stereotypes element with all the requirements in the package
|
|
|
766 |
UpdatePackageToReqProDatabaseAssociation(repository, rq_artifact);
|
|
|
767 |
|
|
|
768 |
// Scan through the EA requirement artifact's links.
|
|
|
769 |
foreach (EA.Connector connector in rq_artifact.Connectors)
|
|
|
770 |
{
|
|
|
771 |
System.Threading.Thread.Sleep(100);
|
|
|
772 |
|
|
|
773 |
EA.Element ea_req = repository.GetElementByID( connector.SupplierID );
|
|
|
774 |
while (ea_req != null)
|
|
|
775 |
{
|
|
|
776 |
try
|
|
|
777 |
{
|
|
|
778 |
//repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,"Exporting " + ea_req.Name, ea_req.ElementID);
|
|
|
779 |
// if the linked element does not have a ReqPro GUID, then we assume it is
|
|
|
780 |
// a new requirement that must be added to ReqPro
|
|
|
781 |
string GUID = EA_Utils.ReadTag(ea_req, "GUID");
|
|
|
782 |
if (GUID == "")
|
|
|
783 |
{
|
|
|
784 |
// must add the requirement to ReqPro
|
|
|
785 |
object vReqTypeLookupValue = "SR";
|
|
|
786 |
object nothing = Type.Missing;
|
|
|
787 |
ReqPro40.Requirement rq_req =
|
|
|
788 |
rq_req_collection.Add( ea_req.Name, ea_req.Notes,
|
|
|
789 |
vReqTypeLookupValue,
|
|
|
790 |
ReqPro40.enumReqTypesLookups.eReqTypesLookups_Prefix,
|
|
|
791 |
ea_req.Version,
|
|
|
792 |
"",
|
|
|
793 |
nothing,
|
|
|
794 |
ReqPro40.enumRequirementLookups.eReqLookup_Empty);
|
|
|
795 |
|
|
|
796 |
ExportAttr(repository, rq_req, "Difficulty", ea_req.Difficulty );
|
|
|
797 |
ExportAttr(repository, rq_req, "Priority" , ea_req.Priority );
|
|
|
798 |
ExportAttr(repository, rq_req, "Status" , ea_req.Status );
|
|
|
799 |
//ExportAttr(repository, rq_req, "Type" , ea_req.Stereotype );
|
|
|
800 |
|
|
|
801 |
rq_req.Save();
|
|
|
802 |
|
|
|
803 |
rq_req_collection.Save();
|
|
|
804 |
|
|
|
805 |
EA_Utils.WriteTag( ea_req, "GUID", rq_req.GUID );
|
|
|
806 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "EA Requirement counterpart in ReqPro was created : " + ea_req.Name, ea_req.ElementID );
|
|
|
807 |
newReqMade = true;
|
|
|
808 |
}
|
|
|
809 |
else
|
|
|
810 |
{
|
|
|
811 |
//string TAG = EA_Utils.ReadTag(ea_req, "TAG");
|
|
|
812 |
//if (TAG != "")
|
|
|
813 |
{
|
|
|
814 |
ReqPro40.Requirement rq_req = rq_project.GetRequirement(GUID,
|
|
|
815 |
ReqPro40.enumRequirementLookups.eReqLookup_GUID,
|
|
|
816 |
ReqPro40.enumRequirementsWeights.eReqWeight_Heavy,
|
|
|
817 |
ReqPro40.enumRequirementFlags.eReqFlag_RetainHierarchy);
|
|
|
818 |
|
|
|
819 |
//rq_req_collection =
|
|
|
820 |
// rq_project.GetRequirements(0,
|
|
|
821 |
// enumRequirementsLookups.eReqsLookup_All,
|
|
|
822 |
// enumRequirementsWeights.eReqWeight_Heavy,
|
|
|
823 |
// enumRequirementFlags.eReqFlag_RetainHierarchy,
|
|
|
824 |
// 1024, 5);
|
|
|
825 |
|
|
|
826 |
//foreach(object key in rq_req_collection)
|
|
|
827 |
//{
|
|
|
828 |
// ReqPro40.Requirement lrq_req = rq_project.GetRequirement(key, ReqPro40.enumRequirementLookups.eReqLookup_Key, ReqPro40.enumRequirementsWeights.eReqWeight_Heavy, ReqPro40.enumRequirementFlags.eReqFlag_RetainHierarchy);
|
|
|
829 |
// if (lrq_req.GUID.StartsWith(GUID))
|
|
|
830 |
// {
|
|
|
831 |
// rq_req = lrq_req;
|
|
|
832 |
// break;
|
|
|
833 |
// }
|
|
|
834 |
//}
|
|
|
835 |
|
|
|
836 |
//rq_req_collection.MoveFirst();
|
|
|
837 |
//for (int i = 0; i < rq_req_collection.Count; i++)
|
|
|
838 |
//{
|
|
|
839 |
// ReqPro40.Requirement lrq_req = rq_req_collection.GetCurrentRequirement();
|
|
|
840 |
// if (lrq_req.GUID.StartsWith(GUID))
|
|
|
841 |
// {
|
|
|
842 |
// rq_req = lrq_req;
|
|
|
843 |
// break;
|
|
|
844 |
// }
|
|
|
845 |
// rq_req_collection.MoveNext();
|
|
|
846 |
//}
|
|
|
847 |
if (rq_req != null)
|
|
|
848 |
|
|
|
849 |
// EA requirement has the GUID of a ReqPro requirement, so look it up in the
|
|
|
850 |
// array list we created earlier in order to obtain the reference to the ReqPro
|
|
|
851 |
// requirement.
|
|
|
852 |
//int i_rq_req = rq_GUIDs.IndexOf(GUID);
|
|
|
853 |
//if (0 <= i_rq_req)
|
|
|
854 |
{
|
|
|
855 |
// must now update the requirement in ReqPro
|
|
|
856 |
//ReqPro40.Requirement rq_req = (ReqPro40.Requirement)rq_reqs[i_rq_req];
|
|
|
857 |
|
|
|
858 |
//repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, rq_req.get_Tag(ReqPro40.enumTagFormat.eTagFormat_FullTag).ToString(), -1);
|
|
|
859 |
|
|
|
860 |
string rq_datetime = rq_req.VersionDateTime;
|
|
|
861 |
DateTime rq_dt = new DateTime();
|
|
|
862 |
|
|
|
863 |
rq_dt = DateTime.Parse(rq_datetime, cultureInfo, DateTimeStyles.NoCurrentDateDefault);
|
|
|
864 |
rq_dt = rq_dt.ToUniversalTime();
|
|
|
865 |
//repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, rq_req.Name + " DATETIME: " + rq_dt.ToString(), -1);
|
|
|
866 |
|
|
|
867 |
DateTime ea_dt = ea_req.Modified.ToUniversalTime();
|
|
|
868 |
//repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, ea_req.Name + " DATETIME: " + ea_dt.ToString(), -1);
|
|
|
869 |
|
|
|
870 |
if (SyncMode && (0 <= rq_dt.CompareTo(ea_dt)))
|
|
|
871 |
{
|
|
|
872 |
importNeeded = true;
|
|
|
873 |
//repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "EA Requirement counterpart in ReqPro was NOT updated (was newer): " + ea_req.Name, ea_req.ElementID );
|
|
|
874 |
}
|
|
|
875 |
else
|
|
|
876 |
{
|
|
|
877 |
rq_req.Name = ea_req.Name;
|
|
|
878 |
rq_req.Text = ea_req.Notes;
|
|
|
879 |
|
|
|
880 |
ExportAttr(repository, rq_req, "Difficulty", ea_req.Difficulty );
|
|
|
881 |
ExportAttr(repository, rq_req, "Priority" , ea_req.Priority );
|
|
|
882 |
ExportAttr(repository, rq_req, "Status" , ea_req.Status );
|
|
|
883 |
//ExportAttr(repository, rq_req, "Type" , ea_req.Stereotype );
|
|
|
884 |
|
|
|
885 |
rq_req.Save();
|
|
|
886 |
|
|
|
887 |
//rq_req.Refresh(ReqPro40.enumRequirementsWeights.eReqWeight_Heavy);
|
|
|
888 |
|
|
|
889 |
//rq_req_collection.Save();
|
|
|
890 |
//rq_req_collection.Refresh(ReqPro40.enumRequirementsWeights.eReqWeight_Heavy);
|
|
|
891 |
|
|
|
892 |
//rq_project.Save();
|
|
|
893 |
|
|
|
894 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "EA Requirement counterpart in ReqPro was updated : " + ea_req.Name, ea_req.ElementID );
|
|
|
895 |
}
|
|
|
896 |
}
|
|
|
897 |
else
|
|
|
898 |
{
|
|
|
899 |
// EA requirement has a ReqPro GUID, but that GUID does not exist in
|
|
|
900 |
// the ReqPro requirement collection. So, we assume someone deleted the
|
|
|
901 |
// ReqPro requirement, and warn the user that this EA requirement is
|
|
|
902 |
// probably dead and needs to be removed. This is based on the assumption
|
|
|
903 |
// that ReqPro holds the master copy of the requirement and normally, addition
|
|
|
904 |
// and deletion of requirements happens in ReqPro first.
|
|
|
905 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "EA Requirement Orphaned (counterpart in ReqPro was missing) : " + ea_req.Name, ea_req.ElementID );
|
|
|
906 |
|
|
|
907 |
// add the EA requirement to the orphaned list for processing later on via another
|
|
|
908 |
// add-in menu item
|
|
|
909 |
orphanedRequirements.Add( ea_req );
|
|
|
910 |
}
|
|
|
911 |
}
|
|
|
912 |
}
|
|
|
913 |
}
|
|
|
914 |
catch (Exception ex)
|
|
|
915 |
{
|
|
|
916 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Exception (ExportToReqPro), " + ex.Message + ", " + ea_req.Name, ea_req.ElementID);
|
|
|
917 |
|
|
|
918 |
// Try an re-establish connection and requirement collection references
|
|
|
919 |
rq_project = rq_connection.ReOpenRqDB();
|
|
|
920 |
rq_req_collection = get_rq_req_collection(rq_project);
|
|
|
921 |
continue;
|
|
|
922 |
}
|
|
|
923 |
break;
|
|
|
924 |
|
|
|
925 |
}
|
|
|
926 |
}
|
|
|
927 |
|
|
|
928 |
rq_req_collection.Save();
|
|
|
929 |
|
|
|
930 |
if (importNeeded && SyncMode)
|
|
|
931 |
{
|
|
|
932 |
ImportFromReqPro(repository, rq_connection, rq_project, rq_artifact);
|
|
|
933 |
}
|
|
|
934 |
else if (importNeeded)
|
|
|
935 |
{
|
|
|
936 |
MessageBox.Show("Some ReqPro requirements were modified later than their EA counterparts.\n" +
|
|
|
937 |
"You may need to perform an import following this export");
|
|
|
938 |
}
|
|
|
939 |
|
|
|
940 |
//rq_project.Refresh(true);
|
|
|
941 |
if (!SyncMode)
|
|
|
942 |
rq_project.CloseProject();
|
|
|
943 |
|
|
|
944 |
if (newReqMade)
|
|
|
945 |
{
|
|
|
946 |
if (orphanedRequirements.Count == 0)
|
|
|
947 |
{
|
|
|
948 |
MessageBox.Show("Export To ReqPro Complete.\n\n" +
|
|
|
949 |
"New requirements were added to ReqPro.");
|
|
|
950 |
}
|
|
|
951 |
else
|
|
|
952 |
{
|
|
|
953 |
MessageBox.Show("Export To ReqPro Complete.\n\n" +
|
|
|
954 |
"New requirements were added to ReqPro." +
|
|
|
955 |
"Some EA requirements were orphaned." );
|
|
|
956 |
}
|
|
|
957 |
}
|
|
|
958 |
else if (orphanedRequirements.Count == 0)
|
|
|
959 |
{
|
|
|
960 |
MessageBox.Show("Export To ReqPro Complete.\n\n" +
|
|
|
961 |
"No new requirements were added to ReqPro.");
|
|
|
962 |
}
|
|
|
963 |
else
|
|
|
964 |
{
|
|
|
965 |
MessageBox.Show("Export To ReqPro Complete.\n\n" +
|
|
|
966 |
"No new requirements were added to ReqPro.\n\n" +
|
|
|
967 |
"Some EA requirements were orphaned." );
|
|
|
968 |
}
|
|
|
969 |
}
|
|
|
970 |
catch (Exception ex)
|
|
|
971 |
{
|
|
|
972 |
MessageBox.Show(ex.Message, "Error (ExportToReqPro)", MessageBoxButtons.OK);
|
|
|
973 |
if (rq_project != null)
|
|
|
974 |
rq_project.CloseProject();
|
|
|
975 |
}
|
|
|
976 |
}
|
|
|
977 |
|
|
|
978 |
|
|
|
979 |
private void UpdatePackageToReqProDatabaseAssociation(EA.Repository repository, EA.Element rq_artifact)
|
|
|
980 |
{
|
|
|
981 |
repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Please Wait - Updating ReqProDB element", rq_artifact.ElementID);
|
|
|
982 |
|
|
|
983 |
// Scan EA package to find all requirement elements, and add links to them
|
|
|
984 |
// from the ReqPro artifact element we have written into the selected package.
|
|
|
985 |
EA_Utilities EA_Utils = new EA_Utilities(repository);
|
|
|
986 |
|
|
|
987 |
ArrayList allowedElementTypes = new ArrayList();
|
|
|
988 |
allowedElementTypes.Add("Requirement");
|
|
|
989 |
allowedElementTypes.Add("UseCase");
|
|
|
990 |
|
|
|
991 |
ElementAccumulator reqLister = new ElementAccumulator(allowedElementTypes);
|
|
|
992 |
|
|
|
993 |
EA.Package thePackage = repository.GetPackageByID( rq_artifact.PackageID );
|
|
|
994 |
EA_Utils.findAndProcessPackageElements( thePackage, reqLister, true );
|
|
|
995 |
|
|
|
996 |
// Get all existing connectors into a list
|
|
|
997 |
ArrayList connectors = new ArrayList();
|
|
|
998 |
foreach(EA.Connector theConnector in rq_artifact.Connectors)
|
|
|
999 |
{
|
|
|
1000 |
connectors.Add(theConnector.SupplierID);
|
|
|
1001 |
}
|
|
|
1002 |
|
|
|
1003 |
// For each element, if it is not already referred to by a connector, add a connector for it
|
|
|
1004 |
foreach (EA.Element theElement in reqLister.Elements)
|
|
|
1005 |
{
|
|
|
1006 |
if (!connectors.Contains(theElement.ElementID))
|
|
|
1007 |
{
|
|
|
1008 |
add_connection(repository, rq_artifact, theElement);
|
|
|
1009 |
}
|
|
|
1010 |
}
|
|
|
1011 |
rq_artifact.Connectors.Refresh();
|
|
|
1012 |
|
|
|
1013 |
|
|
|
1014 |
// Now remove any connectors that point to element IDs that are no longer in the package
|
|
|
1015 |
short i = 0;
|
|
|
1016 |
foreach (EA.Connector theConnector in rq_artifact.Connectors)
|
|
|
1017 |
{
|
|
|
1018 |
if (!reqLister.ElementIDs.Contains(theConnector.SupplierID))
|
|
|
1019 |
{
|
|
|
1020 |
rq_artifact.Connectors.Delete(i);
|
|
|
1021 |
rq_artifact.Connectors.Refresh();
|
|
|
1022 |
}
|
|
|
1023 |
else
|
|
|
1024 |
{
|
|
|
1025 |
i++;
|
|
|
1026 |
}
|
|
|
1027 |
}
|
|
|
1028 |
rq_artifact.Update();
|
|
|
1029 |
rq_artifact.Refresh();
|
|
|
1030 |
}
|
|
|
1031 |
|
|
|
1032 |
private void UpdatePackageToReqProDatabaseAssociation(EA.Repository repository)
|
|
|
1033 |
{
|
|
|
1034 |
EA.Element rq_artifact = (EA.Element)repository.GetTreeSelectedObject();
|
|
|
1035 |
if (rq_artifact != null)
|
|
|
1036 |
{
|
|
|
1037 |
UpdatePackageToReqProDatabaseAssociation(repository, rq_artifact);
|
|
|
1038 |
}
|
|
|
1039 |
}
|
|
|
1040 |
|
|
|
1041 |
|
|
|
1042 |
/// <summary>
|
|
|
1043 |
///
|
|
|
1044 |
/// </summary>
|
|
|
1045 |
/// <param name="repository"></param>
|
|
|
1046 |
private void AssociatePackageToReqProDatabase(EA.Repository repository)
|
|
|
1047 |
{
|
|
|
1048 |
try
|
|
|
1049 |
{
|
|
|
1050 |
OpenFileDialog ofd = new OpenFileDialog();
|
|
|
1051 |
ofd.Title = "Select Requisite Pro project file";
|
|
|
1052 |
ofd.Filter = "ReqPro files (*.rqs)|*.rqs|All files (*.*)|*.*";
|
|
|
1053 |
DialogResult dlgRes = ofd.ShowDialog();
|
|
|
1054 |
|
|
|
1055 |
if (dlgRes == DialogResult.OK)
|
|
|
1056 |
{
|
|
|
1057 |
Logon logon = new Logon("");
|
|
|
1058 |
dlgRes = logon.ShowDialog();
|
|
|
1059 |
|
|
|
1060 |
if (dlgRes == DialogResult.OK)
|
|
|
1061 |
{
|
|
|
1062 |
string username = logon.ebUserName.Text;
|
|
|
1063 |
string password = logon.ebPassword.Text;
|
|
|
1064 |
|
|
|
1065 |
|
|
|
1066 |
// check if the project will open
|
|
|
1067 |
RQConnection connection = new RQConnection(ofd.FileName, logon.ebUserName.Text, logon.ebPassword.Text);
|
|
|
1068 |
|
|
|
1069 |
// add the RQ project to the EA repository
|
|
|
1070 |
object o;
|
|
|
1071 |
EA.ObjectType type = repository.GetTreeSelectedItem(out o);
|
|
|
1072 |
|
|
|
1073 |
connection.SaveAsEAElement(repository, (EA.Package)o);
|
|
|
1074 |
|
|
|
1075 |
EA.Element rq_artifact = repository.GetElementByID( connection.EAId );
|
|
|
1076 |
if (rq_artifact != null)
|
|
|
1077 |
{
|
|
|
1078 |
UpdatePackageToReqProDatabaseAssociation(repository, rq_artifact);
|
|
|
1079 |
}
|
|
|
1080 |
}
|
|
|
1081 |
}
|
|
|
1082 |
}
|
|
|
1083 |
catch (Exception ex)
|
|
|
1084 |
{
|
|
|
1085 |
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK);
|
|
|
1086 |
}
|
|
|
1087 |
}
|
|
|
1088 |
|
|
|
1089 |
|
|
|
1090 |
|
|
|
1091 |
|
|
|
1092 |
|
|
|
1093 |
|
|
|
1094 |
|
|
|
1095 |
|
|
|
1096 |
public void EA_Disconnect()
|
|
|
1097 |
{
|
|
|
1098 |
GC.Collect();
|
|
|
1099 |
GC.WaitForPendingFinalizers();
|
|
|
1100 |
}
|
|
|
1101 |
|
|
|
1102 |
}
|
|
|
1103 |
|
|
|
1104 |
|
|
|
1105 |
|
|
|
1106 |
/// <summary>
|
|
|
1107 |
/// This class is one derived from the EA_UtilitiesRecursionWorker base class so that
|
|
|
1108 |
/// an instance of it can be used as a parameter in the EA_Utilities.findAndProcessPackageElements
|
|
|
1109 |
/// method which recursively parses a given package. Thus, clients can parse EA model structure but
|
|
|
1110 |
/// specify their own functionality to be carried out on packages and elements found in the
|
|
|
1111 |
/// parsing.
|
|
|
1112 |
/// This particular derived class is designed to collect a list of element names from the
|
|
|
1113 |
/// package, from elements that have a type that is acceptable.
|
|
|
1114 |
/// </summary>
|
|
|
1115 |
public class ElementAccumulator : EA_UtilitiesRecursionWorker
|
|
|
1116 |
{
|
|
|
1117 |
public ArrayList Elements = null;
|
|
|
1118 |
public ArrayList ElementIDs = null;
|
|
|
1119 |
private ArrayList validElementTypes = null;
|
|
|
1120 |
|
|
|
1121 |
public ElementAccumulator(ArrayList elementTypeList): base()
|
|
|
1122 |
{
|
|
|
1123 |
validElementTypes = elementTypeList;
|
|
|
1124 |
Elements = new ArrayList();
|
|
|
1125 |
ElementIDs = new ArrayList();
|
|
|
1126 |
}
|
|
|
1127 |
|
|
|
1128 |
public override void processElement( EA.Element theElement )
|
|
|
1129 |
{
|
|
|
1130 |
if (validElementTypes.Contains( theElement.Type ))
|
|
|
1131 |
{
|
|
|
1132 |
Elements.Add( theElement );
|
|
|
1133 |
ElementIDs.Add( theElement.ElementID );
|
|
|
1134 |
}
|
|
|
1135 |
}
|
|
|
1136 |
}
|
|
|
1137 |
|
|
|
1138 |
}
|