Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.osee.define')
-rw-r--r--plugins/org.eclipse.osee.define/.classpath14
-rw-r--r--plugins/org.eclipse.osee.define/.project56
-rw-r--r--plugins/org.eclipse.osee.define/META-INF/MANIFEST.MF170
-rw-r--r--plugins/org.eclipse.osee.define/plugin.xml410
-rw-r--r--plugins/org.eclipse.osee.define/reference/define_navigator_view.html52
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/DefinePerspectiveFactory.java106
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishRequirements.java424
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishSubsystemToDesignTraceability.java264
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishWithSpecifiedTemplate.java248
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/RequirementReorderOperation.java150
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/RequirementsTestReport.java342
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/SubsystemRequirementVerificationLevel.java322
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/SubsystemToLowLevelReqTraceReport.java498
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/TestPlanComplianceReport.java428
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateView.java238
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ITraceParser.java56
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ITraceUnitResourceLocator.java50
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityJob.java488
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/TraceUnitExtensionManager.java384
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/TraceabilityExtractor.java278
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/action/FindTraceUnitActionDelegate.java134
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/blam/RemoveTraceMarksFromTraceUnits.java700
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/blam/TraceReportBlam.java1028
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/blam/UiToTestBlam.java460
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/BaseTraceDataCache.java156
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/CodeUnitData.java110
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/RequirementData.java200
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TestUnitData.java280
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TraceMark.java152
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TraceUnit.java136
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/jobs/FindTraceUnitJob.java152
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/jobs/ImportTraceUnitsJob.java126
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/FindTraceUnitFromResource.java278
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ITraceUnitProcessor.java58
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ResourceToTraceUnit.java438
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitFromResourceOperation.java244
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitReportProcessor.java144
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitToArtifactProcessor.java784
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/AbstractArtifactRelationReport.java120
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/AbstractReport.java134
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/ArtifactToRelatedArtifact.java156
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/ArtifactTraceCount.java170
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/ArtifactsWithoutRelations.java84
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/IReportDataCollector.java46
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/utility/IResourceHandler.java44
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/utility/IResourceLocator.java56
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/utility/UriResourceContentFinder.java386
47 files changed, 5877 insertions, 5877 deletions
diff --git a/plugins/org.eclipse.osee.define/.classpath b/plugins/org.eclipse.osee.define/.classpath
index 8a8f1668cd..ad32c83a78 100644
--- a/plugins/org.eclipse.osee.define/.classpath
+++ b/plugins/org.eclipse.osee.define/.classpath
@@ -1,7 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.osee.define/.project b/plugins/org.eclipse.osee.define/.project
index 1065e3d6fd..f4ea46e3fd 100644
--- a/plugins/org.eclipse.osee.define/.project
+++ b/plugins/org.eclipse.osee.define/.project
@@ -1,28 +1,28 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.osee.define</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.define</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.osee.define/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.define/META-INF/MANIFEST.MF
index af2c59e0f2..7df0efb2f7 100644
--- a/plugins/org.eclipse.osee.define/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.define/META-INF/MANIFEST.MF
@@ -1,85 +1,85 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: OSEE Define Plug-in (Incubation)
-Bundle-SymbolicName: org.eclipse.osee.define;singleton:=true
-Bundle-Version: 0.9.5.qualifier
-Bundle-Activator: org.eclipse.osee.define.DefinePlugin
-Bundle-Vendor: Eclipse Open System Engineering Environment
-Export-Package: org.eclipse.osee.define,
- org.eclipse.osee.define.artifact,
- org.eclipse.osee.define.blam.operation,
- org.eclipse.osee.define.errorhandler,
- org.eclipse.osee.define.navigate,
- org.eclipse.osee.define.relation,
- org.eclipse.osee.define.relation.Import,
- org.eclipse.osee.define.traceability,
- org.eclipse.osee.define.traceability.action,
- org.eclipse.osee.define.traceability.blam,
- org.eclipse.osee.define.traceability.data,
- org.eclipse.osee.define.traceability.importer,
- org.eclipse.osee.define.traceability.jobs,
- org.eclipse.osee.define.traceability.operations,
- org.eclipse.osee.define.traceability.report,
- org.eclipse.osee.define.utility
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.core.resources,
- org.eclipse.core.filesystem,
- org.eclipse.osee.framework.jdk.core,
- org.eclipse.ui.ide,
- org.eclipse.search,
- org.eclipse.osee.framework.plugin.core,
- org.eclipse.osee.framework.ui.plugin,
- org.eclipse.osee.framework.database,
- org.eclipse.ui.forms,
- org.eclipse.osee.framework.messaging.event.skynet,
- org.eclipse.osee.framework.jini,
- org.eclipse.nebula.widgets.xviewer,
- org.eclipse.osee.define.help.ui
-Bundle-ActivationPolicy: lazy
-Import-Package: org.apache.commons.lang;version="2.4.0",
- org.eclipse.osee.framework.core.client,
- org.eclipse.osee.framework.core.data,
- org.eclipse.osee.framework.core.enums,
- org.eclipse.osee.framework.core.exception,
- org.eclipse.osee.framework.core.model,
- org.eclipse.osee.framework.core.model.type,
- org.eclipse.osee.framework.logging,
- org.eclipse.osee.framework.skynet.core,
- org.eclipse.osee.framework.access,
- org.eclipse.osee.framework.skynet.core.artifact,
- org.eclipse.osee.framework.skynet.core.artifact.search,
- org.eclipse.osee.framework.skynet.core.attribute,
- org.eclipse.osee.framework.skynet.core.change,
- org.eclipse.osee.framework.skynet.core.importing,
- org.eclipse.osee.framework.skynet.core.linking,
- org.eclipse.osee.framework.skynet.core.relation,
- org.eclipse.osee.framework.skynet.core.relation.order,
- org.eclipse.osee.framework.skynet.core.transaction,
- org.eclipse.osee.framework.skynet.core.types,
- org.eclipse.osee.framework.skynet.core.utility,
- org.eclipse.osee.framework.skynet.core.word,
- org.eclipse.osee.framework.ui.skynet,
- org.eclipse.osee.framework.ui.skynet.action,
- org.eclipse.osee.framework.ui.skynet.artifact,
- org.eclipse.osee.framework.ui.skynet.artifact.editor,
- org.eclipse.osee.framework.ui.skynet.ats,
- org.eclipse.osee.framework.ui.skynet.blam,
- org.eclipse.osee.framework.ui.skynet.branch,
- org.eclipse.osee.framework.ui.skynet.commandHandlers,
- org.eclipse.osee.framework.ui.skynet.render,
- org.eclipse.osee.framework.ui.skynet.results,
- org.eclipse.osee.framework.ui.skynet.results.html,
- org.eclipse.osee.framework.ui.skynet.results.table,
- org.eclipse.osee.framework.ui.skynet.search,
- org.eclipse.osee.framework.ui.skynet.skywalker,
- org.eclipse.osee.framework.ui.skynet.skywalker.arttype,
- org.eclipse.osee.framework.ui.skynet.templates,
- org.eclipse.osee.framework.ui.skynet.util,
- org.eclipse.osee.framework.ui.skynet.widgets,
- org.eclipse.osee.framework.ui.skynet.widgets.xBranch,
- org.eclipse.osee.framework.ui.skynet.widgets.xHistory,
- org.eclipse.osee.framework.ui.skynet.widgets.xnavigate,
- org.eclipse.osee.framework.ui.swt,
- org.eclipse.osee.framework.ui.ws
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OSEE Define Plug-in (Incubation)
+Bundle-SymbolicName: org.eclipse.osee.define;singleton:=true
+Bundle-Version: 0.9.5.qualifier
+Bundle-Activator: org.eclipse.osee.define.DefinePlugin
+Bundle-Vendor: Eclipse Open System Engineering Environment
+Export-Package: org.eclipse.osee.define,
+ org.eclipse.osee.define.artifact,
+ org.eclipse.osee.define.blam.operation,
+ org.eclipse.osee.define.errorhandler,
+ org.eclipse.osee.define.navigate,
+ org.eclipse.osee.define.relation,
+ org.eclipse.osee.define.relation.Import,
+ org.eclipse.osee.define.traceability,
+ org.eclipse.osee.define.traceability.action,
+ org.eclipse.osee.define.traceability.blam,
+ org.eclipse.osee.define.traceability.data,
+ org.eclipse.osee.define.traceability.importer,
+ org.eclipse.osee.define.traceability.jobs,
+ org.eclipse.osee.define.traceability.operations,
+ org.eclipse.osee.define.traceability.report,
+ org.eclipse.osee.define.utility
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.core.filesystem,
+ org.eclipse.osee.framework.jdk.core,
+ org.eclipse.ui.ide,
+ org.eclipse.search,
+ org.eclipse.osee.framework.plugin.core,
+ org.eclipse.osee.framework.ui.plugin,
+ org.eclipse.osee.framework.database,
+ org.eclipse.ui.forms,
+ org.eclipse.osee.framework.messaging.event.skynet,
+ org.eclipse.osee.framework.jini,
+ org.eclipse.nebula.widgets.xviewer,
+ org.eclipse.osee.define.help.ui
+Bundle-ActivationPolicy: lazy
+Import-Package: org.apache.commons.lang;version="2.4.0",
+ org.eclipse.osee.framework.core.client,
+ org.eclipse.osee.framework.core.data,
+ org.eclipse.osee.framework.core.enums,
+ org.eclipse.osee.framework.core.exception,
+ org.eclipse.osee.framework.core.model,
+ org.eclipse.osee.framework.core.model.type,
+ org.eclipse.osee.framework.logging,
+ org.eclipse.osee.framework.skynet.core,
+ org.eclipse.osee.framework.access,
+ org.eclipse.osee.framework.skynet.core.artifact,
+ org.eclipse.osee.framework.skynet.core.artifact.search,
+ org.eclipse.osee.framework.skynet.core.attribute,
+ org.eclipse.osee.framework.skynet.core.change,
+ org.eclipse.osee.framework.skynet.core.importing,
+ org.eclipse.osee.framework.skynet.core.linking,
+ org.eclipse.osee.framework.skynet.core.relation,
+ org.eclipse.osee.framework.skynet.core.relation.order,
+ org.eclipse.osee.framework.skynet.core.transaction,
+ org.eclipse.osee.framework.skynet.core.types,
+ org.eclipse.osee.framework.skynet.core.utility,
+ org.eclipse.osee.framework.skynet.core.word,
+ org.eclipse.osee.framework.ui.skynet,
+ org.eclipse.osee.framework.ui.skynet.action,
+ org.eclipse.osee.framework.ui.skynet.artifact,
+ org.eclipse.osee.framework.ui.skynet.artifact.editor,
+ org.eclipse.osee.framework.ui.skynet.ats,
+ org.eclipse.osee.framework.ui.skynet.blam,
+ org.eclipse.osee.framework.ui.skynet.branch,
+ org.eclipse.osee.framework.ui.skynet.commandHandlers,
+ org.eclipse.osee.framework.ui.skynet.render,
+ org.eclipse.osee.framework.ui.skynet.results,
+ org.eclipse.osee.framework.ui.skynet.results.html,
+ org.eclipse.osee.framework.ui.skynet.results.table,
+ org.eclipse.osee.framework.ui.skynet.search,
+ org.eclipse.osee.framework.ui.skynet.skywalker,
+ org.eclipse.osee.framework.ui.skynet.skywalker.arttype,
+ org.eclipse.osee.framework.ui.skynet.templates,
+ org.eclipse.osee.framework.ui.skynet.util,
+ org.eclipse.osee.framework.ui.skynet.widgets,
+ org.eclipse.osee.framework.ui.skynet.widgets.xBranch,
+ org.eclipse.osee.framework.ui.skynet.widgets.xHistory,
+ org.eclipse.osee.framework.ui.skynet.widgets.xnavigate,
+ org.eclipse.osee.framework.ui.swt,
+ org.eclipse.osee.framework.ui.ws
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/plugins/org.eclipse.osee.define/plugin.xml b/plugins/org.eclipse.osee.define/plugin.xml
index ec74352a1d..cba9a41f0a 100644
--- a/plugins/org.eclipse.osee.define/plugin.xml
+++ b/plugins/org.eclipse.osee.define/plugin.xml
@@ -1,205 +1,205 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin>
- <extension-point id="DefineNavigateItem" name="DefineNavigateItem" schema="schema/DefineNavigateItem.exsd"/>
- <extension-point id="TraceUnitHandler" name="TraceUnitHandler" schema="schema/TraceUnitHandler.exsd"/>
- <extension
- point="org.eclipse.ui.importWizards">
- <category
- id="org.eclipse.osee.define.import.category"
- name="OSEE">
- </category>
- <wizard
- category="org.eclipse.osee.define.import.category"
- class="org.eclipse.osee.define.traceability.ImportTraceabilityWizard"
- icon="images/relate.gif"
- id="osee.define.traceability.ImportTraceabilityWizard"
- name="Traceability into OSEE">
- <description>
- Import Skynet relations.
- </description>
- </wizard>
- </extension>
- <extension
- point="org.eclipse.ui.importWizards">
- <category
- id="org.eclipse.osee.define.import.category"
- name="OSEE">
- </category>
- <wizard
- category="org.eclipse.osee.define.import.category"
- class="org.eclipse.osee.define.traceability.importer.ImportTraceUnitWizard"
- icon="images/importTrace.gif"
- id="ImportTraceUnitsWizard"
- name="Trace Units Into OSEE">
- <description>
- Imports trace units into OSEE and updates relations.
- </description>
- </wizard>
- </extension>
-
- <extension
- point="org.eclipse.ui.perspectives">
- <perspective
- class="org.eclipse.osee.define.DefinePerspectiveFactory"
- fixed="false"
- icon="images/laser_16_16.gif"
- id="osee.define.PerspectiveFactory"
- name="Define"/>
- </extension>
- <extension
- point="org.eclipse.ui.perspectiveExtensions">
- <perspectiveExtension targetID="org.eclipse.ui.resourcePerspective">
- <perspectiveShortcut id="osee.define.PerspectiveFactory"/>
- </perspectiveExtension>
- <perspectiveExtension targetID="org.eclipse.osee.ats.ATSPerspective">
- <perspectiveShortcut id="osee.define.PerspectiveFactory"/>
- </perspectiveExtension>
- <perspectiveExtension targetID="org.eclipse.jdt.ui.JavaPerspective">
- <perspectiveShortcut id="osee.define.PerspectiveFactory"/>
- </perspectiveExtension>
- <perspectiveExtension targetID="osee.define.PerspectiveFactory">
- <perspectiveShortcut id="org.eclipse.jdt.ui.JavaPerspective"/>
- <perspectiveShortcut id="org.eclipse.ui.resourcePerspective"/>
- <perspectiveShortcut id="org.eclipse.osee.ats.ATSPerspective"/>
- <perspectiveShortcut id="org.eclipse.osee.coverage.CoveragePerspective"/>
- </perspectiveExtension>
- </extension>
- <extension
- id="org.eclipse.osee.ats"
- name="OSEE"
- point="org.eclipse.ui.views">
- <view
- allowMultiple="false"
- category="osee.jdk.core.category"
- class="org.eclipse.osee.define.navigate.DefineNavigateView"
- icon="images/defineNav.gif"
- id="org.eclipse.osee.define.DefineNavigateView"
- name="Define Navigator"/>
- </extension>
- <extension
- point="org.eclipse.osee.framework.ui.skynet.IgnorePublishAttribute">
- <attribute
- name="Word Ole Data">
- </attribute>
- </extension>
- <extension
- point="org.eclipse.osee.framework.ui.skynet.ArtifactRendererTemplate">
- <Template
- presentationType="ALL"
- templateFile="support/Work_Instruction_Template.xml"
- templateName="Work Instruction">
- </Template>
- </extension>
- <extension
- id="PublishSubsystemToDesignTraceability"
- name="Publish Subsystem To Design Traceability"
- point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
- <Operation
- className="org.eclipse.osee.define.blam.operation.PublishSubsystemToDesignTraceability">
- </Operation>
- </extension>
- <extension
- id="SubsystemToLowLevelReqTraceReport"
- name="SubsystemToLowLevelReqTraceReport"
- point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
- <Operation
- className="org.eclipse.osee.define.blam.operation.SubsystemToLowLevelReqTraceReport">
- </Operation>
- </extension>
- <extension
- point="org.eclipse.ui.popupMenus">
- <viewerContribution
- id="traceFind"
- targetID="#CompilationUnitEditorContext">
- <action
- class="org.eclipse.osee.define.traceability.action.FindTraceUnitEditorAction"
- icon="images/artifact_search.gif"
- id="org.eclipse.osee.define.action.FindTraceUnitFromResource"
- label="Find Trace Unit Artifact"
- menubarPath="org.eclipse.jdt.ui.source.menu"
- tooltip="Searches for trace units in OSEE">
- </action>
- </viewerContribution>
- <objectContribution
- adaptable="true"
- id="osee.database.projectContribution"
- objectClass="org.eclipse.core.resources.IResource">
- <action
- class="org.eclipse.osee.define.traceability.action.FindTraceUnitActionDelegate"
- icon="images/artifact_search.gif"
- id="org.eclipse.osee.define.action.FindTraceUnitFromResource2"
- label="Find Trace Unit Artifact"
- menubarPath="org.eclipse.osee.main/main"
- state="true"
- style="push"
- tooltip="Searches for trace units in OSEE">
- </action>
- </objectContribution>
- </extension>
- <extension
- id="UiToTestBlam"
- name="UiToTestBlam"
- point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
- <Operation
- className="org.eclipse.osee.define.traceability.blam.UiToTestBlam">
- </Operation>
- </extension>
- <extension
- id="TraceReport"
- name="TraceReport"
- point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
- <Operation
- className="org.eclipse.osee.define.traceability.blam.TraceReportBlam">
- </Operation>
- </extension>
- <extension
- id="PublishWithSpecifiedTemplate"
- name="Publish With Specified Template"
- point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
- <Operation
- className="org.eclipse.osee.define.blam.operation.PublishWithSpecifiedTemplate">
- </Operation>
- </extension>
- <extension
- id="PublishRequirements"
- name="PublishRequirements"
- point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
- <Operation
- className="org.eclipse.osee.define.blam.operation.PublishRequirements">
- </Operation>
- </extension>
- <extension
- id="RemoveTraceMarksFromTraceUnits"
- name="RemoveTraceMarksFromTraceUnits"
- point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
- <Operation
- className="org.eclipse.osee.define.traceability.blam.RemoveTraceMarksFromTraceUnits">
- </Operation>
- </extension>
- <extension
- point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
- <Operation
- className="org.eclipse.osee.define.blam.operation.SubsystemRequirementVerificationLevel">
- </Operation>
- </extension>
- <extension
- point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
- <Operation
- className="org.eclipse.osee.define.blam.operation.TestPlanComplianceReport">
- </Operation>
- </extension>
- <extension
- point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
- <Operation
- className="org.eclipse.osee.define.blam.operation.RequirementsTestReport">
- </Operation>
- </extension>
- <extension
- point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
- <Operation
- className="org.eclipse.osee.define.blam.operation.RequirementReorderOperation">
- </Operation>
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+ <extension-point id="DefineNavigateItem" name="DefineNavigateItem" schema="schema/DefineNavigateItem.exsd"/>
+ <extension-point id="TraceUnitHandler" name="TraceUnitHandler" schema="schema/TraceUnitHandler.exsd"/>
+ <extension
+ point="org.eclipse.ui.importWizards">
+ <category
+ id="org.eclipse.osee.define.import.category"
+ name="OSEE">
+ </category>
+ <wizard
+ category="org.eclipse.osee.define.import.category"
+ class="org.eclipse.osee.define.traceability.ImportTraceabilityWizard"
+ icon="images/relate.gif"
+ id="osee.define.traceability.ImportTraceabilityWizard"
+ name="Traceability into OSEE">
+ <description>
+ Import Skynet relations.
+ </description>
+ </wizard>
+ </extension>
+ <extension
+ point="org.eclipse.ui.importWizards">
+ <category
+ id="org.eclipse.osee.define.import.category"
+ name="OSEE">
+ </category>
+ <wizard
+ category="org.eclipse.osee.define.import.category"
+ class="org.eclipse.osee.define.traceability.importer.ImportTraceUnitWizard"
+ icon="images/importTrace.gif"
+ id="ImportTraceUnitsWizard"
+ name="Trace Units Into OSEE">
+ <description>
+ Imports trace units into OSEE and updates relations.
+ </description>
+ </wizard>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.perspectives">
+ <perspective
+ class="org.eclipse.osee.define.DefinePerspectiveFactory"
+ fixed="false"
+ icon="images/laser_16_16.gif"
+ id="osee.define.PerspectiveFactory"
+ name="Define"/>
+ </extension>
+ <extension
+ point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension targetID="org.eclipse.ui.resourcePerspective">
+ <perspectiveShortcut id="osee.define.PerspectiveFactory"/>
+ </perspectiveExtension>
+ <perspectiveExtension targetID="org.eclipse.osee.ats.ATSPerspective">
+ <perspectiveShortcut id="osee.define.PerspectiveFactory"/>
+ </perspectiveExtension>
+ <perspectiveExtension targetID="org.eclipse.jdt.ui.JavaPerspective">
+ <perspectiveShortcut id="osee.define.PerspectiveFactory"/>
+ </perspectiveExtension>
+ <perspectiveExtension targetID="osee.define.PerspectiveFactory">
+ <perspectiveShortcut id="org.eclipse.jdt.ui.JavaPerspective"/>
+ <perspectiveShortcut id="org.eclipse.ui.resourcePerspective"/>
+ <perspectiveShortcut id="org.eclipse.osee.ats.ATSPerspective"/>
+ <perspectiveShortcut id="org.eclipse.osee.coverage.CoveragePerspective"/>
+ </perspectiveExtension>
+ </extension>
+ <extension
+ id="org.eclipse.osee.ats"
+ name="OSEE"
+ point="org.eclipse.ui.views">
+ <view
+ allowMultiple="false"
+ category="osee.jdk.core.category"
+ class="org.eclipse.osee.define.navigate.DefineNavigateView"
+ icon="images/defineNav.gif"
+ id="org.eclipse.osee.define.DefineNavigateView"
+ name="Define Navigator"/>
+ </extension>
+ <extension
+ point="org.eclipse.osee.framework.ui.skynet.IgnorePublishAttribute">
+ <attribute
+ name="Word Ole Data">
+ </attribute>
+ </extension>
+ <extension
+ point="org.eclipse.osee.framework.ui.skynet.ArtifactRendererTemplate">
+ <Template
+ presentationType="ALL"
+ templateFile="support/Work_Instruction_Template.xml"
+ templateName="Work Instruction">
+ </Template>
+ </extension>
+ <extension
+ id="PublishSubsystemToDesignTraceability"
+ name="Publish Subsystem To Design Traceability"
+ point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
+ <Operation
+ className="org.eclipse.osee.define.blam.operation.PublishSubsystemToDesignTraceability">
+ </Operation>
+ </extension>
+ <extension
+ id="SubsystemToLowLevelReqTraceReport"
+ name="SubsystemToLowLevelReqTraceReport"
+ point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
+ <Operation
+ className="org.eclipse.osee.define.blam.operation.SubsystemToLowLevelReqTraceReport">
+ </Operation>
+ </extension>
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <viewerContribution
+ id="traceFind"
+ targetID="#CompilationUnitEditorContext">
+ <action
+ class="org.eclipse.osee.define.traceability.action.FindTraceUnitEditorAction"
+ icon="images/artifact_search.gif"
+ id="org.eclipse.osee.define.action.FindTraceUnitFromResource"
+ label="Find Trace Unit Artifact"
+ menubarPath="org.eclipse.jdt.ui.source.menu"
+ tooltip="Searches for trace units in OSEE">
+ </action>
+ </viewerContribution>
+ <objectContribution
+ adaptable="true"
+ id="osee.database.projectContribution"
+ objectClass="org.eclipse.core.resources.IResource">
+ <action
+ class="org.eclipse.osee.define.traceability.action.FindTraceUnitActionDelegate"
+ icon="images/artifact_search.gif"
+ id="org.eclipse.osee.define.action.FindTraceUnitFromResource2"
+ label="Find Trace Unit Artifact"
+ menubarPath="org.eclipse.osee.main/main"
+ state="true"
+ style="push"
+ tooltip="Searches for trace units in OSEE">
+ </action>
+ </objectContribution>
+ </extension>
+ <extension
+ id="UiToTestBlam"
+ name="UiToTestBlam"
+ point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
+ <Operation
+ className="org.eclipse.osee.define.traceability.blam.UiToTestBlam">
+ </Operation>
+ </extension>
+ <extension
+ id="TraceReport"
+ name="TraceReport"
+ point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
+ <Operation
+ className="org.eclipse.osee.define.traceability.blam.TraceReportBlam">
+ </Operation>
+ </extension>
+ <extension
+ id="PublishWithSpecifiedTemplate"
+ name="Publish With Specified Template"
+ point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
+ <Operation
+ className="org.eclipse.osee.define.blam.operation.PublishWithSpecifiedTemplate">
+ </Operation>
+ </extension>
+ <extension
+ id="PublishRequirements"
+ name="PublishRequirements"
+ point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
+ <Operation
+ className="org.eclipse.osee.define.blam.operation.PublishRequirements">
+ </Operation>
+ </extension>
+ <extension
+ id="RemoveTraceMarksFromTraceUnits"
+ name="RemoveTraceMarksFromTraceUnits"
+ point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
+ <Operation
+ className="org.eclipse.osee.define.traceability.blam.RemoveTraceMarksFromTraceUnits">
+ </Operation>
+ </extension>
+ <extension
+ point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
+ <Operation
+ className="org.eclipse.osee.define.blam.operation.SubsystemRequirementVerificationLevel">
+ </Operation>
+ </extension>
+ <extension
+ point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
+ <Operation
+ className="org.eclipse.osee.define.blam.operation.TestPlanComplianceReport">
+ </Operation>
+ </extension>
+ <extension
+ point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
+ <Operation
+ className="org.eclipse.osee.define.blam.operation.RequirementsTestReport">
+ </Operation>
+ </extension>
+ <extension
+ point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
+ <Operation
+ className="org.eclipse.osee.define.blam.operation.RequirementReorderOperation">
+ </Operation>
+ </extension>
+
+</plugin>
diff --git a/plugins/org.eclipse.osee.define/reference/define_navigator_view.html b/plugins/org.eclipse.osee.define/reference/define_navigator_view.html
index 58cbb3e251..1699825e27 100644
--- a/plugins/org.eclipse.osee.define/reference/define_navigator_view.html
+++ b/plugins/org.eclipse.osee.define/reference/define_navigator_view.html
@@ -1,27 +1,27 @@
-<html>
-<!--
- Copyright (c) 2004, 2007 Boeing.
- All rights reserved. This program and the accompanying materials
- are made available under the terms of the Eclipse Public License v1.0
- which accompanies this distribution, and is available at
- http://www.eclipse.org/legal/epl-v10.html
- Contributors:
- Boeing - initial API and implementation
--->
- <head>
- <title>Define Navigator</title>
- <LINK rel="stylesheet" type="text/css" href="../../osee.help/html/style.css">
- </head>
-
- <body>
- <h1>Define Navigator</h1>
- <h2>Purpose</h2>
- Central location to launch frequently used define operations.
- <h2>How to do it</h2>
- Double-click any navigation item to kickoff the corresponding operation.
- <h2>Filter</h2>
- Filter out all navigation items that conains the entered text.
- Select the clear action (<img src="../images/clear.gif"/>) to clear out the text
- and restore all navigation items.
-</body>
+<html>
+<!--
+ Copyright (c) 2004, 2007 Boeing.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+ Contributors:
+ Boeing - initial API and implementation
+-->
+ <head>
+ <title>Define Navigator</title>
+ <LINK rel="stylesheet" type="text/css" href="../../osee.help/html/style.css">
+ </head>
+
+ <body>
+ <h1>Define Navigator</h1>
+ <h2>Purpose</h2>
+ Central location to launch frequently used define operations.
+ <h2>How to do it</h2>
+ Double-click any navigation item to kickoff the corresponding operation.
+ <h2>Filter</h2>
+ Filter out all navigation items that conains the entered text.
+ Select the clear action (<img src="../images/clear.gif"/>) to clear out the text
+ and restore all navigation items.
+</body>
</html> \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/DefinePerspectiveFactory.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/DefinePerspectiveFactory.java
index 08aaeba4ea..50ec5b9073 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/DefinePerspectiveFactory.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/DefinePerspectiveFactory.java
@@ -1,54 +1,54 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define;
-
-import org.eclipse.osee.define.navigate.DefineNavigateView;
-import org.eclipse.osee.framework.ui.skynet.ArtifactExplorer;
-import org.eclipse.osee.framework.ui.skynet.search.QuickSearchView;
-import org.eclipse.osee.framework.ui.skynet.skywalker.arttype.ArtifactTypeWalker;
-import org.eclipse.osee.framework.ui.skynet.widgets.xBranch.BranchView;
-import org.eclipse.osee.framework.ui.skynet.widgets.xHistory.HistoryView;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-
-/**
- * Perspective factory for the Define perspective. This sets up the initial layout and place holders for views.
- *
- * @author Robert A. Fisher
- */
-public class DefinePerspectiveFactory implements IPerspectiveFactory {
-
- @Override
- public void createInitialLayout(IPageLayout layout) {
- String editorArea = layout.getEditorArea();
-
- layout.addShowViewShortcut(ArtifactExplorer.VIEW_ID);
- layout.addShowViewShortcut(BranchView.VIEW_ID);
- layout.addShowViewShortcut(QuickSearchView.VIEW_ID);
- layout.addShowViewShortcut(DefineNavigateView.VIEW_ID);
- layout.addShowViewShortcut(ArtifactTypeWalker.VIEW_ID);
- layout.addShowViewShortcut("org.eclipse.pde.runtime.LogView");
-
- IFolderLayout topLeft = layout.createFolder("topLeft", IPageLayout.LEFT, 0.25f, editorArea);
- topLeft.addPlaceholder(ArtifactExplorer.VIEW_ID + ":*");
- topLeft.addView(ArtifactExplorer.VIEW_ID);
- topLeft.addView(DefineNavigateView.VIEW_ID);
-
- IFolderLayout lower = layout.createFolder("bottom", IPageLayout.BOTTOM, 0.65f, editorArea);
- lower.addView(BranchView.VIEW_ID);
- lower.addPlaceholder(HistoryView.VIEW_ID);
- lower.addPlaceholder(NewSearchUI.SEARCH_VIEW_ID);
- lower.addPlaceholder("org.eclipse.pde.runtime.LogView");
- lower.addView(QuickSearchView.VIEW_ID);
- }
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define;
+
+import org.eclipse.osee.define.navigate.DefineNavigateView;
+import org.eclipse.osee.framework.ui.skynet.ArtifactExplorer;
+import org.eclipse.osee.framework.ui.skynet.search.QuickSearchView;
+import org.eclipse.osee.framework.ui.skynet.skywalker.arttype.ArtifactTypeWalker;
+import org.eclipse.osee.framework.ui.skynet.widgets.xBranch.BranchView;
+import org.eclipse.osee.framework.ui.skynet.widgets.xHistory.HistoryView;
+import org.eclipse.search.ui.NewSearchUI;
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+/**
+ * Perspective factory for the Define perspective. This sets up the initial layout and place holders for views.
+ *
+ * @author Robert A. Fisher
+ */
+public class DefinePerspectiveFactory implements IPerspectiveFactory {
+
+ @Override
+ public void createInitialLayout(IPageLayout layout) {
+ String editorArea = layout.getEditorArea();
+
+ layout.addShowViewShortcut(ArtifactExplorer.VIEW_ID);
+ layout.addShowViewShortcut(BranchView.VIEW_ID);
+ layout.addShowViewShortcut(QuickSearchView.VIEW_ID);
+ layout.addShowViewShortcut(DefineNavigateView.VIEW_ID);
+ layout.addShowViewShortcut(ArtifactTypeWalker.VIEW_ID);
+ layout.addShowViewShortcut("org.eclipse.pde.runtime.LogView");
+
+ IFolderLayout topLeft = layout.createFolder("topLeft", IPageLayout.LEFT, 0.25f, editorArea);
+ topLeft.addPlaceholder(ArtifactExplorer.VIEW_ID + ":*");
+ topLeft.addView(ArtifactExplorer.VIEW_ID);
+ topLeft.addView(DefineNavigateView.VIEW_ID);
+
+ IFolderLayout lower = layout.createFolder("bottom", IPageLayout.BOTTOM, 0.65f, editorArea);
+ lower.addView(BranchView.VIEW_ID);
+ lower.addPlaceholder(HistoryView.VIEW_ID);
+ lower.addPlaceholder(NewSearchUI.SEARCH_VIEW_ID);
+ lower.addPlaceholder("org.eclipse.pde.runtime.LogView");
+ lower.addView(QuickSearchView.VIEW_ID);
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishRequirements.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishRequirements.java
index 5a47507731..ddb01908f9 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishRequirements.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishRequirements.java
@@ -1,228 +1,228 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.osee.define.blam.operation;
-
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.osee.define.blam.operation;
+
import static org.eclipse.osee.framework.skynet.core.artifact.DeletionFlag.INCLUDE_DELETED;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.logging.Level;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.define.DefinePlugin;
-import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
-import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
-import org.eclipse.osee.framework.core.exception.OseeArgumentException;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeStateException;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.core.model.TransactionDelta;
-import org.eclipse.osee.framework.core.model.TransactionRecord;
-import org.eclipse.osee.framework.logging.OseeLog;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.ArtifactCache;
-import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.logging.Level;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.define.DefinePlugin;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.exception.OseeArgumentException;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeStateException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.model.TransactionDelta;
+import org.eclipse.osee.framework.core.model.TransactionRecord;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactCache;
+import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
-import org.eclipse.osee.framework.skynet.core.change.ArtifactDelta;
-import org.eclipse.osee.framework.skynet.core.linking.LinkType;
-import org.eclipse.osee.framework.skynet.core.relation.RelationManager;
-import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
-import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager;
+import org.eclipse.osee.framework.skynet.core.change.ArtifactDelta;
+import org.eclipse.osee.framework.skynet.core.linking.LinkType;
+import org.eclipse.osee.framework.skynet.core.relation.RelationManager;
+import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
+import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager;
import org.eclipse.osee.framework.skynet.core.utility.Artifacts;
-import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
-import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
-import org.eclipse.osee.framework.ui.skynet.render.ITemplateRenderer;
+import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
+import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
+import org.eclipse.osee.framework.ui.skynet.render.ITemplateRenderer;
import org.eclipse.osee.framework.ui.skynet.render.PresentationType;
-import org.eclipse.osee.framework.ui.skynet.render.RendererManager;
-import org.eclipse.osee.framework.ui.skynet.render.WordTemplateRenderer;
-
-/**
- * @author Jeff C. Phillips
- * @author Theron Virgin
- */
-public class PublishRequirements extends AbstractBlam {
- private boolean includeAttributes;
- private boolean publishAsDiff;
- // private boolean removeTrackedChanges;
- private Date date;
- private Branch branch;
- private boolean useBaselineTransaction;
-
- @Override
- public String getName() {
- return "Publish Requirements";
- }
-
- @Override
- public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
- Boolean updateParagraphNumber = variableMap.getBoolean("Update Paragraph Numbers");
- List<Artifact> artifacts = variableMap.getArtifacts("artifacts");
- includeAttributes = variableMap.getBoolean("Publish With Attributes");
- publishAsDiff = variableMap.getBoolean("Publish As Diff");
- useBaselineTransaction = variableMap.getBoolean("Diff from Baseline");
- // removeTrackedChanges = variableMap.getBoolean("Skip Artifacts with Tracked Changes");
- if (variableMap.getValue("Diff Starting Point") instanceof Date) {
- date = (Date) variableMap.getValue("Diff Starting Point");
- }
- branch = variableMap.getBranch("Diff Branch");
-
- boolean useArtifactNameInLinks = variableMap.getBoolean("Use Artifact Names");
- boolean useParagraphNumbersInLinks = variableMap.getBoolean("Use Paragraph Numbers");
-
- if (!useParagraphNumbersInLinks && !useArtifactNameInLinks) {
- throw new OseeArgumentException("Please select at least one Document Link Format");
- }
- LinkType linkType;
- if (useArtifactNameInLinks && useParagraphNumbersInLinks) {
- linkType = LinkType.INTERNAL_DOC_REFERENCE_USE_PARAGRAPH_NUMBER_AND_NAME;
- } else if (useParagraphNumbersInLinks) {
- linkType = LinkType.INTERNAL_DOC_REFERENCE_USE_PARAGRAPH_NUMBER;
- } else {
- linkType = LinkType.INTERNAL_DOC_REFERENCE_USE_NAME;
- }
+import org.eclipse.osee.framework.ui.skynet.render.RendererManager;
+import org.eclipse.osee.framework.ui.skynet.render.WordTemplateRenderer;
+
+/**
+ * @author Jeff C. Phillips
+ * @author Theron Virgin
+ */
+public class PublishRequirements extends AbstractBlam {
+ private boolean includeAttributes;
+ private boolean publishAsDiff;
+ // private boolean removeTrackedChanges;
+ private Date date;
+ private Branch branch;
+ private boolean useBaselineTransaction;
+
+ @Override
+ public String getName() {
+ return "Publish Requirements";
+ }
+
+ @Override
+ public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
+ Boolean updateParagraphNumber = variableMap.getBoolean("Update Paragraph Numbers");
+ List<Artifact> artifacts = variableMap.getArtifacts("artifacts");
+ includeAttributes = variableMap.getBoolean("Publish With Attributes");
+ publishAsDiff = variableMap.getBoolean("Publish As Diff");
+ useBaselineTransaction = variableMap.getBoolean("Diff from Baseline");
+ // removeTrackedChanges = variableMap.getBoolean("Skip Artifacts with Tracked Changes");
+ if (variableMap.getValue("Diff Starting Point") instanceof Date) {
+ date = (Date) variableMap.getValue("Diff Starting Point");
+ }
+ branch = variableMap.getBranch("Diff Branch");
+
+ boolean useArtifactNameInLinks = variableMap.getBoolean("Use Artifact Names");
+ boolean useParagraphNumbersInLinks = variableMap.getBoolean("Use Paragraph Numbers");
+
+ if (!useParagraphNumbersInLinks && !useArtifactNameInLinks) {
+ throw new OseeArgumentException("Please select at least one Document Link Format");
+ }
+ LinkType linkType;
+ if (useArtifactNameInLinks && useParagraphNumbersInLinks) {
+ linkType = LinkType.INTERNAL_DOC_REFERENCE_USE_PARAGRAPH_NUMBER_AND_NAME;
+ } else if (useParagraphNumbersInLinks) {
+ linkType = LinkType.INTERNAL_DOC_REFERENCE_USE_PARAGRAPH_NUMBER;
+ } else {
+ linkType = LinkType.INTERNAL_DOC_REFERENCE_USE_NAME;
+ }
RelationManager.getRelatedArtifacts(artifacts, 999, INCLUDE_DELETED,
CoreRelationTypes.Default_Hierarchical__Child);
-
- SkynetTransaction transaction = new SkynetTransaction(artifacts.get(0).getBranch(), getName());
- String templateOption;
- if (publishAsDiff) {
- templateOption = includeAttributes ? ITemplateRenderer.DIFF_VALUE : ITemplateRenderer.DIFF_NO_ATTRIBUTES_VALUE;
- } else {
- templateOption =
+
+ SkynetTransaction transaction = new SkynetTransaction(artifacts.get(0).getBranch(), getName());
+ String templateOption;
+ if (publishAsDiff) {
+ templateOption = includeAttributes ? ITemplateRenderer.DIFF_VALUE : ITemplateRenderer.DIFF_NO_ATTRIBUTES_VALUE;
+ } else {
+ templateOption =
includeAttributes ? ITemplateRenderer.PREVIEW_WITH_RECURSE_VALUE : ITemplateRenderer.PREVIEW_WITH_RECURSE_NO_ATTRIBUTES_VALUE;
- }
-
- VariableMap options =
+ }
+
+ VariableMap options =
new VariableMap(WordTemplateRenderer.UPDATE_PARAGRAPH_NUMBER_OPTION, updateParagraphNumber,
ITemplateRenderer.TEMPLATE_OPTION, templateOption, ITemplateRenderer.TRANSACTION_OPTION, transaction,
"linkType", linkType, "inPublishMode", true);
-
- if (publishAsDiff) {
- if (branch == null || (date == null && !useBaselineTransaction)) {
- throw new OseeCoreException(
+
+ if (publishAsDiff) {
+ if (branch == null || (date == null && !useBaselineTransaction)) {
+ throw new OseeCoreException(
"Must Select a " + branch == null ? "Branch" : "Date" + " to diff against when publishing as Diff");
- }
- }
- TransactionDelta txDelta = createTransactionDelta(branch);
-
- for (Artifact artifact : artifacts) {
- try {
- publish(monitor, artifact, options, txDelta);
- } catch (OseeStateException ex) {
- OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
- }
- }
- transaction.execute();
- }
-
- private TransactionDelta createTransactionDelta(Branch branch) throws OseeCoreException {
- TransactionRecord startTx;
- if (publishAsDiff && date != null && !useBaselineTransaction) {
- startTx = TransactionManager.getTransactionAtDate(branch, date);
- } else {
- startTx = branch.getBaseTransaction();
- }
- return new TransactionDelta(startTx, TransactionManager.getHeadTransaction(branch));
- }
-
- private void publish(IProgressMonitor monitor, Artifact artifact, VariableMap options, TransactionDelta txDelta) throws OseeCoreException {
- if (monitor.isCanceled()) {
- return;
- }
-
- List<Artifact> nonFolderChildren = new ArrayList<Artifact>();
- if (artifact.isOfType(CoreArtifactTypes.Folder)) {
- for (Artifact child : artifact.getChildren(publishAsDiff)) {
- if (child.isOfType(CoreArtifactTypes.Folder)) {
- publish(monitor, child, options, txDelta);
- } else {
- nonFolderChildren.add(child);
- }
- }
- } else {
- nonFolderChildren.add(artifact);
- }
-
- if (publishAsDiff) {
- nonFolderChildren = artifact.getDescendants();
- ArrayList<Artifact> olderArtifacts =
+ }
+ }
+ TransactionDelta txDelta = createTransactionDelta(branch);
+
+ for (Artifact artifact : artifacts) {
+ try {
+ publish(monitor, artifact, options, txDelta);
+ } catch (OseeStateException ex) {
+ OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
+ }
+ }
+ transaction.execute();
+ }
+
+ private TransactionDelta createTransactionDelta(Branch branch) throws OseeCoreException {
+ TransactionRecord startTx;
+ if (publishAsDiff && date != null && !useBaselineTransaction) {
+ startTx = TransactionManager.getTransactionAtDate(branch, date);
+ } else {
+ startTx = branch.getBaseTransaction();
+ }
+ return new TransactionDelta(startTx, TransactionManager.getHeadTransaction(branch));
+ }
+
+ private void publish(IProgressMonitor monitor, Artifact artifact, VariableMap options, TransactionDelta txDelta) throws OseeCoreException {
+ if (monitor.isCanceled()) {
+ return;
+ }
+
+ List<Artifact> nonFolderChildren = new ArrayList<Artifact>();
+ if (artifact.isOfType(CoreArtifactTypes.Folder)) {
+ for (Artifact child : artifact.getChildren(publishAsDiff)) {
+ if (child.isOfType(CoreArtifactTypes.Folder)) {
+ publish(monitor, child, options, txDelta);
+ } else {
+ nonFolderChildren.add(child);
+ }
+ }
+ } else {
+ nonFolderChildren.add(artifact);
+ }
+
+ if (publishAsDiff) {
+ nonFolderChildren = artifact.getDescendants();
+ ArrayList<Artifact> olderArtifacts =
getOlderArtifacts(nonFolderChildren, txDelta.getStartTx().getId(), branch.getId());
-
- Collection<ArtifactDelta> compareItems = new ArrayList<ArtifactDelta>();
- for (int index = 0; index < olderArtifacts.size() && index < nonFolderChildren.size(); index++) {
- Artifact base = olderArtifacts.get(index);
- Artifact newer = nonFolderChildren.get(index);
- if (isDeleted(base)) {
- base = null;
- }
- if (isDeleted(newer)) {
- newer = null;
- }
- compareItems.add(new ArtifactDelta(txDelta, base, newer));
- }
- RendererManager.diffInJob(compareItems, options);
- } else {
+
+ Collection<ArtifactDelta> compareItems = new ArrayList<ArtifactDelta>();
+ for (int index = 0; index < olderArtifacts.size() && index < nonFolderChildren.size(); index++) {
+ Artifact base = olderArtifacts.get(index);
+ Artifact newer = nonFolderChildren.get(index);
+ if (isDeleted(base)) {
+ base = null;
+ }
+ if (isDeleted(newer)) {
+ newer = null;
+ }
+ compareItems.add(new ArtifactDelta(txDelta, base, newer));
+ }
+ RendererManager.diffInJob(compareItems, options);
+ } else {
RendererManager.open(nonFolderChildren, PresentationType.PREVIEW, options, monitor);
- }
- }
-
- private boolean isDeleted(Artifact artifact) {
- return artifact != null && artifact.isDeleted();
- }
-
- @Override
- public String getDescriptionUsage() {
- return "Drag in parent artifacts below and click the play button at the top right.";
- }
-
- @Override
- public String getXWidgetsXml() {
- StringBuilder builder = new StringBuilder();
- builder.append("<xWidgets>");
- builder.append("<XWidget xwidgetType=\"XCheckBox\" horizontalLabel=\"true\" labelAfter=\"true\" displayName=\"Update Paragraph Numbers\" />");
-
- builder.append("<XWidget xwidgetType=\"XLabel\" displayName=\"Document Link Format:\"/>");
- builder.append("<XWidget xwidgetType=\"XCheckBox\" horizontalLabel=\"true\" labelAfter=\"true\" displayName=\"Use Artifact Names\" />");
- builder.append("<XWidget xwidgetType=\"XCheckBox\" horizontalLabel=\"true\" labelAfter=\"true\" displayName=\"Use Paragraph Numbers\" />");
-
- builder.append("<XWidget xwidgetType=\"XLabel\" displayName=\"Publishing Options:\"/>");
- builder.append("<XWidget xwidgetType=\"XCheckBox\" horizontalLabel=\"true\" labelAfter=\"true\" displayName=\"Publish With Attributes\" />");
- builder.append("<XWidget xwidgetType=\"XCheckBox\" horizontalLabel=\"true\" labelAfter=\"true\" displayName=\"Publish As Diff\" />");
- builder.append("<XWidget xwidgetType=\"XLabel\" displayName=\" \" /><XWidget xwidgetType=\"XLabel\" displayName=\"Diff Options:\" />");
- builder.append("<XWidget xwidgetType=\"XCheckBox\" horizontalLabel=\"true\" labelAfter=\"true\" displayName=\"Diff from Baseline\" />");
- builder.append("<XWidget xwidgetType=\"XDate\" displayName=\"Diff Starting Point\" />");
- builder.append("<XWidget xwidgetType=\"XBranchSelectWidget\" displayName=\"Diff Branch\" defaultValue=\"" + BranchManager.getLastBranch().getGuid() + "\" />");
- builder.append("<XWidget xwidgetType=\"XListDropViewer\" displayName=\"artifacts\" />");
- builder.append("</xWidgets>");
- return builder.toString();
- }
-
- private ArrayList<Artifact> getOlderArtifacts(List<Artifact> artifacts, int transactionId, int branchId) throws OseeCoreException {
- ArrayList<Artifact> historicArtifacts = new ArrayList<Artifact>(artifacts.size());
+ }
+ }
+
+ private boolean isDeleted(Artifact artifact) {
+ return artifact != null && artifact.isDeleted();
+ }
+
+ @Override
+ public String getDescriptionUsage() {
+ return "Drag in parent artifacts below and click the play button at the top right.";
+ }
+
+ @Override
+ public String getXWidgetsXml() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("<xWidgets>");
+ builder.append("<XWidget xwidgetType=\"XCheckBox\" horizontalLabel=\"true\" labelAfter=\"true\" displayName=\"Update Paragraph Numbers\" />");
+
+ builder.append("<XWidget xwidgetType=\"XLabel\" displayName=\"Document Link Format:\"/>");
+ builder.append("<XWidget xwidgetType=\"XCheckBox\" horizontalLabel=\"true\" labelAfter=\"true\" displayName=\"Use Artifact Names\" />");
+ builder.append("<XWidget xwidgetType=\"XCheckBox\" horizontalLabel=\"true\" labelAfter=\"true\" displayName=\"Use Paragraph Numbers\" />");
+
+ builder.append("<XWidget xwidgetType=\"XLabel\" displayName=\"Publishing Options:\"/>");
+ builder.append("<XWidget xwidgetType=\"XCheckBox\" horizontalLabel=\"true\" labelAfter=\"true\" displayName=\"Publish With Attributes\" />");
+ builder.append("<XWidget xwidgetType=\"XCheckBox\" horizontalLabel=\"true\" labelAfter=\"true\" displayName=\"Publish As Diff\" />");
+ builder.append("<XWidget xwidgetType=\"XLabel\" displayName=\" \" /><XWidget xwidgetType=\"XLabel\" displayName=\"Diff Options:\" />");
+ builder.append("<XWidget xwidgetType=\"XCheckBox\" horizontalLabel=\"true\" labelAfter=\"true\" displayName=\"Diff from Baseline\" />");
+ builder.append("<XWidget xwidgetType=\"XDate\" displayName=\"Diff Starting Point\" />");
+ builder.append("<XWidget xwidgetType=\"XBranchSelectWidget\" displayName=\"Diff Branch\" defaultValue=\"" + BranchManager.getLastBranch().getGuid() + "\" />");
+ builder.append("<XWidget xwidgetType=\"XListDropViewer\" displayName=\"artifacts\" />");
+ builder.append("</xWidgets>");
+ return builder.toString();
+ }
+
+ private ArrayList<Artifact> getOlderArtifacts(List<Artifact> artifacts, int transactionId, int branchId) throws OseeCoreException {
+ ArrayList<Artifact> historicArtifacts = new ArrayList<Artifact>(artifacts.size());
TransactionRecord txRecord = TransactionManager.getTransactionId(transactionId);
-
- @SuppressWarnings("unused")
- Collection<Artifact> bulkLoadedArtifacts =
+
+ @SuppressWarnings("unused")
+ Collection<Artifact> bulkLoadedArtifacts =
ArtifactQuery.getHistoricalArtifactListFromIds(Artifacts.toGuids(artifacts), txRecord, INCLUDE_DELETED);
-
- for (Artifact artifact : artifacts) {
- historicArtifacts.add(ArtifactCache.getHistorical(artifact.getArtId(), transactionId));
- }
- return historicArtifacts;
- }
-
- @Override
- public Collection<String> getCategories() {
- return Arrays.asList("Define.Publish");
- }
+
+ for (Artifact artifact : artifacts) {
+ historicArtifacts.add(ArtifactCache.getHistorical(artifact.getArtId(), transactionId));
+ }
+ return historicArtifacts;
+ }
+
+ @Override
+ public Collection<String> getCategories() {
+ return Arrays.asList("Define.Publish");
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishSubsystemToDesignTraceability.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishSubsystemToDesignTraceability.java
index ad1c19fb6e..c3999e7572 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishSubsystemToDesignTraceability.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishSubsystemToDesignTraceability.java
@@ -1,133 +1,133 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.blam.operation;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
-import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
-import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.jdk.core.util.io.CharBackedInputStream;
-import org.eclipse.osee.framework.jdk.core.util.io.xml.ExcelXmlWriter;
-import org.eclipse.osee.framework.jdk.core.util.io.xml.ISheetWriter;
-import org.eclipse.osee.framework.plugin.core.util.AIFile;
-import org.eclipse.osee.framework.plugin.core.util.OseeData;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
-import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
-import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
-import org.eclipse.swt.program.Program;
-
-/**
- * @author Ryan D. Brooks
- */
-public class PublishSubsystemToDesignTraceability extends AbstractBlam {
- private CharBackedInputStream charBak;
- private ISheetWriter excelWriter;
-
- @Override
- public String getName() {
- return "Publish Subsystem To Design Traceability";
- }
-
- private void init() throws IOException {
- charBak = new CharBackedInputStream();
- excelWriter = new ExcelXmlWriter(charBak.getWriter());
- }
-
- @Override
- public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
- monitor.beginTask(getDescriptionUsage(), 100);
-
- List<Artifact> subsystems = variableMap.getArtifacts("Subsystem Root Artifacts");
- Branch branch = subsystems.get(0).getBranch();
-
- init();
-
- monitor.subTask("Aquiring Design Artifacts"); // bulk load for performance reasons
- ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.SubsystemDesign, branch);
- monitor.worked(10);
-
- monitor.subTask("Aquiring Subsystem Requirements"); // bulk load for performance reasons
- ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.SubsystemRequirement, branch);
- monitor.worked(60);
-
- int workIncrement = 30 / subsystems.size();
- for (Artifact subsystem : subsystems) {
- if (monitor.isCanceled()) {
- return;
- }
- monitor.worked(workIncrement);
- writeSubsystemDesignTraceability(subsystem);
- }
-
- excelWriter.endWorkbook();
- IFile iFile = OseeData.getIFile("SubsystemToDesignTrace_" + Lib.getDateTimeString() + ".xml");
- AIFile.writeToFile(iFile, charBak);
- Program.launch(iFile.getLocation().toOSString());
- }
-
- private void writeSubsystemDesignTraceability(Artifact subsystem) throws IOException, OseeCoreException {
- excelWriter.startSheet(subsystem.getName(), 200);
- excelWriter.writeRow(subsystem.getName() + " Subsystem To Design Traceability");
-
- excelWriter.writeRow("Subsystem Requirement", null, "Subsystem Design");
- excelWriter.writeRow("Paragraph Number", "Paragraph Title", "Paragraph Number", "Paragraph Title");
-
- for (Artifact subsystemRequirement : subsystem.getDescendants()) {
- excelWriter.writeCell(subsystemRequirement.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER, ""));
- excelWriter.writeCell(subsystemRequirement.getName());
-
- if (subsystemRequirement.isOfType(CoreArtifactTypes.SubsystemRequirement)) {
- boolean loopNeverRan = true;
- for (Artifact subsystemDesign : subsystemRequirement.getRelatedArtifacts(CoreRelationTypes.Design__Design)) {
- if (subsystemDesign.isOfType(CoreArtifactTypes.SubsystemDesign)) {
- loopNeverRan = false;
- excelWriter.writeCell(subsystemDesign.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER, ""),
- 2);
- excelWriter.writeCell(subsystemDesign.getName(), 3);
- excelWriter.endRow();
- }
- }
- if (loopNeverRan) {
- excelWriter.endRow();
- }
- } else {
- excelWriter.writeCell("N/A - " + subsystemRequirement.getArtifactTypeName());
- excelWriter.endRow();
- }
- }
-
- excelWriter.endSheet();
- }
-
- @Override
- public String getDescriptionUsage() {
- return "Publish Subsystem To Design Traceability Tables";
- }
-
- @Override
- public String getXWidgetsXml() {
- return "<xWidgets><XWidget xwidgetType=\"XListDropViewer\" displayName=\"Subsystem Root Artifacts\" /></xWidgets>";
- }
-
- @Override
- public Collection<String> getCategories() {
- return Arrays.asList("Define.Publish");
- }
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.blam.operation;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.jdk.core.util.io.CharBackedInputStream;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.ExcelXmlWriter;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.ISheetWriter;
+import org.eclipse.osee.framework.plugin.core.util.AIFile;
+import org.eclipse.osee.framework.plugin.core.util.OseeData;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
+import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
+import org.eclipse.swt.program.Program;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class PublishSubsystemToDesignTraceability extends AbstractBlam {
+ private CharBackedInputStream charBak;
+ private ISheetWriter excelWriter;
+
+ @Override
+ public String getName() {
+ return "Publish Subsystem To Design Traceability";
+ }
+
+ private void init() throws IOException {
+ charBak = new CharBackedInputStream();
+ excelWriter = new ExcelXmlWriter(charBak.getWriter());
+ }
+
+ @Override
+ public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
+ monitor.beginTask(getDescriptionUsage(), 100);
+
+ List<Artifact> subsystems = variableMap.getArtifacts("Subsystem Root Artifacts");
+ Branch branch = subsystems.get(0).getBranch();
+
+ init();
+
+ monitor.subTask("Aquiring Design Artifacts"); // bulk load for performance reasons
+ ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.SubsystemDesign, branch);
+ monitor.worked(10);
+
+ monitor.subTask("Aquiring Subsystem Requirements"); // bulk load for performance reasons
+ ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.SubsystemRequirement, branch);
+ monitor.worked(60);
+
+ int workIncrement = 30 / subsystems.size();
+ for (Artifact subsystem : subsystems) {
+ if (monitor.isCanceled()) {
+ return;
+ }
+ monitor.worked(workIncrement);
+ writeSubsystemDesignTraceability(subsystem);
+ }
+
+ excelWriter.endWorkbook();
+ IFile iFile = OseeData.getIFile("SubsystemToDesignTrace_" + Lib.getDateTimeString() + ".xml");
+ AIFile.writeToFile(iFile, charBak);
+ Program.launch(iFile.getLocation().toOSString());
+ }
+
+ private void writeSubsystemDesignTraceability(Artifact subsystem) throws IOException, OseeCoreException {
+ excelWriter.startSheet(subsystem.getName(), 200);
+ excelWriter.writeRow(subsystem.getName() + " Subsystem To Design Traceability");
+
+ excelWriter.writeRow("Subsystem Requirement", null, "Subsystem Design");
+ excelWriter.writeRow("Paragraph Number", "Paragraph Title", "Paragraph Number", "Paragraph Title");
+
+ for (Artifact subsystemRequirement : subsystem.getDescendants()) {
+ excelWriter.writeCell(subsystemRequirement.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER, ""));
+ excelWriter.writeCell(subsystemRequirement.getName());
+
+ if (subsystemRequirement.isOfType(CoreArtifactTypes.SubsystemRequirement)) {
+ boolean loopNeverRan = true;
+ for (Artifact subsystemDesign : subsystemRequirement.getRelatedArtifacts(CoreRelationTypes.Design__Design)) {
+ if (subsystemDesign.isOfType(CoreArtifactTypes.SubsystemDesign)) {
+ loopNeverRan = false;
+ excelWriter.writeCell(subsystemDesign.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER, ""),
+ 2);
+ excelWriter.writeCell(subsystemDesign.getName(), 3);
+ excelWriter.endRow();
+ }
+ }
+ if (loopNeverRan) {
+ excelWriter.endRow();
+ }
+ } else {
+ excelWriter.writeCell("N/A - " + subsystemRequirement.getArtifactTypeName());
+ excelWriter.endRow();
+ }
+ }
+
+ excelWriter.endSheet();
+ }
+
+ @Override
+ public String getDescriptionUsage() {
+ return "Publish Subsystem To Design Traceability Tables";
+ }
+
+ @Override
+ public String getXWidgetsXml() {
+ return "<xWidgets><XWidget xwidgetType=\"XListDropViewer\" displayName=\"Subsystem Root Artifacts\" /></xWidgets>";
+ }
+
+ @Override
+ public Collection<String> getCategories() {
+ return Arrays.asList("Define.Publish");
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishWithSpecifiedTemplate.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishWithSpecifiedTemplate.java
index 7459e3c525..d6c2758f59 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishWithSpecifiedTemplate.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishWithSpecifiedTemplate.java
@@ -1,124 +1,124 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.blam.operation;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
-import org.eclipse.osee.framework.skynet.core.linking.LinkType;
-import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
-import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
-import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
-import org.eclipse.osee.framework.ui.skynet.render.ITemplateRenderer;
-import org.eclipse.osee.framework.ui.skynet.render.WordTemplateRenderer;
-import org.eclipse.osee.framework.ui.skynet.templates.TemplateManager;
-
-/**
- * @author Jeff C. Phillips
- * @author Theron Virgin
- */
-public class PublishWithSpecifiedTemplate extends AbstractBlam {
- private List<Artifact> templates;
-
- @Override
- public String getName() {
- return "Publish With Specified Template";
- }
-
- @Override
- public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
- populateTemplateList();
- Boolean updateParagraphNumber = variableMap.getBoolean("Update Paragraph Numbers");
- Artifact master = getTemplate(variableMap.getString("Master Template"));
- Artifact slave = getTemplate(variableMap.getString("Slave Template"));
- Branch branch = variableMap.getBranch("Branch (If Template specifies Artifacts)");
- List<Artifact> artifacts = variableMap.getArtifacts("Artifacts (If Not Specified in Template)");
- if (artifacts != null && !artifacts.isEmpty()) {
- branch = artifacts.get(0).getBranch();
- }
- if (artifacts != null && artifacts.isEmpty()) {
- artifacts = null;
- }
- VariableMap newVariableMap = new VariableMap();
- newVariableMap.setValue("Branch", branch);
- newVariableMap.setValue("compareBranch", variableMap.getBranch("Compare Against Another Branch"));
- newVariableMap.setValue("Update Paragraph Numbers", updateParagraphNumber);
- newVariableMap.setValue("Publish As Diff", variableMap.getValue("Publish As Diff"));
- // newVariableMap.setValue("Diff from Baseline", variableMap.getValue("Diff from Baseline"));
- newVariableMap.setValue("linkType", LinkType.INTERNAL_DOC_REFERENCE_USE_NAME);
-
- WordTemplateRenderer renderer = new WordTemplateRenderer();
- SkynetTransaction transaction = new SkynetTransaction(branch, "BLAM: Publish with specified template");
-
- renderer.setOptions(new VariableMap(WordTemplateRenderer.UPDATE_PARAGRAPH_NUMBER_OPTION, updateParagraphNumber,
- ITemplateRenderer.TRANSACTION_OPTION, transaction));
- renderer.publish(newVariableMap, master, slave, artifacts);
-
- transaction.execute();
- }
-
- @Override
- public String getDescriptionUsage() {
- return "Select a Master or Master/Slave template and click the play button at the top right.";
- }
-
- @Override
- public String getXWidgetsXml() {
- populateTemplateList();
- StringBuilder builder = new StringBuilder();
- builder.append("<xWidgets><XWidget xwidgetType=\"XCheckBox\" horizontalLabel=\"true\" labelAfter=\"true\" displayName=\"Update Paragraph Numbers\" />");
-
- builder.append("<XWidget xwidgetType=\"XLabel\" displayName=\" \" /><XWidget xwidgetType=\"XCombo(");
- for (Artifact art : templates) {
- builder.append(art.getSafeName());
- builder.append(",");
- }
- builder.append(")\" displayName=\"Master Template\" horizontalLabel=\"true\"/>");
- builder.append("<XWidget xwidgetType=\"XCombo(");
- for (Artifact art : templates) {
- builder.append(art.getSafeName());
- builder.append(",");
- }
-
- builder.append(")\" displayName=\"Slave Template\" horizontalLabel=\"true\"/><XWidget xwidgetType=\"XLabel\" displayName=\" \" />");
- builder.append("<XWidget xwidgetType=\"XBranchSelectWidget\" displayName=\"Branch (If Template specifies Artifacts)\" defaultValue=\"" + BranchManager.getLastBranch().getGuid() + "\" /><XWidget xwidgetType=\"XListDropViewer\" displayName=\"Artifacts (If Not Specified in Template)\" />");
- builder.append("<XWidget xwidgetType=\"XCheckBox\" horizontalLabel=\"true\" labelAfter=\"true\" displayName=\"Publish As Diff\" />");
- // builder.append("<XWidget xwidgetType=\"XCheckBox\" horizontalLabel=\"true\" labelAfter=\"true\" displayName=\"Diff from Baseline\" />");
- builder.append("<XWidget xwidgetType=\"XBranchSelectWidget\" displayName=\"Compare Against Another Branch\"/>");
- builder.append("</xWidgets>");
-
- return builder.toString();
- }
-
- private void populateTemplateList() {
- templates = TemplateManager.getAllTemplates();
- Collections.sort(templates);
- }
-
- private Artifact getTemplate(String templateName) {
- for (Artifact artifact : templates) {
- if (artifact.getSafeName().equals(templateName)) {
- return artifact;
- }
- }
- return null;
- }
-
- @Override
- public Collection<String> getCategories() {
- return Arrays.asList("Define.Publish");
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.blam.operation;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
+import org.eclipse.osee.framework.skynet.core.linking.LinkType;
+import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
+import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
+import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
+import org.eclipse.osee.framework.ui.skynet.render.ITemplateRenderer;
+import org.eclipse.osee.framework.ui.skynet.render.WordTemplateRenderer;
+import org.eclipse.osee.framework.ui.skynet.templates.TemplateManager;
+
+/**
+ * @author Jeff C. Phillips
+ * @author Theron Virgin
+ */
+public class PublishWithSpecifiedTemplate extends AbstractBlam {
+ private List<Artifact> templates;
+
+ @Override
+ public String getName() {
+ return "Publish With Specified Template";
+ }
+
+ @Override
+ public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
+ populateTemplateList();
+ Boolean updateParagraphNumber = variableMap.getBoolean("Update Paragraph Numbers");
+ Artifact master = getTemplate(variableMap.getString("Master Template"));
+ Artifact slave = getTemplate(variableMap.getString("Slave Template"));
+ Branch branch = variableMap.getBranch("Branch (If Template specifies Artifacts)");
+ List<Artifact> artifacts = variableMap.getArtifacts("Artifacts (If Not Specified in Template)");
+ if (artifacts != null && !artifacts.isEmpty()) {
+ branch = artifacts.get(0).getBranch();
+ }
+ if (artifacts != null && artifacts.isEmpty()) {
+ artifacts = null;
+ }
+ VariableMap newVariableMap = new VariableMap();
+ newVariableMap.setValue("Branch", branch);
+ newVariableMap.setValue("compareBranch", variableMap.getBranch("Compare Against Another Branch"));
+ newVariableMap.setValue("Update Paragraph Numbers", updateParagraphNumber);
+ newVariableMap.setValue("Publish As Diff", variableMap.getValue("Publish As Diff"));
+ // newVariableMap.setValue("Diff from Baseline", variableMap.getValue("Diff from Baseline"));
+ newVariableMap.setValue("linkType", LinkType.INTERNAL_DOC_REFERENCE_USE_NAME);
+
+ WordTemplateRenderer renderer = new WordTemplateRenderer();
+ SkynetTransaction transaction = new SkynetTransaction(branch, "BLAM: Publish with specified template");
+
+ renderer.setOptions(new VariableMap(WordTemplateRenderer.UPDATE_PARAGRAPH_NUMBER_OPTION, updateParagraphNumber,
+ ITemplateRenderer.TRANSACTION_OPTION, transaction));
+ renderer.publish(newVariableMap, master, slave, artifacts);
+
+ transaction.execute();
+ }
+
+ @Override
+ public String getDescriptionUsage() {
+ return "Select a Master or Master/Slave template and click the play button at the top right.";
+ }
+
+ @Override
+ public String getXWidgetsXml() {
+ populateTemplateList();
+ StringBuilder builder = new StringBuilder();
+ builder.append("<xWidgets><XWidget xwidgetType=\"XCheckBox\" horizontalLabel=\"true\" labelAfter=\"true\" displayName=\"Update Paragraph Numbers\" />");
+
+ builder.append("<XWidget xwidgetType=\"XLabel\" displayName=\" \" /><XWidget xwidgetType=\"XCombo(");
+ for (Artifact art : templates) {
+ builder.append(art.getSafeName());
+ builder.append(",");
+ }
+ builder.append(")\" displayName=\"Master Template\" horizontalLabel=\"true\"/>");
+ builder.append("<XWidget xwidgetType=\"XCombo(");
+ for (Artifact art : templates) {
+ builder.append(art.getSafeName());
+ builder.append(",");
+ }
+
+ builder.append(")\" displayName=\"Slave Template\" horizontalLabel=\"true\"/><XWidget xwidgetType=\"XLabel\" displayName=\" \" />");
+ builder.append("<XWidget xwidgetType=\"XBranchSelectWidget\" displayName=\"Branch (If Template specifies Artifacts)\" defaultValue=\"" + BranchManager.getLastBranch().getGuid() + "\" /><XWidget xwidgetType=\"XListDropViewer\" displayName=\"Artifacts (If Not Specified in Template)\" />");
+ builder.append("<XWidget xwidgetType=\"XCheckBox\" horizontalLabel=\"true\" labelAfter=\"true\" displayName=\"Publish As Diff\" />");
+ // builder.append("<XWidget xwidgetType=\"XCheckBox\" horizontalLabel=\"true\" labelAfter=\"true\" displayName=\"Diff from Baseline\" />");
+ builder.append("<XWidget xwidgetType=\"XBranchSelectWidget\" displayName=\"Compare Against Another Branch\"/>");
+ builder.append("</xWidgets>");
+
+ return builder.toString();
+ }
+
+ private void populateTemplateList() {
+ templates = TemplateManager.getAllTemplates();
+ Collections.sort(templates);
+ }
+
+ private Artifact getTemplate(String templateName) {
+ for (Artifact artifact : templates) {
+ if (artifact.getSafeName().equals(templateName)) {
+ return artifact;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Collection<String> getCategories() {
+ return Arrays.asList("Define.Publish");
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/RequirementReorderOperation.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/RequirementReorderOperation.java
index bd71e8fe64..51e973a848 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/RequirementReorderOperation.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/RequirementReorderOperation.java
@@ -8,78 +8,78 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.define.blam.operation;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
-import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.importing.ReqNumbering;
-import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
-import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
-import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
-
-public class RequirementReorderOperation extends AbstractBlam {
- private SkynetTransaction transaction;
-
- @Override
- public Collection<String> getCategories() {
- return Arrays.asList("Define");
- }
-
- @Override
- public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
- List<Artifact> artifacts = variableMap.getArtifacts("artifacts");
- Branch branch = artifacts.get(0).getBranch();
- transaction = new SkynetTransaction(branch, "Fix Requirement Ordering BLAM");
- for (Artifact input : artifacts) {
- reorderChildren(input);
- }
- transaction.execute();
- }
-
- public void reorderChildren(Artifact parent) throws OseeCoreException {
- List<Artifact> oldChildren = parent.getChildren();
- List<Artifact> children = parent.getChildren();
- Collections.sort(children, new ParagraphComparator());
- if (!oldChildren.equals(children)) {
- parent.setRelationOrder(CoreRelationTypes.Default_Hierarchical__Child, children);
- parent.persist(transaction);
- }
-
- for (Artifact child : children) {
- reorderChildren(child);
- }
- }
-
- private class ParagraphComparator implements Comparator<Artifact> {
- @Override
- public int compare(Artifact o1, Artifact o2) {
- try {
- ReqNumbering n1 = new ReqNumbering((String) o1.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER));
- ReqNumbering n2 = new ReqNumbering((String) o2.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER));
- return n1.compareTo(n2);
- } catch (OseeCoreException e) {
- return 0;
- }
- }
- }
-
- @Override
- public String getXWidgetsXml() {
- return "<xWidgets><XWidget xwidgetType=\"XListDropViewer\" displayName=\"artifacts\" /></xWidgets>";
- }
-
- @Override
- public String getName() {
- return "Fix Requirement Ordering";
- }
-
-}
+package org.eclipse.osee.define.blam.operation;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.importing.ReqNumbering;
+import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
+import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
+import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
+
+public class RequirementReorderOperation extends AbstractBlam {
+ private SkynetTransaction transaction;
+
+ @Override
+ public Collection<String> getCategories() {
+ return Arrays.asList("Define");
+ }
+
+ @Override
+ public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
+ List<Artifact> artifacts = variableMap.getArtifacts("artifacts");
+ Branch branch = artifacts.get(0).getBranch();
+ transaction = new SkynetTransaction(branch, "Fix Requirement Ordering BLAM");
+ for (Artifact input : artifacts) {
+ reorderChildren(input);
+ }
+ transaction.execute();
+ }
+
+ public void reorderChildren(Artifact parent) throws OseeCoreException {
+ List<Artifact> oldChildren = parent.getChildren();
+ List<Artifact> children = parent.getChildren();
+ Collections.sort(children, new ParagraphComparator());
+ if (!oldChildren.equals(children)) {
+ parent.setRelationOrder(CoreRelationTypes.Default_Hierarchical__Child, children);
+ parent.persist(transaction);
+ }
+
+ for (Artifact child : children) {
+ reorderChildren(child);
+ }
+ }
+
+ private class ParagraphComparator implements Comparator<Artifact> {
+ @Override
+ public int compare(Artifact o1, Artifact o2) {
+ try {
+ ReqNumbering n1 = new ReqNumbering((String) o1.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER));
+ ReqNumbering n2 = new ReqNumbering((String) o2.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER));
+ return n1.compareTo(n2);
+ } catch (OseeCoreException e) {
+ return 0;
+ }
+ }
+ }
+
+ @Override
+ public String getXWidgetsXml() {
+ return "<xWidgets><XWidget xwidgetType=\"XListDropViewer\" displayName=\"artifacts\" /></xWidgets>";
+ }
+
+ @Override
+ public String getName() {
+ return "Fix Requirement Ordering";
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/RequirementsTestReport.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/RequirementsTestReport.java
index 8604831998..ee68912678 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/RequirementsTestReport.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/RequirementsTestReport.java
@@ -1,171 +1,171 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.blam.operation;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
-import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
-import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.type.ArtifactType;
-import org.eclipse.osee.framework.jdk.core.util.AHTML;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.relation.RelationManager;
-import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
-import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
-import org.eclipse.osee.framework.ui.skynet.results.XResultData;
-import org.eclipse.osee.framework.ui.skynet.results.html.XResultPage.Manipulations;
-
-public class RequirementsTestReport extends AbstractBlam {
- private static final String MISSING = "?";
- private static final String EMPTY = "&nbsp;";
- private static final String SPACE = " ";
- private String[] previousCells = {MISSING, MISSING, MISSING, MISSING};
- private final String[] columnHeaders = {"Requirement", "Test Procedure(s)", "Test Status", "Result File(s)"};
- private Collection<Artifact> inputArtifacts;
- private Collection<Artifact> requirementsBulkLoad;
- private StringBuilder report;
-
- @Override
- public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
- init(variableMap);
-
- for (Artifact input : inputArtifacts) {
- processArtifacts(input);
- }
-
- report();
- }
-
- private void processArtifacts(Artifact node) throws OseeCoreException, IOException {
- Collection<Artifact> children = node.getChildren();
-
- if (isRequirement(node)) {
- processRequirement(node);
- } else {
- reportLine(getReqCellOutput(node), "N/A (" + node.getArtifactTypeName() + ")", EMPTY, EMPTY);
- }
- for (Artifact child : children) {
- processArtifacts(child);
- }
- }
-
- private void processRequirement(Artifact req) throws OseeCoreException {
- Collection<Artifact> testProcs = req.getRelatedArtifacts(CoreRelationTypes.Verification__Verifier);
- if (testProcs.isEmpty()) {
- reportLine(getReqCellOutput(req), MISSING, MISSING, MISSING);
- } else {
- for (Artifact testProc : testProcs) {
- processTestProcedure(req, testProc);
- }
- }
- }
-
- private void processTestProcedure(Artifact req, Artifact testProc) throws OseeCoreException {
- String testStatus;
- if (testProc.isAttributeTypeValid(CoreAttributeTypes.TEST_PROCEDURE_STATUS)) {
- testStatus = testProc.getSoleAttributeValue(CoreAttributeTypes.TEST_PROCEDURE_STATUS, MISSING);
- } else {
- testStatus = "N/A (" + testProc.getArtifactTypeName() + ")";
- }
- Collection<Artifact> resultFiles = testProc.getRelatedArtifacts(CoreRelationTypes.Test_Unit_Result__Test_Result);
-
- if (resultFiles.isEmpty()) {
- reportLine(getReqCellOutput(req), testProc.getName(), testStatus, MISSING);
- } else {
- for (Artifact resultFile : resultFiles) {
- reportLine(getReqCellOutput(req), testProc.getName(), testStatus, resultFile.getName());
- }
- }
- }
-
- private String getReqCellOutput(Artifact req) throws OseeCoreException {
- String paragraphNumber = req.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER.getName(), "");
- String reqName = req.getName();
- String returnValue = paragraphNumber + SPACE + reqName;
- return returnValue;
- }
-
- private boolean isRequirement(Artifact src) {
- ArtifactType temp = src.getArtifactType();
- if (temp.inheritsFrom(CoreArtifactTypes.Requirement)) {
- return true;
- }
-
- return false;
- }
-
- private void reportLine(String... cells) {
- String[] outputCells = new String[4];
- for (int i = 0; i < cells.length; i++) {
- if (previousCells[i].equals(cells[i])) {
- if (i == 0 || outputCells[i - 1].equals(" ")) {
- outputCells[i] = " ";
- } else {
- outputCells[i] = cells[i];
- }
- } else {
- outputCells[i] = cells[i];
- }
- }
- previousCells = cells.clone();
- report.append(AHTML.addRowMultiColumnTable(outputCells));
- }
-
- private void report() throws OseeCoreException, IOException {
- report.append(AHTML.endMultiColumnTable());
- XResultData rd = new XResultData();
- rd.addRaw(report.toString());
- rd.report("Requirements Test Report", Manipulations.RAW_HTML);
- }
-
- private void init(VariableMap variableMap) throws OseeCoreException, IOException {
- inputArtifacts = variableMap.getArtifacts("artifacts");
- initReport();
- load();
- }
-
- private void initReport() throws OseeCoreException, IOException {
- report = new StringBuilder(AHTML.beginMultiColumnTable(100, 1));
- report.append(AHTML.addHeaderRowMultiColumnTable(columnHeaders));
- }
-
- private void load() throws OseeCoreException {
- requirementsBulkLoad = new ArrayList<Artifact>();
- for (Artifact input : inputArtifacts) {
- requirementsBulkLoad.addAll(input.getDescendants());
- }
- Collection<Artifact> temp =
- RelationManager.getRelatedArtifacts(requirementsBulkLoad, 1, CoreRelationTypes.Verification__Verifier);
- Collection<Artifact> temp2 =
- RelationManager.getRelatedArtifacts(temp, 1, CoreRelationTypes.Test_Unit_Result__Test_Result);
- System.out.println("Bulk loaded " + temp2.size() + " test results");
- }
-
- @Override
- public String getXWidgetsXml() {
- return "<xWidgets><XWidget xwidgetType=\"XListDropViewer\" displayName=\"artifacts\" /></xWidgets>";
- }
-
- @Override
- public Collection<String> getCategories() {
- return Arrays.asList("Define");
- }
-
- @Override
- public String getName() {
- return "Requirements Test Report";
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.blam.operation;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.type.ArtifactType;
+import org.eclipse.osee.framework.jdk.core.util.AHTML;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.relation.RelationManager;
+import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
+import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
+import org.eclipse.osee.framework.ui.skynet.results.XResultData;
+import org.eclipse.osee.framework.ui.skynet.results.html.XResultPage.Manipulations;
+
+public class RequirementsTestReport extends AbstractBlam {
+ private static final String MISSING = "?";
+ private static final String EMPTY = "&nbsp;";
+ private static final String SPACE = " ";
+ private String[] previousCells = {MISSING, MISSING, MISSING, MISSING};
+ private final String[] columnHeaders = {"Requirement", "Test Procedure(s)", "Test Status", "Result File(s)"};
+ private Collection<Artifact> inputArtifacts;
+ private Collection<Artifact> requirementsBulkLoad;
+ private StringBuilder report;
+
+ @Override
+ public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
+ init(variableMap);
+
+ for (Artifact input : inputArtifacts) {
+ processArtifacts(input);
+ }
+
+ report();
+ }
+
+ private void processArtifacts(Artifact node) throws OseeCoreException, IOException {
+ Collection<Artifact> children = node.getChildren();
+
+ if (isRequirement(node)) {
+ processRequirement(node);
+ } else {
+ reportLine(getReqCellOutput(node), "N/A (" + node.getArtifactTypeName() + ")", EMPTY, EMPTY);
+ }
+ for (Artifact child : children) {
+ processArtifacts(child);
+ }
+ }
+
+ private void processRequirement(Artifact req) throws OseeCoreException {
+ Collection<Artifact> testProcs = req.getRelatedArtifacts(CoreRelationTypes.Verification__Verifier);
+ if (testProcs.isEmpty()) {
+ reportLine(getReqCellOutput(req), MISSING, MISSING, MISSING);
+ } else {
+ for (Artifact testProc : testProcs) {
+ processTestProcedure(req, testProc);
+ }
+ }
+ }
+
+ private void processTestProcedure(Artifact req, Artifact testProc) throws OseeCoreException {
+ String testStatus;
+ if (testProc.isAttributeTypeValid(CoreAttributeTypes.TEST_PROCEDURE_STATUS)) {
+ testStatus = testProc.getSoleAttributeValue(CoreAttributeTypes.TEST_PROCEDURE_STATUS, MISSING);
+ } else {
+ testStatus = "N/A (" + testProc.getArtifactTypeName() + ")";
+ }
+ Collection<Artifact> resultFiles = testProc.getRelatedArtifacts(CoreRelationTypes.Test_Unit_Result__Test_Result);
+
+ if (resultFiles.isEmpty()) {
+ reportLine(getReqCellOutput(req), testProc.getName(), testStatus, MISSING);
+ } else {
+ for (Artifact resultFile : resultFiles) {
+ reportLine(getReqCellOutput(req), testProc.getName(), testStatus, resultFile.getName());
+ }
+ }
+ }
+
+ private String getReqCellOutput(Artifact req) throws OseeCoreException {
+ String paragraphNumber = req.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER.getName(), "");
+ String reqName = req.getName();
+ String returnValue = paragraphNumber + SPACE + reqName;
+ return returnValue;
+ }
+
+ private boolean isRequirement(Artifact src) {
+ ArtifactType temp = src.getArtifactType();
+ if (temp.inheritsFrom(CoreArtifactTypes.Requirement)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ private void reportLine(String... cells) {
+ String[] outputCells = new String[4];
+ for (int i = 0; i < cells.length; i++) {
+ if (previousCells[i].equals(cells[i])) {
+ if (i == 0 || outputCells[i - 1].equals(" ")) {
+ outputCells[i] = " ";
+ } else {
+ outputCells[i] = cells[i];
+ }
+ } else {
+ outputCells[i] = cells[i];
+ }
+ }
+ previousCells = cells.clone();
+ report.append(AHTML.addRowMultiColumnTable(outputCells));
+ }
+
+ private void report() throws OseeCoreException, IOException {
+ report.append(AHTML.endMultiColumnTable());
+ XResultData rd = new XResultData();
+ rd.addRaw(report.toString());
+ rd.report("Requirements Test Report", Manipulations.RAW_HTML);
+ }
+
+ private void init(VariableMap variableMap) throws OseeCoreException, IOException {
+ inputArtifacts = variableMap.getArtifacts("artifacts");
+ initReport();
+ load();
+ }
+
+ private void initReport() throws OseeCoreException, IOException {
+ report = new StringBuilder(AHTML.beginMultiColumnTable(100, 1));
+ report.append(AHTML.addHeaderRowMultiColumnTable(columnHeaders));
+ }
+
+ private void load() throws OseeCoreException {
+ requirementsBulkLoad = new ArrayList<Artifact>();
+ for (Artifact input : inputArtifacts) {
+ requirementsBulkLoad.addAll(input.getDescendants());
+ }
+ Collection<Artifact> temp =
+ RelationManager.getRelatedArtifacts(requirementsBulkLoad, 1, CoreRelationTypes.Verification__Verifier);
+ Collection<Artifact> temp2 =
+ RelationManager.getRelatedArtifacts(temp, 1, CoreRelationTypes.Test_Unit_Result__Test_Result);
+ System.out.println("Bulk loaded " + temp2.size() + " test results");
+ }
+
+ @Override
+ public String getXWidgetsXml() {
+ return "<xWidgets><XWidget xwidgetType=\"XListDropViewer\" displayName=\"artifacts\" /></xWidgets>";
+ }
+
+ @Override
+ public Collection<String> getCategories() {
+ return Arrays.asList("Define");
+ }
+
+ @Override
+ public String getName() {
+ return "Requirements Test Report";
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/SubsystemRequirementVerificationLevel.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/SubsystemRequirementVerificationLevel.java
index c5fa8e55a9..36b6efb12a 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/SubsystemRequirementVerificationLevel.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/SubsystemRequirementVerificationLevel.java
@@ -1,161 +1,161 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.blam.operation;
-
-import java.util.Arrays;
-import java.util.Collection;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
-import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
-import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.jdk.core.util.AHTML;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
-import org.eclipse.osee.framework.skynet.core.relation.RelationManager;
-import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
-import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
-import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
-import org.eclipse.osee.framework.ui.skynet.results.XResultData;
-import org.eclipse.osee.framework.ui.skynet.results.html.XResultPage.Manipulations;
-
-public class SubsystemRequirementVerificationLevel extends AbstractBlam {
-
- @Override
- public Collection<String> getCategories() {
- return Arrays.asList("Define");
- }
-
- @Override
- public String getName() {
- return "Set Verification Level for Subsystem Requirements";
- }
-
- private Branch branch;
- private Collection<Artifact> subsystemRequirements;
- private StringBuilder report;
- private SkynetTransaction transaction;
- private final String[] columnHeaders =
- {"Requirement", "Subsystem", CoreAttributeTypes.PARAGRAPH_NUMBER.getName(), "Current Verification Level",
- "Changed"};
-
- @SuppressWarnings("unused")
- private Collection<Artifact> bulkRequirements;
-
- private void loadFields(VariableMap variableMap) throws OseeCoreException {
- branch = variableMap.getBranch("Branch");
- subsystemRequirements = ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.SubsystemRequirement, branch);
- bulkRequirements =
- RelationManager.getRelatedArtifacts(subsystemRequirements, 1,
- CoreRelationTypes.Requirement_Trace__Lower_Level);
- report = new StringBuilder(AHTML.beginMultiColumnTable(100, 1));
- transaction = new SkynetTransaction(branch, "Set Verification Level for Subsystem Requirements");
- }
-
- @Override
- public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
- loadFields(variableMap);
- beginReport();
-
- for (Artifact req : subsystemRequirements) {
- processSubsystemRequirement(req);
- }
-
- report();
- transaction.execute();
- }
-
- private void report() throws OseeCoreException {
- report.append(AHTML.endMultiColumnTable());
- XResultData rd = new XResultData();
- rd.addRaw(report.toString());
- rd.report("Set Verification Level", Manipulations.RAW_HTML);
- }
-
- private void beginReport() {
- report.append(AHTML.addHeaderRowMultiColumnTable(columnHeaders));
- }
-
- private void addReportRow(String... cells) {
- report.append(AHTML.addRowMultiColumnTable(cells));
- }
-
- private void processSubsystemRequirement(Artifact reqArt) throws OseeCoreException {
- SubsystemRequirement req = new SubsystemRequirement(reqArt);
- req.process();
- }
-
- private class SubsystemRequirement {
- private final Artifact req;
- private int hardwareComponents;
- private int softwareRequirements;
- private String verificationLevel;
- private String paragraphNumber;
- private String subsystem;
-
- public SubsystemRequirement(Artifact req) throws OseeCoreException {
- this.req = req;
- }
-
- public void process() throws OseeCoreException {
- getData();
- if (meetsCriteria()) {
- if (isUnspecified()) {
- adjustVerificationLevel();
- }
- report();
- }
- }
-
- private void getData() throws OseeCoreException {
- this.hardwareComponents = getHardwareComponentCount();
- this.softwareRequirements = getSoftwareRequirementCount();
- paragraphNumber = req.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER, "UNDEFINED");
- subsystem = req.getSoleAttributeValue(CoreAttributeTypes.SUBSYSTEM, "UNDEFINED");
- verificationLevel = req.getSoleAttributeValue(CoreAttributeTypes.VERIFICATION_LEVEL, "UNDEFINED");
- }
-
- private int getHardwareComponentCount() throws OseeCoreException {
- return RelationManager.getRelatedArtifactsCount(req, CoreRelationTypes.Allocation__Component);
- }
-
- private int getSoftwareRequirementCount() throws OseeCoreException {
- Collection<Artifact> traceCollection =
- RelationManager.getRelatedArtifacts(req, CoreRelationTypes.Requirement_Trace__Lower_Level);
- int ret = 0;
- for (Artifact trace : traceCollection) {
- if (trace.isOfType(CoreArtifactTypes.AbstractSoftwareRequirement)) {
- ret++;
- }
- }
- return ret;
- }
-
- private boolean meetsCriteria() {
- return hardwareComponents == 1 && softwareRequirements == 0;
- }
-
- private void adjustVerificationLevel() throws OseeCoreException {
- req.setSoleAttributeValue(CoreAttributeTypes.VERIFICATION_LEVEL, "Component");
- req.persist(SubsystemRequirementVerificationLevel.this.transaction);
- }
-
- public void report() {
- SubsystemRequirementVerificationLevel.this.addReportRow(req.getName(), subsystem, paragraphNumber,
- verificationLevel, String.valueOf(isUnspecified()));
- }
-
- private boolean isUnspecified() {
- return verificationLevel.equals("Unspecified");
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.blam.operation;
+
+import java.util.Arrays;
+import java.util.Collection;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.jdk.core.util.AHTML;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.relation.RelationManager;
+import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
+import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
+import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
+import org.eclipse.osee.framework.ui.skynet.results.XResultData;
+import org.eclipse.osee.framework.ui.skynet.results.html.XResultPage.Manipulations;
+
+public class SubsystemRequirementVerificationLevel extends AbstractBlam {
+
+ @Override
+ public Collection<String> getCategories() {
+ return Arrays.asList("Define");
+ }
+
+ @Override
+ public String getName() {
+ return "Set Verification Level for Subsystem Requirements";
+ }
+
+ private Branch branch;
+ private Collection<Artifact> subsystemRequirements;
+ private StringBuilder report;
+ private SkynetTransaction transaction;
+ private final String[] columnHeaders =
+ {"Requirement", "Subsystem", CoreAttributeTypes.PARAGRAPH_NUMBER.getName(), "Current Verification Level",
+ "Changed"};
+
+ @SuppressWarnings("unused")
+ private Collection<Artifact> bulkRequirements;
+
+ private void loadFields(VariableMap variableMap) throws OseeCoreException {
+ branch = variableMap.getBranch("Branch");
+ subsystemRequirements = ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.SubsystemRequirement, branch);
+ bulkRequirements =
+ RelationManager.getRelatedArtifacts(subsystemRequirements, 1,
+ CoreRelationTypes.Requirement_Trace__Lower_Level);
+ report = new StringBuilder(AHTML.beginMultiColumnTable(100, 1));
+ transaction = new SkynetTransaction(branch, "Set Verification Level for Subsystem Requirements");
+ }
+
+ @Override
+ public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
+ loadFields(variableMap);
+ beginReport();
+
+ for (Artifact req : subsystemRequirements) {
+ processSubsystemRequirement(req);
+ }
+
+ report();
+ transaction.execute();
+ }
+
+ private void report() throws OseeCoreException {
+ report.append(AHTML.endMultiColumnTable());
+ XResultData rd = new XResultData();
+ rd.addRaw(report.toString());
+ rd.report("Set Verification Level", Manipulations.RAW_HTML);
+ }
+
+ private void beginReport() {
+ report.append(AHTML.addHeaderRowMultiColumnTable(columnHeaders));
+ }
+
+ private void addReportRow(String... cells) {
+ report.append(AHTML.addRowMultiColumnTable(cells));
+ }
+
+ private void processSubsystemRequirement(Artifact reqArt) throws OseeCoreException {
+ SubsystemRequirement req = new SubsystemRequirement(reqArt);
+ req.process();
+ }
+
+ private class SubsystemRequirement {
+ private final Artifact req;
+ private int hardwareComponents;
+ private int softwareRequirements;
+ private String verificationLevel;
+ private String paragraphNumber;
+ private String subsystem;
+
+ public SubsystemRequirement(Artifact req) throws OseeCoreException {
+ this.req = req;
+ }
+
+ public void process() throws OseeCoreException {
+ getData();
+ if (meetsCriteria()) {
+ if (isUnspecified()) {
+ adjustVerificationLevel();
+ }
+ report();
+ }
+ }
+
+ private void getData() throws OseeCoreException {
+ this.hardwareComponents = getHardwareComponentCount();
+ this.softwareRequirements = getSoftwareRequirementCount();
+ paragraphNumber = req.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER, "UNDEFINED");
+ subsystem = req.getSoleAttributeValue(CoreAttributeTypes.SUBSYSTEM, "UNDEFINED");
+ verificationLevel = req.getSoleAttributeValue(CoreAttributeTypes.VERIFICATION_LEVEL, "UNDEFINED");
+ }
+
+ private int getHardwareComponentCount() throws OseeCoreException {
+ return RelationManager.getRelatedArtifactsCount(req, CoreRelationTypes.Allocation__Component);
+ }
+
+ private int getSoftwareRequirementCount() throws OseeCoreException {
+ Collection<Artifact> traceCollection =
+ RelationManager.getRelatedArtifacts(req, CoreRelationTypes.Requirement_Trace__Lower_Level);
+ int ret = 0;
+ for (Artifact trace : traceCollection) {
+ if (trace.isOfType(CoreArtifactTypes.AbstractSoftwareRequirement)) {
+ ret++;
+ }
+ }
+ return ret;
+ }
+
+ private boolean meetsCriteria() {
+ return hardwareComponents == 1 && softwareRequirements == 0;
+ }
+
+ private void adjustVerificationLevel() throws OseeCoreException {
+ req.setSoleAttributeValue(CoreAttributeTypes.VERIFICATION_LEVEL, "Component");
+ req.persist(SubsystemRequirementVerificationLevel.this.transaction);
+ }
+
+ public void report() {
+ SubsystemRequirementVerificationLevel.this.addReportRow(req.getName(), subsystem, paragraphNumber,
+ verificationLevel, String.valueOf(isUnspecified()));
+ }
+
+ private boolean isUnspecified() {
+ return verificationLevel.equals("Unspecified");
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/SubsystemToLowLevelReqTraceReport.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/SubsystemToLowLevelReqTraceReport.java
index 7f10bf8429..d6cb8ef351 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/SubsystemToLowLevelReqTraceReport.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/SubsystemToLowLevelReqTraceReport.java
@@ -1,255 +1,255 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.blam.operation;
-
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.blam.operation;
+
import static org.eclipse.osee.framework.skynet.core.artifact.DeletionFlag.INCLUDE_DELETED;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map.Entry;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
-import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
-import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.core.model.type.ArtifactType;
-import org.eclipse.osee.framework.jdk.core.util.io.CharBackedInputStream;
-import org.eclipse.osee.framework.jdk.core.util.io.xml.ExcelXmlWriter;
-import org.eclipse.osee.framework.jdk.core.util.io.xml.ISheetWriter;
-import org.eclipse.osee.framework.plugin.core.util.AIFile;
-import org.eclipse.osee.framework.plugin.core.util.OseeData;
-import org.eclipse.osee.framework.skynet.core.OseeSystemArtifacts;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
-import org.eclipse.osee.framework.skynet.core.relation.RelationManager;
-import org.eclipse.osee.framework.skynet.core.utility.Requirements;
-import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
-import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
-import org.eclipse.swt.program.Program;
-
-/**
- * @author Ryan D. Brooks
- */
-public class SubsystemToLowLevelReqTraceReport extends AbstractBlam {
- private CharBackedInputStream charBak;
- private ISheetWriter excelWriter;
- private final HashMap<String, List<Artifact>> subsysToSubsysReqsMap;
- private final List<Artifact> lowLevelReqs;
- private final HashSet<Artifact> components;
- private Collection<ArtifactType> lowerLevelTypes;
-
- @Override
- public String getName() {
- return "Subsystem To Low Level Req Trace Report";
- }
-
- public SubsystemToLowLevelReqTraceReport() {
- subsysToSubsysReqsMap = new HashMap<String, List<Artifact>>();
- components = new HashSet<Artifact>();
- lowLevelReqs = new ArrayList<Artifact>(1000);
- }
-
- private void init() throws IOException {
- subsysToSubsysReqsMap.clear();
- charBak = new CharBackedInputStream();
- excelWriter = new ExcelXmlWriter(charBak.getWriter());
- components.clear();
- lowLevelReqs.clear();
- }
-
- @Override
- public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
- monitor.beginTask("Generate Report", 100);
-
- init();
- lowerLevelTypes = variableMap.getCollection(ArtifactType.class, "Low Level Requirement Type(s)");
-
- initLowLevelRequirements(variableMap.getArtifacts("Lower Level Requirements"));
- initAllocationComponents(variableMap.getArtifacts("Allocation Components"));
-
- Branch branch = lowLevelReqs.get(0).getBranch();
-
- monitor.subTask("Loading Higher Level Requirements"); // bulk load to improve performance
- monitor.worked(1);
- ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.SubsystemRequirement, branch);
- monitor.worked(30);
-
- Artifact root = OseeSystemArtifacts.getDefaultHierarchyRootArtifact(branch);
- orderSubsystemReqs(root.getChild(Requirements.SUBSYSTEM_REQUIREMENTS));
-
- generateLowLevelToSubsystemTrace();
- generateSubsystemToLowLevelReqTrace();
-
- excelWriter.endWorkbook();
- IFile iFile = OseeData.getIFile("Subsystem_To_Lower_Level_Trace.xml");
- AIFile.writeToFile(iFile, charBak);
- Program.launch(iFile.getLocation().toOSString());
- }
-
- private void generateLowLevelToSubsystemTrace() throws IOException, OseeCoreException {
- excelWriter.startSheet("5.1", 7);
-
- excelWriter.writeRow("5.1 Lower Level Requirements Traceability to Subsystem Requirements");
- excelWriter.writeRow("Lower Level Requirements", null, null, "Traceable Subsystem Requirement");
- excelWriter.writeRow("Paragraph #", "Paragraph Title", "Qualification Method", "PIDS", "Paragraph #",
- "Paragraph Title", Requirements.SUBSYSTEM);
-
- String[] row = new String[7];
-
- for (Artifact lowLevelReq : lowLevelReqs) {
- row[0] = correct(lowLevelReq.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER, ""));
- row[1] = lowLevelReq.getName();
- if (isLowerLevelRequirement(lowLevelReq)) {
- row[2] = lowLevelReq.getAttributesToString(CoreAttributeTypes.QUALIFICATION_METHOD);
-
- for (Artifact subSysReq : lowLevelReq.getRelatedArtifacts(CoreRelationTypes.Requirement_Trace__Higher_Level)) {
- row[3] = getAssociatedSubSystem(subSysReq);
- row[4] = correct(subSysReq.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER, ""));
- row[5] = subSysReq.getName();
- row[6] = subSysReq.getSoleAttributeValue(Requirements.SUBSYSTEM, "");
- excelWriter.writeRow(row);
- row[0] = row[1] = row[2] = null;
- }
- } else {
- row[2] = lowLevelReq.getArtifactTypeName();
- }
-
- if (row[0] != null) { // if this requirement is not traced to any lower level req (i.e. the for loop didn't run)
- row[3] = row[4] = row[5] = row[6] = null;
- excelWriter.writeRow(row);
- }
- }
-
- excelWriter.endSheet();
- }
-
- private boolean isLowerLevelRequirement(Artifact artifact) throws OseeCoreException {
- for (ArtifactType artifactType : lowerLevelTypes) {
- if (artifact.isOfType(artifactType)) {
- return true;
- }
- }
- return false;
- }
-
- private void generateSubsystemToLowLevelReqTrace() throws IOException, OseeCoreException {
- excelWriter.startSheet("5.2", 6);
-
- excelWriter.writeRow("5.2 Subsystem Requirements Allocation Traceability to Lower Level Requirements");
- excelWriter.writeRow();
-
- int count = 1;
- for (Entry<String, List<Artifact>> entry : subsysToSubsysReqsMap.entrySet()) {
- String subSysName = entry.getKey();
- List<Artifact> subsysReqs = entry.getValue();
-
- excelWriter.writeRow();
- excelWriter.writeRow();
- excelWriter.writeRow("5.2." + count++ + " " + subSysName + " Requirements Allocation Traceability to Lower Level Requirements");
- excelWriter.writeRow(CoreArtifactTypes.SubsystemRequirement.getName(), null,
- "Traceable Lower Level Requirements", null);
- excelWriter.writeRow("Paragraph #", "Paragraph Title", "Paragraph #", "Paragraph Title");
-
- String[] row = new String[4];
-
- for (Artifact higherLevelReq : subsysReqs) {
- if (isAllocated(higherLevelReq)) {
- row[0] = correct(higherLevelReq.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER, ""));
- row[1] = higherLevelReq.getName();
-
- for (Artifact lowerLevelReq : higherLevelReq.getRelatedArtifacts(CoreRelationTypes.Requirement_Trace__Lower_Level)) {
- if (lowLevelReqs.contains(lowerLevelReq)) {
- row[2] = correct(lowerLevelReq.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER, ""));
- row[3] = lowerLevelReq.getName();
- excelWriter.writeRow(row);
- row[0] = row[1] = null;
- }
- }
- if (row[0] != null) { // if this requirement is not traced to any low level requirement(i.e. the for loop didn't run)
- row[2] = row[3] = null;
- excelWriter.writeRow(row);
- }
- }
- }
- }
- excelWriter.endSheet();
- }
-
- private boolean isAllocated(Artifact higherLevelReq) throws OseeCoreException {
- for (Artifact component : higherLevelReq.getRelatedArtifacts("Allocation")) {
- if (components.contains(component)) {
- return true;
- }
- }
- return false;
- }
-
- private void initLowLevelRequirements(List<Artifact> artifacts) throws OseeCoreException {
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map.Entry;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.model.type.ArtifactType;
+import org.eclipse.osee.framework.jdk.core.util.io.CharBackedInputStream;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.ExcelXmlWriter;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.ISheetWriter;
+import org.eclipse.osee.framework.plugin.core.util.AIFile;
+import org.eclipse.osee.framework.plugin.core.util.OseeData;
+import org.eclipse.osee.framework.skynet.core.OseeSystemArtifacts;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.relation.RelationManager;
+import org.eclipse.osee.framework.skynet.core.utility.Requirements;
+import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
+import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
+import org.eclipse.swt.program.Program;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class SubsystemToLowLevelReqTraceReport extends AbstractBlam {
+ private CharBackedInputStream charBak;
+ private ISheetWriter excelWriter;
+ private final HashMap<String, List<Artifact>> subsysToSubsysReqsMap;
+ private final List<Artifact> lowLevelReqs;
+ private final HashSet<Artifact> components;
+ private Collection<ArtifactType> lowerLevelTypes;
+
+ @Override
+ public String getName() {
+ return "Subsystem To Low Level Req Trace Report";
+ }
+
+ public SubsystemToLowLevelReqTraceReport() {
+ subsysToSubsysReqsMap = new HashMap<String, List<Artifact>>();
+ components = new HashSet<Artifact>();
+ lowLevelReqs = new ArrayList<Artifact>(1000);
+ }
+
+ private void init() throws IOException {
+ subsysToSubsysReqsMap.clear();
+ charBak = new CharBackedInputStream();
+ excelWriter = new ExcelXmlWriter(charBak.getWriter());
+ components.clear();
+ lowLevelReqs.clear();
+ }
+
+ @Override
+ public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
+ monitor.beginTask("Generate Report", 100);
+
+ init();
+ lowerLevelTypes = variableMap.getCollection(ArtifactType.class, "Low Level Requirement Type(s)");
+
+ initLowLevelRequirements(variableMap.getArtifacts("Lower Level Requirements"));
+ initAllocationComponents(variableMap.getArtifacts("Allocation Components"));
+
+ Branch branch = lowLevelReqs.get(0).getBranch();
+
+ monitor.subTask("Loading Higher Level Requirements"); // bulk load to improve performance
+ monitor.worked(1);
+ ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.SubsystemRequirement, branch);
+ monitor.worked(30);
+
+ Artifact root = OseeSystemArtifacts.getDefaultHierarchyRootArtifact(branch);
+ orderSubsystemReqs(root.getChild(Requirements.SUBSYSTEM_REQUIREMENTS));
+
+ generateLowLevelToSubsystemTrace();
+ generateSubsystemToLowLevelReqTrace();
+
+ excelWriter.endWorkbook();
+ IFile iFile = OseeData.getIFile("Subsystem_To_Lower_Level_Trace.xml");
+ AIFile.writeToFile(iFile, charBak);
+ Program.launch(iFile.getLocation().toOSString());
+ }
+
+ private void generateLowLevelToSubsystemTrace() throws IOException, OseeCoreException {
+ excelWriter.startSheet("5.1", 7);
+
+ excelWriter.writeRow("5.1 Lower Level Requirements Traceability to Subsystem Requirements");
+ excelWriter.writeRow("Lower Level Requirements", null, null, "Traceable Subsystem Requirement");
+ excelWriter.writeRow("Paragraph #", "Paragraph Title", "Qualification Method", "PIDS", "Paragraph #",
+ "Paragraph Title", Requirements.SUBSYSTEM);
+
+ String[] row = new String[7];
+
+ for (Artifact lowLevelReq : lowLevelReqs) {
+ row[0] = correct(lowLevelReq.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER, ""));
+ row[1] = lowLevelReq.getName();
+ if (isLowerLevelRequirement(lowLevelReq)) {
+ row[2] = lowLevelReq.getAttributesToString(CoreAttributeTypes.QUALIFICATION_METHOD);
+
+ for (Artifact subSysReq : lowLevelReq.getRelatedArtifacts(CoreRelationTypes.Requirement_Trace__Higher_Level)) {
+ row[3] = getAssociatedSubSystem(subSysReq);
+ row[4] = correct(subSysReq.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER, ""));
+ row[5] = subSysReq.getName();
+ row[6] = subSysReq.getSoleAttributeValue(Requirements.SUBSYSTEM, "");
+ excelWriter.writeRow(row);
+ row[0] = row[1] = row[2] = null;
+ }
+ } else {
+ row[2] = lowLevelReq.getArtifactTypeName();
+ }
+
+ if (row[0] != null) { // if this requirement is not traced to any lower level req (i.e. the for loop didn't run)
+ row[3] = row[4] = row[5] = row[6] = null;
+ excelWriter.writeRow(row);
+ }
+ }
+
+ excelWriter.endSheet();
+ }
+
+ private boolean isLowerLevelRequirement(Artifact artifact) throws OseeCoreException {
+ for (ArtifactType artifactType : lowerLevelTypes) {
+ if (artifact.isOfType(artifactType)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void generateSubsystemToLowLevelReqTrace() throws IOException, OseeCoreException {
+ excelWriter.startSheet("5.2", 6);
+
+ excelWriter.writeRow("5.2 Subsystem Requirements Allocation Traceability to Lower Level Requirements");
+ excelWriter.writeRow();
+
+ int count = 1;
+ for (Entry<String, List<Artifact>> entry : subsysToSubsysReqsMap.entrySet()) {
+ String subSysName = entry.getKey();
+ List<Artifact> subsysReqs = entry.getValue();
+
+ excelWriter.writeRow();
+ excelWriter.writeRow();
+ excelWriter.writeRow("5.2." + count++ + " " + subSysName + " Requirements Allocation Traceability to Lower Level Requirements");
+ excelWriter.writeRow(CoreArtifactTypes.SubsystemRequirement.getName(), null,
+ "Traceable Lower Level Requirements", null);
+ excelWriter.writeRow("Paragraph #", "Paragraph Title", "Paragraph #", "Paragraph Title");
+
+ String[] row = new String[4];
+
+ for (Artifact higherLevelReq : subsysReqs) {
+ if (isAllocated(higherLevelReq)) {
+ row[0] = correct(higherLevelReq.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER, ""));
+ row[1] = higherLevelReq.getName();
+
+ for (Artifact lowerLevelReq : higherLevelReq.getRelatedArtifacts(CoreRelationTypes.Requirement_Trace__Lower_Level)) {
+ if (lowLevelReqs.contains(lowerLevelReq)) {
+ row[2] = correct(lowerLevelReq.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER, ""));
+ row[3] = lowerLevelReq.getName();
+ excelWriter.writeRow(row);
+ row[0] = row[1] = null;
+ }
+ }
+ if (row[0] != null) { // if this requirement is not traced to any low level requirement(i.e. the for loop didn't run)
+ row[2] = row[3] = null;
+ excelWriter.writeRow(row);
+ }
+ }
+ }
+ }
+ excelWriter.endSheet();
+ }
+
+ private boolean isAllocated(Artifact higherLevelReq) throws OseeCoreException {
+ for (Artifact component : higherLevelReq.getRelatedArtifacts("Allocation")) {
+ if (components.contains(component)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void initLowLevelRequirements(List<Artifact> artifacts) throws OseeCoreException {
RelationManager.getRelatedArtifacts(artifacts, 999, INCLUDE_DELETED,
CoreRelationTypes.Default_Hierarchical__Child);
- for (Artifact artifact : artifacts) {
- if (!artifact.isOfType(CoreArtifactTypes.Folder)) {
- lowLevelReqs.add(artifact);
- }
- lowLevelReqs.addAll(artifact.getDescendants());
- }
- }
-
- private void initAllocationComponents(List<Artifact> artifacts) throws OseeCoreException {
+ for (Artifact artifact : artifacts) {
+ if (!artifact.isOfType(CoreArtifactTypes.Folder)) {
+ lowLevelReqs.add(artifact);
+ }
+ lowLevelReqs.addAll(artifact.getDescendants());
+ }
+ }
+
+ private void initAllocationComponents(List<Artifact> artifacts) throws OseeCoreException {
RelationManager.getRelatedArtifacts(artifacts, 999, INCLUDE_DELETED,
CoreRelationTypes.Default_Hierarchical__Child);
- for (Artifact artifact : artifacts) {
- if (!artifact.isOfType(CoreArtifactTypes.Folder)) {
- components.add(artifact);
- }
- components.addAll(artifact.getDescendants());
- }
- }
-
- private String correct(String value) {
- return value.equals("") ? null : value;
- }
-
- private String getAssociatedSubSystem(Artifact subSysReq) {
- for (Entry<String, List<Artifact>> entry : subsysToSubsysReqsMap.entrySet()) {
- String subSysName = entry.getKey();
- List<Artifact> subsysReqs = entry.getValue();
- if (subsysReqs.contains(subSysReq)) {
- return subSysName;
- }
- }
- return "N/A";
- }
-
- private void orderSubsystemReqs(Artifact subsysTopFolder) throws OseeCoreException {
- for (Artifact subsysFolder : subsysTopFolder.getChildren()) {
- String subSysName = subsysFolder.getName();
- List<Artifact> subsysReqs = subsysFolder.getDescendants();
- subsysToSubsysReqsMap.put(subSysName, subsysReqs);
- }
- }
-
- @Override
- public String getXWidgetsXml() {
- return "<xWidgets><XWidget xwidgetType=\"XListDropViewer\" displayName=\"Lower Level Requirements\" /><XWidget xwidgetType=\"XListDropViewer\" displayName=\"Allocation Components\" /><XWidget xwidgetType=\"XArtifactTypeListViewer\" displayName=\"Low Level Requirement Type(s)\" multiSelect=\"true\" /></xWidgets>";
- }
-
- @Override
- public Collection<String> getCategories() {
- return Arrays.asList("Define.Publish");
- }
+ for (Artifact artifact : artifacts) {
+ if (!artifact.isOfType(CoreArtifactTypes.Folder)) {
+ components.add(artifact);
+ }
+ components.addAll(artifact.getDescendants());
+ }
+ }
+
+ private String correct(String value) {
+ return value.equals("") ? null : value;
+ }
+
+ private String getAssociatedSubSystem(Artifact subSysReq) {
+ for (Entry<String, List<Artifact>> entry : subsysToSubsysReqsMap.entrySet()) {
+ String subSysName = entry.getKey();
+ List<Artifact> subsysReqs = entry.getValue();
+ if (subsysReqs.contains(subSysReq)) {
+ return subSysName;
+ }
+ }
+ return "N/A";
+ }
+
+ private void orderSubsystemReqs(Artifact subsysTopFolder) throws OseeCoreException {
+ for (Artifact subsysFolder : subsysTopFolder.getChildren()) {
+ String subSysName = subsysFolder.getName();
+ List<Artifact> subsysReqs = subsysFolder.getDescendants();
+ subsysToSubsysReqsMap.put(subSysName, subsysReqs);
+ }
+ }
+
+ @Override
+ public String getXWidgetsXml() {
+ return "<xWidgets><XWidget xwidgetType=\"XListDropViewer\" displayName=\"Lower Level Requirements\" /><XWidget xwidgetType=\"XListDropViewer\" displayName=\"Allocation Components\" /><XWidget xwidgetType=\"XArtifactTypeListViewer\" displayName=\"Low Level Requirement Type(s)\" multiSelect=\"true\" /></xWidgets>";
+ }
+
+ @Override
+ public Collection<String> getCategories() {
+ return Arrays.asList("Define.Publish");
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/TestPlanComplianceReport.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/TestPlanComplianceReport.java
index 9a6c64fe4a..4522b8c621 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/TestPlanComplianceReport.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/TestPlanComplianceReport.java
@@ -1,214 +1,214 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.blam.operation;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import org.apache.commons.lang.StringUtils;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
-import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
-import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.type.ArtifactType;
-import org.eclipse.osee.framework.jdk.core.util.AHTML;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.relation.RelationManager;
-import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
-import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
-import org.eclipse.osee.framework.ui.skynet.results.XResultData;
-import org.eclipse.osee.framework.ui.skynet.results.html.XResultPage.Manipulations;
-
-public class TestPlanComplianceReport extends AbstractBlam {
- private static final String MISSING = "?";
- private static final String EMPTY = "&nbsp;";
- private String[] previousCells = {MISSING, MISSING, MISSING, MISSING, MISSING};
- private final String[] columnHeaders =
- {"Test Plan & Paragraph", "Perf Spec Requirement(s)", "Test Procedure", "Test Status", "Test Result"};
- private Collection<Artifact> inputArtifacts;
- private Collection<Artifact> testPlans;
- private StringBuilder report;
-
- @Override
- public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
- init(variableMap);
-
- for (Artifact input : inputArtifacts) {
- processArtifacts(input);
- }
-
- report();
- }
-
- private void processArtifacts(Artifact node) throws OseeCoreException, IOException {
- Collection<Artifact> children = node.getChildren();
-
- if (isTestPlan(node)) {
- processTestPlan(node);
- } else {
- reportLine(node, "N/A (" + node.getArtifactTypeName() + ")", EMPTY, EMPTY);
- }
- for (Artifact child : children) {
- processArtifacts(child);
- }
- }
-
- private boolean isTestPlan(Artifact src) {
- ArtifactType temp = src.getArtifactType();
- if (temp.inheritsFrom(CoreArtifactTypes.TestPlanElement)) {
- return true;
- }
-
- return false;
- }
-
- private void processTestPlan(Artifact testPlan) throws OseeCoreException, IOException {
- Collection<Artifact> testProcedures = getTestProcedures(testPlan);
-
- if (testProcedures.isEmpty()) {
- reportLine(testPlan, MISSING, MISSING, MISSING);
- } else {
- for (Artifact testProc : testProcedures) {
- processTestProcedure(testPlan, testProc);
- }
- }
- }
-
- private void processTestProcedure(Artifact testPlan, Artifact testProc) throws IOException, OseeCoreException {
- Collection<Artifact> testResults = getTestResults(testProc);
- if (testResults.isEmpty()) {
- reportLine(testPlan, testProc.getName(), MISSING, MISSING);
- } else {
- for (Artifact testResult : testResults) {
- reportLine(testPlan, testProc.getName(), getStatus(testProc), testResult.getName());
- }
- }
- }
-
- private String getStatus(Artifact testProc) throws OseeCoreException {
- String returnValue = testProc.getSoleAttributeValue(CoreAttributeTypes.TEST_PROCEDURE_STATUS);
-
- return returnValue;
- }
-
- private String getName(Artifact art) throws OseeCoreException {
- String testPlanNumber = art.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER, "");
- String testPlanOutput = testPlanNumber + " " + art.getName();
- return testPlanOutput;
- }
-
- private Collection<Artifact> getTestProcedures(Artifact testPlan) throws OseeCoreException {
- Collection<Artifact> ret = testPlan.getRelatedArtifacts(CoreRelationTypes.Executes__Test_Procedure);
-
- return ret;
- }
-
- private Collection<Artifact> getTestResults(Artifact testProc) throws OseeCoreException {
- Collection<Artifact> ret = testProc.getRelatedArtifacts(CoreRelationTypes.Test_Unit_Result__Test_Result);
-
- return ret;
- }
-
- private String getRequirementsCellOutput(Artifact art) throws OseeCoreException {
- if (art.getArtifactType().inheritsFrom(CoreArtifactTypes.TestPlanElement)) {
- return getRequirementsCellOutputForTestPlan(art);
- }
-
- return EMPTY;
- }
-
- private String getRequirementsCellOutputForTestPlan(Artifact testPlan) throws OseeCoreException {
- String ret = getRequirementsAsString(testPlan);
- if (ret.isEmpty()) {
- ret = MISSING;
- }
-
- return ret;
- }
-
- private String getRequirementsAsString(Artifact testPlan) throws OseeCoreException {
- Collection<Artifact> requirementArtifacts =
- testPlan.getRelatedArtifacts(CoreRelationTypes.Verification_Plan__Requirement);
- Collection<String> requirementNames = new ArrayList<String>();
- for (Artifact req : requirementArtifacts) {
- String paragraphNumber = req.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER, "");
- requirementNames.add(paragraphNumber + " " + req.getName());
- }
-
- return StringUtils.join(requirementNames, "\n");
- }
-
- private void reportLine(Artifact art, String testProc, String testStatus, String testResult) throws IOException, OseeCoreException {
- String[] outputCells = new String[5];
- String testPlanOutput = getName(art);
- String requirements = getRequirementsCellOutput(art);
- String[] cells = new String[] {testPlanOutput, requirements, testProc, testStatus, testResult};
- for (int i = 0; i < cells.length; i++) {
- if (previousCells[i].equals(cells[i])) {
- if (i == 0 || outputCells[i - 1].equals(" ")) {
- outputCells[i] = " ";
- } else {
- outputCells[i] = cells[i];
- }
- } else {
- outputCells[i] = cells[i];
- }
- }
- previousCells = cells.clone();
- report.append(AHTML.addRowMultiColumnTable(outputCells));
- }
-
- private void report() throws OseeCoreException, IOException {
- report.append(AHTML.endMultiColumnTable());
- XResultData rd = new XResultData();
- rd.addRaw(report.toString());
- rd.report("Test Plan Compliance Report", Manipulations.RAW_HTML);
- }
-
- private void init(VariableMap variableMap) throws OseeCoreException, IOException {
- inputArtifacts = variableMap.getArtifacts("artifacts");
- initReport();
- load();
- }
-
- private void initReport() throws OseeCoreException, IOException {
- report = new StringBuilder(AHTML.beginMultiColumnTable(100, 1));
- report.append(AHTML.addHeaderRowMultiColumnTable(columnHeaders));
- }
-
- private void load() throws OseeCoreException {
- testPlans = new ArrayList<Artifact>();
- for (Artifact input : inputArtifacts) {
- testPlans.addAll(input.getDescendants());
- }
- RelationManager.getRelatedArtifacts(testPlans, 1, CoreRelationTypes.Verification_Plan__Requirement);
- Collection<Artifact> temp =
- RelationManager.getRelatedArtifacts(testPlans, 1, CoreRelationTypes.Executes__Test_Procedure);
- RelationManager.getRelatedArtifacts(temp, 1, CoreRelationTypes.Test_Unit_Result__Test_Result);
- }
-
- @Override
- public String getXWidgetsXml() {
- return "<xWidgets><XWidget xwidgetType=\"XListDropViewer\" displayName=\"artifacts\" /></xWidgets>";
- }
-
- @Override
- public Collection<String> getCategories() {
- return Arrays.asList("Define");
- }
-
- @Override
- public String getName() {
- return "Test Plan Compliance Report";
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.blam.operation;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.type.ArtifactType;
+import org.eclipse.osee.framework.jdk.core.util.AHTML;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.relation.RelationManager;
+import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
+import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
+import org.eclipse.osee.framework.ui.skynet.results.XResultData;
+import org.eclipse.osee.framework.ui.skynet.results.html.XResultPage.Manipulations;
+
+public class TestPlanComplianceReport extends AbstractBlam {
+ private static final String MISSING = "?";
+ private static final String EMPTY = "&nbsp;";
+ private String[] previousCells = {MISSING, MISSING, MISSING, MISSING, MISSING};
+ private final String[] columnHeaders =
+ {"Test Plan & Paragraph", "Perf Spec Requirement(s)", "Test Procedure", "Test Status", "Test Result"};
+ private Collection<Artifact> inputArtifacts;
+ private Collection<Artifact> testPlans;
+ private StringBuilder report;
+
+ @Override
+ public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
+ init(variableMap);
+
+ for (Artifact input : inputArtifacts) {
+ processArtifacts(input);
+ }
+
+ report();
+ }
+
+ private void processArtifacts(Artifact node) throws OseeCoreException, IOException {
+ Collection<Artifact> children = node.getChildren();
+
+ if (isTestPlan(node)) {
+ processTestPlan(node);
+ } else {
+ reportLine(node, "N/A (" + node.getArtifactTypeName() + ")", EMPTY, EMPTY);
+ }
+ for (Artifact child : children) {
+ processArtifacts(child);
+ }
+ }
+
+ private boolean isTestPlan(Artifact src) {
+ ArtifactType temp = src.getArtifactType();
+ if (temp.inheritsFrom(CoreArtifactTypes.TestPlanElement)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ private void processTestPlan(Artifact testPlan) throws OseeCoreException, IOException {
+ Collection<Artifact> testProcedures = getTestProcedures(testPlan);
+
+ if (testProcedures.isEmpty()) {
+ reportLine(testPlan, MISSING, MISSING, MISSING);
+ } else {
+ for (Artifact testProc : testProcedures) {
+ processTestProcedure(testPlan, testProc);
+ }
+ }
+ }
+
+ private void processTestProcedure(Artifact testPlan, Artifact testProc) throws IOException, OseeCoreException {
+ Collection<Artifact> testResults = getTestResults(testProc);
+ if (testResults.isEmpty()) {
+ reportLine(testPlan, testProc.getName(), MISSING, MISSING);
+ } else {
+ for (Artifact testResult : testResults) {
+ reportLine(testPlan, testProc.getName(), getStatus(testProc), testResult.getName());
+ }
+ }
+ }
+
+ private String getStatus(Artifact testProc) throws OseeCoreException {
+ String returnValue = testProc.getSoleAttributeValue(CoreAttributeTypes.TEST_PROCEDURE_STATUS);
+
+ return returnValue;
+ }
+
+ private String getName(Artifact art) throws OseeCoreException {
+ String testPlanNumber = art.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER, "");
+ String testPlanOutput = testPlanNumber + " " + art.getName();
+ return testPlanOutput;
+ }
+
+ private Collection<Artifact> getTestProcedures(Artifact testPlan) throws OseeCoreException {
+ Collection<Artifact> ret = testPlan.getRelatedArtifacts(CoreRelationTypes.Executes__Test_Procedure);
+
+ return ret;
+ }
+
+ private Collection<Artifact> getTestResults(Artifact testProc) throws OseeCoreException {
+ Collection<Artifact> ret = testProc.getRelatedArtifacts(CoreRelationTypes.Test_Unit_Result__Test_Result);
+
+ return ret;
+ }
+
+ private String getRequirementsCellOutput(Artifact art) throws OseeCoreException {
+ if (art.getArtifactType().inheritsFrom(CoreArtifactTypes.TestPlanElement)) {
+ return getRequirementsCellOutputForTestPlan(art);
+ }
+
+ return EMPTY;
+ }
+
+ private String getRequirementsCellOutputForTestPlan(Artifact testPlan) throws OseeCoreException {
+ String ret = getRequirementsAsString(testPlan);
+ if (ret.isEmpty()) {
+ ret = MISSING;
+ }
+
+ return ret;
+ }
+
+ private String getRequirementsAsString(Artifact testPlan) throws OseeCoreException {
+ Collection<Artifact> requirementArtifacts =
+ testPlan.getRelatedArtifacts(CoreRelationTypes.Verification_Plan__Requirement);
+ Collection<String> requirementNames = new ArrayList<String>();
+ for (Artifact req : requirementArtifacts) {
+ String paragraphNumber = req.getSoleAttributeValue(CoreAttributeTypes.PARAGRAPH_NUMBER, "");
+ requirementNames.add(paragraphNumber + " " + req.getName());
+ }
+
+ return StringUtils.join(requirementNames, "\n");
+ }
+
+ private void reportLine(Artifact art, String testProc, String testStatus, String testResult) throws IOException, OseeCoreException {
+ String[] outputCells = new String[5];
+ String testPlanOutput = getName(art);
+ String requirements = getRequirementsCellOutput(art);
+ String[] cells = new String[] {testPlanOutput, requirements, testProc, testStatus, testResult};
+ for (int i = 0; i < cells.length; i++) {
+ if (previousCells[i].equals(cells[i])) {
+ if (i == 0 || outputCells[i - 1].equals(" ")) {
+ outputCells[i] = " ";
+ } else {
+ outputCells[i] = cells[i];
+ }
+ } else {
+ outputCells[i] = cells[i];
+ }
+ }
+ previousCells = cells.clone();
+ report.append(AHTML.addRowMultiColumnTable(outputCells));
+ }
+
+ private void report() throws OseeCoreException, IOException {
+ report.append(AHTML.endMultiColumnTable());
+ XResultData rd = new XResultData();
+ rd.addRaw(report.toString());
+ rd.report("Test Plan Compliance Report", Manipulations.RAW_HTML);
+ }
+
+ private void init(VariableMap variableMap) throws OseeCoreException, IOException {
+ inputArtifacts = variableMap.getArtifacts("artifacts");
+ initReport();
+ load();
+ }
+
+ private void initReport() throws OseeCoreException, IOException {
+ report = new StringBuilder(AHTML.beginMultiColumnTable(100, 1));
+ report.append(AHTML.addHeaderRowMultiColumnTable(columnHeaders));
+ }
+
+ private void load() throws OseeCoreException {
+ testPlans = new ArrayList<Artifact>();
+ for (Artifact input : inputArtifacts) {
+ testPlans.addAll(input.getDescendants());
+ }
+ RelationManager.getRelatedArtifacts(testPlans, 1, CoreRelationTypes.Verification_Plan__Requirement);
+ Collection<Artifact> temp =
+ RelationManager.getRelatedArtifacts(testPlans, 1, CoreRelationTypes.Executes__Test_Procedure);
+ RelationManager.getRelatedArtifacts(temp, 1, CoreRelationTypes.Test_Unit_Result__Test_Result);
+ }
+
+ @Override
+ public String getXWidgetsXml() {
+ return "<xWidgets><XWidget xwidgetType=\"XListDropViewer\" displayName=\"artifacts\" /></xWidgets>";
+ }
+
+ @Override
+ public Collection<String> getCategories() {
+ return Arrays.asList("Define");
+ }
+
+ @Override
+ public String getName() {
+ return "Test Plan Compliance Report";
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateView.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateView.java
index 99dc56d485..4dd7d37e6b 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateView.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateView.java
@@ -1,120 +1,120 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.navigate;
-
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.IRegistryEventListener;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.osee.define.DefinePlugin;
-import org.eclipse.osee.framework.plugin.core.IActionable;
-import org.eclipse.osee.framework.ui.plugin.OseeUiActions;
-import org.eclipse.osee.framework.ui.plugin.PluginUiImage;
-import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite;
-import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem;
-import org.eclipse.osee.framework.ui.skynet.util.DbConnectionExceptionComposite;
-import org.eclipse.osee.framework.ui.swt.ImageManager;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.part.ViewPart;
-
-/**
- * Insert the type's description here.
- *
- * @see ViewPart
- */
-public class DefineNavigateView extends ViewPart implements IActionable {
-
- public static final String VIEW_ID = "org.eclipse.osee.define.DefineNavigateView";
- public static final String HELP_CONTEXT_ID = "defineNavigator";
- private XNavigateComposite xNavComp;
-
- /**
- * The constructor.
- */
- public DefineNavigateView() {
- }
-
- @Override
- public void setFocus() {
- }
-
- /*
- * @see IWorkbenchPart#createPartControl(Composite)
- */
- @Override
- public void createPartControl(Composite parent) {
- if (!DbConnectionExceptionComposite.dbConnectionIsOk(parent)) {
- return;
- }
-
- xNavComp = new XNavigateComposite(new DefineNavigateViewItems(), parent, SWT.NONE);
- xNavComp.getFilteredTree().getViewer().setSorter(new DefineNavigateViewerSorter());
-
- DefinePlugin.getInstance().setHelp(xNavComp, HELP_CONTEXT_ID, "org.eclipse.osee.define.help.ui");
- createActions();
- xNavComp.refresh();
- addExtensionPointListenerBecauseOfWorkspaceLoading();
- }
-
- private void addExtensionPointListenerBecauseOfWorkspaceLoading() {
- IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- extensionRegistry.addListener(new IRegistryEventListener() {
- @Override
- public void added(IExtension[] extensions) {
- xNavComp.refresh();
- }
-
- @Override
- public void added(IExtensionPoint[] extensionPoints) {
- xNavComp.refresh();
- }
-
- @Override
- public void removed(IExtension[] extensions) {
- xNavComp.refresh();
- }
-
- @Override
- public void removed(IExtensionPoint[] extensionPoints) {
- xNavComp.refresh();
- }
- }, "org.eclipse.osee.framework.ui.skynet.BlamOperation");
- }
-
- protected void createActions() {
-
- Action refreshAction = new Action("Refresh") {
-
- @Override
- public void run() {
- xNavComp.refresh();
- }
- };
- refreshAction.setImageDescriptor(ImageManager.getImageDescriptor(PluginUiImage.REFRESH));
- refreshAction.setToolTipText("Refresh");
-
- OseeUiActions.addBugToViewToolbar(this, this, DefinePlugin.getInstance(), VIEW_ID, "Define Navigator");
-
- }
-
- public String getActionDescription() {
- IStructuredSelection sel = (IStructuredSelection) xNavComp.getFilteredTree().getViewer().getSelection();
- if (sel.iterator().hasNext()) {
- return String.format("Currently Selected - %s", ((XNavigateItem) sel.iterator().next()).getName());
- }
- return "";
- }
-
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.navigate;
+
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IRegistryEventListener;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.osee.define.DefinePlugin;
+import org.eclipse.osee.framework.plugin.core.IActionable;
+import org.eclipse.osee.framework.ui.plugin.OseeUiActions;
+import org.eclipse.osee.framework.ui.plugin.PluginUiImage;
+import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite;
+import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem;
+import org.eclipse.osee.framework.ui.skynet.util.DbConnectionExceptionComposite;
+import org.eclipse.osee.framework.ui.swt.ImageManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * Insert the type's description here.
+ *
+ * @see ViewPart
+ */
+public class DefineNavigateView extends ViewPart implements IActionable {
+
+ public static final String VIEW_ID = "org.eclipse.osee.define.DefineNavigateView";
+ public static final String HELP_CONTEXT_ID = "defineNavigator";
+ private XNavigateComposite xNavComp;
+
+ /**
+ * The constructor.
+ */
+ public DefineNavigateView() {
+ }
+
+ @Override
+ public void setFocus() {
+ }
+
+ /*
+ * @see IWorkbenchPart#createPartControl(Composite)
+ */
+ @Override
+ public void createPartControl(Composite parent) {
+ if (!DbConnectionExceptionComposite.dbConnectionIsOk(parent)) {
+ return;
+ }
+
+ xNavComp = new XNavigateComposite(new DefineNavigateViewItems(), parent, SWT.NONE);
+ xNavComp.getFilteredTree().getViewer().setSorter(new DefineNavigateViewerSorter());
+
+ DefinePlugin.getInstance().setHelp(xNavComp, HELP_CONTEXT_ID, "org.eclipse.osee.define.help.ui");
+ createActions();
+ xNavComp.refresh();
+ addExtensionPointListenerBecauseOfWorkspaceLoading();
+ }
+
+ private void addExtensionPointListenerBecauseOfWorkspaceLoading() {
+ IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
+ extensionRegistry.addListener(new IRegistryEventListener() {
+ @Override
+ public void added(IExtension[] extensions) {
+ xNavComp.refresh();
+ }
+
+ @Override
+ public void added(IExtensionPoint[] extensionPoints) {
+ xNavComp.refresh();
+ }
+
+ @Override
+ public void removed(IExtension[] extensions) {
+ xNavComp.refresh();
+ }
+
+ @Override
+ public void removed(IExtensionPoint[] extensionPoints) {
+ xNavComp.refresh();
+ }
+ }, "org.eclipse.osee.framework.ui.skynet.BlamOperation");
+ }
+
+ protected void createActions() {
+
+ Action refreshAction = new Action("Refresh") {
+
+ @Override
+ public void run() {
+ xNavComp.refresh();
+ }
+ };
+ refreshAction.setImageDescriptor(ImageManager.getImageDescriptor(PluginUiImage.REFRESH));
+ refreshAction.setToolTipText("Refresh");
+
+ OseeUiActions.addBugToViewToolbar(this, this, DefinePlugin.getInstance(), VIEW_ID, "Define Navigator");
+
+ }
+
+ public String getActionDescription() {
+ IStructuredSelection sel = (IStructuredSelection) xNavComp.getFilteredTree().getViewer().getSelection();
+ if (sel.iterator().hasNext()) {
+ return String.format("Currently Selected - %s", ((XNavigateItem) sel.iterator().next()).getName());
+ }
+ return "";
+ }
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ITraceParser.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ITraceParser.java
index f2b6161d8f..118d66b35f 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ITraceParser.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ITraceParser.java
@@ -1,28 +1,28 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability;
-
-import java.nio.CharBuffer;
-import java.util.Collection;
-import org.eclipse.osee.define.traceability.data.TraceMark;
-
-/**
- * @author Roberto E. Escobar
- */
-public interface ITraceParser {
-
- public Collection<TraceMark> getTraceMarks(CharBuffer fileBuffer);
-
- public CharBuffer removeTraceMarks(CharBuffer fileBuffer);
-
- public boolean isTraceRemovalAllowed();
-
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability;
+
+import java.nio.CharBuffer;
+import java.util.Collection;
+import org.eclipse.osee.define.traceability.data.TraceMark;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface ITraceParser {
+
+ public Collection<TraceMark> getTraceMarks(CharBuffer fileBuffer);
+
+ public CharBuffer removeTraceMarks(CharBuffer fileBuffer);
+
+ public boolean isTraceRemovalAllowed();
+
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ITraceUnitResourceLocator.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ITraceUnitResourceLocator.java
index c403b8fd37..f23331e355 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ITraceUnitResourceLocator.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ITraceUnitResourceLocator.java
@@ -1,25 +1,25 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability;
-
-import java.nio.CharBuffer;
-import org.eclipse.osee.define.utility.IResourceLocator;
-
-/**
- * @author Roberto E. Escobar
- */
-public interface ITraceUnitResourceLocator extends IResourceLocator {
-
- public String UNIT_TYPE_UNKNOWN = "Unknown";
-
- public String getTraceUnitType(String name, CharBuffer fileBuffer);
-
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability;
+
+import java.nio.CharBuffer;
+import org.eclipse.osee.define.utility.IResourceLocator;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface ITraceUnitResourceLocator extends IResourceLocator {
+
+ public String UNIT_TYPE_UNKNOWN = "Unknown";
+
+ public String getTraceUnitType(String name, CharBuffer fileBuffer);
+
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityJob.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityJob.java
index e63134e07d..1bb22e6285 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityJob.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityJob.java
@@ -1,245 +1,245 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.regex.Pattern;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.osee.define.DefinePlugin;
-import org.eclipse.osee.define.traceability.data.RequirementData;
-import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
-import org.eclipse.osee.framework.core.exception.OseeArgumentException;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.jdk.core.type.CountingMap;
-import org.eclipse.osee.framework.jdk.core.type.HashCollection;
-import org.eclipse.osee.framework.jdk.core.type.Pair;
-import org.eclipse.osee.framework.jdk.core.util.Collections;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.jdk.core.util.io.CharBackedInputStream;
-import org.eclipse.osee.framework.jdk.core.util.io.xml.ExcelXmlWriter;
-import org.eclipse.osee.framework.jdk.core.util.io.xml.ISheetWriter;
-import org.eclipse.osee.framework.plugin.core.util.AIFile;
-import org.eclipse.osee.framework.plugin.core.util.OseeData;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.utility.Requirements;
-import org.eclipse.osee.framework.skynet.core.word.WordUtil;
-import org.eclipse.swt.program.Program;
-
-/**
- * @author Ryan D. Brooks
- */
-public class ImportTraceabilityJob extends Job {
- private static final Pattern filePattern = Pattern.compile(".*\\.(java|ada|ads|adb|c|h)");
- private static final TraceabilityExtractor traceExtractor = TraceabilityExtractor.getInstance();
-
- private final File file;
- private final RequirementData requirementData;
- private final ArrayList<String> noTraceabilityFiles;
- private final CountingMap<Artifact> reqsTraceCounts;
- private final HashCollection<Artifact, String> requirementToCodeUnitsMap;
- private final HashSet<String> codeUnits;
- private final CharBackedInputStream charBak;
- private final ISheetWriter excelWriter;
- private int pathPrefixLength;
- private final boolean writeOutResults;
-
- public ImportTraceabilityJob(File file, Branch branch, boolean writeOutResults) throws CoreException, IOException {
- super("Importing Traceability");
- this.file = file;
- this.requirementData = new RequirementData(branch);
- noTraceabilityFiles = new ArrayList<String>(200);
- reqsTraceCounts = new CountingMap<Artifact>();
- codeUnits = new HashSet<String>();
- requirementToCodeUnitsMap = new HashCollection<Artifact, String>(false, LinkedList.class);
- charBak = new CharBackedInputStream();
- excelWriter = new ExcelXmlWriter(charBak.getWriter());
- this.writeOutResults = writeOutResults;
- }
-
- @Override
- public IStatus run(IProgressMonitor monitor) {
- IStatus toReturn = Status.CANCEL_STATUS;
- try {
- monitor.beginTask("Importing From " + file.getName(), 100);
- monitor.worked(1);
-
- toReturn = requirementData.initialize(monitor);
- if (toReturn.getSeverity() == IStatus.OK) {
- if (monitor.isCanceled() != true) {
- if (writeOutResults) {
- excelWriter.startSheet("srs <--> code units", 6);
- excelWriter.writeRow("Req in DB", "Code Unit", "Requirement Name", "Requirement Trace Mark in Code");
- }
-
- if (file.isFile()) {
- for (String path : Lib.readListFromFile(file, true)) {
- monitor.subTask(path);
- handleDirectory(new File(path));
- if (monitor.isCanceled() == true) {
- break;
- }
- }
- } else if (file.isDirectory()) {
- handleDirectory(file);
- } else {
- throw new IllegalStateException("unexpected file system type");
- }
-
- if (writeOutResults && monitor.isCanceled() != true) {
- excelWriter.endSheet();
-
- writeNoTraceFilesSheet();
- writeTraceCountsSheet();
-
- excelWriter.endWorkbook();
- IFile iFile = OseeData.getIFile("CodeUnit_To_SRS_Trace.xml");
- AIFile.writeToFile(iFile, charBak);
- Program.launch(iFile.getLocation().toOSString());
- }
-
- if (monitor.isCanceled() != true) {
- toReturn = Status.OK_STATUS;
- } else {
- toReturn = Status.CANCEL_STATUS;
- }
- }
- }
- } catch (IOException ex) {
- toReturn = new Status(Status.ERROR, DefinePlugin.PLUGIN_ID, -1, ex.getLocalizedMessage(), ex);
- } catch (OseeCoreException ex) {
- toReturn = new Status(Status.ERROR, DefinePlugin.PLUGIN_ID, -1, ex.getLocalizedMessage(), ex);
- } finally {
- monitor.done();
- }
- return toReturn;
- }
-
- private void handleDirectory(File directory) throws IOException, OseeCoreException {
- if (directory == null || directory.getParentFile() == null) {
- throw new OseeArgumentException("The path " + directory + " is invalid.");
- }
-
- pathPrefixLength = directory.getParentFile().getAbsolutePath().length();
-
- for (File sourceFile : Lib.recursivelyListFiles(directory, filePattern)) {
- List<String> traceMarks = traceExtractor.getTraceMarksFromFile(sourceFile);
-
- int matchCount = 0;
- String relativePath = sourceFile.getPath().substring(pathPrefixLength);
- codeUnits.add(relativePath);
- for (String traceMark : traceMarks) {
- handelReqTrace(relativePath, traceMark);
- matchCount++;
- }
- if (matchCount == 0) {
- noTraceabilityFiles.add(relativePath);
- }
- }
- }
-
- private void writeNoTraceFilesSheet() throws IOException {
- excelWriter.startSheet("no match files", 1);
- for (String path : noTraceabilityFiles) {
- excelWriter.writeRow(path);
- }
- excelWriter.endSheet();
- }
-
- private void writeTraceCountsSheet() throws IOException, OseeCoreException {
- excelWriter.startSheet("trace counts", 3);
- excelWriter.writeRow("SRS Requirement from Database", "Trace Count", "Partitions");
- excelWriter.writeRow("% requirement coverage", null, "=1-COUNTIF(C2,&quot;0&quot;)/COUNTA(C2)");
-
- for (Artifact artifact : requirementData.getDirectSwRequirements()) {
- excelWriter.writeRow(artifact.getName(), String.valueOf(reqsTraceCounts.get(artifact)), Collections.toString(
- ",", artifact.getAttributesToStringList(Requirements.PARTITION)));
- }
-
- excelWriter.endSheet();
- }
-
- private void handelReqTrace(String path, String traceMark) throws OseeCoreException, IOException {
- String foundStr;
- Artifact reqArtifact = null;
-
- if (traceExtractor.isValidTraceMark(traceMark) != true) {
- foundStr = "invalid trace mark";
- } else {
- reqArtifact = requirementData.getRequirementFromTraceMark(traceMark);
- if (reqArtifact == null) {
- Pair<String, String> structuredRequirement = traceExtractor.getStructuredRequirement(traceMark);
- if (structuredRequirement != null) {
- reqArtifact = requirementData.getRequirementFromTraceMark(structuredRequirement.getFirst());
-
- if (reqArtifact == null) {
- foundStr = "no match in DB";
- } else {
- // for local data and procedures search requirement text for traceMark
- // example local data [{SUBSCRIBER}.ID] and example procedure {CURSOR_ACKNOWLEDGE}.NORMAL
- String textContent =
- WordUtil.textOnly(
- reqArtifact.getSoleAttributeValue(CoreAttributeTypes.WORD_TEMPLATE_CONTENT, "")).toUpperCase();
- if (textContent.contains(traceExtractor.getCanonicalRequirementName(structuredRequirement.getSecond()))) {
- foundStr = "req body match";
- } else {
- foundStr = "paritial match";
- }
- }
- } else {
- foundStr = "no match in DB";
- }
- } else {
- foundStr = fullMatch(reqArtifact);
- }
- }
-
- String name = null;
- if (reqArtifact != null) {
- name = reqArtifact.getName();
- requirementToCodeUnitsMap.put(reqArtifact, path);
- }
-
- if (writeOutResults) {
- excelWriter.writeRow(foundStr, path, name, traceMark);
- }
- }
-
- private String fullMatch(Artifact reqArtifact) {
- reqsTraceCounts.put(reqArtifact);
- return "full match";
- }
-
- public HashCollection<Artifact, String> getRequirementToCodeUnitsMap() {
- return requirementToCodeUnitsMap;
- }
-
- /**
- * @return the codeUnits
- */
- public HashSet<String> getCodeUnits() {
- return codeUnits;
- }
-
- public RequirementData getRequirementData() {
- return requirementData;
- }
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.regex.Pattern;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.osee.define.DefinePlugin;
+import org.eclipse.osee.define.traceability.data.RequirementData;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.exception.OseeArgumentException;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.jdk.core.type.CountingMap;
+import org.eclipse.osee.framework.jdk.core.type.HashCollection;
+import org.eclipse.osee.framework.jdk.core.type.Pair;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.jdk.core.util.io.CharBackedInputStream;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.ExcelXmlWriter;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.ISheetWriter;
+import org.eclipse.osee.framework.plugin.core.util.AIFile;
+import org.eclipse.osee.framework.plugin.core.util.OseeData;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.utility.Requirements;
+import org.eclipse.osee.framework.skynet.core.word.WordUtil;
+import org.eclipse.swt.program.Program;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class ImportTraceabilityJob extends Job {
+ private static final Pattern filePattern = Pattern.compile(".*\\.(java|ada|ads|adb|c|h)");
+ private static final TraceabilityExtractor traceExtractor = TraceabilityExtractor.getInstance();
+
+ private final File file;
+ private final RequirementData requirementData;
+ private final ArrayList<String> noTraceabilityFiles;
+ private final CountingMap<Artifact> reqsTraceCounts;
+ private final HashCollection<Artifact, String> requirementToCodeUnitsMap;
+ private final HashSet<String> codeUnits;
+ private final CharBackedInputStream charBak;
+ private final ISheetWriter excelWriter;
+ private int pathPrefixLength;
+ private final boolean writeOutResults;
+
+ public ImportTraceabilityJob(File file, Branch branch, boolean writeOutResults) throws CoreException, IOException {
+ super("Importing Traceability");
+ this.file = file;
+ this.requirementData = new RequirementData(branch);
+ noTraceabilityFiles = new ArrayList<String>(200);
+ reqsTraceCounts = new CountingMap<Artifact>();
+ codeUnits = new HashSet<String>();
+ requirementToCodeUnitsMap = new HashCollection<Artifact, String>(false, LinkedList.class);
+ charBak = new CharBackedInputStream();
+ excelWriter = new ExcelXmlWriter(charBak.getWriter());
+ this.writeOutResults = writeOutResults;
+ }
+
+ @Override
+ public IStatus run(IProgressMonitor monitor) {
+ IStatus toReturn = Status.CANCEL_STATUS;
+ try {
+ monitor.beginTask("Importing From " + file.getName(), 100);
+ monitor.worked(1);
+
+ toReturn = requirementData.initialize(monitor);
+ if (toReturn.getSeverity() == IStatus.OK) {
+ if (monitor.isCanceled() != true) {
+ if (writeOutResults) {
+ excelWriter.startSheet("srs <--> code units", 6);
+ excelWriter.writeRow("Req in DB", "Code Unit", "Requirement Name", "Requirement Trace Mark in Code");
+ }
+
+ if (file.isFile()) {
+ for (String path : Lib.readListFromFile(file, true)) {
+ monitor.subTask(path);
+ handleDirectory(new File(path));
+ if (monitor.isCanceled() == true) {
+ break;
+ }
+ }
+ } else if (file.isDirectory()) {
+ handleDirectory(file);
+ } else {
+ throw new IllegalStateException("unexpected file system type");
+ }
+
+ if (writeOutResults && monitor.isCanceled() != true) {
+ excelWriter.endSheet();
+
+ writeNoTraceFilesSheet();
+ writeTraceCountsSheet();
+
+ excelWriter.endWorkbook();
+ IFile iFile = OseeData.getIFile("CodeUnit_To_SRS_Trace.xml");
+ AIFile.writeToFile(iFile, charBak);
+ Program.launch(iFile.getLocation().toOSString());
+ }
+
+ if (monitor.isCanceled() != true) {
+ toReturn = Status.OK_STATUS;
+ } else {
+ toReturn = Status.CANCEL_STATUS;
+ }
+ }
+ }
+ } catch (IOException ex) {
+ toReturn = new Status(Status.ERROR, DefinePlugin.PLUGIN_ID, -1, ex.getLocalizedMessage(), ex);
+ } catch (OseeCoreException ex) {
+ toReturn = new Status(Status.ERROR, DefinePlugin.PLUGIN_ID, -1, ex.getLocalizedMessage(), ex);
+ } finally {
+ monitor.done();
+ }
+ return toReturn;
+ }
+
+ private void handleDirectory(File directory) throws IOException, OseeCoreException {
+ if (directory == null || directory.getParentFile() == null) {
+ throw new OseeArgumentException("The path " + directory + " is invalid.");
+ }
+
+ pathPrefixLength = directory.getParentFile().getAbsolutePath().length();
+
+ for (File sourceFile : Lib.recursivelyListFiles(directory, filePattern)) {
+ List<String> traceMarks = traceExtractor.getTraceMarksFromFile(sourceFile);
+
+ int matchCount = 0;
+ String relativePath = sourceFile.getPath().substring(pathPrefixLength);
+ codeUnits.add(relativePath);
+ for (String traceMark : traceMarks) {
+ handelReqTrace(relativePath, traceMark);
+ matchCount++;
+ }
+ if (matchCount == 0) {
+ noTraceabilityFiles.add(relativePath);
+ }
+ }
+ }
+
+ private void writeNoTraceFilesSheet() throws IOException {
+ excelWriter.startSheet("no match files", 1);
+ for (String path : noTraceabilityFiles) {
+ excelWriter.writeRow(path);
+ }
+ excelWriter.endSheet();
+ }
+
+ private void writeTraceCountsSheet() throws IOException, OseeCoreException {
+ excelWriter.startSheet("trace counts", 3);
+ excelWriter.writeRow("SRS Requirement from Database", "Trace Count", "Partitions");
+ excelWriter.writeRow("% requirement coverage", null, "=1-COUNTIF(C2,&quot;0&quot;)/COUNTA(C2)");
+
+ for (Artifact artifact : requirementData.getDirectSwRequirements()) {
+ excelWriter.writeRow(artifact.getName(), String.valueOf(reqsTraceCounts.get(artifact)), Collections.toString(
+ ",", artifact.getAttributesToStringList(Requirements.PARTITION)));
+ }
+
+ excelWriter.endSheet();
+ }
+
+ private void handelReqTrace(String path, String traceMark) throws OseeCoreException, IOException {
+ String foundStr;
+ Artifact reqArtifact = null;
+
+ if (traceExtractor.isValidTraceMark(traceMark) != true) {
+ foundStr = "invalid trace mark";
+ } else {
+ reqArtifact = requirementData.getRequirementFromTraceMark(traceMark);
+ if (reqArtifact == null) {
+ Pair<String, String> structuredRequirement = traceExtractor.getStructuredRequirement(traceMark);
+ if (structuredRequirement != null) {
+ reqArtifact = requirementData.getRequirementFromTraceMark(structuredRequirement.getFirst());
+
+ if (reqArtifact == null) {
+ foundStr = "no match in DB";
+ } else {
+ // for local data and procedures search requirement text for traceMark
+ // example local data [{SUBSCRIBER}.ID] and example procedure {CURSOR_ACKNOWLEDGE}.NORMAL
+ String textContent =
+ WordUtil.textOnly(
+ reqArtifact.getSoleAttributeValue(CoreAttributeTypes.WORD_TEMPLATE_CONTENT, "")).toUpperCase();
+ if (textContent.contains(traceExtractor.getCanonicalRequirementName(structuredRequirement.getSecond()))) {
+ foundStr = "req body match";
+ } else {
+ foundStr = "paritial match";
+ }
+ }
+ } else {
+ foundStr = "no match in DB";
+ }
+ } else {
+ foundStr = fullMatch(reqArtifact);
+ }
+ }
+
+ String name = null;
+ if (reqArtifact != null) {
+ name = reqArtifact.getName();
+ requirementToCodeUnitsMap.put(reqArtifact, path);
+ }
+
+ if (writeOutResults) {
+ excelWriter.writeRow(foundStr, path, name, traceMark);
+ }
+ }
+
+ private String fullMatch(Artifact reqArtifact) {
+ reqsTraceCounts.put(reqArtifact);
+ return "full match";
+ }
+
+ public HashCollection<Artifact, String> getRequirementToCodeUnitsMap() {
+ return requirementToCodeUnitsMap;
+ }
+
+ /**
+ * @return the codeUnits
+ */
+ public HashSet<String> getCodeUnits() {
+ return codeUnits;
+ }
+
+ public RequirementData getRequirementData() {
+ return requirementData;
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/TraceUnitExtensionManager.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/TraceUnitExtensionManager.java
index 3708716f56..730df8ef99 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/TraceUnitExtensionManager.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/TraceUnitExtensionManager.java
@@ -1,192 +1,192 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability;
-
-import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.osee.define.DefinePlugin;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.plugin.core.util.ExtensionPoints;
-import org.osgi.framework.Bundle;
-
-/**
- * @author Roberto E. Escobar
- */
-public class TraceUnitExtensionManager {
-
- private static final String TRACE_UNIT_HANDLER = "TraceUnitHandler";
- private static final String TRACE_UNIT_RESOURCE_LOCATOR = "TraceUnitResourceLocator";
- private static final String TRACE_UNIT_PARSER = "TraceUnitParser";
-
- private final Map<String, TraceHandler> contributions;
-
- private static TraceUnitExtensionManager instance = null;
-
- private TraceUnitExtensionManager() {
- contributions = new HashMap<String, TraceHandler>();
- }
-
- public static TraceUnitExtensionManager getInstance() {
- if (instance == null) {
- instance = new TraceUnitExtensionManager();
- }
- return instance;
- }
-
- public Set<String> getTraceUnitHandlerIds() throws OseeCoreException {
- checkObjectsLoaded();
- return contributions.keySet();
- }
-
- public Collection<TraceHandler> getAllTraceHandlers() throws OseeCoreException {
- checkObjectsLoaded();
- return contributions.values();
- }
-
- public TraceHandler getTraceUnitHandlerById(String id) throws OseeCoreException {
- checkObjectsLoaded();
- return contributions.get(id);
- }
-
- public ITraceParser getTraceParserById(String id) throws OseeCoreException {
- TraceHandler traceUnitHandler = getTraceUnitHandlerById(id);
- if (traceUnitHandler != null) {
- return traceUnitHandler.getParser();
- }
- return null;
- }
-
- public ITraceUnitResourceLocator getTraceUnitLocatorById(String id) throws OseeCoreException {
- TraceHandler traceUnitHandler = getTraceUnitHandlerById(id);
- if (traceUnitHandler != null) {
- return traceUnitHandler.getLocator();
- }
- return null;
- }
-
- public Collection<ITraceParser> getAllTraceParsers() throws OseeCoreException {
- checkObjectsLoaded();
- Set<ITraceParser> parsers = new HashSet<ITraceParser>();
- for (TraceHandler traceHandler : contributions.values()) {
- ITraceParser parser = traceHandler.getParser();
- if (parser != null) {
- parsers.add(parser);
- }
- }
- return parsers;
- }
-
- public Collection<ITraceUnitResourceLocator> getAllTraceUnitLocators() throws OseeCoreException {
- checkObjectsLoaded();
- Set<ITraceUnitResourceLocator> locators = new HashSet<ITraceUnitResourceLocator>();
- for (TraceHandler traceHandler : contributions.values()) {
- ITraceUnitResourceLocator locator = traceHandler.getLocator();
- if (locator != null) {
- locators.add(locator);
- }
- }
- return locators;
- }
-
- private void checkObjectsLoaded() throws OseeCoreException {
- if (contributions.isEmpty()) {
- List<IConfigurationElement> elements =
- ExtensionPoints.getExtensionElements(DefinePlugin.PLUGIN_ID + "." + TRACE_UNIT_HANDLER,
- TRACE_UNIT_HANDLER);
- for (IConfigurationElement element : elements) {
- IExtension extension = (IExtension) element.getParent();
- String identifier = extension.getUniqueIdentifier();
- String name = extension.getLabel();
- String bundleName = element.getContributor().getName();
- String parserClassName = element.getAttribute(TRACE_UNIT_PARSER);
- String locatorClassName = element.getAttribute(TRACE_UNIT_RESOURCE_LOCATOR);
-
- ITraceParser parser = (ITraceParser) loadClass(bundleName, parserClassName);
- ITraceUnitResourceLocator locator = (ITraceUnitResourceLocator) loadClass(bundleName, locatorClassName);
- if (parser != null && locator != null) {
- contributions.put(identifier, new TraceHandler(identifier, name, locator, parser));
- }
- }
- }
- }
-
- private Object loadClass(String bundleName, String className) throws OseeCoreException {
- Object object = null;
- if (Strings.isValid(bundleName) && Strings.isValid(className)) {
- try {
- Bundle bundle = Platform.getBundle(bundleName);
- Class<?> taskClass = bundle.loadClass(className);
- try {
- Method getInstance = taskClass.getMethod("getInstance", new Class[] {});
- object = getInstance.invoke(null, new Object[] {});
- } catch (Exception ex) {
- object = taskClass.newInstance();
- }
- } catch (Exception ex) {
- throw new OseeCoreException(String.format("Unable to Load: [%s - %s]", bundleName, className), ex);
- }
- }
- return object;
- }
-
- public static final class TraceHandler {
- private final String name;
- private final String id;
- private final ITraceUnitResourceLocator locator;
- private final ITraceParser parser;
-
- private TraceHandler(String id, String name, ITraceUnitResourceLocator locator, ITraceParser parser) {
- super();
- this.name = name;
- this.id = id;
- this.locator = locator;
- this.parser = parser;
- }
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * @return the id
- */
- public String getId() {
- return id;
- }
-
- /**
- * @return the locator
- */
- public ITraceUnitResourceLocator getLocator() {
- return locator;
- }
-
- /**
- * @return the parser
- */
- public ITraceParser getParser() {
- return parser;
- }
-
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.osee.define.DefinePlugin;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.plugin.core.util.ExtensionPoints;
+import org.osgi.framework.Bundle;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class TraceUnitExtensionManager {
+
+ private static final String TRACE_UNIT_HANDLER = "TraceUnitHandler";
+ private static final String TRACE_UNIT_RESOURCE_LOCATOR = "TraceUnitResourceLocator";
+ private static final String TRACE_UNIT_PARSER = "TraceUnitParser";
+
+ private final Map<String, TraceHandler> contributions;
+
+ private static TraceUnitExtensionManager instance = null;
+
+ private TraceUnitExtensionManager() {
+ contributions = new HashMap<String, TraceHandler>();
+ }
+
+ public static TraceUnitExtensionManager getInstance() {
+ if (instance == null) {
+ instance = new TraceUnitExtensionManager();
+ }
+ return instance;
+ }
+
+ public Set<String> getTraceUnitHandlerIds() throws OseeCoreException {
+ checkObjectsLoaded();
+ return contributions.keySet();
+ }
+
+ public Collection<TraceHandler> getAllTraceHandlers() throws OseeCoreException {
+ checkObjectsLoaded();
+ return contributions.values();
+ }
+
+ public TraceHandler getTraceUnitHandlerById(String id) throws OseeCoreException {
+ checkObjectsLoaded();
+ return contributions.get(id);
+ }
+
+ public ITraceParser getTraceParserById(String id) throws OseeCoreException {
+ TraceHandler traceUnitHandler = getTraceUnitHandlerById(id);
+ if (traceUnitHandler != null) {
+ return traceUnitHandler.getParser();
+ }
+ return null;
+ }
+
+ public ITraceUnitResourceLocator getTraceUnitLocatorById(String id) throws OseeCoreException {
+ TraceHandler traceUnitHandler = getTraceUnitHandlerById(id);
+ if (traceUnitHandler != null) {
+ return traceUnitHandler.getLocator();
+ }
+ return null;
+ }
+
+ public Collection<ITraceParser> getAllTraceParsers() throws OseeCoreException {
+ checkObjectsLoaded();
+ Set<ITraceParser> parsers = new HashSet<ITraceParser>();
+ for (TraceHandler traceHandler : contributions.values()) {
+ ITraceParser parser = traceHandler.getParser();
+ if (parser != null) {
+ parsers.add(parser);
+ }
+ }
+ return parsers;
+ }
+
+ public Collection<ITraceUnitResourceLocator> getAllTraceUnitLocators() throws OseeCoreException {
+ checkObjectsLoaded();
+ Set<ITraceUnitResourceLocator> locators = new HashSet<ITraceUnitResourceLocator>();
+ for (TraceHandler traceHandler : contributions.values()) {
+ ITraceUnitResourceLocator locator = traceHandler.getLocator();
+ if (locator != null) {
+ locators.add(locator);
+ }
+ }
+ return locators;
+ }
+
+ private void checkObjectsLoaded() throws OseeCoreException {
+ if (contributions.isEmpty()) {
+ List<IConfigurationElement> elements =
+ ExtensionPoints.getExtensionElements(DefinePlugin.PLUGIN_ID + "." + TRACE_UNIT_HANDLER,
+ TRACE_UNIT_HANDLER);
+ for (IConfigurationElement element : elements) {
+ IExtension extension = (IExtension) element.getParent();
+ String identifier = extension.getUniqueIdentifier();
+ String name = extension.getLabel();
+ String bundleName = element.getContributor().getName();
+ String parserClassName = element.getAttribute(TRACE_UNIT_PARSER);
+ String locatorClassName = element.getAttribute(TRACE_UNIT_RESOURCE_LOCATOR);
+
+ ITraceParser parser = (ITraceParser) loadClass(bundleName, parserClassName);
+ ITraceUnitResourceLocator locator = (ITraceUnitResourceLocator) loadClass(bundleName, locatorClassName);
+ if (parser != null && locator != null) {
+ contributions.put(identifier, new TraceHandler(identifier, name, locator, parser));
+ }
+ }
+ }
+ }
+
+ private Object loadClass(String bundleName, String className) throws OseeCoreException {
+ Object object = null;
+ if (Strings.isValid(bundleName) && Strings.isValid(className)) {
+ try {
+ Bundle bundle = Platform.getBundle(bundleName);
+ Class<?> taskClass = bundle.loadClass(className);
+ try {
+ Method getInstance = taskClass.getMethod("getInstance", new Class[] {});
+ object = getInstance.invoke(null, new Object[] {});
+ } catch (Exception ex) {
+ object = taskClass.newInstance();
+ }
+ } catch (Exception ex) {
+ throw new OseeCoreException(String.format("Unable to Load: [%s - %s]", bundleName, className), ex);
+ }
+ }
+ return object;
+ }
+
+ public static final class TraceHandler {
+ private final String name;
+ private final String id;
+ private final ITraceUnitResourceLocator locator;
+ private final ITraceParser parser;
+
+ private TraceHandler(String id, String name, ITraceUnitResourceLocator locator, ITraceParser parser) {
+ super();
+ this.name = name;
+ this.id = id;
+ this.locator = locator;
+ this.parser = parser;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @return the locator
+ */
+ public ITraceUnitResourceLocator getLocator() {
+ return locator;
+ }
+
+ /**
+ * @return the parser
+ */
+ public ITraceParser getParser() {
+ return parser;
+ }
+
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/TraceabilityExtractor.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/TraceabilityExtractor.java
index 270a43ec5e..681fe7b50a 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/TraceabilityExtractor.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/TraceabilityExtractor.java
@@ -1,139 +1,139 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.osee.define.traceability;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.CharBuffer;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.eclipse.osee.framework.jdk.core.type.Pair;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-
-/**
- * @author Roberto E. Escobar
- */
-public class TraceabilityExtractor {
- private static final Pattern ofpTraceabilityPattern = Pattern.compile("\\^SRS\\s*([^;\n\r]+);");
- private static final Pattern scriptTraceabilityPattern =
- Pattern.compile("addTraceability\\s*\\(\\s*\\\"\\s*(?:SubDD|SRS|CSID)?\\s*([^\\\"]+)\\\"");
- private static final Pattern invalidTraceabilityPattern = Pattern.compile("(\\[[A-Za-z]|USES_).*");
-
- private static final Pattern embeddedVolumePattern = Pattern.compile("\\{\\d+ (.*)\\}[ .]*");
- private static final Pattern nonWordPattern = Pattern.compile("[^A-Z_0-9]");
- private static final Pattern structuredReqNamePattern = Pattern.compile("\\[?(\\{[^\\}]+\\})(.*)");
- private static final Pattern stripTrailingReqNamePatern = Pattern.compile("(\\}|\\])(.*)");
-
- private static TraceabilityExtractor instance = null;
- private final Matcher scriptReqTraceMatcher;
- private final Matcher ofpReqTraceMatcher;
- private final Matcher invalidTraceMatcher;
- private final Matcher embeddedVolumeMatcher;
- private final Matcher nonWordMatcher;
- private final Matcher structuredRequirementMatcher;
- private final Matcher stripTrailingReqNameMatcher;
-
- private TraceabilityExtractor() {
- this.ofpReqTraceMatcher = ofpTraceabilityPattern.matcher("");
- this.scriptReqTraceMatcher = scriptTraceabilityPattern.matcher("");
- this.invalidTraceMatcher = invalidTraceabilityPattern.matcher("");
- this.embeddedVolumeMatcher = embeddedVolumePattern.matcher("");
- this.nonWordMatcher = nonWordPattern.matcher("");
- this.structuredRequirementMatcher = structuredReqNamePattern.matcher("");
- this.stripTrailingReqNameMatcher = stripTrailingReqNamePatern.matcher("");
- }
-
- public static TraceabilityExtractor getInstance() {
- if (instance == null) {
- instance = new TraceabilityExtractor();
- }
- return instance;
- }
-
- public List<String> getTraceMarksFromFile(File sourceFile) throws IOException {
- CharBuffer buffer = Lib.fileToCharBuffer(sourceFile);
- Matcher matcher = isScriptFile(sourceFile) ? getScriptTraceMarkMatcher() : getCodeTraceMarkMatcher();
- return getTraceMarks(buffer, matcher);
- }
-
- public List<String> getTraceMarks(CharBuffer buffer, Matcher matcher) {
- List<String> toReturn = new ArrayList<String>();
- matcher.reset(buffer);
- while (matcher.find() != false) {
- String mark = matcher.group(1);
- if (Strings.isValid(mark) != false) {
- toReturn.add(mark);
- }
- }
- return toReturn;
- }
-
- public boolean isValidTraceMark(String toCheck) {
- invalidTraceMatcher.reset(toCheck);
- return invalidTraceMatcher.matches() != true;
- }
-
- public Matcher getScriptTraceMarkMatcher() {
- return scriptReqTraceMatcher;
- }
-
- public Matcher getCodeTraceMarkMatcher() {
- return ofpReqTraceMatcher;
- }
-
- public boolean isScriptFile(File sourceFile) {
- return sourceFile.getName().endsWith("java");
- }
-
- public String getCanonicalRequirementName(String requirementMark) {
- String canonicalReqReference = requirementMark;
- if (Strings.isValid(requirementMark) != false) {
- canonicalReqReference = requirementMark.toUpperCase();
-
- embeddedVolumeMatcher.reset(canonicalReqReference);
- if (embeddedVolumeMatcher.find()) {
- canonicalReqReference = embeddedVolumeMatcher.group(1);
- }
-
- // Added to strip trailing artifact descriptive names } ... or ] ....
- stripTrailingReqNameMatcher.reset(canonicalReqReference);
- if (stripTrailingReqNameMatcher.find()) {
- String trail = stripTrailingReqNameMatcher.group(2);
- if (Strings.isValid(trail) && !trail.startsWith(".")) {
- canonicalReqReference = canonicalReqReference.substring(0, stripTrailingReqNameMatcher.start(1) + 1);
- }
- }
-
- nonWordMatcher.reset(canonicalReqReference);
- canonicalReqReference = nonWordMatcher.replaceAll("");
-
- }
- return canonicalReqReference;
- }
-
- // [{SUBSCRIBER}.ID] and example procedure {CURSOR_ACKNOWLEDGE}.NORMAL
- public Pair<String, String> getStructuredRequirement(String requirementMark) {
- Pair<String, String> toReturn = null;
- structuredRequirementMatcher.reset(requirementMark);
- if (structuredRequirementMatcher.matches() != false) {
- String primary = structuredRequirementMatcher.group(1);
- String secondary = structuredRequirementMatcher.group(2);
- if (Strings.isValid(primary) != false) {
- toReturn = new Pair<String, String>(primary, secondary);
- }
- }
- return toReturn;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.osee.define.traceability;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.CharBuffer;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.eclipse.osee.framework.jdk.core.type.Pair;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class TraceabilityExtractor {
+ private static final Pattern ofpTraceabilityPattern = Pattern.compile("\\^SRS\\s*([^;\n\r]+);");
+ private static final Pattern scriptTraceabilityPattern =
+ Pattern.compile("addTraceability\\s*\\(\\s*\\\"\\s*(?:SubDD|SRS|CSID)?\\s*([^\\\"]+)\\\"");
+ private static final Pattern invalidTraceabilityPattern = Pattern.compile("(\\[[A-Za-z]|USES_).*");
+
+ private static final Pattern embeddedVolumePattern = Pattern.compile("\\{\\d+ (.*)\\}[ .]*");
+ private static final Pattern nonWordPattern = Pattern.compile("[^A-Z_0-9]");
+ private static final Pattern structuredReqNamePattern = Pattern.compile("\\[?(\\{[^\\}]+\\})(.*)");
+ private static final Pattern stripTrailingReqNamePatern = Pattern.compile("(\\}|\\])(.*)");
+
+ private static TraceabilityExtractor instance = null;
+ private final Matcher scriptReqTraceMatcher;
+ private final Matcher ofpReqTraceMatcher;
+ private final Matcher invalidTraceMatcher;
+ private final Matcher embeddedVolumeMatcher;
+ private final Matcher nonWordMatcher;
+ private final Matcher structuredRequirementMatcher;
+ private final Matcher stripTrailingReqNameMatcher;
+
+ private TraceabilityExtractor() {
+ this.ofpReqTraceMatcher = ofpTraceabilityPattern.matcher("");
+ this.scriptReqTraceMatcher = scriptTraceabilityPattern.matcher("");
+ this.invalidTraceMatcher = invalidTraceabilityPattern.matcher("");
+ this.embeddedVolumeMatcher = embeddedVolumePattern.matcher("");
+ this.nonWordMatcher = nonWordPattern.matcher("");
+ this.structuredRequirementMatcher = structuredReqNamePattern.matcher("");
+ this.stripTrailingReqNameMatcher = stripTrailingReqNamePatern.matcher("");
+ }
+
+ public static TraceabilityExtractor getInstance() {
+ if (instance == null) {
+ instance = new TraceabilityExtractor();
+ }
+ return instance;
+ }
+
+ public List<String> getTraceMarksFromFile(File sourceFile) throws IOException {
+ CharBuffer buffer = Lib.fileToCharBuffer(sourceFile);
+ Matcher matcher = isScriptFile(sourceFile) ? getScriptTraceMarkMatcher() : getCodeTraceMarkMatcher();
+ return getTraceMarks(buffer, matcher);
+ }
+
+ public List<String> getTraceMarks(CharBuffer buffer, Matcher matcher) {
+ List<String> toReturn = new ArrayList<String>();
+ matcher.reset(buffer);
+ while (matcher.find() != false) {
+ String mark = matcher.group(1);
+ if (Strings.isValid(mark) != false) {
+ toReturn.add(mark);
+ }
+ }
+ return toReturn;
+ }
+
+ public boolean isValidTraceMark(String toCheck) {
+ invalidTraceMatcher.reset(toCheck);
+ return invalidTraceMatcher.matches() != true;
+ }
+
+ public Matcher getScriptTraceMarkMatcher() {
+ return scriptReqTraceMatcher;
+ }
+
+ public Matcher getCodeTraceMarkMatcher() {
+ return ofpReqTraceMatcher;
+ }
+
+ public boolean isScriptFile(File sourceFile) {
+ return sourceFile.getName().endsWith("java");
+ }
+
+ public String getCanonicalRequirementName(String requirementMark) {
+ String canonicalReqReference = requirementMark;
+ if (Strings.isValid(requirementMark) != false) {
+ canonicalReqReference = requirementMark.toUpperCase();
+
+ embeddedVolumeMatcher.reset(canonicalReqReference);
+ if (embeddedVolumeMatcher.find()) {
+ canonicalReqReference = embeddedVolumeMatcher.group(1);
+ }
+
+ // Added to strip trailing artifact descriptive names } ... or ] ....
+ stripTrailingReqNameMatcher.reset(canonicalReqReference);
+ if (stripTrailingReqNameMatcher.find()) {
+ String trail = stripTrailingReqNameMatcher.group(2);
+ if (Strings.isValid(trail) && !trail.startsWith(".")) {
+ canonicalReqReference = canonicalReqReference.substring(0, stripTrailingReqNameMatcher.start(1) + 1);
+ }
+ }
+
+ nonWordMatcher.reset(canonicalReqReference);
+ canonicalReqReference = nonWordMatcher.replaceAll("");
+
+ }
+ return canonicalReqReference;
+ }
+
+ // [{SUBSCRIBER}.ID] and example procedure {CURSOR_ACKNOWLEDGE}.NORMAL
+ public Pair<String, String> getStructuredRequirement(String requirementMark) {
+ Pair<String, String> toReturn = null;
+ structuredRequirementMatcher.reset(requirementMark);
+ if (structuredRequirementMatcher.matches() != false) {
+ String primary = structuredRequirementMatcher.group(1);
+ String secondary = structuredRequirementMatcher.group(2);
+ if (Strings.isValid(primary) != false) {
+ toReturn = new Pair<String, String>(primary, secondary);
+ }
+ }
+ return toReturn;
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/action/FindTraceUnitActionDelegate.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/action/FindTraceUnitActionDelegate.java
index 1a4cee6f79..2e9bca1a8a 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/action/FindTraceUnitActionDelegate.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/action/FindTraceUnitActionDelegate.java
@@ -1,67 +1,67 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability.action;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.osee.define.traceability.jobs.FindTraceUnitJob;
-import org.eclipse.osee.framework.plugin.core.util.Jobs;
-import org.eclipse.osee.framework.ui.skynet.commandHandlers.Handlers;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * @author Roberto E. Escobar
- */
-public class FindTraceUnitActionDelegate implements IWorkbenchWindowActionDelegate {
-
- @Override
- public void dispose() {
- }
-
- @Override
- public void init(IWorkbenchWindow window) {
- }
-
- @Override
- public void run(IAction action) {
- final String jobName = "Resource To Trace Unit Artifact";
- final List<IResource> resources = getSelectedItems();
- Jobs.startJob(new FindTraceUnitJob(jobName, resources.toArray(new IResource[resources.size()])), true);
- }
-
- @Override
- public void selectionChanged(IAction action, ISelection selection) {
- }
-
- private List<IResource> getSelectedItems() {
- ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getSelection();
- if (selection instanceof StructuredSelection) {
- List<IResource> selectedItems =
- Handlers.processSelectionObjects(IResource.class, (StructuredSelection) selection);
- List<IResource> toReturn = new ArrayList<IResource>();
- for (IResource resource : selectedItems) {
- if (resource instanceof IFile) {
- toReturn.add(resource);
- }
- }
- return toReturn;
- }
- return Collections.emptyList();
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability.action;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.osee.define.traceability.jobs.FindTraceUnitJob;
+import org.eclipse.osee.framework.plugin.core.util.Jobs;
+import org.eclipse.osee.framework.ui.skynet.commandHandlers.Handlers;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class FindTraceUnitActionDelegate implements IWorkbenchWindowActionDelegate {
+
+ @Override
+ public void dispose() {
+ }
+
+ @Override
+ public void init(IWorkbenchWindow window) {
+ }
+
+ @Override
+ public void run(IAction action) {
+ final String jobName = "Resource To Trace Unit Artifact";
+ final List<IResource> resources = getSelectedItems();
+ Jobs.startJob(new FindTraceUnitJob(jobName, resources.toArray(new IResource[resources.size()])), true);
+ }
+
+ @Override
+ public void selectionChanged(IAction action, ISelection selection) {
+ }
+
+ private List<IResource> getSelectedItems() {
+ ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getSelection();
+ if (selection instanceof StructuredSelection) {
+ List<IResource> selectedItems =
+ Handlers.processSelectionObjects(IResource.class, (StructuredSelection) selection);
+ List<IResource> toReturn = new ArrayList<IResource>();
+ for (IResource resource : selectedItems) {
+ if (resource instanceof IFile) {
+ toReturn.add(resource);
+ }
+ }
+ return toReturn;
+ }
+ return Collections.emptyList();
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/blam/RemoveTraceMarksFromTraceUnits.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/blam/RemoveTraceMarksFromTraceUnits.java
index a2ee0087a2..ba706310b6 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/blam/RemoveTraceMarksFromTraceUnits.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/blam/RemoveTraceMarksFromTraceUnits.java
@@ -1,350 +1,350 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability.blam;
-
-import java.io.File;
-import java.net.URI;
-import java.nio.CharBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.logging.Level;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.nebula.widgets.xviewer.XViewerColumn;
-import org.eclipse.nebula.widgets.xviewer.XViewerColumn.SortDataType;
-import org.eclipse.osee.define.DefinePlugin;
-import org.eclipse.osee.define.traceability.ITraceParser;
-import org.eclipse.osee.define.traceability.ITraceUnitResourceLocator;
-import org.eclipse.osee.define.traceability.TraceUnitExtensionManager;
-import org.eclipse.osee.define.traceability.TraceUnitExtensionManager.TraceHandler;
-import org.eclipse.osee.define.utility.IResourceHandler;
-import org.eclipse.osee.define.utility.UriResourceContentFinder;
-import org.eclipse.osee.framework.core.exception.OseeArgumentException;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.type.MutableBoolean;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.logging.OseeLog;
-import org.eclipse.osee.framework.plugin.core.util.IExceptionableRunnable;
-import org.eclipse.osee.framework.plugin.core.util.Jobs;
-import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
-import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
-import org.eclipse.osee.framework.ui.skynet.results.IResultsEditorProvider;
-import org.eclipse.osee.framework.ui.skynet.results.IResultsEditorTab;
-import org.eclipse.osee.framework.ui.skynet.results.ResultsEditor;
-import org.eclipse.osee.framework.ui.skynet.results.html.ResultsEditorHtmlTab;
-import org.eclipse.osee.framework.ui.skynet.results.table.IResultsXViewerRow;
-import org.eclipse.osee.framework.ui.skynet.results.table.ResultsEditorTableTab;
-import org.eclipse.osee.framework.ui.skynet.results.table.ResultsXViewerRow;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.progress.UIJob;
-
-/**
- * @author Roberto E. Escobar
- */
-public class RemoveTraceMarksFromTraceUnits extends AbstractBlam {
-
- @Override
- public String getName() {
- return "Remove Trace Marks from Resource";
- }
-
- @Override
- public Collection<String> getCategories() {
- return Arrays.asList("Define.Trace");
- }
-
- @Override
- public String getDescriptionUsage() {
- return "Removes trace marks from files selected.\n*** WARNING_OVERLAY: When \"Persist Changes\" is selected, files will be modified in place.\n There is no way to undo this operation - make sure you know what you are doing. ***\n ";
- }
-
- @Override
- public String getXWidgetsXml() {
- StringBuilder builder = new StringBuilder();
- builder.append("<xWidgets>");
- builder.append("<XWidget xwidgetType=\"XLabel\" displayName=\"Select File Or Folder (file can have a list of folders separated by newlines)\"/>");
- builder.append("<XWidget xwidgetType=\"XFileSelectionDialog\" displayName=\"Select File\" />");
- builder.append("<XWidget xwidgetType=\"XDirectorySelectionDialog\" displayName=\"Select Folder\" />");
- builder.append("<XWidget xwidgetType=\"XLabel\" displayName=\"Select Trace Types:\"/>");
- for (TraceHandler handler : getTraceHandlers()) {
- builder.append(getOperationsCheckBoxes(handler.getName()));
- }
- builder.append("<XWidget xwidgetType=\"XCheckBox\" displayName=\"Persist Changes\" labelAfter=\"true\" horizontalLabel=\"true\" />");
- builder.append("<XWidget xwidgetType=\"XCheckBox\" displayName=\"Include Sub-Folders\" labelAfter=\"true\" horizontalLabel=\"true\" />");
- builder.append("<XWidget xwidgetType=\"XCheckBox\" displayName=\"File With Embedded Paths\" labelAfter=\"true\" horizontalLabel=\"true\" />");
- builder.append("</xWidgets>");
- return builder.toString();
- }
-
- private TraceHandler getCheckedTraceHandler(VariableMap variableMap) throws OseeArgumentException {
- List<TraceHandler> toReturn = new ArrayList<TraceHandler>();
- for (TraceHandler handler : getTraceHandlers()) {
- if (variableMap.getBoolean(handler.getName())) {
- toReturn.add(handler);
- }
- }
- if (toReturn.isEmpty()) {
- throw new OseeArgumentException("Please select a trace type");
- } else if (toReturn.size() > 1) {
- throw new OseeArgumentException("Only (1) trace type can be selected per run. Please de-select other types.");
- }
- return toReturn.get(0);
- }
-
- private void checkPath(String filePath, String type) throws OseeArgumentException {
- if (!Strings.isValid(filePath)) {
- throw new OseeArgumentException(String.format("Please enter a valid %s path", type));
- }
- File file = new File(filePath);
- if (file == null || !file.exists()) {
- throw new OseeArgumentException(String.format("%s path [%s] is not accessible", type, filePath));
- }
- }
-
- private URI getSourceURI(VariableMap variableMap) throws OseeArgumentException {
- String filePath = variableMap.getString("Select File");
- String folderPath = variableMap.getString("Select Folder");
-
- String pathToUse = null;
- if (Strings.isValid(folderPath) && Strings.isValid(filePath)) {
- throw new OseeArgumentException("Enter file or folder but not both");
- } else if (Strings.isValid(folderPath)) {
- checkPath(folderPath, "folder");
- pathToUse = folderPath;
- } else {
- checkPath(filePath, "file");
- pathToUse = filePath;
- }
- return new File(pathToUse).toURI();
- }
-
- @Override
- public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
- try {
- final URI source = getSourceURI(variableMap);
- final TraceHandler handler = getCheckedTraceHandler(variableMap);
- final boolean isInPlaceStorageAllowed = variableMap.getBoolean("Persist Changes");
- final boolean isRecursionAllowed = variableMap.getBoolean("Include Sub-Folders");
- final boolean isFileWithMultiplePaths = variableMap.getBoolean("File With Embedded Paths");
-
- final int TOTAL_WORK = Integer.MAX_VALUE;
- monitor.beginTask(getName(), TOTAL_WORK);
-
- final MutableBoolean isProcessingAllowed = new MutableBoolean(false);
- Job job = new UIJob(getName()) {
-
- @Override
- public IStatus runInUIThread(IProgressMonitor monitor) {
- isProcessingAllowed.setValue(isInPlaceStorageAllowed ? MessageDialog.openConfirm(new Shell(),
- super.getName(), "Are you sure you want to remove trace marks from files?") : true);
- return Status.OK_STATUS;
- }
- };
- Jobs.startJob(job, true);
- job.join();
-
- if (isProcessingAllowed.getValue()) {
- ITraceUnitResourceLocator locator = handler.getLocator();
- ITraceParser parser = handler.getParser();
-
- ReportCreator reportCreator = new ReportCreator(monitor);
- UriResourceContentFinder resourceFinder =
- new UriResourceContentFinder(source, isRecursionAllowed, isFileWithMultiplePaths);
- resourceFinder.addLocator(locator,
- new TraceRemover(isInPlaceStorageAllowed, locator, parser, reportCreator));
-
- SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, TOTAL_WORK);
- resourceFinder.execute(subMonitor);
-
- reportCreator.openReport();
- }
- } finally {
- monitor.done();
- }
- }
-
- private String getOperationsCheckBoxes(String value) {
- StringBuilder builder = new StringBuilder();
- builder.append("<XWidget xwidgetType=\"XCheckBox\" displayName=\"");
- builder.append(value);
- builder.append("\" labelAfter=\"true\" horizontalLabel=\"true\"/>");
- return builder.toString();
- }
-
- private List<TraceHandler> getTraceHandlers() {
- List<TraceHandler> handlers = new ArrayList<TraceHandler>();
- try {
- for (TraceHandler handler : TraceUnitExtensionManager.getInstance().getAllTraceHandlers()) {
- if (handler.getParser().isTraceRemovalAllowed()) {
- handlers.add(handler);
- }
- }
- } catch (Exception ex) {
- OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
- }
- return handlers;
- }
-
- private static final class TraceRemover implements IResourceHandler {
- private final ITraceParser traceParser;
- private final ITraceUnitResourceLocator traceUnitLocator;
- private final boolean isStorageAllowed;
- private final ReportCreator reportCreator;
-
- public TraceRemover(boolean isStorageAllowed, ITraceUnitResourceLocator traceUnitLocator, ITraceParser traceParser, ReportCreator reportCreator) {
- this.isStorageAllowed = isStorageAllowed;
- this.traceParser = traceParser;
- this.traceUnitLocator = traceUnitLocator;
- this.reportCreator = reportCreator;
- }
-
- @Override
- public void onResourceFound(URI uriPath, String name, CharBuffer fileBuffer) {
- String traceUnitType = traceUnitLocator.getTraceUnitType(name, fileBuffer);
- if (Strings.isValid(traceUnitType) && !traceUnitType.equalsIgnoreCase(ITraceUnitResourceLocator.UNIT_TYPE_UNKNOWN)) {
- if (traceParser.isTraceRemovalAllowed()) {
- CharBuffer modifiedBuffer = traceParser.removeTraceMarks(fileBuffer);
- if (modifiedBuffer != null) {
- reportCreator.addModifiedItem(name, fileBuffer, modifiedBuffer);
- if (isStorageAllowed) {
- try {
- Lib.writeCharBufferToFile(modifiedBuffer, new File(uriPath));
- } catch (Exception ex) {
- OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
- }
- }
- } else {
- reportCreator.addNoChangeItem(name);
- }
- }
- }
- }
- }
-
- private final class ReportCreator {
- private List<IResultsXViewerRow> modifiedRows;
- private List<IResultsXViewerRow> noChangeRows;
- private final IProgressMonitor monitor;
-
- public ReportCreator(IProgressMonitor monitor) {
- this.modifiedRows = null;
- this.noChangeRows = null;
- this.monitor = monitor;
- }
-
- public void addModifiedItem(String name, CharBuffer original, CharBuffer modified) {
- if (modifiedRows == null) {
- modifiedRows = new ArrayList<IResultsXViewerRow>();
- }
- String delta = getDelta(original, modified);
- String[] entries = delta.split("(\\n|;)");
- for (String diff : entries) {
- diff = diff.trim();
- if (Strings.isValid(diff)) {
- modifiedRows.add(new ResultsXViewerRow(new String[] {name, diff}));
- }
- }
- }
-
- private String getDelta(CharBuffer original, CharBuffer modified) {
- StringBuilder buffer = new StringBuilder();
- int originalLength = original.length();
- int modifiedLength = modified.length();
-
- int origIndex = 0;
- int modIndex = 0;
- while (origIndex < originalLength || modIndex < modifiedLength) {
- char origChar = original.get(origIndex);
- char modChar = modified.get(modIndex);
- if (origChar != modChar) {
- buffer.append(origChar);
- if (originalLength > modifiedLength) {
- origIndex++;
- } else {
- modIndex++;
- }
- } else {
- origIndex++;
- modIndex++;
- }
- if (monitor.isCanceled()) {
- break;
- }
- }
- return buffer.toString();
- }
-
- public void addNoChangeItem(String... name) {
- if (noChangeRows == null) {
- noChangeRows = new ArrayList<IResultsXViewerRow>();
- }
- noChangeRows.add(new ResultsXViewerRow(name));
- }
-
- private List<XViewerColumn> getNoChangeHeaders() {
- return createColumnHelper("Trace Unit Without Change");
- }
-
- private List<XViewerColumn> getModifiedHeaders() {
- return createColumnHelper("Modified Trace Unit", "Removed");
- }
-
- private List<XViewerColumn> createColumnHelper(String... headers) {
- List<XViewerColumn> columns = new ArrayList<XViewerColumn>();
- for (String name : headers) {
- columns.add(new XViewerColumn(name, name, 80, SWT.LEFT, true, SortDataType.String, false, ""));
- }
- return columns;
- }
-
- public void openReport() {
- IExceptionableRunnable runnable = new IExceptionableRunnable() {
-
- @Override
- public IStatus run(IProgressMonitor monitor) throws Exception {
- ResultsEditor.open(new IResultsEditorProvider() {
- @Override
- public String getEditorName() throws OseeCoreException {
- return getName();
- }
-
- @Override
- public List<IResultsEditorTab> getResultsEditorTabs() throws OseeCoreException {
- List<IResultsEditorTab> resultsTabs = new ArrayList<IResultsEditorTab>();
- if (modifiedRows != null && !modifiedRows.isEmpty()) {
- resultsTabs.add(new ResultsEditorTableTab("Modified Trace Units", getModifiedHeaders(),
- modifiedRows));
- }
- if (noChangeRows != null && !noChangeRows.isEmpty()) {
- resultsTabs.add(new ResultsEditorTableTab("Unmodified Items", getNoChangeHeaders(),
- noChangeRows));
- }
- if (resultsTabs.isEmpty()) {
- resultsTabs.add(new ResultsEditorHtmlTab(getName(), getName(), "No changes Reported"));
- }
- return resultsTabs;
- }
- });
- return Status.OK_STATUS;
- }
- };
- Jobs.runInJob(getName(), runnable, DefinePlugin.class, DefinePlugin.PLUGIN_ID);
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability.blam;
+
+import java.io.File;
+import java.net.URI;
+import java.nio.CharBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.logging.Level;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.nebula.widgets.xviewer.XViewerColumn;
+import org.eclipse.nebula.widgets.xviewer.XViewerColumn.SortDataType;
+import org.eclipse.osee.define.DefinePlugin;
+import org.eclipse.osee.define.traceability.ITraceParser;
+import org.eclipse.osee.define.traceability.ITraceUnitResourceLocator;
+import org.eclipse.osee.define.traceability.TraceUnitExtensionManager;
+import org.eclipse.osee.define.traceability.TraceUnitExtensionManager.TraceHandler;
+import org.eclipse.osee.define.utility.IResourceHandler;
+import org.eclipse.osee.define.utility.UriResourceContentFinder;
+import org.eclipse.osee.framework.core.exception.OseeArgumentException;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.MutableBoolean;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.plugin.core.util.IExceptionableRunnable;
+import org.eclipse.osee.framework.plugin.core.util.Jobs;
+import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
+import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
+import org.eclipse.osee.framework.ui.skynet.results.IResultsEditorProvider;
+import org.eclipse.osee.framework.ui.skynet.results.IResultsEditorTab;
+import org.eclipse.osee.framework.ui.skynet.results.ResultsEditor;
+import org.eclipse.osee.framework.ui.skynet.results.html.ResultsEditorHtmlTab;
+import org.eclipse.osee.framework.ui.skynet.results.table.IResultsXViewerRow;
+import org.eclipse.osee.framework.ui.skynet.results.table.ResultsEditorTableTab;
+import org.eclipse.osee.framework.ui.skynet.results.table.ResultsXViewerRow;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.progress.UIJob;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class RemoveTraceMarksFromTraceUnits extends AbstractBlam {
+
+ @Override
+ public String getName() {
+ return "Remove Trace Marks from Resource";
+ }
+
+ @Override
+ public Collection<String> getCategories() {
+ return Arrays.asList("Define.Trace");
+ }
+
+ @Override
+ public String getDescriptionUsage() {
+ return "Removes trace marks from files selected.\n*** WARNING_OVERLAY: When \"Persist Changes\" is selected, files will be modified in place.\n There is no way to undo this operation - make sure you know what you are doing. ***\n ";
+ }
+
+ @Override
+ public String getXWidgetsXml() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("<xWidgets>");
+ builder.append("<XWidget xwidgetType=\"XLabel\" displayName=\"Select File Or Folder (file can have a list of folders separated by newlines)\"/>");
+ builder.append("<XWidget xwidgetType=\"XFileSelectionDialog\" displayName=\"Select File\" />");
+ builder.append("<XWidget xwidgetType=\"XDirectorySelectionDialog\" displayName=\"Select Folder\" />");
+ builder.append("<XWidget xwidgetType=\"XLabel\" displayName=\"Select Trace Types:\"/>");
+ for (TraceHandler handler : getTraceHandlers()) {
+ builder.append(getOperationsCheckBoxes(handler.getName()));
+ }
+ builder.append("<XWidget xwidgetType=\"XCheckBox\" displayName=\"Persist Changes\" labelAfter=\"true\" horizontalLabel=\"true\" />");
+ builder.append("<XWidget xwidgetType=\"XCheckBox\" displayName=\"Include Sub-Folders\" labelAfter=\"true\" horizontalLabel=\"true\" />");
+ builder.append("<XWidget xwidgetType=\"XCheckBox\" displayName=\"File With Embedded Paths\" labelAfter=\"true\" horizontalLabel=\"true\" />");
+ builder.append("</xWidgets>");
+ return builder.toString();
+ }
+
+ private TraceHandler getCheckedTraceHandler(VariableMap variableMap) throws OseeArgumentException {
+ List<TraceHandler> toReturn = new ArrayList<TraceHandler>();
+ for (TraceHandler handler : getTraceHandlers()) {
+ if (variableMap.getBoolean(handler.getName())) {
+ toReturn.add(handler);
+ }
+ }
+ if (toReturn.isEmpty()) {
+ throw new OseeArgumentException("Please select a trace type");
+ } else if (toReturn.size() > 1) {
+ throw new OseeArgumentException("Only (1) trace type can be selected per run. Please de-select other types.");
+ }
+ return toReturn.get(0);
+ }
+
+ private void checkPath(String filePath, String type) throws OseeArgumentException {
+ if (!Strings.isValid(filePath)) {
+ throw new OseeArgumentException(String.format("Please enter a valid %s path", type));
+ }
+ File file = new File(filePath);
+ if (file == null || !file.exists()) {
+ throw new OseeArgumentException(String.format("%s path [%s] is not accessible", type, filePath));
+ }
+ }
+
+ private URI getSourceURI(VariableMap variableMap) throws OseeArgumentException {
+ String filePath = variableMap.getString("Select File");
+ String folderPath = variableMap.getString("Select Folder");
+
+ String pathToUse = null;
+ if (Strings.isValid(folderPath) && Strings.isValid(filePath)) {
+ throw new OseeArgumentException("Enter file or folder but not both");
+ } else if (Strings.isValid(folderPath)) {
+ checkPath(folderPath, "folder");
+ pathToUse = folderPath;
+ } else {
+ checkPath(filePath, "file");
+ pathToUse = filePath;
+ }
+ return new File(pathToUse).toURI();
+ }
+
+ @Override
+ public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
+ try {
+ final URI source = getSourceURI(variableMap);
+ final TraceHandler handler = getCheckedTraceHandler(variableMap);
+ final boolean isInPlaceStorageAllowed = variableMap.getBoolean("Persist Changes");
+ final boolean isRecursionAllowed = variableMap.getBoolean("Include Sub-Folders");
+ final boolean isFileWithMultiplePaths = variableMap.getBoolean("File With Embedded Paths");
+
+ final int TOTAL_WORK = Integer.MAX_VALUE;
+ monitor.beginTask(getName(), TOTAL_WORK);
+
+ final MutableBoolean isProcessingAllowed = new MutableBoolean(false);
+ Job job = new UIJob(getName()) {
+
+ @Override
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ isProcessingAllowed.setValue(isInPlaceStorageAllowed ? MessageDialog.openConfirm(new Shell(),
+ super.getName(), "Are you sure you want to remove trace marks from files?") : true);
+ return Status.OK_STATUS;
+ }
+ };
+ Jobs.startJob(job, true);
+ job.join();
+
+ if (isProcessingAllowed.getValue()) {
+ ITraceUnitResourceLocator locator = handler.getLocator();
+ ITraceParser parser = handler.getParser();
+
+ ReportCreator reportCreator = new ReportCreator(monitor);
+ UriResourceContentFinder resourceFinder =
+ new UriResourceContentFinder(source, isRecursionAllowed, isFileWithMultiplePaths);
+ resourceFinder.addLocator(locator,
+ new TraceRemover(isInPlaceStorageAllowed, locator, parser, reportCreator));
+
+ SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, TOTAL_WORK);
+ resourceFinder.execute(subMonitor);
+
+ reportCreator.openReport();
+ }
+ } finally {
+ monitor.done();
+ }
+ }
+
+ private String getOperationsCheckBoxes(String value) {
+ StringBuilder builder = new StringBuilder();
+ builder.append("<XWidget xwidgetType=\"XCheckBox\" displayName=\"");
+ builder.append(value);
+ builder.append("\" labelAfter=\"true\" horizontalLabel=\"true\"/>");
+ return builder.toString();
+ }
+
+ private List<TraceHandler> getTraceHandlers() {
+ List<TraceHandler> handlers = new ArrayList<TraceHandler>();
+ try {
+ for (TraceHandler handler : TraceUnitExtensionManager.getInstance().getAllTraceHandlers()) {
+ if (handler.getParser().isTraceRemovalAllowed()) {
+ handlers.add(handler);
+ }
+ }
+ } catch (Exception ex) {
+ OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
+ }
+ return handlers;
+ }
+
+ private static final class TraceRemover implements IResourceHandler {
+ private final ITraceParser traceParser;
+ private final ITraceUnitResourceLocator traceUnitLocator;
+ private final boolean isStorageAllowed;
+ private final ReportCreator reportCreator;
+
+ public TraceRemover(boolean isStorageAllowed, ITraceUnitResourceLocator traceUnitLocator, ITraceParser traceParser, ReportCreator reportCreator) {
+ this.isStorageAllowed = isStorageAllowed;
+ this.traceParser = traceParser;
+ this.traceUnitLocator = traceUnitLocator;
+ this.reportCreator = reportCreator;
+ }
+
+ @Override
+ public void onResourceFound(URI uriPath, String name, CharBuffer fileBuffer) {
+ String traceUnitType = traceUnitLocator.getTraceUnitType(name, fileBuffer);
+ if (Strings.isValid(traceUnitType) && !traceUnitType.equalsIgnoreCase(ITraceUnitResourceLocator.UNIT_TYPE_UNKNOWN)) {
+ if (traceParser.isTraceRemovalAllowed()) {
+ CharBuffer modifiedBuffer = traceParser.removeTraceMarks(fileBuffer);
+ if (modifiedBuffer != null) {
+ reportCreator.addModifiedItem(name, fileBuffer, modifiedBuffer);
+ if (isStorageAllowed) {
+ try {
+ Lib.writeCharBufferToFile(modifiedBuffer, new File(uriPath));
+ } catch (Exception ex) {
+ OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
+ }
+ }
+ } else {
+ reportCreator.addNoChangeItem(name);
+ }
+ }
+ }
+ }
+ }
+
+ private final class ReportCreator {
+ private List<IResultsXViewerRow> modifiedRows;
+ private List<IResultsXViewerRow> noChangeRows;
+ private final IProgressMonitor monitor;
+
+ public ReportCreator(IProgressMonitor monitor) {
+ this.modifiedRows = null;
+ this.noChangeRows = null;
+ this.monitor = monitor;
+ }
+
+ public void addModifiedItem(String name, CharBuffer original, CharBuffer modified) {
+ if (modifiedRows == null) {
+ modifiedRows = new ArrayList<IResultsXViewerRow>();
+ }
+ String delta = getDelta(original, modified);
+ String[] entries = delta.split("(\\n|;)");
+ for (String diff : entries) {
+ diff = diff.trim();
+ if (Strings.isValid(diff)) {
+ modifiedRows.add(new ResultsXViewerRow(new String[] {name, diff}));
+ }
+ }
+ }
+
+ private String getDelta(CharBuffer original, CharBuffer modified) {
+ StringBuilder buffer = new StringBuilder();
+ int originalLength = original.length();
+ int modifiedLength = modified.length();
+
+ int origIndex = 0;
+ int modIndex = 0;
+ while (origIndex < originalLength || modIndex < modifiedLength) {
+ char origChar = original.get(origIndex);
+ char modChar = modified.get(modIndex);
+ if (origChar != modChar) {
+ buffer.append(origChar);
+ if (originalLength > modifiedLength) {
+ origIndex++;
+ } else {
+ modIndex++;
+ }
+ } else {
+ origIndex++;
+ modIndex++;
+ }
+ if (monitor.isCanceled()) {
+ break;
+ }
+ }
+ return buffer.toString();
+ }
+
+ public void addNoChangeItem(String... name) {
+ if (noChangeRows == null) {
+ noChangeRows = new ArrayList<IResultsXViewerRow>();
+ }
+ noChangeRows.add(new ResultsXViewerRow(name));
+ }
+
+ private List<XViewerColumn> getNoChangeHeaders() {
+ return createColumnHelper("Trace Unit Without Change");
+ }
+
+ private List<XViewerColumn> getModifiedHeaders() {
+ return createColumnHelper("Modified Trace Unit", "Removed");
+ }
+
+ private List<XViewerColumn> createColumnHelper(String... headers) {
+ List<XViewerColumn> columns = new ArrayList<XViewerColumn>();
+ for (String name : headers) {
+ columns.add(new XViewerColumn(name, name, 80, SWT.LEFT, true, SortDataType.String, false, ""));
+ }
+ return columns;
+ }
+
+ public void openReport() {
+ IExceptionableRunnable runnable = new IExceptionableRunnable() {
+
+ @Override
+ public IStatus run(IProgressMonitor monitor) throws Exception {
+ ResultsEditor.open(new IResultsEditorProvider() {
+ @Override
+ public String getEditorName() throws OseeCoreException {
+ return getName();
+ }
+
+ @Override
+ public List<IResultsEditorTab> getResultsEditorTabs() throws OseeCoreException {
+ List<IResultsEditorTab> resultsTabs = new ArrayList<IResultsEditorTab>();
+ if (modifiedRows != null && !modifiedRows.isEmpty()) {
+ resultsTabs.add(new ResultsEditorTableTab("Modified Trace Units", getModifiedHeaders(),
+ modifiedRows));
+ }
+ if (noChangeRows != null && !noChangeRows.isEmpty()) {
+ resultsTabs.add(new ResultsEditorTableTab("Unmodified Items", getNoChangeHeaders(),
+ noChangeRows));
+ }
+ if (resultsTabs.isEmpty()) {
+ resultsTabs.add(new ResultsEditorHtmlTab(getName(), getName(), "No changes Reported"));
+ }
+ return resultsTabs;
+ }
+ });
+ return Status.OK_STATUS;
+ }
+ };
+ Jobs.runInJob(getName(), runnable, DefinePlugin.class, DefinePlugin.PLUGIN_ID);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/blam/TraceReportBlam.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/blam/TraceReportBlam.java
index 1555324328..5e11461632 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/blam/TraceReportBlam.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/blam/TraceReportBlam.java
@@ -1,514 +1,514 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability.blam;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.nebula.widgets.xviewer.XViewerColumn;
-import org.eclipse.nebula.widgets.xviewer.XViewerColumn.SortDataType;
-import org.eclipse.osee.define.DefinePlugin;
-import org.eclipse.osee.define.traceability.data.BaseTraceDataCache;
-import org.eclipse.osee.define.traceability.data.CodeUnitData;
-import org.eclipse.osee.define.traceability.data.RequirementData;
-import org.eclipse.osee.define.traceability.data.TestUnitData;
-import org.eclipse.osee.define.traceability.report.AbstractArtifactRelationReport;
-import org.eclipse.osee.define.traceability.report.ArtifactToRelatedArtifact;
-import org.eclipse.osee.define.traceability.report.ArtifactTraceCount;
-import org.eclipse.osee.define.traceability.report.ArtifactsWithoutRelations;
-import org.eclipse.osee.define.traceability.report.IReportDataCollector;
-import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
-import org.eclipse.osee.framework.core.enums.IRelationEnumeration;
-import org.eclipse.osee.framework.core.exception.OseeArgumentException;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.jdk.core.util.io.CharBackedInputStream;
-import org.eclipse.osee.framework.jdk.core.util.io.xml.ExcelXmlWriter;
-import org.eclipse.osee.framework.jdk.core.util.io.xml.ISheetWriter;
-import org.eclipse.osee.framework.logging.OseeLog;
-import org.eclipse.osee.framework.plugin.core.util.AIFile;
-import org.eclipse.osee.framework.plugin.core.util.IExceptionableRunnable;
-import org.eclipse.osee.framework.plugin.core.util.Jobs;
-import org.eclipse.osee.framework.plugin.core.util.OseeData;
-import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
-import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
-import org.eclipse.osee.framework.ui.skynet.results.IResultsEditorProvider;
-import org.eclipse.osee.framework.ui.skynet.results.IResultsEditorTab;
-import org.eclipse.osee.framework.ui.skynet.results.ResultsEditor;
-import org.eclipse.osee.framework.ui.skynet.results.html.ResultsEditorHtmlTab;
-import org.eclipse.osee.framework.ui.skynet.results.table.IResultsXViewerRow;
-import org.eclipse.osee.framework.ui.skynet.results.table.ResultsEditorTableTab;
-import org.eclipse.osee.framework.ui.skynet.results.table.ResultsXViewerRow;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.program.Program;
-
-/**
- * @author Roberto E. Escobar
- */
-public class TraceReportBlam extends AbstractBlam {
- private final List<IResultsEditorTab> resultsTabs;
-
- public TraceReportBlam() {
- this.resultsTabs = new ArrayList<IResultsEditorTab>();
- }
-
- @Override
- public String getName() {
- return "Trace Report";
- }
-
- @Override
- public Collection<String> getCategories() {
- return Arrays.asList("Define.Trace");
- }
-
- @Override
- public String getDescriptionUsage() {
- return "Generates a trace report by scanning the selected branch for the selected trace unit types.";
- }
-
- private String getOperationsCheckBoxes(String value) {
- StringBuilder builder = new StringBuilder();
- builder.append("<XWidget xwidgetType=\"XCheckBox\" displayName=\"");
- builder.append(value);
- builder.append("\" labelAfter=\"true\" horizontalLabel=\"true\"/>");
- return builder.toString();
- }
-
- @Override
- public String getXWidgetsXml() {
- StringBuilder builder = new StringBuilder();
- builder.append("<xWidgets>");
- // builder.append("<XWidget xwidgetType=\"XFileSelectionDialog\" displayName=\"Select UI List File\" />");
- builder.append("<XWidget xwidgetType=\"XBranchSelectWidget\" displayName=\"Requirements Branch\" />");
- builder.append("<XWidget xwidgetType=\"XLabel\" displayName=\"Select Trace Types:\"/>");
- for (TraceTypeEnum traceType : TraceTypeEnum.values()) {
- builder.append(getOperationsCheckBoxes(traceType.asLabel()));
- }
- builder.append("<XWidget xwidgetType=\"XLabel\" displayName=\"Select Report Output:\"/>");
- builder.append("<XWidget xwidgetType=\"XCheckBox\" displayName=\"Result Editor\" labelAfter=\"true\" horizontalLabel=\"true\" />");
- builder.append("<XWidget xwidgetType=\"XCheckBox\" displayName=\"Excel\" labelAfter=\"true\" horizontalLabel=\"true\" />");
- builder.append("</xWidgets>");
- return builder.toString();
- }
-
- // private String getUIsFilterFromFile(IProgressMonitor monitor, String filePath) throws Exception {
- // String input;
- // File file = new File(filePath);
- // if (file == null || !file.exists()) {
- // throw new OseeArgumentException("UI list file not accessible");
- // }
- // IFileStore fileStore = EFS.getStore(file.toURI());
- // InputStream inputStream = null;
- // try {
- // inputStream = new BufferedInputStream(fileStore.openInputStream(EFS.NONE, monitor));
- // input = Lib.inputStreamToString(inputStream);
- // } finally {
- // if (inputStream != null) {
- // inputStream.close();
- // }
- // }
- // return input;
- // }
-
- private List<TraceTypeEnum> getCheckedTraceItems(VariableMap variableMap) throws OseeArgumentException {
- List<TraceTypeEnum> toReturn = new ArrayList<TraceTypeEnum>();
- for (TraceTypeEnum traceType : TraceTypeEnum.values()) {
- if (variableMap.getBoolean(traceType.asLabel())) {
- toReturn.add(traceType);
- }
- }
- return toReturn;
- }
-
- @Override
- public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
-
- // String fileName = variableMap.getString("Select UI List File");
- Branch branch = variableMap.getBranch("Requirements Branch");
- if (branch == null) {
- throw new OseeArgumentException("Branch cannot be null");
- }
- List<TraceTypeEnum> traceTypes = getCheckedTraceItems(variableMap);
- if (traceTypes.isEmpty()) {
- throw new OseeArgumentException("Please select a trace type");
- }
- boolean isExcelOutput = variableMap.getBoolean("Excel");
- boolean isResultEditorOutput = variableMap.getBoolean("Result Editor");
- OutputType output = OutputType.asType(isExcelOutput, isResultEditorOutput);
- if (output == null) {
- throw new OseeArgumentException("Please select a report output type");
- }
- ISheetWriter writer = null;
- CharBackedInputStream excelInputStream = null;
- Map<String, AbstractArtifactRelationReport> reports = new LinkedHashMap<String, AbstractArtifactRelationReport>();
- List<BaseTraceDataCache> traceCache = new ArrayList<BaseTraceDataCache>();
- RequirementData reqData = new RequirementData(branch);
- CodeUnitData codeUnit = null;
- TestUnitData testUnit = null;
- try {
- int TOTAL_WORK = Integer.MAX_VALUE;
- int TASK_WORK = TOTAL_WORK / 5;
- monitor.beginTask("Generate Trace Report", TOTAL_WORK);
-
- SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, TASK_WORK);
- reqData.initialize(subMonitor);
- traceCache.add(reqData);
-
- subMonitor = new SubProgressMonitor(monitor, TASK_WORK);
- if (TraceTypeEnum.Code_Unit_Trace.isIn(traceTypes)) {
- codeUnit = new CodeUnitData(branch);
- codeUnit.initialize(subMonitor);
- traceCache.add(codeUnit);
- } else {
- subMonitor.done();
- }
-
- subMonitor = new SubProgressMonitor(monitor, TASK_WORK);
- if (TraceTypeEnum.containsTestEnum(traceTypes)) {
- testUnit = new TestUnitData(branch);
- testUnit.initialize(subMonitor);
- traceCache.add(testUnit);
- } else {
- subMonitor.done();
- }
-
- if (!monitor.isCanceled()) {
- if (isExcelOutput(output)) {
- excelInputStream = new CharBackedInputStream();
- writer = new ExcelXmlWriter(excelInputStream.getWriter());
- }
- buildReport(reports, "Trace Unit <-> Requirement", output, writer, getTraceUnitToReqReport(codeUnit,
- testUnit, traceTypes));
- buildReport(reports, "Trace Unit with No Valid Traceability", output, writer,
- getDisconnectedTraceUnitReport(codeUnit, testUnit, traceTypes));
- buildReport(reports, "Requirement Trace Counts", output, writer, getTraceCountReport(reqData, traceTypes));
-
- subMonitor = new SubProgressMonitor(monitor, TASK_WORK);
- executeReports(subMonitor, reports);
- }
- subMonitor = new SubProgressMonitor(monitor, TASK_WORK);
- displayReports(subMonitor, writer, excelInputStream, output);
- } finally {
- try {
- for (AbstractArtifactRelationReport report : reports.values()) {
- report.clear();
- }
- for (BaseTraceDataCache cache : traceCache) {
- cache.reset();
- }
- reports.clear();
- traceCache.clear();
-
- resultsTabs.clear();
- } finally {
- monitor.done();
- }
- }
- }
-
- private void executeReports(IProgressMonitor monitor, Map<String, AbstractArtifactRelationReport> reports) throws OseeCoreException {
- try {
- monitor.beginTask("Create Reports", reports.size());
- for (String key : reports.keySet()) {
- monitor.subTask(String.format("Creating [%s]", key));
- if (monitor.isCanceled()) {
- break;
- }
- AbstractArtifactRelationReport report = reports.get(key);
- report.process(monitor);
- report.clear();
- monitor.worked(1);
- }
- } finally {
- monitor.done();
- }
- }
-
- private void displayReports(IProgressMonitor monitor, ISheetWriter excelWriter, CharBackedInputStream excelInputStream, OutputType outputType) throws IOException, OseeCoreException {
- try {
- boolean wasEmpty = resultsTabs == null || resultsTabs.isEmpty();
- monitor.beginTask("Open Reports", 2);
- boolean createReport = true;
- boolean excelValid = excelInputStream != null && excelInputStream.available() > 0;
-
- if (wasEmpty && !excelValid) {
- resultsTabs.add(new ResultsEditorHtmlTab(getName(), getName(), "Nothing Reported"));
- createReport = false;
- }
-
- openReport(resultsTabs);
- monitor.worked(1);
-
- if (createReport) {
- if (excelWriter != null && isExcelOutput(outputType)) {
- excelWriter.endWorkbook();
- openExcel(excelInputStream);
- }
- }
- monitor.worked(1);
- } finally {
- monitor.done();
- }
- }
-
- private boolean isExcelOutput(OutputType output) {
- return output == OutputType.Excel || output == OutputType.Both;
- }
-
- private boolean isEditorOutput(OutputType output) {
- return output == OutputType.ResultsEditor || output == OutputType.Both;
- }
-
- private void buildReport(Map<String, AbstractArtifactRelationReport> reports, String title, OutputType output, ISheetWriter writer, AbstractArtifactRelationReport report) {
- if (isExcelOutput(output)) {
- report.addReportDataCollector(new ExcelReport(title, writer));
- }
- if (isEditorOutput(output)) {
- report.addReportDataCollector(new ResultEditorReport(title));
- }
- reports.put(title, report);
- }
-
- private void openExcel(final InputStream inputStream) throws OseeCoreException {
- IFile iFile = OseeData.getIFile("Trace_Report_" + Lib.getDateTimeString() + ".xml");
- AIFile.writeToFile(iFile, inputStream);
- if (inputStream != null) {
- try {
- inputStream.close();
- } catch (IOException ex) {
- // Do Nothing
- }
- }
- Program.launch(iFile.getLocation().toOSString());
- }
-
- private void openReport(final List<IResultsEditorTab> resultsTabs) {
- final List<IResultsEditorTab> results = new ArrayList<IResultsEditorTab>(resultsTabs);
- if (!results.isEmpty()) {
- IExceptionableRunnable runnable = new IExceptionableRunnable() {
-
- @Override
- public IStatus run(IProgressMonitor monitor) throws Exception {
- ResultsEditor.open(new IResultsEditorProvider() {
- @Override
- public String getEditorName() throws OseeCoreException {
- return getName();
- }
-
- @Override
- public List<IResultsEditorTab> getResultsEditorTabs() throws OseeCoreException {
- return results;
- }
- });
- return Status.OK_STATUS;
- }
- };
- Jobs.runInJob(getName(), runnable, DefinePlugin.class, DefinePlugin.PLUGIN_ID);
- }
- }
-
- private void addRelationToCheck(List<TraceTypeEnum> traceTypes, AbstractArtifactRelationReport report, boolean fromTraceUnit) {
- for (TraceTypeEnum traceTypeEnum : traceTypes) {
- IRelationEnumeration relation =
- fromTraceUnit ? traceTypeEnum.getRelatedToRequirement() : traceTypeEnum.getRelatedToTraceUnit();
- report.addRelationToCheck(relation);
- }
- }
-
- private void addArtifacts(CodeUnitData codeUnit, TestUnitData testUnit, List<TraceTypeEnum> traceTypes, AbstractArtifactRelationReport report) {
- if (TraceTypeEnum.Code_Unit_Trace.isIn(traceTypes)) {
- report.setArtifacts(codeUnit.getAllCodeUnits());
- }
- if (TraceTypeEnum.Verified_By_Test_Unit_Trace.isIn(traceTypes)) {
- report.setArtifacts(testUnit.getTestCases());
- }
- if (TraceTypeEnum.Used_By_Test_Unit_Trace.isIn(traceTypes)) {
- report.setArtifacts(testUnit.getTestSupportItems());
- }
- if (TraceTypeEnum.Validation_By_TestProcedure.isIn(traceTypes)) {
- report.setArtifacts(testUnit.getTestProcedures());
- }
- }
-
- private AbstractArtifactRelationReport getTraceCountReport(RequirementData reqData, List<TraceTypeEnum> traceTypes) {
- ArtifactTraceCount report = new ArtifactTraceCount();
- report.setArtifacts(reqData.getDirectSwRequirements());
- addRelationToCheck(traceTypes, report, false);
- return report;
- }
-
- private AbstractArtifactRelationReport getDisconnectedTraceUnitReport(CodeUnitData codeUnit, TestUnitData testUnit, List<TraceTypeEnum> traceTypes) {
- ArtifactsWithoutRelations report = new ArtifactsWithoutRelations();
- addArtifacts(codeUnit, testUnit, traceTypes, report);
- addRelationToCheck(traceTypes, report, true);
- return report;
- }
-
- private AbstractArtifactRelationReport getTraceUnitToReqReport(CodeUnitData codeUnit, TestUnitData testUnit, List<TraceTypeEnum> traceTypes) {
- ArtifactToRelatedArtifact report = new ArtifactToRelatedArtifact();
- addArtifacts(codeUnit, testUnit, traceTypes, report);
- addRelationToCheck(traceTypes, report, true);
- return report;
- }
-
- private enum OutputType {
- ResultsEditor,
- Excel,
- Both;
-
- public static OutputType asType(boolean isExcel, boolean isEditor) {
- if (isExcel && isEditor) {
- return OutputType.Both;
- } else if (isExcel) {
- return OutputType.Excel;
- } else if (isEditor) {
- return OutputType.ResultsEditor;
- }
- return null;
- }
- }
-
- private enum TraceTypeEnum {
- Code_Unit_Trace(CoreRelationTypes.CodeRequirement_Requirement, CoreRelationTypes.CodeRequirement_CodeUnit, false),
- Verified_By_Test_Unit_Trace(
- CoreRelationTypes.Verification__Requirement,
- CoreRelationTypes.Verification__Verifier,
- true),
- Used_By_Test_Unit_Trace(CoreRelationTypes.Uses__Requirement, CoreRelationTypes.Uses__TestUnit, true),
- Validation_By_TestProcedure(
- CoreRelationTypes.Validation__Requirement,
- CoreRelationTypes.Validation__Validator,
- true);
-
- private IRelationEnumeration toReq;
- private IRelationEnumeration toTraceUnit;
- private boolean isTestType;
-
- TraceTypeEnum(IRelationEnumeration toReq, IRelationEnumeration toTraceUnit, boolean isTestType) {
- this.toReq = toReq;
- this.toTraceUnit = toTraceUnit;
- this.isTestType = isTestType;
- }
-
- public IRelationEnumeration getRelatedToRequirement() {
- return toReq;
- }
-
- public IRelationEnumeration getRelatedToTraceUnit() {
- return toTraceUnit;
- }
-
- public boolean isTestType() {
- return isTestType;
- }
-
- public String asLabel() {
- return name().replaceAll("_", " ");
- }
-
- public boolean isIn(Collection<TraceTypeEnum> traceTypes) {
- return traceTypes.contains(this);
- }
-
- public static boolean containsTestEnum(List<TraceTypeEnum> traceTypes) {
- for (TraceTypeEnum type : TraceTypeEnum.values()) {
- if (type.isTestType() && type.isIn(traceTypes)) {
- return true;
- }
- }
- return false;
- }
- }
-
- private static final class ExcelReport implements IReportDataCollector {
- private final String title;
- private final ISheetWriter sheetWriter;
-
- public ExcelReport(String title, ISheetWriter sheetWriter) {
- this.sheetWriter = sheetWriter;
- this.title = title;
- }
-
- @Override
- public void addRow(String... data) {
- try {
- sheetWriter.writeRow(data);
- } catch (IOException ex) {
- OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
- }
- }
-
- @Override
- public void addTableHeader(String... header) {
- try {
- sheetWriter.startSheet(title, header.length);
- sheetWriter.writeRow(header);
- } catch (IOException ex) {
- OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
- }
- }
-
- @Override
- public void endTable() {
- try {
- sheetWriter.endSheet();
- } catch (IOException ex) {
- OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
- }
- }
- }
-
- private final class ResultEditorReport implements IReportDataCollector {
- private final String title;
- private List<XViewerColumn> columns;
- private List<IResultsXViewerRow> rows;
-
- public ResultEditorReport(String title) {
- this.title = title;
- this.columns = null;
- this.rows = null;
- }
-
- @Override
- public void addRow(String... data) {
- if (rows == null) {
- rows = new ArrayList<IResultsXViewerRow>();
- }
- rows.add(new ResultsXViewerRow(data));
- }
-
- @Override
- public void addTableHeader(String... header) {
- this.columns = new ArrayList<XViewerColumn>();
- for (String name : header) {
- columns.add(new XViewerColumn(name, name, 80, SWT.LEFT, true, SortDataType.String, false, ""));
- }
- }
-
- @Override
- public void endTable() {
- resultsTabs.add(new ResultsEditorTableTab(title, columns, rows));
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability.blam;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.nebula.widgets.xviewer.XViewerColumn;
+import org.eclipse.nebula.widgets.xviewer.XViewerColumn.SortDataType;
+import org.eclipse.osee.define.DefinePlugin;
+import org.eclipse.osee.define.traceability.data.BaseTraceDataCache;
+import org.eclipse.osee.define.traceability.data.CodeUnitData;
+import org.eclipse.osee.define.traceability.data.RequirementData;
+import org.eclipse.osee.define.traceability.data.TestUnitData;
+import org.eclipse.osee.define.traceability.report.AbstractArtifactRelationReport;
+import org.eclipse.osee.define.traceability.report.ArtifactToRelatedArtifact;
+import org.eclipse.osee.define.traceability.report.ArtifactTraceCount;
+import org.eclipse.osee.define.traceability.report.ArtifactsWithoutRelations;
+import org.eclipse.osee.define.traceability.report.IReportDataCollector;
+import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.enums.IRelationEnumeration;
+import org.eclipse.osee.framework.core.exception.OseeArgumentException;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.jdk.core.util.io.CharBackedInputStream;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.ExcelXmlWriter;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.ISheetWriter;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.plugin.core.util.AIFile;
+import org.eclipse.osee.framework.plugin.core.util.IExceptionableRunnable;
+import org.eclipse.osee.framework.plugin.core.util.Jobs;
+import org.eclipse.osee.framework.plugin.core.util.OseeData;
+import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
+import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
+import org.eclipse.osee.framework.ui.skynet.results.IResultsEditorProvider;
+import org.eclipse.osee.framework.ui.skynet.results.IResultsEditorTab;
+import org.eclipse.osee.framework.ui.skynet.results.ResultsEditor;
+import org.eclipse.osee.framework.ui.skynet.results.html.ResultsEditorHtmlTab;
+import org.eclipse.osee.framework.ui.skynet.results.table.IResultsXViewerRow;
+import org.eclipse.osee.framework.ui.skynet.results.table.ResultsEditorTableTab;
+import org.eclipse.osee.framework.ui.skynet.results.table.ResultsXViewerRow;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.program.Program;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class TraceReportBlam extends AbstractBlam {
+ private final List<IResultsEditorTab> resultsTabs;
+
+ public TraceReportBlam() {
+ this.resultsTabs = new ArrayList<IResultsEditorTab>();
+ }
+
+ @Override
+ public String getName() {
+ return "Trace Report";
+ }
+
+ @Override
+ public Collection<String> getCategories() {
+ return Arrays.asList("Define.Trace");
+ }
+
+ @Override
+ public String getDescriptionUsage() {
+ return "Generates a trace report by scanning the selected branch for the selected trace unit types.";
+ }
+
+ private String getOperationsCheckBoxes(String value) {
+ StringBuilder builder = new StringBuilder();
+ builder.append("<XWidget xwidgetType=\"XCheckBox\" displayName=\"");
+ builder.append(value);
+ builder.append("\" labelAfter=\"true\" horizontalLabel=\"true\"/>");
+ return builder.toString();
+ }
+
+ @Override
+ public String getXWidgetsXml() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("<xWidgets>");
+ // builder.append("<XWidget xwidgetType=\"XFileSelectionDialog\" displayName=\"Select UI List File\" />");
+ builder.append("<XWidget xwidgetType=\"XBranchSelectWidget\" displayName=\"Requirements Branch\" />");
+ builder.append("<XWidget xwidgetType=\"XLabel\" displayName=\"Select Trace Types:\"/>");
+ for (TraceTypeEnum traceType : TraceTypeEnum.values()) {
+ builder.append(getOperationsCheckBoxes(traceType.asLabel()));
+ }
+ builder.append("<XWidget xwidgetType=\"XLabel\" displayName=\"Select Report Output:\"/>");
+ builder.append("<XWidget xwidgetType=\"XCheckBox\" displayName=\"Result Editor\" labelAfter=\"true\" horizontalLabel=\"true\" />");
+ builder.append("<XWidget xwidgetType=\"XCheckBox\" displayName=\"Excel\" labelAfter=\"true\" horizontalLabel=\"true\" />");
+ builder.append("</xWidgets>");
+ return builder.toString();
+ }
+
+ // private String getUIsFilterFromFile(IProgressMonitor monitor, String filePath) throws Exception {
+ // String input;
+ // File file = new File(filePath);
+ // if (file == null || !file.exists()) {
+ // throw new OseeArgumentException("UI list file not accessible");
+ // }
+ // IFileStore fileStore = EFS.getStore(file.toURI());
+ // InputStream inputStream = null;
+ // try {
+ // inputStream = new BufferedInputStream(fileStore.openInputStream(EFS.NONE, monitor));
+ // input = Lib.inputStreamToString(inputStream);
+ // } finally {
+ // if (inputStream != null) {
+ // inputStream.close();
+ // }
+ // }
+ // return input;
+ // }
+
+ private List<TraceTypeEnum> getCheckedTraceItems(VariableMap variableMap) throws OseeArgumentException {
+ List<TraceTypeEnum> toReturn = new ArrayList<TraceTypeEnum>();
+ for (TraceTypeEnum traceType : TraceTypeEnum.values()) {
+ if (variableMap.getBoolean(traceType.asLabel())) {
+ toReturn.add(traceType);
+ }
+ }
+ return toReturn;
+ }
+
+ @Override
+ public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
+
+ // String fileName = variableMap.getString("Select UI List File");
+ Branch branch = variableMap.getBranch("Requirements Branch");
+ if (branch == null) {
+ throw new OseeArgumentException("Branch cannot be null");
+ }
+ List<TraceTypeEnum> traceTypes = getCheckedTraceItems(variableMap);
+ if (traceTypes.isEmpty()) {
+ throw new OseeArgumentException("Please select a trace type");
+ }
+ boolean isExcelOutput = variableMap.getBoolean("Excel");
+ boolean isResultEditorOutput = variableMap.getBoolean("Result Editor");
+ OutputType output = OutputType.asType(isExcelOutput, isResultEditorOutput);
+ if (output == null) {
+ throw new OseeArgumentException("Please select a report output type");
+ }
+ ISheetWriter writer = null;
+ CharBackedInputStream excelInputStream = null;
+ Map<String, AbstractArtifactRelationReport> reports = new LinkedHashMap<String, AbstractArtifactRelationReport>();
+ List<BaseTraceDataCache> traceCache = new ArrayList<BaseTraceDataCache>();
+ RequirementData reqData = new RequirementData(branch);
+ CodeUnitData codeUnit = null;
+ TestUnitData testUnit = null;
+ try {
+ int TOTAL_WORK = Integer.MAX_VALUE;
+ int TASK_WORK = TOTAL_WORK / 5;
+ monitor.beginTask("Generate Trace Report", TOTAL_WORK);
+
+ SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, TASK_WORK);
+ reqData.initialize(subMonitor);
+ traceCache.add(reqData);
+
+ subMonitor = new SubProgressMonitor(monitor, TASK_WORK);
+ if (TraceTypeEnum.Code_Unit_Trace.isIn(traceTypes)) {
+ codeUnit = new CodeUnitData(branch);
+ codeUnit.initialize(subMonitor);
+ traceCache.add(codeUnit);
+ } else {
+ subMonitor.done();
+ }
+
+ subMonitor = new SubProgressMonitor(monitor, TASK_WORK);
+ if (TraceTypeEnum.containsTestEnum(traceTypes)) {
+ testUnit = new TestUnitData(branch);
+ testUnit.initialize(subMonitor);
+ traceCache.add(testUnit);
+ } else {
+ subMonitor.done();
+ }
+
+ if (!monitor.isCanceled()) {
+ if (isExcelOutput(output)) {
+ excelInputStream = new CharBackedInputStream();
+ writer = new ExcelXmlWriter(excelInputStream.getWriter());
+ }
+ buildReport(reports, "Trace Unit <-> Requirement", output, writer, getTraceUnitToReqReport(codeUnit,
+ testUnit, traceTypes));
+ buildReport(reports, "Trace Unit with No Valid Traceability", output, writer,
+ getDisconnectedTraceUnitReport(codeUnit, testUnit, traceTypes));
+ buildReport(reports, "Requirement Trace Counts", output, writer, getTraceCountReport(reqData, traceTypes));
+
+ subMonitor = new SubProgressMonitor(monitor, TASK_WORK);
+ executeReports(subMonitor, reports);
+ }
+ subMonitor = new SubProgressMonitor(monitor, TASK_WORK);
+ displayReports(subMonitor, writer, excelInputStream, output);
+ } finally {
+ try {
+ for (AbstractArtifactRelationReport report : reports.values()) {
+ report.clear();
+ }
+ for (BaseTraceDataCache cache : traceCache) {
+ cache.reset();
+ }
+ reports.clear();
+ traceCache.clear();
+
+ resultsTabs.clear();
+ } finally {
+ monitor.done();
+ }
+ }
+ }
+
+ private void executeReports(IProgressMonitor monitor, Map<String, AbstractArtifactRelationReport> reports) throws OseeCoreException {
+ try {
+ monitor.beginTask("Create Reports", reports.size());
+ for (String key : reports.keySet()) {
+ monitor.subTask(String.format("Creating [%s]", key));
+ if (monitor.isCanceled()) {
+ break;
+ }
+ AbstractArtifactRelationReport report = reports.get(key);
+ report.process(monitor);
+ report.clear();
+ monitor.worked(1);
+ }
+ } finally {
+ monitor.done();
+ }
+ }
+
+ private void displayReports(IProgressMonitor monitor, ISheetWriter excelWriter, CharBackedInputStream excelInputStream, OutputType outputType) throws IOException, OseeCoreException {
+ try {
+ boolean wasEmpty = resultsTabs == null || resultsTabs.isEmpty();
+ monitor.beginTask("Open Reports", 2);
+ boolean createReport = true;
+ boolean excelValid = excelInputStream != null && excelInputStream.available() > 0;
+
+ if (wasEmpty && !excelValid) {
+ resultsTabs.add(new ResultsEditorHtmlTab(getName(), getName(), "Nothing Reported"));
+ createReport = false;
+ }
+
+ openReport(resultsTabs);
+ monitor.worked(1);
+
+ if (createReport) {
+ if (excelWriter != null && isExcelOutput(outputType)) {
+ excelWriter.endWorkbook();
+ openExcel(excelInputStream);
+ }
+ }
+ monitor.worked(1);
+ } finally {
+ monitor.done();
+ }
+ }
+
+ private boolean isExcelOutput(OutputType output) {
+ return output == OutputType.Excel || output == OutputType.Both;
+ }
+
+ private boolean isEditorOutput(OutputType output) {
+ return output == OutputType.ResultsEditor || output == OutputType.Both;
+ }
+
+ private void buildReport(Map<String, AbstractArtifactRelationReport> reports, String title, OutputType output, ISheetWriter writer, AbstractArtifactRelationReport report) {
+ if (isExcelOutput(output)) {
+ report.addReportDataCollector(new ExcelReport(title, writer));
+ }
+ if (isEditorOutput(output)) {
+ report.addReportDataCollector(new ResultEditorReport(title));
+ }
+ reports.put(title, report);
+ }
+
+ private void openExcel(final InputStream inputStream) throws OseeCoreException {
+ IFile iFile = OseeData.getIFile("Trace_Report_" + Lib.getDateTimeString() + ".xml");
+ AIFile.writeToFile(iFile, inputStream);
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException ex) {
+ // Do Nothing
+ }
+ }
+ Program.launch(iFile.getLocation().toOSString());
+ }
+
+ private void openReport(final List<IResultsEditorTab> resultsTabs) {
+ final List<IResultsEditorTab> results = new ArrayList<IResultsEditorTab>(resultsTabs);
+ if (!results.isEmpty()) {
+ IExceptionableRunnable runnable = new IExceptionableRunnable() {
+
+ @Override
+ public IStatus run(IProgressMonitor monitor) throws Exception {
+ ResultsEditor.open(new IResultsEditorProvider() {
+ @Override
+ public String getEditorName() throws OseeCoreException {
+ return getName();
+ }
+
+ @Override
+ public List<IResultsEditorTab> getResultsEditorTabs() throws OseeCoreException {
+ return results;
+ }
+ });
+ return Status.OK_STATUS;
+ }
+ };
+ Jobs.runInJob(getName(), runnable, DefinePlugin.class, DefinePlugin.PLUGIN_ID);
+ }
+ }
+
+ private void addRelationToCheck(List<TraceTypeEnum> traceTypes, AbstractArtifactRelationReport report, boolean fromTraceUnit) {
+ for (TraceTypeEnum traceTypeEnum : traceTypes) {
+ IRelationEnumeration relation =
+ fromTraceUnit ? traceTypeEnum.getRelatedToRequirement() : traceTypeEnum.getRelatedToTraceUnit();
+ report.addRelationToCheck(relation);
+ }
+ }
+
+ private void addArtifacts(CodeUnitData codeUnit, TestUnitData testUnit, List<TraceTypeEnum> traceTypes, AbstractArtifactRelationReport report) {
+ if (TraceTypeEnum.Code_Unit_Trace.isIn(traceTypes)) {
+ report.setArtifacts(codeUnit.getAllCodeUnits());
+ }
+ if (TraceTypeEnum.Verified_By_Test_Unit_Trace.isIn(traceTypes)) {
+ report.setArtifacts(testUnit.getTestCases());
+ }
+ if (TraceTypeEnum.Used_By_Test_Unit_Trace.isIn(traceTypes)) {
+ report.setArtifacts(testUnit.getTestSupportItems());
+ }
+ if (TraceTypeEnum.Validation_By_TestProcedure.isIn(traceTypes)) {
+ report.setArtifacts(testUnit.getTestProcedures());
+ }
+ }
+
+ private AbstractArtifactRelationReport getTraceCountReport(RequirementData reqData, List<TraceTypeEnum> traceTypes) {
+ ArtifactTraceCount report = new ArtifactTraceCount();
+ report.setArtifacts(reqData.getDirectSwRequirements());
+ addRelationToCheck(traceTypes, report, false);
+ return report;
+ }
+
+ private AbstractArtifactRelationReport getDisconnectedTraceUnitReport(CodeUnitData codeUnit, TestUnitData testUnit, List<TraceTypeEnum> traceTypes) {
+ ArtifactsWithoutRelations report = new ArtifactsWithoutRelations();
+ addArtifacts(codeUnit, testUnit, traceTypes, report);
+ addRelationToCheck(traceTypes, report, true);
+ return report;
+ }
+
+ private AbstractArtifactRelationReport getTraceUnitToReqReport(CodeUnitData codeUnit, TestUnitData testUnit, List<TraceTypeEnum> traceTypes) {
+ ArtifactToRelatedArtifact report = new ArtifactToRelatedArtifact();
+ addArtifacts(codeUnit, testUnit, traceTypes, report);
+ addRelationToCheck(traceTypes, report, true);
+ return report;
+ }
+
+ private enum OutputType {
+ ResultsEditor,
+ Excel,
+ Both;
+
+ public static OutputType asType(boolean isExcel, boolean isEditor) {
+ if (isExcel && isEditor) {
+ return OutputType.Both;
+ } else if (isExcel) {
+ return OutputType.Excel;
+ } else if (isEditor) {
+ return OutputType.ResultsEditor;
+ }
+ return null;
+ }
+ }
+
+ private enum TraceTypeEnum {
+ Code_Unit_Trace(CoreRelationTypes.CodeRequirement_Requirement, CoreRelationTypes.CodeRequirement_CodeUnit, false),
+ Verified_By_Test_Unit_Trace(
+ CoreRelationTypes.Verification__Requirement,
+ CoreRelationTypes.Verification__Verifier,
+ true),
+ Used_By_Test_Unit_Trace(CoreRelationTypes.Uses__Requirement, CoreRelationTypes.Uses__TestUnit, true),
+ Validation_By_TestProcedure(
+ CoreRelationTypes.Validation__Requirement,
+ CoreRelationTypes.Validation__Validator,
+ true);
+
+ private IRelationEnumeration toReq;
+ private IRelationEnumeration toTraceUnit;
+ private boolean isTestType;
+
+ TraceTypeEnum(IRelationEnumeration toReq, IRelationEnumeration toTraceUnit, boolean isTestType) {
+ this.toReq = toReq;
+ this.toTraceUnit = toTraceUnit;
+ this.isTestType = isTestType;
+ }
+
+ public IRelationEnumeration getRelatedToRequirement() {
+ return toReq;
+ }
+
+ public IRelationEnumeration getRelatedToTraceUnit() {
+ return toTraceUnit;
+ }
+
+ public boolean isTestType() {
+ return isTestType;
+ }
+
+ public String asLabel() {
+ return name().replaceAll("_", " ");
+ }
+
+ public boolean isIn(Collection<TraceTypeEnum> traceTypes) {
+ return traceTypes.contains(this);
+ }
+
+ public static boolean containsTestEnum(List<TraceTypeEnum> traceTypes) {
+ for (TraceTypeEnum type : TraceTypeEnum.values()) {
+ if (type.isTestType() && type.isIn(traceTypes)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ private static final class ExcelReport implements IReportDataCollector {
+ private final String title;
+ private final ISheetWriter sheetWriter;
+
+ public ExcelReport(String title, ISheetWriter sheetWriter) {
+ this.sheetWriter = sheetWriter;
+ this.title = title;
+ }
+
+ @Override
+ public void addRow(String... data) {
+ try {
+ sheetWriter.writeRow(data);
+ } catch (IOException ex) {
+ OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
+ }
+ }
+
+ @Override
+ public void addTableHeader(String... header) {
+ try {
+ sheetWriter.startSheet(title, header.length);
+ sheetWriter.writeRow(header);
+ } catch (IOException ex) {
+ OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
+ }
+ }
+
+ @Override
+ public void endTable() {
+ try {
+ sheetWriter.endSheet();
+ } catch (IOException ex) {
+ OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
+ }
+ }
+ }
+
+ private final class ResultEditorReport implements IReportDataCollector {
+ private final String title;
+ private List<XViewerColumn> columns;
+ private List<IResultsXViewerRow> rows;
+
+ public ResultEditorReport(String title) {
+ this.title = title;
+ this.columns = null;
+ this.rows = null;
+ }
+
+ @Override
+ public void addRow(String... data) {
+ if (rows == null) {
+ rows = new ArrayList<IResultsXViewerRow>();
+ }
+ rows.add(new ResultsXViewerRow(data));
+ }
+
+ @Override
+ public void addTableHeader(String... header) {
+ this.columns = new ArrayList<XViewerColumn>();
+ for (String name : header) {
+ columns.add(new XViewerColumn(name, name, 80, SWT.LEFT, true, SortDataType.String, false, ""));
+ }
+ }
+
+ @Override
+ public void endTable() {
+ resultsTabs.add(new ResultsEditorTableTab(title, columns, rows));
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/blam/UiToTestBlam.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/blam/UiToTestBlam.java
index 634eb05ea9..f5f82ecaf1 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/blam/UiToTestBlam.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/blam/UiToTestBlam.java
@@ -1,233 +1,233 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability.blam;
-
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability.blam;
+
import static org.eclipse.osee.framework.skynet.core.artifact.DeletionFlag.EXCLUDE_DELETED;
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.define.traceability.data.RequirementData;
-import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
-import org.eclipse.osee.framework.core.enums.IRelationEnumeration;
-import org.eclipse.osee.framework.core.exception.OseeArgumentException;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeExceptions;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.plugin.core.util.AIFile;
-import org.eclipse.osee.framework.plugin.core.util.OseeData;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
-import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
-import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
-import org.eclipse.osee.framework.ui.skynet.results.XResultData;
-import org.eclipse.swt.program.Program;
-
-/**
- * @author Roberto E. Escobar
- */
-public class UiToTestBlam extends AbstractBlam {
- private static final String EMPTY_STRING = "";
-
- @Override
- public String getName() {
- return "UI To Test Report";
- }
-
- @Override
- public Collection<String> getCategories() {
- return Arrays.asList("Define.Trace");
- }
-
- @Override
- public String getDescriptionUsage() {
- return "Usage Info here";
- }
-
- @Override
- public String getXWidgetsXml() {
- StringBuilder builder = new StringBuilder();
- builder.append("<xWidgets>");
- builder.append("<XWidget xwidgetType=\"XFileSelectionDialog\" displayName=\"Select UI List File\" />");
- builder.append("<XWidget xwidgetType=\"XBranchSelectWidget\" displayName=\"Requirements Branch\" />");
- builder.append("</xWidgets>");
- return builder.toString();
- }
-
- @Override
- public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
- String fileName = variableMap.getString("Select UI List File");
- Branch branch = variableMap.getBranch("Requirements Branch");
-
- if (branch == null) {
- throw new OseeArgumentException("Branch cannot be null");
- }
-
- XResultData resultData = new XResultData();
- resultData.log("UI To Test Traceability");
-
- Set<Artifact> toTrace = new HashSet<Artifact>();
- String input = null;
-
- monitor.beginTask("UI To Test Trace Report", IProgressMonitor.UNKNOWN);
- try {
- monitor.subTask("Gathering Requirements");
- if (Strings.isValid(fileName)) {
- input = getUIsFromFile(monitor, fileName);
- }
-
- if (Strings.isValid(input)) {
- for (String ui : input.split("\n")) {
- String toGet = ui.trim();
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.define.traceability.data.RequirementData;
+import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.enums.IRelationEnumeration;
+import org.eclipse.osee.framework.core.exception.OseeArgumentException;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.plugin.core.util.AIFile;
+import org.eclipse.osee.framework.plugin.core.util.OseeData;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
+import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
+import org.eclipse.osee.framework.ui.skynet.results.XResultData;
+import org.eclipse.swt.program.Program;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class UiToTestBlam extends AbstractBlam {
+ private static final String EMPTY_STRING = "";
+
+ @Override
+ public String getName() {
+ return "UI To Test Report";
+ }
+
+ @Override
+ public Collection<String> getCategories() {
+ return Arrays.asList("Define.Trace");
+ }
+
+ @Override
+ public String getDescriptionUsage() {
+ return "Usage Info here";
+ }
+
+ @Override
+ public String getXWidgetsXml() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("<xWidgets>");
+ builder.append("<XWidget xwidgetType=\"XFileSelectionDialog\" displayName=\"Select UI List File\" />");
+ builder.append("<XWidget xwidgetType=\"XBranchSelectWidget\" displayName=\"Requirements Branch\" />");
+ builder.append("</xWidgets>");
+ return builder.toString();
+ }
+
+ @Override
+ public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
+ String fileName = variableMap.getString("Select UI List File");
+ Branch branch = variableMap.getBranch("Requirements Branch");
+
+ if (branch == null) {
+ throw new OseeArgumentException("Branch cannot be null");
+ }
+
+ XResultData resultData = new XResultData();
+ resultData.log("UI To Test Traceability");
+
+ Set<Artifact> toTrace = new HashSet<Artifact>();
+ String input = null;
+
+ monitor.beginTask("UI To Test Trace Report", IProgressMonitor.UNKNOWN);
+ try {
+ monitor.subTask("Gathering Requirements");
+ if (Strings.isValid(fileName)) {
+ input = getUIsFromFile(monitor, fileName);
+ }
+
+ if (Strings.isValid(input)) {
+ for (String ui : input.split("\n")) {
+ String toGet = ui.trim();
toTrace.addAll(ArtifactQuery.getArtifactListFromName(toGet, branch, EXCLUDE_DELETED));
- }
- } else {
- RequirementData requirements = new RequirementData(branch);
- requirements.initialize(monitor);
- toTrace.addAll(requirements.getAllSwRequirements());
- }
-
- StringWriter appendable = new StringWriter();
-
- monitor.subTask("Gathering Test Unit Trace");
-
- if (toTrace.isEmpty()) {
- addRow(appendable, "No Requirements found");
- } else {
- addRow(appendable, String.format("[%s] Requirements Found", toTrace.size()));
-
- List<String> headers = new ArrayList<String>();
- for (Column column : Column.values()) {
- headers.add(column.name());
- }
- addRow(appendable, headers.toArray(new String[headers.size()]));
- for (Artifact requirement : toTrace) {
- processTrace(appendable, requirement, "Verified By", CoreRelationTypes.Verification__Verifier);
- processTrace(appendable, requirement, "Used By", CoreRelationTypes.Uses__TestUnit);
- processTrace(appendable, requirement, "Validated By", CoreRelationTypes.Validation__Validator);
- }
- }
-
- if (appendable.getBuffer().length() > 0) {
- String outFileName = "UI_To_TestUnit." + Lib.getDateTimeString() + ".csv";
- IFile iFile = OseeData.getIFile(outFileName);
- AIFile.writeToFile(iFile, appendable.toString());
- Program.launch(iFile.getLocation().toOSString());
- }
- } finally {
- monitor.subTask("Done");
- System.gc();
- }
- }
-
- private void addRow(Appendable appendable, String... data) throws OseeCoreException {
- if (data != null && data.length > 0) {
- try {
- for (int index = 0; index < data.length; index++) {
- appendable.append("\"");
- appendable.append(data[index]);
- appendable.append("\"");
- if (index + 1 < data.length) {
- appendable.append(",");
- }
- }
- appendable.append("\n");
- } catch (Exception ex) {
- OseeExceptions.wrapAndThrow(ex);
- }
- }
- }
-
- private String getUIsFromFile(IProgressMonitor monitor, String filePath) throws Exception {
- String input;
- File file = new File(filePath);
- if (file == null || !file.exists()) {
- throw new OseeArgumentException("UI list file not accessible");
- }
- IFileStore fileStore = EFS.getStore(file.toURI());
- InputStream inputStream = null;
- try {
- inputStream = new BufferedInputStream(fileStore.openInputStream(EFS.NONE, monitor));
- input = Lib.inputStreamToString(inputStream);
- } finally {
- if (inputStream != null) {
- inputStream.close();
- }
- }
- return input;
- }
-
- private String[] asArray(String... data) {
- String[] toReturn = new String[Column.values().length];
- if (data != null && data.length > 0) {
- for (int index = 0; index < toReturn.length; index++) {
- if (data.length > index) {
- toReturn[index] = data[index];
- }
- }
- }
- return toReturn;
- }
-
- private void processTrace(Appendable appendable, Artifact requirement, String testType, IRelationEnumeration relationType) throws OseeCoreException {
- String uiTitle = requirement.getName();
- String uiType = requirement.getArtifactTypeName();
-
- List<Artifact> testUnits = requirement.getRelatedArtifacts(relationType);
- if (testUnits.isEmpty()) {
- addRow(appendable, asArray(uiTitle, uiType, "NONE", "NONE", EMPTY_STRING, EMPTY_STRING, EMPTY_STRING,
- EMPTY_STRING));
- } else {
- for (Artifact testUnit : testUnits) {
- String testUnitName = testUnit.getName();
- String testUnitType = testUnit.getArtifactTypeName();
- List<String> verified = getTrace(testUnit, CoreRelationTypes.Verification__Requirement);
- List<String> used = getTrace(testUnit, CoreRelationTypes.Uses__Requirement);
- List<String> validates = getTrace(testUnit, CoreRelationTypes.Validation__Requirement);
- String verifyStr = org.eclipse.osee.framework.jdk.core.util.Collections.toString(verified, ",");
- String usesStr = org.eclipse.osee.framework.jdk.core.util.Collections.toString(used, ",");
- String validatesStr = org.eclipse.osee.framework.jdk.core.util.Collections.toString(validates, ",");
-
- addRow(appendable, asArray(uiTitle, uiType, testType, testUnitName, testUnitType, verifyStr, validatesStr,
- usesStr));
- }
- }
- }
-
- private List<String> getTrace(Artifact testUnit, IRelationEnumeration relation) throws OseeCoreException {
- List<String> toReturn = new ArrayList<String>();
- for (Artifact item : testUnit.getRelatedArtifacts(relation)) {
- toReturn.add(item.getName());
- }
- if (toReturn.isEmpty()) {
- toReturn.add("NONE");
- }
- return toReturn;
- }
-
- private static enum Column {
+ }
+ } else {
+ RequirementData requirements = new RequirementData(branch);
+ requirements.initialize(monitor);
+ toTrace.addAll(requirements.getAllSwRequirements());
+ }
+
+ StringWriter appendable = new StringWriter();
+
+ monitor.subTask("Gathering Test Unit Trace");
+
+ if (toTrace.isEmpty()) {
+ addRow(appendable, "No Requirements found");
+ } else {
+ addRow(appendable, String.format("[%s] Requirements Found", toTrace.size()));
+
+ List<String> headers = new ArrayList<String>();
+ for (Column column : Column.values()) {
+ headers.add(column.name());
+ }
+ addRow(appendable, headers.toArray(new String[headers.size()]));
+ for (Artifact requirement : toTrace) {
+ processTrace(appendable, requirement, "Verified By", CoreRelationTypes.Verification__Verifier);
+ processTrace(appendable, requirement, "Used By", CoreRelationTypes.Uses__TestUnit);
+ processTrace(appendable, requirement, "Validated By", CoreRelationTypes.Validation__Validator);
+ }
+ }
+
+ if (appendable.getBuffer().length() > 0) {
+ String outFileName = "UI_To_TestUnit." + Lib.getDateTimeString() + ".csv";
+ IFile iFile = OseeData.getIFile(outFileName);
+ AIFile.writeToFile(iFile, appendable.toString());
+ Program.launch(iFile.getLocation().toOSString());
+ }
+ } finally {
+ monitor.subTask("Done");
+ System.gc();
+ }
+ }
+
+ private void addRow(Appendable appendable, String... data) throws OseeCoreException {
+ if (data != null && data.length > 0) {
+ try {
+ for (int index = 0; index < data.length; index++) {
+ appendable.append("\"");
+ appendable.append(data[index]);
+ appendable.append("\"");
+ if (index + 1 < data.length) {
+ appendable.append(",");
+ }
+ }
+ appendable.append("\n");
+ } catch (Exception ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ }
+ }
+ }
+
+ private String getUIsFromFile(IProgressMonitor monitor, String filePath) throws Exception {
+ String input;
+ File file = new File(filePath);
+ if (file == null || !file.exists()) {
+ throw new OseeArgumentException("UI list file not accessible");
+ }
+ IFileStore fileStore = EFS.getStore(file.toURI());
+ InputStream inputStream = null;
+ try {
+ inputStream = new BufferedInputStream(fileStore.openInputStream(EFS.NONE, monitor));
+ input = Lib.inputStreamToString(inputStream);
+ } finally {
+ if (inputStream != null) {
+ inputStream.close();
+ }
+ }
+ return input;
+ }
+
+ private String[] asArray(String... data) {
+ String[] toReturn = new String[Column.values().length];
+ if (data != null && data.length > 0) {
+ for (int index = 0; index < toReturn.length; index++) {
+ if (data.length > index) {
+ toReturn[index] = data[index];
+ }
+ }
+ }
+ return toReturn;
+ }
+
+ private void processTrace(Appendable appendable, Artifact requirement, String testType, IRelationEnumeration relationType) throws OseeCoreException {
+ String uiTitle = requirement.getName();
+ String uiType = requirement.getArtifactTypeName();
+
+ List<Artifact> testUnits = requirement.getRelatedArtifacts(relationType);
+ if (testUnits.isEmpty()) {
+ addRow(appendable, asArray(uiTitle, uiType, "NONE", "NONE", EMPTY_STRING, EMPTY_STRING, EMPTY_STRING,
+ EMPTY_STRING));
+ } else {
+ for (Artifact testUnit : testUnits) {
+ String testUnitName = testUnit.getName();
+ String testUnitType = testUnit.getArtifactTypeName();
+ List<String> verified = getTrace(testUnit, CoreRelationTypes.Verification__Requirement);
+ List<String> used = getTrace(testUnit, CoreRelationTypes.Uses__Requirement);
+ List<String> validates = getTrace(testUnit, CoreRelationTypes.Validation__Requirement);
+ String verifyStr = org.eclipse.osee.framework.jdk.core.util.Collections.toString(verified, ",");
+ String usesStr = org.eclipse.osee.framework.jdk.core.util.Collections.toString(used, ",");
+ String validatesStr = org.eclipse.osee.framework.jdk.core.util.Collections.toString(validates, ",");
+
+ addRow(appendable, asArray(uiTitle, uiType, testType, testUnitName, testUnitType, verifyStr, validatesStr,
+ usesStr));
+ }
+ }
+ }
+
+ private List<String> getTrace(Artifact testUnit, IRelationEnumeration relation) throws OseeCoreException {
+ List<String> toReturn = new ArrayList<String>();
+ for (Artifact item : testUnit.getRelatedArtifacts(relation)) {
+ toReturn.add(item.getName());
+ }
+ if (toReturn.isEmpty()) {
+ toReturn.add("NONE");
+ }
+ return toReturn;
+ }
+
+ private static enum Column {
UI_Title, Requirement_Type, Relates_To_Test_Unit, Test_Unit_Name, Test_Unit_Type, Verified_By, Validated_By,
- Used_By;
- }
-
-}
+ Used_By;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/BaseTraceDataCache.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/BaseTraceDataCache.java
index 2fa7e324e2..a7f0314cb5 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/BaseTraceDataCache.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/BaseTraceDataCache.java
@@ -1,78 +1,78 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability.data;
-
-import java.util.List;
-import java.util.Map;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.osee.define.DefinePlugin;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-
-/**
- * @author Roberto E. Escobar
- */
-public abstract class BaseTraceDataCache {
-
- private boolean isInitialized;
- private final Branch branch;
- private final String traceType;
-
- public BaseTraceDataCache(String traceType, Branch branch) {
- isInitialized = false;
- this.traceType = traceType;
- this.branch = branch;
- }
-
- public boolean isInitialized() {
- return isInitialized;
- }
-
- public Branch getBranch() {
- return branch;
- }
-
- public final IStatus initialize(IProgressMonitor monitor) {
- IStatus toReturn = Status.CANCEL_STATUS;
- try {
- reset();
- monitor.subTask(String.format("Loading %s from: [%s]", traceType, getBranch().getShortName()));
-
- doBulkLoad(monitor);
-
- if (monitor.isCanceled() != true) {
- toReturn = Status.OK_STATUS;
- }
- isInitialized = true;
- } catch (Exception ex) {
- toReturn = new Status(IStatus.ERROR, DefinePlugin.PLUGIN_ID, String.format("Loading %s ", traceType), ex);
- }
- return toReturn;
- }
-
- protected abstract void doBulkLoad(IProgressMonitor monitor) throws Exception;
-
- protected void populateTraceMap(IProgressMonitor monitor, List<Artifact> artList, Map<String, Artifact> toPopulate) {
- for (Artifact artifact : artList) {
- toPopulate.put(asTraceMapKey(artifact), artifact);
- }
- }
-
- protected String asTraceMapKey(Artifact artifact) {
- return artifact.getName();
- }
-
- public void reset() {
- isInitialized = false;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability.data;
+
+import java.util.List;
+import java.util.Map;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.osee.define.DefinePlugin;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public abstract class BaseTraceDataCache {
+
+ private boolean isInitialized;
+ private final Branch branch;
+ private final String traceType;
+
+ public BaseTraceDataCache(String traceType, Branch branch) {
+ isInitialized = false;
+ this.traceType = traceType;
+ this.branch = branch;
+ }
+
+ public boolean isInitialized() {
+ return isInitialized;
+ }
+
+ public Branch getBranch() {
+ return branch;
+ }
+
+ public final IStatus initialize(IProgressMonitor monitor) {
+ IStatus toReturn = Status.CANCEL_STATUS;
+ try {
+ reset();
+ monitor.subTask(String.format("Loading %s from: [%s]", traceType, getBranch().getShortName()));
+
+ doBulkLoad(monitor);
+
+ if (monitor.isCanceled() != true) {
+ toReturn = Status.OK_STATUS;
+ }
+ isInitialized = true;
+ } catch (Exception ex) {
+ toReturn = new Status(IStatus.ERROR, DefinePlugin.PLUGIN_ID, String.format("Loading %s ", traceType), ex);
+ }
+ return toReturn;
+ }
+
+ protected abstract void doBulkLoad(IProgressMonitor monitor) throws Exception;
+
+ protected void populateTraceMap(IProgressMonitor monitor, List<Artifact> artList, Map<String, Artifact> toPopulate) {
+ for (Artifact artifact : artList) {
+ toPopulate.put(asTraceMapKey(artifact), artifact);
+ }
+ }
+
+ protected String asTraceMapKey(Artifact artifact) {
+ return artifact.getName();
+ }
+
+ public void reset() {
+ isInitialized = false;
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/CodeUnitData.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/CodeUnitData.java
index e98d350963..8810e38391 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/CodeUnitData.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/CodeUnitData.java
@@ -1,55 +1,55 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability.data;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
-
-/**
- * @author Roberto E. Escobar
- */
-public class CodeUnitData extends BaseTraceDataCache {
-
- private final Map<String, Artifact> codeUnitMap;
-
- public CodeUnitData(Branch branch) {
- super("Code Unit Data", branch);
- this.codeUnitMap = new HashMap<String, Artifact>();
- }
-
- @Override
- protected void doBulkLoad(IProgressMonitor monitor) throws Exception {
- List<Artifact> codeUnits = ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.CodeUnit, getBranch());
- populateTraceMap(monitor, codeUnits, codeUnitMap);
- monitor.worked(30);
- }
-
- @Override
- public void reset() {
- super.reset();
- codeUnitMap.clear();
- }
-
- public Collection<Artifact> getAllCodeUnits() {
- return codeUnitMap.values();
- }
-
- public Artifact getCodeUnitByName(String codeUnitName) {
- return codeUnitMap.get(codeUnitName);
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability.data;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class CodeUnitData extends BaseTraceDataCache {
+
+ private final Map<String, Artifact> codeUnitMap;
+
+ public CodeUnitData(Branch branch) {
+ super("Code Unit Data", branch);
+ this.codeUnitMap = new HashMap<String, Artifact>();
+ }
+
+ @Override
+ protected void doBulkLoad(IProgressMonitor monitor) throws Exception {
+ List<Artifact> codeUnits = ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.CodeUnit, getBranch());
+ populateTraceMap(monitor, codeUnits, codeUnitMap);
+ monitor.worked(30);
+ }
+
+ @Override
+ public void reset() {
+ super.reset();
+ codeUnitMap.clear();
+ }
+
+ public Collection<Artifact> getAllCodeUnits() {
+ return codeUnitMap.values();
+ }
+
+ public Artifact getCodeUnitByName(String codeUnitName) {
+ return codeUnitMap.get(codeUnitName);
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/RequirementData.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/RequirementData.java
index ad98abd347..b74902365f 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/RequirementData.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/RequirementData.java
@@ -1,103 +1,103 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.osee.define.traceability.data;
-
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.osee.define.traceability.data;
+
import static org.eclipse.osee.framework.skynet.core.artifact.DeletionFlag.EXCLUDE_DELETED;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.define.traceability.TraceabilityExtractor;
-import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.jdk.core.type.Pair;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
-
-/**
- * @author Roberto E. Escobar
- */
-public class RequirementData extends BaseTraceDataCache {
- private static final TraceabilityExtractor traceExtractor = TraceabilityExtractor.getInstance();
-
- private final List<Artifact> directSwRequirements = new ArrayList<Artifact>();
- private final HashMap<String, Artifact> allSwRequirementsMap = new HashMap<String, Artifact>();
- private final TraceabilityExtractor extractor = TraceabilityExtractor.getInstance();
-
- public RequirementData(Branch branch) {
- super("Software Requirements Data", branch);
- }
-
- @Override
- public void reset() {
- super.reset();
- this.directSwRequirements.clear();
- allSwRequirementsMap.clear();
- }
-
- @Override
- protected void doBulkLoad(IProgressMonitor monitor) throws Exception {
- List<Artifact> allSwRequirements =
- ArtifactQuery.getArtifactListFromTypeWithInheritence(CoreArtifactTypes.AbstractSoftwareRequirement,
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.define.traceability.TraceabilityExtractor;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.jdk.core.type.Pair;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class RequirementData extends BaseTraceDataCache {
+ private static final TraceabilityExtractor traceExtractor = TraceabilityExtractor.getInstance();
+
+ private final List<Artifact> directSwRequirements = new ArrayList<Artifact>();
+ private final HashMap<String, Artifact> allSwRequirementsMap = new HashMap<String, Artifact>();
+ private final TraceabilityExtractor extractor = TraceabilityExtractor.getInstance();
+
+ public RequirementData(Branch branch) {
+ super("Software Requirements Data", branch);
+ }
+
+ @Override
+ public void reset() {
+ super.reset();
+ this.directSwRequirements.clear();
+ allSwRequirementsMap.clear();
+ }
+
+ @Override
+ protected void doBulkLoad(IProgressMonitor monitor) throws Exception {
+ List<Artifact> allSwRequirements =
+ ArtifactQuery.getArtifactListFromTypeWithInheritence(CoreArtifactTypes.AbstractSoftwareRequirement,
getBranch(), EXCLUDE_DELETED);
- populateTraceMap(monitor, allSwRequirements, allSwRequirementsMap);
-
- for (Artifact requirement : getAllSwRequirements()) {
- if (!requirement.isOfType(CoreArtifactTypes.IndirectSoftwareRequirement)) {
- directSwRequirements.add(requirement);
- }
- }
- monitor.worked(38);
- }
-
- @Override
- protected String asTraceMapKey(Artifact artifact) {
- return traceExtractor.getCanonicalRequirementName(artifact.getName());
- }
-
- public Collection<Artifact> getDirectSwRequirements() {
- return directSwRequirements;
- }
-
- public Collection<Artifact> getAllSwRequirements() {
- return allSwRequirementsMap.values();
- }
-
- /**
- * Get Requirement Artifact based on traceMark mark
- *
- * @param traceMark
- * @return requirement artifact
- */
- public Artifact getRequirementFromTraceMark(String traceMark) {
- return allSwRequirementsMap.get(extractor.getCanonicalRequirementName(traceMark));
- }
-
- /**
- * Get Requirement Artifact based on traceMark mark if it fails, check if trace mark is a structured requirement and
- * try again
- *
- * @param traceMark
- * @return requirement artifact
- */
- public Artifact getRequirementFromTraceMarkIncludeStructuredRequirements(String traceMark) {
- Artifact toReturn = getRequirementFromTraceMark(traceMark);
- if (toReturn == null) {
- Pair<String, String> structured = extractor.getStructuredRequirement(traceMark);
- if (structured != null) {
- toReturn = getRequirementFromTraceMark(structured.getFirst());
- }
- }
- return toReturn;
- }
+ populateTraceMap(monitor, allSwRequirements, allSwRequirementsMap);
+
+ for (Artifact requirement : getAllSwRequirements()) {
+ if (!requirement.isOfType(CoreArtifactTypes.IndirectSoftwareRequirement)) {
+ directSwRequirements.add(requirement);
+ }
+ }
+ monitor.worked(38);
+ }
+
+ @Override
+ protected String asTraceMapKey(Artifact artifact) {
+ return traceExtractor.getCanonicalRequirementName(artifact.getName());
+ }
+
+ public Collection<Artifact> getDirectSwRequirements() {
+ return directSwRequirements;
+ }
+
+ public Collection<Artifact> getAllSwRequirements() {
+ return allSwRequirementsMap.values();
+ }
+
+ /**
+ * Get Requirement Artifact based on traceMark mark
+ *
+ * @param traceMark
+ * @return requirement artifact
+ */
+ public Artifact getRequirementFromTraceMark(String traceMark) {
+ return allSwRequirementsMap.get(extractor.getCanonicalRequirementName(traceMark));
+ }
+
+ /**
+ * Get Requirement Artifact based on traceMark mark if it fails, check if trace mark is a structured requirement and
+ * try again
+ *
+ * @param traceMark
+ * @return requirement artifact
+ */
+ public Artifact getRequirementFromTraceMarkIncludeStructuredRequirements(String traceMark) {
+ Artifact toReturn = getRequirementFromTraceMark(traceMark);
+ if (toReturn == null) {
+ Pair<String, String> structured = extractor.getStructuredRequirement(traceMark);
+ if (structured != null) {
+ toReturn = getRequirementFromTraceMark(structured.getFirst());
+ }
+ }
+ return toReturn;
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TestUnitData.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TestUnitData.java
index ffa2f93481..5096cc6c51 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TestUnitData.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TestUnitData.java
@@ -1,140 +1,140 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability.data;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubMonitor;
-import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
-
-/**
- * @author Roberto E. Escobar
- */
-public class TestUnitData extends BaseTraceDataCache {
-
- private final List<Artifact> testCases;
- private final List<Artifact> testProcedures;
- private final List<Artifact> testSupportItems;
- private final Set<Artifact> allTestUnits;
-
- private final HashMap<String, Artifact> testCaseMap;
- private final HashMap<String, Artifact> testProcedureMap;
- private final HashMap<String, Artifact> testSupportMap;
-
- public TestUnitData(Branch branch) {
- super("Test Unit Data", branch);
- this.testCaseMap = new HashMap<String, Artifact>();
- this.testProcedureMap = new HashMap<String, Artifact>();
- this.testSupportMap = new HashMap<String, Artifact>();
-
- this.testCases = new ArrayList<Artifact>();
- this.testProcedures = new ArrayList<Artifact>();
- this.testSupportItems = new ArrayList<Artifact>();
-
- this.allTestUnits = new TreeSet<Artifact>();
- }
-
- @Override
- public void reset() {
- super.reset();
- this.testCaseMap.clear();
- this.testProcedureMap.clear();
- this.testSupportMap.clear();
-
- this.testCases.clear();
- this.testProcedures.clear();
- this.testSupportItems.clear();
-
- this.allTestUnits.clear();
- }
-
- @Override
- protected void doBulkLoad(IProgressMonitor monitor) throws Exception {
- IProgressMonitor subMonitor = SubMonitor.convert(monitor);
- testCases.addAll(ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.TestCase, getBranch()));
- populateTraceMap(monitor, testCases, testCaseMap);
- subMonitor.worked(20);
-
- if (!monitor.isCanceled()) {
- monitor.subTask(String.format("Load Test Support from: [%s]", getBranch().getShortName()));
-
- testSupportItems.addAll(ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.TestSupport, getBranch()));
- populateTraceMap(monitor, testSupportItems, testSupportMap);
- subMonitor.worked(20);
- }
-
- if (!monitor.isCanceled()) {
- monitor.subTask(String.format("Load Test Procedures from: [%s]", getBranch().getShortName()));
- testProcedures.addAll(ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.TestProcedure, getBranch()));
- testProcedures.addAll(ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.TestProcedureWML, getBranch()));
- testProcedures.addAll(ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.TestProcedureXL, getBranch()));
- populateTraceMap(monitor, testProcedures, testProcedureMap);
- subMonitor.worked(20);
- }
-
- if (!monitor.isCanceled()) {
- allTestUnits.addAll(testCases);
- allTestUnits.addAll(testProcedures);
- allTestUnits.addAll(testSupportItems);
- subMonitor.worked(1);
- }
- }
-
- /**
- * @return the test cases
- */
- public Collection<Artifact> getTestCases() {
- return testCases;
- }
-
- /**
- * @return the test support items
- */
- public Collection<Artifact> getTestSupportItems() {
- return testSupportItems;
- }
-
- /**
- * @return the test procedures
- */
- public Collection<Artifact> getTestProcedures() {
- return testProcedures;
- }
-
- /**
- * @return the allTestUnits
- */
- public Set<Artifact> getAllTestUnits() {
- return allTestUnits;
- }
-
- /**
- * @return the testUnitArtifact
- */
- public Artifact getTestUnitByName(String testUnitName) {
- Artifact testUnit = testCaseMap.get(testUnitName);
- if (testUnit == null) {
- testUnit = testSupportMap.get(testUnitName);
- }
- if (testUnit == null) {
- testUnit = testProcedureMap.get(testUnitName);
- }
- return testUnit;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability.data;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class TestUnitData extends BaseTraceDataCache {
+
+ private final List<Artifact> testCases;
+ private final List<Artifact> testProcedures;
+ private final List<Artifact> testSupportItems;
+ private final Set<Artifact> allTestUnits;
+
+ private final HashMap<String, Artifact> testCaseMap;
+ private final HashMap<String, Artifact> testProcedureMap;
+ private final HashMap<String, Artifact> testSupportMap;
+
+ public TestUnitData(Branch branch) {
+ super("Test Unit Data", branch);
+ this.testCaseMap = new HashMap<String, Artifact>();
+ this.testProcedureMap = new HashMap<String, Artifact>();
+ this.testSupportMap = new HashMap<String, Artifact>();
+
+ this.testCases = new ArrayList<Artifact>();
+ this.testProcedures = new ArrayList<Artifact>();
+ this.testSupportItems = new ArrayList<Artifact>();
+
+ this.allTestUnits = new TreeSet<Artifact>();
+ }
+
+ @Override
+ public void reset() {
+ super.reset();
+ this.testCaseMap.clear();
+ this.testProcedureMap.clear();
+ this.testSupportMap.clear();
+
+ this.testCases.clear();
+ this.testProcedures.clear();
+ this.testSupportItems.clear();
+
+ this.allTestUnits.clear();
+ }
+
+ @Override
+ protected void doBulkLoad(IProgressMonitor monitor) throws Exception {
+ IProgressMonitor subMonitor = SubMonitor.convert(monitor);
+ testCases.addAll(ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.TestCase, getBranch()));
+ populateTraceMap(monitor, testCases, testCaseMap);
+ subMonitor.worked(20);
+
+ if (!monitor.isCanceled()) {
+ monitor.subTask(String.format("Load Test Support from: [%s]", getBranch().getShortName()));
+
+ testSupportItems.addAll(ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.TestSupport, getBranch()));
+ populateTraceMap(monitor, testSupportItems, testSupportMap);
+ subMonitor.worked(20);
+ }
+
+ if (!monitor.isCanceled()) {
+ monitor.subTask(String.format("Load Test Procedures from: [%s]", getBranch().getShortName()));
+ testProcedures.addAll(ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.TestProcedure, getBranch()));
+ testProcedures.addAll(ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.TestProcedureWML, getBranch()));
+ testProcedures.addAll(ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.TestProcedureXL, getBranch()));
+ populateTraceMap(monitor, testProcedures, testProcedureMap);
+ subMonitor.worked(20);
+ }
+
+ if (!monitor.isCanceled()) {
+ allTestUnits.addAll(testCases);
+ allTestUnits.addAll(testProcedures);
+ allTestUnits.addAll(testSupportItems);
+ subMonitor.worked(1);
+ }
+ }
+
+ /**
+ * @return the test cases
+ */
+ public Collection<Artifact> getTestCases() {
+ return testCases;
+ }
+
+ /**
+ * @return the test support items
+ */
+ public Collection<Artifact> getTestSupportItems() {
+ return testSupportItems;
+ }
+
+ /**
+ * @return the test procedures
+ */
+ public Collection<Artifact> getTestProcedures() {
+ return testProcedures;
+ }
+
+ /**
+ * @return the allTestUnits
+ */
+ public Set<Artifact> getAllTestUnits() {
+ return allTestUnits;
+ }
+
+ /**
+ * @return the testUnitArtifact
+ */
+ public Artifact getTestUnitByName(String testUnitName) {
+ Artifact testUnit = testCaseMap.get(testUnitName);
+ if (testUnit == null) {
+ testUnit = testSupportMap.get(testUnitName);
+ }
+ if (testUnit == null) {
+ testUnit = testProcedureMap.get(testUnitName);
+ }
+ return testUnit;
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TraceMark.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TraceMark.java
index 1fb1d9e0dc..d825a438d7 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TraceMark.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TraceMark.java
@@ -1,76 +1,76 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability.data;
-
-
-/**
- * @author Roberto E. Escobar
- */
-public class TraceMark {
- private final String traceType;
- private final String rawTraceMark;
-
- public TraceMark(String traceType, String rawTraceMark) {
- super();
- this.traceType = traceType;
- this.rawTraceMark = rawTraceMark;
- }
-
- public String getTraceType() {
- return traceType;
- }
-
- public String getRawTraceMark() {
- return rawTraceMark;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof TraceMark) {
- final TraceMark other = (TraceMark) obj;
- boolean result = true;
- if (other.getTraceType() != null && getTraceType() != null) {
- result &= other.getTraceType().equals(getTraceType());
- } else {
- result &= other.getTraceType() == null && getTraceType() == null;
- }
- if (other.getRawTraceMark() != null && getRawTraceMark() != null) {
- result &= other.getRawTraceMark().equals(getRawTraceMark());
- } else {
- result &= other.getRawTraceMark() == null && getRawTraceMark() == null;
- }
- return result;
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- final int prime = 37;
- int result = 17;
- if (getTraceType() != null) {
- result = prime * result + getTraceType().hashCode();
- } else {
- result = prime * result;
- }
- if (getRawTraceMark() != null) {
- result = prime * result + getRawTraceMark().hashCode();
- } else {
- result = prime * result;
- }
- return result;
- }
-
- @Override
- public String toString() {
- return String.format("<%s:%s>", getTraceType(), getRawTraceMark());
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability.data;
+
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class TraceMark {
+ private final String traceType;
+ private final String rawTraceMark;
+
+ public TraceMark(String traceType, String rawTraceMark) {
+ super();
+ this.traceType = traceType;
+ this.rawTraceMark = rawTraceMark;
+ }
+
+ public String getTraceType() {
+ return traceType;
+ }
+
+ public String getRawTraceMark() {
+ return rawTraceMark;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof TraceMark) {
+ final TraceMark other = (TraceMark) obj;
+ boolean result = true;
+ if (other.getTraceType() != null && getTraceType() != null) {
+ result &= other.getTraceType().equals(getTraceType());
+ } else {
+ result &= other.getTraceType() == null && getTraceType() == null;
+ }
+ if (other.getRawTraceMark() != null && getRawTraceMark() != null) {
+ result &= other.getRawTraceMark().equals(getRawTraceMark());
+ } else {
+ result &= other.getRawTraceMark() == null && getRawTraceMark() == null;
+ }
+ return result;
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 37;
+ int result = 17;
+ if (getTraceType() != null) {
+ result = prime * result + getTraceType().hashCode();
+ } else {
+ result = prime * result;
+ }
+ if (getRawTraceMark() != null) {
+ result = prime * result + getRawTraceMark().hashCode();
+ } else {
+ result = prime * result;
+ }
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("<%s:%s>", getTraceType(), getRawTraceMark());
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TraceUnit.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TraceUnit.java
index 906e5d79be..f0fc95e3ad 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TraceUnit.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TraceUnit.java
@@ -1,68 +1,68 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability.data;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author Roberto E. Escobar
- */
-public class TraceUnit {
- private final String traceUnitType;
- private final String name;
- private final Collection<TraceMark> traceMarks;
-
- public TraceUnit(String traceUnitType, String name) {
- this.name = name;
- this.traceUnitType = traceUnitType;
- this.traceMarks = new HashSet<TraceMark>();
- }
-
- public String getTraceUnitType() {
- return traceUnitType;
- }
-
- public String getName() {
- return name;
- }
-
- public void addAllTraceMarks(Collection<TraceMark> traceItems) {
- traceMarks.addAll(traceItems);
- }
-
- public void addTraceMark(TraceMark traceMark) {
- traceMarks.add(traceMark);
- }
-
- public Collection<TraceMark> getTraceMarks() {
- return traceMarks;
- }
-
- public Set<String> getTraceMarkTypes() {
- Set<String> toReturn = new HashSet<String>();
- for (TraceMark traceMark : traceMarks) {
- toReturn.add(traceMark.getTraceType());
- }
- return toReturn;
- }
-
- public Collection<TraceMark> getTraceMarksByType(String type) {
- Set<TraceMark> toReturn = new HashSet<TraceMark>();
- for (TraceMark traceMark : traceMarks) {
- if (traceMark.getTraceType().equalsIgnoreCase(type)) {
- toReturn.add(traceMark);
- }
- }
- return toReturn;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability.data;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class TraceUnit {
+ private final String traceUnitType;
+ private final String name;
+ private final Collection<TraceMark> traceMarks;
+
+ public TraceUnit(String traceUnitType, String name) {
+ this.name = name;
+ this.traceUnitType = traceUnitType;
+ this.traceMarks = new HashSet<TraceMark>();
+ }
+
+ public String getTraceUnitType() {
+ return traceUnitType;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void addAllTraceMarks(Collection<TraceMark> traceItems) {
+ traceMarks.addAll(traceItems);
+ }
+
+ public void addTraceMark(TraceMark traceMark) {
+ traceMarks.add(traceMark);
+ }
+
+ public Collection<TraceMark> getTraceMarks() {
+ return traceMarks;
+ }
+
+ public Set<String> getTraceMarkTypes() {
+ Set<String> toReturn = new HashSet<String>();
+ for (TraceMark traceMark : traceMarks) {
+ toReturn.add(traceMark.getTraceType());
+ }
+ return toReturn;
+ }
+
+ public Collection<TraceMark> getTraceMarksByType(String type) {
+ Set<TraceMark> toReturn = new HashSet<TraceMark>();
+ for (TraceMark traceMark : traceMarks) {
+ if (traceMark.getTraceType().equalsIgnoreCase(type)) {
+ toReturn.add(traceMark);
+ }
+ }
+ return toReturn;
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/jobs/FindTraceUnitJob.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/jobs/FindTraceUnitJob.java
index 694ac2b624..d4eb229e2c 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/jobs/FindTraceUnitJob.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/jobs/FindTraceUnitJob.java
@@ -8,82 +8,82 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.define.traceability.jobs;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.IJobChangeEvent;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.core.runtime.jobs.JobChangeAdapter;
-import org.eclipse.osee.define.DefinePlugin;
-import org.eclipse.osee.define.traceability.operations.FindTraceUnitFromResource;
+package org.eclipse.osee.define.traceability.jobs;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.osee.define.DefinePlugin;
+import org.eclipse.osee.define.traceability.operations.FindTraceUnitFromResource;
import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.plugin.core.util.IExceptionableRunnable;
-import org.eclipse.osee.framework.plugin.core.util.Jobs;
-import org.eclipse.osee.framework.ui.skynet.branch.BranchSelectionDialog;
-import org.eclipse.ui.progress.UIJob;
-
-/**
- * @author Roberto E. Escobar
- */
-public class FindTraceUnitJob extends Job {
- private final IResource[] resources;
-
- public FindTraceUnitJob(String name, IResource... resources) {
- super(name);
- if (resources != null) {
- this.resources = resources;
- } else {
- this.resources = new IResource[0];
- }
- }
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- if (resources != null && resources.length > 0) {
- FetchBranchJob job = new FetchBranchJob(getName());
- Jobs.startJob(job, true, new JobChangeAdapter() {
-
- @Override
- public void done(IJobChangeEvent event) {
- FetchBranchJob fetcherJob = (FetchBranchJob) event.getJob();
- final Branch branch = fetcherJob.getSelectedBranch();
- if (branch != null) {
- IExceptionableRunnable runnable = new IExceptionableRunnable() {
-
- @Override
- public IStatus run(IProgressMonitor monitor) throws Exception {
- if (branch != null) {
- FindTraceUnitFromResource.search(branch, resources);
- }
- return Status.OK_STATUS;
- }
- };
- Jobs.runInJob(getName(), runnable, DefinePlugin.class, DefinePlugin.PLUGIN_ID);
- }
- }
- });
- }
- return Status.OK_STATUS;
- }
+import org.eclipse.osee.framework.plugin.core.util.IExceptionableRunnable;
+import org.eclipse.osee.framework.plugin.core.util.Jobs;
+import org.eclipse.osee.framework.ui.skynet.branch.BranchSelectionDialog;
+import org.eclipse.ui.progress.UIJob;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class FindTraceUnitJob extends Job {
+ private final IResource[] resources;
+
+ public FindTraceUnitJob(String name, IResource... resources) {
+ super(name);
+ if (resources != null) {
+ this.resources = resources;
+ } else {
+ this.resources = new IResource[0];
+ }
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ if (resources != null && resources.length > 0) {
+ FetchBranchJob job = new FetchBranchJob(getName());
+ Jobs.startJob(job, true, new JobChangeAdapter() {
+
+ @Override
+ public void done(IJobChangeEvent event) {
+ FetchBranchJob fetcherJob = (FetchBranchJob) event.getJob();
+ final Branch branch = fetcherJob.getSelectedBranch();
+ if (branch != null) {
+ IExceptionableRunnable runnable = new IExceptionableRunnable() {
+
+ @Override
+ public IStatus run(IProgressMonitor monitor) throws Exception {
+ if (branch != null) {
+ FindTraceUnitFromResource.search(branch, resources);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ Jobs.runInJob(getName(), runnable, DefinePlugin.class, DefinePlugin.PLUGIN_ID);
+ }
+ }
+ });
+ }
+ return Status.OK_STATUS;
+ }
private static final class FetchBranchJob extends UIJob {
- private Branch branch;
-
- public FetchBranchJob(String name) {
- super(name);
- branch = null;
- }
-
+ private Branch branch;
+
+ public FetchBranchJob(String name) {
+ super(name);
+ branch = null;
+ }
+
@Override
- public IStatus runInUIThread(IProgressMonitor monitor) {
- branch = BranchSelectionDialog.getBranchFromUser();
- return Status.OK_STATUS;
- }
-
- public Branch getSelectedBranch() {
- return branch;
- }
- }
-}
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ branch = BranchSelectionDialog.getBranchFromUser();
+ return Status.OK_STATUS;
+ }
+
+ public Branch getSelectedBranch() {
+ return branch;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/jobs/ImportTraceUnitsJob.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/jobs/ImportTraceUnitsJob.java
index d7c8c0b985..d2c7849755 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/jobs/ImportTraceUnitsJob.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/jobs/ImportTraceUnitsJob.java
@@ -8,67 +8,67 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.define.traceability.jobs;
-
-import java.net.URI;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.osee.define.DefinePlugin;
-import org.eclipse.osee.define.traceability.operations.TraceUnitFromResourceOperation;
+package org.eclipse.osee.define.traceability.jobs;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.osee.define.DefinePlugin;
+import org.eclipse.osee.define.traceability.operations.TraceUnitFromResourceOperation;
import org.eclipse.osee.framework.core.model.Branch;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ImportTraceUnitsJob extends Job {
- private final Branch importToBranch;
- private final boolean isRecursive;
- private final boolean isPersistChanges;
- private final boolean fileWithMultiPaths;
- private final URI source;
- private final String[] traceTypeIds;
-
- public ImportTraceUnitsJob(String jobName, Branch importToBranch, URI source, boolean isRecursive, boolean isPersistChanges, boolean fileWithMultiPaths, String... traceHandlerIds) {
- super(jobName);
- this.importToBranch = importToBranch;
- this.source = source;
- this.isRecursive = isRecursive;
- this.isPersistChanges = isPersistChanges;
- this.fileWithMultiPaths = fileWithMultiPaths;
- if (traceHandlerIds == null) {
- traceTypeIds = new String[0];
- } else {
- Set<String> traceSet = new HashSet<String>(Arrays.asList(traceHandlerIds));
- traceTypeIds = traceSet.toArray(new String[traceSet.size()]);
- }
- }
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- IStatus status = Status.CANCEL_STATUS;
- try {
- monitor.beginTask(getName(), Integer.MAX_VALUE);
- if (isPersistChanges) {
- TraceUnitFromResourceOperation.importTraceFromTestUnits(monitor, source, isRecursive, fileWithMultiPaths,
- importToBranch, traceTypeIds);
- } else {
- TraceUnitFromResourceOperation.printTraceFromTestUnits(monitor, source, isRecursive, fileWithMultiPaths,
- traceTypeIds);
- }
- if (!monitor.isCanceled()) {
- status = Status.OK_STATUS;
- }
- } catch (Exception ex) {
- status = new Status(Status.ERROR, DefinePlugin.PLUGIN_ID, "", ex);
- } finally {
- monitor.done();
- }
- return status;
- }
-
-}
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ImportTraceUnitsJob extends Job {
+ private final Branch importToBranch;
+ private final boolean isRecursive;
+ private final boolean isPersistChanges;
+ private final boolean fileWithMultiPaths;
+ private final URI source;
+ private final String[] traceTypeIds;
+
+ public ImportTraceUnitsJob(String jobName, Branch importToBranch, URI source, boolean isRecursive, boolean isPersistChanges, boolean fileWithMultiPaths, String... traceHandlerIds) {
+ super(jobName);
+ this.importToBranch = importToBranch;
+ this.source = source;
+ this.isRecursive = isRecursive;
+ this.isPersistChanges = isPersistChanges;
+ this.fileWithMultiPaths = fileWithMultiPaths;
+ if (traceHandlerIds == null) {
+ traceTypeIds = new String[0];
+ } else {
+ Set<String> traceSet = new HashSet<String>(Arrays.asList(traceHandlerIds));
+ traceTypeIds = traceSet.toArray(new String[traceSet.size()]);
+ }
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ IStatus status = Status.CANCEL_STATUS;
+ try {
+ monitor.beginTask(getName(), Integer.MAX_VALUE);
+ if (isPersistChanges) {
+ TraceUnitFromResourceOperation.importTraceFromTestUnits(monitor, source, isRecursive, fileWithMultiPaths,
+ importToBranch, traceTypeIds);
+ } else {
+ TraceUnitFromResourceOperation.printTraceFromTestUnits(monitor, source, isRecursive, fileWithMultiPaths,
+ traceTypeIds);
+ }
+ if (!monitor.isCanceled()) {
+ status = Status.OK_STATUS;
+ }
+ } catch (Exception ex) {
+ status = new Status(Status.ERROR, DefinePlugin.PLUGIN_ID, "", ex);
+ } finally {
+ monitor.done();
+ }
+ return status;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/FindTraceUnitFromResource.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/FindTraceUnitFromResource.java
index e86218dc07..0b3b1b61eb 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/FindTraceUnitFromResource.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/FindTraceUnitFromResource.java
@@ -1,139 +1,139 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability.operations;
-
-import java.io.InputStream;
-import java.nio.CharBuffer;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.logging.Level;
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.osee.define.DefinePlugin;
-import org.eclipse.osee.define.traceability.ITraceUnitResourceLocator;
-import org.eclipse.osee.define.traceability.TraceUnitExtensionManager;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.jdk.core.type.HashCollection;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.logging.OseeLog;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
-import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.skynet.artifact.editor.ArtifactEditor;
-import org.eclipse.osee.framework.ui.skynet.artifact.editor.ArtifactEditorInput;
-import org.eclipse.osee.framework.ui.swt.Displays;
-
-/**
- * @author Roberto E. Escobar
- */
-public class FindTraceUnitFromResource {
-
- private FindTraceUnitFromResource() {
- }
-
- private static HashCollection<String, String> toIdentifiers(IResource... resources) {
- HashCollection<String, String> toReturn = new HashCollection<String, String>(false, HashSet.class);
- if (resources != null && resources.length > 0) {
- try {
- Collection<ITraceUnitResourceLocator> locators =
- TraceUnitExtensionManager.getInstance().getAllTraceUnitLocators();
- for (IResource resource : resources) {
- resourceToId(toReturn, resource, locators);
- }
- } catch (Exception ex) {
- OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
- }
- }
- return toReturn;
- }
-
- private static void resourceToId(HashCollection<String, String> idStore, IResource resource, Collection<ITraceUnitResourceLocator> locators) {
- try {
- IFileStore fileStore = EFS.getStore(resource.getLocationURI());
- for (ITraceUnitResourceLocator locator : locators) {
- if (locator.isValidFile(fileStore)) {
- InputStream inputStream = null;
- try {
- inputStream = fileStore.openInputStream(EFS.NONE, new NullProgressMonitor());
- CharBuffer buffer = Lib.inputStreamToCharBuffer(inputStream);
- String identifier = locator.getIdentifier(fileStore, buffer);
- String traceType = locator.getTraceUnitType(identifier, buffer);
- idStore.put(traceType, identifier);
- } catch (Exception ex) {
- OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
- } finally {
- if (inputStream != null) {
- try {
- inputStream.close();
- } catch (Exception ex) {
- // do nothing
- }
- }
- }
- }
- }
- } catch (Exception ex) {
- OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
- }
- }
-
- public static void search(Branch branch, IResource... resources) {
- HashCollection<String, String> typeAndIds = toIdentifiers(resources);
- if (!typeAndIds.isEmpty()) {
- Set<Artifact> artifacts = new HashSet<Artifact>();
- for (String artifactTypeName : typeAndIds.keySet()) {
- Collection<String> items = typeAndIds.getValues(artifactTypeName);
- if (items != null) {
- for (String artifactName : items) {
- try {
- artifacts.addAll(ArtifactQuery.getArtifactListFromTypeAndName(artifactTypeName, artifactName,
- branch));
- } catch (OseeCoreException ex) {
- OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
- }
- }
- }
- }
-
- if (!artifacts.isEmpty()) {
- openArtifacts(artifacts);
- } else {
- AWorkbench.popup("Find Trace Unit from Resource",
- String.format("Unable to find trace for: %s", Arrays.deepToString(resources)));
- }
- } else {
- AWorkbench.popup("Find Trace Unit from Resource",
- String.format("Unable to find trace handler for: %s", Arrays.deepToString(resources)));
- }
- }
-
- private static void openArtifacts(final Collection<Artifact> artifacts) {
- Displays.ensureInDisplayThread(new Runnable() {
-
- @Override
- public void run() {
- try {
- for (Artifact artifact : artifacts) {
- AWorkbench.getActivePage().openEditor(new ArtifactEditorInput(artifact), ArtifactEditor.EDITOR_ID,
- true);
- }
- } catch (Exception ex) {
- OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
- }
- }
- });
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability.operations;
+
+import java.io.InputStream;
+import java.nio.CharBuffer;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.logging.Level;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.osee.define.DefinePlugin;
+import org.eclipse.osee.define.traceability.ITraceUnitResourceLocator;
+import org.eclipse.osee.define.traceability.TraceUnitExtensionManager;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.jdk.core.type.HashCollection;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
+import org.eclipse.osee.framework.ui.skynet.artifact.editor.ArtifactEditor;
+import org.eclipse.osee.framework.ui.skynet.artifact.editor.ArtifactEditorInput;
+import org.eclipse.osee.framework.ui.swt.Displays;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class FindTraceUnitFromResource {
+
+ private FindTraceUnitFromResource() {
+ }
+
+ private static HashCollection<String, String> toIdentifiers(IResource... resources) {
+ HashCollection<String, String> toReturn = new HashCollection<String, String>(false, HashSet.class);
+ if (resources != null && resources.length > 0) {
+ try {
+ Collection<ITraceUnitResourceLocator> locators =
+ TraceUnitExtensionManager.getInstance().getAllTraceUnitLocators();
+ for (IResource resource : resources) {
+ resourceToId(toReturn, resource, locators);
+ }
+ } catch (Exception ex) {
+ OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
+ }
+ }
+ return toReturn;
+ }
+
+ private static void resourceToId(HashCollection<String, String> idStore, IResource resource, Collection<ITraceUnitResourceLocator> locators) {
+ try {
+ IFileStore fileStore = EFS.getStore(resource.getLocationURI());
+ for (ITraceUnitResourceLocator locator : locators) {
+ if (locator.isValidFile(fileStore)) {
+ InputStream inputStream = null;
+ try {
+ inputStream = fileStore.openInputStream(EFS.NONE, new NullProgressMonitor());
+ CharBuffer buffer = Lib.inputStreamToCharBuffer(inputStream);
+ String identifier = locator.getIdentifier(fileStore, buffer);
+ String traceType = locator.getTraceUnitType(identifier, buffer);
+ idStore.put(traceType, identifier);
+ } catch (Exception ex) {
+ OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (Exception ex) {
+ // do nothing
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception ex) {
+ OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
+ }
+ }
+
+ public static void search(Branch branch, IResource... resources) {
+ HashCollection<String, String> typeAndIds = toIdentifiers(resources);
+ if (!typeAndIds.isEmpty()) {
+ Set<Artifact> artifacts = new HashSet<Artifact>();
+ for (String artifactTypeName : typeAndIds.keySet()) {
+ Collection<String> items = typeAndIds.getValues(artifactTypeName);
+ if (items != null) {
+ for (String artifactName : items) {
+ try {
+ artifacts.addAll(ArtifactQuery.getArtifactListFromTypeAndName(artifactTypeName, artifactName,
+ branch));
+ } catch (OseeCoreException ex) {
+ OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
+ }
+ }
+ }
+ }
+
+ if (!artifacts.isEmpty()) {
+ openArtifacts(artifacts);
+ } else {
+ AWorkbench.popup("Find Trace Unit from Resource",
+ String.format("Unable to find trace for: %s", Arrays.deepToString(resources)));
+ }
+ } else {
+ AWorkbench.popup("Find Trace Unit from Resource",
+ String.format("Unable to find trace handler for: %s", Arrays.deepToString(resources)));
+ }
+ }
+
+ private static void openArtifacts(final Collection<Artifact> artifacts) {
+ Displays.ensureInDisplayThread(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ for (Artifact artifact : artifacts) {
+ AWorkbench.getActivePage().openEditor(new ArtifactEditorInput(artifact), ArtifactEditor.EDITOR_ID,
+ true);
+ }
+ } catch (Exception ex) {
+ OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
+ }
+ }
+ });
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ITraceUnitProcessor.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ITraceUnitProcessor.java
index 7196a85f5f..18c017a82f 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ITraceUnitProcessor.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ITraceUnitProcessor.java
@@ -1,29 +1,29 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability.operations;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.define.traceability.data.TraceUnit;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-
-/**
- * @author Roberto E. Escobar
- */
-public interface ITraceUnitProcessor {
-
- public void initialize(IProgressMonitor monitor);
-
- public void onComplete(IProgressMonitor monitor) throws OseeCoreException;
-
- public void clear();
-
- public void process(IProgressMonitor monitor, TraceUnit testUnit) throws OseeCoreException;
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability.operations;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.define.traceability.data.TraceUnit;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface ITraceUnitProcessor {
+
+ public void initialize(IProgressMonitor monitor);
+
+ public void onComplete(IProgressMonitor monitor) throws OseeCoreException;
+
+ public void clear();
+
+ public void process(IProgressMonitor monitor, TraceUnit testUnit) throws OseeCoreException;
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ResourceToTraceUnit.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ResourceToTraceUnit.java
index f583fee5ab..e79db5b992 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ResourceToTraceUnit.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ResourceToTraceUnit.java
@@ -1,219 +1,219 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability.operations;
-
-import java.net.URI;
-import java.nio.CharBuffer;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.osee.define.traceability.ITraceParser;
-import org.eclipse.osee.define.traceability.ITraceUnitResourceLocator;
-import org.eclipse.osee.define.traceability.data.TraceMark;
-import org.eclipse.osee.define.traceability.data.TraceUnit;
-import org.eclipse.osee.define.utility.IResourceHandler;
-import org.eclipse.osee.define.utility.UriResourceContentFinder;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.type.HashCollection;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ResourceToTraceUnit {
-
- private final UriResourceContentFinder resourceFinder;
- private final Set<ITraceUnitProcessor> traceProcessors;
- private final HashCollection<ITraceUnitResourceLocator, ITraceParser> traceUnitHandlers;
-
- public ResourceToTraceUnit(final URI source, final boolean isRecursionAllowed, final boolean isFileWithMultiplePaths) {
- super();
- this.traceUnitHandlers = new HashCollection<ITraceUnitResourceLocator, ITraceParser>();
- this.traceProcessors = Collections.synchronizedSet(new HashSet<ITraceUnitProcessor>());
- this.resourceFinder = new UriResourceContentFinder(source, isRecursionAllowed, isFileWithMultiplePaths);
- }
-
- public void addTraceProcessor(ITraceUnitProcessor traceProcessor) {
- synchronized (traceProcessors) {
- traceProcessors.add(traceProcessor);
- }
- }
-
- public void removeTraceProcessor(ITraceUnitProcessor traceProcessor) {
- synchronized (traceProcessors) {
- traceProcessors.remove(traceProcessor);
- }
- }
-
- public void addTraceUnitHandler(ITraceUnitResourceLocator locator, ITraceParser parser) {
- traceUnitHandlers.put(locator, parser);
- }
-
- public void removeTestUnitLocator(ITraceUnitResourceLocator locator) {
- traceUnitHandlers.removeValues(locator);
- }
-
- private void clear() {
- for (ITraceUnitProcessor traceProcessor : traceProcessors) {
- traceProcessor.clear();
- }
- for (ITraceUnitResourceLocator locator : traceUnitHandlers.keySet()) {
- resourceFinder.removeLocator(locator);
- }
- System.gc();
- }
-
- public void execute(IProgressMonitor monitor) throws OseeCoreException {
- List<TraceUnitCollector> collectors = new ArrayList<TraceUnitCollector>();
- try {
- for (ITraceUnitResourceLocator locator : traceUnitHandlers.keySet()) {
- Collection<ITraceParser> parsers = traceUnitHandlers.getValues(locator);
- for (ITraceParser parser : parsers) {
- TraceUnitCollector testUnitCollector = new TraceUnitCollector(locator, parser);
- resourceFinder.addLocator(locator, testUnitCollector);
- collectors.add(testUnitCollector);
- }
- }
-
- final int TOTAL_WORK = Integer.MAX_VALUE;
- final int QUARTER_TOTAL = TOTAL_WORK / 4;
-
- SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, QUARTER_TOTAL);
- resourceFinder.execute(subMonitor);
-
- if (!monitor.isCanceled()) {
- subMonitor = new SubProgressMonitor(monitor, QUARTER_TOTAL);
- notifyOnInitialize(subMonitor);
- }
-
- if (!monitor.isCanceled()) {
- subMonitor = new SubProgressMonitor(monitor, QUARTER_TOTAL);
- subMonitor.beginTask("Processing", collectors.size());
- for (TraceUnitCollector collector : collectors) {
- if (monitor.isCanceled()) {
- break;
- }
- if (!collector.isEmpty()) {
- processCollector(subMonitor, collector);
- }
- subMonitor.worked(1);
- }
- subMonitor.done();
- }
-
- if (!monitor.isCanceled()) {
- subMonitor = new SubProgressMonitor(monitor, QUARTER_TOTAL);
- notifyOnComplete(subMonitor);
- }
- } finally {
- collectors.clear();
- clear();
- }
- }
-
- private void processCollector(IProgressMonitor monitor, TraceUnitCollector testUnitCollector) throws OseeCoreException {
- for (String testUnitType : testUnitCollector.getTraceUnitTypes()) {
- if (monitor.isCanceled()) {
- break;
- }
- Map<String, TraceUnit> unitToTrace = testUnitCollector.getUnitsToTraceMarks(testUnitType);
- if (unitToTrace != null) {
- for (String testUnitName : unitToTrace.keySet()) {
- monitor.subTask(String.format("Processing [%s - %s]", testUnitType, testUnitName));
- if (monitor.isCanceled()) {
- break;
- }
- TraceUnit testUnit = unitToTrace.get(testUnitName);
- if (testUnit != null) {
- notifyOnProcess(monitor, testUnit);
- }
- }
- }
- }
- }
-
- private void notifyOnProcess(IProgressMonitor monitor, TraceUnit testUnit) throws OseeCoreException {
- for (ITraceUnitProcessor traceProcessor : traceProcessors) {
- traceProcessor.process(monitor, testUnit);
- }
- }
-
- private void notifyOnInitialize(IProgressMonitor monitor) {
- monitor.beginTask("Initialize", traceProcessors.size());
- for (ITraceUnitProcessor traceProcessor : traceProcessors) {
- monitor.subTask(String.format("Initializing [%s]", traceProcessor.getClass().getSimpleName()));
- traceProcessor.initialize(monitor);
- monitor.worked(1);
- }
- }
-
- private void notifyOnComplete(IProgressMonitor monitor) throws OseeCoreException {
- monitor.beginTask("On Completion", traceProcessors.size());
- for (ITraceUnitProcessor traceProcessor : traceProcessors) {
- monitor.subTask(String.format("Completing [%s]", traceProcessor.getClass().getSimpleName()));
- traceProcessor.onComplete(monitor);
- monitor.worked(1);
- }
- }
-
- private static final class TraceUnitCollector implements IResourceHandler {
-
- private final ITraceParser traceParser;
- private final ITraceUnitResourceLocator traceUnitLocator;
- private final Map<String, Map<String, TraceUnit>> traceUnitToTraceMarks;
-
- public TraceUnitCollector(ITraceUnitResourceLocator traceUnitLocator, ITraceParser traceParser) {
- this.traceParser = traceParser;
- this.traceUnitLocator = traceUnitLocator;
- this.traceUnitToTraceMarks = new HashMap<String, Map<String, TraceUnit>>();
- }
-
- @Override
- public void onResourceFound(URI uriPath, String name, CharBuffer fileBuffer) {
- String traceUnitType = traceUnitLocator.getTraceUnitType(name, fileBuffer);
- if (Strings.isValid(traceUnitType) && !traceUnitType.equalsIgnoreCase(ITraceUnitResourceLocator.UNIT_TYPE_UNKNOWN)) {
- Collection<TraceMark> traceMarks = traceParser.getTraceMarks(fileBuffer);
- if (traceMarks != null && !traceMarks.isEmpty()) {
- Map<String, TraceUnit> traceUnits = traceUnitToTraceMarks.get(traceUnitType);
- if (traceUnits == null) {
- traceUnits = new HashMap<String, TraceUnit>();
- traceUnitToTraceMarks.put(traceUnitType, traceUnits);
- }
- TraceUnit unit = traceUnits.get(name);
- if (unit == null) {
- unit = new TraceUnit(traceUnitType, name);
- traceUnits.put(name, unit);
- }
- unit.addAllTraceMarks(traceMarks);
- }
- }
- }
-
- public boolean isEmpty() {
- return traceUnitToTraceMarks.isEmpty();
- }
-
- public Set<String> getTraceUnitTypes() {
- return traceUnitToTraceMarks.keySet();
- }
-
- public Map<String, TraceUnit> getUnitsToTraceMarks(String unitType) {
- return traceUnitToTraceMarks.get(unitType);
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability.operations;
+
+import java.net.URI;
+import java.nio.CharBuffer;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.osee.define.traceability.ITraceParser;
+import org.eclipse.osee.define.traceability.ITraceUnitResourceLocator;
+import org.eclipse.osee.define.traceability.data.TraceMark;
+import org.eclipse.osee.define.traceability.data.TraceUnit;
+import org.eclipse.osee.define.utility.IResourceHandler;
+import org.eclipse.osee.define.utility.UriResourceContentFinder;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.HashCollection;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ResourceToTraceUnit {
+
+ private final UriResourceContentFinder resourceFinder;
+ private final Set<ITraceUnitProcessor> traceProcessors;
+ private final HashCollection<ITraceUnitResourceLocator, ITraceParser> traceUnitHandlers;
+
+ public ResourceToTraceUnit(final URI source, final boolean isRecursionAllowed, final boolean isFileWithMultiplePaths) {
+ super();
+ this.traceUnitHandlers = new HashCollection<ITraceUnitResourceLocator, ITraceParser>();
+ this.traceProcessors = Collections.synchronizedSet(new HashSet<ITraceUnitProcessor>());
+ this.resourceFinder = new UriResourceContentFinder(source, isRecursionAllowed, isFileWithMultiplePaths);
+ }
+
+ public void addTraceProcessor(ITraceUnitProcessor traceProcessor) {
+ synchronized (traceProcessors) {
+ traceProcessors.add(traceProcessor);
+ }
+ }
+
+ public void removeTraceProcessor(ITraceUnitProcessor traceProcessor) {
+ synchronized (traceProcessors) {
+ traceProcessors.remove(traceProcessor);
+ }
+ }
+
+ public void addTraceUnitHandler(ITraceUnitResourceLocator locator, ITraceParser parser) {
+ traceUnitHandlers.put(locator, parser);
+ }
+
+ public void removeTestUnitLocator(ITraceUnitResourceLocator locator) {
+ traceUnitHandlers.removeValues(locator);
+ }
+
+ private void clear() {
+ for (ITraceUnitProcessor traceProcessor : traceProcessors) {
+ traceProcessor.clear();
+ }
+ for (ITraceUnitResourceLocator locator : traceUnitHandlers.keySet()) {
+ resourceFinder.removeLocator(locator);
+ }
+ System.gc();
+ }
+
+ public void execute(IProgressMonitor monitor) throws OseeCoreException {
+ List<TraceUnitCollector> collectors = new ArrayList<TraceUnitCollector>();
+ try {
+ for (ITraceUnitResourceLocator locator : traceUnitHandlers.keySet()) {
+ Collection<ITraceParser> parsers = traceUnitHandlers.getValues(locator);
+ for (ITraceParser parser : parsers) {
+ TraceUnitCollector testUnitCollector = new TraceUnitCollector(locator, parser);
+ resourceFinder.addLocator(locator, testUnitCollector);
+ collectors.add(testUnitCollector);
+ }
+ }
+
+ final int TOTAL_WORK = Integer.MAX_VALUE;
+ final int QUARTER_TOTAL = TOTAL_WORK / 4;
+
+ SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, QUARTER_TOTAL);
+ resourceFinder.execute(subMonitor);
+
+ if (!monitor.isCanceled()) {
+ subMonitor = new SubProgressMonitor(monitor, QUARTER_TOTAL);
+ notifyOnInitialize(subMonitor);
+ }
+
+ if (!monitor.isCanceled()) {
+ subMonitor = new SubProgressMonitor(monitor, QUARTER_TOTAL);
+ subMonitor.beginTask("Processing", collectors.size());
+ for (TraceUnitCollector collector : collectors) {
+ if (monitor.isCanceled()) {
+ break;
+ }
+ if (!collector.isEmpty()) {
+ processCollector(subMonitor, collector);
+ }
+ subMonitor.worked(1);
+ }
+ subMonitor.done();
+ }
+
+ if (!monitor.isCanceled()) {
+ subMonitor = new SubProgressMonitor(monitor, QUARTER_TOTAL);
+ notifyOnComplete(subMonitor);
+ }
+ } finally {
+ collectors.clear();
+ clear();
+ }
+ }
+
+ private void processCollector(IProgressMonitor monitor, TraceUnitCollector testUnitCollector) throws OseeCoreException {
+ for (String testUnitType : testUnitCollector.getTraceUnitTypes()) {
+ if (monitor.isCanceled()) {
+ break;
+ }
+ Map<String, TraceUnit> unitToTrace = testUnitCollector.getUnitsToTraceMarks(testUnitType);
+ if (unitToTrace != null) {
+ for (String testUnitName : unitToTrace.keySet()) {
+ monitor.subTask(String.format("Processing [%s - %s]", testUnitType, testUnitName));
+ if (monitor.isCanceled()) {
+ break;
+ }
+ TraceUnit testUnit = unitToTrace.get(testUnitName);
+ if (testUnit != null) {
+ notifyOnProcess(monitor, testUnit);
+ }
+ }
+ }
+ }
+ }
+
+ private void notifyOnProcess(IProgressMonitor monitor, TraceUnit testUnit) throws OseeCoreException {
+ for (ITraceUnitProcessor traceProcessor : traceProcessors) {
+ traceProcessor.process(monitor, testUnit);
+ }
+ }
+
+ private void notifyOnInitialize(IProgressMonitor monitor) {
+ monitor.beginTask("Initialize", traceProcessors.size());
+ for (ITraceUnitProcessor traceProcessor : traceProcessors) {
+ monitor.subTask(String.format("Initializing [%s]", traceProcessor.getClass().getSimpleName()));
+ traceProcessor.initialize(monitor);
+ monitor.worked(1);
+ }
+ }
+
+ private void notifyOnComplete(IProgressMonitor monitor) throws OseeCoreException {
+ monitor.beginTask("On Completion", traceProcessors.size());
+ for (ITraceUnitProcessor traceProcessor : traceProcessors) {
+ monitor.subTask(String.format("Completing [%s]", traceProcessor.getClass().getSimpleName()));
+ traceProcessor.onComplete(monitor);
+ monitor.worked(1);
+ }
+ }
+
+ private static final class TraceUnitCollector implements IResourceHandler {
+
+ private final ITraceParser traceParser;
+ private final ITraceUnitResourceLocator traceUnitLocator;
+ private final Map<String, Map<String, TraceUnit>> traceUnitToTraceMarks;
+
+ public TraceUnitCollector(ITraceUnitResourceLocator traceUnitLocator, ITraceParser traceParser) {
+ this.traceParser = traceParser;
+ this.traceUnitLocator = traceUnitLocator;
+ this.traceUnitToTraceMarks = new HashMap<String, Map<String, TraceUnit>>();
+ }
+
+ @Override
+ public void onResourceFound(URI uriPath, String name, CharBuffer fileBuffer) {
+ String traceUnitType = traceUnitLocator.getTraceUnitType(name, fileBuffer);
+ if (Strings.isValid(traceUnitType) && !traceUnitType.equalsIgnoreCase(ITraceUnitResourceLocator.UNIT_TYPE_UNKNOWN)) {
+ Collection<TraceMark> traceMarks = traceParser.getTraceMarks(fileBuffer);
+ if (traceMarks != null && !traceMarks.isEmpty()) {
+ Map<String, TraceUnit> traceUnits = traceUnitToTraceMarks.get(traceUnitType);
+ if (traceUnits == null) {
+ traceUnits = new HashMap<String, TraceUnit>();
+ traceUnitToTraceMarks.put(traceUnitType, traceUnits);
+ }
+ TraceUnit unit = traceUnits.get(name);
+ if (unit == null) {
+ unit = new TraceUnit(traceUnitType, name);
+ traceUnits.put(name, unit);
+ }
+ unit.addAllTraceMarks(traceMarks);
+ }
+ }
+ }
+
+ public boolean isEmpty() {
+ return traceUnitToTraceMarks.isEmpty();
+ }
+
+ public Set<String> getTraceUnitTypes() {
+ return traceUnitToTraceMarks.keySet();
+ }
+
+ public Map<String, TraceUnit> getUnitsToTraceMarks(String unitType) {
+ return traceUnitToTraceMarks.get(unitType);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitFromResourceOperation.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitFromResourceOperation.java
index 98c5eefa5a..0b98d6a4fc 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitFromResourceOperation.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitFromResourceOperation.java
@@ -1,122 +1,122 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability.operations;
-
-import java.net.URI;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Set;
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileInfo;
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.osee.define.traceability.TraceUnitExtensionManager;
-import org.eclipse.osee.define.traceability.TraceUnitExtensionManager.TraceHandler;
-import org.eclipse.osee.framework.core.enums.BranchType;
-import org.eclipse.osee.framework.core.exception.OseeArgumentException;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeExceptions;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.jdk.core.util.Collections;
-
-/**
- * @author Roberto E. Escobar
- */
-public class TraceUnitFromResourceOperation {
-
- public static Set<String> getTraceUnitHandlerIds() throws OseeCoreException {
- return TraceUnitExtensionManager.getInstance().getTraceUnitHandlerIds();
- }
-
- private static ResourceToTraceUnit getResourceToTestUnit(URI source, boolean isRecursive, boolean isFileWithMultiplePaths, String... testUnitTraceIds) throws OseeCoreException {
- checkSourceArgument(source);
- checkTraceUnitHandlerIdsArgument(testUnitTraceIds);
-
- ResourceToTraceUnit operation = new ResourceToTraceUnit(source, isRecursive, isFileWithMultiplePaths);
- TraceUnitExtensionManager traceManager = TraceUnitExtensionManager.getInstance();
- for (String traceUnitHandlerId : testUnitTraceIds) {
-
- TraceHandler handler = traceManager.getTraceUnitHandlerById(traceUnitHandlerId);
- if (handler != null) {
- operation.addTraceUnitHandler(handler.getLocator(), handler.getParser());
- }
- }
- return operation;
- }
-
- public static void printTraceFromTestUnits(IProgressMonitor monitor, URI source, boolean isRecursive, boolean isFileWithMultiplePaths, String... traceUnitHandlerIds) throws OseeCoreException {
- ResourceToTraceUnit operation =
- getResourceToTestUnit(source, isRecursive, isFileWithMultiplePaths, traceUnitHandlerIds);
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- operation.addTraceProcessor(new TraceUnitReportProcessor());
- operation.execute(monitor);
- }
-
- public static void importTraceFromTestUnits(IProgressMonitor monitor, URI source, boolean isRecursive, boolean isFileWithMultiplePaths, Branch importToBranch, String... traceUnitHandlerIds) throws OseeCoreException {
- checkBranchArguments(importToBranch);
-
- ResourceToTraceUnit operation =
- getResourceToTestUnit(source, isRecursive, isFileWithMultiplePaths, traceUnitHandlerIds);
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- operation.addTraceProcessor(new TraceUnitToArtifactProcessor(importToBranch));
- operation.execute(monitor);
- }
-
- private static void checkTraceUnitHandlerIdsArgument(String... traceUnitHandlerIds) throws OseeCoreException {
- if (traceUnitHandlerIds == null) {
- throw new OseeArgumentException("Test unit trace ids was null");
- }
- if (traceUnitHandlerIds.length == 0) {
- throw new OseeArgumentException("Test unit trace ids was empty");
- }
-
- try {
- Set<String> ids = getTraceUnitHandlerIds();
- List<String> notFound = Collections.setComplement(Arrays.asList(traceUnitHandlerIds), ids);
- if (!notFound.isEmpty()) {
- throw new OseeArgumentException(String.format("Invalid test unit trace id(s) [%s]", notFound));
- }
- } catch (Exception ex) {
- OseeExceptions.wrapAndThrow(ex);
- }
- }
-
- private static void checkSourceArgument(URI source) throws OseeArgumentException {
- if (source == null) {
- throw new OseeArgumentException("Source was null");
- }
- try {
- IFileStore fileStore = EFS.getStore(source);
- IFileInfo fileInfo = fileStore.fetchInfo();
- if (!fileInfo.exists()) {
- throw new OseeArgumentException(String.format("Unable to access source: [%s]", source));
- }
- } catch (CoreException ex) {
- throw new OseeArgumentException(String.format("Unable to access source: [%s]", source));
- }
- }
-
- private static void checkBranchArguments(Branch importToBranch) throws OseeArgumentException {
- if (importToBranch == null) {
- throw new OseeArgumentException("Branch to import into was null");
- }
- if (!importToBranch.getBranchType().isOfType(BranchType.WORKING)) {
- throw new OseeArgumentException(String.format("Branch to import into was not a working branch: [%s]",
- importToBranch));
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability.operations;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileInfo;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.osee.define.traceability.TraceUnitExtensionManager;
+import org.eclipse.osee.define.traceability.TraceUnitExtensionManager.TraceHandler;
+import org.eclipse.osee.framework.core.enums.BranchType;
+import org.eclipse.osee.framework.core.exception.OseeArgumentException;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class TraceUnitFromResourceOperation {
+
+ public static Set<String> getTraceUnitHandlerIds() throws OseeCoreException {
+ return TraceUnitExtensionManager.getInstance().getTraceUnitHandlerIds();
+ }
+
+ private static ResourceToTraceUnit getResourceToTestUnit(URI source, boolean isRecursive, boolean isFileWithMultiplePaths, String... testUnitTraceIds) throws OseeCoreException {
+ checkSourceArgument(source);
+ checkTraceUnitHandlerIdsArgument(testUnitTraceIds);
+
+ ResourceToTraceUnit operation = new ResourceToTraceUnit(source, isRecursive, isFileWithMultiplePaths);
+ TraceUnitExtensionManager traceManager = TraceUnitExtensionManager.getInstance();
+ for (String traceUnitHandlerId : testUnitTraceIds) {
+
+ TraceHandler handler = traceManager.getTraceUnitHandlerById(traceUnitHandlerId);
+ if (handler != null) {
+ operation.addTraceUnitHandler(handler.getLocator(), handler.getParser());
+ }
+ }
+ return operation;
+ }
+
+ public static void printTraceFromTestUnits(IProgressMonitor monitor, URI source, boolean isRecursive, boolean isFileWithMultiplePaths, String... traceUnitHandlerIds) throws OseeCoreException {
+ ResourceToTraceUnit operation =
+ getResourceToTestUnit(source, isRecursive, isFileWithMultiplePaths, traceUnitHandlerIds);
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ operation.addTraceProcessor(new TraceUnitReportProcessor());
+ operation.execute(monitor);
+ }
+
+ public static void importTraceFromTestUnits(IProgressMonitor monitor, URI source, boolean isRecursive, boolean isFileWithMultiplePaths, Branch importToBranch, String... traceUnitHandlerIds) throws OseeCoreException {
+ checkBranchArguments(importToBranch);
+
+ ResourceToTraceUnit operation =
+ getResourceToTestUnit(source, isRecursive, isFileWithMultiplePaths, traceUnitHandlerIds);
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ operation.addTraceProcessor(new TraceUnitToArtifactProcessor(importToBranch));
+ operation.execute(monitor);
+ }
+
+ private static void checkTraceUnitHandlerIdsArgument(String... traceUnitHandlerIds) throws OseeCoreException {
+ if (traceUnitHandlerIds == null) {
+ throw new OseeArgumentException("Test unit trace ids was null");
+ }
+ if (traceUnitHandlerIds.length == 0) {
+ throw new OseeArgumentException("Test unit trace ids was empty");
+ }
+
+ try {
+ Set<String> ids = getTraceUnitHandlerIds();
+ List<String> notFound = Collections.setComplement(Arrays.asList(traceUnitHandlerIds), ids);
+ if (!notFound.isEmpty()) {
+ throw new OseeArgumentException(String.format("Invalid test unit trace id(s) [%s]", notFound));
+ }
+ } catch (Exception ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ }
+ }
+
+ private static void checkSourceArgument(URI source) throws OseeArgumentException {
+ if (source == null) {
+ throw new OseeArgumentException("Source was null");
+ }
+ try {
+ IFileStore fileStore = EFS.getStore(source);
+ IFileInfo fileInfo = fileStore.fetchInfo();
+ if (!fileInfo.exists()) {
+ throw new OseeArgumentException(String.format("Unable to access source: [%s]", source));
+ }
+ } catch (CoreException ex) {
+ throw new OseeArgumentException(String.format("Unable to access source: [%s]", source));
+ }
+ }
+
+ private static void checkBranchArguments(Branch importToBranch) throws OseeArgumentException {
+ if (importToBranch == null) {
+ throw new OseeArgumentException("Branch to import into was null");
+ }
+ if (!importToBranch.getBranchType().isOfType(BranchType.WORKING)) {
+ throw new OseeArgumentException(String.format("Branch to import into was not a working branch: [%s]",
+ importToBranch));
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitReportProcessor.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitReportProcessor.java
index 4f99dcf3a5..a0992cf5b0 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitReportProcessor.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitReportProcessor.java
@@ -1,72 +1,72 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability.operations;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.define.traceability.data.TraceMark;
-import org.eclipse.osee.define.traceability.data.TraceUnit;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.AHTML;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.ui.skynet.results.XResultData;
-
-/**
- * @author Roberto E. Escobar
- */
-public final class TraceUnitReportProcessor implements ITraceUnitProcessor {
- private long startTime;
- private long startMemory;
- private XResultData resultData;
-
- public TraceUnitReportProcessor() {
- this.resultData = new XResultData();
- startTime = System.currentTimeMillis();
- startMemory = Runtime.getRuntime().totalMemory();
- }
-
- @Override
- public void clear() {
- startTime = 0;
- startMemory = 0;
- }
-
- @Override
- public void initialize(IProgressMonitor monitor) {
- resultData.addRaw(AHTML.beginMultiColumnTable(95, 1));
- resultData.addRaw(AHTML.addHeaderRowMultiColumnTable(new String[] {"Test Unit Type", "Test Unit Name",
- "Trace Type", "Trace Mark"}));
- }
-
- @Override
- public void process(IProgressMonitor monitor, TraceUnit testUnit) {
- if (testUnit != null) {
- for (String traceTypes : testUnit.getTraceMarkTypes()) {
- for (TraceMark traceMark : testUnit.getTraceMarksByType(traceTypes)) {
- if (monitor.isCanceled()) break;
- resultData.addRaw(AHTML.addRowMultiColumnTable(testUnit.getTraceUnitType(), testUnit.getName(),
- traceMark.getTraceType(), traceMark.getRawTraceMark()));
- }
- }
- }
- }
-
- @Override
- public void onComplete(IProgressMonitor monitor) {
- resultData.addRaw(AHTML.endMultiColumnTable());
- System.out.println(String.format("Completed in: %s", Lib.getElapseString(startTime)));
- System.out.println(String.format("Memory Leaked: %s", Runtime.getRuntime().totalMemory() - startMemory));
- try {
- resultData.report("Report");
- } catch (OseeCoreException ex) {
- //
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability.operations;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.define.traceability.data.TraceMark;
+import org.eclipse.osee.define.traceability.data.TraceUnit;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.util.AHTML;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.ui.skynet.results.XResultData;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class TraceUnitReportProcessor implements ITraceUnitProcessor {
+ private long startTime;
+ private long startMemory;
+ private XResultData resultData;
+
+ public TraceUnitReportProcessor() {
+ this.resultData = new XResultData();
+ startTime = System.currentTimeMillis();
+ startMemory = Runtime.getRuntime().totalMemory();
+ }
+
+ @Override
+ public void clear() {
+ startTime = 0;
+ startMemory = 0;
+ }
+
+ @Override
+ public void initialize(IProgressMonitor monitor) {
+ resultData.addRaw(AHTML.beginMultiColumnTable(95, 1));
+ resultData.addRaw(AHTML.addHeaderRowMultiColumnTable(new String[] {"Test Unit Type", "Test Unit Name",
+ "Trace Type", "Trace Mark"}));
+ }
+
+ @Override
+ public void process(IProgressMonitor monitor, TraceUnit testUnit) {
+ if (testUnit != null) {
+ for (String traceTypes : testUnit.getTraceMarkTypes()) {
+ for (TraceMark traceMark : testUnit.getTraceMarksByType(traceTypes)) {
+ if (monitor.isCanceled()) break;
+ resultData.addRaw(AHTML.addRowMultiColumnTable(testUnit.getTraceUnitType(), testUnit.getName(),
+ traceMark.getTraceType(), traceMark.getRawTraceMark()));
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onComplete(IProgressMonitor monitor) {
+ resultData.addRaw(AHTML.endMultiColumnTable());
+ System.out.println(String.format("Completed in: %s", Lib.getElapseString(startTime)));
+ System.out.println(String.format("Memory Leaked: %s", Runtime.getRuntime().totalMemory() - startMemory));
+ try {
+ resultData.report("Report");
+ } catch (OseeCoreException ex) {
+ //
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitToArtifactProcessor.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitToArtifactProcessor.java
index 58d4f4a0f9..4d750a001b 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitToArtifactProcessor.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitToArtifactProcessor.java
@@ -1,392 +1,392 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability.operations;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.nebula.widgets.xviewer.XViewerColumn;
-import org.eclipse.nebula.widgets.xviewer.XViewerColumn.SortDataType;
-import org.eclipse.osee.define.DefinePlugin;
-import org.eclipse.osee.define.traceability.TraceabilityExtractor;
-import org.eclipse.osee.define.traceability.data.CodeUnitData;
-import org.eclipse.osee.define.traceability.data.RequirementData;
-import org.eclipse.osee.define.traceability.data.TestUnitData;
-import org.eclipse.osee.define.traceability.data.TraceMark;
-import org.eclipse.osee.define.traceability.data.TraceUnit;
-import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
-import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
-import org.eclipse.osee.framework.core.enums.IRelationEnumeration;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.core.model.type.ArtifactType;
-import org.eclipse.osee.framework.jdk.core.type.HashCollection;
-import org.eclipse.osee.framework.jdk.core.type.Pair;
-import org.eclipse.osee.framework.plugin.core.util.IExceptionableRunnable;
-import org.eclipse.osee.framework.plugin.core.util.Jobs;
-import org.eclipse.osee.framework.skynet.core.OseeSystemArtifacts;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
-import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
-import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
-import org.eclipse.osee.framework.skynet.core.utility.Requirements;
-import org.eclipse.osee.framework.ui.skynet.results.IResultsEditorProvider;
-import org.eclipse.osee.framework.ui.skynet.results.IResultsEditorTab;
-import org.eclipse.osee.framework.ui.skynet.results.ResultsEditor;
-import org.eclipse.osee.framework.ui.skynet.results.html.ResultsEditorHtmlTab;
-import org.eclipse.osee.framework.ui.skynet.results.table.IResultsXViewerRow;
-import org.eclipse.osee.framework.ui.skynet.results.table.ResultsEditorTableTab;
-import org.eclipse.osee.framework.ui.skynet.results.table.ResultsXViewerRow;
-import org.eclipse.swt.SWT;
-
-/**
- * @author Roberto E. Escobar
- */
-public class TraceUnitToArtifactProcessor implements ITraceUnitProcessor {
- private RequirementData requirementData;
-
- private CodeUnitData codeUnitData;
- private TestUnitData testUnitData;
-
- private final Branch importIntoBranch;
- private SkynetTransaction transaction;
-
- private final HashCollection<TraceUnit, TraceMark> reportTraceNotFound;
- private final HashCollection<String, String> unknownRelationError;
- private final Set<String> unRelatedUnits;
-
- public TraceUnitToArtifactProcessor(Branch importIntoBranch) {
- this.importIntoBranch = importIntoBranch;
- this.reportTraceNotFound = new HashCollection<TraceUnit, TraceMark>(false, HashSet.class);
- this.unknownRelationError = new HashCollection<String, String>(false, HashSet.class);
- this.unRelatedUnits = new HashSet<String>();
- }
-
- @Override
- public void clear() {
- transaction = null;
- if (requirementData != null) {
- requirementData.reset();
- requirementData = null;
- }
- if (testUnitData != null) {
- testUnitData.reset();
- testUnitData = null;
- }
- if (codeUnitData != null) {
- codeUnitData.reset();
- codeUnitData = null;
- }
- }
-
- @Override
- public void initialize(IProgressMonitor monitor) {
- transaction = null;
- requirementData = new RequirementData(importIntoBranch);
- if (!monitor.isCanceled()) {
- requirementData.initialize(monitor);
- }
- }
-
- private Artifact getArtifactFromCache(IProgressMonitor monitor, String artifactTypeName, String name) throws OseeCoreException {
- ArtifactType typeValue = ArtifactTypeManager.getType(artifactTypeName);
- if (typeValue.inheritsFrom(CoreArtifactTypes.TestUnit)) {
- if (testUnitData == null) {
- testUnitData = new TestUnitData(importIntoBranch);
- if (!monitor.isCanceled()) {
- testUnitData.initialize(monitor);
- }
- }
- return testUnitData.getTestUnitByName(name);
- } else if (typeValue.inheritsFrom(CoreArtifactTypes.CodeUnit)) {
- if (codeUnitData == null) {
- codeUnitData = new CodeUnitData(importIntoBranch);
- if (!monitor.isCanceled()) {
- codeUnitData.initialize(monitor);
- }
- }
- return codeUnitData.getCodeUnitByName(name);
- }
- return null;
- }
-
- @Override
- public void process(IProgressMonitor monitor, TraceUnit traceUnit) throws OseeCoreException {
- if (transaction == null) {
- transaction = new SkynetTransaction(importIntoBranch, "Importing Trace Unit(s)");
- }
- boolean hasChange = false;
- boolean artifactWasCreated = false;
- boolean wasRelated = false;
- String traceUnitType = traceUnit.getTraceUnitType();
-
- Artifact traceUnitArtifact = getArtifactFromCache(monitor, traceUnitType, traceUnit.getName());
- if (traceUnitArtifact == null) {
- traceUnitArtifact =
- ArtifactTypeManager.addArtifact(traceUnit.getTraceUnitType(), transaction.getBranch(),
- traceUnit.getName());
- artifactWasCreated = true;
- }
-
- for (TraceMark traceMark : traceUnit.getTraceMarks()) {
- if (monitor.isCanceled()) {
- break;
- }
-
- Artifact requirementArtifact = getRequirementArtifact(traceMark.getRawTraceMark(), requirementData);
- if (requirementArtifact != null) {
- IRelationEnumeration relationType = getRelationFromTraceType(traceUnitArtifact, traceMark.getTraceType());
- if (relationType == null) {
- unknownRelationError.put(traceUnitArtifact.getArtifactTypeName(), traceMark.getTraceType());
- } else if (!requirementArtifact.isRelated(relationType, traceUnitArtifact)) {
- requirementArtifact.addRelation(relationType, traceUnitArtifact);
- hasChange = true;
- wasRelated = true;
- } else {
- wasRelated = true;
- }
- } else {
- reportTraceNotFound.put(traceUnit, traceMark);
- }
- }
-
- // TODO Report Items that were not used from the TEST UNIT DATA Structure
- // Not Part of this class though
- if (!wasRelated) {
- unRelatedUnits.add(traceUnitArtifact.getName());
- }
-
- if (hasChange || artifactWasCreated) {
- HierarchyHandler.addArtifact(transaction, traceUnitArtifact);
- if (traceUnitArtifact.isOfType(CoreArtifactTypes.AbstractTestUnit)) {
- TestRunHandler.linkWithTestUnit(transaction, traceUnitArtifact);
- }
- traceUnitArtifact.persist(transaction);
- }
- }
-
- private boolean isUsesTraceType(String traceType) {
- return traceType.equalsIgnoreCase("USES");
- }
-
- private IRelationEnumeration getRelationFromTraceType(Artifact traceUnitArtifact, String traceType) throws OseeCoreException {
- if (traceUnitArtifact.isOfType(CoreArtifactTypes.TestUnit)) {
- if (isUsesTraceType(traceType)) {
- return CoreRelationTypes.Uses__TestUnit;
- } else {
- return CoreRelationTypes.Verification__Verifier;
- }
- } else if (traceUnitArtifact.isOfType(CoreArtifactTypes.CodeUnit)) {
- return CoreRelationTypes.CodeRequirement_CodeUnit;
- }
- return null;
- }
-
- private Artifact getRequirementArtifact(String traceMark, RequirementData requirementData) {
- Artifact toReturn = requirementData.getRequirementFromTraceMark(traceMark);
- if (toReturn == null) {
- Pair<String, String> structuredRequirement =
- TraceabilityExtractor.getInstance().getStructuredRequirement(traceMark);
- if (structuredRequirement != null) {
- toReturn = requirementData.getRequirementFromTraceMark(structuredRequirement.getFirst());
- }
- }
- return toReturn;
- }
-
- @Override
- public void onComplete(IProgressMonitor monitor) throws OseeCoreException {
- try {
- if (!monitor.isCanceled()) {
- if (transaction != null) {
- transaction.execute();
- }
- }
- } finally {
- openReport();
- }
- }
-
- private void openReport() {
- IExceptionableRunnable runnable = new IExceptionableRunnable() {
-
- @Override
- public IStatus run(IProgressMonitor monitor) throws Exception {
- ResultsEditor.open(new ResultEditorProvider());
- return Status.OK_STATUS;
- }
- };
- Jobs.runInJob("Trace Unit to Artifact Report", runnable, DefinePlugin.class, DefinePlugin.PLUGIN_ID);
- }
-
- private static final class TestRunHandler {
-
- private static void createGuidLink(Artifact testCase, Artifact testRun) throws OseeCoreException {
- if (testCase != null) {
- testRun.setSoleAttributeValue("Test Script GUID", testCase.getGuid());
- }
- }
-
- public static void linkWithTestUnit(SkynetTransaction transaction, Artifact testCase) throws OseeCoreException {
- if (testCase.isOfType(CoreArtifactTypes.TestCase)) {
- List<Artifact> testRuns =
- ArtifactQuery.getArtifactListFromTypeAndName(CoreArtifactTypes.TestRun, testCase.getName(),
- transaction.getBranch());
-
- for (Artifact testRun : testRuns) {
- createGuidLink(testCase, testRun);
- }
- }
- }
- }
-
- private static final class HierarchyHandler {
-
- public static void addArtifact(SkynetTransaction transaction, Artifact testUnit) throws OseeCoreException {
- Artifact folder = null;
- if (testUnit.isOfType(CoreArtifactTypes.TestCase)) {
- folder = getOrCreateTestCaseFolder(transaction);
- } else if (testUnit.isOfType(CoreArtifactTypes.TestSupport)) {
- folder = getOrCreateTestSupportFolder(transaction);
- } else if (testUnit.isOfType(CoreArtifactTypes.CodeUnit)) {
- folder = getOrCreateCodeUnitFolder(transaction);
- } else {
- folder = getOrCreateUnknownTestUnitFolder(transaction);
- }
-
- if (folder != null && !folder.isRelated(CoreRelationTypes.Default_Hierarchical__Child, testUnit)) {
- folder.addChild(testUnit);
- folder.persist(transaction);
- }
- }
-
- private static Artifact getOrCreateUnknownTestUnitFolder(SkynetTransaction transaction) throws OseeCoreException {
- return getOrCreateTestUnitSubFolder(transaction, "Unknown Test Unit Type");
- }
-
- private static Artifact getOrCreateTestSupportFolder(SkynetTransaction transaction) throws OseeCoreException {
- return getOrCreateTestUnitSubFolder(transaction, Requirements.TEST_SUPPORT_UNITS);
- }
-
- private static Artifact getOrCreateTestCaseFolder(SkynetTransaction transaction) throws OseeCoreException {
- return getOrCreateTestUnitSubFolder(transaction, "Test Cases");
- }
-
- private static Artifact getOrCreateCodeUnitFolder(SkynetTransaction transaction) throws OseeCoreException {
- Artifact codeUnitFolder = getOrCreateFolder(transaction, "Code Units");
- Artifact root = OseeSystemArtifacts.getDefaultHierarchyRootArtifact(transaction.getBranch());
- if (!root.isRelated(CoreRelationTypes.Default_Hierarchical__Child, codeUnitFolder)) {
- root.addChild(codeUnitFolder);
- root.persist(transaction);
- }
- return codeUnitFolder;
- }
-
- private static Artifact getOrCreateTestUnitSubFolder(SkynetTransaction transaction, String folderName) throws OseeCoreException {
- Artifact subFolder = getOrCreateFolder(transaction, folderName);
- Artifact testUnits = getOrCreateTestUnitsFolder(transaction);
- if (!testUnits.isRelated(CoreRelationTypes.Default_Hierarchical__Child, subFolder)) {
- testUnits.addChild(subFolder);
- testUnits.persist(transaction);
- }
- return subFolder;
- }
-
- private static Artifact getOrCreateTestUnitsFolder(SkynetTransaction transaction) throws OseeCoreException {
- Artifact testUnitFolder = getOrCreateFolder(transaction, "Test Units");
- Artifact root = OseeSystemArtifacts.getDefaultHierarchyRootArtifact(transaction.getBranch());
- if (!root.isRelated(CoreRelationTypes.Default_Hierarchical__Child, testUnitFolder)) {
- root.addChild(testUnitFolder);
- root.persist(transaction);
- }
- return testUnitFolder;
- }
-
- private static Artifact getOrCreateFolder(SkynetTransaction transaction, String folderName) throws OseeCoreException {
- return OseeSystemArtifacts.getOrCreateArtifact(CoreArtifactTypes.Folder, folderName, transaction.getBranch());
- }
- }
-
- private final class ResultEditorProvider implements IResultsEditorProvider {
-
- @Override
- public String getEditorName() throws OseeCoreException {
- return "Trace Units To Artifacts Report";
- }
-
- private List<XViewerColumn> createColumns(String... columnNames) {
- List<XViewerColumn> columns = new ArrayList<XViewerColumn>();
- for (String name : columnNames) {
- columns.add(new XViewerColumn(name, name, 80, SWT.LEFT, true, SortDataType.String, false, ""));
- }
- return columns;
- }
-
- private void addUnRelatedTraceUnit(List<IResultsEditorTab> toReturn) {
- if (!unRelatedUnits.isEmpty()) {
- List<XViewerColumn> columns = createColumns("Trace Unit Name");
- List<IResultsXViewerRow> rows = new ArrayList<IResultsXViewerRow>();
- for (String artifactName : unRelatedUnits) {
- rows.add(new ResultsXViewerRow(new String[] {artifactName}));
- }
- toReturn.add(new ResultsEditorTableTab("Trace Units Created But Had No Relations", columns, rows));
- }
- }
-
- private void addTraceNotFoundTab(List<IResultsEditorTab> toReturn) {
- if (!reportTraceNotFound.isEmpty()) {
- List<XViewerColumn> columns =
- createColumns("Trace Unit Name", "Trace Unit Type", "Trace Mark Type", "Trace Mark");
-
- List<IResultsXViewerRow> rows = new ArrayList<IResultsXViewerRow>();
- for (TraceUnit unit : reportTraceNotFound.keySet()) {
- Collection<TraceMark> traceMarks = reportTraceNotFound.getValues(unit);
- for (TraceMark traceMark : traceMarks) {
- rows.add(new ResultsXViewerRow(new String[] {unit.getName(), unit.getTraceUnitType(),
- traceMark.getTraceType(), traceMark.getRawTraceMark()}));
- }
- }
- toReturn.add(new ResultsEditorTableTab("Trace Marks Not Found", columns, rows));
- }
- }
-
- private void addRelationTypeNotFoundTab(List<IResultsEditorTab> toReturn) {
- if (!unknownRelationError.isEmpty()) {
- List<XViewerColumn> columns = createColumns("Artifact Type", "Trace Mark Type");
- List<IResultsXViewerRow> rows = new ArrayList<IResultsXViewerRow>();
- for (String artifactType : unknownRelationError.keySet()) {
- Collection<String> traceTypes = unknownRelationError.getValues(artifactType);
- for (String traceType : traceTypes) {
- rows.add(new ResultsXViewerRow(new String[] {artifactType, traceType}));
- }
- }
- toReturn.add(new ResultsEditorTableTab("Invalid Artifact Type to Trace Relation", columns, rows));
- }
- }
-
- @Override
- public List<IResultsEditorTab> getResultsEditorTabs() throws OseeCoreException {
- List<IResultsEditorTab> toReturn = new ArrayList<IResultsEditorTab>();
- addTraceNotFoundTab(toReturn);
- addUnRelatedTraceUnit(toReturn);
- addRelationTypeNotFoundTab(toReturn);
- if (toReturn.isEmpty()) {
- toReturn.add(new ResultsEditorHtmlTab("Trace Unit Import Status", "Import Status", "All Items Linked"));
- }
- return toReturn;
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability.operations;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.nebula.widgets.xviewer.XViewerColumn;
+import org.eclipse.nebula.widgets.xviewer.XViewerColumn.SortDataType;
+import org.eclipse.osee.define.DefinePlugin;
+import org.eclipse.osee.define.traceability.TraceabilityExtractor;
+import org.eclipse.osee.define.traceability.data.CodeUnitData;
+import org.eclipse.osee.define.traceability.data.RequirementData;
+import org.eclipse.osee.define.traceability.data.TestUnitData;
+import org.eclipse.osee.define.traceability.data.TraceMark;
+import org.eclipse.osee.define.traceability.data.TraceUnit;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.enums.IRelationEnumeration;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.model.type.ArtifactType;
+import org.eclipse.osee.framework.jdk.core.type.HashCollection;
+import org.eclipse.osee.framework.jdk.core.type.Pair;
+import org.eclipse.osee.framework.plugin.core.util.IExceptionableRunnable;
+import org.eclipse.osee.framework.plugin.core.util.Jobs;
+import org.eclipse.osee.framework.skynet.core.OseeSystemArtifacts;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
+import org.eclipse.osee.framework.skynet.core.utility.Requirements;
+import org.eclipse.osee.framework.ui.skynet.results.IResultsEditorProvider;
+import org.eclipse.osee.framework.ui.skynet.results.IResultsEditorTab;
+import org.eclipse.osee.framework.ui.skynet.results.ResultsEditor;
+import org.eclipse.osee.framework.ui.skynet.results.html.ResultsEditorHtmlTab;
+import org.eclipse.osee.framework.ui.skynet.results.table.IResultsXViewerRow;
+import org.eclipse.osee.framework.ui.skynet.results.table.ResultsEditorTableTab;
+import org.eclipse.osee.framework.ui.skynet.results.table.ResultsXViewerRow;
+import org.eclipse.swt.SWT;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class TraceUnitToArtifactProcessor implements ITraceUnitProcessor {
+ private RequirementData requirementData;
+
+ private CodeUnitData codeUnitData;
+ private TestUnitData testUnitData;
+
+ private final Branch importIntoBranch;
+ private SkynetTransaction transaction;
+
+ private final HashCollection<TraceUnit, TraceMark> reportTraceNotFound;
+ private final HashCollection<String, String> unknownRelationError;
+ private final Set<String> unRelatedUnits;
+
+ public TraceUnitToArtifactProcessor(Branch importIntoBranch) {
+ this.importIntoBranch = importIntoBranch;
+ this.reportTraceNotFound = new HashCollection<TraceUnit, TraceMark>(false, HashSet.class);
+ this.unknownRelationError = new HashCollection<String, String>(false, HashSet.class);
+ this.unRelatedUnits = new HashSet<String>();
+ }
+
+ @Override
+ public void clear() {
+ transaction = null;
+ if (requirementData != null) {
+ requirementData.reset();
+ requirementData = null;
+ }
+ if (testUnitData != null) {
+ testUnitData.reset();
+ testUnitData = null;
+ }
+ if (codeUnitData != null) {
+ codeUnitData.reset();
+ codeUnitData = null;
+ }
+ }
+
+ @Override
+ public void initialize(IProgressMonitor monitor) {
+ transaction = null;
+ requirementData = new RequirementData(importIntoBranch);
+ if (!monitor.isCanceled()) {
+ requirementData.initialize(monitor);
+ }
+ }
+
+ private Artifact getArtifactFromCache(IProgressMonitor monitor, String artifactTypeName, String name) throws OseeCoreException {
+ ArtifactType typeValue = ArtifactTypeManager.getType(artifactTypeName);
+ if (typeValue.inheritsFrom(CoreArtifactTypes.TestUnit)) {
+ if (testUnitData == null) {
+ testUnitData = new TestUnitData(importIntoBranch);
+ if (!monitor.isCanceled()) {
+ testUnitData.initialize(monitor);
+ }
+ }
+ return testUnitData.getTestUnitByName(name);
+ } else if (typeValue.inheritsFrom(CoreArtifactTypes.CodeUnit)) {
+ if (codeUnitData == null) {
+ codeUnitData = new CodeUnitData(importIntoBranch);
+ if (!monitor.isCanceled()) {
+ codeUnitData.initialize(monitor);
+ }
+ }
+ return codeUnitData.getCodeUnitByName(name);
+ }
+ return null;
+ }
+
+ @Override
+ public void process(IProgressMonitor monitor, TraceUnit traceUnit) throws OseeCoreException {
+ if (transaction == null) {
+ transaction = new SkynetTransaction(importIntoBranch, "Importing Trace Unit(s)");
+ }
+ boolean hasChange = false;
+ boolean artifactWasCreated = false;
+ boolean wasRelated = false;
+ String traceUnitType = traceUnit.getTraceUnitType();
+
+ Artifact traceUnitArtifact = getArtifactFromCache(monitor, traceUnitType, traceUnit.getName());
+ if (traceUnitArtifact == null) {
+ traceUnitArtifact =
+ ArtifactTypeManager.addArtifact(traceUnit.getTraceUnitType(), transaction.getBranch(),
+ traceUnit.getName());
+ artifactWasCreated = true;
+ }
+
+ for (TraceMark traceMark : traceUnit.getTraceMarks()) {
+ if (monitor.isCanceled()) {
+ break;
+ }
+
+ Artifact requirementArtifact = getRequirementArtifact(traceMark.getRawTraceMark(), requirementData);
+ if (requirementArtifact != null) {
+ IRelationEnumeration relationType = getRelationFromTraceType(traceUnitArtifact, traceMark.getTraceType());
+ if (relationType == null) {
+ unknownRelationError.put(traceUnitArtifact.getArtifactTypeName(), traceMark.getTraceType());
+ } else if (!requirementArtifact.isRelated(relationType, traceUnitArtifact)) {
+ requirementArtifact.addRelation(relationType, traceUnitArtifact);
+ hasChange = true;
+ wasRelated = true;
+ } else {
+ wasRelated = true;
+ }
+ } else {
+ reportTraceNotFound.put(traceUnit, traceMark);
+ }
+ }
+
+ // TODO Report Items that were not used from the TEST UNIT DATA Structure
+ // Not Part of this class though
+ if (!wasRelated) {
+ unRelatedUnits.add(traceUnitArtifact.getName());
+ }
+
+ if (hasChange || artifactWasCreated) {
+ HierarchyHandler.addArtifact(transaction, traceUnitArtifact);
+ if (traceUnitArtifact.isOfType(CoreArtifactTypes.AbstractTestUnit)) {
+ TestRunHandler.linkWithTestUnit(transaction, traceUnitArtifact);
+ }
+ traceUnitArtifact.persist(transaction);
+ }
+ }
+
+ private boolean isUsesTraceType(String traceType) {
+ return traceType.equalsIgnoreCase("USES");
+ }
+
+ private IRelationEnumeration getRelationFromTraceType(Artifact traceUnitArtifact, String traceType) throws OseeCoreException {
+ if (traceUnitArtifact.isOfType(CoreArtifactTypes.TestUnit)) {
+ if (isUsesTraceType(traceType)) {
+ return CoreRelationTypes.Uses__TestUnit;
+ } else {
+ return CoreRelationTypes.Verification__Verifier;
+ }
+ } else if (traceUnitArtifact.isOfType(CoreArtifactTypes.CodeUnit)) {
+ return CoreRelationTypes.CodeRequirement_CodeUnit;
+ }
+ return null;
+ }
+
+ private Artifact getRequirementArtifact(String traceMark, RequirementData requirementData) {
+ Artifact toReturn = requirementData.getRequirementFromTraceMark(traceMark);
+ if (toReturn == null) {
+ Pair<String, String> structuredRequirement =
+ TraceabilityExtractor.getInstance().getStructuredRequirement(traceMark);
+ if (structuredRequirement != null) {
+ toReturn = requirementData.getRequirementFromTraceMark(structuredRequirement.getFirst());
+ }
+ }
+ return toReturn;
+ }
+
+ @Override
+ public void onComplete(IProgressMonitor monitor) throws OseeCoreException {
+ try {
+ if (!monitor.isCanceled()) {
+ if (transaction != null) {
+ transaction.execute();
+ }
+ }
+ } finally {
+ openReport();
+ }
+ }
+
+ private void openReport() {
+ IExceptionableRunnable runnable = new IExceptionableRunnable() {
+
+ @Override
+ public IStatus run(IProgressMonitor monitor) throws Exception {
+ ResultsEditor.open(new ResultEditorProvider());
+ return Status.OK_STATUS;
+ }
+ };
+ Jobs.runInJob("Trace Unit to Artifact Report", runnable, DefinePlugin.class, DefinePlugin.PLUGIN_ID);
+ }
+
+ private static final class TestRunHandler {
+
+ private static void createGuidLink(Artifact testCase, Artifact testRun) throws OseeCoreException {
+ if (testCase != null) {
+ testRun.setSoleAttributeValue("Test Script GUID", testCase.getGuid());
+ }
+ }
+
+ public static void linkWithTestUnit(SkynetTransaction transaction, Artifact testCase) throws OseeCoreException {
+ if (testCase.isOfType(CoreArtifactTypes.TestCase)) {
+ List<Artifact> testRuns =
+ ArtifactQuery.getArtifactListFromTypeAndName(CoreArtifactTypes.TestRun, testCase.getName(),
+ transaction.getBranch());
+
+ for (Artifact testRun : testRuns) {
+ createGuidLink(testCase, testRun);
+ }
+ }
+ }
+ }
+
+ private static final class HierarchyHandler {
+
+ public static void addArtifact(SkynetTransaction transaction, Artifact testUnit) throws OseeCoreException {
+ Artifact folder = null;
+ if (testUnit.isOfType(CoreArtifactTypes.TestCase)) {
+ folder = getOrCreateTestCaseFolder(transaction);
+ } else if (testUnit.isOfType(CoreArtifactTypes.TestSupport)) {
+ folder = getOrCreateTestSupportFolder(transaction);
+ } else if (testUnit.isOfType(CoreArtifactTypes.CodeUnit)) {
+ folder = getOrCreateCodeUnitFolder(transaction);
+ } else {
+ folder = getOrCreateUnknownTestUnitFolder(transaction);
+ }
+
+ if (folder != null && !folder.isRelated(CoreRelationTypes.Default_Hierarchical__Child, testUnit)) {
+ folder.addChild(testUnit);
+ folder.persist(transaction);
+ }
+ }
+
+ private static Artifact getOrCreateUnknownTestUnitFolder(SkynetTransaction transaction) throws OseeCoreException {
+ return getOrCreateTestUnitSubFolder(transaction, "Unknown Test Unit Type");
+ }
+
+ private static Artifact getOrCreateTestSupportFolder(SkynetTransaction transaction) throws OseeCoreException {
+ return getOrCreateTestUnitSubFolder(transaction, Requirements.TEST_SUPPORT_UNITS);
+ }
+
+ private static Artifact getOrCreateTestCaseFolder(SkynetTransaction transaction) throws OseeCoreException {
+ return getOrCreateTestUnitSubFolder(transaction, "Test Cases");
+ }
+
+ private static Artifact getOrCreateCodeUnitFolder(SkynetTransaction transaction) throws OseeCoreException {
+ Artifact codeUnitFolder = getOrCreateFolder(transaction, "Code Units");
+ Artifact root = OseeSystemArtifacts.getDefaultHierarchyRootArtifact(transaction.getBranch());
+ if (!root.isRelated(CoreRelationTypes.Default_Hierarchical__Child, codeUnitFolder)) {
+ root.addChild(codeUnitFolder);
+ root.persist(transaction);
+ }
+ return codeUnitFolder;
+ }
+
+ private static Artifact getOrCreateTestUnitSubFolder(SkynetTransaction transaction, String folderName) throws OseeCoreException {
+ Artifact subFolder = getOrCreateFolder(transaction, folderName);
+ Artifact testUnits = getOrCreateTestUnitsFolder(transaction);
+ if (!testUnits.isRelated(CoreRelationTypes.Default_Hierarchical__Child, subFolder)) {
+ testUnits.addChild(subFolder);
+ testUnits.persist(transaction);
+ }
+ return subFolder;
+ }
+
+ private static Artifact getOrCreateTestUnitsFolder(SkynetTransaction transaction) throws OseeCoreException {
+ Artifact testUnitFolder = getOrCreateFolder(transaction, "Test Units");
+ Artifact root = OseeSystemArtifacts.getDefaultHierarchyRootArtifact(transaction.getBranch());
+ if (!root.isRelated(CoreRelationTypes.Default_Hierarchical__Child, testUnitFolder)) {
+ root.addChild(testUnitFolder);
+ root.persist(transaction);
+ }
+ return testUnitFolder;
+ }
+
+ private static Artifact getOrCreateFolder(SkynetTransaction transaction, String folderName) throws OseeCoreException {
+ return OseeSystemArtifacts.getOrCreateArtifact(CoreArtifactTypes.Folder, folderName, transaction.getBranch());
+ }
+ }
+
+ private final class ResultEditorProvider implements IResultsEditorProvider {
+
+ @Override
+ public String getEditorName() throws OseeCoreException {
+ return "Trace Units To Artifacts Report";
+ }
+
+ private List<XViewerColumn> createColumns(String... columnNames) {
+ List<XViewerColumn> columns = new ArrayList<XViewerColumn>();
+ for (String name : columnNames) {
+ columns.add(new XViewerColumn(name, name, 80, SWT.LEFT, true, SortDataType.String, false, ""));
+ }
+ return columns;
+ }
+
+ private void addUnRelatedTraceUnit(List<IResultsEditorTab> toReturn) {
+ if (!unRelatedUnits.isEmpty()) {
+ List<XViewerColumn> columns = createColumns("Trace Unit Name");
+ List<IResultsXViewerRow> rows = new ArrayList<IResultsXViewerRow>();
+ for (String artifactName : unRelatedUnits) {
+ rows.add(new ResultsXViewerRow(new String[] {artifactName}));
+ }
+ toReturn.add(new ResultsEditorTableTab("Trace Units Created But Had No Relations", columns, rows));
+ }
+ }
+
+ private void addTraceNotFoundTab(List<IResultsEditorTab> toReturn) {
+ if (!reportTraceNotFound.isEmpty()) {
+ List<XViewerColumn> columns =
+ createColumns("Trace Unit Name", "Trace Unit Type", "Trace Mark Type", "Trace Mark");
+
+ List<IResultsXViewerRow> rows = new ArrayList<IResultsXViewerRow>();
+ for (TraceUnit unit : reportTraceNotFound.keySet()) {
+ Collection<TraceMark> traceMarks = reportTraceNotFound.getValues(unit);
+ for (TraceMark traceMark : traceMarks) {
+ rows.add(new ResultsXViewerRow(new String[] {unit.getName(), unit.getTraceUnitType(),
+ traceMark.getTraceType(), traceMark.getRawTraceMark()}));
+ }
+ }
+ toReturn.add(new ResultsEditorTableTab("Trace Marks Not Found", columns, rows));
+ }
+ }
+
+ private void addRelationTypeNotFoundTab(List<IResultsEditorTab> toReturn) {
+ if (!unknownRelationError.isEmpty()) {
+ List<XViewerColumn> columns = createColumns("Artifact Type", "Trace Mark Type");
+ List<IResultsXViewerRow> rows = new ArrayList<IResultsXViewerRow>();
+ for (String artifactType : unknownRelationError.keySet()) {
+ Collection<String> traceTypes = unknownRelationError.getValues(artifactType);
+ for (String traceType : traceTypes) {
+ rows.add(new ResultsXViewerRow(new String[] {artifactType, traceType}));
+ }
+ }
+ toReturn.add(new ResultsEditorTableTab("Invalid Artifact Type to Trace Relation", columns, rows));
+ }
+ }
+
+ @Override
+ public List<IResultsEditorTab> getResultsEditorTabs() throws OseeCoreException {
+ List<IResultsEditorTab> toReturn = new ArrayList<IResultsEditorTab>();
+ addTraceNotFoundTab(toReturn);
+ addUnRelatedTraceUnit(toReturn);
+ addRelationTypeNotFoundTab(toReturn);
+ if (toReturn.isEmpty()) {
+ toReturn.add(new ResultsEditorHtmlTab("Trace Unit Import Status", "Import Status", "All Items Linked"));
+ }
+ return toReturn;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/AbstractArtifactRelationReport.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/AbstractArtifactRelationReport.java
index 5d8a4d5768..dc8fbc0e5b 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/AbstractArtifactRelationReport.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/AbstractArtifactRelationReport.java
@@ -1,60 +1,60 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability.report;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.eclipse.osee.framework.core.enums.IRelationEnumeration;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-
-/**
- * @author Roberto E. Escobar
- */
-public abstract class AbstractArtifactRelationReport extends AbstractReport {
-
- private final Set<Artifact> artifactsToCheck;
- private final List<IRelationEnumeration> relationsToCheck;
-
- public AbstractArtifactRelationReport() {
- super();
- this.artifactsToCheck = new HashSet<Artifact>();
- this.relationsToCheck = new ArrayList<IRelationEnumeration>();
- }
-
- public void setArtifacts(Collection<Artifact> artifacts) {
- if (artifacts != null) {
- this.artifactsToCheck.addAll(artifacts);
- }
- }
-
- public void addRelationToCheck(IRelationEnumeration relation) {
- if (relation != null) {
- this.relationsToCheck.add(relation);
- }
- }
-
- public Artifact[] getArtifactsToCheck() {
- return artifactsToCheck.toArray(new Artifact[artifactsToCheck.size()]);
- }
-
- public IRelationEnumeration[] getRelationsToCheck() {
- return relationsToCheck.toArray(new IRelationEnumeration[relationsToCheck.size()]);
- }
-
- public void clear() {
- artifactsToCheck.clear();
- relationsToCheck.clear();
- super.clear();
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability.report;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.eclipse.osee.framework.core.enums.IRelationEnumeration;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public abstract class AbstractArtifactRelationReport extends AbstractReport {
+
+ private final Set<Artifact> artifactsToCheck;
+ private final List<IRelationEnumeration> relationsToCheck;
+
+ public AbstractArtifactRelationReport() {
+ super();
+ this.artifactsToCheck = new HashSet<Artifact>();
+ this.relationsToCheck = new ArrayList<IRelationEnumeration>();
+ }
+
+ public void setArtifacts(Collection<Artifact> artifacts) {
+ if (artifacts != null) {
+ this.artifactsToCheck.addAll(artifacts);
+ }
+ }
+
+ public void addRelationToCheck(IRelationEnumeration relation) {
+ if (relation != null) {
+ this.relationsToCheck.add(relation);
+ }
+ }
+
+ public Artifact[] getArtifactsToCheck() {
+ return artifactsToCheck.toArray(new Artifact[artifactsToCheck.size()]);
+ }
+
+ public IRelationEnumeration[] getRelationsToCheck() {
+ return relationsToCheck.toArray(new IRelationEnumeration[relationsToCheck.size()]);
+ }
+
+ public void clear() {
+ artifactsToCheck.clear();
+ relationsToCheck.clear();
+ super.clear();
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/AbstractReport.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/AbstractReport.java
index dde8c6d87f..9618247c27 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/AbstractReport.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/AbstractReport.java
@@ -1,67 +1,67 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability.report;
-
-import java.util.HashSet;
-import java.util.Set;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-
-/**
- * @author Roberto E. Escobar
- */
-public abstract class AbstractReport {
- protected static final String EMPTY_STRING = "";
- private final Set<IReportDataCollector> dataCollectors;
-
- public AbstractReport() {
- this.dataCollectors = new HashSet<IReportDataCollector>();
- }
-
- public void addReportDataCollector(IReportDataCollector collector) {
- if (collector != null) {
- dataCollectors.add(collector);
- }
- }
-
- public void removeReportDataCollector(IReportDataCollector collector) {
- if (collector != null) {
- dataCollectors.remove(collector);
- }
- }
-
- protected void notifyOnTableHeader(String... header) {
- if (header != null && header.length > 0) {
- for (IReportDataCollector collector : dataCollectors) {
- collector.addTableHeader(header);
- }
- }
- }
-
- protected void notifyOnRowData(String... rowData) {
- if (rowData != null && rowData.length > 0) {
- for (IReportDataCollector collector : dataCollectors) {
- collector.addRow(rowData);
- }
- }
- }
-
- protected void notifyOnEndTable() {
- for (IReportDataCollector collector : dataCollectors) {
- collector.endTable();
- }
- }
-
- public abstract void process(IProgressMonitor monitor) throws OseeCoreException;
-
- public void clear() {
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability.report;
+
+import java.util.HashSet;
+import java.util.Set;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public abstract class AbstractReport {
+ protected static final String EMPTY_STRING = "";
+ private final Set<IReportDataCollector> dataCollectors;
+
+ public AbstractReport() {
+ this.dataCollectors = new HashSet<IReportDataCollector>();
+ }
+
+ public void addReportDataCollector(IReportDataCollector collector) {
+ if (collector != null) {
+ dataCollectors.add(collector);
+ }
+ }
+
+ public void removeReportDataCollector(IReportDataCollector collector) {
+ if (collector != null) {
+ dataCollectors.remove(collector);
+ }
+ }
+
+ protected void notifyOnTableHeader(String... header) {
+ if (header != null && header.length > 0) {
+ for (IReportDataCollector collector : dataCollectors) {
+ collector.addTableHeader(header);
+ }
+ }
+ }
+
+ protected void notifyOnRowData(String... rowData) {
+ if (rowData != null && rowData.length > 0) {
+ for (IReportDataCollector collector : dataCollectors) {
+ collector.addRow(rowData);
+ }
+ }
+ }
+
+ protected void notifyOnEndTable() {
+ for (IReportDataCollector collector : dataCollectors) {
+ collector.endTable();
+ }
+ }
+
+ public abstract void process(IProgressMonitor monitor) throws OseeCoreException;
+
+ public void clear() {
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/ArtifactToRelatedArtifact.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/ArtifactToRelatedArtifact.java
index 03a87e974b..33d2cbf078 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/ArtifactToRelatedArtifact.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/ArtifactToRelatedArtifact.java
@@ -1,78 +1,78 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability.report;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.enums.IRelationEnumeration;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ArtifactToRelatedArtifact extends AbstractArtifactRelationReport {
-
- public ArtifactToRelatedArtifact() {
- super();
- }
-
- public String[] getHeader() {
- List<String> toReturn = new ArrayList<String>();
- toReturn.add("Name");
- toReturn.add("Related By");
- toReturn.add("Requirement");
- return toReturn.toArray(new String[toReturn.size()]);
- }
-
- public List<String[]> getRelatedRows(IRelationEnumeration[] relations, Artifact artifact) throws OseeCoreException {
- List<String[]> toReturn = new ArrayList<String[]>();
- int maxSize = 0;
- List<List<String>> items = new ArrayList<List<String>>();
- for (IRelationEnumeration relationEnum : relations) {
- List<String> entries = new ArrayList<String>();
- for (Artifact relArtifact : artifact.getRelatedArtifacts(relationEnum)) {
- entries.add(relArtifact.getName());
- }
- items.add(entries);
- maxSize = Math.max(maxSize, entries.size());
- }
- String unitName = artifact.getName();
- int width = relations.length;
- for (int rowNumber = 0; rowNumber < maxSize; rowNumber++) {
- String[] row = new String[width + 1];
- row[0] = unitName;
- for (int index = 0; index < width; index++) {
- List<String> entry = items.get(index);
- row[index + 1] = rowNumber < entry.size() ? entry.get(rowNumber) : EMPTY_STRING;
- }
- toReturn.add(row);
- }
- return toReturn;
- }
-
- @Override
- public void process(IProgressMonitor monitor) throws OseeCoreException {
- notifyOnTableHeader(getHeader());
- IRelationEnumeration[] relations = getRelationsToCheck();
- for (Artifact artifact : getArtifactsToCheck()) {
- String name = artifact.getName();
- for (IRelationEnumeration relationEnum : relations) {
- String typeName = relationEnum.getName();
- for (Artifact relArtifact : artifact.getRelatedArtifacts(relationEnum)) {
- notifyOnRowData(name, typeName, relArtifact.getName());
- }
- }
- }
- notifyOnEndTable();
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability.report;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.enums.IRelationEnumeration;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ArtifactToRelatedArtifact extends AbstractArtifactRelationReport {
+
+ public ArtifactToRelatedArtifact() {
+ super();
+ }
+
+ public String[] getHeader() {
+ List<String> toReturn = new ArrayList<String>();
+ toReturn.add("Name");
+ toReturn.add("Related By");
+ toReturn.add("Requirement");
+ return toReturn.toArray(new String[toReturn.size()]);
+ }
+
+ public List<String[]> getRelatedRows(IRelationEnumeration[] relations, Artifact artifact) throws OseeCoreException {
+ List<String[]> toReturn = new ArrayList<String[]>();
+ int maxSize = 0;
+ List<List<String>> items = new ArrayList<List<String>>();
+ for (IRelationEnumeration relationEnum : relations) {
+ List<String> entries = new ArrayList<String>();
+ for (Artifact relArtifact : artifact.getRelatedArtifacts(relationEnum)) {
+ entries.add(relArtifact.getName());
+ }
+ items.add(entries);
+ maxSize = Math.max(maxSize, entries.size());
+ }
+ String unitName = artifact.getName();
+ int width = relations.length;
+ for (int rowNumber = 0; rowNumber < maxSize; rowNumber++) {
+ String[] row = new String[width + 1];
+ row[0] = unitName;
+ for (int index = 0; index < width; index++) {
+ List<String> entry = items.get(index);
+ row[index + 1] = rowNumber < entry.size() ? entry.get(rowNumber) : EMPTY_STRING;
+ }
+ toReturn.add(row);
+ }
+ return toReturn;
+ }
+
+ @Override
+ public void process(IProgressMonitor monitor) throws OseeCoreException {
+ notifyOnTableHeader(getHeader());
+ IRelationEnumeration[] relations = getRelationsToCheck();
+ for (Artifact artifact : getArtifactsToCheck()) {
+ String name = artifact.getName();
+ for (IRelationEnumeration relationEnum : relations) {
+ String typeName = relationEnum.getName();
+ for (Artifact relArtifact : artifact.getRelatedArtifacts(relationEnum)) {
+ notifyOnRowData(name, typeName, relArtifact.getName());
+ }
+ }
+ }
+ notifyOnEndTable();
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/ArtifactTraceCount.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/ArtifactTraceCount.java
index 0fd1275b99..377745c053 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/ArtifactTraceCount.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/ArtifactTraceCount.java
@@ -1,85 +1,85 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability.report;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.enums.IRelationEnumeration;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.type.AttributeType;
-import org.eclipse.osee.framework.jdk.core.util.Collections;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.utility.Requirements;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ArtifactTraceCount extends AbstractArtifactRelationReport {
-
- public ArtifactTraceCount() {
- super();
- }
-
- public String[] getHeader() {
- List<String> header = new ArrayList<String>();
- header.add("Name");
- header.add("Type");
- for (IRelationEnumeration relation : getRelationsToCheck()) {
- header.add(relation.getName() + " Trace Count");
- }
- header.add("Subsystem");
- return header.toArray(new String[header.size()]);
- }
-
- private String getSubsystemAttributeType(Artifact artifact) {
- Collection<String> attributeTypes = new ArrayList<String>();
- try {
- for (AttributeType type : artifact.getAttributeTypes()) {
- attributeTypes.add(type.getName());
- }
- } catch (Exception ex) {
- // Do Nothing;
- }
-
- if (attributeTypes.contains(Requirements.PARTITION)) {
- return Requirements.PARTITION;
- } else if (attributeTypes.contains(Requirements.CSCI)) {
- return Requirements.CSCI;
- }
- return EMPTY_STRING;
- }
-
- public void process(IProgressMonitor monitor) throws OseeCoreException {
- String[] header = getHeader();
- notifyOnTableHeader(header);
- IRelationEnumeration[] relations = getRelationsToCheck();
- for (Artifact art : getArtifactsToCheck()) {
- String[] rowData = new String[header.length];
- int index = 0;
- rowData[index++] = art.getName();
- rowData[index++] = art.getArtifactTypeName();
- for (IRelationEnumeration relationType : relations) {
- rowData[index++] = String.valueOf(art.getRelatedArtifactsCount(relationType));
- }
- String attributeType = getSubsystemAttributeType(art);
- if (Strings.isValid(attributeType)) {
- rowData[index++] = Collections.toString(",", art.getAttributesToStringList(attributeType));
- } else {
- rowData[index++] = "Unspecified";
- }
- notifyOnRowData(rowData);
- }
- notifyOnEndTable();
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability.report;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.enums.IRelationEnumeration;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.type.AttributeType;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.utility.Requirements;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ArtifactTraceCount extends AbstractArtifactRelationReport {
+
+ public ArtifactTraceCount() {
+ super();
+ }
+
+ public String[] getHeader() {
+ List<String> header = new ArrayList<String>();
+ header.add("Name");
+ header.add("Type");
+ for (IRelationEnumeration relation : getRelationsToCheck()) {
+ header.add(relation.getName() + " Trace Count");
+ }
+ header.add("Subsystem");
+ return header.toArray(new String[header.size()]);
+ }
+
+ private String getSubsystemAttributeType(Artifact artifact) {
+ Collection<String> attributeTypes = new ArrayList<String>();
+ try {
+ for (AttributeType type : artifact.getAttributeTypes()) {
+ attributeTypes.add(type.getName());
+ }
+ } catch (Exception ex) {
+ // Do Nothing;
+ }
+
+ if (attributeTypes.contains(Requirements.PARTITION)) {
+ return Requirements.PARTITION;
+ } else if (attributeTypes.contains(Requirements.CSCI)) {
+ return Requirements.CSCI;
+ }
+ return EMPTY_STRING;
+ }
+
+ public void process(IProgressMonitor monitor) throws OseeCoreException {
+ String[] header = getHeader();
+ notifyOnTableHeader(header);
+ IRelationEnumeration[] relations = getRelationsToCheck();
+ for (Artifact art : getArtifactsToCheck()) {
+ String[] rowData = new String[header.length];
+ int index = 0;
+ rowData[index++] = art.getName();
+ rowData[index++] = art.getArtifactTypeName();
+ for (IRelationEnumeration relationType : relations) {
+ rowData[index++] = String.valueOf(art.getRelatedArtifactsCount(relationType));
+ }
+ String attributeType = getSubsystemAttributeType(art);
+ if (Strings.isValid(attributeType)) {
+ rowData[index++] = Collections.toString(",", art.getAttributesToStringList(attributeType));
+ } else {
+ rowData[index++] = "Unspecified";
+ }
+ notifyOnRowData(rowData);
+ }
+ notifyOnEndTable();
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/ArtifactsWithoutRelations.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/ArtifactsWithoutRelations.java
index 407462bfb8..9774636520 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/ArtifactsWithoutRelations.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/ArtifactsWithoutRelations.java
@@ -1,42 +1,42 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability.report;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.enums.IRelationEnumeration;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ArtifactsWithoutRelations extends AbstractArtifactRelationReport {
-
- public ArtifactsWithoutRelations() {
- super();
- }
-
- @Override
- public void process(IProgressMonitor monitor) throws OseeCoreException {
- notifyOnTableHeader("Item Name", "Type");
- IRelationEnumeration[] relations = getRelationsToCheck();
- for (Artifact artifact : getArtifactsToCheck()) {
- int count = 0;
- for (IRelationEnumeration relation : relations) {
- count += artifact.getRelatedArtifactsCount(relation);
- }
- if (count <= 0) {
- notifyOnRowData(artifact.getName(), artifact.getArtifactTypeName());
- }
- }
- notifyOnEndTable();
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability.report;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.enums.IRelationEnumeration;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ArtifactsWithoutRelations extends AbstractArtifactRelationReport {
+
+ public ArtifactsWithoutRelations() {
+ super();
+ }
+
+ @Override
+ public void process(IProgressMonitor monitor) throws OseeCoreException {
+ notifyOnTableHeader("Item Name", "Type");
+ IRelationEnumeration[] relations = getRelationsToCheck();
+ for (Artifact artifact : getArtifactsToCheck()) {
+ int count = 0;
+ for (IRelationEnumeration relation : relations) {
+ count += artifact.getRelatedArtifactsCount(relation);
+ }
+ if (count <= 0) {
+ notifyOnRowData(artifact.getName(), artifact.getArtifactTypeName());
+ }
+ }
+ notifyOnEndTable();
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/IReportDataCollector.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/IReportDataCollector.java
index 0fe30c629a..f62da527f0 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/IReportDataCollector.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/IReportDataCollector.java
@@ -1,23 +1,23 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.traceability.report;
-
-/**
- * @author Roberto E. Escobar
- */
-public interface IReportDataCollector {
-
- public void addTableHeader(String... header);
-
- public void addRow(String... data);
-
- public void endTable();
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.traceability.report;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface IReportDataCollector {
+
+ public void addTableHeader(String... header);
+
+ public void addRow(String... data);
+
+ public void endTable();
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/utility/IResourceHandler.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/utility/IResourceHandler.java
index c90bc95314..56a767e021 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/utility/IResourceHandler.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/utility/IResourceHandler.java
@@ -1,22 +1,22 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.utility;
-
-import java.net.URI;
-import java.nio.CharBuffer;
-
-/**
- * @author Roberto E. Escobar
- */
-public interface IResourceHandler {
-
- void onResourceFound(URI uriPath, String name, CharBuffer fileBuffer);
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.utility;
+
+import java.net.URI;
+import java.nio.CharBuffer;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface IResourceHandler {
+
+ void onResourceFound(URI uriPath, String name, CharBuffer fileBuffer);
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/utility/IResourceLocator.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/utility/IResourceLocator.java
index 46cf722602..82267ceea8 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/utility/IResourceLocator.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/utility/IResourceLocator.java
@@ -1,28 +1,28 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.utility;
-
-import java.nio.CharBuffer;
-import org.eclipse.core.filesystem.IFileStore;
-
-/**
- * @author Roberto E. Escobar
- */
-public interface IResourceLocator {
-
- public boolean isValidDirectory(IFileStore fileStore);
-
- public boolean isValidFile(IFileStore fileStore);
-
- public boolean hasValidContent(CharBuffer fileBuffer);
-
- public String getIdentifier(IFileStore fileStore, CharBuffer fileBuffer) throws Exception;
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.utility;
+
+import java.nio.CharBuffer;
+import org.eclipse.core.filesystem.IFileStore;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface IResourceLocator {
+
+ public boolean isValidDirectory(IFileStore fileStore);
+
+ public boolean isValidFile(IFileStore fileStore);
+
+ public boolean hasValidContent(CharBuffer fileBuffer);
+
+ public String getIdentifier(IFileStore fileStore, CharBuffer fileBuffer) throws Exception;
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/utility/UriResourceContentFinder.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/utility/UriResourceContentFinder.java
index 31ba45cba1..733a66b70b 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/utility/UriResourceContentFinder.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/utility/UriResourceContentFinder.java
@@ -1,193 +1,193 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.define.utility;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.nio.CharBuffer;
-import java.util.Arrays;
-import java.util.List;
-import java.util.logging.Level;
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileInfo;
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.define.DefinePlugin;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeExceptions;
-import org.eclipse.osee.framework.jdk.core.type.HashCollection;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-/**
- * @author Roberto E. Escobar
- */
-public class UriResourceContentFinder {
-
- private final URI source;
- private final HashCollection<IResourceLocator, IResourceHandler> locatorMap;
- private final boolean isRecursionAllowed;
- private final boolean isFileWithMultiplePaths;
-
- public UriResourceContentFinder(final URI source, final boolean isRecursionAllowed, final boolean isFileWithMultiplePaths) {
- super();
- this.source = source;
- this.isRecursionAllowed = isRecursionAllowed;
- this.isFileWithMultiplePaths = isFileWithMultiplePaths;
- this.locatorMap = new HashCollection<IResourceLocator, IResourceHandler>();
- }
-
- public void addLocator(IResourceLocator locator, IResourceHandler... handler) {
- if (locator != null && handler != null && handler.length > 0) {
- synchronized (locatorMap) {
- locatorMap.put(locator, Arrays.asList(handler));
- }
- }
- }
-
- public void removeLocator(IResourceLocator locator) {
- if (locator != null) {
- synchronized (locatorMap) {
- locatorMap.removeValues(locator);
- }
- }
- }
-
- public void execute(IProgressMonitor monitor) throws OseeCoreException {
- try {
- IFileStore fileStore = EFS.getStore(source);
- if (isFileWithMultiplePaths) {
- processFileWithPaths(monitor, fileStore);
- } else {
- monitor.beginTask("Scanning files", 1);
- processFileStore(monitor, fileStore);
- monitor.worked(1);
- }
- } catch (Exception ex) {
- OseeExceptions.wrapAndThrow(ex);
- } finally {
- monitor.done();
- }
- }
-
- private void processFileWithPaths(IProgressMonitor monitor, IFileStore fileStore) throws Exception {
- IFileInfo info = fileStore.fetchInfo(EFS.NONE, monitor);
- if (info != null && info.exists()) {
- List<String> paths = Lib.readListFromFile(new File(fileStore.toURI()), true);
- monitor.beginTask("Searching for files", paths.size());
- for (String path : paths) {
- if (Strings.isValid(path)) {
- processFileStore(monitor, EFS.getStore(new File(path).toURI()));
- }
- if (monitor.isCanceled()) {
- break;
- }
- monitor.worked(1);
- }
- } else {
- monitor.beginTask("Searching for files", 1);
- }
- }
-
- private void processFileStore(IProgressMonitor monitor, IFileStore fileStore) throws Exception {
- IFileInfo info = fileStore.fetchInfo(EFS.NONE, monitor);
- if (info != null && info.exists()) {
- if (info.isDirectory()) {
- processDirectory(monitor, fileStore);
- } else {
- processFile(monitor, fileStore);
- }
- }
- }
-
- private boolean isValidDirectory(IProgressMonitor monitor, IFileStore fileStore) {
- boolean result = false;
- for (IResourceLocator locator : locatorMap.keySet()) {
- if (monitor.isCanceled()) {
- break;
- }
- if (locator.isValidDirectory(fileStore)) {
- result = true;
- break;
- }
- }
- return result;
- }
-
- private void processDirectory(IProgressMonitor monitor, IFileStore fileStore) throws Exception {
- if (isValidDirectory(monitor, fileStore)) {
- boolean isProcessingAllowed = false;
- for (IFileStore childStore : fileStore.childStores(EFS.NONE, monitor)) {
- isProcessingAllowed = false;
- if (monitor.isCanceled()) {
- break;
- }
- if (!isRecursionAllowed) {
- isProcessingAllowed = !childStore.fetchInfo().isDirectory();
- } else {
- isProcessingAllowed = true;
- }
-
- if (isProcessingAllowed) {
- processFileStore(monitor, childStore);
- }
- }
- }
- monitor.worked(1);
- }
-
- private void processFile(IProgressMonitor monitor, IFileStore fileStore) throws Exception {
- if (!monitor.isCanceled()) {
- for (IResourceLocator locator : locatorMap.keySet()) {
- if (locator.isValidFile(fileStore)) {
- CharBuffer fileBuffer = getContents(monitor, fileStore);
- if (locator.hasValidContent(fileBuffer)) {
- String fileName = locator.getIdentifier(fileStore, fileBuffer);
- if (!monitor.isCanceled()) {
- monitor.subTask(String.format("processing [%s]", fileStore.getName()));
- notifyListeners(locator, fileStore.toURI(), fileName, fileBuffer);
- }
- }
- }
- }
- }
- monitor.worked(1);
- }
-
- private CharBuffer getContents(IProgressMonitor monitor, IFileStore fileStore) throws Exception {
- CharBuffer toReturn = null;
- InputStream inputStream = null;
- try {
- inputStream = new BufferedInputStream(fileStore.openInputStream(EFS.NONE, monitor));
- toReturn = Lib.inputStreamToCharBuffer(inputStream);
- } finally {
- if (inputStream != null) {
- try {
- inputStream.close();
- } catch (IOException ex) {
- OseeLog.log(DefinePlugin.class, Level.SEVERE, String.format("Error closing stream for resource: [%s]",
- fileStore.getName()), ex);
- }
- }
- }
- return toReturn;
- }
-
- private void notifyListeners(final IResourceLocator locator, final URI uriPath, final String fileName, final CharBuffer fileBuffer) {
- for (IResourceHandler handler : locatorMap.getValues(locator)) {
- handler.onResourceFound(uriPath, fileName, fileBuffer);
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.utility;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.nio.CharBuffer;
+import java.util.Arrays;
+import java.util.List;
+import java.util.logging.Level;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileInfo;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.define.DefinePlugin;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.eclipse.osee.framework.jdk.core.type.HashCollection;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class UriResourceContentFinder {
+
+ private final URI source;
+ private final HashCollection<IResourceLocator, IResourceHandler> locatorMap;
+ private final boolean isRecursionAllowed;
+ private final boolean isFileWithMultiplePaths;
+
+ public UriResourceContentFinder(final URI source, final boolean isRecursionAllowed, final boolean isFileWithMultiplePaths) {
+ super();
+ this.source = source;
+ this.isRecursionAllowed = isRecursionAllowed;
+ this.isFileWithMultiplePaths = isFileWithMultiplePaths;
+ this.locatorMap = new HashCollection<IResourceLocator, IResourceHandler>();
+ }
+
+ public void addLocator(IResourceLocator locator, IResourceHandler... handler) {
+ if (locator != null && handler != null && handler.length > 0) {
+ synchronized (locatorMap) {
+ locatorMap.put(locator, Arrays.asList(handler));
+ }
+ }
+ }
+
+ public void removeLocator(IResourceLocator locator) {
+ if (locator != null) {
+ synchronized (locatorMap) {
+ locatorMap.removeValues(locator);
+ }
+ }
+ }
+
+ public void execute(IProgressMonitor monitor) throws OseeCoreException {
+ try {
+ IFileStore fileStore = EFS.getStore(source);
+ if (isFileWithMultiplePaths) {
+ processFileWithPaths(monitor, fileStore);
+ } else {
+ monitor.beginTask("Scanning files", 1);
+ processFileStore(monitor, fileStore);
+ monitor.worked(1);
+ }
+ } catch (Exception ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ } finally {
+ monitor.done();
+ }
+ }
+
+ private void processFileWithPaths(IProgressMonitor monitor, IFileStore fileStore) throws Exception {
+ IFileInfo info = fileStore.fetchInfo(EFS.NONE, monitor);
+ if (info != null && info.exists()) {
+ List<String> paths = Lib.readListFromFile(new File(fileStore.toURI()), true);
+ monitor.beginTask("Searching for files", paths.size());
+ for (String path : paths) {
+ if (Strings.isValid(path)) {
+ processFileStore(monitor, EFS.getStore(new File(path).toURI()));
+ }
+ if (monitor.isCanceled()) {
+ break;
+ }
+ monitor.worked(1);
+ }
+ } else {
+ monitor.beginTask("Searching for files", 1);
+ }
+ }
+
+ private void processFileStore(IProgressMonitor monitor, IFileStore fileStore) throws Exception {
+ IFileInfo info = fileStore.fetchInfo(EFS.NONE, monitor);
+ if (info != null && info.exists()) {
+ if (info.isDirectory()) {
+ processDirectory(monitor, fileStore);
+ } else {
+ processFile(monitor, fileStore);
+ }
+ }
+ }
+
+ private boolean isValidDirectory(IProgressMonitor monitor, IFileStore fileStore) {
+ boolean result = false;
+ for (IResourceLocator locator : locatorMap.keySet()) {
+ if (monitor.isCanceled()) {
+ break;
+ }
+ if (locator.isValidDirectory(fileStore)) {
+ result = true;
+ break;
+ }
+ }
+ return result;
+ }
+
+ private void processDirectory(IProgressMonitor monitor, IFileStore fileStore) throws Exception {
+ if (isValidDirectory(monitor, fileStore)) {
+ boolean isProcessingAllowed = false;
+ for (IFileStore childStore : fileStore.childStores(EFS.NONE, monitor)) {
+ isProcessingAllowed = false;
+ if (monitor.isCanceled()) {
+ break;
+ }
+ if (!isRecursionAllowed) {
+ isProcessingAllowed = !childStore.fetchInfo().isDirectory();
+ } else {
+ isProcessingAllowed = true;
+ }
+
+ if (isProcessingAllowed) {
+ processFileStore(monitor, childStore);
+ }
+ }
+ }
+ monitor.worked(1);
+ }
+
+ private void processFile(IProgressMonitor monitor, IFileStore fileStore) throws Exception {
+ if (!monitor.isCanceled()) {
+ for (IResourceLocator locator : locatorMap.keySet()) {
+ if (locator.isValidFile(fileStore)) {
+ CharBuffer fileBuffer = getContents(monitor, fileStore);
+ if (locator.hasValidContent(fileBuffer)) {
+ String fileName = locator.getIdentifier(fileStore, fileBuffer);
+ if (!monitor.isCanceled()) {
+ monitor.subTask(String.format("processing [%s]", fileStore.getName()));
+ notifyListeners(locator, fileStore.toURI(), fileName, fileBuffer);
+ }
+ }
+ }
+ }
+ }
+ monitor.worked(1);
+ }
+
+ private CharBuffer getContents(IProgressMonitor monitor, IFileStore fileStore) throws Exception {
+ CharBuffer toReturn = null;
+ InputStream inputStream = null;
+ try {
+ inputStream = new BufferedInputStream(fileStore.openInputStream(EFS.NONE, monitor));
+ toReturn = Lib.inputStreamToCharBuffer(inputStream);
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException ex) {
+ OseeLog.log(DefinePlugin.class, Level.SEVERE, String.format("Error closing stream for resource: [%s]",
+ fileStore.getName()), ex);
+ }
+ }
+ }
+ return toReturn;
+ }
+
+ private void notifyListeners(final IResourceLocator locator, final URI uriPath, final String fileName, final CharBuffer fileBuffer) {
+ for (IResourceHandler handler : locatorMap.getValues(locator)) {
+ handler.onResourceFound(uriPath, fileName, fileBuffer);
+ }
+ }
+}

Back to the top