Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2020-03-14 20:40:20 +0000
committerRyan D. Brooks2020-12-15 21:40:25 +0000
commit0f78077c7c514d3d855c93f45d50f7e75316292f (patch)
treef1c75d63dac819780f5c30d8a61148d0a2234446
parent99cbd93e20a65f2548a6fa9f4d797cd98b1c7d45 (diff)
downloadorg.eclipse.osee-0f78077c7c514d3d855c93f45d50f7e75316292f.tar.gz
org.eclipse.osee-0f78077c7c514d3d855c93f45d50f7e75316292f.tar.xz
org.eclipse.osee-0f78077c7c514d3d855c93f45d50f7e75316292f.zip
refinement[TW16727]: Improve performance of AtsWorldEndpoint search
-rw-r--r--plugins/org.eclipse.osee.ats.api/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsAttributeTypes.java2
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/AtsWorldEndpointApi.java9
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/world/AtsWorldEndpointImpl.java35
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/world/AtsWorldResultRowOperation.java46
5 files changed, 56 insertions, 37 deletions
diff --git a/plugins/org.eclipse.osee.ats.api/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.api/META-INF/MANIFEST.MF
index 293d0931ee6..d8541f7dc72 100644
--- a/plugins/org.eclipse.osee.ats.api/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.ats.api/META-INF/MANIFEST.MF
@@ -79,6 +79,7 @@ Import-Package: com.fasterxml.jackson.annotation,
org.eclipse.osee.jaxrs.mvc,
org.eclipse.osee.jdbc,
org.eclipse.osee.logger,
+ org.eclipse.osee.orcs.data,
org.eclipse.osee.orcs.rest.model,
org.osgi.framework,
org.osgi.service.event
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsAttributeTypes.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsAttributeTypes.java
index 76f21c91ed6..03742f6951f 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsAttributeTypes.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsAttributeTypes.java
@@ -91,7 +91,7 @@ public interface AtsAttributeTypes {
AttributeTypeString CreatedBy = ats.createString(1152921504606847174L, "ats.Created By", MediaType.TEXT_PLAIN, "UserId of the user who created the workflow.");
AttributeTypeDate CreatedDate = ats.createDate(1152921504606847173L, "ats.Created Date", AttributeTypeToken.TEXT_CALENDAR, "Date the workflow was created.");
AttributeTypeString CurrentState = ats.createString(1152921504606847192L, "ats.Current State", MediaType.TEXT_PLAIN, "Current state of workflow state machine.");
- AttributeTypeString CurrentStateType = ats.createString(1152921504606847147L, "ats.Current State Type", MediaType.TEXT_PLAIN, "Type of Current State: InWork, Completed or Cancelled.");
+ AttributeTypeString CurrentStateType = ats.createString(1152921504606847147L, "ats.Current State Type", MediaType.TEXT_PLAIN, "Type of Current State: Working, Completed or Cancelled.");
AttributeTypeString Decision = ats.createString(1152921504606847221L, "ats.Decision", MediaType.TEXT_PLAIN, "Option selected during decision review.");
AttributeTypeString DecisionReviewOptions = ats.createString(1152921504606847220L, "ats.Decision Review Options", MediaType.TEXT_PLAIN, "Options available for selection in review. Each line is a separate option. Format: <option name>;<state to transition to>;<assignee>\")");
AttributeTypeBoolean Default = ats.createBoolean(1152921875139002538L, "ats.Default", MediaType.TEXT_PLAIN, "Default");
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/AtsWorldEndpointApi.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/AtsWorldEndpointApi.java
index c323b82eea4..95dd6e61890 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/AtsWorldEndpointApi.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/AtsWorldEndpointApi.java
@@ -14,18 +14,21 @@
package org.eclipse.osee.ats.api.workflow;
import java.util.Collection;
+import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import org.eclipse.nebula.widgets.xviewer.core.model.CustomizeData;
import org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.ats.api.query.AtsSearchData;
import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.jdk.core.result.ResultRows;
+import org.eclipse.osee.orcs.data.ArtifactReadable;
/**
* @author Donald G. Dunne
@@ -87,4 +90,10 @@ public interface AtsWorldEndpointApi {
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
ResultRows searchNew(AtsSearchData atsSearchData);
+
+ @GET
+ @Path("/{program}/workflowsInState")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ List<ArtifactReadable> teamWfByProgram(@PathParam("program") ArtifactId program, @QueryParam("state") String state);
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/world/AtsWorldEndpointImpl.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/world/AtsWorldEndpointImpl.java
index 4753cfd347c..c5ba2048432 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/world/AtsWorldEndpointImpl.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/world/AtsWorldEndpointImpl.java
@@ -30,6 +30,7 @@ import org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.ats.api.column.IAtsColumnId;
import org.eclipse.osee.ats.api.config.AtsConfigurations;
import org.eclipse.osee.ats.api.data.AtsArtifactTypes;
+import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
import org.eclipse.osee.ats.api.data.AtsRelationTypes;
import org.eclipse.osee.ats.api.query.AtsSearchData;
import org.eclipse.osee.ats.api.user.AtsUser;
@@ -39,12 +40,16 @@ import org.eclipse.osee.ats.core.column.AtsColumnId;
import org.eclipse.osee.ats.rest.AtsApiServer;
import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.jdk.core.result.ResultRows;
import org.eclipse.osee.framework.jdk.core.util.AHTML;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.jdk.core.util.Conditions;
import org.eclipse.osee.framework.jdk.core.util.ElapsedTime;
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.search.QueryBuilder;
/**
* @author Donald G. Dunne
@@ -54,12 +59,15 @@ public class AtsWorldEndpointImpl implements AtsWorldEndpointApi {
private final AtsApiServer atsApiServer;
private final AtsApi atsApi;
+ private final OrcsApi orcsApi;
+
public final static List<String> namespaces =
Arrays.asList("WorldXViewer", "BacklogXViewer", "SprintXViewer", "GoalXViewer", "TaskXViewer");
public AtsWorldEndpointImpl(AtsApiServer atsApiServer) {
this.atsApiServer = atsApiServer;
this.atsApi = atsApiServer;
+ this.orcsApi = atsServer.getOrcsApi();
}
@Override
@@ -266,16 +274,31 @@ public class AtsWorldEndpointImpl implements AtsWorldEndpointApi {
@Override
public ResultRows search(AtsSearchData atsSearchData) {
- AtsWorldResultRowOperation op = new AtsWorldResultRowOperation(atsApi, atsSearchData);
- ResultRows rows = op.run();
- return rows;
+ AtsWorldResultRowOperation op = new AtsWorldResultRowOperation(atsApi, atsServer.getOrcsApi(), atsSearchData);
+ return op.run();
}
@Override
public ResultRows searchNew(AtsSearchData atsSearchData) {
- AtsWorldResultRowOperation op = new AtsWorldResultRowOperation(atsApi, atsSearchData);
+ AtsWorldResultRowOperation op = new AtsWorldResultRowOperation(atsApi, atsServer.getOrcsApi(), atsSearchData);
op.setNew(true);
- ResultRows rows = op.run();
- return rows;
+ return op.run();
+ }
+
+ @Override
+ public List<ArtifactReadable> teamWfByProgram(ArtifactId program, String state) {
+ QueryBuilder query = orcsApi.getQueryFactory().fromBranch(CoreBranches.COMMON);
+
+ Collection<ArtifactId> teamDefs =
+ query.andTypeEquals(AtsArtifactTypes.TeamDefinition).andAttributeIs(AtsAttributeTypes.ProgramId,
+ program.getIdString()).asArtifactIds();
+ Collection<String> teamDefStrs = Collections.transform(teamDefs, String::valueOf);
+
+ query = query.andAttributeIs(AtsAttributeTypes.TeamDefinitionReference, teamDefStrs);
+
+ if (Strings.isValid(state)) {
+ query.andAttributeIs(AtsAttributeTypes.CurrentStateType, state);
+ }
+ return query.asArtifacts();
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/world/AtsWorldResultRowOperation.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/world/AtsWorldResultRowOperation.java
index 01e691ad1f5..85fd5821f93 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/world/AtsWorldResultRowOperation.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/world/AtsWorldResultRowOperation.java
@@ -20,13 +20,15 @@ import org.eclipse.nebula.widgets.xviewer.core.model.XViewerColumn;
import org.eclipse.osee.ats.api.AtsApi;
import org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.ats.api.data.AtsArtifactTypes;
+import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
import org.eclipse.osee.ats.api.demo.AtsDemoOseeTypes;
import org.eclipse.osee.ats.api.query.AtsSearchData;
-import org.eclipse.osee.ats.api.workdef.StateType;
-import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.ArtifactToken;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.jdk.core.result.ResultRow;
import org.eclipse.osee.framework.jdk.core.result.ResultRows;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
+import org.eclipse.osee.orcs.OrcsApi;
/**
* @author Donald G. Dunne
@@ -34,11 +36,13 @@ import org.eclipse.osee.framework.jdk.core.result.ResultRows;
public class AtsWorldResultRowOperation {
private final AtsApi atsApi;
+ private final OrcsApi orcsApi;
private final AtsSearchData atsSearchData;
private boolean teamWfsInState;
- public AtsWorldResultRowOperation(AtsApi atsApi, AtsSearchData atsSearchData) {
+ public AtsWorldResultRowOperation(AtsApi atsApi, OrcsApi orcsApi, AtsSearchData atsSearchData) {
this.atsApi = atsApi;
+ this.orcsApi = orcsApi;
this.atsSearchData = atsSearchData;
AtsDemoOseeTypes.Action.getName();
}
@@ -49,7 +53,7 @@ public class AtsWorldResultRowOperation {
rows.getRd().error("CustomizeData can not be null or empty.");
}
- Collection<ArtifactToken> artifacts = getArtifacts();
+ Collection<? extends ArtifactToken> artifacts = getArtifacts();
List<XViewerColumn> showCols = new ArrayList<>();
for (XViewerColumn col : atsSearchData.getCustomizeData().getColumnData().getColumns()) {
if (col.isShow()) {
@@ -68,23 +72,14 @@ public class AtsWorldResultRowOperation {
return rows;
}
- private Collection<ArtifactToken> getArtifacts() {
+ private Collection<? extends ArtifactToken> getArtifacts() {
if (teamWfsInState) {
- StringBuilder sb = new StringBuilder("\'");
- for (Long teamDefId : atsSearchData.getTeamDefIds()) {
- sb.append(teamDefId.toString());
- sb.append("','");
- }
- String teamIds = sb.toString().replaceFirst(",'$", "");
- sb = new StringBuilder("\'");
- for (StateType type : atsSearchData.getStateTypes()) {
- sb.append(type.toString());
- sb.append("','");
- }
- String stateType = sb.toString().replaceFirst(",'$", "");
- String query = String.format(getQuery(), teamIds, stateType);
- List<ArtifactId> artIds = atsApi.getQueryService().getArtifactIdsFromQuery(query);
- return atsApi.getQueryService().getArtifacts(artIds, atsApi.getAtsBranch());
+ Collection<String> teamDefs = Collections.transform(atsSearchData.getTeamDefIds(), String::valueOf);
+ Collection<String> stateTypes = Collections.transform(atsSearchData.getStateTypes(), String::valueOf);
+
+ return orcsApi.getQueryFactory().fromBranch(CoreBranches.COMMON).andAttributeIs(
+ AtsAttributeTypes.TeamDefinitionReference, teamDefs).andAttributeIs(AtsAttributeTypes.CurrentStateType,
+ stateTypes).asArtifacts();
} else {
return atsApi.getQueryService().getArtifacts(atsSearchData, null);
}
@@ -102,13 +97,4 @@ public class AtsWorldResultRowOperation {
public void setNew(boolean teamWfsInState) {
this.teamWfsInState = teamWfsInState;
}
-
- public String getQuery() {
- return "SELECT distinct art.art_id as art_id FROM osee_artifact art, osee_txs txs, OSEE_ATTRIBUTE attr \n" + //
- "WHERE attr.gamma_id = txs.gamma_id AND txs.tx_current = 1 AND txs.branch_id = 570 and \n" + //
- "attr.ART_ID = art.ART_ID and attr.ATTR_TYPE_ID = 4730961339090285773 and attr.VALUE \n IN (%s) \n" + //
- "AND art.art_id IN (SELECT distinct art.art_id AS art_id FROM osee_artifact art, osee_txs txs, OSEE_ATTRIBUTE attr \n" + //
- "WHERE attr.gamma_id = txs.gamma_id AND txs.tx_current = 1 AND txs.branch_id = 570 and \n" + //
- "attr.ART_ID = art.ART_ID and attr.ATTR_TYPE_ID = 1152921504606847147 and attr.VALUE in (%s))"; //
- }
-}
+} \ No newline at end of file

Back to the top