| 2151 |
ghuddy |
1 |
using System;
|
|
|
2 |
using System.Text;
|
|
|
3 |
using System.Globalization;
|
|
|
4 |
using System.Collections;
|
|
|
5 |
using System.Windows.Forms;
|
| 2141 |
ghuddy |
6 |
using ReqPro40;
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
namespace EA_ReqPro
|
|
|
10 |
{
|
| 2151 |
ghuddy |
11 |
/// <summary>
|
|
|
12 |
/// The ReqProDB_Artifact class contains methods supporting the use of the ReqProDB
|
|
|
13 |
/// element used to control ReqPro imports for requirement-to-design tracability
|
|
|
14 |
/// purposes.
|
|
|
15 |
/// </summary>
|
|
|
16 |
public class ReqProDB_Artifact
|
|
|
17 |
{
|
| 2145 |
ghuddy |
18 |
/// <summary>
|
|
|
19 |
/// A ReqProDB artifact can be used for document model (document generation) purposes,
|
|
|
20 |
/// or requirement-to-design traceability purposes, and this is to be recorded in the element
|
|
|
21 |
/// as a tagged value. We need an enum to represent the differning modes.
|
|
|
22 |
/// </summary>
|
|
|
23 |
public enum MODE
|
|
|
24 |
{
|
|
|
25 |
TRACEABILITY,
|
|
|
26 |
DOC_MODEL,
|
|
|
27 |
UNDEFINED
|
|
|
28 |
}
|
| 2141 |
ghuddy |
29 |
|
| 2145 |
ghuddy |
30 |
public ReqPro40.Application RQ_app;
|
|
|
31 |
|
| 2141 |
ghuddy |
32 |
/// <summary>
|
|
|
33 |
/// Constructor logic
|
|
|
34 |
/// </summary>
|
| 2151 |
ghuddy |
35 |
public ReqProDB_Artifact()
|
|
|
36 |
{
|
| 2145 |
ghuddy |
37 |
RQ_app = new ReqPro40.ApplicationClass();
|
| 2151 |
ghuddy |
38 |
}
|
| 2141 |
ghuddy |
39 |
|
| 2151 |
ghuddy |
40 |
|
| 2141 |
ghuddy |
41 |
/// <summary>
|
|
|
42 |
/// This method is used to open a ReqPro database file indicated by a given ReqProDB artifact
|
|
|
43 |
/// element.
|
|
|
44 |
/// </summary>
|
|
|
45 |
/// <param name="ea_repository"></param>
|
|
|
46 |
/// <param name="rq_artifact"></param>
|
|
|
47 |
/// <returns></returns>
|
| 2151 |
ghuddy |
48 |
public ReqPro40.Project OpenReqProProject(EA.Element rq_artifact)
|
| 2141 |
ghuddy |
49 |
{
|
| 2153 |
ghuddy |
50 |
Logon logon = new Logon(EA_Utilities.ReadTag(rq_artifact, "Username"));
|
| 2151 |
ghuddy |
51 |
|
|
|
52 |
DialogResult dlgRes = logon.ShowDialog();
|
|
|
53 |
if (dlgRes == DialogResult.OK)
|
|
|
54 |
{
|
|
|
55 |
ReqPro40.Project project = RQ_app.OpenProject(
|
| 2153 |
ghuddy |
56 |
EA_Utilities.ReadTag(rq_artifact, "Location"),
|
| 2151 |
ghuddy |
57 |
ReqPro40.enumOpenProjectOptions.eOpenProjOpt_RQSFile,
|
| 2153 |
ghuddy |
58 |
EA_Utilities.ReadTag(rq_artifact, "Username"),
|
| 2151 |
ghuddy |
59 |
logon.ebPassword.Text,
|
|
|
60 |
enumProjectFlags.eProjFlag_Normal,
|
|
|
61 |
enumRelatedProjectOptions.eRelatedProjOption_ConnectAsSpecified);
|
|
|
62 |
|
|
|
63 |
if (project == null)
|
|
|
64 |
{
|
|
|
65 |
MessageBoxEx.Show("Cannot establish connection to ReqPro database. " +
|
|
|
66 |
"Check the tagged values in the artifact are correct. " +
|
|
|
67 |
"Check the database still exists or is not locked by " +
|
|
|
68 |
"another user, or has not been password protected.", "Error" );
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
return project;
|
|
|
72 |
}
|
|
|
73 |
return null;
|
| 2141 |
ghuddy |
74 |
}
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
/// <summary>
|
|
|
78 |
/// This method is used to return the ReqProDB artifact, on the assumption that it is the
|
|
|
79 |
/// item the user has highlighted in EA's project browser prior to initiating the process
|
| 2145 |
ghuddy |
80 |
/// leading up to the call to this method. If the user however has selected a package, then
|
|
|
81 |
/// that package is searched for the first ReqProDB artifact that can be found, and that one
|
|
|
82 |
/// is returned.
|
| 2141 |
ghuddy |
83 |
/// </summary>
|
|
|
84 |
/// <param name="ea_repository"></param>
|
|
|
85 |
/// <returns></returns>
|
| 2151 |
ghuddy |
86 |
public EA.Element get_rq_artifact()
|
| 2141 |
ghuddy |
87 |
{
|
| 2151 |
ghuddy |
88 |
object o;
|
|
|
89 |
EA.ObjectType type;
|
| 2141 |
ghuddy |
90 |
|
| 2151 |
ghuddy |
91 |
type = Main.EA_Repository.GetTreeSelectedItem(out o);
|
|
|
92 |
if ( (type == EA.ObjectType.otElement) && (((EA.Element)o).Stereotype == "ReqProDB"))
|
|
|
93 |
{
|
|
|
94 |
return (EA.Element)o;
|
| 2145 |
ghuddy |
95 |
}
|
| 2151 |
ghuddy |
96 |
else if (type == EA.ObjectType.otPackage)
|
|
|
97 |
{
|
|
|
98 |
for(short i=0; i < ((EA.Package)o).Elements.Count; i++)
|
|
|
99 |
{
|
|
|
100 |
EA.Element ea_ele = (EA.Element)((EA.Package)o).Elements.GetAt(i);
|
|
|
101 |
|
|
|
102 |
if (ea_ele.Stereotype == "ReqProDB")
|
|
|
103 |
{
|
|
|
104 |
return ea_ele;
|
|
|
105 |
}
|
|
|
106 |
}
|
|
|
107 |
}
|
| 2145 |
ghuddy |
108 |
return null;
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
|
| 2141 |
ghuddy |
112 |
/// <summary>
|
|
|
113 |
/// This method is used to create a ReqProDB element in an EA package.
|
|
|
114 |
/// Do not modify the tag names that are in current use. Only extend with
|
|
|
115 |
/// additional new tags.
|
|
|
116 |
/// </summary>
|
|
|
117 |
/// <param name="ea_repository"></param>
|
|
|
118 |
/// <param name="package"></param>
|
|
|
119 |
/// <param name="name"></param>
|
|
|
120 |
/// <param name="description"></param>
|
|
|
121 |
/// <param name="reqpro_db_username"></param>
|
|
|
122 |
/// <param name="reqpro_db_filename"></param>
|
|
|
123 |
/// <param name="reqpro_db_guid"></param>
|
|
|
124 |
/// <returns></returns>
|
| 2151 |
ghuddy |
125 |
public EA.Element create_rq_artifact(
|
|
|
126 |
EA.Package package,
|
|
|
127 |
string name,
|
|
|
128 |
string description,
|
|
|
129 |
string reqpro_db_username,
|
|
|
130 |
string reqpro_db_filename,
|
|
|
131 |
string reqpro_db_guid)
|
|
|
132 |
{
|
|
|
133 |
package.Notes = description;
|
|
|
134 |
package.Update();
|
|
|
135 |
|
|
|
136 |
EA.Element element;
|
|
|
137 |
element = (EA.Element)package.Elements.AddNew(name + " - " + reqpro_db_username, "Artifact");
|
|
|
138 |
if (element != null)
|
|
|
139 |
{
|
|
|
140 |
element.Stereotype = "ReqProDB";
|
|
|
141 |
element.Notes = description;
|
|
|
142 |
|
| 2153 |
ghuddy |
143 |
EA_Utilities.WriteTag( element, "Location", reqpro_db_filename);
|
|
|
144 |
EA_Utilities.WriteTag( element, "Username", reqpro_db_username);
|
|
|
145 |
EA_Utilities.WriteTag( element, "GUID", reqpro_db_guid);
|
| 2151 |
ghuddy |
146 |
|
|
|
147 |
element.Update();
|
|
|
148 |
element.Refresh();
|
|
|
149 |
element.TaggedValues.Refresh();
|
|
|
150 |
package.Update();
|
|
|
151 |
package.Packages.Refresh();
|
|
|
152 |
package.Elements.Refresh();
|
|
|
153 |
|
|
|
154 |
return element;
|
|
|
155 |
}
|
|
|
156 |
return null;
|
| 2141 |
ghuddy |
157 |
}
|
|
|
158 |
|
|
|
159 |
|
| 2151 |
ghuddy |
160 |
public void set_traceability_mode(EA.Element rq_artifact)
|
|
|
161 |
{
|
| 2153 |
ghuddy |
162 |
EA_Utilities.WriteTag( rq_artifact, "Mode", "Traceability");
|
| 2151 |
ghuddy |
163 |
rq_artifact.Update();
|
|
|
164 |
}
|
|
|
165 |
|
|
|
166 |
public void set_doc_model_mode(EA.Element rq_artifact)
|
|
|
167 |
{
|
| 2153 |
ghuddy |
168 |
EA_Utilities.WriteTag( rq_artifact, "Mode", "DocModel");
|
| 2151 |
ghuddy |
169 |
rq_artifact.Update();
|
|
|
170 |
}
|
|
|
171 |
|
|
|
172 |
public MODE get_mode(EA.Element rq_artifact)
|
|
|
173 |
{
|
| 2153 |
ghuddy |
174 |
string mode = EA_Utilities.ReadTag(rq_artifact, "Mode");
|
| 2151 |
ghuddy |
175 |
|
|
|
176 |
if (0 == mode.CompareTo("Traceability"))
|
|
|
177 |
return MODE.TRACEABILITY;
|
|
|
178 |
else if (0 == mode.CompareTo("DocModel"))
|
|
|
179 |
return MODE.DOC_MODEL;
|
|
|
180 |
|
|
|
181 |
return MODE.UNDEFINED;
|
|
|
182 |
}
|
|
|
183 |
}
|
| 2141 |
ghuddy |
184 |
}
|