Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.osee.define/src/org')
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/DefinePerspectiveFactory.java68
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/DefinePlugin.java35
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/artifact/Resolver.java49
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/AddEveryoneGroupToBranches.java49
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishRequirements.java250
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishSubsystemToDesignTraceability.java132
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishWithSpecifiedTemplate.java117
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/RequirementReorderOperation.java75
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/RequirementsTestReport.java171
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/SubsystemRequirementVerificationLevel.java161
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/SubsystemToLowLevelReqTraceReport.java250
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/TestPlanComplianceReport.java214
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/ErrorHandler.java49
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/Resolver.java17
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/SqlResolver.java40
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/StateValue.java30
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateView.java120
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateViewItems.java105
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateViewerSorter.java37
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/IDefineNavigateItem.java23
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/Import/ExtractTestRelations.java136
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/Import/RelationImporter.java156
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/TreeViewerTest.java272
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ITraceParser.java28
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ITraceUnitResourceLocator.java25
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityJob.java245
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityPage.java137
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityWizard.java57
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/TraceUnitExtensionManager.java192
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/TraceabilityExtractor.java139
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/action/FindTraceUnitActionDelegate.java67
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/action/FindTraceUnitEditorAction.java52
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/blam/RemoveTraceMarksFromTraceUnits.java350
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/blam/TraceReportBlam.java514
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/blam/UiToTestBlam.java238
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/BaseTraceDataCache.java78
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/CodeUnitData.java55
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/RequirementData.java102
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TestUnitData.java140
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TraceMark.java76
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TraceUnit.java68
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/importer/ImportTraceUnitPage.java425
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/importer/ImportTraceUnitWizard.java69
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/jobs/FindTraceUnitJob.java89
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/jobs/ImportTraceUnitsJob.java74
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/FindTraceUnitFromResource.java136
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ITraceUnitProcessor.java29
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ResourceToTraceUnit.java219
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitFromResourceOperation.java122
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitReportProcessor.java72
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitToArtifactProcessor.java392
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/AbstractArtifactRelationReport.java60
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/AbstractReport.java67
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/ArtifactToRelatedArtifact.java78
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/ArtifactTraceCount.java85
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/ArtifactsWithoutRelations.java42
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/IReportDataCollector.java23
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/utility/IResourceHandler.java22
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/utility/IResourceLocator.java28
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/utility/UriResourceContentFinder.java193
60 files changed, 7344 insertions, 0 deletions
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
new file mode 100644
index 00000000000..67b591a83a8
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/DefinePerspectiveFactory.java
@@ -0,0 +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;
+
+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 placeholders for views.
+ *
+ * @author Robert A. Fisher
+ */
+public class DefinePerspectiveFactory implements IPerspectiveFactory {
+
+ 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");
+
+ IFolderLayout underLower = layout.createFolder("underBottom", IPageLayout.BOTTOM, .75f, "bottom");
+ underLower.addView(QuickSearchView.VIEW_ID);
+
+ // The following is some sample code that can be used for future reference for other areas and
+ // placeholders ...
+ // topLeft.addPlaceholder(IPageLayout.ID_BOOKMARKS);
+ //
+ // // Bottom left: Outline view and Property Sheet view
+ // IFolderLayout bottomLeft = layout.createFolder("bottomLeft", IPageLayout.BOTTOM, 0.50f,
+ // "topLeft");
+ // bottomLeft.addView(IPageLayout.ID_OUTLINE);
+ // bottomLeft.addView(IPageLayout.ID_PROP_SHEET);
+ //
+ // // Bottom right: Task List view
+ // layout.addView(IPageLayout.ID_TASK_LIST, IPageLayout.BOTTOM, 0.66f, editorArea);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/DefinePlugin.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/DefinePlugin.java
new file mode 100644
index 00000000000..a5be791f5a2
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/DefinePlugin.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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.framework.ui.plugin.OseeUiActivator;
+
+public class DefinePlugin extends OseeUiActivator {
+ private static DefinePlugin pluginInstance; // The shared instance.
+ public static final String PLUGIN_ID = "org.eclipse.osee.define";
+
+ public DefinePlugin() {
+ super();
+ pluginInstance = this;
+ }
+
+ @Override
+ protected String getPluginName() {
+ return PLUGIN_ID;
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static DefinePlugin getInstance() {
+ return pluginInstance;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/artifact/Resolver.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/artifact/Resolver.java
new file mode 100644
index 00000000000..4f546489d9a
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/artifact/Resolver.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * 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.artifact;
+
+import java.io.CharArrayReader;
+import java.nio.CharBuffer;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.stream.StreamSource;
+import org.eclipse.osee.define.DefinePlugin;
+import org.eclipse.osee.framework.ui.plugin.OseeUiActivator;
+
+public class Resolver implements URIResolver {
+ private static final OseeUiActivator plugin = DefinePlugin.getInstance();
+ private static final CharBuffer xslAuxiliary = plugin.getCharBuffer("support/xslt/auxiliary.xsl");
+ private static final CharBuffer xslProperties = plugin.getCharBuffer("support/xslt/elementProperties.xsl");
+ private static final CharBuffer xslStructure = plugin.getCharBuffer("support/xslt/elementStructure.xsl");
+ private static final CharBuffer xslPageLayout = plugin.getCharBuffer("support/xslt/pageLayout.xsl");
+ private static final CharBuffer xslProfile = plugin.getCharBuffer("support/xslt/profile.xsl");
+
+ public Source resolve(String href, String base) throws TransformerException {
+ CharBuffer rightOne = null;
+ if (href.equals("auxiliary.xsl")) {
+ rightOne = xslAuxiliary;
+ }
+ if (href.equals("elementProperties.xsl")) {
+ rightOne = xslProperties;
+ }
+ if (href.equals("elementStructure.xsl")) {
+ rightOne = xslStructure;
+ }
+ if (href.equals("pageLayout.xsl")) {
+ rightOne = xslPageLayout;
+ }
+ if (href.equals("profile.xsl")) {
+ rightOne = xslProfile;
+ }
+ return new StreamSource(new CharArrayReader(rightOne.array()));
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/AddEveryoneGroupToBranches.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/AddEveryoneGroupToBranches.java
new file mode 100644
index 00000000000..041e2efdd71
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/AddEveryoneGroupToBranches.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * 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.PermissionEnum;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.skynet.core.access.AccessControlManager;
+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.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
+import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
+
+/**
+ * @author Jeff C. Phillips
+ */
+public class AddEveryoneGroupToBranches extends AbstractBlam {
+
+ public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
+ for (Branch brnch : BranchManager.getNormalBranches()) {
+
+ if (!AccessControlManager.getAccessControlList(brnch).isEmpty()) {
+ Artifact everyone =
+ ArtifactQuery.getArtifactFromAttribute("Name", "Everyone", BranchManager.getCommonBranch());
+ AccessControlManager.setPermission(everyone, brnch, PermissionEnum.READ);
+ }
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "Add Everone Group to Branches";
+ }
+
+ public Collection<String> getCategories() {
+ return Arrays.asList("Define");
+ }
+} \ 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
new file mode 100644
index 00000000000..0ce02a950df
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishRequirements.java
@@ -0,0 +1,250 @@
+/*******************************************************************************
+ * 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.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Level;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.define.DefinePlugin;
+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.database.core.ConnectionHandler;
+import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
+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.ArtifactLoad;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactLoader;
+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.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.render.ITemplateRenderer;
+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 static final String SELECT_BRANCH_TRANSACTION =
+ "SELECT transaction_id FROM osee_tx_details WHERE branch_id = ? AND time < ? ORDER BY time DESC";
+
+ private boolean includeAttributes;
+ private boolean publishAsDiff;
+ //private boolean removeTrackedChanges;
+ private Date date;
+ private Branch branch;
+
+ @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");
+ // 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, true, 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 =
+ includeAttributes ? ITemplateRenderer.PREVIEW_WITH_RECURSE_VALUE : ITemplateRenderer.PREVIEW_WITH_RECURSE_NO_ATTRIBUTES_VALUE;
+ }
+
+ VariableMap options =
+ new VariableMap(WordTemplateRenderer.UPDATE_PARAGRAPH_NUMBER_OPTION, updateParagraphNumber,
+ ITemplateRenderer.TEMPLATE_OPTION, templateOption, ITemplateRenderer.TRANSACTION_OPTION, transaction,
+ "linkType", linkType, "inPublishMode", true);
+ for (Artifact artifact : artifacts) {
+ try {
+ publish(monitor, artifact, options);
+ } catch (OseeStateException ex) {
+ OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
+ }
+ }
+ transaction.execute();
+ }
+
+ private static int getBranchTransaction(Date date, int branchId) throws OseeCoreException {
+ int transactionId = -1;
+ IOseeStatement chStmt = ConnectionHandler.getStatement();
+
+ if (date == null) {
+ throw new OseeCoreException("Must select a valid Date");
+ }
+ try {
+ chStmt.runPreparedQuery(SELECT_BRANCH_TRANSACTION, branchId, new Timestamp(date.getTime()));
+
+ if (chStmt.next()) {
+ transactionId = chStmt.getInt("transaction_id");
+ }
+ } finally {
+ chStmt.close();
+ }
+ return transactionId;
+ }
+
+ private void publish(IProgressMonitor monitor, Artifact artifact, VariableMap options) throws OseeCoreException {
+ if (monitor.isCanceled()) {
+ return;
+ }
+
+ ArrayList<Artifact> nonFolderChildren = new ArrayList<Artifact>();
+ if (artifact.isOfType("Folder")) {
+ for (Artifact child : artifact.getChildren(publishAsDiff)) {
+ if (child.isOfType("Folder")) {
+ publish(monitor, child, options);
+ } else {
+ nonFolderChildren.add(child);
+ }
+ }
+ } else {
+ nonFolderChildren.add(artifact);
+ }
+
+ if (publishAsDiff) {
+ if (branch == null || date == null) {
+ throw new OseeCoreException(
+ "Must Select a " + branch == null ? "Branch" : "Date" + " to diff against when publishing as Diff");
+ }
+ nonFolderChildren = buildRecursiveList(nonFolderChildren);
+ int transactionId = getBranchTransaction(date, branch.getId());
+ ArrayList<Artifact> olderArtifacts = getOlderArtifacts(nonFolderChildren, transactionId, branch.getId());
+ int index = 0;
+ for (Artifact art : olderArtifacts) {
+ if (art != null && art.isDeleted()) {
+ olderArtifacts.set(index, null);
+ }
+ index++;
+ }
+ index = 0;
+ for (Artifact art : nonFolderChildren) {
+ if (art != null && art.isDeleted()) {
+ nonFolderChildren.set(index, null);
+ }
+ index++;
+ }
+ RendererManager.diffInJob(olderArtifacts, nonFolderChildren, options);
+ } else {
+ RendererManager.preview(nonFolderChildren, monitor, options);
+ }
+ }
+
+ @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=\"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(ArrayList<Artifact> artifacts, int transactionId, int branchId) throws OseeCoreException {
+ ArrayList<Artifact> historicArtifacts = new ArrayList<Artifact>(artifacts.size());
+ int queryId = ArtifactLoader.getNewQueryId();
+ Timestamp insertTime = GlobalTime.GreenwichMeanTimestamp();
+
+ Set<Artifact> artifactSet = new HashSet<Artifact>(artifacts);
+ List<Object[]> insertParameters = new LinkedList<Object[]>();
+ for (Artifact artifact : artifactSet) {
+ insertParameters.add(new Object[] {queryId, insertTime, artifact.getArtId(), branchId, transactionId});
+ }
+
+ @SuppressWarnings("unused")
+ Collection<Artifact> bulkLoadedArtifacts =
+ ArtifactLoader.loadArtifacts(queryId, ArtifactLoad.FULL, null, insertParameters, false, true, true);
+
+ for (Artifact artifact : artifacts) {
+ historicArtifacts.add(ArtifactCache.getHistorical(artifact.getArtId(), transactionId));
+ }
+ return historicArtifacts;
+ }
+
+ private ArrayList<Artifact> buildRecursiveList(ArrayList<Artifact> artifacts) throws OseeCoreException {
+ ArrayList<Artifact> artifactWithChildren = new ArrayList<Artifact>(artifacts.size());
+ for (Artifact artifact : artifacts) {
+ artifactWithChildren.add(artifact);
+ addChildren(artifactWithChildren, artifact);
+ }
+ return artifactWithChildren;
+ }
+
+ private void addChildren(ArrayList<Artifact> artifacts, Artifact artifact) throws OseeCoreException {
+ for (Artifact loopArtifact : artifact.getChildren(true)) {
+ artifacts.add(loopArtifact);
+ addChildren(artifacts, loopArtifact);
+ }
+ }
+
+ @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
new file mode 100644
index 00000000000..8dc9d1c7072
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishSubsystemToDesignTraceability.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * 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.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("Subsystem Design", branch);
+ monitor.worked(10);
+
+ monitor.subTask("Aquiring Subsystem Requirements"); // bulk load for performance reasons
+ ArtifactQuery.getArtifactListFromType("Subsystem Requirement", 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("Subsystem Requirement")) {
+ boolean loopNeverRan = true;
+ for (Artifact subsystemDesign : subsystemRequirement.getRelatedArtifacts(CoreRelationTypes.Design__Design)) {
+ if (subsystemDesign.isOfType("Subsystem Design")) {
+ 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
new file mode 100644
index 00000000000..f4744132c9f
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishWithSpecifiedTemplate.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * 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.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("Update Paragraph Numbers", updateParagraphNumber);
+
+ 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("</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
new file mode 100644
index 00000000000..7069c83eb16
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/RequirementReorderOperation.java
@@ -0,0 +1,75 @@
+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
new file mode 100644
index 00000000000..eca04572894
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/RequirementsTestReport.java
@@ -0,0 +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.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
new file mode 100644
index 00000000000..c5fa8e55a94
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/SubsystemRequirementVerificationLevel.java
@@ -0,0 +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");
+ }
+ }
+}
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
new file mode 100644
index 00000000000..5c25cc2878f
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/SubsystemToLowLevelReqTraceReport.java
@@ -0,0 +1,250 @@
+/*******************************************************************************
+ * 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 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.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.ArtifactType;
+import org.eclipse.osee.framework.core.model.Branch;
+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(Requirements.SUBSYSTEM_REQUIREMENT, 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(Requirements.SUBSYSTEM_REQUIREMENT, 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, true, CoreRelationTypes.Default_Hierarchical__Child);
+ for (Artifact artifact : artifacts) {
+ if (!artifact.isOfType("Folder")) {
+ lowLevelReqs.add(artifact);
+ }
+ lowLevelReqs.addAll(artifact.getDescendants());
+ }
+ }
+
+ private void initAllocationComponents(List<Artifact> artifacts) throws OseeCoreException {
+ RelationManager.getRelatedArtifacts(artifacts, 999, true, CoreRelationTypes.Default_Hierarchical__Child);
+ for (Artifact artifact : artifacts) {
+ if (!artifact.isOfType("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
new file mode 100644
index 00000000000..cb8fde16d27
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/TestPlanComplianceReport.java
@@ -0,0 +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.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/errorhandler/ErrorHandler.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/ErrorHandler.java
new file mode 100644
index 00000000000..e12cb033134
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/ErrorHandler.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * 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.errorhandler;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class ErrorHandler {
+
+ private Set<Resolver> set;
+ private StateValue value;
+
+ /**
+ * Error handler.
+ */
+ public ErrorHandler() {
+ super();
+ this.set = new HashSet<Resolver>();
+ this.value = new StateValue();
+ }
+
+ public void processException(Exception ex) {
+ boolean resolved = false;
+ for (Resolver r : set) {
+ if (r.resolve(ex, value)) {
+ resolved = true;
+ }
+ }
+ if (!resolved) {
+ throw new RuntimeException("Exception not resolved", ex);
+ }
+ }
+
+ public void addResolver(Resolver resolver) {
+ set.add(resolver);
+ }
+
+ public boolean isSaveValid() {
+ return value.isSaveValid();
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/Resolver.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/Resolver.java
new file mode 100644
index 00000000000..aacf4e76012
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/Resolver.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * 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.errorhandler;
+
+public interface Resolver {
+
+ public boolean resolve(Exception ex, StateValue value);
+
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/SqlResolver.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/SqlResolver.java
new file mode 100644
index 00000000000..979a519a76b
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/SqlResolver.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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.errorhandler;
+
+public class SqlResolver implements Resolver {
+
+ public SqlResolver() {
+ super();
+ }
+
+ public boolean resolve(Exception ex, StateValue value) {
+ if (ex.getMessage().contains("connection")) {
+ value.andSaveValid(false);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ return this.getClass().getCanonicalName().equals(obj.getClass().getCanonicalName());
+ }
+
+ @Override
+ public int hashCode() {
+ return this.getClass().getCanonicalName().hashCode();
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/StateValue.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/StateValue.java
new file mode 100644
index 00000000000..8cb4546cb80
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/StateValue.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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.errorhandler;
+
+public class StateValue {
+
+ private boolean isSaveValid;
+
+ public StateValue() {
+ super();
+ isSaveValid = true;
+ }
+
+ public boolean isSaveValid() {
+ return isSaveValid;
+ }
+
+ public void andSaveValid(boolean isSaveValid) {
+ this.isSaveValid &= isSaveValid;
+ }
+
+}
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
new file mode 100644
index 00000000000..99dc56d4852
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateView.java
@@ -0,0 +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 "";
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateViewItems.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateViewItems.java
new file mode 100644
index 00000000000..215c3010a22
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateViewItems.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * 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 java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+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.logging.OseeLevel;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.skynet.core.access.AccessControlManager;
+import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem;
+import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItemAction;
+import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItemFolder;
+import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItemOperation;
+import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateViewItems;
+import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
+import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
+import org.eclipse.osee.framework.ui.skynet.action.CompareTwoStringsAction;
+import org.eclipse.osee.framework.ui.skynet.artifact.MassEditDirtyArtifactOperation;
+import org.eclipse.osee.framework.ui.skynet.blam.BlamContributionManager;
+import org.osgi.framework.Bundle;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class DefineNavigateViewItems extends XNavigateViewItems {
+ private static DefineNavigateViewItems navigateItems = new DefineNavigateViewItems();
+
+ public DefineNavigateViewItems() {
+ super();
+ }
+
+ public static DefineNavigateViewItems getInstance() {
+ return navigateItems;
+ }
+
+ @Override
+ public List<XNavigateItem> getSearchNavigateItems() {
+ List<XNavigateItem> items = new ArrayList<XNavigateItem>();
+
+ try {
+ BlamContributionManager.addBlamOperationsToNavigator(items);
+
+ if (AccessControlManager.isOseeAdmin()) {
+ XNavigateItem adminItems = new XNavigateItemFolder(null, "Admin");
+ items.add(adminItems);
+ }
+ } catch (OseeCoreException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
+ }
+
+ addExtensionPointItems(items);
+ items.add(new XNavigateItemAction(null, new CompareTwoStringsAction(), FrameworkImage.EDIT));
+ items.add(new XNavigateItemOperation(null, FrameworkImage.GEAR, MassEditDirtyArtifactOperation.NAME,
+ new MassEditDirtyArtifactOperation()));
+
+ return items;
+ }
+
+ public void addExtensionPointItems(List<XNavigateItem> items) {
+ IExtensionPoint point =
+ Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.osee.define.DefineNavigateItem");
+ if (point == null) {
+ OseeLog.log(DefinePlugin.class, OseeLevel.SEVERE_POPUP, "Can't access DefineNavigateItem extension point");
+ return;
+ }
+ IExtension[] extensions = point.getExtensions();
+ for (IExtension extension : extensions) {
+ IConfigurationElement[] elements = extension.getConfigurationElements();
+ String classname = null;
+ String bundleName = null;
+ for (IConfigurationElement el : elements) {
+ if (el.getName().equals("IDefineNavigateItem")) {
+ classname = el.getAttribute("classname");
+ bundleName = el.getContributor().getName();
+ }
+ }
+ if (classname != null && bundleName != null) {
+ Bundle bundle = Platform.getBundle(bundleName);
+ try {
+ Class<?> taskClass = bundle.loadClass(classname);
+ Object obj = taskClass.newInstance();
+ IDefineNavigateItem task = (IDefineNavigateItem) obj;
+ items.addAll(task.getNavigateItems());
+ } catch (Exception ex) {
+ OseeLog.log(DefinePlugin.class, OseeLevel.SEVERE_POPUP, "Error loading DefineNavigateItem extension", ex);
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateViewerSorter.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateViewerSorter.java
new file mode 100644
index 00000000000..a3fab9cff43
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateViewerSorter.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class DefineNavigateViewerSorter extends ViewerSorter {
+
+ /**
+ * @param treeViewer
+ */
+ public DefineNavigateViewerSorter() {
+ super();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ XNavigateItem item1 = (XNavigateItem) e1;
+ XNavigateItem item2 = (XNavigateItem) e2;
+ return getComparator().compare(item1.getName(), item2.getName());
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/IDefineNavigateItem.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/IDefineNavigateItem.java
new file mode 100644
index 00000000000..ae0c07e949e
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/IDefineNavigateItem.java
@@ -0,0 +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.navigate;
+
+import java.util.List;
+import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem;
+
+/**
+ * @author Donald G. Dunne
+ */
+public interface IDefineNavigateItem {
+
+ public List<XNavigateItem> getNavigateItems();
+
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/Import/ExtractTestRelations.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/Import/ExtractTestRelations.java
new file mode 100644
index 00000000000..9a29f5fbdf6
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/Import/ExtractTestRelations.java
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * 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.relation.Import;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.CharBuffer;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.osee.define.DefinePlugin;
+import org.eclipse.osee.framework.core.exception.ArtifactDoesNotExist;
+import org.eclipse.osee.framework.core.exception.MultipleArtifactsExist;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.jdk.core.text.FindResults;
+import org.eclipse.osee.framework.jdk.core.text.tool.Find;
+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.ArtifactTypeManager;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.utility.Requirements;
+import org.eclipse.osee.framework.ui.plugin.util.AWorkspace;
+
+public class ExtractTestRelations {
+ private String scriptsDir;
+ private String fileNamePattern;
+ private Branch branch;
+ private static final Matcher testScriptMatcher = Pattern.compile("doTestCase").matcher("");
+ private static final Matcher traceabilityMatcher = Pattern.compile("RequirementId\\(\\\"([^\\\"]+)\\\"").matcher("");
+
+ public ExtractTestRelations(String scriptsDir, String fileNamePattern, Branch branch) {
+ super();
+ this.scriptsDir = scriptsDir;
+ this.fileNamePattern = fileNamePattern;
+ this.branch = branch;
+ }
+
+ public void run() {
+ ArrayList<String> patterns = new ArrayList<String>();
+ patterns.add(scriptsDir);
+ Find app = new Find("RequirementId\\(\\\"([^\\\"]+)\\\"", new File(scriptsDir), fileNamePattern);
+ app.find(999999, true);
+ FindResults results = app.getResults();
+
+ for (FindResults.FindResultsIterator i = results.iterator(); i.hasNext();) {
+ try {
+ addRelationToDatabaseIfNotAlreadyThere(AWorkspace.fileToIFile(i.currentFile), i.currentRegion);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ }
+
+ public static void traceabilityReport() throws IOException {
+ Pattern javaFilePattern = Pattern.compile(".*\\.java");
+ for (IProject project : AWorkspace.getProjects()) {
+ File projectLocation = project.getLocation().toFile();
+ for (File javaFile : (List<File>) Lib.recursivelyListFiles(projectLocation, javaFilePattern)) {
+ CharBuffer buf = Lib.fileToCharBuffer(javaFile);
+ testScriptMatcher.reset(buf);
+ if (testScriptMatcher.find()) {
+ traceabilityMatcher.reset(buf);
+ while (traceabilityMatcher.find()) {
+ System.out.println(javaFile.getName() + ", " + traceabilityMatcher.group(1));
+ }
+ } else {
+ System.out.println(javaFile + ": no traceability");
+ }
+ }
+ }
+ }
+
+ private void addRelationToDatabaseIfNotAlreadyThere(IFile testArtifactFile, String reqArtifactName) throws OseeCoreException {
+
+ // Make sure that the runtime relation type is available
+ Artifact reqArtifact =
+ ArtifactQuery.getArtifactFromTypeAndName(Requirements.SOFTWARE_REQUIREMENT, reqArtifactName, branch);
+
+ // Make sure we have the reqArtifact
+ if (reqArtifact == null) {
+ System.out.println("Unable to locate the requirement named:\"" + reqArtifactName + "\"");
+ return;
+ }
+
+ // TODO replace the null here with the Test_TestSide relationSide enumeration
+ reqArtifact.addRelation(null, getTestArtifact(testArtifactFile, reqArtifact.getBranch()));
+ // Get a new test relation with the same tag as the requirement artifact
+ // UserRelation testRelation = relationManager.getUserRelationDescriptor("Test").makeNewUserRelation(reqArtifact.getTag());
+ // RelationLink link = relationManager.getRelationLinkDescriptor("Test").makeNewLink();
+
+ // Add the items to the relation
+ // link.setArtifact("Requirement", reqArtifact);
+ // link.setArtifact("Test", getTestArtifact(testArtifactName, reqArtifact.getTag()));
+ // reqArtifact.getLinkManager().addLink(link);
+ //
+ // link.setArtifactA(reqArtifact);
+ // link.setArtifactB(getTestArtifact(testArtifactName, reqArtifact.getTag()));
+ // link.persist();
+
+ // testRelation.addArtifact("test", getTestArtifact(testArtifactName, reqArtifact.getTag()));
+ // testRelation.addArtifact("requirement", reqArtifact);
+
+ // Save the relation
+ // link.persist();
+ }
+
+ private Artifact getTestArtifact(IFile testArtifactFile, Branch branch) throws OseeCoreException {
+ try {
+ return ArtifactQuery.getArtifactFromTypeAndName(Requirements.TEST_CASE, testArtifactFile.getName(), branch);
+ } catch (MultipleArtifactsExist ex) {
+ OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
+ return null;
+ } catch (ArtifactDoesNotExist ex) {
+ Artifact testArtifact =
+ ArtifactTypeManager.addArtifact(Requirements.TEST_CASE, branch, testArtifactFile.getName());
+ testArtifact.setSoleAttributeValue("Content URL", testArtifactFile.getFullPath().toString());
+ testArtifact.persist();
+ return testArtifact;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/Import/RelationImporter.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/Import/RelationImporter.java
new file mode 100644
index 00000000000..9a357c74ac2
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/Import/RelationImporter.java
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * 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.relation.Import;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.logging.Level;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.define.DefinePlugin;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.enums.RelationOrderBaseTypes;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.ExcelSaxHandler;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.RowProcessor;
+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.skynet.core.utility.Requirements;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class RelationImporter implements RowProcessor {
+ private static final int leadingColumnCount = 2;
+ private final ExcelSaxHandler excelHandler;
+ private final XMLReader xmlReader;
+ private Artifact[] columnArtifacts;
+ private IProgressMonitor monitor;
+ private boolean done;
+ private final Branch branch;
+
+ /**
+ * @throws SAXException
+ */
+ public RelationImporter(Branch branch) throws SAXException {
+ this.branch = branch;
+ excelHandler = new ExcelSaxHandler(this, true, true);
+
+ xmlReader = XMLReaderFactory.createXMLReader();
+ xmlReader.setContentHandler(excelHandler);
+ }
+
+ public void extractRelationsFromSheet(InputStream importStream, IProgressMonitor monitor) throws IOException, SAXException {
+ this.monitor = monitor;
+ xmlReader.parse(new InputSource(importStream));
+ }
+
+ public void processRow(String[] row) {
+ if (done) {
+ return;
+ }
+ try {
+ monitor.worked(1);
+ Collection<Artifact> artifacts =
+ ArtifactQuery.getArtifactListFromTypeAndAttribute(Requirements.SUBSYSTEM_REQUIREMENT,
+ CoreAttributeTypes.PARAGRAPH_NUMBER, row[1], branch);
+
+ Artifact rowArtifact;
+ try {
+ rowArtifact = getSoleArtifact(artifacts);
+ } catch (IllegalArgumentException ex) {
+ OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
+ return;
+ }
+
+ if (rowArtifact == null) {
+ System.out.println("Skipping " + row[0] + " becuase no matching artifact was found");
+ } else {
+ if (!row[0].equals(rowArtifact.getName())) {
+ System.out.printf("Warning %s != %s%n", row[0], rowArtifact.getName());
+ }
+ monitor.subTask(rowArtifact.getName());
+ for (int i = 0; i < columnArtifacts.length; i++) {
+ String rationale = row[i + leadingColumnCount];
+ if (rationale != null) {
+ if (rationale.equalsIgnoreCase("x")) {
+ rationale = "";
+ }
+ columnArtifacts[i].addRelation(RelationOrderBaseTypes.USER_DEFINED,
+ CoreRelationTypes.Allocation__Requirement, rowArtifact, rationale);
+ columnArtifacts[i].persist();
+ }
+ }
+ }
+ } catch (Exception ex) {
+ OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
+ }
+ }
+
+ private Artifact getSoleArtifact(Collection<Artifact> artifacts) {
+ Artifact artifactResult = null;
+ boolean soleArtifact = true;
+ for (Artifact artifact : artifacts) {
+ if (soleArtifact) {
+ soleArtifact = false;
+ } else {
+ throw new IllegalArgumentException("Found more than one match for: " + artifact);
+ }
+ artifactResult = artifact;
+ }
+ return artifactResult;
+ }
+
+ public void processHeaderRow(String[] row) {
+ monitor.setTaskName("Aquire Column Artifacts");
+ columnArtifacts = new Artifact[row.length - leadingColumnCount];
+ for (int i = 0; i < columnArtifacts.length; i++) {
+ monitor.worked(1);
+ try {
+ Collection<Artifact> artifacts =
+ ArtifactQuery.getArtifactListFromTypeAndName(Requirements.COMPONENT, row[i + leadingColumnCount],
+ branch);
+
+ columnArtifacts[i] = getSoleArtifact(artifacts);
+ monitor.subTask(columnArtifacts[i].getName());
+ } catch (Exception ex) {
+ System.out.println(ex);
+ }
+ }
+ System.out.println(Arrays.deepToString(columnArtifacts));
+ monitor.setTaskName("Relate Row Artifacts");
+ }
+
+ public void processEmptyRow() {
+ }
+
+ public void processCommentRow(String[] row) {
+ }
+
+ public void reachedEndOfWorksheet() {
+ monitor.done();
+ done = true;
+ }
+
+ public void detectedRowAndColumnCounts(int rowCount, int columnCount) {
+ monitor.beginTask("Importing Relations", rowCount + columnCount - leadingColumnCount);
+ }
+
+ public void foundStartOfWorksheet(String sheetName) {
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/TreeViewerTest.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/TreeViewerTest.java
new file mode 100644
index 00000000000..08c9ac349f5
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/TreeViewerTest.java
@@ -0,0 +1,272 @@
+/*******************************************************************************
+ * 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.relation;
+
+import java.io.File;
+import java.util.Date;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ITableColorProvider;
+import org.eclipse.jface.viewers.ITableFontProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+
+public class TreeViewerTest {
+
+ class TreeViewerTestLabelProvider implements ITableLabelProvider, ITableColorProvider, ITableFontProvider {
+ Font font = null;
+
+ public String getColumnText(Object element, int columnIndex) {
+ if (!(element instanceof File)) {
+ return null;
+ }
+ File file = (File) element;
+ switch (columnIndex) {
+ case 0:
+ return file.getName();
+ case 1:
+ return "" + new Date(file.lastModified());
+ case 2:
+ return "" + file.isHidden();
+ }
+ return null;
+ }
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ if (columnIndex != 0) {
+ return null;
+ }
+ if (!(element instanceof File)) {
+ return null;
+ }
+ File file = (File) element;
+ Display display = Display.getCurrent();
+ if (file.isDirectory()) {
+ return display.getSystemImage(SWT.ICON_WARNING);
+ }
+ return display.getSystemImage(SWT.ICON_QUESTION);
+ }
+
+ public void dispose() {
+ if (font != null) {
+ font.dispose();
+ }
+ font = null;
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ public Color getForeground(Object element, int columnIndex) {
+ if (columnIndex == 1) {
+ Display display = Display.getCurrent();
+ return display.getSystemColor(SWT.COLOR_RED);
+ }
+ return null;
+ }
+
+ public Color getBackground(Object element, int columnIndex) {
+ if (columnIndex == 0) {
+ File file = (File) element;
+ Display display = Display.getCurrent();
+ if (file.isDirectory()) {
+ return display.getSystemColor(SWT.COLOR_CYAN);
+ }
+ return display.getSystemColor(SWT.COLOR_MAGENTA);
+ }
+ return null;
+ }
+
+ public Font getFont(Object element, int columnIndex) {
+ if (columnIndex == 2) {
+ if (font == null) {
+ Display display = Display.getCurrent();
+ font = new Font(display, "Times", 12, SWT.ITALIC);
+ }
+ return font;
+ }
+ return null;
+ }
+ }
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new FormLayout());
+
+ TreeViewerTestLabelProvider labelProvider1 = new TreeViewerTest().new TreeViewerTestLabelProvider();
+ ITreeContentProvider contentProvider = new ITreeContentProvider() {
+ public Object[] getChildren(Object parentElement) {
+ if (!(parentElement instanceof File)) {
+ return null;
+ }
+ File file = (File) parentElement;
+ if (file.isDirectory()) {
+ return file.listFiles();
+ }
+ return null;
+ }
+
+ public Object getParent(Object element) {
+ if (!(element instanceof File)) {
+ return null;
+ }
+ File file = (File) element;
+ return file.getParentFile();
+ }
+
+ public boolean hasChildren(Object element) {
+ if (!(element instanceof File)) {
+ return false;
+ }
+ File file = (File) element;
+ return file.isDirectory();
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ };
+
+ ILabelProvider labelProvider2 = new ILabelProvider() {
+ public void dispose() {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ public Image getImage(Object element) {
+ if (!(element instanceof File)) {
+ return null;
+ }
+ File file = (File) element;
+ if (file.isDirectory()) {
+ return display.getSystemImage(SWT.ICON_WARNING);
+ }
+ return display.getSystemImage(SWT.ICON_QUESTION);
+ }
+
+ public String getText(Object element) {
+ if (!(element instanceof File)) {
+ return null;
+ }
+ File file = (File) element;
+ return file.getName();
+ }
+
+ };
+
+ final TreeViewer treeViewer1 = new TreeViewer(shell, SWT.FULL_SELECTION | SWT.CHECK);
+ Tree tree1 = treeViewer1.getTree();
+ tree1.setHeaderVisible(true);
+ TreeColumn column1 = new TreeColumn(tree1, SWT.LEFT);
+ column1.setText("Name");
+ column1.setImage(display.getSystemImage(SWT.ICON_WORKING));
+ column1.setWidth(200);
+ TreeColumn column2 = new TreeColumn(tree1, SWT.CENTER);
+ column2.setText("Last Modified");
+ column2.setImage(display.getSystemImage(SWT.ICON_INFORMATION));
+ column2.setWidth(200);
+ TreeColumn column3 = new TreeColumn(tree1, SWT.CENTER);
+ column3.setText("Hidden");
+ column3.setImage(display.getSystemImage(SWT.ICON_INFORMATION));
+ column3.setWidth(100);
+ treeViewer1.setLabelProvider(labelProvider1);
+ treeViewer1.setContentProvider(contentProvider);
+
+ final TreeViewer treeViewer2 = new TreeViewer(shell);
+ Tree tree2 = treeViewer2.getTree();
+ treeViewer2.setLabelProvider(labelProvider2);
+ treeViewer2.setContentProvider(contentProvider);
+
+ Button b = new Button(shell, SWT.PUSH);
+ b.setText("choose root folder");
+ b.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event e) {
+ DirectoryDialog f = new DirectoryDialog(shell, SWT.OPEN);
+ String root = f.open();
+ if (root != null) {
+ File file = new File(root);
+ if (file.exists()) {
+ treeViewer1.setInput(file);
+ treeViewer1.refresh();
+ treeViewer2.setInput(file);
+ treeViewer2.refresh();
+ }
+ }
+ }
+ });
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 10);
+ data.top = new FormAttachment(0, 10);
+ data.right = new FormAttachment(50, -5);
+ data.bottom = new FormAttachment(b, -10);
+ tree1.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(50, 5);
+ data.top = new FormAttachment(0, 10);
+ data.right = new FormAttachment(100, -10);
+ data.bottom = new FormAttachment(b, -10);
+ tree2.setLayoutData(data);
+
+ data = new FormData();
+ data.left = new FormAttachment(0, 10);
+ data.bottom = new FormAttachment(100, -10);
+ b.setLayoutData(data);
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ display.dispose();
+ }
+} \ 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
new file mode 100644
index 00000000000..f2b6161d8ff
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ITraceParser.java
@@ -0,0 +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();
+
+}
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
new file mode 100644
index 00000000000..c403b8fd37b
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ITraceUnitResourceLocator.java
@@ -0,0 +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);
+
+}
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
new file mode 100644
index 00000000000..e63134e07d8
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityJob.java
@@ -0,0 +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;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityPage.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityPage.java
new file mode 100644
index 00000000000..9dc9ee6f2ce
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityPage.java
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * 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 org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.ui.plugin.util.DirectoryOrFileSelector;
+import org.eclipse.osee.framework.ui.skynet.branch.BranchSelectComposite;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.dialogs.WizardDataTransferPage;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class ImportTraceabilityPage extends WizardDataTransferPage {
+ public static final String PAGE_NAME = "org.eclipse.osee.define.wizardPage.importTraceabilityPage";
+
+ private DirectoryOrFileSelector directoryFileSelector;
+ private BranchSelectComposite branchSelectComposite;
+
+ private IResource currentResourceSelection;
+
+ /**
+ * @param name
+ * @param selection
+ */
+ public ImportTraceabilityPage(IStructuredSelection selection) {
+ super(PAGE_NAME);
+
+ setTitle("Import traceability into OSEE Define");
+ setDescription("Import relations between artifacts");
+
+ if (selection != null && selection.size() == 1) {
+ Object firstElement = selection.getFirstElement();
+ if (firstElement instanceof IAdaptable) {
+ currentResourceSelection = (IResource) ((IAdaptable) firstElement).getAdapter(IResource.class);
+ }
+ }
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ initializeDialogUnits(parent);
+
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
+ composite.setSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ composite.setFont(parent.getFont());
+
+ createSourceGroup(composite);
+
+ restoreWidgetValues();
+ updateWidgetEnablements();
+ setPageComplete(determinePageCompletion());
+
+ setControl(composite);
+ }
+
+ /**
+ * The <code>WizardResourceImportPage</code> implementation of this <code>Listener</code> method handles all events
+ * and enablements for controls on this page. Subclasses may extend.
+ *
+ * @param event Event
+ */
+ public void handleEvent(Event event) {
+ setPageComplete(determinePageCompletion());
+ }
+
+ protected void createSourceGroup(Composite parent) {
+ directoryFileSelector = new DirectoryOrFileSelector(parent, SWT.NONE, "Import Source", this);
+
+ if (currentResourceSelection == null) {
+ // Select directory as the default
+ directoryFileSelector.setDirectorySelected(true);
+ } else {
+ directoryFileSelector.setDirectorySelected(currentResourceSelection.getType() != IResource.FILE);
+ directoryFileSelector.setText(currentResourceSelection.getLocation().toString());
+ }
+
+ Group composite = new Group(parent, SWT.NONE);
+ composite.setText("Destination Branch");
+ GridLayout gd = new GridLayout();
+ composite.setLayout(gd);
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ branchSelectComposite = new BranchSelectComposite(composite, SWT.BORDER, false);
+
+ setPageComplete(determinePageCompletion());
+ }
+
+ /*
+ * @see WizardPage#becomesVisible
+ */
+ @Override
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ // policy: wizards are not allowed to come up with an error message
+ if (visible) {
+ setErrorMessage(null);
+ }
+ }
+
+ @Override
+ protected boolean validateSourceGroup() {
+ return directoryFileSelector.validate(this);
+ }
+
+ public File getImportFile() {
+ return directoryFileSelector.getFile();
+ }
+
+ public Branch getSelectedBranch() {
+ return branchSelectComposite.getSelectedBranch();
+ }
+
+ @Override
+ protected boolean allowNewContainerName() {
+ return false;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityWizard.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityWizard.java
new file mode 100644
index 00000000000..51406f0738e
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityWizard.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * 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 org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.osee.define.DefinePlugin;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.logging.OseeLevel;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.plugin.core.util.Jobs;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class ImportTraceabilityWizard extends Wizard implements IImportWizard {
+ private ImportTraceabilityPage mainPage;
+ private IStructuredSelection selection;
+
+ public ImportTraceabilityWizard() {
+ super();
+ setWindowTitle("Traceability Import Wizard");
+ }
+
+ @Override
+ public boolean performFinish() {
+ try {
+ Branch branch = mainPage.getSelectedBranch();
+ File file = mainPage.getImportFile();
+ Jobs.startJob(new ImportTraceabilityJob(file, branch, true));
+ } catch (Exception ex) {
+ OseeLog.log(DefinePlugin.class, OseeLevel.SEVERE_POPUP, "Traceability Import Error", ex);
+ }
+ return true;
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.selection = selection;
+ }
+
+ @Override
+ public void addPages() {
+ mainPage = new ImportTraceabilityPage(selection);
+ addPage(mainPage);
+ }
+}
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
new file mode 100644
index 00000000000..3708716f569
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/TraceUnitExtensionManager.java
@@ -0,0 +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;
+ }
+
+ }
+}
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
new file mode 100644
index 00000000000..270a43ec5ef
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/TraceabilityExtractor.java
@@ -0,0 +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;
+ }
+}
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
new file mode 100644
index 00000000000..1a4cee6f791
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/action/FindTraceUnitActionDelegate.java
@@ -0,0 +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();
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/action/FindTraceUnitEditorAction.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/action/FindTraceUnitEditorAction.java
new file mode 100644
index 00000000000..b5da8bbd682
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/action/FindTraceUnitEditorAction.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * 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.logging.Level;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.osee.define.DefinePlugin;
+import org.eclipse.osee.define.traceability.jobs.FindTraceUnitJob;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.plugin.core.util.Jobs;
+import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
+import org.eclipse.ui.IEditorActionDelegate;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.PlatformUI;
+
+public class FindTraceUnitEditorAction implements IEditorActionDelegate {
+
+ public void run(IAction action) {
+ IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ IEditorInput editorInput = editorPart.getEditorInput();
+ IFile iFile = null;
+ if (editorInput instanceof IFileEditorInput) {
+ iFile = ((IFileEditorInput) editorInput).getFile();
+ if (iFile != null) {
+ OseeLog.log(DefinePlugin.class, Level.INFO, "iFile *" + iFile + "*");
+ }
+ }
+ if (iFile == null) {
+ AWorkbench.popup("ERROR", "Can't retrieve IFile");
+ return;
+ }
+ Jobs.startJob(new FindTraceUnitJob("Resource To Trace Unit Artifact", iFile), true);
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ }
+
+ public void setActiveEditor(IAction action, IEditorPart targetEditor) {
+ }
+} \ No newline at end of file
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
new file mode 100644
index 00000000000..a2ee0087a22
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/blam/RemoveTraceMarksFromTraceUnits.java
@@ -0,0 +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);
+ }
+ }
+}
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
new file mode 100644
index 00000000000..1555324328b
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/blam/TraceReportBlam.java
@@ -0,0 +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));
+ }
+ }
+}
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
new file mode 100644
index 00000000000..054bfd9021a
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/blam/UiToTestBlam.java
@@ -0,0 +1,238 @@
+/*******************************************************************************
+ * 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.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, false));
+ }
+ } 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;
+ }
+
+}
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
new file mode 100644
index 00000000000..2fa7e324e2f
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/BaseTraceDataCache.java
@@ -0,0 +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;
+ }
+}
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
new file mode 100644
index 00000000000..e98d350963e
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/CodeUnitData.java
@@ -0,0 +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);
+ }
+}
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
new file mode 100644
index 00000000000..fd005a93edd
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/RequirementData.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * 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 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(), false);
+ 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
new file mode 100644
index 00000000000..55686eecf5f
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TestUnitData.java
@@ -0,0 +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.model.Branch;
+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.utility.Requirements;
+
+/**
+ * @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(Requirements.TEST_CASE, 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(Requirements.TEST_SUPPORT, 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(Requirements.TEST_PROCEDURE, getBranch()));
+ testProcedures.addAll(ArtifactQuery.getArtifactListFromType("Test Procedure WML", getBranch()));
+ testProcedures.addAll(ArtifactQuery.getArtifactListFromType("Test Procedure XL", 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
new file mode 100644
index 00000000000..1fb1d9e0dc1
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TraceMark.java
@@ -0,0 +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());
+ }
+}
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
new file mode 100644
index 00000000000..906e5d79be8
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TraceUnit.java
@@ -0,0 +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;
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/importer/ImportTraceUnitPage.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/importer/ImportTraceUnitPage.java
new file mode 100644
index 00000000000..7ae4d4acf33
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/importer/ImportTraceUnitPage.java
@@ -0,0 +1,425 @@
+/*******************************************************************************
+ * 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.importer;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Level;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.osee.define.DefinePlugin;
+import org.eclipse.osee.define.traceability.TraceUnitExtensionManager;
+import org.eclipse.osee.define.traceability.TraceUnitExtensionManager.TraceHandler;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.jdk.core.type.MutableBoolean;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
+import org.eclipse.osee.framework.ui.plugin.util.DirectoryOrFileSelector;
+import org.eclipse.osee.framework.ui.skynet.branch.BranchSelectComposite;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.dialogs.WizardDataTransferPage;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ImportTraceUnitPage extends WizardDataTransferPage {
+ private static final String PAGE_NAME = "org.eclipse.osee.define.traceability.importer.importTraceUnitPage";
+
+ private static final String PAGE_TITLE = "Import Trace Units into OSEE";
+ private static final String PAGE_DESCRIPTION = "Imports trace units into OSEE and updates relations.";
+
+ private static final String SOURCE_GROUP = "Select trace unit(s) source path";
+ private static final String BRANCH_SELECT_GROUP = "Select branch to import into";
+ private static final String IMPORT_BRANCH_TOOLTIP = "Only working branches are allowed";
+
+ private static final String TRACE_UNIT_HANDLER_GROUP = "Select trace unit parser";
+ private static final String TRACE_UNIT_ERROR = "Please select a trace unit handler";
+
+ private static final String OPTIONS_GROUP = "Processing Options";
+ private static final String PERSIST_CHANGES = "Persist Changes";
+ private static final String PERSIST_TOOLTIP =
+ "When not selected, will report all trace marks found per trace unit file.";
+
+ private static final String RECURSION_BUTTON = "Traverse sub-folders";
+ private static final String RECURSION_TOOLTIP =
+ "When selected, processing will include folders and their sub-folders.";
+
+ private static final String FILE_WITH_PATHS_BUTTON = "Is File With Embedded Paths";
+ private static final String FILE_WITH_PATHS_TOOLTIP =
+ "Select when using a source file with multiple paths separated with newlines.";
+
+ private static final String SELECTED_TRACE_HANDLERS_KEY = "trace.handlers";
+ private static final String BRANCH_KEY = "branch.selected";
+ private static final String SOURCE_URI_KEY = "source.uri";
+ private static final String SOURCE_URI_IS_DIRECTORY_KEY = "source.uri.is.directory";
+ private static final String IS_ART_PERSIST_ALLOWED_KEY = "is.art.persist.allowed";
+ private static final String IS_FOLDER_RECURSION_KEY = "is.folder.recurse.allowed";
+ private static final String IS_FILE_WITH_MULTI_PATHS_KEY = "is.file.with.multi.paths";
+
+ private DirectoryOrFileSelector directoryFileSelector;
+ private BranchSelectComposite branchSelectComposite;
+ private final MutableBoolean isFolderRecursionAllowed;
+ private final MutableBoolean isArtifactPersistanceAllowed;
+ private IResource currentResourceSelection;
+ private final MutableBoolean isFileContainingMultiplePaths;
+ private final Map<Button, Boolean> traceUnitHandlers;
+ private final Map<String, Button> optionButtons;
+
+ /**
+ * @param name
+ * @param selection
+ */
+ public ImportTraceUnitPage(IStructuredSelection selection) {
+ super(PAGE_NAME);
+ setTitle(PAGE_TITLE);
+ setDescription(PAGE_DESCRIPTION);
+ this.traceUnitHandlers = new HashMap<Button, Boolean>();
+ this.optionButtons = new HashMap<String, Button>();
+
+ this.isFolderRecursionAllowed = new MutableBoolean(false);
+ this.isArtifactPersistanceAllowed = new MutableBoolean(false);
+ this.isFileContainingMultiplePaths = new MutableBoolean(false);
+
+ if (selection != null && selection.size() == 1) {
+ Object firstElement = selection.getFirstElement();
+ if (firstElement instanceof IAdaptable) {
+ currentResourceSelection = (IResource) ((IAdaptable) firstElement).getAdapter(IResource.class);
+ }
+ }
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ initializeDialogUnits(parent);
+
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
+ composite.setSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ composite.setFont(parent.getFont());
+
+ createTestUnitSourceArea(composite);
+ createBranchSelectArea(composite);
+ createParserSelectArea(composite);
+ createOptionsArea(composite);
+
+ restoreWidgetValues();
+ updateWidgetEnablements();
+
+ setControl(composite);
+
+ setPageComplete(determinePageCompletion());
+
+ directoryFileSelector.addListener(SWT.Selection, new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+ Button button = optionButtons.get(IS_FILE_WITH_MULTI_PATHS_KEY);
+ if (isWidgetAccessible(button) && isWidgetAccessible(directoryFileSelector)) {
+ button.setEnabled(!directoryFileSelector.isDirectorySelected());
+ }
+ setPageComplete(determinePageCompletion());
+ }
+ });
+ }
+
+ private boolean isWidgetAccessible(Widget widget) {
+ return widget != null && !widget.isDisposed();
+ }
+
+ /**
+ * The <code>WizardResourceImportPage</code> implementation of this <code>Listener</code> method handles all events
+ * and enablements for controls on this page. Subclasses may extend.
+ *
+ * @param event Event
+ */
+ public void handleEvent(Event event) {
+ setPageComplete(determinePageCompletion());
+ }
+
+ protected void createTestUnitSourceArea(Composite parent) {
+ directoryFileSelector = new DirectoryOrFileSelector(parent, SWT.NONE, SOURCE_GROUP, this);
+
+ if (currentResourceSelection == null) {
+ // Select directory as the default
+ directoryFileSelector.setDirectorySelected(true);
+ } else {
+ directoryFileSelector.setDirectorySelected(currentResourceSelection.getType() != IResource.FILE);
+ directoryFileSelector.setText(currentResourceSelection.getLocation().toString());
+ }
+ }
+
+ protected void createBranchSelectArea(Composite parent) {
+ Group composite = new Group(parent, SWT.NONE);
+ composite.setText(BRANCH_SELECT_GROUP);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ composite.setToolTipText(IMPORT_BRANCH_TOOLTIP);
+
+ branchSelectComposite = new BranchSelectComposite(composite, SWT.BORDER, true);
+ branchSelectComposite.setToolTipText(IMPORT_BRANCH_TOOLTIP);
+ branchSelectComposite.addListener(new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+ setPageComplete(determinePageCompletion());
+ }
+ });
+ }
+
+ protected void createParserSelectArea(Composite parent) {
+ Group composite = new Group(parent, SWT.NONE);
+ composite.setText(TRACE_UNIT_HANDLER_GROUP);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ try {
+ for (TraceHandler handler : TraceUnitExtensionManager.getInstance().getAllTraceHandlers()) {
+ createTraceHandler(composite, handler.getName(), handler.getId());
+ }
+ } catch (Exception ex) {
+ OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
+ }
+
+ }
+
+ private void createTraceHandler(Composite parent, String text, String handlerId) {
+ Button handlerButton = new Button(parent, SWT.CHECK);
+ handlerButton.setText(text);
+ handlerButton.setData(handlerId);
+ handlerButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Object source = e.getSource();
+ if (source instanceof Button) {
+ Button button = (Button) source;
+ traceUnitHandlers.put(button, button.getSelection());
+ }
+ setPageComplete(determinePageCompletion());
+ }
+ });
+ traceUnitHandlers.put(handlerButton, false);
+ }
+
+ protected void createOptionsArea(Composite parent) {
+ Group composite = new Group(parent, SWT.NONE);
+ composite.setText(OPTIONS_GROUP);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ createOptionButton(composite, IS_ART_PERSIST_ALLOWED_KEY, PERSIST_CHANGES, PERSIST_TOOLTIP,
+ isArtifactPersistanceAllowed);
+ createOptionButton(composite, IS_FOLDER_RECURSION_KEY, RECURSION_BUTTON, RECURSION_TOOLTIP,
+ isFolderRecursionAllowed);
+ createOptionButton(composite, IS_FILE_WITH_MULTI_PATHS_KEY, FILE_WITH_PATHS_BUTTON, FILE_WITH_PATHS_TOOLTIP,
+ isFileContainingMultiplePaths);
+ }
+
+ private void createOptionButton(Composite parent, String buttonId, String buttonText, String buttonToolTip, final MutableBoolean toModify) {
+ Button optionButton = new Button(parent, SWT.CHECK);
+ optionButton.setText(buttonText);
+ optionButton.setToolTipText(buttonToolTip);
+ optionButton.setData(toModify);
+ optionButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Object object = e.getSource();
+ if (object instanceof Button) {
+ toModify.setValue(((Button) object).getSelection());
+ }
+ setPageComplete(determinePageCompletion());
+ }
+ });
+ optionButton.setSelection(toModify.getValue());
+ optionButtons.put(buttonId, optionButton);
+ }
+
+ /*
+ * @see WizardPage#becomesVisible
+ */
+ @Override
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ // policy: wizards are not allowed to come up with an error message
+ if (visible) {
+ setErrorMessage(null);
+ }
+ }
+
+ @Override
+ protected boolean validateSourceGroup() {
+ boolean result = directoryFileSelector.validate(this);
+ if (result) {
+ Branch branch = getSelectedBranch();
+ if (branch == null) {
+ result = false;
+ setErrorMessage("Please select a valid working branch");
+ }
+ }
+ if (result) {
+ result &= validateParser(this);
+ }
+ return result;
+ }
+
+ protected boolean validateParser(WizardDataTransferPage wizardPage) {
+ boolean result = false;
+ String[] selectedHandlers = getTraceUnitHandlerIds();
+ if (selectedHandlers.length > 0) {
+ result = true;
+ } else {
+ wizardPage.setErrorMessage(TRACE_UNIT_ERROR);
+ }
+ return result;
+ }
+
+ public URI getSourceURI() {
+ return isWidgetAccessible(directoryFileSelector) ? directoryFileSelector.getFile().toURI() : null;
+ }
+
+ public Branch getSelectedBranch() {
+ return isWidgetAccessible(branchSelectComposite) ? branchSelectComposite.getSelectedBranch() : null;
+ }
+
+ public boolean isFolderRecursionAllowed() {
+ return isFolderRecursionAllowed.getValue();
+ }
+
+ public boolean isArtifactPersistanceAllowed() {
+ return isArtifactPersistanceAllowed.getValue();
+ }
+
+ public boolean isFileContainingMultiplePaths() {
+ return isWidgetAccessible(directoryFileSelector) ? !directoryFileSelector.isDirectorySelected() && isFileContainingMultiplePaths.getValue() : isFileContainingMultiplePaths.getValue();
+ }
+
+ public String[] getTraceUnitHandlerIds() {
+ List<String> selectedIds = new ArrayList<String>();
+ for (Button button : traceUnitHandlers.keySet()) {
+ Boolean value = traceUnitHandlers.get(button);
+ if (value != null && value == true) {
+ selectedIds.add((String) button.getData());
+ }
+ }
+ return selectedIds.toArray(new String[selectedIds.size()]);
+ }
+
+ @Override
+ protected void restoreWidgetValues() {
+ super.restoreWidgetValues();
+ IDialogSettings settings = getDialogSettings();
+ if (settings != null) {
+
+ String source = settings.get(SOURCE_URI_KEY);
+ if (currentResourceSelection == null || !currentResourceSelection.isAccessible()) {
+ if (Strings.isValid(source)) {
+ directoryFileSelector.setDirectorySelected(settings.getBoolean(SOURCE_URI_IS_DIRECTORY_KEY));
+ try {
+ directoryFileSelector.setText(new File(new URI(source)).getAbsolutePath());
+ } catch (URISyntaxException ex) {
+ // Do Nothing
+ }
+ }
+ }
+
+ for (String id : optionButtons.keySet()) {
+ Boolean value = settings.getBoolean(id);
+ if (id.equals(IS_FILE_WITH_MULTI_PATHS_KEY)) {
+ if (directoryFileSelector.isDirectorySelected()) {
+ value = false;
+ }
+ }
+ Button button = optionButtons.get(id);
+ button.setSelection(value);
+ Object data = button.getData();
+ if (data instanceof MutableBoolean) {
+ ((MutableBoolean) data).setValue(value);
+ }
+ }
+
+ try {
+ Integer branchId = settings.getInt(BRANCH_KEY);
+ if (branchId > 0) {
+ Branch branch = BranchManager.getBranch(branchId);
+ if (branch != null) {
+ branchSelectComposite.setSelected(branch);
+ }
+ }
+ } catch (OseeCoreException ex) {
+ // Do Nothing
+ }
+
+ String[] traceHandlers = settings.getArray(SELECTED_TRACE_HANDLERS_KEY);
+ if (traceHandlers != null && traceHandlers.length > 0) {
+ Set<String> traceIds = new HashSet<String>(Arrays.asList(traceHandlers));
+ for (Button button : traceUnitHandlers.keySet()) {
+ Object data = button.getData();
+ if (data instanceof String) {
+ String id = (String) data;
+ if (traceIds.contains(id)) {
+ button.setSelection(true);
+ traceUnitHandlers.put(button, true);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void saveWidgetValues() {
+ super.saveWidgetValues();
+ IDialogSettings settings = getDialogSettings();
+ if (settings != null) {
+ Branch branch = getSelectedBranch();
+ if (branch != null) {
+ settings.put(BRANCH_KEY, branch.getId());
+ }
+
+ settings.put(SELECTED_TRACE_HANDLERS_KEY, getTraceUnitHandlerIds());
+ settings.put(SOURCE_URI_KEY, getSourceURI().toASCIIString());
+ settings.put(SOURCE_URI_IS_DIRECTORY_KEY, directoryFileSelector.isDirectorySelected());
+ settings.put(IS_ART_PERSIST_ALLOWED_KEY, isArtifactPersistanceAllowed());
+ settings.put(IS_FOLDER_RECURSION_KEY, isFolderRecursionAllowed());
+ settings.put(IS_FILE_WITH_MULTI_PATHS_KEY, isFileContainingMultiplePaths());
+ }
+ }
+
+ @Override
+ protected boolean allowNewContainerName() {
+ return false;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/importer/ImportTraceUnitWizard.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/importer/ImportTraceUnitWizard.java
new file mode 100644
index 00000000000..cb8f06074c8
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/importer/ImportTraceUnitWizard.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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.importer;
+
+import java.net.URI;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.osee.define.DefinePlugin;
+import org.eclipse.osee.define.traceability.jobs.ImportTraceUnitsJob;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.logging.OseeLevel;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.plugin.core.util.Jobs;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ImportTraceUnitWizard extends Wizard implements IImportWizard {
+ private ImportTraceUnitPage page;
+ private IStructuredSelection selection;
+
+ public ImportTraceUnitWizard() {
+ super();
+ setDialogSettings(DefinePlugin.getInstance().getDialogSettings());
+ setWindowTitle("Import Trace Units Wizard");
+ }
+
+ @Override
+ public boolean performFinish() {
+ try {
+ Branch importToBranch = page.getSelectedBranch();
+ boolean isRecursive = page.isFolderRecursionAllowed();
+ boolean isPersistChanges = page.isArtifactPersistanceAllowed();
+ URI source = page.getSourceURI();
+ String[] traceUnitHandlerIds = page.getTraceUnitHandlerIds();
+ boolean fileWithMultiPaths = page.isFileContainingMultiplePaths();
+
+ Job job =
+ new ImportTraceUnitsJob("Import Trace Units", importToBranch, source, isRecursive, isPersistChanges,
+ fileWithMultiPaths, traceUnitHandlerIds);
+ Jobs.startJob(job, true);
+ page.saveWidgetValues();
+ } catch (Exception ex) {
+ OseeLog.log(DefinePlugin.class, OseeLevel.SEVERE_POPUP, "Import Trace Unit Error", ex);
+ }
+ return true;
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.selection = selection;
+ }
+
+ @Override
+ public void addPages() {
+ page = new ImportTraceUnitPage(selection);
+ addPage(page);
+ }
+}
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
new file mode 100644
index 00000000000..694ac2b6243
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/jobs/FindTraceUnitJob.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * 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.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;
+ }
+ private static final class FetchBranchJob extends UIJob {
+ 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;
+ }
+ }
+}
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
new file mode 100644
index 00000000000..d7c8c0b9854
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/jobs/ImportTraceUnitsJob.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * 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.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;
+ }
+
+}
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
new file mode 100644
index 00000000000..5555dc3f5c4
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/FindTraceUnitFromResource.java
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * 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.swt.widgets.Display;
+
+/**
+ * @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) {
+ Display.getDefault().asyncExec(new Runnable() {
+ 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
new file mode 100644
index 00000000000..7196a85f5f2
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ITraceUnitProcessor.java
@@ -0,0 +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;
+}
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
new file mode 100644
index 00000000000..f583fee5ab7
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ResourceToTraceUnit.java
@@ -0,0 +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);
+ }
+ }
+}
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
new file mode 100644
index 00000000000..98c5eefa5a3
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitFromResourceOperation.java
@@ -0,0 +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));
+ }
+ }
+}
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
new file mode 100644
index 00000000000..4f99dcf3a54
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitReportProcessor.java
@@ -0,0 +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) {
+ //
+ }
+ }
+}
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
new file mode 100644
index 00000000000..cb33e4bbe0c
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitToArtifactProcessor.java
@@ -0,0 +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.ArtifactType;
+import org.eclipse.osee.framework.core.model.Branch;
+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(Requirements.ABSTRACT_TEST_UNIT)) {
+ 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(Requirements.TEST_CASE)) {
+ List<Artifact> testRuns =
+ ArtifactQuery.getArtifactListFromTypeAndName(Requirements.TEST_RUN, 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(Requirements.TEST_CASE)) {
+ folder = getOrCreateTestCaseFolder(transaction);
+ } else if (testUnit.isOfType(Requirements.TEST_SUPPORT)) {
+ 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
new file mode 100644
index 00000000000..5d8a4d57685
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/AbstractArtifactRelationReport.java
@@ -0,0 +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();
+ }
+}
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
new file mode 100644
index 00000000000..dde8c6d87f9
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/AbstractReport.java
@@ -0,0 +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() {
+ }
+}
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
new file mode 100644
index 00000000000..03a87e974b2
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/ArtifactToRelatedArtifact.java
@@ -0,0 +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();
+ }
+}
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
new file mode 100644
index 00000000000..b269e2493c3
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/ArtifactTraceCount.java
@@ -0,0 +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.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
new file mode 100644
index 00000000000..407462bfb89
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/ArtifactsWithoutRelations.java
@@ -0,0 +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();
+ }
+}
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
new file mode 100644
index 00000000000..0fe30c629a3
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/report/IReportDataCollector.java
@@ -0,0 +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();
+}
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
new file mode 100644
index 00000000000..c90bc953144
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/utility/IResourceHandler.java
@@ -0,0 +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);
+}
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
new file mode 100644
index 00000000000..46cf7226026
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/utility/IResourceLocator.java
@@ -0,0 +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;
+}
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
new file mode 100644
index 00000000000..31ba45cba1d
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/utility/UriResourceContentFinder.java
@@ -0,0 +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);
+ }
+ }
+}

Back to the top