Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.osee.ats.client.integration.tests/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/AtsClientService.java12
-rw-r--r--plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/resource/AtsTest_Resource_Suite.java3
-rw-r--r--plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/resource/OrcsWriterEndpointTest.java91
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/DateUtil.java7
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/AttributeTypesImpl.java18
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/META-INF/MANIFEST.MF4
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/OrcsWriterEndpoint.java65
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsCollectorValidatorTest.java248
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsRestWriterSuite.java23
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF13
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/script/js/script_console_app.js (renamed from plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/js/script_console_app.js)0
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/script/script_console.html (renamed from plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/script_console.html)0
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/writer/main.html88
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/writer/orcsWriter.js66
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsCollectorValidator.java174
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsCollectorWriter.java192
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsWriterCollectorGenerator.java253
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsWriterEndpointImpl.java91
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsWriterStreamingOutput.java44
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsWriterWorkbookGenerator.java211
-rw-r--r--plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/OrcsIntegrationTestSuite.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsWriterTest.java26
-rw-r--r--plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/writer/OrcsValidationHelperAdapterTest.java92
-rw-r--r--plugins/org.eclipse.osee.orcs/META-INF/MANIFEST.MF10
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/AttributeTypes.java6
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/IOrcsValidationHelper.java22
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsValidationHelperAdapter.java51
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsWriterExcelReader.java132
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsWriterFactory.java133
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsWriterSheetProcessorForCreate.java203
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsWriterSheetProcessorForSettings.java92
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsWriterUtil.java42
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/config/OrcsWriterInputConfig.java44
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/config/OrcsWriterRelationSide.java40
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/config/OrcsWriterToken.java40
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwArtifact.java71
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwArtifactToken.java25
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwArtifactType.java25
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwAttribute.java59
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwAttributeType.java25
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwBase.java82
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwBranch.java25
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwCollector.java160
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwFactory.java108
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwNamedBase.java31
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwRelation.java54
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwRelationType.java45
52 files changed, 3259 insertions, 8 deletions
diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.client.integration.tests/META-INF/MANIFEST.MF
index fde4e71a2d3..5bc8eb92400 100644
--- a/plugins/org.eclipse.osee.ats.client.integration.tests/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.ats.client.integration.tests/META-INF/MANIFEST.MF
@@ -82,6 +82,7 @@ Import-Package: com.google.common.collect,
org.eclipse.osee.framework.core.exception,
org.eclipse.osee.framework.core.model,
org.eclipse.osee.framework.core.model.cache,
+ org.eclipse.osee.framework.core.model.type,
org.eclipse.osee.framework.core.operation,
org.eclipse.osee.framework.core.util,
org.eclipse.osee.framework.database.init,
@@ -121,6 +122,8 @@ Import-Package: com.google.common.collect,
org.eclipse.osee.framework.ui.swt,
org.eclipse.osee.jaxrs,
org.eclipse.osee.jaxrs.client,
+ org.eclipse.osee.orcs.rest.model,
+ org.eclipse.osee.orcs.writer.model.reader,
org.eclipse.osee.support.test.util,
org.osgi.framework
Service-Component: OSGI-INF/*.xml
diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/AtsClientService.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/AtsClientService.java
index 7c12bed26b3..655001342e9 100644
--- a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/AtsClientService.java
+++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/AtsClientService.java
@@ -15,6 +15,7 @@ import org.eclipse.osee.ats.core.client.IAtsClient;
import org.eclipse.osee.framework.core.client.OseeClientProperties;
import org.eclipse.osee.jaxrs.client.JaxRsClient;
import org.eclipse.osee.jaxrs.client.JaxRsWebTarget;
+import org.eclipse.osee.orcs.rest.model.OrcsWriterEndpoint;
/**
* @author Donald G. Dunne
@@ -24,6 +25,7 @@ public class AtsClientService {
private static IAtsClient atsClient;
private static AgileEndpointApi agile;
private static JaxRsWebTarget target;
+ private static OrcsWriterEndpoint orcsWriter;
public void setAtsClient(IAtsClient atsClient) {
AtsClientService.atsClient = atsClient;
@@ -50,4 +52,14 @@ public class AtsClientService {
return agile;
}
+ public static OrcsWriterEndpoint getOrcsWriter() {
+ if (orcsWriter == null) {
+ String appServer = OseeClientProperties.getOseeApplicationServer();
+ String orcsUri = String.format("%s/orcs", appServer);
+ JaxRsClient jaxRsClient = JaxRsClient.newBuilder().build();
+ orcsWriter = jaxRsClient.target(orcsUri).newProxy(OrcsWriterEndpoint.class);
+ }
+ return orcsWriter;
+ }
+
}
diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/resource/AtsTest_Resource_Suite.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/resource/AtsTest_Resource_Suite.java
index 46a6748843e..dfa513fc180 100644
--- a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/resource/AtsTest_Resource_Suite.java
+++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/resource/AtsTest_Resource_Suite.java
@@ -19,6 +19,7 @@ import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
+ OrcsWriterEndpointTest.class,
ActionResourceTest.class,
ActionUiResourceTest.class,
ConvertResourceTest.class,
@@ -27,7 +28,7 @@ import org.junit.runners.Suite;
WordUpdateEndpointTest.class})
/**
* This test suite contains test that can be run against any production db
- *
+ *
* @author Donald G. Dunne
*/
public class AtsTest_Resource_Suite {
diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/resource/OrcsWriterEndpointTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/resource/OrcsWriterEndpointTest.java
new file mode 100644
index 00000000000..24504d2120b
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/resource/OrcsWriterEndpointTest.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.ats.client.integration.tests.ats.resource;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import javax.ws.rs.core.Response;
+import org.eclipse.osee.ats.client.integration.tests.AtsClientService;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.model.type.ArtifactType;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
+import org.eclipse.osee.orcs.rest.model.OrcsWriterEndpoint;
+import org.eclipse.osee.orcs.writer.model.reader.OwArtifact;
+import org.eclipse.osee.orcs.writer.model.reader.OwCollector;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test unit for {@link OrcsWriterEndpoint}
+ *
+ * @author Donald G. Dunne
+ */
+public class OrcsWriterEndpointTest extends AbstractRestTest {
+ private OrcsWriterEndpoint writer;
+
+ @Before
+ public void setup() {
+ writer = AtsClientService.getOrcsWriter();
+ }
+
+ @Test
+ public void testGetOrcsWriterInputDefaultJson() throws Exception {
+ OwCollector collector = getDefaultOwCollector();
+ assertEquals(3, collector.getCreate().size());
+ }
+
+ private OwCollector getDefaultOwCollector() throws Exception {
+ Response response = writer.getOrcsWriterInputDefaultJson();
+ assertEquals(javax.ws.rs.core.Response.Status.OK.getStatusCode(), response.getStatus());
+ OwCollector collector = response.readEntity(OwCollector.class);
+ return collector;
+ }
+
+ @Test
+ public void testGetOrcsWriterInputDefault() throws Exception {
+ Response response = writer.getOrcsWriterInputDefault();
+ assertEquals(javax.ws.rs.core.Response.Status.OK.getStatusCode(), response.getStatus());
+ String excelXml = response.readEntity(String.class);
+ assertTrue(excelXml.contains("Orcs Writer Import Folder"));
+ }
+
+ @Test
+ public void testValidate() throws Exception {
+ OwCollector collector = getDefaultOwCollector();
+ Response response = writer.getOrcsWriterValidate(collector);
+ assertEquals(javax.ws.rs.core.Response.Status.OK.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testPersist() throws Exception {
+ OwCollector collector = getDefaultOwCollector();
+ Response response = writer.getOrcsWriterPersist(collector);
+ assertEquals(javax.ws.rs.core.Response.Status.OK.getStatusCode(), response.getStatus());
+
+ for (OwArtifact art : collector.getCreate()) {
+ long artTypeUuid = art.getType().getUuid();
+ ArtifactType typeByGuid = ArtifactTypeManager.getTypeByGuid(artTypeUuid);
+ assertNotNull(typeByGuid);
+ if (typeByGuid.equals(CoreArtifactTypes.Folder)) {
+ long artUuid = art.getUuid();
+ Artifact folderArt = AtsClientService.get().getArtifact(artUuid);
+ assertNotNull(folderArt);
+ assertEquals(2, folderArt.getChildren().size());
+ for (Artifact child : folderArt.getChildren()) {
+ assertTrue(child.getName().equals("Software Requirement 1") || child.getName().equals(
+ "Software Requirement 2"));
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/DateUtil.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/DateUtil.java
index 85454fcacc7..75805fc79e9 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/DateUtil.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/DateUtil.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.framework.jdk.core.util;
import java.text.DateFormat;
+import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
@@ -42,6 +43,12 @@ public class DateUtil {
return getWorkingDaysBetween(getCalendar(fromDate), getCalendar(toDate));
}
+ public static Date getDate(String format, String value) throws ParseException {
+ SimpleDateFormat formatter = new SimpleDateFormat(format);
+ Date date = formatter.parse(value);
+ return date;
+ }
+
public static int getWorkingDaysBetween(Calendar fromDate, Calendar toDate) {
int workingDays = 0;
while (!fromDate.after(toDate)) {
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/AttributeTypesImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/AttributeTypesImpl.java
index 99f5a20bf38..d8fe979be3e 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/AttributeTypesImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/AttributeTypesImpl.java
@@ -201,4 +201,22 @@ public class AttributeTypesImpl implements AttributeTypes {
String baseType = getBaseAttributeTypeId(attrType);
return baseType != null && baseType.toLowerCase().contains("boolean");
}
+
+ @Override
+ public boolean isIntegerType(IAttributeType attrType) {
+ String baseType = getBaseAttributeTypeId(attrType);
+ return baseType != null && baseType.toLowerCase().contains("integer");
+ }
+
+ @Override
+ public boolean isDateType(IAttributeType attrType) {
+ String baseType = getBaseAttributeTypeId(attrType);
+ return baseType != null && baseType.toLowerCase().contains("date");
+ }
+
+ @Override
+ public boolean isFloatingType(IAttributeType attrType) {
+ String baseType = getBaseAttributeTypeId(attrType);
+ return baseType != null && baseType.toLowerCase().contains("floatingpoint");
+ }
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java
index c2dc67d69f5..0822dc42aa9 100644
--- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java
@@ -19,6 +19,7 @@ import org.eclipse.osee.orcs.rest.model.BranchEndpoint;
import org.eclipse.osee.orcs.rest.model.DatastoreEndpoint;
import org.eclipse.osee.orcs.rest.model.IdeClientEndpoint;
import org.eclipse.osee.orcs.rest.model.IndexerEndpoint;
+import org.eclipse.osee.orcs.rest.model.OrcsWriterEndpoint;
import org.eclipse.osee.orcs.rest.model.ResourcesEndpoint;
import org.eclipse.osee.orcs.rest.model.TransactionEndpoint;
import org.eclipse.osee.orcs.rest.model.TypesEndpoint;
@@ -49,4 +50,6 @@ public interface OseeClient {
WordUpdateEndpoint getWordUpdateEndpoint();
+ OrcsWriterEndpoint getOrcsWriterEndpoint();
+
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java
index 592a773dca9..7cf577aafa3 100644
--- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java
@@ -39,6 +39,7 @@ import org.eclipse.osee.orcs.rest.model.BranchEndpoint;
import org.eclipse.osee.orcs.rest.model.DatastoreEndpoint;
import org.eclipse.osee.orcs.rest.model.IdeClientEndpoint;
import org.eclipse.osee.orcs.rest.model.IndexerEndpoint;
+import org.eclipse.osee.orcs.rest.model.OrcsWriterEndpoint;
import org.eclipse.osee.orcs.rest.model.ResourcesEndpoint;
import org.eclipse.osee.orcs.rest.model.TransactionEndpoint;
import org.eclipse.osee.orcs.rest.model.TypesEndpoint;
@@ -194,4 +195,9 @@ public class OseeClientImpl implements OseeClient, QueryExecutor {
return client.targetProxy(defineUri, WordUpdateEndpoint.class);
}
+ @Override
+ public OrcsWriterEndpoint getOrcsWriterEndpoint() {
+ return client.targetProxy(baseUri, OrcsWriterEndpoint.class);
+ }
+
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.rest.model/META-INF/MANIFEST.MF
index 74ae19e69b3..5cd0a62f8c1 100644
--- a/plugins/org.eclipse.osee.orcs.rest.model/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.rest.model/META-INF/MANIFEST.MF
@@ -17,4 +17,6 @@ Import-Package: javax.annotation.security;version="1.2.0",
org.eclipse.osee.framework.core.model.change,
org.eclipse.osee.framework.core.util,
org.eclipse.osee.framework.jdk.core.type,
- org.eclipse.osee.framework.jdk.core.util
+ org.eclipse.osee.framework.jdk.core.util,
+ org.eclipse.osee.orcs.writer.model.config,
+ org.eclipse.osee.orcs.writer.model.reader
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/OrcsWriterEndpoint.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/OrcsWriterEndpoint.java
new file mode 100644
index 00000000000..d0f90433da7
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/OrcsWriterEndpoint.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.rest.model;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.eclipse.osee.orcs.writer.model.config.OrcsWriterInputConfig;
+import org.eclipse.osee.orcs.writer.model.reader.OwCollector;
+
+/**
+ * @author Donald G. dunne
+ */
+public interface OrcsWriterEndpoint {
+
+ /**
+ * Return Orcs Writer import excel sheet with all available types in reference sheets
+ */
+ @GET
+ @Path("writer/sheet")
+ @Produces({MediaType.APPLICATION_XML})
+ Response getOrcsWriterInputDefault();
+
+ @GET
+ @Path("writer/sheet")
+ @Produces({MediaType.APPLICATION_JSON})
+ Response getOrcsWriterInputDefaultJson() throws Exception;
+
+ /**
+ * Return OrcsWriter import sheet with only specified types shown in reference tabs.<br/>
+ * <br/>
+ * { "includeArtifactTypes": [ 24, 11 ], "includeAttributeTypes": [ 1152921504606847088, 1152921504606847111 ],
+ * "includeRelationTypes": [ { "relationTypeUuid": 2305843009213694292, "sideA": false } ], "includeTokens": [ {
+ * "name": "Root Artifact", "uuid": 60807 } ] }
+ */
+ @POST
+ @Path("writer/sheet")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ Response getOrcsWriterInputFromConfig(OrcsWriterInputConfig config);
+
+ @POST
+ @Path("writer/validate")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ Response getOrcsWriterValidate(OwCollector collector);
+
+ @POST
+ @Path("writer")
+ @Consumes({MediaType.APPLICATION_JSON})
+ Response getOrcsWriterPersist(OwCollector collector);
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.rest.test/META-INF/MANIFEST.MF
index f384478a279..1b183a62eb2 100644
--- a/plugins/org.eclipse.osee.orcs.rest.test/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.rest.test/META-INF/MANIFEST.MF
@@ -12,4 +12,5 @@ Require-Bundle: org.junit,
org.objenesis
Import-Package: org.eclipse.osee.executor.admin,
org.eclipse.osee.framework.jdk.core.type,
- org.eclipse.osee.orcs.db.mock
+ org.eclipse.osee.orcs.db.mock,
+ org.eclipse.osee.orcs.writer
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsCollectorValidatorTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsCollectorValidatorTest.java
new file mode 100644
index 00000000000..93c46c2973c
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsCollectorValidatorTest.java
@@ -0,0 +1,248 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.rest.internal.writer;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+import java.util.Arrays;
+import org.eclipse.osee.framework.core.util.XResultData;
+import org.eclipse.osee.orcs.writer.IOrcsValidationHelper;
+import org.eclipse.osee.orcs.writer.model.reader.OwArtifact;
+import org.eclipse.osee.orcs.writer.model.reader.OwArtifactToken;
+import org.eclipse.osee.orcs.writer.model.reader.OwArtifactType;
+import org.eclipse.osee.orcs.writer.model.reader.OwAttribute;
+import org.eclipse.osee.orcs.writer.model.reader.OwAttributeType;
+import org.eclipse.osee.orcs.writer.model.reader.OwBranch;
+import org.eclipse.osee.orcs.writer.model.reader.OwCollector;
+import org.eclipse.osee.orcs.writer.model.reader.OwRelation;
+import org.eclipse.osee.orcs.writer.model.reader.OwRelationType;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test Case for {@link OrcsCollectorValidator}
+ *
+ * @author Donald G. Dunne
+ */
+public class OrcsCollectorValidatorTest {
+
+ // @formatter:off
+ @Mock private IOrcsValidationHelper helper;
+ @Mock private OwCollector collector;
+ @Mock private OwBranch branch;
+ // @formatter:on
+ private OrcsCollectorValidator validator;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+
+ when(collector.getAsUserId()).thenReturn("3443");
+ when(branch.getUuid()).thenReturn(570L);
+ when(branch.toString()).thenReturn("OwBranch [uuid=570]");
+ when(collector.getBranch()).thenReturn(branch);
+ when(collector.getPersistComment()).thenReturn("persist comment");
+
+ validator = createValidator(collector);
+ }
+
+ @Test
+ public void test_validateArtifactType() {
+ XResultData rd = validator.run();
+
+ OwArtifact artifact = new OwArtifact();
+ OwArtifactType artType = new OwArtifactType();
+ artType.setUuid(11);
+ artType.setName("Folder");
+ artifact.setType(artType);
+
+ when(collector.getCreate()).thenReturn(Arrays.asList(artifact));
+ when(helper.isArtifactTypeExist(11)).thenReturn(false);
+ rd = validator.run();
+ assertTrue(rd.toString().contains("Artifact Type [OwArtifactType [uuid=11, data=null]] does not exist."));
+
+ when(helper.isArtifactTypeExist(11)).thenReturn(true);
+ rd = validator.run();
+ assertFalse(rd.toString().contains("Artifact Type [OwArtifactType [uuid=11, data=null]] does not exist."));
+
+ artType.setUuid(0L);
+ rd = validator.run();
+ assertTrue(rd.toString().contains("Invalid Artifact Type uuid [OwArtifactType [uuid=0, data=null]]."));
+ }
+
+ @Test
+ public void test_validateArtifactDoesNotExist() {
+
+ when(helper.isBranchExists(570)).thenReturn(true);
+ XResultData rd = validator.run();
+ assertFalse(rd.toString().contains("Branch [OwBranch [uuid=570]] not valid."));
+
+ OwArtifact artifact = new OwArtifact();
+ OwArtifactType artType = new OwArtifactType();
+ artType.setUuid(11);
+ artType.setName("Folder");
+ artifact.setType(artType);
+ artifact.setUuid(5555L);
+
+ when(helper.isArtifactExists(570, 5555L)).thenReturn(false);
+ when(collector.getCreate()).thenReturn(Arrays.asList(artifact));
+ rd = validator.run();
+ assertTrue(rd.toString().contains("Artifact Type [OwArtifactType [uuid=11, data=null]] does not exist."));
+
+ when(branch.getUuid()).thenReturn(0L);
+ rd = validator.run();
+ assertTrue(rd.toString().contains(
+ "Invalid Branch; can't validate artifact uuid for [OwArtifact [type=OwArtifactType [uuid=11, data=null], uuid=5555, data=null]]."));
+
+ }
+
+ @Test
+ public void test_validateCreateAttributes() {
+
+ when(helper.isBranchExists(570)).thenReturn(true);
+ XResultData rd = validator.run();
+ assertFalse(rd.toString().contains("Branch [OwBranch [uuid=570]] not valid."));
+
+ OwArtifact artifact = new OwArtifact();
+ OwArtifactType artType = new OwArtifactType();
+ artType.setUuid(11);
+ artType.setName("Folder");
+ artifact.setType(artType);
+ artifact.setUuid(5555L);
+
+ when(collector.getCreate()).thenReturn(Arrays.asList(artifact));
+
+ rd = validator.run();
+ assertTrue(rd.toString().contains(
+ "Artifact [OwArtifact [type=OwArtifactType [uuid=11, data=null], uuid=5555, data=null]] does not have Name attribute."));
+
+ artifact.setName("my name");
+ OwAttribute attribute = new OwAttribute();
+ artifact.getAttributes().add(attribute);
+ rd = validator.run();
+ assertTrue(rd.toString().contains(
+ "Invalid Attribute Type uuid [null] for artifact [OwArtifact [type=OwArtifactType [uuid=11, data=null], uuid=5555, data=null]]."));
+
+ OwAttributeType attrType = new OwAttributeType();
+ attrType.setName("Static Id");
+ attrType.setUuid(234);
+ attribute.setType(attrType);
+
+ when(helper.isAttributeTypeExists(234)).thenReturn(false);
+ rd = validator.run();
+ assertTrue(rd.toString().contains(
+ "Error: Attribute Type [OwAttributeType [uuid=234, data=null]] does not exist for artifact [OwArtifact [type=OwArtifactType [uuid=11, data=null], uuid=5555, data=null]]."));
+
+ when(helper.isAttributeTypeExists(234)).thenReturn(true);
+ rd = validator.run();
+ assertFalse(rd.toString().contains(
+ "Error: Attribute Type [OwAttributeType [uuid=234, data=null]] does not exist for artifact [OwArtifact [type=OwArtifactType [uuid=11, data=null], uuid=5555, data=null]]."));
+ }
+
+ @Test
+ public void test_validateCreateRelations() {
+
+ when(helper.isBranchExists(570)).thenReturn(true);
+ XResultData rd = validator.run();
+ assertFalse(rd.toString().contains("Branch [OwBranch [uuid=570]] not valid."));
+
+ OwArtifact artifact = new OwArtifact();
+ OwArtifactType artType = new OwArtifactType();
+ artType.setUuid(11);
+ artType.setName("Folder");
+ artifact.setType(artType);
+ artifact.setUuid(5555L);
+
+ when(collector.getCreate()).thenReturn(Arrays.asList(artifact));
+
+ OwRelation relation = new OwRelation();
+ artifact.getRelations().add(relation);
+ rd = validator.run();
+ assertTrue(rd.toString().contains(
+ "Invalid Relation Type [null] for artifact [OwArtifact [type=OwArtifactType [uuid=11, data=null], uuid=5555, data=null]]."));
+
+ OwRelationType relType = new OwRelationType();
+ relType.setUuid(65656);
+ relation.setType(relType);
+ when(helper.isRelationTypeExist(65656)).thenReturn(true);
+ rd = validator.run();
+ assertTrue(rd.toString().contains(
+ "Invalid artifact token [null] for artifact [OwArtifact [type=OwArtifactType [uuid=11, data=null], uuid=5555, data=null]] and relation [OwRelation [type=OwRelationType [sideA=false, sideName=null, uuid=65656, data=null], artToken=null, data=null]]."));
+
+ OwArtifactToken token = new OwArtifactToken();
+ token.setUuid(9999);
+ token.setName("Default Hierarchy - Child");
+ relation.setArtToken(token);
+ rd = validator.run();
+ assertTrue(rd.toString().contains(
+ "Artifact from token [OwArtifactToken [uuid=9999, data=null]] does not exist to relate to artifact [OwArtifact [type=OwArtifactType [uuid=11, data=null], uuid=5555, data=null]] for relation [OwRelation [type=OwRelationType [sideA=false, sideName=null, uuid=65656, data=null], artToken=OwArtifactToken [uuid=9999, data=null], data=null]]."));
+
+ when(helper.isArtifactExists(collector.getBranch().getUuid(), 9999)).thenReturn(true);
+ rd = validator.run();
+ assertFalse(rd.toString().contains(
+ "Artifact from token [OwArtifactToken [uuid=9999, data=null]] does not exist to relate to artifact [OwArtifact [type=OwArtifactType [uuid=11, data=null], uuid=5555, data=null]] for relation [OwRelation [type=OwRelationType [sideA=false, sideName=null, uuid=65656, data=null], artToken=OwArtifactToken [uuid=9999, data=null], data=null]]."));
+ }
+
+ @Test
+ public void test_createEmpty() {
+ assertTrue(collector.getCreate().isEmpty());
+
+ XResultData rd = validator.run();
+ assertTrue(rd.toString().contains("No create, update or delete entries."));
+
+ when(collector.getCreate()).thenReturn(Arrays.asList(new OwArtifact()));
+ rd = validator.run();
+ assertFalse(rd.toString().contains("No create, update or delete entries."));
+ }
+
+ @Test
+ public void test_branch() {
+ when(helper.isBranchExists(570)).thenReturn(false);
+ XResultData rd = validator.run();
+ assertTrue(rd.toString().contains("Branch [OwBranch [uuid=570]] not valid."));
+
+ when(helper.isBranchExists(570)).thenReturn(true);
+ rd = validator.run();
+ assertFalse(rd.toString().contains("Branch [OwBranch [uuid=570]] not valid."));
+ }
+
+ @Test
+ public void test_asUserId() {
+
+ when(helper.isUserExists("3443")).thenReturn(false);
+ XResultData rd = validator.run();
+ assertTrue(rd.toString().contains("Invalid asUserId [3443]"));
+
+ when(helper.isUserExists("3443")).thenReturn(true);
+ rd = validator.run();
+ assertFalse(rd.toString().contains("Invalid asUserId [3443]"));
+ }
+
+ @Test
+ public void test_persistComment() {
+
+ when(collector.getPersistComment()).thenReturn(null);
+ XResultData rd = validator.run();
+ assertTrue(rd.toString().contains("Invalid persistComment [null]"));
+
+ when(collector.getPersistComment()).thenReturn("persist comment");
+ rd = validator.run();
+ assertFalse(rd.toString().contains("Invalid persistComment"));
+ }
+
+ private OrcsCollectorValidator createValidator(OwCollector collector) {
+ return new OrcsCollectorValidator(collector, helper);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsRestWriterSuite.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsRestWriterSuite.java
new file mode 100644
index 00000000000..695067eabfa
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsRestWriterSuite.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.rest.internal.writer;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * @author John R. Misinco
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({OrcsCollectorValidatorTest.class})
+public class OrcsRestWriterSuite {
+ // Test Suite
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF
index 4c071274b6b..7c94c825d2e 100644
--- a/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF
@@ -19,11 +19,14 @@ Import-Package: com.google.common.base;version="15.0.0",
org.eclipse.osee.executor.admin,
org.eclipse.osee.framework.core.data,
org.eclipse.osee.framework.core.enums,
+ org.eclipse.osee.framework.core.exception,
org.eclipse.osee.framework.core.model,
org.eclipse.osee.framework.core.model.cache,
org.eclipse.osee.framework.core.model.change,
+ org.eclipse.osee.framework.core.util,
org.eclipse.osee.framework.jdk.core.type,
org.eclipse.osee.framework.jdk.core.util,
+ org.eclipse.osee.framework.jdk.core.util.io.xml,
org.eclipse.osee.framework.resource.management,
org.eclipse.osee.jaxrs,
org.eclipse.osee.jaxrs.mvc,
@@ -32,6 +35,10 @@ Import-Package: com.google.common.base;version="15.0.0",
org.eclipse.osee.orcs.rest.model,
org.eclipse.osee.orcs.rest.model.search.artifact,
org.eclipse.osee.orcs.search,
- org.eclipse.osee.orcs.transaction
-Osee-JaxRs-Resource: OSEE-INF/web/*;path=/orcs/script/ui
- OSEE-INF/web/example/*;path=/orcs/example/ui
+ org.eclipse.osee.orcs.transaction,
+ org.eclipse.osee.orcs.writer,
+ org.eclipse.osee.orcs.writer.model.config,
+ org.eclipse.osee.orcs.writer.model.reader
+Osee-JaxRs-Resource: OSEE-INF/web/*;path=/orcs/script/ui,
+ OSEE-INF/web/example/*;path=/orcs/example/ui,
+ OSEE-INF/web/writer/*;path=/orcs/writer/ui
diff --git a/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/js/script_console_app.js b/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/script/js/script_console_app.js
index d3d64539c4b..d3d64539c4b 100644
--- a/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/js/script_console_app.js
+++ b/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/script/js/script_console_app.js
diff --git a/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/script_console.html b/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/script/script_console.html
index a685bbb9eea..a685bbb9eea 100644
--- a/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/script_console.html
+++ b/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/script/script_console.html
diff --git a/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/writer/main.html b/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/writer/main.html
new file mode 100644
index 00000000000..a83f602ffc8
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/writer/main.html
@@ -0,0 +1,88 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset="UTF-8"></meta>
+<meta http-equiv="X-UA-Compatible" content="IE=edge"></meta>
+<meta name="viewport" content="width=device-width, initial-scale=1"></meta>
+
+<link rel="stylesheet" type="text/css"
+ href="/ajax/libs/bootstrap/3.3.2/css/bootstrap.min.css"></link>
+
+<title>OSEE - ORCS Writer</title>
+
+<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
+<!--[if lt IE 9]>
+ <script src="/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"></script>
+ <script src="/ajax/libs/respond/1.4.2/respond.min.js"></script>
+ <![endif]-->
+</head>
+<body ng-app="OrcsWriterApp" ng-controller="FormController">
+
+ <nav class="navbar navbar-default" role="navigation">
+ <div class="container-fluid">
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle" data-toggle="collapse"
+ data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span> <span
+ class="icon-bar"></span> <span class="icon-bar"></span> <span
+ class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="../ui/main.html">OSEE - ORCS
+ Writer</a>
+ </div>
+ <div class="collapse navbar-collapse" ng-controller="FormController">
+ <ul class="nav navbar-nav navbar-right">
+ <li ng-class="home"><a href="../ui/main.html">Home</a></li>
+ </ul>
+ </div>
+ </div>
+ </nav>
+
+ <div class="container">
+ <p>
+ <b> ORCS Writer provides Create, Update and Delete capabilities
+ through JSON or an Excel spreadsheet.<br />
+ <ul>
+ <li>Download an <a href="../sheet">Example Excel Workbook</a>
+ OR <a href="../sheet.json">Example JSON</a> to get started.
+ </li>
+ <li>Make modifications to the input. CREATE, MODIFY and DELETE
+ tabs/structures are the only items that will be read. Token and
+ Type tabs/structures are for reference only and should be used in
+ the CREATE, MODIFY and DELETE tabs/structures.</li>
+ <li>Select branch to apply changes to.</li>
+ <li>Enter JSON below or select the Excel option and provide
+ the filename.</li>
+ <li>Click Validate to confirm that input is valid.</li>
+ <li>Click Execute to make changes and persist to OSEE.</li>
+ </ul>
+ </b>
+ </p>
+ </div>
+
+ <div class="container">
+ <label>Input: </label><br /><br />
+ <div class="form-group">
+ <label><input type="file" ng-model-instant id="fileToUpload"
+ single onchange="angular.element(this).scope().setFiles(this)" /> </label>
+ <br /> <br /> <label><b>OR paste JSON</b></label><br />
+ <textarea class="form-control" rows="6" placeholder="json"
+ ng-model="formData.json"
+ title="Paste ORCS JSon in text area. Click button to execute."></textarea>
+ </div>
+ </div>
+
+ <div class="container">
+ <div class="form-group">
+ <button type="button" class="btn btn-primary" ng-click="validate()">Validate</button>
+ <button type="submit" class="btn btn-primary" ng-click="execute()">Execute</button>
+ </div>
+
+ <div class="container-fluid well" ng-show="message">
+ <textarea rows="30" class="form-control">{{ message }}</textarea>
+ </div>
+
+ <script src="/ajax/libs/angularjs/1.2.28/angular.min.js"></script>
+ <script src="orcsWriter.js"></script>
+</body>
+</html> \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/writer/orcsWriter.js b/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/writer/orcsWriter.js
new file mode 100644
index 00000000000..ccb453ca351
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/writer/orcsWriter.js
@@ -0,0 +1,66 @@
+var app = angular.module('OrcsWriterApp', []);
+
+app.controller("FormController", function($scope, $http) {
+
+ $scope.formData = {
+ filename : '',
+ json : ''
+ };
+ $scope.message = '';
+
+ $scope.validate = function() {
+ $scope.run(true);
+ }
+
+ $scope.execute = function() {
+ $scope.run(false);
+ }
+
+ $scope.setFiles = function(element) {
+ $scope.$apply(function() {
+ console.log('files:', element.files);
+ $scope.formData.filename = "";
+ $scope.formData.asJson = false;
+ if (element.files[0]) {
+ $scope.formData.filename = element.files[0];
+ }
+ });
+ };
+
+ $scope.run = function(validate) {
+ $scope.message = '';
+ var url = "";
+ if (validate) {
+ url = "../../writer/validate";
+ } else {
+ url = "../../writer";
+ }
+ var data = {};
+ if (!$scope.formData.json && !$scope.formData.filename) {
+ $scope.message = "ERROR: Must select Excel or enter JSON";
+ } else if ($scope.formData.json) {
+ $scope.message = "Processing JSON";
+ data = $scope.formData.json;
+ $http({
+ method : 'POST',
+ url : url,
+ data : data,
+ headers : {
+ 'Accept' : 'application/json',
+ 'Content-Type' : 'application/json'
+ }
+ }).success(function(data, status, headers, config) {
+ $scope.message += "\nValidation Passed";
+ }).error(function(data, status, headers, config) {
+ var message = 'error - status: ' + status + ' ' + data;
+ if (data.exception) {
+ message += ' Exception: ' + data.exception;
+ }
+ $scope.message += '\n' + message;
+ });
+ } else if ($scope.formData.filename) {
+ $scope.message = "Processing Excel - NOT IMPLEMENTED YET";
+ $scope.message += '\nExcel Output Generated';
+ }
+ }
+});
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java
index 382b6a337fc..f8192a70545 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java
@@ -18,10 +18,11 @@ import javax.ws.rs.core.Application;
import org.eclipse.osee.activity.api.ActivityLog;
import org.eclipse.osee.framework.resource.management.IResourceManager;
import org.eclipse.osee.orcs.OrcsApi;
+import org.eclipse.osee.orcs.rest.internal.writer.OrcsWriterEndpointImpl;
/**
* Get application.wadl at this context to get rest documentation
- *
+ *
* @author Roberto E. Escobar
*/
@ApplicationPath("orcs")
@@ -58,6 +59,7 @@ public class OrcsApplication extends Application {
resources.add(new IdeClientEndpointImpl());
resources.add(new BranchEndpointImpl(orcsApi, resourceManager));
+ resources.add(new OrcsWriterEndpointImpl(orcsApi));
resources.add(new TransactionEndpointImpl(orcsApi));
resources.add(new TypesEndpointImpl(orcsApi));
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsCollectorValidator.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsCollectorValidator.java
new file mode 100644
index 00000000000..8430170e350
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsCollectorValidator.java
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.rest.internal.writer;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.eclipse.osee.framework.core.util.XResultData;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.orcs.OrcsApi;
+import org.eclipse.osee.orcs.writer.IOrcsValidationHelper;
+import org.eclipse.osee.orcs.writer.OrcsValidationHelperAdapter;
+import org.eclipse.osee.orcs.writer.model.reader.OwArtifact;
+import org.eclipse.osee.orcs.writer.model.reader.OwArtifactToken;
+import org.eclipse.osee.orcs.writer.model.reader.OwArtifactType;
+import org.eclipse.osee.orcs.writer.model.reader.OwAttribute;
+import org.eclipse.osee.orcs.writer.model.reader.OwAttributeType;
+import org.eclipse.osee.orcs.writer.model.reader.OwCollector;
+import org.eclipse.osee.orcs.writer.model.reader.OwRelation;
+import org.eclipse.osee.orcs.writer.model.reader.OwRelationType;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class OrcsCollectorValidator {
+
+ private final OwCollector collector;
+ private Map<Long, OwArtifact> uuidToArtifact;
+ private final Set<Long> artifactsExist;
+ private final IOrcsValidationHelper helper;
+ private boolean branchValid;
+
+ public OrcsCollectorValidator(OwCollector collector, IOrcsValidationHelper helper) {
+ this.collector = collector;
+ this.helper = helper;
+ uuidToArtifact = new HashMap<>();
+ artifactsExist = new HashSet<>();
+ }
+
+ public OrcsCollectorValidator(OrcsApi orcsApi, OwCollector collector2) {
+ this(collector2, new OrcsValidationHelperAdapter(orcsApi));
+ }
+
+ public XResultData run() {
+ XResultData results = new XResultData(false);
+ branchValid = validateBranch(results);
+ if (!helper.isUserExists(collector.getAsUserId())) {
+ results.logErrorWithFormat("Invalid asUserId [%s].\n", collector.getAsUserId());
+ }
+ if (!Strings.isValid(collector.getPersistComment())) {
+ results.logErrorWithFormat("Invalid persistComment [%s].\n", collector.getPersistComment());
+ }
+ boolean createEntries = collector.getCreate() != null && !collector.getCreate().isEmpty();
+ boolean updateEntries = collector.getUpdate() != null && !collector.getUpdate().isEmpty();
+ boolean deleteEntries = collector.getDelete() != null && !collector.getDelete().isEmpty();
+ if (!createEntries && !updateEntries && !deleteEntries) {
+ results.logError("No create, update or delete entries.\n");
+ }
+ validateCreate(results);
+ return results;
+ }
+
+ private void validateCreate(XResultData results) {
+ for (OwArtifact artifact : collector.getCreate()) {
+ validateArtifactType(results, artifact);
+ validateArtifactDoesNotExist(results, artifact);
+ validateCreateAttributes(artifact, results);
+ validateCreateRelations(artifact, results);
+ }
+ }
+
+ private void validateArtifactType(XResultData results, OwArtifact artifact) {
+ OwArtifactType artType = artifact.getType();
+ if (artType == null || artType.getUuid() <= 0L) {
+ results.logErrorWithFormat("Invalid Artifact Type uuid [%s].\n", artType);
+ } else {
+ if (!helper.isArtifactTypeExist(artType.getUuid())) {
+ results.logErrorWithFormat("Artifact Type [%s] does not exist.\n", artType);
+ }
+ }
+ }
+
+ private void validateArtifactDoesNotExist(XResultData results, OwArtifact artifact) {
+ long artifactUuid = artifact.getUuid();
+ if (!branchValid) {
+ results.logErrorWithFormat("Invalid Branch; can't validate artifact uuid for [%s].\n", artifact);
+ } else if (artifactUuid > 0L) {
+ if (helper.isArtifactExists(collector.getBranch().getUuid(), artifactUuid)) {
+ results.logErrorWithFormat("Artifact with uuid already exists [%s].\n", artifact);
+ }
+ if (uuidToArtifact == null) {
+ uuidToArtifact = new HashMap<>();
+ }
+ uuidToArtifact.put(artifactUuid, artifact);
+ }
+ }
+
+ private void validateCreateRelations(OwArtifact artifact, XResultData results) {
+ for (OwRelation relation : artifact.getRelations()) {
+ if (!branchValid) {
+ results.logErrorWithFormat(
+ "Invalid Branch; can't validate artifact uuid for artifact [%s] and relation [%s].\n", artifact,
+ relation);
+ } else {
+ OwRelationType relType = relation.getType();
+ try {
+ if (relType == null || relType.getUuid() <= 0L || !helper.isRelationTypeExist(relType.getUuid())) {
+ results.logErrorWithFormat("Invalid Relation Type [%s] for artifact [%s].\n", relType, artifact);
+ } else {
+ OwArtifactToken artToken = relation.getArtToken();
+ long branchUuid = collector.getBranch().getUuid();
+ if (artToken == null) {
+ results.logErrorWithFormat("Invalid artifact token [%s] for artifact [%s] and relation [%s].\n",
+ artToken, artifact, relation);
+ }
+ // for performance, check to see if this artifact token was validated
+ else if (!artifactsExist.contains(artToken.getUuid())) {
+ // check to see if token is one of the artifacts to create
+ if (!uuidToArtifact.containsKey(artToken.getUuid())) {
+ // else, check to see if token exists in db
+ if (!helper.isArtifactExists(branchUuid, artToken.getUuid())) {
+ results.logErrorWithFormat(
+ "Artifact from token [%s] does not exist to relate to artifact [%s] for relation [%s].\n",
+ artToken, artifact, relation);
+ } else {
+ artifactsExist.add(artToken.getUuid());
+ }
+ }
+ }
+ }
+ } catch (Exception ex) {
+ results.logErrorWithFormat("Exception [%s] processing relation [%s] for relType [%s].\n",
+ ex.getLocalizedMessage(), relation, relType);
+ }
+ }
+ }
+ }
+
+ private void validateCreateAttributes(OwArtifact artifact, XResultData results) {
+ String name = artifact.getName();
+ if (!Strings.isValid(name)) {
+ results.logErrorWithFormat("Artifact [%s] does not have Name attribute.\n", artifact);
+ }
+ for (OwAttribute attribute : artifact.getAttributes()) {
+ OwAttributeType attrType = attribute.getType();
+ if (attrType == null || attrType.getUuid() <= 0L) {
+ results.logErrorWithFormat("Invalid Attribute Type uuid [%s] for artifact [%s].\n", attrType, artifact);
+ } else {
+ if (!helper.isAttributeTypeExists(attrType.getUuid())) {
+ results.logErrorWithFormat("Attribute Type [%s] does not exist for artifact [%s].\n", attrType, artifact);
+ }
+ }
+ }
+ }
+
+ private boolean validateBranch(XResultData results) {
+ boolean valid = true;
+ if (collector.getBranch() == null || collector.getBranch().getUuid() <= 0L || !helper.isBranchExists(collector.getBranch().getUuid())) {
+ results.logErrorWithFormat("Branch [%s] not valid.\n", collector.getBranch());
+ valid = false;
+ }
+ return valid;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsCollectorWriter.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsCollectorWriter.java
new file mode 100644
index 00000000000..8945012cc3b
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsCollectorWriter.java
@@ -0,0 +1,192 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.rest.internal.writer;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.data.IRelationType;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.util.XResultData;
+import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.util.DateUtil;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.orcs.OrcsApi;
+import org.eclipse.osee.orcs.data.ArtifactReadable;
+import org.eclipse.osee.orcs.transaction.TransactionBuilder;
+import org.eclipse.osee.orcs.writer.model.reader.OwArtifact;
+import org.eclipse.osee.orcs.writer.model.reader.OwArtifactToken;
+import org.eclipse.osee.orcs.writer.model.reader.OwArtifactType;
+import org.eclipse.osee.orcs.writer.model.reader.OwAttribute;
+import org.eclipse.osee.orcs.writer.model.reader.OwAttributeType;
+import org.eclipse.osee.orcs.writer.model.reader.OwCollector;
+import org.eclipse.osee.orcs.writer.model.reader.OwRelation;
+import org.eclipse.osee.orcs.writer.model.reader.OwRelationType;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class OrcsCollectorWriter {
+
+ private final OwCollector collector;
+ private final OrcsApi orcsApi;
+ private Map<Long, ArtifactId> uuidToArtifact;
+ private TransactionBuilder transaction;
+ private IOseeBranch branch;
+ private ArtifactReadable user;
+
+ public OrcsCollectorWriter(OrcsApi orcsApi, OwCollector collector) {
+ this.orcsApi = orcsApi;
+ this.collector = collector;
+ uuidToArtifact = new HashMap<>();
+ }
+
+ public XResultData run() {
+ XResultData results = new XResultData(false);
+ processCreate(results);
+ return results;
+ }
+
+ private void processCreate(XResultData results) {
+ for (OwArtifact owArtifact : collector.getCreate()) {
+ OwArtifactType owArtType = owArtifact.getType();
+ IArtifactType artType = orcsApi.getOrcsTypes().getArtifactTypes().getByUuid(owArtType.getUuid());
+
+ long artifactUuid = owArtifact.getUuid();
+ if (artifactUuid > 0L) {
+ if (uuidToArtifact == null) {
+ uuidToArtifact = new HashMap<>();
+ }
+ } else {
+ artifactUuid = Lib.generateArtifactIdAsInt();
+ }
+ String name = owArtifact.getName();
+ ArtifactId artifact = getTransaction().createArtifact(artType, name, GUID.create(), artifactUuid);
+
+ uuidToArtifact.put(artifactUuid, artifact);
+
+ createAttributes(owArtifact, artifact, results);
+
+ createRelations(owArtifact, artifact, results);
+ }
+ getTransaction().commit();
+ }
+
+ private void createRelations(OwArtifact owArtifact, ArtifactId artifact, XResultData results) {
+ for (OwRelation relation : owArtifact.getRelations()) {
+ OwRelationType owRelType = relation.getType();
+ IRelationType relType = orcsApi.getOrcsTypes().getRelationTypes().getByUuid(owRelType.getUuid());
+
+ OwArtifactToken artToken = relation.getArtToken();
+ long branchUuid = collector.getBranch().getUuid();
+ ArtifactReadable otherArtifact = null;
+
+ if (uuidToArtifact.containsKey(artToken.getUuid())) {
+ otherArtifact = (ArtifactReadable) uuidToArtifact.get(artToken.getUuid());
+ } else {
+ otherArtifact =
+ orcsApi.getQueryFactory().fromBranch(branchUuid).andUuid(artToken.getUuid()).getResults().getExactlyOne();
+ }
+ if (relation.getType().isSideA()) {
+ getTransaction().relate(otherArtifact, relType, artifact);
+ } else {
+ getTransaction().relate(artifact, relType, otherArtifact);
+ }
+ }
+ }
+
+ private void createAttributes(OwArtifact owArtifact, ArtifactId artifact, XResultData results) {
+ for (OwAttribute owAttribute : owArtifact.getAttributes()) {
+ if (!CoreAttributeTypes.Name.getGuid().equals(owAttribute.getType().getUuid())) {
+ OwAttributeType owAttrType = owAttribute.getType();
+ IAttributeType attrType = orcsApi.getOrcsTypes().getAttributeTypes().getByUuid(owAttrType.getUuid());
+ List<Object> values = owAttribute.getValues();
+ for (Object value : values) {
+ if (orcsApi.getOrcsTypes().getAttributeTypes().isFloatingType(attrType)) {
+ getTransaction().setSoleAttributeValue(artifact, attrType, Double.valueOf((String) value));
+ } else if (orcsApi.getOrcsTypes().getAttributeTypes().isIntegerType(attrType)) {
+ getTransaction().setSoleAttributeValue(artifact, attrType, Integer.valueOf((String) value));
+ } else if (orcsApi.getOrcsTypes().getAttributeTypes().isBooleanType(attrType)) {
+ boolean set = ((String) value).toLowerCase().equals("true");
+ getTransaction().setSoleAttributeValue(artifact, attrType, set);
+ } else if (orcsApi.getOrcsTypes().getAttributeTypes().isDateType(attrType)) {
+ Date date = null;
+ if (Strings.isNumeric((String) value)) {
+ date = new Date(Long.valueOf((String) value));
+ } else {
+ try {
+ date = DateUtil.getDate(DateUtil.MMDDYY, (String) value);
+ } catch (Exception ex) {
+ // do nothing
+ }
+ try {
+ date = DateUtil.getDate("MM/dd/yy", (String) value);
+ } catch (Exception ex) {
+ // do nothing
+ }
+ try {
+ Calendar calendar = javax.xml.bind.DatatypeConverter.parseDateTime((String) value);
+ date = calendar.getTime();
+ } catch (Exception ex) {
+ // do nothing
+ }
+ }
+ if (date != null) {
+ getTransaction().setSoleAttributeValue(artifact, attrType, date);
+ } else {
+ throw new OseeArgumentException("Unexpected date format [%s]", value);
+ }
+ } else if (orcsApi.getOrcsTypes().getAttributeTypes().getMaxOccurrences(attrType) == 1) {
+ getTransaction().setSoleAttributeValue(artifact, attrType, value);
+ } else {
+ getTransaction().createAttribute(artifact, attrType, value);
+ }
+ }
+ }
+ }
+ }
+
+ private IOseeBranch getBranch() {
+ if (branch == null) {
+ branch =
+ orcsApi.getQueryFactory().branchQuery().andUuids(collector.getBranch().getUuid()).getResults().getAtMostOneOrNull();
+ }
+ return branch;
+ }
+
+ public TransactionBuilder getTransaction() throws OseeCoreException {
+ if (transaction == null) {
+ transaction =
+ orcsApi.getTransactionFactory().createTransaction(getBranch(), getUser(), collector.getPersistComment());
+ }
+ return transaction;
+ }
+
+ private ArtifactReadable getUser() {
+ if (user == null) {
+ user =
+ orcsApi.getQueryFactory().fromBranch(CoreBranches.COMMON).and(CoreAttributeTypes.UserId,
+ collector.getAsUserId()).getResults().getExactlyOne();
+ }
+ return user;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsWriterCollectorGenerator.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsWriterCollectorGenerator.java
new file mode 100644
index 00000000000..5cfd300f274
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsWriterCollectorGenerator.java
@@ -0,0 +1,253 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.rest.internal.writer;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.data.IRelationType;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTokens;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.enums.SystemUser;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.orcs.OrcsApi;
+import org.eclipse.osee.orcs.writer.model.config.OrcsWriterInputConfig;
+import org.eclipse.osee.orcs.writer.model.config.OrcsWriterRelationSide;
+import org.eclipse.osee.orcs.writer.model.config.OrcsWriterToken;
+import org.eclipse.osee.orcs.writer.model.reader.OwArtifact;
+import org.eclipse.osee.orcs.writer.model.reader.OwArtifactToken;
+import org.eclipse.osee.orcs.writer.model.reader.OwArtifactType;
+import org.eclipse.osee.orcs.writer.model.reader.OwAttributeType;
+import org.eclipse.osee.orcs.writer.model.reader.OwBranch;
+import org.eclipse.osee.orcs.writer.model.reader.OwCollector;
+import org.eclipse.osee.orcs.writer.model.reader.OwFactory;
+import org.eclipse.osee.orcs.writer.model.reader.OwRelation;
+import org.eclipse.osee.orcs.writer.model.reader.OwRelationType;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class OrcsWriterCollectorGenerator {
+ private OrcsApi orcsApi;
+ private final OrcsWriterInputConfig config;
+ private OwCollector collector;
+
+ public OrcsWriterCollectorGenerator() {
+ this(null);
+ }
+
+ public OrcsWriterCollectorGenerator(OrcsWriterInputConfig config) {
+ this.config = config;
+ }
+
+ private void init(OrcsApi orcsApi) {
+ this.orcsApi = orcsApi;
+ this.collector = new OwCollector();
+ }
+
+ public OwCollector run(OrcsApi providedOrcs) {
+ init(providedOrcs);
+ collector.setPersistComment("Put Comment Here");
+ collector.setAsUserId(SystemUser.OseeSystem.getUserId());
+ collector.getBranch().setName(CoreBranches.COMMON.getName());
+ collector.getBranch().setUuid(CoreBranches.COMMON.getUuid());
+ collector.getBranch().setData(
+ String.format("[%s]-[%s]", CoreBranches.COMMON.getName(), CoreBranches.COMMON.getUuid()));
+ createInstructions();
+ createCreateSheet();
+ createUpdateSheet();
+ createDeleteSheet();
+ createBranchSheet();
+ createArtifactTokenSheet();
+ createArtifactTypeSheet();
+ createAttributeTypeSheet();
+ createRelationTypeSheet();
+ return collector;
+ }
+
+ private void createInstructions() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("ORCS Writer provides Create, Update and Delete capabilities through JSON or an Excel spreadsheet\n");
+ sb.append(" - Download an Example Excel Workbook (<server>/orcs/writer/sheet) or ");
+ sb.append("Example JSON (<server>/orcs/writer/sheet.json)\n");
+ sb.append(" - Make modifications to the input. CREATE, MODIFY, DELETE, BRANCH tabs/structures are the only items\n");
+ sb.append(" that will be read. Token and Type tabs/structures are for reference only and should be used\n");
+ sb.append(" in the CREATE, MODIFY and DELETE tabs/structures.\n");
+ sb.append(" - NOTE: MODIFY and DELETE tabs are not yet implemented\n");
+ sb.append(" - On BRANCH tab, delete all but the single branch to apply changes to.\n");
+ sb.append(" - Use <server>/orcs/writer/ui/main.html to validate sheet/json and then apply changes to branch.");
+ collector.setInstructions(sb.toString());
+ }
+
+ private void createCreateSheet() {
+ OwArtifactToken folder = createFolder();
+ createSoftwareRequirement(folder, "1");
+ createSoftwareRequirement(folder, "2");
+ }
+
+ private void createSoftwareRequirement(OwArtifactToken folderToken, String number) {
+ Long reqUuid = Lib.generateArtifactIdAsInt();
+ String name = "Software Requirement " + number;
+ OwArtifact softwareReq = OwFactory.createArtifact(CoreArtifactTypes.SoftwareRequirement, name, reqUuid);
+ OwFactory.createAttribute(softwareReq, CoreAttributeTypes.StaticId, "static id field " + number);
+ collector.getCreate().add(softwareReq);
+
+ // add to new folder
+ OwRelation relation = new OwRelation();
+ relation.setType(OwFactory.createRelationType(orcsApi, CoreRelationTypes.Default_Hierarchical__Parent));
+ relation.setArtToken(folderToken);
+ softwareReq.getRelations().add(relation);
+ }
+
+ private OwArtifactToken createFolder() {
+ Long folderUuid = Lib.generateArtifactIdAsInt();
+ String folderName = "Orcs Writer Import Folder";
+ OwArtifact folder = OwFactory.createArtifact(CoreArtifactTypes.Folder, folderName, folderUuid);
+ collector.getCreate().add(folder);
+
+ // add to default hierarchy root
+ OwRelation relation = new OwRelation();
+ relation.setType(OwFactory.createRelationType(orcsApi, CoreRelationTypes.Default_Hierarchical__Parent));
+ relation.setArtToken(OwFactory.createArtifactToken(CoreArtifactTokens.DefaultHierarchyRoot));
+ folder.getRelations().add(relation);
+
+ return OwFactory.createArtifactToken(folderName, folderUuid);
+ }
+
+ private void createUpdateSheet() {
+ collector.getUpdate();
+ }
+
+ private void createDeleteSheet() {
+ collector.getDelete();
+ }
+
+ private void createArtifactTokenSheet() {
+ if (config == null) {
+ OwArtifactToken owToken = OwFactory.createArtifactToken(CoreArtifactTokens.DefaultHierarchyRoot);
+ collector.getArtTokens().add(owToken);
+ } else {
+ for (OrcsWriterToken token : config.getIncludeTokens()) {
+ OwArtifactToken owToken = OwFactory.createArtifactToken(token.getName(), token.getUuid());
+ collector.getArtTokens().add(owToken);
+ }
+ }
+ }
+
+ private void createArtifactTypeSheet() {
+ Map<String, IArtifactType> types = new HashMap<String, IArtifactType>(100);
+ if (config == null) {
+ for (IArtifactType type : orcsApi.getOrcsTypes().getArtifactTypes().getAll()) {
+ types.put(type.getName(), type);
+ }
+ } else {
+ for (Long typeUuid : config.getIncludeArtifactTypes()) {
+ IArtifactType type = orcsApi.getOrcsTypes().getArtifactTypes().getByUuid(typeUuid);
+ if (type != null) {
+ types.put(type.getName(), type);
+ }
+ }
+ }
+ List<String> typeNames = new ArrayList<String>();
+ typeNames.addAll(types.keySet());
+ Collections.sort(typeNames);
+ for (String typeName : typeNames) {
+ IArtifactType type = types.get(typeName);
+ OwArtifactType owType = OwFactory.createArtifactType(type);
+ collector.getArtTypes().add(owType);
+ }
+ }
+
+ private void createBranchSheet() {
+ Map<String, IOseeBranch> branches = new HashMap<String, IOseeBranch>(500);
+ for (IOseeBranch branch : orcsApi.getQueryFactory().branchQuery().getResults()) {
+ branches.put(branch.getName(), branch);
+ }
+
+ List<String> branchNames = new ArrayList<String>();
+ branchNames.addAll(branches.keySet());
+ Collections.sort(branchNames);
+ for (String branchName : branchNames) {
+ IOseeBranch type = branches.get(branchName);
+ OwBranch owBranch = OwFactory.createBranchToken(type);
+ collector.getBranches().add(owBranch);
+ }
+ }
+
+ private void createAttributeTypeSheet() {
+ Map<String, IAttributeType> types = new HashMap<String, IAttributeType>(100);
+ if (config == null) {
+ for (IAttributeType type : orcsApi.getOrcsTypes().getAttributeTypes().getAll()) {
+ types.put(type.getName(), type);
+ }
+ } else {
+ for (Long typeUuid : config.getIncludeAttributeTypes()) {
+ IAttributeType type = orcsApi.getOrcsTypes().getAttributeTypes().getByUuid(typeUuid);
+ if (type != null) {
+ types.put(type.getName(), type);
+ }
+ }
+
+ }
+
+ List<String> typeNames = new ArrayList<String>();
+ typeNames.addAll(types.keySet());
+ Collections.sort(typeNames);
+ for (String typeName : typeNames) {
+ IAttributeType type = types.get(typeName);
+ OwAttributeType owType = OwFactory.createAttributeType(type);
+ collector.getAttrTypes().add(owType);
+ }
+ }
+
+ private void createRelationTypeSheet() {
+ Map<String, IRelationType> types = new HashMap<String, IRelationType>(100);
+ if (config == null) {
+ for (IRelationType type : orcsApi.getOrcsTypes().getRelationTypes().getAll()) {
+ types.put(type.getName(), type);
+ }
+ } else {
+ for (OrcsWriterRelationSide token : config.getIncludeRelationTypes()) {
+ Long relationTypeUuid = token.getRelationTypeUuid();
+ IRelationType type = orcsApi.getOrcsTypes().getRelationTypes().getByUuid(relationTypeUuid);
+ if (type != null) {
+ types.put(type.getName(), type);
+ }
+ }
+
+ }
+ List<String> typeNames = new ArrayList<String>();
+ typeNames.addAll(types.keySet());
+ Collections.sort(typeNames);
+ for (String typeName : typeNames) {
+ IRelationType type = types.get(typeName);
+ writeRelationType(type);
+ }
+ }
+
+ private void writeRelationType(IRelationType type) {
+ String sideAName = orcsApi.getOrcsTypes().getRelationTypes().getSideAName(type);
+ OwRelationType owType = OwFactory.createRelationType(type, sideAName, true);
+ collector.getRelTypes().add(owType);
+ String sideBName = orcsApi.getOrcsTypes().getRelationTypes().getSideBName(type);
+ owType = OwFactory.createRelationType(type, sideBName, false);
+ collector.getRelTypes().add(owType);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsWriterEndpointImpl.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsWriterEndpointImpl.java
new file mode 100644
index 00000000000..49c0d51a3c5
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsWriterEndpointImpl.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.rest.internal.writer;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import javax.ws.rs.core.StreamingOutput;
+import org.eclipse.osee.framework.core.exception.OseeWrappedException;
+import org.eclipse.osee.framework.core.util.XResultData;
+import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
+import org.eclipse.osee.orcs.OrcsApi;
+import org.eclipse.osee.orcs.rest.model.OrcsWriterEndpoint;
+import org.eclipse.osee.orcs.writer.model.config.OrcsWriterInputConfig;
+import org.eclipse.osee.orcs.writer.model.reader.OwCollector;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class OrcsWriterEndpointImpl implements OrcsWriterEndpoint {
+
+ private final OrcsApi orcsApi;
+
+ public OrcsWriterEndpointImpl(OrcsApi orcsApi) {
+ this.orcsApi = orcsApi;
+ }
+
+ @Override
+ public Response getOrcsWriterInputDefault() {
+ OrcsWriterCollectorGenerator generator = new OrcsWriterCollectorGenerator();
+ OwCollector collector = generator.run(orcsApi);
+ StreamingOutput streamingOutput = new OrcsWriterStreamingOutput(orcsApi, 0L, collector);
+ ResponseBuilder builder = Response.ok(streamingOutput);
+ builder.header("Content-Disposition", "attachment; filename=" + "OrcsWriterInput.xml");
+ return builder.build();
+ }
+
+ @Override
+ public Response getOrcsWriterInputDefaultJson() throws Exception {
+ OrcsWriterCollectorGenerator generator = new OrcsWriterCollectorGenerator();
+ OwCollector collector = generator.run(orcsApi);
+ return Response.ok(collector).build();
+ }
+
+ @Override
+ public Response getOrcsWriterInputFromConfig(OrcsWriterInputConfig config) {
+ OrcsWriterCollectorGenerator generator = new OrcsWriterCollectorGenerator(config);
+ OwCollector collector = generator.run(orcsApi);
+ StreamingOutput streamingOutput = new OrcsWriterStreamingOutput(orcsApi, 0L, collector);
+ ResponseBuilder builder = Response.ok(streamingOutput);
+ builder.header("Content-Disposition", "attachment; filename=" + "OrcsWriterInput.xml");
+ return builder.build();
+ }
+
+ @Override
+ public Response getOrcsWriterValidate(OwCollector collector) {
+ try {
+ OrcsCollectorValidator validator = new OrcsCollectorValidator(orcsApi, collector);
+ XResultData results = validator.run();
+ if (results.isErrors()) {
+ return Response.serverError().entity(results.toString()).build();
+ }
+ return Response.ok(results.toString()).build();
+ } catch (Exception ex) {
+ throw new OseeWrappedException(ex);
+ }
+ }
+
+ @Override
+ public Response getOrcsWriterPersist(OwCollector collector) {
+ OrcsCollectorValidator validator = new OrcsCollectorValidator(orcsApi, collector);
+ XResultData results = validator.run();
+ if (results.isErrors()) {
+ throw new OseeArgumentException(results.toString());
+ }
+ OrcsCollectorWriter writer = new OrcsCollectorWriter(orcsApi, collector);
+ writer.run();
+ if (results.isErrors()) {
+ return Response.notModified().entity(results.toString()).build();
+ }
+ return Response.ok().build();
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsWriterStreamingOutput.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsWriterStreamingOutput.java
new file mode 100644
index 00000000000..e38bf40e1a1
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsWriterStreamingOutput.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.rest.internal.writer;
+
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import javax.ws.rs.core.StreamingOutput;
+import org.eclipse.osee.orcs.OrcsApi;
+import org.eclipse.osee.orcs.writer.model.reader.OwCollector;
+
+/**
+ * @author Donald G. Dunne
+ */
+public final class OrcsWriterStreamingOutput implements StreamingOutput {
+ private final OrcsApi orcsApi;
+ private final long branchUuid;
+ private final OwCollector collector;
+
+ public OrcsWriterStreamingOutput(OrcsApi orcsApi, long branchUuid, OwCollector collector) {
+ this.orcsApi = orcsApi;
+ this.branchUuid = branchUuid;
+ this.collector = collector;
+ }
+
+ @Override
+ public void write(OutputStream output) {
+ try {
+ Writer writer = new OutputStreamWriter(output);
+ OrcsWriterWorkbookGenerator generator = new OrcsWriterWorkbookGenerator(collector, orcsApi);
+ generator.runOperation(orcsApi, branchUuid, writer);
+ } catch (Exception ex) {
+ // do nothing
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsWriterWorkbookGenerator.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsWriterWorkbookGenerator.java
new file mode 100644
index 00000000000..e8ea7e93655
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsWriterWorkbookGenerator.java
@@ -0,0 +1,211 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.rest.internal.writer;
+
+import java.io.IOException;
+import java.io.Writer;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTokens;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.enums.SystemUser;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.ExcelXmlWriter;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.ISheetWriter;
+import org.eclipse.osee.orcs.OrcsApi;
+import org.eclipse.osee.orcs.writer.OrcsWriterUtil;
+import org.eclipse.osee.orcs.writer.model.reader.OwArtifactToken;
+import org.eclipse.osee.orcs.writer.model.reader.OwArtifactType;
+import org.eclipse.osee.orcs.writer.model.reader.OwAttributeType;
+import org.eclipse.osee.orcs.writer.model.reader.OwBranch;
+import org.eclipse.osee.orcs.writer.model.reader.OwCollector;
+import org.eclipse.osee.orcs.writer.model.reader.OwFactory;
+import org.eclipse.osee.orcs.writer.model.reader.OwRelationType;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class OrcsWriterWorkbookGenerator {
+
+ // @formatter:off
+ private final String[] instructionHeadings = {"Instructions and Settings", " "};
+ private final String[] updateSheetHeadings = {"Artifact Token", "Attr/Rel", "Attr/Rel"};
+ private final String[] deleteSheetHeadings = {"Artifact Token - List Artifact Tokens for artifacts to delete"};
+ private final String[] branchSheetHeadings = {"Branch Token - Copy one to Settings Sheet"};
+ private final String[] artifactTokenSheetHeadings = {"Artifact Token - Copy for relations columns"};
+ private final String[] artifactTypeSheetHeadings = {"Artifact Type - Copy for Artifact Type Columns"};
+ private final String[] attributeTypeSheetHeadings = {"Attribute Type - Copy for Attribute Columns"};
+ private final String[] relationTypeSheetHeadings = {"Relation Type - Copy for Relation Columns"};
+ private final OwCollector collector;
+ private final OrcsApi orcsApi;
+ // @formatter:on
+
+ public OrcsWriterWorkbookGenerator(OwCollector collector, OrcsApi orcsApi) {
+ this.collector = collector;
+ this.orcsApi = orcsApi;
+ }
+
+ public void runOperation(OrcsApi providedOrcs, long branchUuid, Writer providedWriter) throws IOException {
+ ISheetWriter writer = new ExcelXmlWriter(providedWriter);
+ createInstructionSheet(writer);
+ createCreateSheet(writer);
+ createUpdateSheet(writer);
+ createDeleteSheet(writer);
+ createBranchSheet(writer);
+ createArtifactTokenSheet(writer);
+ createArtifactTypeSheet(writer);
+ createAttributeTypeSheet(writer);
+ createRelationTypeSheet(writer);
+ writer.endWorkbook();
+ }
+
+ private void createInstructionSheet(ISheetWriter writer) throws IOException {
+ writer.startSheet(OrcsWriterUtil.INSTRUCTIONS_AND_SETTINGS_SHEET_NAME, instructionHeadings.length);
+ writer.writeRow((Object[]) instructionHeadings);
+ writer.writeCell(null);
+ writer.endRow();
+ writer.writeCell("Instructions");
+ writer.endRow();
+ for (String line : collector.getInstructions().split("\n")) {
+ writer.writeCell(line);
+ writer.endRow();
+ }
+ writer.writeCell(null);
+ writer.endRow();
+
+ // create settings
+ writer.writeCell("Settings");
+ writer.endRow();
+ writer.writeCell(OrcsWriterUtil.BRANCH_TOKEN_SETTING);
+ writer.writeCell(OwFactory.createBranchToken(CoreBranches.COMMON).getData());
+ writer.endRow();
+ writer.writeCell(OrcsWriterUtil.AS_USER_ID_SETTING);
+ writer.writeCell(SystemUser.OseeSystem.getUserId());
+ writer.endRow();
+ writer.writeCell(OrcsWriterUtil.PERSIST_COMMENT_SETTING);
+ writer.writeCell("Enter Persist Comment Here");
+ writer.endRow();
+
+ writer.endSheet();
+ }
+
+ private void createCreateSheet(ISheetWriter writer) throws IOException {
+ // @formatter:off
+ String[] createSheetHeadings = {null, "New Art Token (for refrence in relations, if needed)", "Name", "Attribute", "Relation"};
+ // @formatter:on
+ writer.startSheet(OrcsWriterUtil.CREATE_SHEET_NAME, createSheetHeadings.length);
+ writer.writeRow((Object[]) createSheetHeadings);
+
+ // row 2
+ writer.writeCell("Artifact Type Token");
+ writer.writeCell(null);
+ writer.writeCell(CoreAttributeTypes.Name.getName() + " (required)");
+ writer.writeCell(OwFactory.createAttributeType(CoreAttributeTypes.StaticId).getData());
+ writer.writeCell(OwFactory.createRelationType(orcsApi, CoreRelationTypes.Default_Hierarchical__Parent).getData());
+ writer.endRow();
+
+ // row 3 - New Folder rooted at Default Hierarchy Root
+ writer.writeCell(OwFactory.createArtifactType(CoreArtifactTypes.Folder).getData());
+ Long folderUuid = Lib.generateArtifactIdAsInt();
+ OwArtifactToken folderToken = OwFactory.createArtifactToken("Orcs Writer Import Folder", folderUuid);
+ writer.writeCell(folderToken.getData());
+ writer.writeCell("Orcs Writer Import Folder");
+ writer.writeCell(null);
+ writer.writeCell(OwFactory.createArtifactToken(CoreArtifactTokens.DefaultHierarchyRoot).getData());
+ writer.endRow();
+
+ // row 4 - New Software Requirement 1 under folder
+ writer.writeCell(OwFactory.createArtifactType(CoreArtifactTypes.SoftwareRequirement).getData());
+ writer.writeCell(null);
+ writer.writeCell("Software Requirement 1");
+ writer.writeCell("static id field 1");
+ writer.writeCell(folderToken.getData());
+ writer.endRow();
+
+ // row 5 - New Software Requirement 2 under folder
+ writer.writeCell(OwFactory.createArtifactType(CoreArtifactTypes.SoftwareRequirement).getData());
+ writer.writeCell(null);
+ writer.writeCell("Software Requirement 2");
+ writer.writeCell("static id field 2");
+ writer.writeCell(folderToken.getData());
+ writer.endRow();
+
+ writer.endSheet();
+ }
+
+ private void createUpdateSheet(ISheetWriter writer) throws IOException {
+ writer.startSheet(OrcsWriterUtil.UPDATE_SHEET_NAME, updateSheetHeadings.length);
+ writer.writeRow((Object[]) updateSheetHeadings);
+ writer.writeCell("This sheet is not yet implemented");
+ writer.endRow();
+ writer.endSheet();
+ }
+
+ private void createDeleteSheet(ISheetWriter writer) throws IOException {
+ writer.startSheet(OrcsWriterUtil.DELETE_SHEET_NAME, deleteSheetHeadings.length);
+ writer.writeRow((Object[]) deleteSheetHeadings);
+ writer.writeCell("This sheet is not yet implemented");
+ writer.endRow();
+ writer.endSheet();
+ }
+
+ private void createBranchSheet(ISheetWriter writer) throws IOException {
+ writer.startSheet("Branch Token", branchSheetHeadings.length);
+ writer.writeRow((Object[]) branchSheetHeadings);
+ for (OwBranch token : collector.getBranches()) {
+ writer.writeCell(token.getData());
+ writer.endRow();
+ }
+ writer.endSheet();
+ }
+
+ private void createArtifactTokenSheet(ISheetWriter writer) throws IOException {
+ writer.startSheet("Artifact Token", artifactTokenSheetHeadings.length);
+ writer.writeRow((Object[]) artifactTokenSheetHeadings);
+ for (OwArtifactToken token : collector.getArtTokens()) {
+ writer.writeCell(token.getData());
+ writer.endRow();
+ }
+ writer.endSheet();
+ }
+
+ private void createArtifactTypeSheet(ISheetWriter writer) throws IOException {
+ writer.startSheet("Artifact Types", artifactTypeSheetHeadings.length);
+ writer.writeRow((Object[]) artifactTypeSheetHeadings);
+ for (OwArtifactType type : collector.getArtTypes()) {
+ writer.writeCell(type.getData());
+ writer.endRow();
+ }
+ writer.endSheet();
+ }
+
+ private void createAttributeTypeSheet(ISheetWriter writer) throws IOException {
+ writer.startSheet("Attribute Types", attributeTypeSheetHeadings.length);
+ writer.writeRow((Object[]) attributeTypeSheetHeadings);
+ for (OwAttributeType type : collector.getAttrTypes()) {
+ writer.writeCell(type.getData());
+ writer.endRow();
+ }
+ writer.endSheet();
+ }
+
+ private void createRelationTypeSheet(ISheetWriter writer) throws IOException {
+ writer.startSheet("Relation Types", relationTypeSheetHeadings.length);
+ writer.writeRow((Object[]) relationTypeSheetHeadings);
+ for (OwRelationType relation : collector.getRelTypes()) {
+ writer.writeCell(relation.getData());
+ writer.endRow();
+ }
+ writer.endSheet();
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/OrcsIntegrationTestSuite.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/OrcsIntegrationTestSuite.java
index 9ac4ec9b6fa..3f54eefad79 100644
--- a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/OrcsIntegrationTestSuite.java
+++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/OrcsIntegrationTestSuite.java
@@ -21,6 +21,7 @@ import org.eclipse.osee.orcs.api.OrcsScriptScopeTest;
import org.eclipse.osee.orcs.api.OrcsScriptTest;
import org.eclipse.osee.orcs.api.OrcsTransactionTest;
import org.eclipse.osee.orcs.api.OrcsTxQueryTest;
+import org.eclipse.osee.orcs.writer.OrcsValidationHelperAdapterTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -29,6 +30,7 @@ import org.junit.runners.Suite;
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
+ OrcsValidationHelperAdapterTest.class,
OrcsAttributeLoadingTest.class,
OrcsAttributeSearchTest.class,
OrcsBranchQueryTest.class,
diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsWriterTest.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsWriterTest.java
new file mode 100644
index 00000000000..b697970d528
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsWriterTest.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.api;
+
+import static org.junit.Assert.fail;
+import org.junit.Test;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class OrcsWriterTest {
+
+ @Test
+ public void test() {
+ fail("Not yet implemented");
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/writer/OrcsValidationHelperAdapterTest.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/writer/OrcsValidationHelperAdapterTest.java
new file mode 100644
index 00000000000..99e8165843e
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/writer/OrcsValidationHelperAdapterTest.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.writer;
+
+import static org.eclipse.osee.orcs.OrcsIntegrationRule.integrationRule;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.enums.SystemUser;
+import org.eclipse.osee.orcs.OrcsApi;
+import org.eclipse.osee.orcs.data.ArtifactReadable;
+import org.eclipse.osee.orcs.db.mock.OsgiService;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestRule;
+
+/**
+ * Test case for {@link OrcsValidationHelperAdapter}
+ *
+ * @author Donald G. Dunne
+ */
+public class OrcsValidationHelperAdapterTest {
+
+ @Rule
+ public TestRule osgi = integrationRule(this);
+
+ @OsgiService
+ private OrcsApi orcsApi;
+
+ private OrcsValidationHelperAdapter helper;
+
+ @Before
+ public void setUp() throws Exception {
+ helper = new OrcsValidationHelperAdapter(orcsApi);
+ }
+
+ @Test
+ public void testIsBranchExists() {
+ Assert.assertTrue(helper.isBranchExists(CoreBranches.COMMON.getGuid()));
+
+ Assert.assertFalse(helper.isBranchExists(34598L));
+ }
+
+ @Test
+ public void testIsUserExists() {
+ Assert.assertTrue(helper.isUserExists(SystemUser.OseeSystem.getUserId()));
+
+ Assert.assertFalse(helper.isUserExists("notUserId"));
+ }
+
+ @Test
+ public void testIsArtifactExists() {
+ ArtifactReadable artifact =
+ orcsApi.getQueryFactory().fromBranch(CoreBranches.COMMON).andIsOfType(CoreArtifactTypes.User).getResults().iterator().next();
+ Assert.assertTrue(helper.isArtifactExists(CoreBranches.COMMON.getUuid(), artifact.getUuid()));
+
+ Assert.assertFalse(helper.isArtifactExists(CoreBranches.COMMON.getUuid(), 999999L));
+ }
+
+ @Test
+ public void testIsArtifactTypeExist() {
+ Assert.assertTrue(helper.isArtifactTypeExist(CoreArtifactTypes.User.getGuid()));
+
+ Assert.assertFalse(helper.isArtifactTypeExist(999999L));
+ }
+
+ @Test
+ public void testIsRelationTypeExist() {
+ Assert.assertTrue(helper.isRelationTypeExist(CoreRelationTypes.Default_Hierarchical__Child.getGuid()));
+
+ Assert.assertFalse(helper.isRelationTypeExist(999999L));
+ }
+
+ @Test
+ public void testIsAttributeTypeExists() {
+ Assert.assertTrue(helper.isAttributeTypeExists(CoreAttributeTypes.StaticId.getGuid()));
+
+ Assert.assertFalse(helper.isAttributeTypeExists(999999L));
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs/META-INF/MANIFEST.MF
index c12e91cfe07..ce1c45bc900 100644
--- a/plugins/org.eclipse.osee.orcs/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs/META-INF/MANIFEST.MF
@@ -6,6 +6,9 @@ Bundle-Version: 0.23.0.qualifier
Bundle-Vendor: Eclipse Open System Engineering Environment
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: com.google.gson;version="2.1.0",
+ org.codehaus.jackson.map.annotate;version="1.9.13",
+ org.codehaus.jackson.map.ser;version="1.9.13",
+ org.codehaus.jackson.map.ser.std;version="1.9.13",
org.eclipse.core.runtime,
org.eclipse.osee.executor.admin,
org.eclipse.osee.framework.core.data,
@@ -13,8 +16,10 @@ Import-Package: com.google.gson;version="2.1.0",
org.eclipse.osee.framework.core.model,
org.eclipse.osee.framework.core.model.cache,
org.eclipse.osee.framework.core.model.change,
+ org.eclipse.osee.framework.core.util,
org.eclipse.osee.framework.jdk.core.type,
org.eclipse.osee.framework.jdk.core.util,
+ org.eclipse.osee.framework.jdk.core.util.io.xml,
org.eclipse.osee.framework.resource.management,
org.json
Export-Package: org.eclipse.osee.orcs,
@@ -22,5 +27,8 @@ Export-Package: org.eclipse.osee.orcs,
org.eclipse.osee.orcs.search,
org.eclipse.osee.orcs.statistics,
org.eclipse.osee.orcs.transaction,
- org.eclipse.osee.orcs.utility
+ org.eclipse.osee.orcs.utility,
+ org.eclipse.osee.orcs.writer,
+ org.eclipse.osee.orcs.writer.model.config,
+ org.eclipse.osee.orcs.writer.model.reader
Bundle-ActivationPolicy: lazy
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/AttributeTypes.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/AttributeTypes.java
index d5aa10f83f4..a5fecc927c4 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/AttributeTypes.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/AttributeTypes.java
@@ -49,4 +49,10 @@ public interface AttributeTypes extends IdentityCollection<Long, IAttributeType>
boolean isBooleanType(IAttributeType attrType) throws OseeCoreException;
+ boolean isIntegerType(IAttributeType attrType);
+
+ boolean isDateType(IAttributeType attrType);
+
+ boolean isFloatingType(IAttributeType attrType);
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/IOrcsValidationHelper.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/IOrcsValidationHelper.java
new file mode 100644
index 00000000000..12e2dea0b49
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/IOrcsValidationHelper.java
@@ -0,0 +1,22 @@
+/*
+ * Created on Jun 30, 2015
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.orcs.writer;
+
+public interface IOrcsValidationHelper {
+
+ boolean isBranchExists(long branchUuid);
+
+ boolean isUserExists(String userId);
+
+ boolean isArtifactTypeExist(long artifactTypeUuid);
+
+ boolean isRelationTypeExist(long relationTypeUuid);
+
+ boolean isAttributeTypeExists(long attributeTypeUuid);
+
+ public boolean isArtifactExists(long branchUuid, long artifactUuid);
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsValidationHelperAdapter.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsValidationHelperAdapter.java
new file mode 100644
index 00000000000..71c4713a395
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsValidationHelperAdapter.java
@@ -0,0 +1,51 @@
+/*
+ * Created on Jun 30, 2015
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.orcs.writer;
+
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.orcs.OrcsApi;
+
+public class OrcsValidationHelperAdapter implements IOrcsValidationHelper {
+
+ private final OrcsApi orcsApi;
+
+ public OrcsValidationHelperAdapter(OrcsApi orcsApi) {
+ this.orcsApi = orcsApi;
+ }
+
+ @Override
+ public boolean isBranchExists(long branchUuid) {
+ return orcsApi.getQueryFactory().branchQuery().andUuids(branchUuid).getResultsAsId().size() == 1;
+ }
+
+ @Override
+ public boolean isUserExists(String userId) {
+ return orcsApi.getQueryFactory().fromBranch(CoreBranches.COMMON).and(CoreAttributeTypes.UserId, userId).getResults().getAtMostOneOrNull() != null;
+ }
+
+ @Override
+ public boolean isArtifactExists(long branchUuid, long artifactUuid) {
+ int matchedArtifacts = orcsApi.getQueryFactory().fromBranch(branchUuid).andUuid(artifactUuid).getResults().size();
+ return matchedArtifacts == 1;
+ }
+
+ @Override
+ public boolean isArtifactTypeExist(long artifactTypeUuid) {
+ return orcsApi.getOrcsTypes().getArtifactTypes().getByUuid(artifactTypeUuid) != null;
+ }
+
+ @Override
+ public boolean isRelationTypeExist(long relationTypeUuid) {
+ return orcsApi.getOrcsTypes().getRelationTypes().getByUuid(relationTypeUuid) != null;
+ }
+
+ @Override
+ public boolean isAttributeTypeExists(long attributeTypeUuid) {
+ return orcsApi.getOrcsTypes().getAttributeTypes().getByUuid(attributeTypeUuid) != null;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsWriterExcelReader.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsWriterExcelReader.java
new file mode 100644
index 00000000000..7c423860e8d
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsWriterExcelReader.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.writer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import org.eclipse.osee.framework.core.util.XResultData;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+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.orcs.writer.model.reader.OwCollector;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class OrcsWriterExcelReader {
+
+ private OwCollector collector;
+ private final XResultData result;
+
+ public OrcsWriterExcelReader(XResultData result) throws Exception {
+ this.result = result;
+ }
+
+ public void run(URI source) throws SAXException, IOException, UnsupportedEncodingException, MalformedURLException {
+ collector = new OwCollector();
+ XMLReader xmlReader = XMLReaderFactory.createXMLReader();
+ xmlReader.setContentHandler(new ExcelSaxHandler(new ExcelRowProcessor(collector, result), true));
+ InputStreamReader inputStreamReader = new InputStreamReader(source.toURL().openStream(), "UTF-8");
+ xmlReader.parse(new InputSource(inputStreamReader));
+ inputStreamReader.close();
+ }
+
+ public void run(InputStream source) throws SAXException, IOException, UnsupportedEncodingException, MalformedURLException {
+ collector = new OwCollector();
+ XMLReader xmlReader = XMLReaderFactory.createXMLReader();
+ xmlReader.setContentHandler(new ExcelSaxHandler(new ExcelRowProcessor(collector, result), true));
+ xmlReader.parse(new InputSource(source));
+ }
+
+ private static final class ExcelRowProcessor implements RowProcessor {
+
+ private final OwCollector collector;
+ private OrcsWriterSheetProcessorForCreate createSheet;
+ private OrcsWriterSheetProcessorForSettings settingsSheet;
+ private String sheetName = "";
+ private final XResultData result;
+
+ public ExcelRowProcessor(OwCollector collector, XResultData result) {
+ this.collector = collector;
+ this.result = result;
+ }
+
+ @Override
+ public void detectedRowAndColumnCounts(int rowCount, int columnCount) {
+ // do nothing
+ }
+
+ @Override
+ public void foundStartOfWorksheet(String sheetName) throws OseeCoreException {
+ System.out.println("Processing Sheet " + sheetName);
+ this.sheetName = sheetName;
+ if (sheetName.equals(OrcsWriterUtil.CREATE_SHEET_NAME)) {
+ createSheet = new OrcsWriterSheetProcessorForCreate(collector, result);
+ return;
+ } else if (sheetName.equals(OrcsWriterUtil.INSTRUCTIONS_AND_SETTINGS_SHEET_NAME)) {
+ settingsSheet = new OrcsWriterSheetProcessorForSettings(collector, result);
+ return;
+ }
+ }
+
+ @Override
+ public void processCommentRow(String[] row) {
+ // do nothing
+ }
+
+ @Override
+ public void processEmptyRow() {
+ // do nothing
+ }
+
+ @Override
+ public void processHeaderRow(String[] headerRow) {
+ if (isCreateSheet()) {
+ createSheet.processHeaderRow(headerRow);
+ }
+ }
+
+ private boolean isCreateSheet() {
+ return sheetName.equals(OrcsWriterUtil.CREATE_SHEET_NAME);
+ }
+
+ private boolean isSettingsSheet() {
+ return sheetName.equals(OrcsWriterUtil.INSTRUCTIONS_AND_SETTINGS_SHEET_NAME);
+ }
+
+ @Override
+ public void processRow(String[] row) throws OseeCoreException {
+ if (isCreateSheet()) {
+ createSheet.processRow(row);
+ } else if (isSettingsSheet()) {
+ settingsSheet.processRow(row);
+ }
+ }
+
+ @Override
+ public void reachedEndOfWorksheet() {
+ // do nothing
+ }
+
+ }
+
+ public OwCollector getCollector() {
+ return collector;
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsWriterFactory.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsWriterFactory.java
new file mode 100644
index 00000000000..143ee084371
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsWriterFactory.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.writer;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.eclipse.osee.orcs.writer.model.reader.OwArtifact;
+import org.eclipse.osee.orcs.writer.model.reader.OwArtifactToken;
+import org.eclipse.osee.orcs.writer.model.reader.OwArtifactType;
+import org.eclipse.osee.orcs.writer.model.reader.OwAttribute;
+import org.eclipse.osee.orcs.writer.model.reader.OwAttributeType;
+import org.eclipse.osee.orcs.writer.model.reader.OwBranch;
+import org.eclipse.osee.orcs.writer.model.reader.OwCollector;
+import org.eclipse.osee.orcs.writer.model.reader.OwRelation;
+import org.eclipse.osee.orcs.writer.model.reader.OwRelationType;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class OrcsWriterFactory {
+
+ private final Pattern relTypePattern = Pattern.compile("\\[(.*)\\]-\\[(.*)\\]-\\[(.*)\\]-\\[(.*)\\]");
+ private final Pattern nameIdPattern = Pattern.compile("\\[(.*)\\]-\\[(.*)\\]");
+ private final Map<Long, OwArtifactType> uuidToArtType = new HashMap<>();
+ private final Map<Long, OwArtifactToken> uuidToArtToken = new HashMap<>();
+ private final OwCollector collector;
+
+ public OrcsWriterFactory(OwCollector collector) {
+ this.collector = collector;
+ }
+
+ public OwArtifactToken getOrCreateToken(String value) {
+ OwArtifactToken token = null;
+ Matcher matcher = nameIdPattern.matcher(value);
+ if (matcher.find()) {
+ Long uuid = Long.valueOf(matcher.group(2));
+ token = uuidToArtToken.get(uuid);
+ if (token == null) {
+ token = new OwArtifactToken();
+ token.setName(matcher.group(1));
+ token.setUuid(uuid);
+ token.setData(value);
+ collector.getArtTokens().add(token);
+ uuidToArtToken.put(uuid, token);
+ }
+ }
+ return token;
+ }
+
+ public OwArtifactType getOrCreateArtifactType(String value) {
+ OwArtifactType artType = null;
+ Matcher matcher = nameIdPattern.matcher(value);
+ if (matcher.find()) {
+ Long uuid = Long.valueOf(matcher.group(2));
+ artType = uuidToArtType.get(uuid);
+ if (artType == null) {
+ artType = new OwArtifactType();
+ artType.setName(matcher.group(1));
+ artType.setUuid(uuid);
+ artType.setData(value);
+ collector.getArtTypes().add(artType);
+ uuidToArtType.put(uuid, artType);
+ }
+ }
+ return artType;
+ }
+
+ public OwAttribute getOrCreateAttribute(OwArtifact artifact, OwAttributeType attrType) {
+ OwAttribute attr = null;
+ for (OwAttribute fAttr : artifact.getAttributes()) {
+ if (fAttr.getType().getUuid() == attrType.getUuid()) {
+ attr = fAttr;
+ break;
+ }
+ }
+ if (attr == null) {
+ attr = new OwAttribute();
+ attr.setType(attrType);
+ artifact.getAttributes().add(attr);
+ }
+ return attr;
+ }
+
+ public OwRelation createRelationType(OwRelationType relType, String value) {
+ OwArtifactToken token = getOrCreateToken(value);
+ OwRelation relation = new OwRelation();
+ relation.setData(value);
+ relation.setArtToken(token);
+ relation.setType(relType);
+ return relation;
+ }
+
+ public void processRelationType(OwRelationType relType, String value) {
+ relType.setData(value);
+ Matcher matcher = relTypePattern.matcher(value);
+ if (matcher.find()) {
+ relType.setName(matcher.group(1));
+ relType.setSideName(matcher.group(2));
+ relType.setSideA(matcher.group(3).contains("Side A"));
+ relType.setUuid(Long.valueOf(matcher.group(4)));
+ }
+ }
+
+ public void processAttributeType(OwAttributeType attrType, String value) {
+ attrType.setData(value);
+ Matcher matcher = nameIdPattern.matcher(value);
+ if (matcher.find()) {
+ attrType.setName(matcher.group(1));
+ attrType.setUuid(Long.valueOf(matcher.group(2)));
+ }
+ }
+
+ public OwBranch getOrCreateBranchToken(String value) {
+ OwBranch branch = new OwBranch();
+ Matcher matcher = nameIdPattern.matcher(value);
+ if (matcher.find()) {
+ branch.setName(matcher.group(1));
+ branch.setUuid(Long.valueOf(matcher.group(2)));
+ }
+ return branch;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsWriterSheetProcessorForCreate.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsWriterSheetProcessorForCreate.java
new file mode 100644
index 00000000000..72ac66cd52b
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsWriterSheetProcessorForCreate.java
@@ -0,0 +1,203 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.writer;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.util.XResultData;
+import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.OseeStateException;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.RowProcessor;
+import org.eclipse.osee.orcs.writer.model.reader.OwArtifact;
+import org.eclipse.osee.orcs.writer.model.reader.OwArtifactToken;
+import org.eclipse.osee.orcs.writer.model.reader.OwArtifactType;
+import org.eclipse.osee.orcs.writer.model.reader.OwAttribute;
+import org.eclipse.osee.orcs.writer.model.reader.OwAttributeType;
+import org.eclipse.osee.orcs.writer.model.reader.OwCollector;
+import org.eclipse.osee.orcs.writer.model.reader.OwRelation;
+import org.eclipse.osee.orcs.writer.model.reader.OwRelationType;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class OrcsWriterSheetProcessorForCreate implements RowProcessor {
+
+ private final OwCollector collector;
+ private final Map<Integer, OwAttributeType> columnToAttributeType = new HashMap<>();
+ private final Map<Integer, OwRelationType> columnToRelationType = new HashMap<>();
+ private Integer artTokenColumn = null, nameColumn = null;
+ private int rowCount = 0;
+ private final OrcsWriterFactory factory;
+
+ public OrcsWriterSheetProcessorForCreate(OwCollector collector, XResultData result) {
+ this.collector = collector;
+ this.factory = new OrcsWriterFactory(collector);
+ }
+
+ @Override
+ public void detectedRowAndColumnCounts(int rowCount, int columnCount) {
+ // do nothing
+ }
+
+ @Override
+ public void foundStartOfWorksheet(String sheetName) throws OseeCoreException {
+ // do nothing
+ }
+
+ @Override
+ public void processCommentRow(String[] row) {
+ // do nothing
+ }
+
+ @Override
+ public void processEmptyRow() {
+ // do nothing
+ }
+
+ boolean isAttributeColumn(int x) {
+ return columnToAttributeType.containsKey(x);
+ }
+
+ boolean isRelationColumn(int x) {
+ return columnToRelationType.containsKey(x);
+ }
+
+ @Override
+ public void processHeaderRow(String[] headerRow) {
+ rowCount++;
+ for (int colCount = 0; colCount < headerRow.length; colCount++) {
+ String value = headerRow[colCount];
+ System.err.println(String.format("Header [%s]", value));
+ if (value != null) {
+ if (value.toLowerCase().equals("name")) {
+ if (nameColumn != null) {
+ throw new OseeArgumentException("Can't have multiple Name columns");
+ }
+ nameColumn = colCount;
+ } else if (value.toLowerCase().equals("attribute")) {
+ OwAttributeType attrType = new OwAttributeType();
+ attrType.setData("Column " + colCount);
+ columnToAttributeType.put(colCount, attrType);
+ collector.getAttrTypes().add(attrType);
+ } else if (value.toLowerCase().equals("relation")) {
+ OwRelationType relType = new OwRelationType();
+ relType.setData("Column " + colCount);
+ columnToRelationType.put(colCount, relType);
+ collector.getRelTypes().add(relType);
+ } else if (value.toLowerCase().startsWith("new art token")) {
+ if (artTokenColumn != null) {
+ throw new OseeArgumentException("Can't have multiple \"New Art Token\" columns");
+ }
+ artTokenColumn = colCount;
+ }
+ }
+ }
+ if (nameColumn == null) {
+ throw new OseeArgumentException("Name column must be present");
+ }
+ if (artTokenColumn == null) {
+ throw new OseeArgumentException("Artifact Token column must be present");
+ }
+ }
+
+ @Override
+ public void processRow(String[] row) throws OseeCoreException {
+ rowCount++;
+ OwArtifact artifact = new OwArtifact();
+ artifact.setData("Row " + rowCount);
+ if (rowCount == 2) {
+ for (int colCount = 0; colCount < row.length; colCount++) {
+ if (colCount > 2) {
+ if (isAttributeColumn(colCount)) {
+ OwAttributeType attrType = columnToAttributeType.get(colCount);
+ String value = row[colCount];
+ factory.processAttributeType(attrType, value);
+ } else if (isRelationColumn(colCount)) {
+ OwRelationType relType = columnToRelationType.get(colCount);
+ String value = row[colCount];
+ factory.processRelationType(relType, value);
+ }
+ }
+ }
+ } else if (rowCount > 2) {
+ collector.getCreate().add(artifact);
+ for (int colCount = 0; colCount < row.length; colCount++) {
+ System.err.print(colCount + ", ");
+ if (colCount == 0) {
+ String value = row[0];
+ if (!Strings.isValid(value)) {
+ throw new OseeArgumentException("First column must contain artifact type. row number " + rowCount);
+ } else {
+ OwArtifactType artType = factory.getOrCreateArtifactType(value);
+ if (artType == null) {
+ throw new OseeArgumentException("Invalid Artifact Type row %d value [%s]; expected [name]-[uuid]",
+ rowCount, value);
+ }
+ artifact.setType(artType);
+ }
+ }
+ if (artTokenColumn == colCount) {
+ String value = row[colCount];
+ if (Strings.isValid(value)) {
+ OwArtifactToken token = factory.getOrCreateToken(value);
+ if (token.getUuid() > 0L) {
+ artifact.setUuid(token.getUuid());
+ } else {
+ System.out.println(String.format("Unexpected string [%s] at %s; expected [name]-[uuid]", value,
+ OrcsWriterUtil.getRowColumnStr(colCount, colCount)));
+ }
+ }
+ }
+ if (nameColumn == colCount) {
+ String value = row[colCount];
+ if (Strings.isValid(value)) {
+ artifact.setName(value);
+ } else {
+ System.out.println(String.format("Unexpected Name [%s] at %s", value,
+ OrcsWriterUtil.getRowColumnStr(colCount, colCount)));
+ }
+ }
+ if (colCount > 2) {
+ if (isAttributeColumn(colCount)) {
+ OwAttributeType attrType = columnToAttributeType.get(colCount);
+ if (attrType.getName().equals(CoreAttributeTypes.Name.getName())) {
+ throw new OseeStateException("Name cannot also exist as attribute column at %s",
+ OrcsWriterUtil.getRowColumnStr(rowCount, colCount));
+ }
+ String value = row[colCount];
+ if (Strings.isValid(value)) {
+ OwAttribute attr = factory.getOrCreateAttribute(artifact, attrType);
+ attr.getValues().add(value);
+ attr.setData(OrcsWriterUtil.getData(rowCount, colCount, attr.getData()));
+ }
+ } else if (isRelationColumn(colCount)) {
+ OwRelationType relType = columnToRelationType.get(colCount);
+ String value = row[colCount];
+ if (Strings.isValid(value)) {
+ OwRelation relation = factory.createRelationType(relType, value);
+ relation.setData(OrcsWriterUtil.getData(rowCount, colCount, relation.getData()));
+ artifact.getRelations().add(relation);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void reachedEndOfWorksheet() {
+ // do nothing
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsWriterSheetProcessorForSettings.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsWriterSheetProcessorForSettings.java
new file mode 100644
index 00000000000..f2793ac5c41
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsWriterSheetProcessorForSettings.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.writer;
+
+import org.eclipse.osee.framework.core.util.XResultData;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.RowProcessor;
+import org.eclipse.osee.orcs.writer.model.reader.OwBranch;
+import org.eclipse.osee.orcs.writer.model.reader.OwCollector;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class OrcsWriterSheetProcessorForSettings implements RowProcessor {
+
+ private final OwCollector collector;
+ private int rowCount = 0;
+ private final OrcsWriterFactory factory;
+
+ public OrcsWriterSheetProcessorForSettings(OwCollector collector, XResultData result) {
+ this.collector = collector;
+ this.factory = new OrcsWriterFactory(collector);
+ }
+
+ @Override
+ public void detectedRowAndColumnCounts(int rowCount, int columnCount) {
+ // do nothing
+ }
+
+ @Override
+ public void foundStartOfWorksheet(String sheetName) throws OseeCoreException {
+ // do nothing
+ }
+
+ @Override
+ public void processCommentRow(String[] row) {
+ // do nothing
+ }
+
+ @Override
+ public void processEmptyRow() {
+ // do nothing
+ }
+
+ @Override
+ public void processHeaderRow(String[] headerRow) {
+ // do nothing
+ }
+
+ @Override
+ public void processRow(String[] row) throws OseeCoreException {
+ rowCount++;
+ for (int colCount = 0; colCount < row.length; colCount++) {
+ if (colCount == 0) {
+ String key = row[colCount];
+ if (key.equals(OrcsWriterUtil.BRANCH_TOKEN_SETTING)) {
+ String branchTokenStr = row[1];
+ if (Strings.isValid(branchTokenStr)) {
+ OwBranch branchToken = factory.getOrCreateBranchToken(branchTokenStr);
+ collector.setBranch(branchToken);
+ branchToken.setData(OrcsWriterUtil.getData(rowCount, colCount, branchTokenStr));
+ }
+ } else if (key.equals(OrcsWriterUtil.AS_USER_ID_SETTING)) {
+ String userId = row[1];
+ if (Strings.isValid(userId)) {
+ collector.setAsUserId(userId);
+ }
+ } else if (key.equals(OrcsWriterUtil.PERSIST_COMMENT_SETTING)) {
+ String persistComment = row[1];
+ if (Strings.isValid(persistComment)) {
+ collector.setPersistComment(persistComment);
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void reachedEndOfWorksheet() {
+ // do nothing
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsWriterUtil.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsWriterUtil.java
new file mode 100644
index 00000000000..9d95a68bb7e
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsWriterUtil.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.writer;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class OrcsWriterUtil {
+
+ public static final String PERSIST_COMMENT_SETTING = "PERSIST COMMENT";
+ public static final String AS_USER_ID_SETTING = "AS USER ID";
+ public static final String BRANCH_TOKEN_SETTING = "BRANCH TOKEN";
+ public static final String INSTRUCTIONS_AND_SETTINGS_SHEET_NAME = "Instructions and Settings";
+ public static final String CREATE_SHEET_NAME = "CREATE";
+ public static final String DELETE_SHEET_NAME = "DELETE";
+ public static final String UPDATE_SHEET_NAME = "UPDATE";
+
+ private OrcsWriterUtil() {
+ // Utility Class
+ }
+
+ public static String getData(int rowCount, int colCount, String data) {
+ if (data != null) {
+ data += ", ";
+ }
+ data += getRowColumnStr(rowCount, colCount);
+ return data;
+ }
+
+ public static String getRowColumnStr(int rowCount, int colCount) {
+ return "row " + rowCount + ", column " + (colCount + 1);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/config/OrcsWriterInputConfig.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/config/OrcsWriterInputConfig.java
new file mode 100644
index 00000000000..0bddb8d710b
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/config/OrcsWriterInputConfig.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.writer.model.config;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Donald G. Dunne
+ */
+@XmlRootElement
+public class OrcsWriterInputConfig {
+
+ private final List<Long> includeArtifactTypes = new ArrayList<>();
+ private final List<Long> includeAttributeTypes = new ArrayList<>();
+ private final List<OrcsWriterRelationSide> includeRelationSideTypes = new ArrayList<>();
+ private final List<OrcsWriterToken> includeTokens = new ArrayList<>();
+
+ public List<Long> getIncludeArtifactTypes() {
+ return includeArtifactTypes;
+ }
+
+ public List<Long> getIncludeAttributeTypes() {
+ return includeAttributeTypes;
+ }
+
+ public List<OrcsWriterRelationSide> getIncludeRelationTypes() {
+ return includeRelationSideTypes;
+ }
+
+ public List<OrcsWriterToken> getIncludeTokens() {
+ return includeTokens;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/config/OrcsWriterRelationSide.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/config/OrcsWriterRelationSide.java
new file mode 100644
index 00000000000..0013dc5fb11
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/config/OrcsWriterRelationSide.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.writer.model.config;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Donald G. Dunne
+ */
+@XmlRootElement
+public class OrcsWriterRelationSide {
+
+ private Long relationTypeUuid;
+ private boolean sideA;
+
+ public Long getRelationTypeUuid() {
+ return relationTypeUuid;
+ }
+
+ public void setRelationTypeUuid(Long relationTypeUuid) {
+ this.relationTypeUuid = relationTypeUuid;
+ }
+
+ public boolean isSideA() {
+ return sideA;
+ }
+
+ public void setSideA(boolean sideA) {
+ this.sideA = sideA;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/config/OrcsWriterToken.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/config/OrcsWriterToken.java
new file mode 100644
index 00000000000..06258dbc308
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/config/OrcsWriterToken.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.writer.model.config;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Donald G. Dunne
+ */
+@XmlRootElement
+public class OrcsWriterToken {
+
+ private Long uuid;
+ private String name;
+
+ public Long getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(Long uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwArtifact.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwArtifact.java
new file mode 100644
index 00000000000..f3ec772aaa5
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwArtifact.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.writer.model.reader;
+
+import java.util.LinkedList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Donald G. Dunne
+ */
+@XmlRootElement
+public class OwArtifact extends OwBase {
+
+ OwArtifactType type;
+ String name;
+ List<OwAttribute> attributes;
+ List<OwRelation> relations;
+
+ public OwArtifactType getType() {
+ return type;
+ }
+
+ public void setType(OwArtifactType type) {
+ this.type = type;
+ }
+
+ public List<OwAttribute> getAttributes() {
+ if (attributes == null) {
+ attributes = new LinkedList<>();
+ }
+ return attributes;
+ }
+
+ public void setAttributes(List<OwAttribute> attributes) {
+ this.attributes = attributes;
+ }
+
+ public List<OwRelation> getRelations() {
+ if (relations == null) {
+ relations = new LinkedList<>();
+ }
+ return relations;
+ }
+
+ public void setRelations(List<OwRelation> relations) {
+ this.relations = relations;
+ }
+
+ @Override
+ public String toString() {
+ return "OwArtifact [type=" + type + ", uuid=" + uuid + ", data=" + data + "]";
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwArtifactToken.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwArtifactToken.java
new file mode 100644
index 00000000000..27c91817147
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwArtifactToken.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.writer.model.reader;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Donald G. Dunne
+ */
+@XmlRootElement
+public class OwArtifactToken extends OwNamedBase {
+
+ @Override
+ public String toString() {
+ return "OwArtifactToken [uuid=" + uuid + ", data=" + data + "]";
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwArtifactType.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwArtifactType.java
new file mode 100644
index 00000000000..72869d1a523
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwArtifactType.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.writer.model.reader;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Donald G. Dunne
+ */
+@XmlRootElement
+public class OwArtifactType extends OwNamedBase {
+
+ @Override
+ public String toString() {
+ return "OwArtifactType [uuid=" + uuid + ", data=" + data + "]";
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwAttribute.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwAttribute.java
new file mode 100644
index 00000000000..5c3a988250e
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwAttribute.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.writer.model.reader;
+
+import java.util.LinkedList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Donald G. Dunne
+ */
+@XmlRootElement
+public class OwAttribute {
+
+ public OwAttributeType type;
+ public List<Object> values;
+ public String data;
+
+ public OwAttributeType getType() {
+ return type;
+ }
+
+ public void setType(OwAttributeType type) {
+ this.type = type;
+ }
+
+ public List<Object> getValues() {
+ if (values == null) {
+ values = new LinkedList<Object>();
+ }
+ return values;
+ }
+
+ public void setValues(List<Object> values) {
+ this.values = values;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ @Override
+ public String toString() {
+ return "OwAttribute [type=" + type + ", values=" + values + ", data=" + data + "]";
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwAttributeType.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwAttributeType.java
new file mode 100644
index 00000000000..9b10509e21f
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwAttributeType.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.writer.model.reader;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Donald G. Dunne
+ */
+@XmlRootElement
+public class OwAttributeType extends OwNamedBase {
+
+ @Override
+ public String toString() {
+ return "OwAttributeType [uuid=" + uuid + ", data=" + data + "]";
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwBase.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwBase.java
new file mode 100644
index 00000000000..6b7a7966ae4
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwBase.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.writer.model.reader;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.ser.std.ToStringSerializer;
+import org.eclipse.osee.framework.jdk.core.type.UuidBaseIdentity;
+import org.eclipse.osee.framework.jdk.core.type.UuidIdentity;
+
+/**
+ * @author Donald G. Dunne
+ */
+@XmlRootElement
+public class OwBase implements UuidIdentity {
+
+ @JsonSerialize(using = ToStringSerializer.class)
+ long uuid = 0L;
+ String data = null;
+
+ @Override
+ public long getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(long uuid) {
+ this.uuid = uuid;
+ }
+
+ @Override
+ public boolean matches(UuidIdentity... identities) {
+ for (UuidIdentity identity : identities) {
+ if (equals(identity)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int) (uuid ^ (uuid >>> 32));
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ UuidBaseIdentity other = (UuidBaseIdentity) obj;
+ if (uuid != other.getUuid()) {
+ return false;
+ }
+ return true;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwBranch.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwBranch.java
new file mode 100644
index 00000000000..f117345a878
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwBranch.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.writer.model.reader;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Donald G. Dunne
+ */
+@XmlRootElement
+public class OwBranch extends OwNamedBase {
+
+ @Override
+ public String toString() {
+ return "OwBranch [uuid=" + uuid + ", data=" + data + "]";
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwCollector.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwCollector.java
new file mode 100644
index 00000000000..2e2173a5a6a
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwCollector.java
@@ -0,0 +1,160 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.writer.model.reader;
+
+import java.util.LinkedList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Donald G. Dunne
+ */
+@XmlRootElement
+public class OwCollector {
+
+ private String instructions;
+ private OwBranch branch;
+ private String persistComment;
+ private String asUserId;
+ private List<OwArtifact> create;
+ private List<OwArtifact> update;
+ private List<OwArtifactToken> delete;
+ private List<OwArtifactType> artTypes;
+ private List<OwAttributeType> attrTypes;
+ private List<OwRelationType> relTypes;
+ private List<OwBranch> branches;
+ private List<OwArtifactToken> artTokens;
+
+ public OwCollector() {
+ create = new LinkedList<>();
+ branch = new OwBranch();
+ }
+
+ public List<OwArtifact> getCreate() {
+ if (create == null) {
+ create = new LinkedList<OwArtifact>();
+ }
+ return create;
+ }
+
+ public void setCreate(List<OwArtifact> artifacts) {
+ this.create = artifacts;
+ }
+
+ public List<OwArtifactType> getArtTypes() {
+ if (artTypes == null) {
+ artTypes = new LinkedList<>();
+ }
+ return artTypes;
+ }
+
+ public void setArtTypes(List<OwArtifactType> artTypes) {
+ this.artTypes = artTypes;
+ }
+
+ public List<OwAttributeType> getAttrTypes() {
+ if (attrTypes == null) {
+ attrTypes = new LinkedList<>();
+ }
+ return attrTypes;
+ }
+
+ public void setAttrTypes(List<OwAttributeType> attrTypes) {
+ this.attrTypes = attrTypes;
+ }
+
+ public List<OwRelationType> getRelTypes() {
+ if (relTypes == null) {
+ relTypes = new LinkedList<>();
+ }
+ return relTypes;
+ }
+
+ public void setRelTypes(List<OwRelationType> relTypes) {
+ this.relTypes = relTypes;
+ }
+
+ public List<OwArtifactToken> getArtTokens() {
+ if (artTokens == null) {
+ artTokens = new LinkedList<>();
+ }
+ return artTokens;
+ }
+
+ public void setArtTokens(List<OwArtifactToken> artTokens) {
+ this.artTokens = artTokens;
+ }
+
+ public List<OwArtifact> getUpdate() {
+ return update;
+ }
+
+ public void setUpdate(List<OwArtifact> update) {
+ this.update = update;
+ }
+
+ public List<OwArtifactToken> getDelete() {
+ return delete;
+ }
+
+ public void setDelete(List<OwArtifactToken> delete) {
+ this.delete = delete;
+ }
+
+ public OwBranch getBranch() {
+ return branch;
+ }
+
+ public void setBranch(OwBranch branch) {
+ this.branch = branch;
+ }
+
+ public List<OwBranch> getBranches() {
+ if (branches == null) {
+ branches = new LinkedList<>();
+ }
+ return branches;
+ }
+
+ public void setBranches(List<OwBranch> branches) {
+ this.branches = branches;
+ }
+
+ public String getInstructions() {
+ return instructions;
+ }
+
+ public void setInstructions(String instructions) {
+ this.instructions = instructions;
+ }
+
+ @Override
+ public String toString() {
+ return "OwCollector [branch=" + branch + ", create=" + create + ", update=" + update + ", delete=" + delete + "]";
+ }
+
+ public String getPersistComment() {
+ return persistComment;
+ }
+
+ public void setPersistComment(String persistComment) {
+ this.persistComment = persistComment;
+ }
+
+ public String getAsUserId() {
+ return asUserId;
+ }
+
+ public void setAsUserId(String asUserId) {
+ this.asUserId = asUserId;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwFactory.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwFactory.java
new file mode 100644
index 00000000000..fef06479ee5
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwFactory.java
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.writer.model.reader;
+
+/**
+ * Donald G. Dunne
+ */
+import org.eclipse.osee.framework.core.data.IArtifactToken;
+import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.data.IRelationType;
+import org.eclipse.osee.framework.core.data.IRelationTypeSide;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.orcs.OrcsApi;
+
+public class OwFactory {
+
+ public static OwArtifactType createArtifactType(IArtifactType artType) {
+ String typeStr = String.format("[%s]-[%d]", artType.getName(), artType.getGuid());
+ OwArtifactType type = new OwArtifactType();
+ type.setUuid(artType.getGuid());
+ type.setName(artType.getName());
+ type.setData(typeStr);
+ return type;
+ }
+
+ public static OwAttributeType createAttributeType(IAttributeType attrType) {
+ String typeStr = String.format("[%s]-[%d]", attrType.getName(), attrType.getGuid());
+ OwAttributeType type = new OwAttributeType();
+ type.setUuid(attrType.getGuid());
+ type.setName(attrType.getName());
+ type.setData(typeStr);
+ return type;
+ }
+
+ public static OwArtifactToken createArtifactToken(IArtifactToken token) {
+ return createArtifactToken(token.getName(), token.getUuid());
+ }
+
+ public static OwArtifactToken createArtifactToken(String name, long uuid) {
+ String tokenStr = String.format("[%s]-[%d]", name, uuid);
+ OwArtifactToken owToken = new OwArtifactToken();
+ owToken.setUuid(uuid);
+ owToken.setName(name);
+ owToken.setData(tokenStr);
+ return owToken;
+ }
+
+ public static OwRelationType createRelationType(IRelationType relType, String sideName, boolean sideA) {
+ String sideData =
+ String.format("[%s]-[%s]-[Side %s]-[%d]", relType.getName(), sideName, (sideA ? "A" : "B"), relType.getGuid());
+ OwRelationType owType = new OwRelationType();
+ owType.setUuid(relType.getGuid());
+ owType.setName(relType.getName());
+ owType.setData(sideData);
+ owType.setSideA(sideA);
+ return owType;
+ }
+
+ public static OwRelationType createRelationType(OrcsApi orcsApi, IRelationTypeSide type) {
+ String sideAName = orcsApi.getOrcsTypes().getRelationTypes().getSideAName(type);
+ OwRelationType owType = OwFactory.createRelationType(type, sideAName, true);
+ return owType;
+ }
+
+ public static OwArtifact createArtifact(IArtifactType artifactType, String name) {
+ return createArtifact(artifactType, name, null);
+ }
+
+ public static OwArtifact createArtifact(IArtifactType artifactType, String name, Long uuid) {
+ OwArtifact artifact = new OwArtifact();
+ artifact.setType(OwFactory.createArtifactType(artifactType));
+ if (uuid == null) {
+ uuid = Lib.generateArtifactIdAsInt();
+ }
+ artifact.setUuid(uuid);
+ artifact.setName(name);
+ return artifact;
+ }
+
+ public static OwAttribute createAttribute(OwArtifact artifact, IAttributeType attrType, Object... values) {
+ OwAttribute attribute = new OwAttribute();
+ attribute.setType(OwFactory.createAttributeType(attrType));
+ for (Object obj : values) {
+ attribute.getValues().add(obj);
+ }
+ artifact.getAttributes().add(attribute);
+ return attribute;
+ }
+
+ public static OwBranch createBranchToken(IOseeBranch branch) {
+ String tokenStr = String.format("[%s]-[%d]", branch.getName(), branch.getUuid());
+ OwBranch owBranch = new OwBranch();
+ owBranch.setData(tokenStr);
+ owBranch.setName(branch.getName());
+ owBranch.setUuid(branch.getUuid());
+ return owBranch;
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwNamedBase.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwNamedBase.java
new file mode 100644
index 00000000000..24671945da8
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwNamedBase.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.writer.model.reader;
+
+import org.eclipse.osee.framework.jdk.core.type.Named;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class OwNamedBase extends OwBase implements Named {
+
+ private String name;
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwRelation.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwRelation.java
new file mode 100644
index 00000000000..154de3d7b44
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwRelation.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.writer.model.reader;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Donald G. Dunne
+ */
+@XmlRootElement
+public class OwRelation {
+
+ public OwRelationType type;
+ public OwArtifactToken artToken;
+ public String data;
+
+ public OwRelationType getType() {
+ return type;
+ }
+
+ public void setType(OwRelationType type) {
+ this.type = type;
+ }
+
+ public OwArtifactToken getArtToken() {
+ return artToken;
+ }
+
+ public void setArtToken(OwArtifactToken artToken) {
+ this.artToken = artToken;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ @Override
+ public String toString() {
+ return "OwRelation [type=" + type + ", artToken=" + artToken + ", data=" + data + "]";
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwRelationType.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwRelationType.java
new file mode 100644
index 00000000000..23c30299de5
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/model/reader/OwRelationType.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.writer.model.reader;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Donald G. Dunne
+ */
+@XmlRootElement
+public class OwRelationType extends OwNamedBase {
+
+ private boolean sideA;
+ private String sideName;
+
+ public boolean isSideA() {
+ return sideA;
+ }
+
+ public void setSideA(boolean sideA) {
+ this.sideA = sideA;
+ }
+
+ public String getSideName() {
+ return sideName;
+ }
+
+ public void setSideName(String sideName) {
+ this.sideName = sideName;
+ }
+
+ @Override
+ public String toString() {
+ return "OwRelationType [sideA=" + sideA + ", sideName=" + sideName + ", uuid=" + uuid + ", data=" + data + "]";
+ }
+
+}

Back to the top