Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrbrooks2007-12-08 07:34:17 +0000
committerrbrooks2007-12-08 07:34:17 +0000
commite8f608978dd689780d59b1066920867b691ee6c4 (patch)
tree7bc40feb53e675f62d8cceab1f0be938f6e16931 /org.eclipse.osee.define/src/org/eclipse/osee/define
parenta9a5baedeb63aad242477951e562f2cc40cb52f0 (diff)
downloadorg.eclipse.osee-e8f608978dd689780d59b1066920867b691ee6c4.tar.gz
org.eclipse.osee-e8f608978dd689780d59b1066920867b691ee6c4.tar.xz
org.eclipse.osee-e8f608978dd689780d59b1066920867b691ee6c4.zip
[CQ 1720]
Diffstat (limited to 'org.eclipse.osee.define/src/org/eclipse/osee/define')
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/DefinePerspectiveFactory.java73
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/DefinePlugin.java38
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/artifact/Resolver.java54
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/artifact/Spreadsheet.java34
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/artifact/SpreadsheetArtifactFactory.java42
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/AddEveryoneGroupToBranches.java53
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/ChangeArtifactType.java186
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/CheckValidArtifactTypes.java33
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/CheckValidAttributeTypes.java33
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/CheckValidType.java74
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishPids.java50
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishSoftwareTestPlan.java113
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishSrs.java47
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/ErrorHandler.java49
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/Resolver.java17
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/SqlResolver.java37
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/StateValue.java30
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/meta/ImportRelationJob.java56
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/meta/ImportRelationPage.java190
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/meta/ImportRelationWizard.java62
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateView.java80
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateViewItems.java100
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateViewerSorter.java40
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/IDefineNavigateItem.java23
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/relation/Import/ExtractTestRelations.java131
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/relation/Import/RelationImporter.java178
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/relation/TreeViewerTest.java244
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityJob.java269
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityPage.java169
-rw-r--r--org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityWizard.java71
30 files changed, 2576 insertions, 0 deletions
diff --git a/org.eclipse.osee.define/src/org/eclipse/osee/define/DefinePerspectiveFactory.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/DefinePerspectiveFactory.java
new file mode 100644
index 00000000000..d4f0b73d9b9
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/DefinePerspectiveFactory.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * 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.branch.BranchView;
+import org.eclipse.osee.framework.ui.skynet.changeReport.ChangeReportView;
+import org.eclipse.osee.framework.ui.skynet.history.RevisionHistoryView;
+import org.eclipse.osee.framework.ui.skynet.queryLog.QueryLogView;
+import org.eclipse.osee.framework.ui.skynet.search.QuickSearchView;
+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) {
+ // Get the editor area.
+ String editorArea = layout.getEditorArea();
+
+ // Add views to Window -> Show View
+ layout.addShowViewShortcut(ArtifactExplorer.VIEW_ID);
+ layout.addShowViewShortcut(BranchView.VIEW_ID);
+ layout.addShowViewShortcut(ChangeReportView.VIEW_ID);
+ layout.addShowViewShortcut(QueryLogView.VIEW_ID);
+ layout.addShowViewShortcut(QuickSearchView.VIEW_ID);
+ layout.addShowViewShortcut(DefineNavigateView.VIEW_ID);
+ layout.addShowViewShortcut("org.eclipse.pde.runtime.LogView");
+
+ // Top left: Artifact Explorer
+ IFolderLayout topLeft = layout.createFolder("topLeft", IPageLayout.LEFT, 0.25f, editorArea);
+ 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(RevisionHistoryView.VIEW_ID);
+ lower.addPlaceholder(ChangeReportView.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/org.eclipse.osee.define/src/org/eclipse/osee/define/DefinePlugin.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/DefinePlugin.java
new file mode 100644
index 00000000000..7715bea43e7
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/DefinePlugin.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * 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;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.jdk.core.util.plugin.OseePlugin#getPluginName()
+ */
+ @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/org.eclipse.osee.define/src/org/eclipse/osee/define/artifact/Resolver.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/artifact/Resolver.java
new file mode 100644
index 00000000000..07f4e13e971
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/artifact/Resolver.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.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");
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.xml.transform.URIResolver#resolve(java.lang.String, java.lang.String)
+ */
+ 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/org.eclipse.osee.define/src/org/eclipse/osee/define/artifact/Spreadsheet.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/artifact/Spreadsheet.java
new file mode 100644
index 00000000000..1e73da3b0fc
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/artifact/Spreadsheet.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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.sql.SQLException;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.Branch;
+import org.eclipse.osee.framework.skynet.core.artifact.factory.IArtifactFactory;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class Spreadsheet extends Artifact {
+
+ /**
+ * @param parentFactory
+ * @param guid
+ * @param humanReadableId
+ * @param branch
+ * @throws SQLException
+ */
+ public Spreadsheet(IArtifactFactory parentFactory, String guid, String humanReadableId, Branch branch) throws SQLException {
+ super(parentFactory, guid, humanReadableId, branch);
+ }
+
+}
diff --git a/org.eclipse.osee.define/src/org/eclipse/osee/define/artifact/SpreadsheetArtifactFactory.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/artifact/SpreadsheetArtifactFactory.java
new file mode 100644
index 00000000000..90c4b91b7d2
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/artifact/SpreadsheetArtifactFactory.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.artifact;
+
+import java.sql.SQLException;
+import org.eclipse.osee.framework.skynet.core.artifact.Branch;
+import org.eclipse.osee.framework.skynet.core.artifact.factory.ArtifactFactory;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class SpreadsheetArtifactFactory extends ArtifactFactory<Spreadsheet> {
+ private static SpreadsheetArtifactFactory factory = null;
+
+ private SpreadsheetArtifactFactory(int factoryId) {
+ super(factoryId);
+ }
+
+ public static SpreadsheetArtifactFactory getInstance(int factoryId) {
+ if (factory == null) {
+ factory = new SpreadsheetArtifactFactory(factoryId);
+ }
+ return factory;
+ }
+
+ public static SpreadsheetArtifactFactory getInstance() {
+ return factory;
+ }
+
+ @Override
+ public Spreadsheet getNewArtifact(String guid, String humandReadableId, String factoryKey, Branch branch) throws SQLException {
+ return new Spreadsheet(this, guid, humandReadableId, branch);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/AddEveryoneGroupToBranches.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/AddEveryoneGroupToBranches.java
new file mode 100644
index 00000000000..092ea0ca278
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/AddEveryoneGroupToBranches.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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.Collection;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.skynet.core.access.AccessControlManager;
+import org.eclipse.osee.framework.skynet.core.access.PermissionEnum;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactPersistenceManager;
+import org.eclipse.osee.framework.skynet.core.artifact.Branch;
+import org.eclipse.osee.framework.skynet.core.artifact.BranchPersistenceManager;
+import org.eclipse.osee.framework.ui.skynet.blam.BlamVariableMap;
+import org.eclipse.osee.framework.ui.skynet.blam.operation.BlamOperation;
+
+/**
+ * @author Jeff C. Phillips
+ */
+public class AddEveryoneGroupToBranches implements BlamOperation {
+
+ AccessControlManager accessControlManager = AccessControlManager.getInstance();
+ BranchPersistenceManager branchPersistenceManager = BranchPersistenceManager.getInstance();
+ ArtifactPersistenceManager artifactPersistenceManager = ArtifactPersistenceManager.getInstance();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.ui.skynet.blam.operation.BlamOperation#runOperation(org.eclipse.osee.framework.ui.skynet.blam.BlamVariableMap, org.eclipse.osee.framework.skynet.core.artifact.Branch, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void runOperation(BlamVariableMap variableMap, Branch branch, IProgressMonitor monitor) throws Exception {
+ Collection<Artifact> artifacts;
+
+ for (Branch brnch : branchPersistenceManager.getBranches()) {
+
+ if (!accessControlManager.getAccessControlList(brnch).isEmpty()) {
+ artifacts = artifactPersistenceManager.getArtifactsFromAttribute("Name", "Everyone",
+ branchPersistenceManager.getCommonBranch());
+
+ if (!artifacts.isEmpty()) {
+ accessControlManager.setPermission(artifacts.iterator().next(), brnch, PermissionEnum.READ);
+ }
+ }
+ }
+
+ }
+
+}
diff --git a/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/ChangeArtifactType.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/ChangeArtifactType.java
new file mode 100644
index 00000000000..f2e39b6e1fe
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/ChangeArtifactType.java
@@ -0,0 +1,186 @@
+/*******************************************************************************
+ * 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.SQLException;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
+import org.eclipse.osee.framework.plugin.core.config.ConfigUtil;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.Branch;
+import org.eclipse.osee.framework.skynet.core.attribute.ArtifactSubtypeDescriptor;
+import org.eclipse.osee.framework.skynet.core.attribute.Attribute;
+import org.eclipse.osee.framework.skynet.core.attribute.ConfigurationPersistenceManager;
+import org.eclipse.osee.framework.skynet.core.attribute.DynamicAttributeDescriptor;
+import org.eclipse.osee.framework.skynet.core.attribute.DynamicAttributeManager;
+import org.eclipse.osee.framework.skynet.core.relation.IRelationLink;
+import org.eclipse.osee.framework.skynet.core.relation.RelationLinkBase;
+import org.eclipse.osee.framework.skynet.core.relation.RelationPersistenceManager;
+import org.eclipse.osee.framework.ui.plugin.util.Displays;
+import org.eclipse.osee.framework.ui.skynet.blam.BlamVariableMap;
+import org.eclipse.osee.framework.ui.skynet.blam.operation.BlamOperation;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Changes the descriptor type of an artifact to the provided descriptor.
+ *
+ * @author Jeff C. Phillips
+ */
+public class ChangeArtifactType implements BlamOperation {
+
+ private static final Logger logger = ConfigUtil.getConfigFactory().getLogger(ChangeArtifactType.class);
+ private static final ConfigurationPersistenceManager configurationPersistenceManager = ConfigurationPersistenceManager.getInstance();
+ private static final RelationPersistenceManager relationPersistenceManager = RelationPersistenceManager.getInstance();
+ private List<Attribute> attributesToPurge;
+ private List<RelationLinkBase> linksToPurge;
+
+ @SuppressWarnings("unchecked")
+ public void runOperation(BlamVariableMap variableMap, Branch branch, IProgressMonitor monitor) throws Exception {
+ processChange(variableMap.getArtifacts("artifact"), variableMap.getArtifactSubtypeDescriptor("descriptor"));
+ }
+
+ /**
+ * Changes the descriptor of the artifacts to the provided artifact descriptor
+ *
+ * @param artifacts
+ * @param descriptor
+ * @throws SQLException
+ */
+ private void processChange(List<Artifact> artifacts, ArtifactSubtypeDescriptor descriptor) throws SQLException {
+ for (Artifact artifact : artifacts) {
+ processAttributes(artifact, descriptor);
+ processRelations(artifact, descriptor);
+
+ if (doesUserAcceptArtifactChange(artifact, descriptor)) {
+ changeArtifactType(artifact, descriptor);
+ }
+ }
+ }
+
+ /**
+ * Splits the attributes of the current artifact into two groups. The attributes that are compatable for the new type
+ * and the attributes that will need to be purged.
+ *
+ * @param artifact
+ * @param descriptor
+ */
+ private void processAttributes(Artifact artifact, ArtifactSubtypeDescriptor descriptor) {
+ attributesToPurge = new LinkedList<Attribute>();
+
+ try {
+ Collection<DynamicAttributeDescriptor> descriptorAttrTypes = configurationPersistenceManager.getAttributeTypesFromArtifactType(descriptor);
+
+ for (DynamicAttributeManager attributeManager : artifact.getAttributes()) {
+
+ if (!descriptorAttrTypes.contains(attributeManager.getDescriptor())) {
+ attributesToPurge.addAll(attributeManager.getAttributes());
+ }
+ }
+ } catch (SQLException ex) {
+ logger.log(Level.SEVERE, ex.toString(), ex);
+ }
+ }
+
+ /**
+ * Splits the relationLinks of the current artifact into Two groups. The links that are compatable for the new type
+ * and the links that will need to be pruged.
+ *
+ * @param artifact
+ * @param descriptor
+ * @throws SQLException
+ */
+ private void processRelations(Artifact artifact, ArtifactSubtypeDescriptor descriptor) throws SQLException {
+ linksToPurge = new LinkedList<RelationLinkBase>();
+
+ for (IRelationLink link : artifact.getLinkManager().getLinks()) {
+
+ if (link instanceof RelationLinkBase) {
+ RelationLinkBase linkBase = (RelationLinkBase) link;
+ if (linkBase.getLinkDescriptor().getRestrictionSizeFor(descriptor.getArtTypeId(),
+ linkBase.getArtifactA().equals(artifact)) == 0) {
+ linksToPurge.add(linkBase);
+ }
+ }
+
+ }
+ }
+
+ /**
+ * @param artifact
+ * @param descriptor
+ * @return true if the user acceptes the purging of the attributes and realtions that are not compatable for the new
+ * artifact type else false.
+ */
+ private boolean doesUserAcceptArtifactChange(final Artifact artifact, final ArtifactSubtypeDescriptor descriptor) {
+ if (!linksToPurge.isEmpty() || !attributesToPurge.isEmpty()) {
+ ArtifactChangeMessageRunnable messageRunnable = new ArtifactChangeMessageRunnable(artifact, descriptor);
+ Displays.ensureInDisplayThread(messageRunnable, true);
+ return messageRunnable.isAccept();
+ } else {
+ return true;
+ }
+ }
+
+ private class ArtifactChangeMessageRunnable implements Runnable {
+ private boolean accept = false;
+ private Artifact artifact;
+ private ArtifactSubtypeDescriptor descriptor;
+
+ public ArtifactChangeMessageRunnable(Artifact artifact, ArtifactSubtypeDescriptor descriptor) {
+ this.artifact = artifact;
+ this.descriptor = descriptor;
+ }
+
+ public void run() {
+ accept = MessageDialog.openQuestion(
+ Display.getCurrent().getActiveShell(),
+ "Confirm Artifact Type Change ",
+ "There has been a conflict in changing " + artifact.getDescriptiveName() + " to " + descriptor.getName() + " type. \n" + "The following data will need to be purged " + (linksToPurge.isEmpty() ? "" : Collections.toString(
+ linksToPurge, ":", ",", null)) + (attributesToPurge.isEmpty() ? "" : Collections.toString(
+ attributesToPurge, ":", ",", null)));
+ }
+
+ /**
+ * @return Returns the accept.
+ */
+ public boolean isAccept() {
+ return accept;
+ }
+ };
+
+ /**
+ * Sets the artifact descriptor.
+ *
+ * @param artifact
+ * @param descriptor
+ * @throws SQLException
+ */
+ private void changeArtifactType(Artifact artifact, ArtifactSubtypeDescriptor descriptor) throws SQLException {
+ for (Attribute attribute : attributesToPurge) {
+ if (attribute.getPersistenceMemo() != null) {
+ attribute.purge();
+ }
+ }
+
+ if (!linksToPurge.isEmpty()) {
+ relationPersistenceManager.purgeRelationLinks(linksToPurge);
+ }
+
+ artifact.changeArtifactType(descriptor);
+ artifact.persist();
+ }
+}
diff --git a/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/CheckValidArtifactTypes.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/CheckValidArtifactTypes.java
new file mode 100644
index 00000000000..1893c278311
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/CheckValidArtifactTypes.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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.logging.Logger;
+import org.eclipse.osee.framework.plugin.core.config.ConfigUtil;
+
+/**
+ * @author Jeff C. Phillips
+ */
+public class CheckValidArtifactTypes extends CheckValidType {
+ private static final Logger logger = ConfigUtil.getConfigFactory().getLogger(CheckValidArtifactTypes.class);
+ private static final String CHECK_SQL = "SELECT t1.*, t3.gamma_id, t4.* " + "FROM osee_define_artifact t1, " + "osee_define_artifact_version t2, " + "osee_define_txs t3, " + "osee_define_tx_details t4 " + "WHERE t1.art_id = t2.art_id " + "AND t2.gamma_id = t3.gamma_id " + "AND t3.transaction_id = t4.transaction_id " + "AND NOT EXISTS " + "(SELECT 'x' " + "FROM osee_define_artifact_type t5, " + "osee_define_txs t6, " + "osee_define_tx_details t7 " + "WHERE t5.gamma_id = t6.gamma_id " + "AND t6.transaction_id = t7.transaction_id " + "AND t4.branch_id = t7.branch_id " + "AND t1.art_type_id = t5.art_type_id)";
+
+ /**
+ * @param sql
+ * @param headers
+ * @param colNames
+ * @param logger
+ */
+ public CheckValidArtifactTypes() {
+ super(CHECK_SQL, new String[] {"art_id", "gamma_id", "transaction_id", "branch_id"}, new String[] {"Art ID",
+ "Gamma ID", "Transaction ID", "Branch ID"}, logger);
+ }
+}
diff --git a/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/CheckValidAttributeTypes.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/CheckValidAttributeTypes.java
new file mode 100644
index 00000000000..cbd213f1da1
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/CheckValidAttributeTypes.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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.logging.Logger;
+import org.eclipse.osee.framework.plugin.core.config.ConfigUtil;
+
+/**
+ * @author Jeff C. Phillips
+ */
+public class CheckValidAttributeTypes extends CheckValidType {
+ private static final Logger logger = ConfigUtil.getConfigFactory().getLogger(CheckValidAttributeTypes.class);
+ private static final String CHECK_SQL = "SELECT t2.*, t4.*, t10.guid, t10.human_readable_id, t10.art_type_id " + "FROM osee_define_attribute t2, " + "osee_define_txs t3, " + "osee_define_tx_details t4, " + "osee_define_artifact t10 " + "WHERE t2.gamma_id = t3.gamma_id " + "and t10.art_id = t2.art_id " + "AND t3.transaction_id = t4.transaction_id " + "AND NOT EXISTS " + "(SELECT 'x' " + "FROM osee_define_attribute_type t5, " + "osee_define_txs t6, " + "osee_define_tx_details t7 " + "WHERE t5.gamma_id = t6.gamma_id " + "AND t6.transaction_id = t7.transaction_id " + "AND t4.branch_id = t7.branch_id " + "AND t2.attr_type_id = t5.attr_type_id) order by attr_id";
+
+ /**
+ * @param sql
+ * @param headers
+ * @param colNames
+ * @param logger
+ */
+ public CheckValidAttributeTypes() {
+ super(CHECK_SQL, new String[] {"art_id", "attr_id", "attr_type_id", "gamma_id", "transaction_id", "branch_id"},
+ new String[] {"Art ID", "Attr ID", "Art Type ID", "Gamma ID", "Transaction ID", "Branch ID"}, logger);
+ }
+}
diff --git a/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/CheckValidType.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/CheckValidType.java
new file mode 100644
index 00000000000..01f78b4fb25
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/CheckValidType.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.blam.operation;
+
+import java.sql.ResultSet;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.TimeZone;
+import java.util.logging.Logger;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.jdk.core.util.AHTML;
+import org.eclipse.osee.framework.skynet.core.artifact.Branch;
+import org.eclipse.osee.framework.ui.plugin.util.db.ConnectionHandler;
+import org.eclipse.osee.framework.ui.plugin.util.db.ConnectionHandlerStatement;
+import org.eclipse.osee.framework.ui.skynet.blam.BlamVariableMap;
+import org.eclipse.osee.framework.ui.skynet.blam.operation.BlamOperation;
+import org.eclipse.osee.framework.ui.skynet.widgets.xresults.XResultData;
+import org.eclipse.osee.framework.ui.skynet.widgets.xresults.XResultPage.Manipulations;
+
+/**
+ * @author Jeff C. Phillips
+ */
+public class CheckValidType implements BlamOperation {
+ private static final SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy HH:mm");
+ private final String sql;
+ private final String[] headers;
+ private final String[] colNames;
+ private final Logger logger;
+
+ /**
+ * @param sql
+ */
+ public CheckValidType(final String sql, final String[] colNames, final String[] headers, final Logger logger) {
+ super();
+ this.sql = sql;
+ this.headers = headers;
+ this.colNames = colNames;
+ this.logger = logger;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.ui.skynet.blam.operation.BlamOperation#runOperation(org.eclipse.osee.framework.ui.skynet.blam.BlamVariableMap, org.eclipse.osee.framework.skynet.core.artifact.Branch, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void runOperation(BlamVariableMap variableMap, Branch branch, IProgressMonitor monitor) throws Exception {
+ ConnectionHandlerStatement chStmt = ConnectionHandler.runPreparedQuery(sql);
+ Calendar cal = Calendar.getInstance(TimeZone.getDefault());
+ List<String> datas = new LinkedList<String>();
+ XResultData rd = new XResultData(logger);
+ ResultSet rSet = chStmt.getRset();
+ ;
+ int count = 0;
+
+ while (rSet.next()) {
+
+ for (String colName : colNames) {
+ datas.add(rSet.getString(colName));
+ }
+ count++;
+ }
+ rd.addRaw("Results: " + count + "<br></br>Date: " + dateFormat.format(cal.getTime()) + "<br></br><br></br>" + AHTML.createTable(
+ datas, headers, headers.length, 1, 3));
+ rd.report("The report", Manipulations.RAW_HTML);
+ }
+}
diff --git a/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishPids.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishPids.java
new file mode 100644
index 00000000000..c8932fa142a
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishPids.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * 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.ArrayList;
+import java.util.Set;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactPersistenceManager;
+import org.eclipse.osee.framework.skynet.core.artifact.Branch;
+import org.eclipse.osee.framework.ui.skynet.blam.BlamVariableMap;
+import org.eclipse.osee.framework.ui.skynet.blam.operation.BlamOperation;
+import org.eclipse.osee.framework.ui.skynet.render.IRenderer;
+import org.eclipse.osee.framework.ui.skynet.render.RendererManager;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class PublishPids implements BlamOperation {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.ui.skynet.blam.operation.BlamOperation#runOperation(org.eclipse.osee.framework.ui.skynet.blam.BlamVariableMap, org.eclipse.osee.framework.skynet.core.artifact.Branch)
+ */
+ public void runOperation(BlamVariableMap variableMap, Branch branch, IProgressMonitor monitor) throws Exception {
+ ArtifactPersistenceManager artifactManager = ArtifactPersistenceManager.getInstance();
+ RendererManager rendererManager = RendererManager.getInstance();
+ Artifact root = artifactManager.getDefaultHierarchyRootArtifact(branch);
+ Artifact subsysTopFolder = root.getChild("Subsystem Requirements");
+
+ monitor.subTask("Aquiring Subsystem Requirements"); // bulk load for performance reasons
+ artifactManager.getArtifactsFromSubtypeName("Subsystem Requirement", branch);
+
+ for (Artifact subsystem : subsysTopFolder.getChildren()) {
+ if (monitor.isCanceled()) {
+ return;
+ }
+ Set<Artifact> children = subsystem.getChildren();
+ IRenderer renderer = rendererManager.getRendererById("org.eclipse.osee.framework.ui.skynet.word");
+ renderer.preview(new ArrayList<Artifact>(children), "Publish Pids", monitor);
+ }
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishSoftwareTestPlan.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishSoftwareTestPlan.java
new file mode 100644
index 00000000000..a06e64827cb
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishSoftwareTestPlan.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * 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.sql.SQLException;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.TreeSet;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.jdk.core.type.HashCollection;
+import org.eclipse.osee.framework.jdk.core.util.io.CharBackedInputStream;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.excel.ExcelXmlWriter;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.excel.ISheetWriter;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactPersistenceManager;
+import org.eclipse.osee.framework.skynet.core.artifact.Branch;
+import org.eclipse.osee.framework.skynet.core.attribute.Attribute;
+import org.eclipse.osee.framework.ui.plugin.util.AIFile;
+import org.eclipse.osee.framework.ui.plugin.util.OseeData;
+import org.eclipse.osee.framework.ui.skynet.blam.BlamVariableMap;
+import org.eclipse.osee.framework.ui.skynet.blam.operation.BlamOperation;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class PublishSoftwareTestPlan implements BlamOperation {
+ private HashCollection<String, Artifact> swReqsByPartition;
+ private CharBackedInputStream charBak;
+ private ISheetWriter excelWriter;
+
+ /**
+ *
+ */
+ public PublishSoftwareTestPlan() {
+ swReqsByPartition = new HashCollection<String, Artifact>(false, LinkedList.class);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.ui.skynet.blam.operation.BlamOperation#runOperation(org.eclipse.osee.framework.ui.skynet.blam.BlamVariableMap, org.eclipse.osee.framework.skynet.core.artifact.Branch)
+ */
+ public void runOperation(BlamVariableMap variableMap, Branch branch, IProgressMonitor monitor) throws Exception {
+ init();
+ ArtifactPersistenceManager artifactManager = ArtifactPersistenceManager.getInstance();
+
+ monitor.beginTask("Publish Software Test Plan", IProgressMonitor.UNKNOWN);
+
+ if (monitor.isCanceled()) return;
+
+ monitor.subTask("Aquiring Software Requirements"); // bulk load for performance reasons
+ artifactManager.getArtifactsFromSubtypeName("Software Requirement", branch);
+
+ if (monitor.isCanceled()) return;
+
+ Artifact root = artifactManager.getDefaultHierarchyRootArtifact(branch);
+ Artifact swReqTopFolder = root.getChild("Software Requirements");
+ recurseSwReqs(swReqTopFolder);
+
+ publishTables();
+
+ excelWriter.endWorkbook();
+ IFile iFile = OseeData.getIFile("SDD_Traceability.xml");
+ AIFile.writeToFile(iFile, charBak);
+ }
+
+ /**
+ * @throws IOException
+ */
+ private void publishTables() throws IOException {
+ TreeSet<String> partitions = new TreeSet<String>(swReqsByPartition.keySet());
+ for (String partition : partitions) {
+ excelWriter.writeRow();
+ excelWriter.writeRow();
+ excelWriter.writeRow(partition);
+ excelWriter.writeRow("Requirement Name", "Qualification Method", "Test Level", "Qualification Facility");
+ publishRequirementsTrace(swReqsByPartition.getValues(partition));
+ }
+ }
+
+ private void publishRequirementsTrace(Collection<Artifact> requirements) throws IllegalStateException, IOException {
+ for (Artifact requirement : requirements) {
+ excelWriter.writeRow(requirement.getDescriptiveName(),
+ requirement.getSoleAttributeValue("Qualification Method"));
+ }
+ }
+
+ private void init() throws IOException {
+ swReqsByPartition.clear();
+ charBak = new CharBackedInputStream();
+ excelWriter = new ExcelXmlWriter(charBak.getWriter());
+ excelWriter.startSheet("traceability", 4);
+ }
+
+ private void recurseSwReqs(Artifact artifact) throws SQLException {
+ for (Artifact child : artifact.getChildren()) {
+ if (artifact.getArtifactTypeName().equals("Software Requirement")) {
+ for (Attribute partition : child.getAttributeManager("Partition").getAttributes()) {
+ swReqsByPartition.put(partition.getStringData(), child);
+ }
+ }
+ recurseSwReqs(child);
+ }
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishSrs.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishSrs.java
new file mode 100644
index 00000000000..a0567156a9c
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishSrs.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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.FileInputStream;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.jdk.core.util.io.Streams;
+import org.eclipse.osee.framework.skynet.core.artifact.Branch;
+import org.eclipse.osee.framework.ui.skynet.blam.BlamVariableMap;
+import org.eclipse.osee.framework.ui.skynet.blam.operation.BlamOperation;
+import org.eclipse.osee.framework.ui.skynet.render.FileSystemRenderer;
+import org.eclipse.osee.framework.ui.skynet.render.PresentationType;
+import org.eclipse.osee.framework.ui.skynet.render.word.WordTemplateProcessor;
+
+/**
+ * @author Robert A. Fisher
+ */
+public class PublishSrs implements BlamOperation {
+
+ @SuppressWarnings("unchecked")
+ public void runOperation(BlamVariableMap variableMap, Branch branch, IProgressMonitor monitor) throws Exception {
+
+ // Master Template <XWidget xwidgetType="XText" displayName="masterTemplate" />
+ // Slave Template <XWidget xwidgetType="XText" displayName="slaveTemplate" />
+
+ String masterTemplate = new String(Streams.getByteArray(new FileInputStream(
+ variableMap.getString("masterTemplate"))), "UTF-8");
+ String slaveTemplate = new String(
+ Streams.getByteArray(new FileInputStream(variableMap.getString("slaveTemplate"))), "UTF-8");
+
+ WordTemplateProcessor processor = new WordTemplateProcessor(masterTemplate, slaveTemplate);
+
+ BlamVariableMap blamVariableMap = new BlamVariableMap();
+ blamVariableMap.setValue("MasterFileName", "SRS");
+ blamVariableMap.setValue("Branch", variableMap.getValue("Branch"));
+
+ processor.applyTemplate(FileSystemRenderer.ensureRenderFolderExists(PresentationType.PREVIEW), blamVariableMap);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/ErrorHandler.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/ErrorHandler.java
new file mode 100644
index 00000000000..e12cb033134
--- /dev/null
+++ b/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/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/Resolver.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/Resolver.java
new file mode 100644
index 00000000000..aacf4e76012
--- /dev/null
+++ b/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/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/SqlResolver.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/SqlResolver.java
new file mode 100644
index 00000000000..eae68646af2
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/SqlResolver.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.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) {
+ return this.getClass().getCanonicalName().equals(obj.getClass().getCanonicalName());
+ }
+
+ @Override
+ public int hashCode() {
+ return this.getClass().getCanonicalName().hashCode();
+ }
+
+}
diff --git a/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/StateValue.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/errorhandler/StateValue.java
new file mode 100644
index 00000000000..8cb4546cb80
--- /dev/null
+++ b/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/org.eclipse.osee.define/src/org/eclipse/osee/define/meta/ImportRelationJob.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/meta/ImportRelationJob.java
new file mode 100644
index 00000000000..fd4350f6354
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/meta/ImportRelationJob.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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.meta;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.sql.SQLException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+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.relation.Import.RelationImporter;
+import org.eclipse.osee.framework.plugin.core.config.ConfigUtil;
+import org.eclipse.osee.framework.skynet.core.artifact.Branch;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class ImportRelationJob extends Job {
+ private static Logger logger = ConfigUtil.getConfigFactory().getLogger(ImportRelationJob.class);
+ private final File file;
+ private final Branch branch;
+
+ public ImportRelationJob(File file, Branch branch) throws IllegalArgumentException, CoreException, SQLException {
+ super("Importing Relations");
+ this.file = file;
+ this.branch = branch;
+ }
+
+ public IStatus run(IProgressMonitor monitor) {
+ try {
+ RelationImporter importer = new RelationImporter(branch);
+ importer.extractRelationsFromSheet(new FileInputStream(file), monitor);
+ return Status.OK_STATUS;
+ } catch (Exception ex) {
+ String message = ex.getMessage();
+
+ if (message == null) message = "";
+
+ logger.log(Level.SEVERE, message, ex);
+ return new Status(Status.ERROR, DefinePlugin.PLUGIN_ID, -1, ex.toString(), ex);
+ }
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.osee.define/src/org/eclipse/osee/define/meta/ImportRelationPage.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/meta/ImportRelationPage.java
new file mode 100644
index 00000000000..30bbb70c717
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/meta/ImportRelationPage.java
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * 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.meta;
+
+import java.io.File;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.osee.framework.skynet.core.artifact.BranchPersistenceManager;
+import org.eclipse.osee.framework.ui.plugin.util.AWorkspace;
+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.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.WizardDataTransferPage;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class ImportRelationPage extends WizardDataTransferPage {
+ private static final BranchPersistenceManager branchManager = BranchPersistenceManager.getInstance();
+ private Button btnSingleFile;
+ private Text txtSingleFile;
+ private String currentFileSelection;
+
+ /**
+ * @param name
+ * @param selection
+ */
+ public ImportRelationPage(String name, IStructuredSelection selection) {
+ super(name);
+ setTitle("Import relations into Define");
+ setDescription("Import relations into Define");
+
+ if (selection != null && selection.size() == 1) {
+ Object firstElement = selection.getFirstElement();
+ if (firstElement instanceof IAdaptable) {
+ Object resource = ((IAdaptable) firstElement).getAdapter(IResource.class);
+ if (resource != null) {
+ IResource currentResourceSelection = (IResource) resource;
+ if (currentResourceSelection.getType() == IResource.FILE) {
+ currentFileSelection = currentResourceSelection.getLocation().toString();
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * (non-Javadoc) Method declared on IDialogPage.
+ */
+ 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) {
+ Group composite = new Group(parent, SWT.NONE);
+ composite.setText("Import Source");
+ GridLayout gd = new GridLayout();
+ gd.numColumns = 3;
+ composite.setLayout(gd);
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ txtSingleFile = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ txtSingleFile.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ txtSingleFile.setText((currentFileSelection == null ? "" : currentFileSelection));
+ txtSingleFile.addListener(SWT.Modify, this);
+ btnSingleFile = new Button(composite, SWT.PUSH);
+ btnSingleFile.setText("&Browse...");
+
+ btnSingleFile.addSelectionListener(new SelectionAdapter() {
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ File file = selectFile();
+ if (file != null && file.isFile()) txtSingleFile.setText(file.getPath());
+ }
+ });
+
+ setPageComplete(determinePageCompletion());
+ }
+
+ /*
+ * @see WizardPage#becomesVisible
+ */
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ // policy: wizards are not allowed to come up with an error message
+ if (visible) {
+ setErrorMessage(null);
+ }
+ }
+
+ protected boolean validateSourceGroup() {
+ if (!(new File(txtSingleFile.getText()).isFile())) {
+ setErrorMessage(txtSingleFile.getText() + " is not a file");
+ return false;
+ }
+ return true;
+ }
+
+ public boolean finish() {
+ try {
+ // getSpecifiedContainer().getProject();
+
+ File file = new File(txtSingleFile.getText());
+ // TODO this branch needs to be selected from the wizard not hard coded
+ Job job = new ImportRelationJob(file, branchManager.getDefaultBranch());
+ job.setUser(true);
+ job.setPriority(Job.LONG);
+ job.schedule();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ ErrorDialog.openError(getShell(), "Define Import Error", "An error has occured while importing a document.",
+ new Status(IStatus.ERROR, "org.eclipse.osee.framework.jdk.core", IStatus.ERROR,
+ "Unknown exception occurred in the import", ex));
+ }
+ return true;
+ }
+
+ private File selectFile() {
+ FileDialog dialog = new FileDialog(getShell(), SWT.OPEN | SWT.SINGLE);
+ dialog.setFilterExtensions(new String[] {"*.xml"});
+ dialog.setFilterPath(AWorkspace.getWorkspacePath());
+
+ String path = dialog.open();
+
+ if (path != null) {
+ return new File(path);
+ } else {
+ return null;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.dialogs.WizardResourceImportPage#allowNewContainerName()
+ */
+ @Override
+ protected boolean allowNewContainerName() {
+ return false;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.osee.define/src/org/eclipse/osee/define/meta/ImportRelationWizard.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/meta/ImportRelationWizard.java
new file mode 100644
index 00000000000..3de43c67a94
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/meta/ImportRelationWizard.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.meta;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.osee.define.DefinePlugin;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class ImportRelationWizard extends Wizard implements IImportWizard {
+ private ImportRelationPage mainPage;
+ private IStructuredSelection selection;
+
+ /**
+ *
+ */
+ public ImportRelationWizard() {
+ super();
+ setDialogSettings(DefinePlugin.getInstance().getDialogSettings());
+ setWindowTitle("Skynet Types Import Wizard");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+ return mainPage.finish();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
+ * org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.selection = selection;
+ }
+
+ /**
+ * (non-Javadoc) Method declared on Wizard.
+ */
+ public void addPages() {
+ mainPage = new ImportRelationPage("Import Artifact Types", selection);
+ addPage(mainPage);
+ }
+}
diff --git a/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateView.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateView.java
new file mode 100644
index 00000000000..ceb99f0e2a7
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateView.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * 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.action.Action;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.osee.define.DefinePlugin;
+import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
+import org.eclipse.osee.framework.ui.skynet.ats.IActionable;
+import org.eclipse.osee.framework.ui.skynet.ats.OseeAts;
+import org.eclipse.osee.framework.ui.skynet.widgets.xnavigate.XNavigateComposite;
+import org.eclipse.osee.framework.ui.skynet.widgets.xnavigate.XNavigateItem;
+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() {
+ }
+
+ public void setFocus() {
+ }
+
+ /*
+ * @see IWorkbenchPart#createPartControl(Composite)
+ */
+ public void createPartControl(Composite parent) {
+
+ xNavComp = new XNavigateComposite(new DefineNavigateViewItems(), parent, SWT.NONE);
+ xNavComp.getFilteredTree().getViewer().setSorter(new DefineNavigateViewerSorter());
+
+ DefinePlugin.getInstance().setHelp(xNavComp, HELP_CONTEXT_ID);
+ createActions();
+ xNavComp.refresh();
+ }
+
+ protected void createActions() {
+
+ Action refreshAction = new Action("Refresh") {
+
+ public void run() {
+ xNavComp.refresh();
+ }
+ };
+ refreshAction.setImageDescriptor(SkynetGuiPlugin.getInstance().getImageDescriptor("refresh.gif"));
+ refreshAction.setToolTipText("Refresh");
+
+ OseeAts.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/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateViewItems.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateViewItems.java
new file mode 100644
index 00000000000..bebc4ec84db
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateViewItems.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * 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 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.jdk.core.util.OseeProperties;
+import org.eclipse.osee.framework.ui.skynet.util.OSEELog;
+import org.eclipse.osee.framework.ui.skynet.widgets.xnavigate.XNavigateItem;
+import org.eclipse.osee.framework.ui.skynet.widgets.xnavigate.XNavigateViewItems;
+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;
+ }
+
+ public List<XNavigateItem> getSearchNavigateItems() {
+ List<XNavigateItem> items = new ArrayList<XNavigateItem>();
+
+ XNavigateItem blamItems = new XNavigateItem(null, "Blam Operations");
+ items.add(blamItems);
+
+ if (OseeProperties.getInstance().isDeveloper()) {
+ XNavigateItem adminItems = new XNavigateItem(null, "Admin");
+
+ new XNavigateItem(adminItems, "Health");
+
+ items.add(adminItems);
+ }
+
+ XNavigateItem otherReportItems = new XNavigateItem(null, "Skynet");
+ if (OseeProperties.getInstance().isDeveloper()) {
+ XNavigateItem adminItems = new XNavigateItem(null, "Admin");
+
+ XNavigateItem healthItems = new XNavigateItem(adminItems, "Health");
+ adminItems.addChild(healthItems);
+
+ }
+ items.add(otherReportItems);
+
+ addExtensionPointItems(items);
+
+ return items;
+ }
+
+ @SuppressWarnings("deprecation")
+ public void addExtensionPointItems(List<XNavigateItem> items) {
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(
+ "org.eclipse.osee.define.DefineNavigateItem");
+ if (point == null) OSEELog.logSevere(DefinePlugin.class, "Can't access DefineNavigateItem extension point", true);
+ 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.getSearchNavigateItems());
+ } catch (Exception ex) {
+ OSEELog.logException(DefinePlugin.class, "Error loading DefineNavigateItem extension", ex, true);
+ }
+ }
+ }
+
+ }
+
+}
diff --git a/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateViewerSorter.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateViewerSorter.java
new file mode 100644
index 00000000000..70ad4d49b27
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/DefineNavigateViewerSorter.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.navigate;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.osee.framework.ui.skynet.widgets.xnavigate.XNavigateItem;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class DefineNavigateViewerSorter extends ViewerSorter {
+
+ /**
+ * @param treeViewer
+ */
+ public DefineNavigateViewerSorter() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ @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/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/IDefineNavigateItem.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/navigate/IDefineNavigateItem.java
new file mode 100644
index 00000000000..36818942018
--- /dev/null
+++ b/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.skynet.widgets.xnavigate.XNavigateItem;
+
+/**
+ * @author Donald G. Dunne
+ */
+public interface IDefineNavigateItem {
+
+ public List<XNavigateItem> getSearchNavigateItems();
+
+}
diff --git a/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/Import/ExtractTestRelations.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/Import/ExtractTestRelations.java
new file mode 100644
index 00000000000..39d7ddd87b1
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/Import/ExtractTestRelations.java
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * 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.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+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.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.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactPersistenceManager;
+import org.eclipse.osee.framework.skynet.core.artifact.Branch;
+import org.eclipse.osee.framework.skynet.core.attribute.ConfigurationPersistenceManager;
+import org.eclipse.osee.framework.ui.plugin.util.AWorkspace;
+
+public class ExtractTestRelations {
+ private static final ArtifactPersistenceManager artifactManager = ArtifactPersistenceManager.getInstance();
+ private static final ConfigurationPersistenceManager configurationPersistenceManager = ConfigurationPersistenceManager.getInstance();
+ // private static final BranchPersistenceManager branchManager = BranchPersistenceManager.getInstance();
+
+ 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) throws SQLException {
+ 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 (SQLException 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 SQLException {
+
+ // Make sure that the runtime relation type is available
+ Artifact reqArtifact = artifactManager.getArtifactFromTypeName("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.relate(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());
+ // IRelationLink link = relationManager.getIRelationLinkDescriptor("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 SQLException {
+ Artifact testArtifact = artifactManager.getArtifactFromTypeName("Test Script", testArtifactFile.getName(), branch);
+
+ if (testArtifact == null) {
+ testArtifact = configurationPersistenceManager.getArtifactSubtypeDescriptor("Test Script", branch).makeNewArtifact();
+ testArtifact.setAttribute("Name", testArtifactFile.getName());
+ testArtifact.setAttribute("Content URL", testArtifactFile.getFullPath().toString());
+ testArtifact.persist();
+ }
+ return testArtifact;
+
+ }
+}
diff --git a/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/Import/RelationImporter.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/Import/RelationImporter.java
new file mode 100644
index 00000000000..191956b3ab1
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/Import/RelationImporter.java
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * 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 static org.eclipse.osee.framework.skynet.core.artifact.search.Operator.EQUAL;
+import java.io.IOException;
+import java.io.InputStream;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+import org.eclipse.core.runtime.IProgressMonitor;
+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.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactPersistenceManager;
+import org.eclipse.osee.framework.skynet.core.artifact.Branch;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactTypeSearch;
+import org.eclipse.osee.framework.skynet.core.artifact.search.AttributeValueSearch;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ISearchPrimitive;
+import org.eclipse.osee.framework.skynet.core.relation.RelationSide;
+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 ArtifactPersistenceManager artifactManager = ArtifactPersistenceManager.getInstance();
+ 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));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.define.artifact.Import.RowProcessor#processRow(java.lang.String[])
+ */
+ public void processRow(String[] row) {
+ if (done) return;
+ try {
+ monitor.worked(1);
+ List<ISearchPrimitive> criteria = new LinkedList<ISearchPrimitive>();
+ criteria.add(new ArtifactTypeSearch("System Requirement", EQUAL));
+ criteria.add(new AttributeValueSearch("Imported Paragraph Number", row[1], EQUAL));
+ Collection<Artifact> artifacts = artifactManager.getArtifacts(criteria, true, branch);
+
+ Artifact rowArtifact;
+ try {
+ rowArtifact = getSoleArtifact(artifacts);
+ } catch (IllegalArgumentException ex) {
+ System.out.println(ex.getMessage());
+ return;
+ }
+
+ if (rowArtifact == null) {
+ System.out.println("Skipping " + row[0] + " becuase no matching artifact was found");
+ } else {
+ if (!row[0].equals(rowArtifact.getDescriptiveName())) {
+ System.out.printf("Warning %s != %s%n", row[0], rowArtifact.getDescriptiveName());
+ }
+ monitor.subTask(rowArtifact.getDescriptiveName());
+ for (int i = 0; i < columnArtifacts.length; i++) {
+ String rationale = row[i + leadingColumnCount];
+ if (rationale != null) {
+ if (rationale.equalsIgnoreCase("x")) {
+ rationale = "";
+ }
+ columnArtifacts[i].relate(RelationSide.ALLOCATION__REQUIREMENT, rowArtifact, rationale, true);
+ }
+ }
+ }
+ } catch (SQLException ex) {
+ System.out.println(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;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.define.artifact.Import.RowProcessor#processHeaderRow(java.lang.String[])
+ */
+ public void processHeaderRow(String[] row) {
+ monitor.setTaskName("Aquire Column Artifacts");
+ List<ISearchPrimitive> criteria = new LinkedList<ISearchPrimitive>();
+ columnArtifacts = new Artifact[row.length - leadingColumnCount];
+ for (int i = 0; i < columnArtifacts.length; i++) {
+ monitor.worked(1);
+ try {
+ criteria.add(new ArtifactTypeSearch("Component", EQUAL));
+ criteria.add(new AttributeValueSearch("Name", row[i + leadingColumnCount], EQUAL));
+ Collection<Artifact> artifacts = artifactManager.getArtifacts(criteria, true, branch);
+ criteria.clear();
+
+ columnArtifacts[i] = getSoleArtifact(artifacts);
+ monitor.subTask(columnArtifacts[i].getDescriptiveName());
+ } catch (SQLException ex) {
+ System.out.println(ex);
+ }
+ }
+ System.out.println(Arrays.deepToString(columnArtifacts));
+ monitor.setTaskName("Relate Row Artifacts");
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.define.artifact.Import.RowProcessor#processEmptyRow()
+ */
+ public void processEmptyRow() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.define.artifact.Import.RowProcessor#processCommentRow(java.lang.String[])
+ */
+ public void processCommentRow(String[] row) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.define.artifact.Import.RowProcessor#reachedEndOfWorksheet()
+ */
+ public void reachedEndOfWorksheet() {
+ monitor.done();
+ done = true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.define.artifact.Import.RowProcessor#detectedTotalRowCount(int)
+ */
+ public void detectedRowAndColumnCounts(int rowCount, int columnCount) {
+ monitor.beginTask("Importing Relations", rowCount + columnCount - leadingColumnCount);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.define.artifact.Import.RowProcessor#foundStartOfWorksheet(java.lang.String)
+ */
+ public void foundStartOfWorksheet(String sheetName) {
+ }
+}
diff --git a/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/TreeViewerTest.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/TreeViewerTest.java
new file mode 100644
index 00000000000..00023bf9d34
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/relation/TreeViewerTest.java
@@ -0,0 +1,244 @@
+/*******************************************************************************
+ * 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();
+ }
+}
diff --git a/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityJob.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityJob.java
new file mode 100644
index 00000000000..57b5cc2702a
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityJob.java
@@ -0,0 +1,269 @@
+/*******************************************************************************
+ * 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.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.regex.Matcher;
+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.framework.jdk.core.type.CountingMap;
+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.excel.ExcelXmlWriter;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.excel.ISheetWriter;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactPersistenceManager;
+import org.eclipse.osee.framework.skynet.core.artifact.Branch;
+import org.eclipse.osee.framework.skynet.core.attribute.Attribute;
+import org.eclipse.osee.framework.skynet.core.attribute.WordAttribute;
+import org.eclipse.osee.framework.skynet.core.util.WordUtil;
+import org.eclipse.osee.framework.ui.plugin.util.AIFile;
+import org.eclipse.osee.framework.ui.plugin.util.OseeData;
+import org.eclipse.osee.framework.ui.skynet.util.OSEELog;
+import org.eclipse.swt.program.Program;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class ImportTraceabilityJob extends Job {
+ private static final Pattern ofpReqTraceP = Pattern.compile("\\^SRS\\s*([^;\n\r]+);");
+ private final Matcher ofpReqTraceMatcher;
+ private static final Pattern scriptReqTraceP = Pattern.compile("addTraceability\\s*\\(\\\"(?:SubDD|SRS|CSID)?\\s*([^\\\"]+)\\\"");
+ private final Matcher scriptReqTraceMatcher;
+ private static final Pattern structuredReqNameP = Pattern.compile("\\[?(\\{[^\\}]+\\})(.*)");
+ private static final Pattern filePattern = Pattern.compile(".*\\.(java|ada|ads|adb|c|h)");
+ private static final Pattern embeddedVolumePattern = Pattern.compile("\\{\\d+ (.*)\\}");
+ private static final Pattern invalidTraceMarkPattern = Pattern.compile("(\\[[A-Za-z]|USES_).*");
+ private static final Pattern curlyBracesPattern = Pattern.compile("[{}]");
+
+ private static final ArtifactPersistenceManager artifactManager = ArtifactPersistenceManager.getInstance();
+ private final File file;
+ private final Branch branch;
+ private final ArrayList<String> noTraceabilityFiles;
+ private final HashMap<String, Artifact> softwareReqs;
+ private final HashMap<String, Artifact> indirectReqs;
+ private final CountingMap<Artifact> reqsTraceCounts;
+ private final CharBackedInputStream charBak;
+ private final ISheetWriter excelWriter;
+ private int pathPrefixLength;
+
+ public ImportTraceabilityJob(File file, Branch branch) throws IllegalArgumentException, CoreException, SQLException, IOException {
+ super("Importing Traceability");
+ this.file = file;
+ this.branch = branch;
+ noTraceabilityFiles = new ArrayList<String>(200);
+ softwareReqs = new HashMap<String, Artifact>(3000);
+ indirectReqs = new HashMap<String, Artifact>(700);
+ reqsTraceCounts = new CountingMap<Artifact>();
+ charBak = new CharBackedInputStream();
+ excelWriter = new ExcelXmlWriter(charBak.getWriter());
+ ofpReqTraceMatcher = ofpReqTraceP.matcher("");
+ scriptReqTraceMatcher = scriptReqTraceP.matcher("");
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IStatus run(IProgressMonitor monitor) {
+ try {
+ monitor.beginTask("Importing From " + file.getName(), 100);
+ monitor.worked(1);
+
+ monitor.subTask("Aquiring Software Requirements"); // bulk load for performance reasons
+ for (Artifact artifact : artifactManager.getArtifactsFromSubtypeName("Software Requirement", branch)) {
+ softwareReqs.put(getCanonicalReqName(artifact.getDescriptiveName()), artifact);
+ }
+ monitor.worked(30);
+
+ monitor.subTask("Aquiring Indirect Software Requirements");
+ for (Artifact artifact : artifactManager.getArtifactsFromSubtypeName("Indirect Software Requirement", branch)) {
+ indirectReqs.put(getCanonicalReqName(artifact.getDescriptiveName()), artifact);
+ }
+ monitor.worked(7);
+
+ 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));
+ }
+ } else if (file.isDirectory()) {
+ handleDirectory(file);
+ } else {
+ throw new IllegalStateException("unexpected file system type");
+ }
+
+ excelWriter.endSheet();
+
+ writeNoTraceFilesSheet();
+ writeTraceCountsSheet();
+
+ excelWriter.endWorkbook();
+ IFile iFile = OseeData.getIFile("CodeUnit_To_SRS_Trace.xml");
+ AIFile.writeToFile(iFile, charBak);
+ Program.launch(iFile.getLocation().toOSString());
+
+ monitor.done();
+ return Status.OK_STATUS;
+ } catch (Exception ex) {
+ return new Status(Status.ERROR, DefinePlugin.PLUGIN_ID, -1, ex.getLocalizedMessage(), ex);
+ }
+ }
+
+ private String getCanonicalReqName(String reqReference) {
+ String canonicalReqReference = reqReference.toUpperCase();
+ if (canonicalReqReference.endsWith(".")) {
+ canonicalReqReference = canonicalReqReference.substring(0, canonicalReqReference.length() - 1);
+ }
+
+ Matcher embeddedVolumeMatcher = embeddedVolumePattern.matcher(canonicalReqReference);
+ if (embeddedVolumeMatcher.find()) {
+ canonicalReqReference = embeddedVolumeMatcher.group(1);
+ }
+
+ int lastCurlyBraceIndex = canonicalReqReference.lastIndexOf('}');
+ if (lastCurlyBraceIndex > -1) {
+ canonicalReqReference = canonicalReqReference.substring(0, lastCurlyBraceIndex);
+ }
+
+ canonicalReqReference = curlyBracesPattern.matcher(canonicalReqReference).replaceAll("");
+
+ return canonicalReqReference;
+ }
+
+ private void handleDirectory(File directory) throws IOException, SQLException {
+ if (directory == null || directory.getParentFile() == null) {
+ OSEELog.logWarning(DefinePlugin.class, "The path " + directory + " is invalid.", true);
+ return;
+ }
+
+ pathPrefixLength = directory.getParentFile().getAbsolutePath().length();
+
+ for (File sourceFile : (List<File>) Lib.recursivelyListFiles(directory, filePattern)) {
+ CharBuffer buf = Lib.fileToCharBuffer(sourceFile);
+ Matcher reqTraceMatcher = getReqTraceMatcher(sourceFile);
+ reqTraceMatcher.reset(buf);
+
+ int matchCount = 0;
+ String relativePath = sourceFile.getPath().substring(pathPrefixLength);
+ while (reqTraceMatcher.find()) {
+ handelReqTrace(relativePath, reqTraceMatcher.group(1));
+ matchCount++;
+ }
+ if (matchCount == 0) {
+ noTraceabilityFiles.add(relativePath);
+ }
+ }
+ }
+
+ private Matcher getReqTraceMatcher(File sourceFile) {
+ if (sourceFile.getName().endsWith("java")) {
+ return scriptReqTraceMatcher;
+ }
+ return ofpReqTraceMatcher;
+ }
+
+ 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, SQLException {
+ excelWriter.startSheet("trace counts", 3);
+ excelWriter.writeRow("SRS Requirement from Database", "Trace Count", "Partitions");
+ excelWriter.writeRow("% requirement coverage", null, "=1-COUNTIF($B:$B,\"0\")/COUNTA($B:$B)");
+ StringBuffer partitionStrB = new StringBuffer(100);
+ for (Artifact artifact : softwareReqs.values()) {
+ Collection<Attribute> partitions = artifact.getAttributeManager("Partition").getAttributes();
+
+ for (Attribute attribute : partitions) {
+ partitionStrB.append(attribute.getStringData());
+ partitionStrB.append(',');
+ }
+
+ excelWriter.writeRow(artifact.getDescriptiveName(), String.valueOf(reqsTraceCounts.get(artifact)),
+ partitionStrB.substring(0, partitionStrB.length() - 1));
+ partitionStrB.delete(0, 99999);
+ }
+
+ excelWriter.endSheet();
+ }
+
+ private void handelReqTrace(String path, String traceMark) throws SQLException, IOException {
+ String foundStr;
+ Artifact reqArtifact = null;
+
+ Matcher invalidTraceMarkMatcher = invalidTraceMarkPattern.matcher(traceMark);
+ if (invalidTraceMarkMatcher.matches()) {
+ foundStr = "invalid trace mark";
+ } else {
+ reqArtifact = getRequirementArtifact(traceMark);
+ if (reqArtifact == null) {
+ Matcher structuredReqNameMatcher = structuredReqNameP.matcher(traceMark);
+ if (structuredReqNameMatcher.matches()) {
+ reqArtifact = getRequirementArtifact(structuredReqNameMatcher.group(1));
+
+ 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(WordAttribute.CONTENT_NAME)).toUpperCase();
+ if (textContent.contains(getCanonicalReqName(structuredReqNameMatcher.group(2)))) {
+ foundStr = "req body match";
+ } else {
+ foundStr = "paritial match";
+ }
+ }
+ } else {
+ foundStr = "no match in DB";
+ }
+ } else {
+ foundStr = fullMatch(reqArtifact);
+ }
+ }
+
+ excelWriter.writeRow(foundStr, path, reqArtifact == null ? null : reqArtifact.getDescriptiveName(), traceMark);
+ }
+
+ private Artifact getRequirementArtifact(String traceMark) {
+ String canonicalTraceMark = getCanonicalReqName(traceMark);
+ Artifact reqArtifact = softwareReqs.get(canonicalTraceMark);
+ if (reqArtifact == null) {
+ reqArtifact = indirectReqs.get(canonicalTraceMark);
+ }
+ return reqArtifact;
+ }
+
+ private String fullMatch(Artifact reqArtifact) {
+ reqsTraceCounts.put(reqArtifact);
+ return "full match";
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityPage.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityPage.java
new file mode 100644
index 00000000000..c6291b9729d
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityPage.java
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * 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.sql.SQLException;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.osee.framework.skynet.core.artifact.Branch;
+import org.eclipse.osee.framework.skynet.core.artifact.BranchPersistenceManager;
+import org.eclipse.osee.framework.ui.plugin.util.DirectoryOrFileSelector;
+import org.eclipse.osee.framework.ui.skynet.util.OSEELog;
+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.swt.widgets.List;
+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 List branchList;
+
+ 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);
+ }
+ }
+ }
+
+ /**
+ * (non-Javadoc) Method declared on IDialogPage.
+ */
+ 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_BOTH));
+
+ branchList = new List(composite, SWT.BORDER | SWT.V_SCROLL);
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ gridData.heightHint = 300;
+ branchList.setLayoutData(gridData);
+
+ try {
+ Branch defaultBranch = BranchPersistenceManager.getInstance().getDefaultBranch();
+
+ int defaultBranchIndex = 0;
+ for (Branch branch : BranchPersistenceManager.getInstance().getBranches()) {
+ branchList.add(branch.getBranchName());
+ branchList.setData(branch.getBranchName(), branch);
+ if (branch.equals(defaultBranch)) {
+ branchList.select(defaultBranchIndex);
+ } else {
+ defaultBranchIndex++;
+ }
+ }
+ } catch (SQLException ex) {
+ branchList.add(ex.getLocalizedMessage());
+ OSEELog.logException(getClass(), ex, false);
+ }
+
+ setPageComplete(determinePageCompletion());
+ }
+
+ /*
+ * @see WizardPage#becomesVisible
+ */
+ 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() {
+ String itemName = branchList.getItem(branchList.getSelectionIndex());
+ return (Branch) branchList.getData(itemName);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.dialogs.WizardResourceImportPage#allowNewContainerName()
+ */
+ @Override
+ protected boolean allowNewContainerName() {
+ return false;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityWizard.java b/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityWizard.java
new file mode 100644
index 00000000000..8190f191a66
--- /dev/null
+++ b/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ImportTraceabilityWizard.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * 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.framework.skynet.core.artifact.Branch;
+import org.eclipse.osee.framework.ui.plugin.util.Jobs;
+import org.eclipse.osee.framework.ui.skynet.util.OSEELog;
+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");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+ try {
+ Branch branch = mainPage.getSelectedBranch();
+ File file = mainPage.getImportFile();
+ Jobs.startJob(new ImportTraceabilityJob(file, branch));
+ } catch (Exception ex) {
+ OSEELog.logException(getClass(), "Traceability Import Error", ex, true);
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
+ * org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.selection = selection;
+ }
+
+ /**
+ * (non-Javadoc) Method declared on Wizard.
+ */
+ public void addPages() {
+ mainPage = new ImportTraceabilityPage(selection);
+ addPage(mainPage);
+ }
+}

Back to the top