Subversion Repositories DevTools

Rev

Rev 2153 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2153 Rev 2155
Line 16... Line 16...
16
   public class ReqProDB_Artifact
16
   public class ReqProDB_Artifact
17
   {
17
   {
18
      /// <summary>
18
      /// <summary>
19
      /// A ReqProDB artifact can be used for document model (document generation) purposes,
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
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.
21
      /// as a tagged value. We need an enum to represent the differning modes, plus some additional
-
 
22
      /// modes as required
22
      /// </summary>
23
      /// </summary>
23
      public enum MODE
24
      public enum MODE
24
      {
25
      {
25
         TRACEABILITY,
26
         TRACEABILITY,
26
         DOC_MODEL,
27
         DOC_MODEL,
-
 
28
         EXPORT,
27
         UNDEFINED
29
         UNDEFINED
28
      }
30
      }
29
 
31
 
30
      public ReqPro40.Application RQ_app;
-
 
31
 
32
 
32
      /// <summary>
33
      /// <summary>
33
      /// Constructor logic
34
      /// Constructor logic
34
      /// </summary>
35
      /// </summary>
35
      public ReqProDB_Artifact()
36
      public ReqProDB_Artifact()
36
      {
37
      {
37
         RQ_app = new ReqPro40.ApplicationClass();
-
 
38
      }
38
      }
39
 
39
 
40
 
40
 
41
      /// <summary>
41
      /// <summary>
42
      /// This method is used to open a ReqPro database file indicated by a given ReqProDB artifact
42
      /// This method is used to open a ReqPro database file indicated by a given ReqProDB artifact
43
      /// element.
43
      /// element.
44
      /// </summary>
44
      /// </summary>
45
      /// <param name="ea_repository"></param>
45
      /// <param name="ea_repository"></param>
46
      /// <param name="rq_artifact"></param>
46
      /// <param name="rq_artifact"></param>
47
      /// <returns></returns>
47
      /// <returns></returns>
48
      public ReqPro40.Project OpenReqProProject(EA.Element rq_artifact)
48
      public bool OpenReqProProject(EA.Element rq_artifact, out bool cancelled)
49
      {
49
      {
-
 
50
         cancelled = false;
-
 
51
 
50
         Logon logon = new Logon(EA_Utilities.ReadTag(rq_artifact, "Username"));
52
         Logon logon = new Logon(EA_TaggedValues.Read(rq_artifact, Constants.TAG_DB_USERNAME));
51
 
53
 
52
         DialogResult dlgRes = logon.ShowDialog();
54
         DialogResult dlgRes = logon.ShowDialog();
53
         if (dlgRes == DialogResult.OK)
55
         if (dlgRes == DialogResult.OK)
54
         {
56
         {
55
            ReqPro40.Project project = RQ_app.OpenProject(
-
 
56
               EA_Utilities.ReadTag(rq_artifact, "Location"),
57
            if (false == ReqProDatabase.open(EA_TaggedValues.Read(rq_artifact, Constants.TAG_DB_LOCATION),
57
               ReqPro40.enumOpenProjectOptions.eOpenProjOpt_RQSFile,
-
 
58
               EA_Utilities.ReadTag(rq_artifact, "Username"),
58
               EA_TaggedValues.Read(rq_artifact, Constants.TAG_DB_USERNAME),
59
               logon.ebPassword.Text,
59
               logon.ebPassword.Text))
60
               enumProjectFlags.eProjFlag_Normal,
-
 
61
               enumRelatedProjectOptions.eRelatedProjOption_ConnectAsSpecified);
-
 
62
 
-
 
63
            if (project == null)
-
 
64
            {
60
            {
-
 
61
               MessageBoxEx.Show(
65
               MessageBoxEx.Show("Cannot establish connection to ReqPro database. " +
62
                  "Cannot establish connection to ReqPro database.\n" +
66
                  "Check the tagged values in the artifact are correct. " +
63
                  "Check the tagged values in the artifact are correct.\n" +
67
                  "Check the database still exists or is not locked by " +
64
                  "Check the database still exists or is not locked by\n" +
68
                  "another user, or has not been password protected.", "Error" );
65
                  "another user, or has not been password protected.", "Error" );
69
            }
66
            }
70
 
67
 
71
            return project;
68
            return ReqProDatabase.opened();
72
         }
69
         }
-
 
70
         else
-
 
71
         {
-
 
72
            cancelled = true;
-
 
73
         }
73
         return null;
74
         return false;
74
      }
75
      }
75
 
76
 
76
 
77
 
77
      /// <summary>
78
      /// <summary>
78
      /// This method is used to return the ReqProDB artifact, on the assumption that it is the
79
      /// This method is used to return the ReqProDB artifact. The algorithm searches the areas
-
 
80
      /// in EA's project browser beginning at where the user selected/highlighted and working
79
      /// item the user has highlighted in EA's project browser prior to initiating the process
81
      /// up through the parent package levels. This gives the best possible chance of finding
80
      /// leading up to the call to this method. If the user however has selected a package, then
82
      /// the artifact and allows the user to select anything in a ReqPro import area before
81
      /// that package is searched for the first ReqProDB artifact that can be found, and that one
83
      /// initiating an import/export. The software automatically finds where the import area
82
      /// is returned.
84
      /// exists (ie. its parent container package)
83
      /// </summary>
85
      /// </summary>
84
      /// <param name="ea_repository"></param>
86
      /// <param name="ea_repository"></param>
85
      /// <returns></returns>
87
      /// <returns></returns>
86
      public EA.Element get_rq_artifact()
88
      public EA.Element get_rq_artifact()
87
      {
89
      {
88
         object o;
90
         object o;
89
         EA.ObjectType type;
91
         EA.ObjectType type;
90
 
92
 
91
         type = Main.EA_Repository.GetTreeSelectedItem(out o);
93
         type = Main.EA_Repository.GetTreeSelectedItem(out o);
-
 
94
 
-
 
95
         // if user selected the actual ReqProDB element then we can exit straight away with
-
 
96
         // the object.
92
         if ( (type == EA.ObjectType.otElement) && (((EA.Element)o).Stereotype == "ReqProDB"))
97
         if ( (type == EA.ObjectType.otElement) && (((EA.Element)o).Stereotype == "ReqProDB"))
93
         {
98
         {
94
            return (EA.Element)o;
99
            return (EA.Element)o;
95
         }
100
         }
96
         else if (type == EA.ObjectType.otPackage)
101
         else
97
         {
102
         {
-
 
103
            // Get the package in or under which the EA project browser selection exists
98
            for(short i=0; i < ((EA.Package)o).Elements.Count; i++)
104
            EA.Package pkg = EA_Utilities.get_selected_package();
-
 
105
 
-
 
106
            // iterate up through the package hiearchy
-
 
107
            while (pkg != null)
99
            {
108
            {
-
 
109
               // search for ReqProDB element in the package at the current level
-
 
110
               for(short i=0; i < pkg.Elements.Count; i++)
-
 
111
               {
100
               EA.Element ea_ele = (EA.Element)((EA.Package)o).Elements.GetAt(i);
112
                  EA.Element ea_ele = (EA.Element)pkg.Elements.GetAt(i);
-
 
113
 
-
 
114
                  if (ea_ele.Stereotype == "ReqProDB")
-
 
115
                  {
-
 
116
                     return ea_ele;
-
 
117
                  }
-
 
118
               }
101
 
119
 
-
 
120
               // Didnt find ReqProDB element, go up one package level ready for the next loop iteration
102
               if (ea_ele.Stereotype == "ReqProDB")
121
               if (pkg.ParentID > 0)
103
               {
122
               {
-
 
123
                  pkg = Main.EA_Repository.GetPackageByID(pkg.ParentID);
-
 
124
               }
-
 
125
               else
-
 
126
               {
-
 
127
                  // force loop termination if cannot go up one more package level
104
                  return ea_ele;
128
                  pkg = null;
105
               }
129
               }
106
            }
130
            }
107
         }
131
         }
-
 
132
 
-
 
133
         // tell caller we didnt find a ReqProDB stereotyped element.
108
         return null;
134
         return null;
109
      }
135
      }
110
 
136
 
111
 
137
 
112
      /// <summary>
138
      /// <summary>
Line 138... Line 164...
138
         if (element != null)
164
         if (element != null)
139
         {
165
         {
140
            element.Stereotype = "ReqProDB";
166
            element.Stereotype = "ReqProDB";
141
            element.Notes = description;
167
            element.Notes = description;
142
 
168
 
143
            EA_Utilities.WriteTag( element, "Location", reqpro_db_filename);
169
            EA_TaggedValues.Write( element, Constants.TAG_DB_LOCATION, reqpro_db_filename);
144
            EA_Utilities.WriteTag( element, "Username", reqpro_db_username);
170
            EA_TaggedValues.Write( element, Constants.TAG_DB_USERNAME, reqpro_db_username);
145
            EA_Utilities.WriteTag( element, "GUID", reqpro_db_guid);
171
            EA_TaggedValues.Write( element, Constants.TAG_GUID, reqpro_db_guid);
146
 
172
 
147
            element.Update();
173
            element.Update();
148
            element.Refresh();
174
            element.Refresh();
149
            element.TaggedValues.Refresh();
175
            element.TaggedValues.Refresh();
150
            package.Update();
176
            package.Update();
Line 157... Line 183...
157
      }
183
      }
158
 
184
 
159
 
185
 
160
      public void set_traceability_mode(EA.Element rq_artifact)
186
      public void set_traceability_mode(EA.Element rq_artifact)
161
      {
187
      {
162
         EA_Utilities.WriteTag( rq_artifact, "Mode", "Traceability");
188
         EA_TaggedValues.Write( rq_artifact, Constants.TAG_MODE, "Traceability");
163
         rq_artifact.Update();
189
         rq_artifact.Update();
164
      }
190
      }
165
 
191
 
166
      public void set_doc_model_mode(EA.Element rq_artifact)
192
      public void set_doc_model_mode(EA.Element rq_artifact)
167
      {
193
      {
168
         EA_Utilities.WriteTag( rq_artifact, "Mode", "DocModel");
194
         EA_TaggedValues.Write( rq_artifact, Constants.TAG_MODE, "DocModel");
169
         rq_artifact.Update();
195
         rq_artifact.Update();
170
      }
196
      }
171
 
197
 
172
      public MODE get_mode(EA.Element rq_artifact)
198
      public MODE get_mode(EA.Element rq_artifact)
173
      {
199
      {
174
         string mode = EA_Utilities.ReadTag(rq_artifact, "Mode");
200
         string mode = EA_TaggedValues.Read(rq_artifact, Constants.TAG_MODE);
175
 
201
 
176
         if (0 == mode.CompareTo("Traceability"))
202
         if (mode.Equals("Traceability"))
177
            return MODE.TRACEABILITY;
203
            return MODE.TRACEABILITY;
178
         else if (0 == mode.CompareTo("DocModel"))
204
         else if (mode.Equals("DocModel"))
179
            return MODE.DOC_MODEL;
205
            return MODE.DOC_MODEL;
180
 
206
 
181
         return MODE.UNDEFINED;
207
         return MODE.UNDEFINED;
182
      }
208
      }
183
   }
209
   }