Subversion Repositories DevTools

Rev

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

Rev 2149 Rev 2151
Line 1... Line 1...
1
using System;
1
using System;
2
using System.Text;
2
using System.Text;
3
using System.Globalization;
3
using System.Globalization;
4
using System.Collections;
4
using System.Collections;
5
using System.Windows.Forms;
5
using System.Windows.Forms;
6
using ReqPro40;
6
using ReqPro40;
7
 
7
 
8
 
8
 
9
namespace EA_ReqPro
9
namespace EA_ReqPro
10
{
10
{
Line 12... Line 12...
12
	/// <summary>
12
	/// <summary>
13
	/// Summary description for ImportReqProDatabase.
13
	/// Summary description for ImportReqProDatabase.
14
	/// </summary>
14
	/// </summary>
15
	public class ImportReqProDatabase : CopyReqProDatabaseToMemory
15
	public class ImportReqProDatabase : CopyReqProDatabaseToMemory
16
	{
16
	{
-
 
17
      private int totalRequirements = 0;
-
 
18
 
17
      /// <summary>
19
      /// <summary>
18
      /// Constructor logic
20
      /// Constructor logic
19
      /// </summary>
21
      /// </summary>
20
      /// <param name="ea_repository"></param>
22
      /// <param name="ea_repository"></param>
21
      public ImportReqProDatabase(EA.Repository ea_repository): base(ea_repository)
23
      public ImportReqProDatabase(): base()
22
		{
24
		{
-
 
25
         totalRequirements = 0;
23
		}
26
		}
24
 
27
 
25
 
28
 
26
      /// <summary>
29
      /// <summary>
27
      /// Method to parse a ReqPro database using the information in a ReqProDB artifact,
30
      /// Method to parse a ReqPro database using the information in a ReqProDB artifact,
28
      /// assumed to be selected in EA's project browser prior to the method call.
31
      /// assumed to be selected in EA's project browser prior to the method call.
29
      /// </summary>
32
      /// </summary>
30
      /// <param name="ea_repository"></param>
33
      /// <param name="ea_repository"></param>
31
      /// <returns></returns>
34
      /// <returns></returns>
32
      public override bool prompt_and_parse(EA.Repository ea_repository, ReqProDB_Artifact.MODE mode)
35
      public override bool prompt_and_parse(ReqProDB_Artifact.MODE mode)
33
      {
36
      {
34
         try
37
         try
35
         {
38
         {
36
            if (true == base.prompt_and_parse(ea_repository, mode))
39
            if (true == base.prompt_and_parse(mode))
37
            {
40
            {
38
               ea_repository.EnsureOutputVisible(Main.GUI_OUTPUT_TAB_NAME);
41
               if (Main.mustAbort)
39
               ImportFromReqPro(ea_repository);
42
                  return false;
-
 
43
 
-
 
44
               Main.EA_Repository.EnsureOutputVisible(Main.GUI_OUTPUT_TAB_NAME);
40
 
45
 
41
               // Configure the ReqProDB artifact as a traceability artifact
46
               // Configure the ReqProDB artifact as a traceability artifact
42
               RQ_Artifact.set_traceability_mode(ea_repository, RQ_Element);
47
               RQ_Artifact.set_traceability_mode(RQ_Element);
-
 
48
 
-
 
49
               ImportFromReqPro();
43
 
50
 
44
               return true;
51
               return true;
45
            }
52
            }
46
         }
53
         }
47
         catch (Exception ex)
54
         catch (Exception ex)
48
         {
55
         {
49
            MessageBox.Show(ex.Message, "Error (ImportReqProDatabase::parse)", MessageBoxButtons.OK);
56
            MessageBoxEx.Show(ex.Message, "Error (parse)", MessageBoxButtons.OK);
50
         }      
57
         }      
51
         return false;
58
         return false;
52
      }
59
      }
53
 
60
 
54
      /// <summary>
61
      /// <summary>
55
      /// Displays the content of the change log element to the output trace display. This method must
62
      /// Displays the content of the change log element to the output trace display. This method must
56
      /// be kept in sync with the ImportFromReqPro method, obviously.
63
      /// be kept in sync with the ImportFromReqPro method, obviously.
57
      /// </summary>
64
      /// </summary>
58
      /// <param name="ea_repository"></param>
65
      /// <param name="ea_repository"></param>
59
      /// <param name="changeLog"></param>
66
      /// <param name="changeLog"></param>
60
      public void displayChangeLog(EA.Repository ea_repository, EA.Element changeLog)
67
      public void displayChangeLog(EA.Element changeLog)
61
      {
68
      {
62
         // The change log element contains all the log in its notes section. Break it up into
69
         // The change log element contains all the log in its notes section. Break it up into
63
         // lines, because each line is a single log entry, so that we can process them one at
70
         // lines, because each line is a single log entry, so that we can process them one at
64
         // a time.
71
         // a time.
65
         string delimStr = "\n";
72
         string delimStr = "\n";
Line 72... Line 79...
72
 
79
 
73
         // modify delimiters to : character so that we can extract the parameters for each log entry
80
         // modify delimiters to : character so that we can extract the parameters for each log entry
74
         delimStr = ":";
81
         delimStr = ":";
75
         delim = delimStr.ToCharArray();
82
         delim = delimStr.ToCharArray();
76
 
83
 
77
         ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,"Displaying Import Change Log", -1);
84
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,"Displaying Import Change Log", -1);
78
 
85
 
79
         foreach(string s in log_strings)
86
         foreach(string s in log_strings)
80
         {
87
         {
-
 
88
            if (Main.mustAbort)
-
 
89
               break;
-
 
90
 
81
            // over time, users may delete the orphaned requirements from the EA database, but their
91
            // over time, users may delete the orphaned requirements from the EA database, but their
82
            // GUIDs will still exist in the change log. Use of such a GUID will cause 
92
            // GUIDs will still exist in the change log. Use of such a GUID will cause 
83
            // an exception in the GetElementByGuid() function. What should we do? We can attempt
93
            // an exception in the GetElementByGuid() function. What should we do? We can attempt
84
            // to remove those GUIDs from the list. We can do this by accumulating a new list of GUIDs
94
            // to remove those GUIDs from the list. We can do this by accumulating a new list of GUIDs
85
            // that is formed from the old list, where only good items from the old list find their 
95
            // that is formed from the old list, where only good items from the old list find their 
Line 94... Line 104...
94
 
104
 
95
                  // Get log entry;s parameters.
105
                  // Get log entry;s parameters.
96
                  string[] parameters = trimmed_s.Split(delim, 10);
106
                  string[] parameters = trimmed_s.Split(delim, 10);
97
 
107
 
98
                  // The first parameter is the GUID so use it to get the requirement element
108
                  // The first parameter is the GUID so use it to get the requirement element
99
                  EA.Element ea_req = ea_repository.GetElementByGuid(parameters[0]);
109
                  EA.Element ea_req = Main.EA_Repository.GetElementByGuid(parameters[0]);
100
 
110
 
101
                  // Now discriminate actions based on the second parameter
111
                  // Now discriminate actions based on the second parameter
102
 
112
 
103
                  if (parameters[1].StartsWith("Created"))
113
                  if (parameters[1].StartsWith("Created"))
104
                  {
114
                  {
105
                     ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,"  Created : " + ea_req.Name, ea_req.ElementID );
115
                     Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,"  Created : " + ea_req.Name, ea_req.ElementID );
106
                  }
116
                  }
107
                  /////////////////////////////////////////////////////////////////////////////////////////////////////////////
117
                  /////////////////////////////////////////////////////////////////////////////////////////////////////////////
108
                  else if (parameters[1].StartsWith("Orphaned"))
118
                  else if (parameters[1].StartsWith("Orphaned"))
109
                  {
119
                  {
110
                     ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,"  Orphaned : " + ea_req.Name, ea_req.ElementID );
120
                     Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,"  Orphaned : " + ea_req.Name, ea_req.ElementID );
111
 
121
 
112
                     foreach (EA.Connector theConnector in ea_req.Connectors)
122
                     foreach (EA.Connector theConnector in ea_req.Connectors)
113
                     {
123
                     {
114
                        EA.Element tgt_ele = (EA.Element)ea_repository.GetElementByID( theConnector.SupplierID );
124
                        EA.Element tgt_ele = (EA.Element)Main.EA_Repository.GetElementByID( theConnector.SupplierID );
115
                        if (tgt_ele != null)
125
                        if (tgt_ele != null)
116
                        {
126
                        {
117
                           if (!tgt_ele.Type.StartsWith("Requirement"))
127
                           if (!tgt_ele.Type.StartsWith("Requirement"))
118
                           {
128
                           {
119
                              ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     --> " + tgt_ele.Name, tgt_ele.ElementID);
129
                              Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     --> " + tgt_ele.Name, tgt_ele.ElementID);
120
                           }
130
                           }
121
                        }
131
                        }
122
                     }
132
                     }
123
                  }
133
                  }
124
                  /////////////////////////////////////////////////////////////////////////////////////////////////////////////
134
                  /////////////////////////////////////////////////////////////////////////////////////////////////////////////
125
                  else if (parameters[1].StartsWith("Name"))
135
                  else if (parameters[1].StartsWith("Name"))
126
                  {
136
                  {
127
                     ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "  Modified Name: " + ea_req.Name, ea_req.ElementID );
137
                     Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "  Modified Name: " + ea_req.Name, ea_req.ElementID );
128
                     ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     <<< " + parameters[2], ea_req.ElementID);
138
                     Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     <<< " + parameters[2], ea_req.ElementID);
129
                     ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     >>> " + parameters[3], ea_req.ElementID);
139
                     Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     >>> " + parameters[3], ea_req.ElementID);
130
                  }
140
                  }
131
                  /////////////////////////////////////////////////////////////////////////////////////////////////////////////
141
                  /////////////////////////////////////////////////////////////////////////////////////////////////////////////
132
                  else if (parameters[1].StartsWith("Notes"))
142
                  else if (parameters[1].StartsWith("Notes"))
133
                  {
143
                  {
134
                     ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "  Modified Description: " + ea_req.Name, ea_req.ElementID );
144
                     Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "  Modified Description: " + ea_req.Name, ea_req.ElementID );
135
                     ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     <<< " + parameters[2], ea_req.ElementID);
145
                     Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     <<< " + parameters[2], ea_req.ElementID);
136
                     ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     >>> " + parameters[3], ea_req.ElementID);
146
                     Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     >>> " + parameters[3], ea_req.ElementID);
137
                  }
147
                  }
138
                  /////////////////////////////////////////////////////////////////////////////////////////////////////////////
148
                  /////////////////////////////////////////////////////////////////////////////////////////////////////////////
139
                  else if (parameters[1].StartsWith("Difficulty"))
149
                  else if (parameters[1].StartsWith("Difficulty"))
140
                  {
150
                  {
141
                     ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "  Modified Difficulty: " + ea_req.Name, ea_req.ElementID );
151
                     Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "  Modified Difficulty: " + ea_req.Name, ea_req.ElementID );
142
                     ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     <<< " + parameters[2], ea_req.ElementID);
152
                     Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     <<< " + parameters[2], ea_req.ElementID);
143
                     ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     >>> " + parameters[3], ea_req.ElementID);
153
                     Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     >>> " + parameters[3], ea_req.ElementID);
144
                  }
154
                  }
145
                  /////////////////////////////////////////////////////////////////////////////////////////////////////////////
155
                  /////////////////////////////////////////////////////////////////////////////////////////////////////////////
146
                  else if (parameters[1].StartsWith("Priority"))
156
                  else if (parameters[1].StartsWith("Priority"))
147
                  {
157
                  {
148
                     ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "  Modified Priority: " + ea_req.Name, ea_req.ElementID );
158
                     Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "  Modified Priority: " + ea_req.Name, ea_req.ElementID );
149
                     ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     <<< " + parameters[2], ea_req.ElementID);
159
                     Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     <<< " + parameters[2], ea_req.ElementID);
150
                     ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     >>> " + parameters[3], ea_req.ElementID);
160
                     Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     >>> " + parameters[3], ea_req.ElementID);
151
                  }
161
                  }
152
                  /////////////////////////////////////////////////////////////////////////////////////////////////////////////
162
                  /////////////////////////////////////////////////////////////////////////////////////////////////////////////
153
                  else if (parameters[1].StartsWith("Version"))
163
                  else if (parameters[1].StartsWith("Version"))
154
                  {
164
                  {
155
                     ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "  Modified Version: " + ea_req.Name, ea_req.ElementID );
165
                     Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "  Modified Version: " + ea_req.Name, ea_req.ElementID );
156
                     ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     <<< " + parameters[2], ea_req.ElementID);
166
                     Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     <<< " + parameters[2], ea_req.ElementID);
157
                     ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     >>> " + parameters[3], ea_req.ElementID);
167
                     Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     >>> " + parameters[3], ea_req.ElementID);
158
                  }
168
                  }
159
                  /////////////////////////////////////////////////////////////////////////////////////////////////////////////
169
                  /////////////////////////////////////////////////////////////////////////////////////////////////////////////
160
                  else if (parameters[1].StartsWith("Status"))
170
                  else if (parameters[1].StartsWith("Status"))
161
                  {
171
                  {
162
                     ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "  Modified Status: " + ea_req.Name, ea_req.ElementID );
172
                     Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "  Modified Status: " + ea_req.Name, ea_req.ElementID );
163
                     ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     <<< " + parameters[2], ea_req.ElementID);
173
                     Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     <<< " + parameters[2], ea_req.ElementID);
164
                     ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     >>> " + parameters[3], ea_req.ElementID);
174
                     Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "     >>> " + parameters[3], ea_req.ElementID);
165
                  }
175
                  }
166
 
176
 
167
                  // accumulate good item into the newList
177
                  // accumulate good item into the newList
168
                  newList += trimmed_s + "\r\n";
178
                  newList += trimmed_s + "\r\n";
169
               }
179
               }
Line 193... Line 203...
193
         sc = sc.Replace('\r' , ' ');
203
         sc = sc.Replace('\r' , ' ');
194
         sc = sc.Replace('\n' , ' ');
204
         sc = sc.Replace('\n' , ' ');
195
         
205
         
196
         return sc;
206
         return sc;
197
      }
207
      }
198
 
208
 
199
 
209
 
200
      /// <summary>
210
      /// <summary>
201
      /// A method that imports requirements from a ReqPro database into EA for the purpose
211
      /// A method that imports requirements from a ReqPro database into EA for the purpose
202
      /// of supporting requirement-to-design traceability.
212
      /// of supporting requirement-to-design traceability.
203
      /// </summary>
213
      /// </summary>
204
      /// <param name="repository"></param>
214
      /// <param name="repository"></param>
205
      private void ImportFromReqPro(EA.Repository ea_repository)
215
      private void ImportFromReqPro()
206
      {
216
      {
207
         try
217
         try
208
         {
218
         {
209
            //IFormatProvider cultureInfo = new CultureInfo("en-US", true);
219
            //IFormatProvider cultureInfo = new CultureInfo("en-US", true);
210
 
220
 
211
            string importDateTime = System.TimeZone.CurrentTimeZone.ToUniversalTime( System.DateTime.Now ).ToString();
221
            string importDateTime = System.TimeZone.CurrentTimeZone.ToUniversalTime( System.DateTime.Now ).ToString();
212
 
222
 
213
            ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "EA Requirement import at " + importDateTime, -1 );
223
            Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "EA Requirement import at " + importDateTime, -1 );
214
 
224
 
215
            // Update the ReqProDB stereotypes element with all the EA requirements in the package
225
            // Get a list of EA requirements and their associated ReqPro GUIDs
216
            base.RQ_Artifact.UpdatePackageToReqProDatabaseAssociation(ea_repository, base.RQ_Element);
226
            ArrayList ea_reqs;
217
 
227
            ArrayList ea_GUIDs = new ArrayList();
218
            // Get a list of EA requirements and their associated ReqPro GUIDs
228
            ArrayList ea_req_matched = new ArrayList();
219
            ArrayList ea_reqs = new ArrayList();
229
 
220
            ArrayList ea_GUIDs = new ArrayList();
230
            // Obtain the EA parent package so that we can create under it an import package
221
            ArrayList ea_req_matched = new ArrayList();
231
            // if need be, and scan for existing requirement elements.
222
            foreach (EA.Connector connector in base.RQ_Element.Connectors)
232
            EA.Package parentPackage = Main.EA_Repository.GetPackageByID( base.RQ_Element.PackageID );
223
            {
233
 
224
               EA.Element ea_req = ea_repository.GetElementByID( connector.SupplierID );
234
            ArrayList allowedElementTypes = new ArrayList();
225
               if (ea_req != null)
235
            allowedElementTypes.Add("Requirement");
226
               {
236
            allowedElementTypes.Add("UseCase");
227
                  ea_reqs.Add(ea_req);
237
 
228
                  string GUID = EA_Utils.ReadTag(ea_req, "GUID");
238
            Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "", -1);
229
                  ea_GUIDs.Add(GUID);
239
            Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Acquiring list of elements already in EA", -1);
230
                  ea_req_matched.Add(false);
240
            ElementAccumulator reqLister = new ElementAccumulator(allowedElementTypes);
231
               }
241
            EA_Utils.findAndProcessPackageElements( parentPackage, reqLister, true );
232
            }
242
 
233
 
243
            if (Main.mustAbort)
234
            // Obtain the EA parent package so that we can create under it an import package
244
               return;
235
            // if need be.
245
 
236
            EA.Package parentPackage = ea_repository.GetPackageByID( base.RQ_Element.PackageID );
246
            ea_reqs = reqLister.Elements; 
237
 
247
            foreach (EA.Element ea_req in ea_reqs)
238
            EA.Package importPackage = (EA.Package )parentPackage.Packages.AddNew( "import " + importDateTime, "Package");
248
            {
239
            importPackage.Update();
249
               string GUID = EA_Utils.ReadTag(ea_req, "GUID");
240
 
250
               ea_GUIDs.Add(GUID);
241
            EA.Element changeLog = (EA.Element)importPackage.Elements.AddNew("Change Log","InformationItem");
251
               ea_req_matched.Add(false);
242
            changeLog.Update();
252
            }
243
 
253
 
244
            // Get a flattened list of requirements from the hierarchical data the user has filtered
254
            if (Main.mustAbort)
245
            ArrayList rq_req_collection = new ArrayList();
255
               return;
246
            get_rq_req_collection(ea_repository, ref rq_req_collection);
256
 
247
 
257
            EA.Package importPackage = (EA.Package )parentPackage.Packages.AddNew( "import " + importDateTime, "Package");
248
            int newRequirementCount = 0;
258
            importPackage.Update();
249
            int modifiedRequirementCount = 0;
259
 
250
            int statusUpdatedRequirementCount = 0;
260
            EA.Element changeLog = (EA.Element)importPackage.Elements.AddNew("Change Log","InformationItem");
251
            int orphanedCount = 0;
261
            changeLog.Update();
252
 
262
 
253
 
263
            // Get a flattened list of requirements from the hierarchical data the user has filtered
254
            // loop through all of the ReqPro requirements
264
            ArrayList rq_req_collection = new ArrayList();
255
            foreach(ReqPro_object rq_obj in rq_req_collection)
265
            get_rq_req_collection(ref rq_req_collection);
256
            {
266
 
257
               try
267
            int newRequirementCount = 0;
258
               {
268
            int modifiedRequirementCount = 0;
259
                  // Find which EA requirement element refers to the current ReqPro GUID
269
            int statusUpdatedRequirementCount = 0;
260
                  int i_ea_req;
270
            int orphanedCount = 0;
261
                  i_ea_req = ea_GUIDs.IndexOf( rq_obj.guid );
271
 
262
 
272
 
263
                  // If EA element was found
273
            Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Merging ReqPro content to EA", -1);
264
                  if (0 <= i_ea_req)
274
            // loop through all of the ReqPro requirements
265
                  {
275
            foreach(ReqPro_object rq_obj in rq_req_collection)
266
                     ea_req_matched[i_ea_req] = true;
276
            {
267
 
277
               if (Main.mustAbort)
268
                     EA.Element ea_req = ((EA.Element)ea_reqs[i_ea_req]);
278
                  break;
269
 
279
 
270
                     rq_obj.ea_element_ID = ea_req.ElementID;
280
               try
271
 
281
               {
272
                     // This ReqPro requirement already has a counterpart in EA, so we must simply
282
                  // Find which EA requirement element refers to the current ReqPro GUID
273
                     // update the counterpart. But, to aid the designer, we need to try to tell them
283
                  int i_ea_req;
274
                     // how the requirement has changed, which could ofcoarse change the meaning 
284
                  i_ea_req = ea_GUIDs.IndexOf( rq_obj.guid );
275
                     // of the requirement and require design changes to be done.
285
 
276
 
286
                  // If EA element was found
277
                     bool meaningMayHaveChanged = false;
287
                  if (0 <= i_ea_req)
278
                     bool statusMayHaveChanged = false;
288
                  {
279
                     
289
                     ea_req_matched[i_ea_req] = true;
280
                     string ea_req_name = rq_obj.tag + " " + rq_obj.name;
290
 
281
 
291
                     EA.Element ea_req = ((EA.Element)ea_reqs[i_ea_req]);
282
                     if ( ea_req.Name.CompareTo(ea_req_name) != 0 )
292
 
283
                     {
293
                     rq_obj.ea_element_ID = ea_req.ElementID;
284
                        changeLog.Notes += ea_req.ElementGUID + ":Name:" + NO_COLONS(ea_req.Name) + ":" + NO_COLONS(ea_req_name) + "\r\n";
294
 
285
                        changeLog.Update();
295
                     // This ReqPro requirement already has a counterpart in EA, so we must simply
286
                        meaningMayHaveChanged = true;
296
                     // update the counterpart. But, to aid the designer, we need to try to tell them
287
                        ea_req.Name  = ea_req_name;
297
                     // how the requirement has changed, which could ofcoarse change the meaning 
288
                     }
298
                     // of the requirement and require design changes to be done.
289
 
299
 
290
                     if ( ea_req.Notes.CompareTo(rq_obj.text) != 0 )
300
                     bool meaningMayHaveChanged = false;
291
                     {
301
                     bool statusMayHaveChanged = false;
292
                        changeLog.Notes += ea_req.ElementGUID + ":Notes:" + NO_COLONS(ea_req.Notes) + ":" + NO_COLONS(rq_obj.text) + "\r\n";
302
                     
293
                        changeLog.Update();
303
                     string ea_req_name = rq_obj.tag + " " + rq_obj.name;
294
                        meaningMayHaveChanged = true;
304
 
295
                        ea_req.Notes = rq_obj.text;
305
                     Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Updating: " + ea_req_name, rq_obj.ea_element_ID);
296
                     }
306
 
297
 
307
                     if ( ea_req.Name.CompareTo(ea_req_name) != 0 )
298
                     if (ea_req.Difficulty != rq_obj.difficulty)
308
                     {
299
                     {
309
                        changeLog.Notes += ea_req.ElementGUID + ":Name:" + NO_COLONS(ea_req.Name) + ":" + NO_COLONS(ea_req_name) + "\r\n";
300
                        changeLog.Notes += ea_req.ElementGUID + ":Difficulty:" + ea_req.Difficulty + ":" + rq_obj.difficulty + "\r\n";
310
                        changeLog.Update();
301
                        changeLog.Update();
311
                        meaningMayHaveChanged = true;
302
                        statusMayHaveChanged = true;
312
                        ea_req.Name  = ea_req_name;
303
                        ea_req.Difficulty    = rq_obj.difficulty;
313
                     }
304
                     }
314
 
305
                     if (ea_req.Priority != rq_obj.priority)
315
                     if ( ea_req.Notes.CompareTo(rq_obj.text) != 0 )
306
                     {
316
                     {
307
                        changeLog.Notes += ea_req.ElementGUID + ":Priority:" + ea_req.Priority + ":" + rq_obj.priority + "\r\n";
317
                        changeLog.Notes += ea_req.ElementGUID + ":Notes:" + NO_COLONS(ea_req.Notes) + ":" + NO_COLONS(rq_obj.text) + "\r\n";
308
                        changeLog.Update();
318
                        changeLog.Update();
309
                        statusMayHaveChanged = true;
319
                        meaningMayHaveChanged = true;
310
                        ea_req.Priority      = rq_obj.priority;
320
                        ea_req.Notes = rq_obj.text;
311
                     }
321
                     }
312
                     if (ea_req.Version != rq_obj.version)
322
 
313
                     {
323
                     if (ea_req.Difficulty != rq_obj.difficulty)
314
                        changeLog.Notes += ea_req.ElementGUID + ":Version:" + ea_req.Version + ":" + rq_obj.version + "\r\n";
324
                     {
315
                        changeLog.Update();
325
                        changeLog.Notes += ea_req.ElementGUID + ":Difficulty:" + ea_req.Difficulty + ":" + rq_obj.difficulty + "\r\n";
316
                        statusMayHaveChanged = true;
326
                        changeLog.Update();
317
                        ea_req.Version       = rq_obj.version;
327
                        statusMayHaveChanged = true;
318
                     }
328
                        ea_req.Difficulty    = rq_obj.difficulty;
319
                     if (ea_req.Status != rq_obj.status)
329
                     }
320
                     {
330
                     if (ea_req.Priority != rq_obj.priority)
321
                        changeLog.Notes += ea_req.ElementGUID + ":Status:" + ea_req.Status + ":" + rq_obj.status + "\r\n";
331
                     {
322
                        changeLog.Update();
332
                        changeLog.Notes += ea_req.ElementGUID + ":Priority:" + ea_req.Priority + ":" + rq_obj.priority + "\r\n";
323
                        statusMayHaveChanged = true;
333
                        changeLog.Update();
324
                        ea_req.Status        = rq_obj.status;
334
                        statusMayHaveChanged = true;
325
                     }
335
                        ea_req.Priority      = rq_obj.priority;
326
 
336
                     }
327
                     ea_req.Update();
337
                     if (ea_req.Version != rq_obj.version)
328
 
338
                     {
329
                     if (meaningMayHaveChanged)
339
                        changeLog.Notes += ea_req.ElementGUID + ":Version:" + ea_req.Version + ":" + rq_obj.version + "\r\n";
330
                     {
340
                        changeLog.Update();
331
                        modifiedRequirementCount++;
341
                        statusMayHaveChanged = true;
332
                     }
342
                        ea_req.Version       = rq_obj.version;
333
                     
343
                     }
334
                     if (statusMayHaveChanged)
344
                     if (ea_req.Status != rq_obj.status)
335
                     {
345
                     {
336
                        statusUpdatedRequirementCount++;
346
                        changeLog.Notes += ea_req.ElementGUID + ":Status:" + ea_req.Status + ":" + rq_obj.status + "\r\n";
337
                     }
347
                        changeLog.Update();
338
                  }
348
                        statusMayHaveChanged = true;
339
                  else
349
                        ea_req.Status        = rq_obj.status;
340
                  {
350
                     }
341
                     // This ReqPro requirement does not have a counterpart in EA, so we must create
351
 
342
                     // a new one.
352
                     ea_req.Update();
343
                     newRequirementCount++;
353
 
344
 
354
                     if (meaningMayHaveChanged)
345
                     // create the new EA requirement in the import package
355
                     {
346
                     EA.Element ea_req = (EA.Element)importPackage.Elements.AddNew( rq_obj.tag + " " + rq_obj.name, "Requirement");
356
                        modifiedRequirementCount++;
347
                     ea_req.Notes = rq_obj.text;
357
                     }
348
 
358
                     
349
                     rq_obj.ea_element_ID = ea_req.ElementID;
359
                     if (statusMayHaveChanged)
350
 
360
                     {
351
                     ea_req.Difficulty = rq_obj.difficulty;
361
                        statusUpdatedRequirementCount++;
352
                     ea_req.Priority   = rq_obj.priority;
362
                     }
353
                     ea_req.Version    = rq_obj.version;
363
 
354
                     ea_req.Status     = rq_obj.status;
364
                     totalRequirements++;
355
 
365
 
356
                     EA_Utils.WriteTag(ea_req, "GUID", rq_obj.guid);
366
                  }
357
                     EA_Utils.WriteTag(ea_req, "TAG", rq_obj.tag);
367
                  else
358
                     ea_req.Update();
368
                  {
359
 
369
                     totalRequirements++;
360
                     // Connect the new requirement to the ea_rq_artifact
370
 
361
                     base.RQ_Artifact.add_connection(ea_repository, base.RQ_Element, ea_req);
371
                     // This ReqPro requirement does not have a counterpart in EA, so we must create
362
 
372
                     // a new one.
363
                     changeLog.Notes += ea_req.ElementGUID + ":Created:" + ea_req.Name + "\r\n";
373
                     newRequirementCount++;
364
                     changeLog.Update();
374
 
365
                  }
375
                     // create the new EA requirement in the import package
366
                  
376
                     EA.Element ea_req = (EA.Element)importPackage.Elements.AddNew( rq_obj.tag + " " + rq_obj.name, "Requirement");
367
               }
377
                     ea_req.Notes = rq_obj.text;
368
               catch (Exception ex)
378
 
369
               {
379
                     rq_obj.ea_element_ID = ea_req.ElementID;
370
                  ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Exception (ImportFromReqPro), " + ex.Message + ", " + rq_obj.name, -1);
380
 
371
               }
381
                     ea_req.Difficulty = rq_obj.difficulty;
372
            }
382
                     ea_req.Priority   = rq_obj.priority;
373
 
383
                     ea_req.Version    = rq_obj.version;
374
 
384
                     ea_req.Status     = rq_obj.status;
375
            // Now check for orphaned EA requirements
385
 
376
            for (int i = 0; i < ea_GUIDs.Count; i++)
386
                     EA_Utils.WriteTag(ea_req, "GUID", rq_obj.guid);
377
            {
387
                     EA_Utils.WriteTag(ea_req, "TAG", rq_obj.tag);
378
               string rq_GUID = (string)ea_GUIDs[i];
388
                     ea_req.Update();
379
               if (rq_GUID != "")
389
 
380
               {
390
                     // Connect the new requirement to the ea_rq_artifact
381
                  if ((bool)ea_req_matched[i] == false)
391
                     //base.RQ_Artifact.add_connection(ea_repository, base.RQ_Element, ea_req);
382
                  {
392
 
383
                     EA.Element ea_req = (EA.Element)ea_reqs[i];
393
                     changeLog.Notes += ea_req.ElementGUID + ":Created:" + ea_req.Name + "\r\n";
384
       
394
                     changeLog.Update();
385
                     orphanedCount++;
395
 
386
 
396
                     Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Created: " + ea_req.Name, ea_req.ElementID);
387
                     changeLog.Notes += ea_req.ElementGUID + ":Orphaned:" + ea_req.Name + "\r\n";
397
                  }
388
                     changeLog.Update();
398
                  
389
                  }
399
               }
390
               }
400
               catch (Exception ex)
391
            }
401
               {
392
 
402
                  Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Exception (ImportFromReqPro), " + ex.Message + ", " + rq_obj.name, -1);
393
            displayChangeLog(ea_repository, changeLog);
403
               }
394
 
404
            }
395
            ea_repository.RefreshModelView(parentPackage.PackageID);
405
 
396
 
406
            if (Main.mustAbort)
-
 
407
               return;
-
 
408
 
-
 
409
            Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Checking for orphaned requirements", -1);
-
 
410
            // Now check for orphaned EA requirements
-
 
411
            for (int i = 0; i < ea_GUIDs.Count; i++)
-
 
412
            {
-
 
413
               if (Main.mustAbort)
-
 
414
                  break;
-
 
415
 
-
 
416
               string rq_GUID = (string)ea_GUIDs[i];
-
 
417
               if (rq_GUID != "")
-
 
418
               {
-
 
419
                  if ((bool)ea_req_matched[i] == false)
-
 
420
                  {
-
 
421
                     EA.Element ea_req = (EA.Element)ea_reqs[i];
-
 
422
       
-
 
423
                     orphanedCount++;
-
 
424
 
-
 
425
                     changeLog.Notes += ea_req.ElementGUID + ":Orphaned:" + ea_req.Name + "\r\n";
-
 
426
                     changeLog.Update();
-
 
427
                  }
-
 
428
               }
-
 
429
            }
-
 
430
 
-
 
431
            DialogResult dlgres = MessageBoxEx.Show("Display Change Log?", "Change Log", MessageBoxButtons.YesNo);
-
 
432
            if (dlgres == DialogResult.Yes)
-
 
433
               displayChangeLog(changeLog);
-
 
434
 
-
 
435
            Main.EA_Repository.RefreshModelView(parentPackage.PackageID);
-
 
436
 
397
            // Setup the internal requirement to requirement connectivity. This is seperate from the browser
437
            // Setup the internal requirement to requirement connectivity. This is seperate from the browser
398
            // organisation of elements in EA, but since in ReqPro, that organisation tells part of the story
438
            // organisation of elements in EA, but since in ReqPro, that organisation tells part of the story
399
            // of requirement to requirement connectivity, it is mirrored in the internal connectivity, along
439
            // of requirement to requirement connectivity, it is mirrored in the internal connectivity, along
400
            // with explicit trace relationships setup in ReqPro.
440
            // with explicit trace relationships setup in ReqPro.
401
            // The purpose of this internal connectivity is to support relationship matrix tables in documentation
441
            // The purpose of this internal connectivity is to support relationship matrix tables in documentation
402
            // generated by EA_DocGen, or to support diagrammatic representations of the requirements in EA,
442
            // generated by EA_DocGen, or to support diagrammatic representations of the requirements in EA,
403
            // where the connectivity will become apparent through links ajoining the requirement elements in the
443
            // where the connectivity will become apparent through links ajoining the requirement elements in the
404
            // diagram.
444
            // diagram.
405
            ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Writing Trace Information", -1);
-
 
406
            foreach( ReqPro_object sub_obj in rq_root_package.ReqPro_objects )
445
            write_traces(totalRequirements);
407
            {
446
 
408
               write_traces(ea_repository, sub_obj);
447
            if (Main.mustAbort)
409
            }
448
               return;
410
 
449
 
411
            // display summary stats
450
            // display summary stats
412
            ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, newRequirementCount.ToString() + " new requirements", -1);
451
            Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, newRequirementCount.ToString() + " new requirements", -1);
413
            ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, modifiedRequirementCount.ToString() + " requirements modified", -1);
452
            Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, modifiedRequirementCount.ToString() + " requirements modified", -1);
414
            ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, statusUpdatedRequirementCount.ToString() + " requirements had status changes", -1);
453
            Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, statusUpdatedRequirementCount.ToString() + " requirements had status changes", -1);
415
            ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, orphanedCount.ToString() + " requirements were orphaned", -1);
454
            Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, orphanedCount.ToString() + " requirements were orphaned", -1);
416
 
455
 
417
            ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Completed import", -1);
456
            writeDelayedMessages();
418
 
457
 
-
 
458
            Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Import Completed", -1);
419
            MessageBox.Show("Import Completed");
459
            MessageBoxEx.Show("Import Completed", MessageBoxButtons.OK);
420
         }
460
         }
421
         catch (Exception ex)
461
         catch (Exception ex)
422
         {
462
         {
423
            MessageBox.Show(ex.Message, "Error (ImportFromReqPro)", MessageBoxButtons.OK);
463
            MessageBoxEx.Show(ex.Message, "Error (ImportFromReqPro)", MessageBoxButtons.OK);
424
         }
464
         }
425
      }
465
      }
426
 
466
 
427
 
467
 
428
 
468
 
429
 
469
 
430
      /// <summary>
470
      /// <summary>
431
      /// This method (along with its sibling overload) obtains a flattened view of the 
471
      /// This method (along with its sibling overload) obtains a flattened view of the 
432
      /// hierarchical requirements obtained from the ReqPro database. This accumulation
472
      /// hierarchical requirements obtained from the ReqPro database. This accumulation
433
      /// takes account of the users filtering requests.
473
      /// takes account of the users filtering requests.
434
      /// </summary>
474
      /// </summary>
435
      /// <param name="ea_repository"></param>
475
      /// <param name="ea_repository"></param>
436
      private void get_rq_req_collection(EA.Repository ea_repository, ref ArrayList rq_req_collection)
476
      private void get_rq_req_collection(ref ArrayList rq_req_collection)
437
      {
477
      {
438
         foreach( ReqPro_object sub_obj in rq_root_package.ReqPro_objects )
478
         foreach( ReqPro_object sub_obj in rq_root_package.ReqPro_objects )
439
         {
479
         {
440
            get_rq_req_collection(ea_repository, ref rq_req_collection, sub_obj);
480
            get_rq_req_collection(ref rq_req_collection, sub_obj);
441
         }
481
         }
442
      }
482
      }
443
 
483
 
444
      private void get_rq_req_collection(EA.Repository ea_repository,
484
      private void get_rq_req_collection(ref ArrayList rq_req_collection,
445
                                         ref ArrayList rq_req_collection,
-
 
446
                                         ReqPro_object rq_obj )
485
                                         ReqPro_object rq_obj )
447
      {
486
      {
448
         if (rq_obj.isPackage)
487
         if (rq_obj.isPackage)
449
         {
488
         {
450
            // if the package is not filtered, or if we are allowed to dig beneath filtered
489
            // if the package is not filtered, or if we are allowed to dig beneath filtered
Line 459... Line 498...
459
                  // is not filtered, so that requirements of filtered packages are themselves
498
                  // is not filtered, so that requirements of filtered packages are themselves
460
                  // filtered out by virtue of their parent packages filtering state.
499
                  // filtered out by virtue of their parent packages filtering state.
461
                  if (  sub_obj.isPackage
500
                  if (  sub_obj.isPackage
462
                     || (sub_obj.isRequirement && rq_obj.filtered == false))
501
                     || (sub_obj.isRequirement && rq_obj.filtered == false))
463
                  {
502
                  {
464
                     get_rq_req_collection(ea_repository, ref rq_req_collection, sub_obj);
503
                     get_rq_req_collection(ref rq_req_collection, sub_obj);
465
                  }
504
                  }
466
               }
505
               }
467
            }
506
            }
468
         }
507
         }
469
         else if (rq_obj.isRequirement)
508
         else if (rq_obj.isRequirement)
Line 498... Line 537...
498
               // Using recursion, scan this objects sub-objects, which in practise will all
537
               // Using recursion, scan this objects sub-objects, which in practise will all
499
               // be requirement objects. At this time requirement objects cannot have packages 
538
               // be requirement objects. At this time requirement objects cannot have packages 
500
               // as children.
539
               // as children.
501
               foreach( ReqPro_object sub_obj in rq_obj.ReqPro_objects )
540
               foreach( ReqPro_object sub_obj in rq_obj.ReqPro_objects )
502
               {
541
               {
503
                  get_rq_req_collection(ea_repository, ref rq_req_collection, sub_obj);
542
                  get_rq_req_collection(ref rq_req_collection, sub_obj);
504
               }
543
               }
505
            }
544
            }
506
         }
545
         }
507
      }
546
      }
508
 
547