Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2017-01-31 12:54:47 -0500
committerdonald.g.dunne2017-02-06 13:24:44 -0500
commit2347c264474a5c56fe434631d4324986d9ce459d (patch)
treed2f7176e5e13df32fe15fb451f76a6bd501d591c
parent2b1a3ac135c97c6619a991b6a661ed657e36b51d (diff)
downloadorg.eclipse.osee-2347c264474a5c56fe434631d4324986d9ce459d.tar.gz
org.eclipse.osee-2347c264474a5c56fe434631d4324986d9ce459d.tar.xz
org.eclipse.osee-2347c264474a5c56fe434631d4324986d9ce459d.zip
bug[ats_ATS344961]: Improve AgileFeatureGroupColumn performance
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsObjects.java33
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/agile/AgileFeatureGroupColumn.java48
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/ev/WorkPackageSearchProvider.java5
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java86
4 files changed, 143 insertions, 29 deletions
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsObjects.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsObjects.java
index 60474d639f..ac3b68cebf 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsObjects.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsObjects.java
@@ -15,8 +15,11 @@ import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.osee.ats.api.IAtsObject;
+import org.eclipse.osee.ats.api.IAtsServices;
import org.eclipse.osee.ats.api.IAtsWorkItem;
+import org.eclipse.osee.ats.api.data.AtsArtifactTypes;
import org.eclipse.osee.ats.api.workflow.IAtsAction;
+import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow;
import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.jdk.core.util.Collections;
@@ -99,10 +102,34 @@ public class AtsObjects {
return uuids;
}
- public static Collection<ArtifactId> getArtifacts(Collection<? extends IAtsObject> atsObjects) {
+ public static Collection<ArtifactId> getArtifacts(Collection<?> objects) {
List<ArtifactId> artifacts = new LinkedList<>();
- for (IAtsObject task : atsObjects) {
- artifacts.add(task.getStoreObject());
+ for (Object object : objects) {
+ if (object instanceof ArtifactId) {
+ artifacts.add((ArtifactId) object);
+ } else if (object instanceof IAtsObject) {
+ artifacts.add(((IAtsObject) object).getStoreObject());
+ }
+ }
+ return artifacts;
+ }
+
+ /**
+ * Return collection of TeamWfs. If Task or Review, return nothing. If Action, return children TeamWfs.
+ */
+ public static Collection<ArtifactId> getTeamWfArtifacts(Collection<?> objects, IAtsServices services) {
+ List<ArtifactId> artifacts = new LinkedList<>();
+ for (Object object : objects) {
+ if (object instanceof ArtifactId) {
+ ArtifactId artId = (ArtifactId) object;
+ if (services.getStoreService().isOfType(artId, AtsArtifactTypes.Action)) {
+ artifacts.addAll(AtsObjects.getArtifacts(
+ services.getWorkItemService().getTeams(services.getWorkItemFactory().getAction(artId))));
+ }
+ }
+ if (object instanceof IAtsTeamWorkflow) {
+ artifacts.add(((IAtsTeamWorkflow) object).getStoreObject());
+ }
}
return artifacts;
}
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/agile/AgileFeatureGroupColumn.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/agile/AgileFeatureGroupColumn.java
index 39eac5e9da..14c37b7ec0 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/agile/AgileFeatureGroupColumn.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/agile/AgileFeatureGroupColumn.java
@@ -17,6 +17,7 @@ import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.nebula.widgets.xviewer.IAltLeftClickProvider;
import org.eclipse.nebula.widgets.xviewer.IMultiColumnEditProvider;
@@ -25,7 +26,6 @@ import org.eclipse.nebula.widgets.xviewer.core.model.SortDataType;
import org.eclipse.nebula.widgets.xviewer.core.model.XViewerAlign;
import org.eclipse.nebula.widgets.xviewer.core.model.XViewerColumn;
import org.eclipse.osee.ats.api.IAtsObject;
-import org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.ats.api.agile.AgileEndpointApi;
import org.eclipse.osee.ats.api.agile.IAgileFeatureGroup;
import org.eclipse.osee.ats.api.agile.JaxAgileFeatureGroup;
@@ -36,10 +36,15 @@ import org.eclipse.osee.ats.column.IAtsXViewerPreComputedColumn;
import org.eclipse.osee.ats.core.client.action.ActionManager;
import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact;
import org.eclipse.osee.ats.core.client.workflow.AbstractWorkflowArtifact;
+import org.eclipse.osee.ats.core.util.AtsObjects;
+import org.eclipse.osee.ats.core.util.AtsUtilCore;
import org.eclipse.osee.ats.internal.Activator;
import org.eclipse.osee.ats.internal.AtsClientService;
import org.eclipse.osee.ats.util.xviewer.column.XViewerAtsColumn;
import org.eclipse.osee.ats.world.WorldXViewerFactory;
+import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.core.data.IArtifactToken;
+import org.eclipse.osee.framework.jdk.core.type.HashCollection;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.logging.OseeLevel;
@@ -189,30 +194,41 @@ public class AgileFeatureGroupColumn extends XViewerAtsColumn implements IAtsXVi
Long result = 0L;
if (obj instanceof IAtsObject) {
result = ((IAtsObject) obj).getUuid();
+ } else if (obj instanceof ArtifactId) {
+ result = ((ArtifactId) obj).getId();
}
return result;
}
@Override
public void populateCachedValues(Collection<?> objects, Map<Long, String> preComputedValueMap) {
- for (Object element : objects) {
- try {
- if (Artifacts.isOfType(element, AtsArtifactTypes.Action)) {
- Set<String> strs = new HashSet<>();
- for (TeamWorkFlowArtifact teamWf : ActionManager.getTeams(element)) {
- for (Artifact art : ((Artifact) teamWf.getStoreObject()).getRelatedArtifacts(
- AtsRelationTypes.AgileFeatureToItem_FeatureGroup)) {
- strs.add(art.getName());
+ Collection<ArtifactId> artifacts = AtsObjects.getTeamWfArtifacts(objects, AtsClientService.get());
+
+ if (!artifacts.isEmpty()) {
+ // Change NamedId to ArtifactToken when merge to 25.0
+ HashCollection<ArtifactId, IArtifactToken> artifactToTokens =
+ ArtifactQuery.getArtifactTokenListFromRelated(AtsUtilCore.getAtsBranch(), artifacts,
+ AtsArtifactTypes.Version, AtsRelationTypes.AgileFeatureToItem_FeatureGroup);
+ for (Entry<ArtifactId, Collection<IArtifactToken>> entry : artifactToTokens.entrySet()) {
+ try {
+ if (Artifacts.isOfType(entry.getKey(), AtsArtifactTypes.Action)) {
+ Set<String> strs = new HashSet<>();
+ for (TeamWorkFlowArtifact teamWf : ActionManager.getTeams(entry.getKey())) {
+ for (IArtifactToken artToken : artifactToTokens.getValues(teamWf)) {
+ strs.add(artToken.getName());
+ }
+ }
+ preComputedValueMap.put(getKey(entry.getKey()), Collections.toString(", ", strs));
+ } else {
+ Set<String> strs = new HashSet<>();
+ for (IArtifactToken artToken : entry.getValue()) {
+ strs.add(artToken.getName());
}
+ preComputedValueMap.put(getKey(entry.getKey()), Collections.toString(", ", strs));
}
- preComputedValueMap.put(getKey(element), Collections.toString(", ", strs));
- } else {
- preComputedValueMap.put(getKey(element),
- Collections.toString(", ", ((Artifact) (IAtsWorkItem) element).getRelatedArtifacts(
- AtsRelationTypes.AgileFeatureToItem_FeatureGroup)));
+ } catch (OseeCoreException ex) {
+ preComputedValueMap.put(getKey(entry.getKey()), LogUtil.getCellExceptionString(ex));
}
- } catch (OseeCoreException ex) {
- preComputedValueMap.put(getKey(element), LogUtil.getCellExceptionString(ex));
}
}
}
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/ev/WorkPackageSearchProvider.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/ev/WorkPackageSearchProvider.java
index f83f4ed061..59518bc270 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/ev/WorkPackageSearchProvider.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/ev/WorkPackageSearchProvider.java
@@ -13,6 +13,7 @@ package org.eclipse.osee.ats.ev;
import java.util.Collection;
import java.util.LinkedList;
import org.eclipse.osee.ats.api.data.AtsArtifactTypes;
+import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
import org.eclipse.osee.ats.api.ev.IAtsWorkPackage;
import org.eclipse.osee.ats.column.WorkPackageFilterTreeDialog.IWorkPackageProvider;
import org.eclipse.osee.ats.core.util.AtsUtilCore;
@@ -33,8 +34,8 @@ public class WorkPackageSearchProvider implements IWorkPackageProvider {
@Override
public Collection<IAtsWorkPackage> getActiveWorkPackages() {
- Collection<IArtifactToken> selectableWorkPackageTokens =
- ArtifactQuery.getArtifactTokenListFromTypeAndActive(AtsArtifactTypes.WorkPackage, AtsUtilCore.getAtsBranch());
+ Collection<IArtifactToken> selectableWorkPackageTokens = ArtifactQuery.getArtifactTokenListFromTypeAndActive(
+ AtsArtifactTypes.WorkPackage, AtsAttributeTypes.Active, AtsUtilCore.getAtsBranch());
Collection<IAtsWorkPackage> items = new LinkedList<>();
for (Artifact art : ArtifactQuery.getArtifactListFromTokens(selectableWorkPackageTokens,
AtsUtilCore.getAtsBranch())) {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java
index 1a24a6a28f..de87d6bb3e 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java
@@ -29,11 +29,13 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.BranchId;
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.IRelationType;
+import org.eclipse.osee.framework.core.data.IRelationTypeSide;
import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.data.TransactionId;
import org.eclipse.osee.framework.core.data.TransactionToken;
@@ -795,11 +797,11 @@ public class ArtifactQuery {
* performing queries.
*/
- public static Collection<IArtifactToken> getArtifactTokenListFromTypeAndActive(IArtifactType artifactType, BranchId branch) {
+ public static Collection<IArtifactToken> getArtifactTokenListFromTypeAndActive(IArtifactType artifactType, IAttributeType activeAttrType, BranchId branch) {
JdbcStatement chStmt = ConnectionHandler.getStatement();
try {
- chStmt.runPreparedQuery(getTokenQuery(Active.Active), artifactType.getId(), branch.getId(), branch.getId(),
- branch.getId());
+ chStmt.runPreparedQuery(getTokenQuery(Active.Active, activeAttrType), artifactType.getId(), branch.getId(),
+ branch.getId(), branch.getId());
List<IArtifactToken> tokens = extractTokensFromQuery(chStmt);
return tokens;
} finally {
@@ -810,7 +812,8 @@ public class ArtifactQuery {
public static Collection<IArtifactToken> getArtifactTokenListFromType(IArtifactType artifactType, BranchId branch) {
JdbcStatement chStmt = ConnectionHandler.getStatement();
try {
- chStmt.runPreparedQuery(getTokenQuery(Active.Both), artifactType.getId(), branch.getId(), branch.getId());
+ chStmt.runPreparedQuery(getTokenQuery(Active.Both, null), artifactType.getId(), branch.getId(),
+ branch.getId());
List<IArtifactToken> tokens = extractTokensFromQuery(chStmt);
return tokens;
} finally {
@@ -818,9 +821,10 @@ public class ArtifactQuery {
}
}
- private static String getTokenQuery(Active active) {
+ private static String getTokenQuery(Active active, IAttributeType activeAttrType) {
if (active == Active.Active) {
- return tokenQuery + activeTokenQueryAdendum;
+ return tokenQuery + activeTokenQueryAdendum.replaceFirst("PUT_ACTIVE_ATTR_TYPE_HERE",
+ activeAttrType.getId().toString());
} else if (active == Active.Both) {
return tokenQuery;
} else {
@@ -846,12 +850,12 @@ public class ArtifactQuery {
"from osee_txs txsArt, osee_txs txsAttr, osee_artifact art, osee_attribute attr where art.art_type_id = ? " + //
"and txsArt.BRANCH_ID = ? and art.GAMMA_ID = txsArt.GAMMA_ID and txsArt.TX_CURRENT = 1 " + //
"and txsAttr.BRANCH_ID = ? and attr.GAMMA_ID = txsAttr.GAMMA_ID and txsAttr.TX_CURRENT = 1 " + //
- "and art.ART_ID = attr.art_id and attr.ATTR_TYPE_ID = 1152921504606847088 ";
+ "and art.ART_ID = attr.art_id and attr.ATTR_TYPE_ID = " + CoreAttributeTypes.Name.getId() + " ";
private static String activeTokenQueryAdendum =
"and not exists (select 1 from osee_attribute attr, osee_txs txs where txs.BRANCH_ID = ? " + //
"and txs.GAMMA_ID = attr.GAMMA_ID and attr.art_id = art.art_id " + //
- "and txs.TX_CURRENT = 1 and attr.ATTR_TYPE_ID = 1152921504606847153 and value = 'false')";
+ "and txs.TX_CURRENT = 1 and attr.ATTR_TYPE_ID = PUT_ACTIVE_ATTR_TYPE_HERE and value = 'false')";
private static String attributeTokenQuery = "select art.art_id, art.art_type_id, art.guid, attr.value " + //
"from osee_txs txsArt, osee_txs txsAttr, osee_artifact art, osee_attribute attr where art.art_type_id in ( ART_IDS_HERE ) " + //
@@ -882,4 +886,70 @@ public class ArtifactQuery {
}
}
+ private static String artifactTokensRelatedToArtifactQuery =
+ "select * from osee_attribute attr, OSEE_ARTIFACT art where attr.attr_type_id = " + CoreAttributeTypes.Name.getId() + " and " + //
+ "art.ART_ID = attr.ART_ID and attr.ART_ID in (" + //
+ "with links as (select GAMMA_ID, a_art_id, b_art_id from OSEE_RELATION_LINK where REL_SIDE_HERE in (ART_IDS_HERE) and REL_LINK_TYPE_ID = REL_TYPE_LINKE_ID_HERE) " + //
+ "select links.OPPOSITE_REL_SIDE_HERE from links, osee_txs txs where txs.BRANCH_ID = BRANCH_ID_HERE and txs.TX_CURRENT = 1 and txs.MOD_TYPE " + //
+ "not in (3,5,9.10) and txs.GAMMA_ID = links.gamma_id)";
+
+ private static String aArtifactIdToRelatedBArtifactId =
+ "with links as (select GAMMA_ID, a_art_id, b_art_id from OSEE_RELATION_LINK where REL_SIDE_HERE in (ART_IDS_HERE) and REL_LINK_TYPE_ID = REL_TYPE_LINKE_ID_HERE) " + //
+ "select links.a_art_id, links.b_art_id from links, osee_txs txs where txs.BRANCH_ID = BRANCH_ID_HERE and txs.TX_CURRENT = 1 and txs.MOD_TYPE not in (3,5,9.10) " + //
+ "and txs.GAMMA_ID = links.gamma_id";
+
+ public static HashCollection<ArtifactId, IArtifactToken> getArtifactTokenListFromRelated(BranchId branch, Collection<ArtifactId> artifacts, IArtifactType artifactType, IRelationTypeSide relationType) {
+ List<Long> artIds = new LinkedList<>();
+ String ids = "";
+ for (ArtifactId art : artifacts) {
+ artIds.add(art.getId());
+ ids += art.getId().toString() + ",";
+ }
+ ids = ids.replaceFirst(",$", "");
+
+ Map<Long, Long> artBIdToArtAId = new HashMap<>();
+ Map<Long, Long> artAIdToArtBId = new HashMap<>();
+ JdbcStatement chStmt = ConnectionHandler.getStatement();
+ boolean isSideA = relationType.getSide().isSideA();
+ try {
+ String query = aArtifactIdToRelatedBArtifactId.replaceFirst("ART_IDS_HERE", ids);
+ query = query.replaceAll("REL_SIDE_HERE", isSideA ? "b_art_id" : "a_art_id");
+ query = query.replaceAll("REL_TYPE_LINKE_ID_HERE", relationType.getGuid().toString());
+ query = query.replaceAll("BRANCH_ID_HERE", branch.getId().toString());
+ chStmt.runPreparedQuery(query);
+ while (chStmt.next()) {
+ Long aArtId = chStmt.getLong("a_art_id");
+ Long bArtId = chStmt.getLong("b_art_id");
+ artBIdToArtAId.put(bArtId, aArtId);
+ artAIdToArtBId.put(aArtId, bArtId);
+ }
+ } finally {
+ chStmt.close();
+ }
+
+ chStmt = ConnectionHandler.getStatement();
+ HashCollection<ArtifactId, IArtifactToken> artToRelatedTokens = new HashCollection<>();
+ try {
+ String query = artifactTokensRelatedToArtifactQuery.replaceFirst("ART_IDS_HERE", ids);
+ query = query.replaceAll("OPPOSITE_REL_SIDE_HERE", isSideA ? "a_art_id" : "b_art_id");
+ query = query.replaceAll("REL_SIDE_HERE", isSideA ? "b_art_id" : "a_art_id");
+ query = query.replaceAll("REL_TYPE_LINKE_ID_HERE", relationType.getGuid().toString());
+ query = query.replaceAll("BRANCH_ID_HERE", branch.getId().toString());
+ chStmt.runPreparedQuery(query);
+ while (chStmt.next()) {
+ Long artId = chStmt.getLong("art_id");
+ Long artTypeId = chStmt.getLong("art_type_id");
+ String name = chStmt.getString("value");
+ ArtifactType artType = ArtifactTypeManager.getTypeByGuid(Long.valueOf(artTypeId));
+ IArtifactToken token = TokenFactory.createArtifactToken(artId, name, artType);
+ Long artIdLong = isSideA ? artAIdToArtBId.get(artId) : artBIdToArtAId.get(artId);
+ ArtifactId aArtId = ArtifactId.valueOf(artIdLong);
+ artToRelatedTokens.put(aArtId, token);
+ }
+ } finally {
+ chStmt.close();
+ }
+ return artToRelatedTokens;
+ }
+
}

Back to the top