Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.osee.ote.rest/src/org/eclipse/osee/ote/rest/internal/OteRunTestResource.java')
-rw-r--r--plugins/org.eclipse.osee.ote.rest/src/org/eclipse/osee/ote/rest/internal/OteRunTestResource.java111
1 files changed, 111 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.ote.rest/src/org/eclipse/osee/ote/rest/internal/OteRunTestResource.java b/plugins/org.eclipse.osee.ote.rest/src/org/eclipse/osee/ote/rest/internal/OteRunTestResource.java
new file mode 100644
index 00000000000..09201f55079
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.rest/src/org/eclipse/osee/ote/rest/internal/OteRunTestResource.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.ote.rest.internal;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.ExecutionException;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.UriBuilderException;
+import javax.ws.rs.core.UriInfo;
+
+import org.eclipse.osee.framework.jdk.core.type.IPropertyStore;
+import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
+import org.eclipse.osee.ote.Configuration;
+import org.eclipse.osee.ote.core.ServiceUtility;
+import org.eclipse.osee.ote.core.environment.TestEnvironmentInterface;
+import org.eclipse.osee.ote.core.framework.command.RunTests;
+import org.eclipse.osee.ote.rest.model.KeyValue;
+import org.eclipse.osee.ote.rest.model.OTEJobStatus;
+import org.eclipse.osee.ote.rest.model.OTETestRun;
+import org.eclipse.osee.ote.rest.model.Properties;
+
+/**
+ * @author Andrew M. Finkbeiner
+ */
+@Path("run")
+public class OteRunTestResource {
+
+ // Allows to insert contextual objects into the class,
+ // e.g. ServletContext, Request, Response, UriInfo
+ @Context
+ UriInfo uriInfo;
+ @Context
+ Request request;
+
+ @GET
+ @Produces({MediaType.TEXT_HTML})
+ public String getCurrentRunStatus() throws MalformedURLException, IllegalArgumentException, UriBuilderException, InterruptedException, ExecutionException {
+ return "hello";//getDataStore().getConfiguration(uriInfo);
+ }
+
+ @POST
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public OTEJobStatus run(OTETestRun tests) throws IOException, InterruptedException, ExecutionException {
+ TestEnvironmentInterface env = ServiceUtility.getService(TestEnvironmentInterface.class);
+ OTEJobStatus status = new OTEJobStatus();
+ if(env == null){
+ status.setSuccess(false);
+ status.setJobComplete(true);
+ status.setErrorLog("Failed to aquire TestEnvironmentInterface.");
+ } else {
+ UUID id = UUID.randomUUID();
+ Configuration configuration = TranslateUtil.translateToOtherConfig(tests.getJarConfiguration());
+ RunTests envTestRun = new RunTests(id.toString(), id, configuration, propertyStoreConversion(tests.getGlobalProperties()), propertyStoreConversion(tests.getTests()));
+ OteRunTestCommands commands = ServiceUtility.getService(OteRunTestCommands.class);
+ if(commands != null){
+ commands.putCommand(id.toString(), envTestRun);
+ }
+ env.addCommand(envTestRun);
+ status.setJobId(id.toString());
+ }
+ return status;
+ }
+
+ @Path("{uuid}")
+ public OteRunTestResourceItem getConfiguration(@PathParam("uuid") String id) {
+ return new OteRunTestResourceItem(uriInfo, request, id);
+ }
+
+ public IPropertyStore propertyStoreConversion(Properties properties){
+ IPropertyStore store = new PropertyStore();
+ for(KeyValue pair:properties.getPairs()){
+ if(pair.getValue() == null){
+ store.put(pair.getKey(), pair.getValues().toArray(new String[0]));
+ } else {
+ store.put(pair.getKey(), pair.getValue());
+ }
+ }
+ return store;
+ }
+
+ public List<IPropertyStore> propertyStoreConversion(List<Properties> properties){
+ List<IPropertyStore> stores = new ArrayList<IPropertyStore>();
+ for(Properties prop:properties){
+ stores.add(propertyStoreConversion(prop));
+ }
+ return stores;
+ }
+
+}

Back to the top