Browse files

Continue of implementation and some changes.

  • Loading branch information...
1 parent 5f19ab2 commit b59a7b2eee76ec55f5e2afbc14505e2f0dc12b97 @redsteve committed Jun 26, 2011
Showing with 43 additions and 11 deletions.
  1. +43 −11 EA_ReqIF_AddIn/ReqIfHeaderImporter.cs
View
54 EA_ReqIF_AddIn/ReqIfHeaderImporter.cs
@@ -4,9 +4,10 @@
namespace EA_ReqIF_AddIn
{
/// <summary>
- /// Description of ReqIfHeaderImporter.
+ /// Objects of this class are responsible for importing the parts of a ReqIF file between
+ /// XML nodes <c>&lt;REQ-IF-HEADER&gt;</c> and <c>&lt;/REQ-IF-HEADER&gt;</c>.
/// </summary>
- public class ReqIfHeaderImporter
+ public class ReqIfHeaderImporter : BasicReqIfFileImporter
{
private enum ProcessingElement
{
@@ -23,13 +24,18 @@ private enum ProcessingElement
private ProcessingElement processingElement;
private Package requirementsPackage;
+ public Package RequirementsPackage
+ {
+ get { return requirementsPackage; }
+ }
+
public ReqIfHeaderImporter(Package rootPackage)
{
processingElement = ProcessingElement.Undefined;
if (rootPackage == null)
{
- throw new Exception();
+ throw new ArgumentNullException();
}
createPackage(rootPackage);
@@ -40,14 +46,15 @@ private void createPackage(Package rootPackage)
EnterpriseArchitectModelElementFactory factory =
new EnterpriseArchitectModelElementFactory();
requirementsPackage = factory.createPackage(rootPackage, "Requirements");
+ requirementsPackage.Element.Author = "<imported>";
requirementsPackage.StereotypeEx = "ExchangeDocument";
if (! requirementsPackage.Update())
{
-
+ throw new ParserFailureException();
}
}
- public void ProcessElementStartNode(string name)
+ public override void ProcessElementStartNode(string name)
{
switch (name)
{
@@ -80,11 +87,11 @@ public void ProcessElementStartNode(string name)
break;
default:
- throw new InvalidOperationException();
+ throw new ParserFailureException("Unexpected or unknown element node: " + name + ".");
}
}
- public void ProcessTextNode(string text)
+ public override void ProcessTextNode(string text)
{
switch (processingElement)
{
@@ -93,29 +100,54 @@ public void ProcessTextNode(string text)
break;
case ProcessingElement.CreationTime:
- DateTime creationTime = DateTime.Parse(text);
- requirementsPackage.Created = creationTime;
- requirementsPackage.Modified = creationTime;
+ SetElementsCreatedAndModifiedTimeStamps(requirementsPackage, text);
break;
case ProcessingElement.RepositoryId:
+ AddTaggedValueToElement(requirementsPackage.Element, "repositoryId", "String", text);
break;
case ProcessingElement.ReqIfToolId:
+ AddTaggedValueToElement(requirementsPackage.Element, "reqIfToolId", "String", text);
break;
case ProcessingElement.ReqIfVersion:
+ AddTaggedValueToElement(requirementsPackage.Element, "reqIfVersion", "String", text);
break;
case ProcessingElement.SourceToolId:
+ AddTaggedValueToElement(requirementsPackage.Element, "sourceToolId", "String", text);
break;
case ProcessingElement.Title:
requirementsPackage.Name = text;
break;
default:
- throw new InvalidOperationException();
+ throw new ParserFailureException("Unexpected or unknown text node: " + text + ".");
+ }
+
+ if (! requirementsPackage.Update())
+ {
+ throw new ParserFailureException(requirementsPackage.GetLastError());
+ }
+ }
+
+ public override void ProcessElementEndNode(string name)
+ {
+ // Nothing to do here!
+ }
+
+ public override void ProcessAttribute(string name, string value)
+ {
+ switch (name)
+ {
+ case "IDENTIFIER":
+ AddTaggedValueToElement(requirementsPackage.Element, "identifier", "String", value);
+ break;
+
+ default:
+ throw new ParserFailureException("Unexpected or unknown attribute: " + name + ".");
}
}
}

0 comments on commit b59a7b2

Please sign in to comment.