Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan G. Rader2014-09-05 14:27:25 +0000
committerRoberto E. Escobar2014-10-01 21:04:37 +0000
commitba6cc3c993c59f22ef037271aed3b1dfadd15618 (patch)
tree4e57f12b86a3738c14b2f553a586d169613503aa
parenta30d454be52218576b71bc298890ed89f721dabd (diff)
downloadorg.eclipse.osee-ba6cc3c993c59f22ef037271aed3b1dfadd15618.tar.gz
org.eclipse.osee-ba6cc3c993c59f22ef037271aed3b1dfadd15618.tar.xz
org.eclipse.osee-ba6cc3c993c59f22ef037271aed3b1dfadd15618.zip
feature[ats_ATS98067]: Import Code Data Rights
Change-Id: Ie17c57ed3990df7f46a3dab9ca509991946f2d19 Signed-off-by: rrader <ryan.rader@boeing.com>
-rw-r--r--plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/traceability/DemoTraceParser.java5
-rw-r--r--plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/traceability/DemoTraceParser.java5
-rw-r--r--plugins/org.eclipse.osee.define/plugin.xml6
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/DataRightsImporter.java160
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ITraceParser.java2
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TraceUnit.java5
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ResourceToTraceUnit.java3
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreAttributeTypes.java2
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/support/OseeTypes_Framework.osee10
9 files changed, 196 insertions, 2 deletions
diff --git a/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/traceability/DemoTraceParser.java b/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/traceability/DemoTraceParser.java
index b8c0c00787a..9fd1aa6d8e9 100644
--- a/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/traceability/DemoTraceParser.java
+++ b/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/traceability/DemoTraceParser.java
@@ -44,4 +44,9 @@ public class DemoTraceParser implements ITraceParser {
return false;
}
+ @Override
+ public boolean addIfEmpty() {
+ return false;
+ }
+
}
diff --git a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/traceability/DemoTraceParser.java b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/traceability/DemoTraceParser.java
index 4fdb4b551f9..ff6c8fec328 100644
--- a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/traceability/DemoTraceParser.java
+++ b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/traceability/DemoTraceParser.java
@@ -44,4 +44,9 @@ public class DemoTraceParser implements ITraceParser {
return false;
}
+ @Override
+ public boolean addIfEmpty() {
+ return false;
+ }
+
}
diff --git a/plugins/org.eclipse.osee.define/plugin.xml b/plugins/org.eclipse.osee.define/plugin.xml
index e11299ea1ca..e813aa72f4f 100644
--- a/plugins/org.eclipse.osee.define/plugin.xml
+++ b/plugins/org.eclipse.osee.define/plugin.xml
@@ -282,4 +282,10 @@
className="org.eclipse.osee.define.blam.operation.FixEmbeddedLinksBlam">
</Operation>
</extension>
+ <extension
+ point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
+ <Operation
+ className="org.eclipse.osee.define.blam.operation.DataRightsImporter">
+ </Operation>
+ </extension>
</plugin>
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/DataRightsImporter.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/DataRightsImporter.java
new file mode 100644
index 00000000000..0b7343768cf
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/DataRightsImporter.java
@@ -0,0 +1,160 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.blam.operation;
+
+import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.CodeUnit;
+import static org.eclipse.osee.framework.core.enums.CoreAttributeTypes.DataRightsBasis;
+import static org.eclipse.osee.framework.core.enums.CoreAttributeTypes.DataRightsClassification;
+import static org.eclipse.osee.framework.core.enums.CoreAttributeTypes.SubjectMatterExpert;
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.Arrays;
+import java.util.Collection;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.enums.QueryOption;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+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.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
+import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager;
+import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
+import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * @author Ryan Rader
+ */
+public class DataRightsImporter extends AbstractBlam {
+
+ public Branch branch;
+ public SkynetTransaction transaction;
+
+ @Override
+ public Collection<String> getCategories() {
+ return Arrays.asList("Util");
+ }
+
+ @Override
+ public String getXWidgetsXml() {
+ return "<XWidgets><XWidget xwidgetType=\"XBranchSelectWidget\" horizontalLabel=\"true\" displayName=\"Branch\" /><XWidget xwidgetType=\"XText\" displayName=\"Path to DataRights XML\" /></XWidgets>";
+ }
+
+ @Override
+ public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
+ // Get branch by name from blam
+ branch = variableMap.getBranch("Branch");
+ String xmlPath = variableMap.getString("Path to DataRights XML");
+ if (branch == null) {
+ log(String.format("A branch needs to be defined."));
+ return;
+ }
+
+ if (!Strings.isValid(xmlPath)) {
+ log(String.format("A path needs to be defined."));
+ return;
+ }
+
+ transaction = TransactionManager.createTransaction(branch, "Data Rights Importer");
+
+ File path = new File(xmlPath);
+ XMLReader xmlReader = XMLReaderFactory.createXMLReader();
+ xmlReader.setContentHandler(new ExcelSaxHandler(new DataRightsProcessor(), true));
+ xmlReader.parse(new InputSource(new FileInputStream(path)));
+
+ transaction.execute();
+ }
+
+ @Override
+ public String getName() {
+ return "Data Rights Importer";
+ }
+
+ public class DataRightsProcessor implements RowProcessor {
+
+ private boolean ignore = false;
+ private int smeIndex;
+ private int dataRightsIndex;
+ private int fileNameIndex;
+ private int dataRightsBasisIndex;
+
+ @Override
+ public void processRow(String[] row) throws Exception {
+ if (!ignore) {
+ String SME = row[smeIndex];
+ String dataRightsClassification = row[dataRightsIndex];
+ String fileName = row[fileNameIndex];
+ String dataRightsBasis = row[dataRightsBasisIndex];
+
+ Artifact artifact =
+ ArtifactQuery.getArtifactFromTypeAndName(CodeUnit, fileName, branch, QueryOption.CONTAINS_MATCH_OPTIONS);
+
+ if (artifact == null) {
+ log("artifact [" + fileName + "] does not exist");
+
+ } else {
+ artifact.setSoleAttributeValue(DataRightsClassification, dataRightsClassification);
+ artifact.setSoleAttributeValue(DataRightsBasis, dataRightsBasis);
+ artifact.setSoleAttributeValue(SubjectMatterExpert, SME);
+
+ artifact.persist(transaction);
+ }
+ }
+ }
+
+ @Override
+ public void processHeaderRow(String[] row) {
+ for (int i = 0; i < row.length; i++) {
+ if (row[i] != null) {
+ if (row[i].equals("SME")) {
+ smeIndex = i;
+ } else if (row[i].equals("Classification")) {
+ dataRightsIndex = i;
+ } else if (row[i].equals("Code Unit")) {
+ fileNameIndex = i;
+ } else if (row[i].equals("Basis")) {
+ dataRightsBasisIndex = i;
+ }
+ }
+ }
+ }
+
+ @Override
+ public void reachedEndOfWorksheet() {
+ ignore = true;
+ }
+
+ @Override
+ public void processEmptyRow() {
+ // do nothing
+ }
+
+ @Override
+ public void processCommentRow(String[] row) {
+ // do nothing
+ }
+
+ @Override
+ public void foundStartOfWorksheet(String sheetName) throws Exception {
+ // do nothing
+ }
+
+ @Override
+ public void detectedRowAndColumnCounts(int rowCount, int columnCount) {
+ // do nothing
+ }
+
+ }
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ITraceParser.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ITraceParser.java
index 118d66b35f5..0d52f0ee157 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ITraceParser.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/ITraceParser.java
@@ -19,6 +19,8 @@ import org.eclipse.osee.define.traceability.data.TraceMark;
*/
public interface ITraceParser {
+ public boolean addIfEmpty();
+
public Collection<TraceMark> getTraceMarks(CharBuffer fileBuffer);
public CharBuffer removeTraceMarks(CharBuffer fileBuffer);
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TraceUnit.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TraceUnit.java
index c8963fdf20c..e40c89d344c 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TraceUnit.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/data/TraceUnit.java
@@ -15,6 +15,7 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.jdk.core.util.Conditions;
/**
* @author Roberto E. Escobar
@@ -48,7 +49,9 @@ public class TraceUnit {
}
public void addAllTraceMarks(Collection<TraceMark> traceItems) {
- traceMarks.addAll(traceItems);
+ if (Conditions.hasValues(traceItems)) {
+ traceMarks.addAll(traceItems);
+ }
}
public void addTraceMark(TraceMark traceMark) {
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ResourceToTraceUnit.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ResourceToTraceUnit.java
index fb0801d7ed4..fbd4878023f 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ResourceToTraceUnit.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ResourceToTraceUnit.java
@@ -31,6 +31,7 @@ import org.eclipse.osee.define.utility.UriResourceContentFinder;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.jdk.core.type.HashCollection;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.util.Conditions;
/**
* @author Roberto E. Escobar
@@ -188,7 +189,7 @@ public class ResourceToTraceUnit {
IArtifactType traceUnitType = traceUnitLocator.getTraceUnitType(name, fileBuffer);
if (!traceUnitType.equals(ITraceUnitResourceLocator.UNIT_TYPE_UNKNOWN)) {
Collection<TraceMark> traceMarks = traceParser.getTraceMarks(fileBuffer);
- if (traceMarks != null && !traceMarks.isEmpty()) {
+ if (traceParser.addIfEmpty() || Conditions.hasValues(traceMarks)) {
Map<String, TraceUnit> traceUnits = traceUnitToTraceMarks.get(traceUnitType);
if (traceUnits == null) {
traceUnits = new HashMap<String, TraceUnit>();
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreAttributeTypes.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreAttributeTypes.java
index 38b19675c4f..319d27073e6 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreAttributeTypes.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreAttributeTypes.java
@@ -37,6 +37,8 @@ public final class CoreAttributeTypes {
public static final IAttributeType CrewInterfaceRequirement = TokenFactory.createAttributeType(0x1000000000000082L, "Crew Interface Requirement");
public static final IAttributeType Csci = TokenFactory.createAttributeType(0x10000000000000A0L, "CSCI");
public static final IAttributeType DataRightsClassification = TokenFactory.createAttributeType(0x1000000000000155L, "Data Rights Classification");
+ public static final IAttributeType DataRightsBasis = TokenFactory.createAttributeType(0x100000000000154L, "Data Rights Basis");
+ public static final IAttributeType SubjectMatterExpert = TokenFactory.createAttributeType(0x100000000000153L, "Subject Matter Expert");
public static final IAttributeType DefaultMailServer = TokenFactory.createAttributeType(0x1000000000000057L, "osee.config.Default Mail Server");
public static final IAttributeType DefaultGroup = TokenFactory.createAttributeType(0x100000000000006EL, "Default Group");
public static final IAttributeType Description = TokenFactory.createAttributeType(0x1000000000000072L, "Description");
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/support/OseeTypes_Framework.osee b/plugins/org.eclipse.osee.framework.skynet.core/support/OseeTypes_Framework.osee
index 9b849bd3c92..257d6f66edc 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/support/OseeTypes_Framework.osee
+++ b/plugins/org.eclipse.osee.framework.skynet.core/support/OseeTypes_Framework.osee
@@ -668,6 +668,16 @@ attributeType "Data Rights Basis" extends StringAttribute {
mediaType "text/plain"
}
+attributeType "Subject Matter Expert" extends StringAttribute {
+ uuid 0x100000000000153
+ dataProvider DefaultAttributeDataProvider
+ min 0
+ max 1
+ taggerId DefaultAttributeTaggerProvider
+ description "Name of the Subject Matter Expert"
+ mediaType "text/plain"
+}
+
oseeEnumType "enum.data.rights.classification" {
uuid 0x3000000000000205
entry "Restricted Rights"

Back to the top