Subversion Repositories DevTools

Rev

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

Rev 2155 Rev 2157
Line 133... Line 133...
133
               parentPackage = Main.EA_Repository.GetPackageByID( base.RQ_Element.PackageID );
133
               parentPackage = Main.EA_Repository.GetPackageByID( base.RQ_Element.PackageID );
134
            }
134
            }
135
            #endregion
135
            #endregion
136
 
136
 
137
            #region GET_EXPORT_LIST
137
            #region GET_EXPORT_LIST
138
            Main.WriteOutput("Acquiring list of elements already in EA", -1);
138
            Main.WriteOutput("Acquiring list of requirement elements in EA", -1);
139
 
139
 
140
            // setup the element types list to control the element accumulation
140
            // setup the element types list to control the element accumulation
141
            ArrayList allowedElementTypes = new ArrayList();
141
            ArrayList allowedElementTypes = new ArrayList();
142
            allowedElementTypes.Add("Requirement");
142
            allowedElementTypes.Add("Requirement");
143
            //allowedElementTypes.Add("UseCase");
143
            //allowedElementTypes.Add("UseCase");
Line 302... Line 302...
302
 
302
 
303
            // process each requirement found in EA that needs exporting
303
            // process each requirement found in EA that needs exporting
304
            foreach(EA.Element ea_req in ea_reqs)
304
            foreach(EA.Element ea_req in ea_reqs)
305
            {
305
            {
306
               // get EA requirement without any temporary tag that the modeller may have given it
306
               // get EA requirement without any temporary tag that the modeller may have given it
-
 
307
               string tag = null;
307
               string ea_req_untagged_name = untaggedReqName(ea_req.Name, false);
308
               string ea_req_untagged_name = untaggedReqName(ea_req.Name, ref tag, false);
308
 
309
 
309
               Main.WriteOutput("Exporting : " + ea_req.Name, ea_req.ElementID);
310
               Main.WriteOutput("Exporting : " + ea_req.Name, ea_req.ElementID);
310
 
311
 
311
               // Add the requirement to ReqPro requirement collection
312
               // Add the requirement to ReqPro requirement collection
312
               ReqPro40.Requirement rp_req = ReqProDatabase.add_requirement(req_collection, ea_req_untagged_name, ea_req.Notes, this.m_ReqType);
313
               ReqPro40.Requirement rp_req = ReqProDatabase.add_requirement(req_collection, ea_req_untagged_name, ea_req.Notes, this.m_ReqType);
Line 333... Line 334...
333
 
334
 
334
                     cancelled = true;
335
                     cancelled = true;
335
                     return false;
336
                     return false;
336
                  }
337
                  }
337
 
338
 
338
                  // Attempt to set any attributes in the new ReqPro requirement. 
-
 
339
                  exportAttributes(rp_req, ea_req);
-
 
340
 
339
 
341
                  // Commit changes to ReqPro database
340
                  // Commit changes to ReqPro database
342
                  rp_req.Save();
341
                  rp_req.Save();
343
 
342
 
344
                  // Now locate the new requirement under the selected package in ReqPro
343
                  // Now locate the new requirement under the selected package in ReqPro
Line 376... Line 375...
376
 
375
 
377
                  // Now re-acquire the tag, which should no longer be in a pending form but have a real number
376
                  // Now re-acquire the tag, which should no longer be in a pending form but have a real number
378
                  // assigned to it as a result of the commit we just did above.
377
                  // assigned to it as a result of the commit we just did above.
379
                  rp_req_tag = rp_req.get_Tag(ReqPro40.enumTagFormat.eTagFormat_FullTag);
378
                  rp_req_tag = rp_req.get_Tag(ReqPro40.enumTagFormat.eTagFormat_FullTag);
380
 
379
 
-
 
380
                  // Attempt to set any attributes in the new ReqPro requirement. 
-
 
381
                  exportAttributes(rp_req, ea_req, rp_req_tag);
-
 
382
                  rp_req.Save();
-
 
383
 
381
                  // Update the EA requirement for the second time, now with the correct and final tag
384
                  // Update the EA requirement for the second time, now with the correct and final tag
382
                  ea_req.Name = rp_req_tag + " " + ea_req_untagged_name;
385
                  ea_req.Name = rp_req_tag + " " + ea_req_untagged_name;
383
                  ea_req.Update();
386
                  ea_req.Update();
384
                  Main.WriteOutput("   (Re)Assigned Tag : " + ea_req.Name, ea_req.ElementID);
387
                  Main.WriteOutput("   (Re)Assigned Tag : " + ea_req.Name, ea_req.ElementID);
385
 
388
 
Line 458... Line 461...
458
                  // Try and find the requirement in ReqPro
461
                  // Try and find the requirement in ReqPro
459
                  rp_req = ReqProDatabase.get_requirement_by_guid(GUID);
462
                  rp_req = ReqProDatabase.get_requirement_by_guid(GUID);
460
                  if (rp_req != null)
463
                  if (rp_req != null)
461
                  {
464
                  {
462
                     // copy name and notes from EA to ReqPro
465
                     // copy name and notes from EA to ReqPro
-
 
466
                     string tag = null;
463
                     string ea_req_untagged_name = untaggedReqName(ea_req.Name, true);
467
                     string ea_req_untagged_name = untaggedReqName(ea_req.Name, ref tag, true);
464
 
468
 
465
                     // Test that the EA requirement can be updated.
469
                     // Test that the EA requirement can be updated.
466
                     ea_req.Name = ea_req_untagged_name;
470
                     ea_req.Name = ea_req_untagged_name;
467
                     ea_req.Update();
471
                     ea_req.Update();
468
                     if (false == ea_req.Update())
472
                     if (false == ea_req.Update())
Line 480... Line 484...
480
 
484
 
481
                     // copy content to the existing ReqPro requirement
485
                     // copy content to the existing ReqPro requirement
482
                     rp_req.Name = ea_req_untagged_name;
486
                     rp_req.Name = ea_req_untagged_name;
483
                     rp_req.Text = ea_req.Notes;
487
                     rp_req.Text = ea_req.Notes;
484
 
488
 
-
 
489
                     string rp_req_tag = rp_req.get_Tag(ReqPro40.enumTagFormat.eTagFormat_FullTag);
-
 
490
 
485
                     // Attempt to set any attributes in the existing ReqPro requirement. 
491
                     // Attempt to set any attributes in the existing ReqPro requirement. 
486
                     exportAttributes(rp_req, ea_req);
492
                     exportAttributes(rp_req, ea_req, rp_req_tag);
487
 
493
 
488
                     // Commit changes to ReqPro database
494
                     // Commit changes to ReqPro database
489
                     rp_req.Save();
495
                     rp_req.Save();
490
 
496
 
491
                     // Although we are allowing EA to be the master repository of requirements
497
                     // Although we are allowing EA to be the master repository of requirements
492
                     // if they were originally created in EA, we still want to use ReqPro as the
498
                     // if they were originally created in EA, we still want to use ReqPro as the
493
                     // master for any numbering scheme (ie. tags), so update the EA requirements
499
                     // master for any numbering scheme (ie. tags), so update the EA requirements
494
                     // Tag as necessary.
500
                     // Tag as necessary.
495
                     string rp_req_tag = rp_req.get_Tag(ReqPro40.enumTagFormat.eTagFormat_FullTag);
-
 
496
                     ea_req.Name = rp_req_tag + " " + ea_req_untagged_name;
501
                     ea_req.Name = rp_req_tag + " " + ea_req_untagged_name;
497
                     ea_req.Update();
502
                     ea_req.Update();
498
                     EA_TaggedValues.Write(ea_req, Constants.TAG_TAG, rp_req_tag);
503
                     EA_TaggedValues.Write(ea_req, Constants.TAG_TAG, rp_req_tag);
499
                     Main.WriteOutput("Updated : " + ea_req.Name, ea_req.ElementID);
504
                     Main.WriteOutput("Updated : " + ea_req.Name, ea_req.ElementID);
500
                  }
505
                  }
Line 1001... Line 1006...
1001
      /// Look for and strip any temporary tag from the requirement name, returning a new
1006
      /// Look for and strip any temporary tag from the requirement name, returning a new
1002
      /// string to be used as the requirement name
1007
      /// string to be used as the requirement name
1003
      /// </summary>
1008
      /// </summary>
1004
      /// <param name="taggedReqName"></param>
1009
      /// <param name="taggedReqName"></param>
1005
      /// <returns></returns>
1010
      /// <returns></returns>
1006
      private string untaggedReqName(string taggedReqName, bool force)
1011
      private string untaggedReqName(string taggedReqName, ref string tag, bool force)
1007
      {
1012
      {
1008
         if (taggedReqName != null)
1013
         if (taggedReqName != null)
1009
         {
1014
         {
1010
            // Try and split the string into two tokens at the first space character
1015
            // Try and split the string into two tokens at the first space character
1011
            char [] delim = {' '};
1016
            char [] delim = {' '};
1012
            string [] tokens = taggedReqName.Split(delim, 2);
1017
            string [] tokens = taggedReqName.Split(delim, 2);
1013
 
1018
 
1014
            // if there are two tokens resulting from the split
1019
            // if there are two tokens resulting from the split
1015
            if (tokens.GetLength(0) == 2)
1020
            if (tokens.GetLength(0) == 2)
1016
            {
1021
            {
1017
               
1022
               // return tag
-
 
1023
               tag = tokens[0];
-
 
1024
 
1018
               // if the first token appears to be a tag
1025
               // if the first token appears to be a tag
1019
               if (force == true
1026
               if (force == true
1020
                  || tokens[0].StartsWith("REQ")
1027
                  || tokens[0].StartsWith("REQ")
1021
                  || tokens[0].StartsWith("TAG")
1028
                  || tokens[0].StartsWith("TAG")
1022
                  || tokens[0].StartsWith("SPR")
1029
                  || tokens[0].StartsWith("SPR")
Line 1029... Line 1036...
1029
         }
1036
         }
1030
         // default to the input string
1037
         // default to the input string
1031
         return taggedReqName;
1038
         return taggedReqName;
1032
      }
1039
      }
1033
 
1040
 
-
 
1041
      private string tagPrefix(string tag)
-
 
1042
      {
-
 
1043
         if (tag != null && tag.Length > 0)
-
 
1044
         {
-
 
1045
            string[] prefixes = tag.Split("0123456789.".ToCharArray());
-
 
1046
            if (prefixes.GetLength(0) > 0)
-
 
1047
            {
-
 
1048
               return prefixes[0];
-
 
1049
            }
-
 
1050
         }
-
 
1051
         return tag;
-
 
1052
      }
1034
 
1053
 
1035
      private void exportAttributes(ReqPro40.Requirement rp_req, EA.Element ea_req)
1054
      private void exportAttributes(ReqPro40.Requirement rp_req, EA.Element ea_req, string rp_req_tag)
1036
      {
1055
      {
1037
         // Update the attributes of a ReqPro requirement. We have to be very careful here.
1056
         // Update the attributes of a ReqPro requirement. We have to be very careful here.
1038
         // ReqPro does not like us trying to set the value of attributes that do not exist for the
1057
         // ReqPro does not like us trying to set the value of attributes that do not exist for the
1039
         // specified requirement type, and it also does not like us trying to set an attribute that is
1058
         // specified requirement type, and it also does not like us trying to set an attribute that is
1040
         // a list type, to a value that is not in the predefined set of values for the list type.
1059
         // a list type, to a value that is not in the predefined set of values for the list type.
Line 1046... Line 1065...
1046
         bool hasSourceSection = false;
1065
         bool hasSourceSection = false;
1047
         bool hasSubsystem = false;
1066
         bool hasSubsystem = false;
1048
         bool hasStability = false;
1067
         bool hasStability = false;
1049
         bool hasType = false;
1068
         bool hasType = false;
1050
 
1069
 
-
 
1070
         string reqType = tagPrefix(rp_req_tag);
-
 
1071
 
1051
         // Use the ReqProParser's knowledge of requirement types and attribute type associations to tell
1072
         // Use the ReqProParser's knowledge of requirement types and attribute type associations to tell
1052
         // us what attributes we can set, and then use the setListItemValue() function to do the setting.
1073
         // us what attributes we can set, and then use the setListItemValue() function to do the setting.
1053
         // That function knows how to set List items correctly and safely so as to not cause exceptions
1074
         // That function knows how to set List items correctly and safely so as to not cause exceptions
1054
         // to be raised in the ReqPro automation onject.
1075
         // to be raised in the ReqPro automation onject.
1055
         if (reqTypeHasOneOrMoreAttrs(this.m_ReqType,
1076
         if (reqTypeHasOneOrMoreAttrs(reqType,
1056
            ref hasStatus, ref hasDifficulty, ref hasPriority,
1077
            ref hasStatus, ref hasDifficulty, ref hasPriority,
1057
            ref hasSource, ref hasSourceVersion, ref hasSourceSection,
1078
            ref hasSource, ref hasSourceVersion, ref hasSourceSection,
1058
            ref hasSubsystem, ref hasStability, ref hasType))
1079
            ref hasSubsystem, ref hasStability, ref hasType))
1059
         {
1080
         {
1060
            if (hasStatus)
1081
            if (hasStatus)
1061
            {
1082
            {
1062
               setListItemAttrValue(rp_req, "Status", ea_req.Status);
1083
               setListItemAttrValue(rp_req, ea_req, "Status", ea_req.Status, rp_req_tag);
1063
            }
1084
            }
1064
            if (hasDifficulty)
1085
            if (hasDifficulty)
1065
            {
1086
            {
1066
               setListItemAttrValue(rp_req, "Difficulty", ea_req.Difficulty);
1087
               setListItemAttrValue(rp_req, ea_req, "Difficulty", ea_req.Difficulty, rp_req_tag);
1067
            }
1088
            }
1068
            if (hasPriority)
1089
            if (hasPriority)
1069
            {
1090
            {
1070
               setListItemAttrValue(rp_req, "Priority", ea_req.Priority);
1091
               setListItemAttrValue(rp_req, ea_req, "Priority", ea_req.Priority, rp_req_tag);
-
 
1092
            }
-
 
1093
            if (hasSource)
-
 
1094
            {
-
 
1095
               string s = EA_TaggedValues.Read(ea_req, Constants.TAG_SOURCE);
-
 
1096
               if (s != null && s.Length > 0)
-
 
1097
               {
-
 
1098
                  setListItemAttrValue(rp_req, ea_req, "Source", s, rp_req_tag);
-
 
1099
               }
-
 
1100
            }
-
 
1101
            if (hasSourceVersion)
-
 
1102
            {
-
 
1103
               string s = EA_TaggedValues.Read(ea_req, Constants.TAG_SOURCE_VERSION);
-
 
1104
               if (s != null && s.Length > 0)
-
 
1105
               {
-
 
1106
                  setTextAttrValue(rp_req, ea_req, "Source Version", s, rp_req_tag);
-
 
1107
               }
-
 
1108
            }
-
 
1109
            if (hasSourceSection)
-
 
1110
            {
-
 
1111
               string s = EA_TaggedValues.Read(ea_req, Constants.TAG_SOURCE_SECTION);
-
 
1112
               if (s != null && s.Length > 0)
-
 
1113
               {
-
 
1114
                  setTextAttrValue(rp_req, ea_req, "Source Section", s, rp_req_tag);
-
 
1115
               }
-
 
1116
            }
-
 
1117
            if (hasSubsystem)
-
 
1118
            {
-
 
1119
               string s = EA_TaggedValues.Read(ea_req, Constants.TAG_SUBSYSTEM);
-
 
1120
               if (s != null && s.Length > 0)
-
 
1121
               {
-
 
1122
                  setListItemAttrValue(rp_req, ea_req, "Subsystem", s, rp_req_tag);
-
 
1123
               }
-
 
1124
            }
-
 
1125
            if (hasStability)
-
 
1126
            {
-
 
1127
               string s = EA_TaggedValues.Read(ea_req, Constants.TAG_STABILITY);
-
 
1128
               if (s != null && s.Length > 0)
-
 
1129
               {
-
 
1130
                  setListItemAttrValue(rp_req, ea_req, "Stability", s, rp_req_tag);
-
 
1131
               }
-
 
1132
            }
-
 
1133
            if (hasType)
-
 
1134
            {
-
 
1135
               if (ea_req.Stereotype != null && ea_req.Stereotype.Length > 0)
-
 
1136
               {
-
 
1137
                  setListItemAttrValue(rp_req, ea_req, "Requirement Type", ea_req.Stereotype, rp_req_tag);
-
 
1138
               }
-
 
1139
               else if (ea_req.StereotypeEx != null && ea_req.StereotypeEx.Length > 0)
-
 
1140
               {
-
 
1141
                  string[] s_arr = ea_req.StereotypeEx.Split(",".ToCharArray());
-
 
1142
                  if (s_arr[0] != null && s_arr[0].Length > 0)
-
 
1143
                  {
-
 
1144
                     setListItemAttrValue(rp_req, ea_req, "Requirement Type", s_arr[0], rp_req_tag);
-
 
1145
                  }
-
 
1146
               }
1071
            }
1147
            }
1072
         }
1148
         }
1073
      }
1149
      }
1074
 
1150
 
1075
 
1151
 
Line 1080... Line 1156...
1080
      /// ReqPro automation object.
1156
      /// ReqPro automation object.
1081
      /// </summary>
1157
      /// </summary>
1082
      /// <param name="rp_req"></param>
1158
      /// <param name="rp_req"></param>
1083
      /// <param name="label"></param>
1159
      /// <param name="label"></param>
1084
      /// <param name="value"></param>
1160
      /// <param name="value"></param>
1085
      private void setListItemAttrValue(ReqPro40.Requirement rp_req, string label, string value)
1161
      private void setListItemAttrValue(ReqPro40.Requirement rp_req, EA.Element ea_req, string label, string value, string rp_req_tag)
1086
      {
1162
      {
-
 
1163
         bool attribute_type_found = false;
-
 
1164
         bool attribute_value_found = false;
-
 
1165
 
1087
         // look through each attribute value, for the one whose label matches the one specified
1166
         // look through each attribute value, for the one whose label matches the one specified
1088
         ReqPro40.AttrValues rp_attr_values = rp_req.AttrValues;
1167
         ReqPro40.AttrValues rp_attr_values = rp_req.AttrValues;
1089
 
1168
 
1090
         foreach (ReqPro40.AttrValue rp_attr_value in rp_attr_values)
1169
         foreach (ReqPro40.AttrValue rp_attr_value in rp_attr_values)
1091
         {
1170
         {
1092
            if (rp_attr_value != null && rp_attr_value.Label.Equals(label))
1171
            if (rp_attr_value != null && rp_attr_value.Label.Equals(label))
1093
            {
1172
            {
-
 
1173
               attribute_type_found = true;
-
 
1174
 
1094
               // Look through each list item value to make sure that one exists that matches
1175
               // Look through each list item value to make sure that one exists that matches
1095
               // the value specified
1176
               // the value specified
1096
               ReqPro40.ListItemValues rp_list_item_values = rp_attr_value.ListItemValues;
1177
               ReqPro40.ListItemValues rp_list_item_values = rp_attr_value.ListItemValues;
1097
               if (rp_list_item_values != null)
1178
               if (rp_list_item_values != null)
1098
               {
1179
               {
Line 1101... Line 1182...
1101
                     if (rp_list_item_value.Text.Equals(value))
1182
                     if (rp_list_item_value.Text.Equals(value))
1102
                     {
1183
                     {
1103
                        // We found that the list contains the value specified, so set the value of the attribute
1184
                        // We found that the list contains the value specified, so set the value of the attribute
1104
                        rp_list_item_value.Selected = true;
1185
                        rp_list_item_value.Selected = true;
1105
 
1186
 
-
 
1187
                        attribute_value_found = true;
1106
                        // exit inner loop
1188
                        // exit inner loop
1107
                        break;
1189
                        break;
1108
                     }
1190
                     }
1109
                  }
1191
                  }
1110
               }
1192
               }
1111
               // exit outer loop
1193
               // exit outer loop
1112
               break;
1194
               break;
1113
            }
1195
            }
1114
         }
1196
         }
-
 
1197
 
-
 
1198
         if (!attribute_type_found)
-
 
1199
         {
-
 
1200
            Main.WriteOutput(string.Format("WARNING, Failed to export attribute type ({0}) for ({1})",
-
 
1201
               label, rp_req_tag), ea_req.ElementID);
-
 
1202
         }
-
 
1203
         if (!attribute_value_found)
-
 
1204
         {
-
 
1205
            Main.WriteOutput(string.Format("WARNING, Failed to export attribute type/value ({0}/{1}) for ({2})",
-
 
1206
               label, value, rp_req_tag), ea_req.ElementID);
-
 
1207
         }
-
 
1208
      }
-
 
1209
 
-
 
1210
 
-
 
1211
 
-
 
1212
      /// <summary>
-
 
1213
      /// Set a ReqPro requirement attribute value, for an attribute that is a text type.
-
 
1214
      /// </summary>
-
 
1215
      /// <param name="rp_req"></param>
-
 
1216
      /// <param name="label"></param>
-
 
1217
      /// <param name="value"></param>
-
 
1218
      private void setTextAttrValue(ReqPro40.Requirement rp_req, EA.Element ea_req, string label, string value, string rp_req_tag)
-
 
1219
      {
-
 
1220
         bool attribute_type_found = false;
-
 
1221
 
-
 
1222
         // look through each attribute value, for the one whose label matches the one specified
-
 
1223
         ReqPro40.AttrValues rp_attr_values = rp_req.AttrValues;
-
 
1224
 
-
 
1225
         foreach (ReqPro40.AttrValue rp_attr_value in rp_attr_values)
-
 
1226
         {
-
 
1227
            if (rp_attr_value != null && rp_attr_value.Label.Equals(label))
-
 
1228
            {
-
 
1229
               attribute_type_found = true;
-
 
1230
 
-
 
1231
               rp_attr_value.Text = value;
-
 
1232
 
-
 
1233
               // exit outer loop
-
 
1234
               break;
-
 
1235
            }
-
 
1236
         }
-
 
1237
 
-
 
1238
         if (!attribute_type_found)
-
 
1239
         {
-
 
1240
            Main.WriteOutput(string.Format("WARNING, Failed to export attribute type ({0}) for ({1})",
-
 
1241
               label, rp_req_tag), ea_req.ElementID);
-
 
1242
         }
1115
      }
1243
      }
1116
 
1244
 
1117
 
1245
 
1118
	}
1246
	}
1119
}
1247
}