Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2016-09-06 18:44:35 -0400
committerDonald Dunne2016-09-08 18:48:17 -0400
commit1ba100d20b2ddc92b5c46659286579f9d741563a (patch)
tree336f5c6aac7c7015d551a4bec8663036a7fe4dec
parentb0ab21b34cc3c6d17f9302fc6893f6cabd668888 (diff)
downloadorg.eclipse.osee-1ba100d20b2ddc92b5c46659286579f9d741563a.tar.gz
org.eclipse.osee-1ba100d20b2ddc92b5c46659286579f9d741563a.tar.xz
org.eclipse.osee-1ba100d20b2ddc92b5c46659286579f9d741563a.zip
bug[ats_ATS313614]: Populating work package dialog locks UI
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/search/widget/WorkPackageSearchWidget.java25
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java75
2 files changed, 95 insertions, 5 deletions
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/search/widget/WorkPackageSearchWidget.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/search/widget/WorkPackageSearchWidget.java
index 3c9fcec3b0..98bf09328b 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/search/widget/WorkPackageSearchWidget.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/search/widget/WorkPackageSearchWidget.java
@@ -13,7 +13,9 @@ package org.eclipse.osee.ats.search.widget;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
+import java.util.LinkedList;
import java.util.List;
+import org.eclipse.osee.ats.api.IAtsConfigObject;
import org.eclipse.osee.ats.api.data.AtsArtifactTypes;
import org.eclipse.osee.ats.api.ev.AtsWorkPackageType;
import org.eclipse.osee.ats.api.ev.IAtsWorkPackage;
@@ -21,13 +23,17 @@ import org.eclipse.osee.ats.api.insertion.IAtsInsertion;
import org.eclipse.osee.ats.api.insertion.IAtsInsertionActivity;
import org.eclipse.osee.ats.api.program.IAtsProgram;
import org.eclipse.osee.ats.api.query.AtsSearchData;
+import org.eclipse.osee.ats.core.util.AtsUtilCore;
import org.eclipse.osee.ats.internal.AtsClientService;
import org.eclipse.osee.ats.world.WorldEditorParameterSearchItem;
import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.core.data.IArtifactToken;
import org.eclipse.osee.framework.jdk.core.type.Named;
import org.eclipse.osee.framework.jdk.core.type.NamedIdentity;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Collections;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.ui.plugin.util.ArrayTreeContentProvider;
import org.eclipse.osee.framework.ui.plugin.util.StringLabelProvider;
import org.eclipse.osee.framework.ui.skynet.util.StringNameSorter;
@@ -111,12 +117,21 @@ public class WorkPackageSearchWidget extends AbstractXComboViewerSearchWidget<IA
new ArrayTreeContentProvider(), new WorkPackageLabelProvider(), new StringNameSorter());
dialog.setMultiSelect(false);
if (combo.getSelected().equals(selectOtherActive)) {
- dialog.setInput(
- AtsClientService.get().getQueryService().createQuery(AtsArtifactTypes.WorkPackage).andActive(
- true).getItems());
+ Collection<IArtifactToken> tokens = ArtifactQuery.getArtifactTokenListFromTypeAndActive(
+ AtsArtifactTypes.WorkPackage, AtsUtilCore.getAtsBranch());
+ Collection<IAtsConfigObject> items = new LinkedList<>();
+ for (Artifact art : ArtifactQuery.getArtifactListFromTokens(tokens, AtsUtilCore.getAtsBranch())) {
+ items.add(AtsClientService.get().getConfigItemFactory().getWorkPackage(art));
+ }
+ dialog.setInput(items);
} else if (combo.getSelected().equals(selectOther)) {
- dialog.setInput(
- AtsClientService.get().getQueryService().createQuery(AtsArtifactTypes.WorkPackage).getItems());
+ Collection<IArtifactToken> tokens = ArtifactQuery.getArtifactTokenListFromType(
+ AtsArtifactTypes.WorkPackage, AtsUtilCore.getAtsBranch());
+ Collection<IAtsConfigObject> items = new LinkedList<>();
+ for (Artifact art : ArtifactQuery.getArtifactListFromTokens(tokens, AtsUtilCore.getAtsBranch())) {
+ items.add(AtsClientService.get().getConfigItemFactory().getWorkPackage(art));
+ }
+ dialog.setInput(items);
}
if (dialog.open() == 0) {
IAtsWorkPackage selectedWorkPackage = dialog.getSelectedFirst();
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 2ecf8aea04..42eb27f2f2 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
@@ -37,6 +37,7 @@ import org.eclipse.osee.framework.core.data.IRelationType;
import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.data.TransactionId;
import org.eclipse.osee.framework.core.data.TransactionToken;
+import org.eclipse.osee.framework.core.enums.Active;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.enums.LoadLevel;
@@ -59,6 +60,8 @@ import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
import org.eclipse.osee.framework.skynet.core.event.model.EventBasicGuidArtifact;
import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil;
+import org.eclipse.osee.framework.skynet.core.utility.ConnectionHandler;
+import org.eclipse.osee.jdbc.JdbcStatement;
import org.eclipse.osee.orcs.rest.client.OseeClient;
import org.eclipse.osee.orcs.rest.client.QueryBuilder;
import org.eclipse.osee.orcs.rest.model.search.artifact.RequestType;
@@ -256,6 +259,14 @@ public class ArtifactQuery {
options).getOrCheckArtifact(QueryType.CHECK);
}
+ public static List<Artifact> getArtifactListFromTokens(Collection<IArtifactToken> tokens, BranchId branch) {
+ List<Integer> ids = new LinkedList<>();
+ for (IArtifactToken token : tokens) {
+ ids.add(token.getId().intValue());
+ }
+ return getArtifactListFromIds(ids, branch);
+ }
+
/**
* search for un-deleted artifacts with any of the given artifact ids
*
@@ -768,4 +779,68 @@ public class ArtifactQuery {
return result;
}
+ /**
+ * The following methods are in support of poor running queries that are known about in 0.24.0. Significant query
+ * improvements will be done for Product Line in 0.25.0. This code should be removed and it's uses move to the better
+ * performing queries.
+ */
+
+ public static Collection<IArtifactToken> getArtifactTokenListFromTypeAndActive(IArtifactType artifactType, BranchId branch) {
+ JdbcStatement chStmt = ConnectionHandler.getStatement();
+ try {
+ chStmt.runPreparedQuery(getTokenQuery(Active.Active), artifactType.getId(), branch.getId(), branch.getId(),
+ branch.getId());
+ List<IArtifactToken> tokens = extractTokensFromQuery(chStmt);
+ return tokens;
+ } finally {
+ chStmt.close();
+ }
+ }
+
+ 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());
+ List<IArtifactToken> tokens = extractTokensFromQuery(chStmt);
+ return tokens;
+ } finally {
+ chStmt.close();
+ }
+ }
+
+ private static String getTokenQuery(Active active) {
+ if (active == Active.Active) {
+ return tokenQuery + activeTokenQueryAdendum;
+ } else if (active == Active.Both) {
+ return tokenQuery;
+ } else {
+ throw new UnsupportedOperationException("Unhandled Active case " + active);
+ }
+ }
+
+ private static List<IArtifactToken> extractTokensFromQuery(JdbcStatement chStmt) {
+ List<IArtifactToken> tokens = new LinkedList<>();
+ while (chStmt.next()) {
+ Integer artId = chStmt.getInt("art_id");
+ Long artTypeId = chStmt.getLong("art_type_id");
+ String name = chStmt.getString("value");
+ String guid = chStmt.getString("guid");
+ IArtifactToken token =
+ TokenFactory.createArtifactToken(artId, guid, name, ArtifactTypeManager.getTypeByGuid(artTypeId));
+ tokens.add(token);
+ }
+ return tokens;
+ }
+
+ private static String tokenQuery = "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 = ? " + //
+ "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 ";
+
+ 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')";
+
}

Back to the top