Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Joy2015-09-01 22:13:48 +0000
committerAngel Avila2015-09-12 01:05:42 +0000
commitb7b88057e54671a7ad1d43622cd622f8f92b9062 (patch)
tree8b80e228649224df84d363c3b92e0ecc9a7a216a /plugins/org.eclipse.osee.ats.rest
parentd32a36c938e84d9bbe119c41a1ff46935b84bb9f (diff)
downloadorg.eclipse.osee-b7b88057e54671a7ad1d43622cd622f8f92b9062.tar.gz
org.eclipse.osee-b7b88057e54671a7ad1d43622cd622f8f92b9062.tar.xz
org.eclipse.osee-b7b88057e54671a7ad1d43622cd622f8f92b9062.zip
feature[ats_ATS217738]: Allow ATS Rules to generate configured tasks
Change-Id: I9e57184d311b8d65f97c2c8d2bb1a91c433e5230 Signed-off-by: Mark Joy <mark.joy@boeing.com>
Diffstat (limited to 'plugins/org.eclipse.osee.ats.rest')
-rw-r--r--plugins/org.eclipse.osee.ats.rest/.project6
-rw-r--r--plugins/org.eclipse.osee.ats.rest/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.ats.rest/OSEE-INF/support/ruleDefinitions.ats3
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/AtsApplication.java6
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/UpdateAtsConfiguration.java22
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/AtsActionEndpointImpl.java (renamed from plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/ActionResource.java)14
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/AtsRuleEndpointImpl.java98
7 files changed, 139 insertions, 11 deletions
diff --git a/plugins/org.eclipse.osee.ats.rest/.project b/plugins/org.eclipse.osee.ats.rest/.project
index 6c6bff4972f..06000bdc368 100644
--- a/plugins/org.eclipse.osee.ats.rest/.project
+++ b/plugins/org.eclipse.osee.ats.rest/.project
@@ -6,6 +6,11 @@
</projects>
<buildSpec>
<buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
@@ -29,5 +34,6 @@
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
</projectDescription>
diff --git a/plugins/org.eclipse.osee.ats.rest/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.rest/META-INF/MANIFEST.MF
index e2f7c08600c..db91b050135 100644
--- a/plugins/org.eclipse.osee.ats.rest/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.ats.rest/META-INF/MANIFEST.MF
@@ -27,6 +27,7 @@ Import-Package: com.google.gson;version="2.1.0",
org.eclipse.osee.ats.core.workflow.transition,
org.eclipse.osee.ats.impl,
org.eclipse.osee.ats.impl.config,
+ org.eclipse.osee.ats.impl.util,
org.eclipse.osee.ats.impl.workitem,
org.eclipse.osee.framework.core.data,
org.eclipse.osee.framework.core.enums,
diff --git a/plugins/org.eclipse.osee.ats.rest/OSEE-INF/support/ruleDefinitions.ats b/plugins/org.eclipse.osee.ats.rest/OSEE-INF/support/ruleDefinitions.ats
new file mode 100644
index 00000000000..d01007c296f
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.rest/OSEE-INF/support/ruleDefinitions.ats
@@ -0,0 +1,3 @@
+// Rule Definitions file
+// Define all rule definitions below
+
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/AtsApplication.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/AtsApplication.java
index e1c8ba37336..8cc56769cc5 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/AtsApplication.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/AtsApplication.java
@@ -35,9 +35,10 @@ import org.eclipse.osee.ats.rest.internal.config.VersionResource;
import org.eclipse.osee.ats.rest.internal.cpa.CpaResource;
import org.eclipse.osee.ats.rest.internal.cpa.CpaServiceRegistry;
import org.eclipse.osee.ats.rest.internal.notify.AtsNotifyEndpointImpl;
-import org.eclipse.osee.ats.rest.internal.workitem.ActionResource;
import org.eclipse.osee.ats.rest.internal.workitem.ActionUiResource;
import org.eclipse.osee.ats.rest.internal.workitem.AtsTaskEndpointImpl;
+import org.eclipse.osee.ats.rest.internal.workitem.AtsActionEndpointImpl;
+import org.eclipse.osee.ats.rest.internal.workitem.AtsRuleEndpointImpl;
import org.eclipse.osee.ats.rest.internal.workitem.StateResource;
import org.eclipse.osee.framework.jdk.core.type.IResourceRegistry;
import org.eclipse.osee.framework.jdk.core.type.ResourceRegistry;
@@ -92,7 +93,8 @@ public class AtsApplication extends Application {
singletons.add(new InsertionResource(atsServer));
singletons.add(new InsertionActivityResource(atsServer));
- singletons.add(new ActionResource(atsServer, orcsApi));
+ singletons.add(new AtsActionEndpointImpl(atsServer, orcsApi));
+ singletons.add(new AtsRuleEndpointImpl(atsServer));
singletons.add(new StateResource(atsServer));
singletons.add(new ConvertResource(atsServer));
singletons.add(new CpaResource(orcsApi, atsServer, cpaRegistry));
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/UpdateAtsConfiguration.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/UpdateAtsConfiguration.java
index ae55f2fe925..c5d84b59d5b 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/UpdateAtsConfiguration.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/UpdateAtsConfiguration.java
@@ -16,6 +16,7 @@ import java.util.List;
import org.eclipse.osee.ats.api.config.AtsAttributeValueColumn;
import org.eclipse.osee.ats.api.config.AtsViews;
import org.eclipse.osee.ats.api.data.AtsArtifactToken;
+import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
import org.eclipse.osee.ats.api.util.ColorColumns;
import org.eclipse.osee.ats.core.column.ColorTeamColumn;
import org.eclipse.osee.ats.core.users.AtsCoreUsers;
@@ -29,6 +30,7 @@ import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.exception.OseeWrappedException;
import org.eclipse.osee.framework.core.util.XResultData;
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.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
@@ -55,11 +57,29 @@ public class UpdateAtsConfiguration {
public XResultData createUpdateConfig(XResultData rd) {
ArtifactReadable userArt = atsServer.getArtifact(AtsCoreUsers.SYSTEM_USER);
- getOrCreateConfigFolder(userArt, rd);
+ ArtifactId configFolder = getOrCreateConfigFolder(userArt, rd);
getOrCreateAtsConfig(userArt, rd);
+ importRuleDefinitions(userArt, configFolder, rd);
return rd;
}
+ private void importRuleDefinitions(ArtifactReadable userArt, ArtifactId configFolderArt, XResultData rd) {
+ try {
+ TransactionBuilder tx = atsServer.getOrcsApi().getTransactionFactory().createTransaction(CoreBranches.COMMON,
+ userArt, "Add Rule Definitions");
+ ArtifactId ruleDefConfigArt = tx.createArtifact(AtsArtifactToken.RuleDefinitions);
+ String ruleDefs = RestUtil.getResource("support/ruleDefinitions.ats");
+ tx.createAttribute(ruleDefConfigArt, AtsAttributeTypes.DslSheet, ruleDefs);
+ if (rd.isErrors()) {
+ throw new OseeStateException(rd.toString());
+ }
+ tx.relate(configFolderArt, CoreRelationTypes.Default_Hierarchical__Child, ruleDefConfigArt);
+ tx.commit();
+ } catch (Exception ex) {
+ throw new OseeWrappedException("Error loading column ruleDefinitions.ats file", ex);
+ }
+ }
+
private TransactionBuilder setConfigAttributes(ArtifactReadable configArt, ArtifactReadable userArt, TransactionBuilder tx, XResultData rd) throws OseeCoreException {
try {
String viewsJson = RestUtil.getResource("support/views.json");
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/ActionResource.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/AtsActionEndpointImpl.java
index 72b2cbd680e..f58cb98a10e 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/ActionResource.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/AtsActionEndpointImpl.java
@@ -48,13 +48,13 @@ import org.eclipse.osee.orcs.data.ArtifactReadable;
* @author Donald G. Dunne
*/
@Path("action")
-public final class ActionResource implements AtsActionEndpointApi {
+public final class AtsActionEndpointImpl implements AtsActionEndpointApi {
private final IAtsServer atsServer;
private final OrcsApi orcsApi;
private static final String ATS_UI_ACTION_PREFIX = "/ui/action/UUID";
- public ActionResource(IAtsServer atsServer, OrcsApi orcsApi) {
+ public AtsActionEndpointImpl(IAtsServer atsServer, OrcsApi orcsApi) {
this.atsServer = atsServer;
this.orcsApi = orcsApi;
}
@@ -74,7 +74,6 @@ public final class ActionResource implements AtsActionEndpointApi {
@Path("{ids}")
@IdentityView
@GET
- @Produces({MediaType.APPLICATION_JSON})
public List<IAtsWorkItem> getAction(@PathParam("ids") String ids) throws Exception {
List<IAtsWorkItem> workItems = atsServer.getWorkItemListByIds(ids);
return workItems;
@@ -166,8 +165,8 @@ public final class ActionResource implements AtsActionEndpointApi {
return RestUtil.returnBadRequest("actionableItems is not valid");
}
List<IAtsActionableItem> aias = new ArrayList<IAtsActionableItem>();
- ArtifactReadable aiArt =
- atsServer.getQuery().andTypeEquals(AtsArtifactTypes.ActionableItem).andNameEquals(actionableItems).getResults().getOneOrNull();
+ ArtifactReadable aiArt = atsServer.getQuery().andTypeEquals(AtsArtifactTypes.ActionableItem).andNameEquals(
+ actionableItems).getResults().getOneOrNull();
if (aiArt == null) {
return RestUtil.returnBadRequest(String.format("actionableItems [%s] is not valid", actionableItems));
}
@@ -209,9 +208,8 @@ public final class ActionResource implements AtsActionEndpointApi {
}
// create action
- IAtsAction action =
- atsServer.getActionFactory().createAction(atsUser, title, description, changeType, priority, false, null,
- aias, new Date(), atsUser, null, changes).getFirst();
+ IAtsAction action = atsServer.getActionFactory().createAction(atsUser, title, description, changeType, priority,
+ false, null, aias, new Date(), atsUser, null, changes).getFirst();
changes.execute();
// Redirect to action ui
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/AtsRuleEndpointImpl.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/AtsRuleEndpointImpl.java
new file mode 100644
index 00000000000..4442515d64c
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/AtsRuleEndpointImpl.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * 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.rest.internal.workitem;
+
+import java.util.LinkedList;
+import java.util.List;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+import org.eclipse.osee.ats.api.IAtsConfigObject;
+import org.eclipse.osee.ats.api.IAtsWorkItem;
+import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
+import org.eclipse.osee.ats.api.util.IAtsChangeSet;
+import org.eclipse.osee.ats.api.workdef.AddRuleData;
+import org.eclipse.osee.ats.api.workdef.IAtsRuleDefinition;
+import org.eclipse.osee.ats.api.workdef.RunRuleData;
+import org.eclipse.osee.ats.api.workdef.RunRuleResults;
+import org.eclipse.osee.ats.api.workflow.AtsRuleEndpointApi;
+import org.eclipse.osee.ats.core.users.AtsCoreUsers;
+import org.eclipse.osee.ats.impl.IAtsServer;
+import org.eclipse.osee.ats.impl.util.WorkflowRuleRunner;
+import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
+import org.eclipse.osee.orcs.data.ArtifactReadable;
+
+/**
+ * @author Mark Joy
+ */
+public class AtsRuleEndpointImpl implements AtsRuleEndpointApi {
+ private final IAtsServer atsServer;
+
+ public AtsRuleEndpointImpl(IAtsServer atsServer) {
+ this.atsServer = atsServer;
+ }
+
+ @GET
+ @Path("rule")
+ @Override
+ public List<IAtsRuleDefinition> get() throws Exception {
+ List<IAtsRuleDefinition> rules = new LinkedList<>(atsServer.getWorkDefAdmin().getAllRuleDefinitions());
+ return rules;
+ }
+
+ @POST
+ @Path("rulerun")
+ @Override
+ public RunRuleResults runWorkflowRules(RunRuleData runRuleData) {
+ RunRuleResults ruleResults = new RunRuleResults();
+
+ List<IAtsWorkItem> workItemsCreated = new LinkedList<>();
+ for (long workflowUuid : runRuleData.getWorkItemUuids()) {
+ ArtifactReadable artifact = atsServer.getArtifactByUuid(workflowUuid);
+ IAtsWorkItem workItem = atsServer.getWorkItemFactory().getWorkItem(artifact);
+ if (workItem == null) {
+ throw new OseeArgumentException("Workflow of uuid [%d] does not exist", workflowUuid);
+ }
+ if (!workItem.isTeamWorkflow()) {
+ throw new OseeArgumentException("Workflow of uuid [%d] is not a Team Workflow", workflowUuid);
+ }
+ workItemsCreated.add(workItem);
+ }
+ if (!workItemsCreated.isEmpty()) {
+ WorkflowRuleRunner runner =
+ new WorkflowRuleRunner(runRuleData.getRuleEventType(), workItemsCreated, atsServer, ruleResults);
+ runner.run();
+ }
+ return ruleResults;
+ }
+
+ @POST
+ @Path("rule")
+ @Override
+ public Response addRuleToConfig(AddRuleData setRuleData) {
+ ArtifactReadable artifact = atsServer.getArtifactByUuid(setRuleData.getConfigItemUuid());
+ List<String> ruleList = artifact.getAttributeValues(AtsAttributeTypes.RuleDefinition);
+ if (!ruleList.contains(setRuleData.getRuleName())) {
+ IAtsChangeSet changes =
+ atsServer.getStoreService().createAtsChangeSet("Update artifact with Rule", AtsCoreUsers.SYSTEM_USER);
+ changes.addAttribute(atsServer.getConfigItemFactory().getConfigObject(artifact),
+ AtsAttributeTypes.RuleDefinition, setRuleData.getRuleName());
+ changes.execute();
+ IAtsConfigObject soleByUuid = atsServer.getConfig().getSoleByUuid(setRuleData.getConfigItemUuid());
+
+ atsServer.getConfig().invalidate(soleByUuid);
+ }
+
+ return Response.ok().build();
+ }
+
+}

Back to the top