Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/OrcsWriterEndpoint.java9
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/writer/main.html16
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/writer/orcsWriter.js26
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/writer/writer.css12
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsWriterEndpointImpl.java54
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/writer/OrcsWriterExcelReader.java2
8 files changed, 97 insertions, 25 deletions
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 5cd0a62f8c..7230bd6771 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
@@ -11,6 +11,7 @@ Import-Package: javax.annotation.security;version="1.2.0",
javax.ws.rs;version="2.0.0",
javax.ws.rs.core;version="2.0.0",
javax.xml.bind.annotation,
+ org.apache.cxf.jaxrs.ext.multipart;version="3.0.1",
org.eclipse.osee.framework.core.data,
org.eclipse.osee.framework.core.enums,
org.eclipse.osee.framework.core.exception,
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
index d0f90433da..ad2ea2d917 100644
--- 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
@@ -17,6 +17,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.eclipse.osee.orcs.writer.model.config.OrcsWriterInputConfig;
import org.eclipse.osee.orcs.writer.model.reader.OwCollector;
@@ -62,4 +63,12 @@ public interface OrcsWriterEndpoint {
@Consumes({MediaType.APPLICATION_JSON})
Response getOrcsWriterPersist(OwCollector collector);
+ @POST
+ @Path("writer/validate/excel")
+ Response validateExcelInput(Attachment attachment);
+
+ @POST
+ @Path("writer/excel")
+ Response persistExcelInput(Attachment attachment);
+
}
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 7c94c825d2..cb50b6cb7a 100644
--- a/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF
@@ -12,6 +12,8 @@ Import-Package: com.google.common.base;version="15.0.0",
javax.ws.rs,
javax.ws.rs.core,
javax.ws.rs.ext,
+ org.apache.cxf.io,
+ org.apache.cxf.jaxrs.ext.multipart,
org.codehaus.jackson;version="1.9.13",
org.codehaus.jackson.map;version="1.9.13",
org.eclipse.core.runtime,
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
index 74ace2730c..4e514389f3 100644
--- 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
@@ -7,6 +7,7 @@
<link rel="stylesheet" type="text/css"
href="/ajax/libs/bootstrap/3.3.2/css/bootstrap.min.css"></link>
+<link rel="stylesheet" type="text/css" href="writer.css"></link>
<title>OSEE - ORCS Writer</title>
@@ -59,11 +60,10 @@
</div>
<div class="container">
- <label>Input: </label><br /><br />
+ <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 />
+ <button type="button" ngf-select ng-model="file" ngf-multiple="false">Select File</button> {{file.name}}
+ <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>
@@ -72,8 +72,8 @@
<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>
+ <button type="button" class="btn btn-primary" ng-click="run(true)">Validate</button>
+ <button type="submit" class="btn btn-primary" ng-click="run(false)">Execute</button>
</div>
<div class="container-fluid well" ng-show="message">
@@ -81,6 +81,10 @@
</div>
<script src="/ajax/libs/angularjs/1.2.28/angular.min.js"></script>
+ <script
+ src="/ajax/libs/ng-file-upload/6.0.4/ng-file-upload-shim.min.js"></script>
+ <script src="/ajax/libs/ng-file-upload/6.0.4/ng-file-upload.min.js"></script>
<script src="orcsWriter.js"></script>
+ </div>
</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
index f854e0f0ad..c597022630 100644
--- 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
@@ -1,6 +1,6 @@
-var app = angular.module('OrcsWriterApp', []);
+var app = angular.module('OrcsWriterApp', ['ngFileUpload']);
-app.controller("FormController", function($scope, $http) {
+app.controller("FormController", ['$scope', '$http', 'Upload', function($scope, $http, Upload) {
$scope.formData = {
filename : '',
@@ -16,17 +16,6 @@ app.controller("FormController", function($scope, $http) {
$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 = "";
@@ -36,7 +25,7 @@ app.controller("FormController", function($scope, $http) {
url = "../../writer";
}
var data = {};
- if (!$scope.formData.json && !$scope.formData.filename) {
+ if (!$scope.formData.json && !$scope.file) {
$scope.message = "ERROR: Must select Excel or enter JSON";
} else if ($scope.formData.json) {
$scope.message = "Processing JSON";
@@ -61,9 +50,10 @@ app.controller("FormController", function($scope, $http) {
}
$scope.message += '\n' + message;
});
- } else if ($scope.formData.filename) {
- $scope.message = "Processing Excel - NOT IMPLEMENTED YET";
- $scope.message += '\nExcel Output Generated';
+ } else if ($scope.file) {
+ Upload.upload({
+ url: url + '/excel',
+ file: $scope.file});
}
}
-});
+}]);
diff --git a/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/writer/writer.css b/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/writer/writer.css
new file mode 100644
index 0000000000..76560ef829
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest/OSEE-INF/web/writer/writer.css
@@ -0,0 +1,12 @@
+.drop-box {
+ background: #F8F8F8;
+ border: 5px dashed #DDD;
+ width: 200px;
+ height: 65px;
+ text-align: center;
+ padding-top: 25px;
+ margin: 10px;
+}
+.dragover {
+ border: 5px dashed blue;
+}
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
index 09745a9fde..c476f22f27 100644
--- 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
@@ -10,14 +10,17 @@
*******************************************************************************/
package org.eclipse.osee.orcs.rest.internal.writer;
+import java.io.InputStream;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.StreamingOutput;
+import org.apache.cxf.jaxrs.ext.multipart.Attachment;
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.OrcsWriterExcelReader;
import org.eclipse.osee.orcs.writer.model.config.OrcsWriterInputConfig;
import org.eclipse.osee.orcs.writer.model.reader.OwCollector;
@@ -88,4 +91,55 @@ public class OrcsWriterEndpointImpl implements OrcsWriterEndpoint {
return Response.ok().entity(results.toString()).build();
}
+ @Override
+ public Response validateExcelInput(Attachment attachment) {
+ InputStream stream = attachment.getObject(InputStream.class);
+
+ XResultData results = new XResultData();
+ OrcsWriterExcelReader reader = new OrcsWriterExcelReader(results);
+ try {
+ reader.run(stream);
+ } catch (Exception ex) {
+ throw new OseeWrappedException(ex);
+ }
+ OwCollector collector = reader.getCollector();
+ OrcsCollectorValidator validator = new OrcsCollectorValidator(orcsApi, collector);
+ results = validator.run();
+ if (results.isErrors()) {
+ throw new OseeArgumentException(results.toString());
+ }
+ OrcsCollectorWriter writer = new OrcsCollectorWriter(orcsApi, collector, results);
+ writer.run();
+ if (results.isErrors()) {
+ return Response.notModified().entity(results.toString()).build();
+ }
+ return Response.ok().entity(results.toString()).build();
+ }
+
+ @Override
+ public Response persistExcelInput(Attachment attachment) {
+ InputStream stream = attachment.getObject(InputStream.class);
+
+ XResultData results = new XResultData();
+ OrcsWriterExcelReader reader = new OrcsWriterExcelReader(results);
+ try {
+ reader.run(stream);
+ } catch (Exception ex) {
+ throw new OseeWrappedException(ex);
+ }
+ OwCollector collector = reader.getCollector();
+
+ OrcsCollectorValidator validator = new OrcsCollectorValidator(orcsApi, collector);
+ results = validator.run();
+ if (results.isErrors()) {
+ throw new OseeArgumentException(results.toString());
+ }
+ OrcsCollectorWriter writer = new OrcsCollectorWriter(orcsApi, collector, results);
+ writer.run();
+ if (results.isErrors()) {
+ return Response.notModified().entity(results.toString()).build();
+ }
+ return Response.ok().entity(results.toString()).build();
+ }
+
}
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
index 36ced36f4c..0a3df914b7 100644
--- 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
@@ -34,7 +34,7 @@ public class OrcsWriterExcelReader {
private OwCollector collector;
private final XResultData result;
- public OrcsWriterExcelReader(XResultData result) throws Exception {
+ public OrcsWriterExcelReader(XResultData result) {
this.result = result;
}

Back to the top