Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2016-03-07 13:56:33 -0500
committerMegumi Telles2016-03-09 14:58:21 -0500
commit3a12002b35fed3078aafc746f97039a94c48c074 (patch)
treee89281f21c3180abb8b322666c1c4d866fe46996
parent95f6bf99d9518c446347bc55ef741cb7785cb0e5 (diff)
downloadorg.eclipse.osee-3a12002b35fed3078aafc746f97039a94c48c074.tar.gz
org.eclipse.osee-3a12002b35fed3078aafc746f97039a94c48c074.tar.xz
org.eclipse.osee-3a12002b35fed3078aafc746f97039a94c48c074.zip
bug[ats_ATS276451]: Sorting by Activity Id is slow
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/ev/IAtsEarnedValueService.java2
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/ev/AtsEarnedValueImpl.java24
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/ActivityIdColumnTest.java4
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/column/IActivityIdUtility.java8
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/column/ev/ActivityIdUtility.java52
-rw-r--r--plugins/org.eclipse.osee.ats/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/column/ev/ActivityIdColumnUI.java46
8 files changed, 90 insertions, 52 deletions
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/ev/IAtsEarnedValueService.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/ev/IAtsEarnedValueService.java
index 7646268f81c..320535db4e8 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/ev/IAtsEarnedValueService.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/ev/IAtsEarnedValueService.java
@@ -24,4 +24,6 @@ public interface IAtsEarnedValueService {
public Collection<IAtsWorkPackage> getWorkPackageOptions(IAtsObject object) throws OseeCoreException;
+ public String getWorkPackageId(IAtsWorkItem atsObject);
+
}
diff --git a/plugins/org.eclipse.osee.ats.core.client/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.core.client/META-INF/MANIFEST.MF
index 77ef40dea26..9f9c2d723eb 100644
--- a/plugins/org.eclipse.osee.ats.core.client/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.ats.core.client/META-INF/MANIFEST.MF
@@ -7,7 +7,8 @@ Eclipse-ExtensibleAPI: true
Bundle-Activator: org.eclipse.osee.ats.core.client.internal.Activator
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Import-Package: com.google.inject,
+Import-Package: com.google.common.cache,
+ com.google.inject,
javax.ws.rs.client;version="2.0.0",
javax.ws.rs.core;version="2.0.0",
org.eclipse.core.runtime,
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/ev/AtsEarnedValueImpl.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/ev/AtsEarnedValueImpl.java
index dc4d0c111ae..ace3af2db0f 100644
--- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/ev/AtsEarnedValueImpl.java
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/ev/AtsEarnedValueImpl.java
@@ -39,17 +39,24 @@ import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
public class AtsEarnedValueImpl implements IAtsEarnedValueService {
@Override
- public IAtsWorkPackage getWorkPackage(IAtsWorkItem workItem) throws OseeCoreException {
- WorkPackageArtifact wpa = null;
+ public String getWorkPackageId(IAtsWorkItem workItem) {
+ String guid = null;
Artifact artifact = AtsClientService.get().getArtifact(workItem);
- Conditions.checkNotNull(artifact, "workItem", "Can't Find Artifact matching [%s]", workItem.toString());
+ Conditions.checkNotNull(artifact, "workItem", "Can't Find Work Package matching %s", workItem.toStringWithId());
if (artifact instanceof AbstractWorkflowArtifact) {
AbstractWorkflowArtifact awa = (AbstractWorkflowArtifact) artifact;
- String workPackageGuid = awa.getSoleAttributeValue(AtsAttributeTypes.WorkPackageGuid, null);
- if (Strings.isValid(workPackageGuid)) {
- Artifact workPkgArt = ArtifactQuery.getArtifactFromId(workPackageGuid, AtsUtilCore.getAtsBranch());
- wpa = new WorkPackageArtifact(workPkgArt);
- }
+ guid = awa.getSoleAttributeValue(AtsAttributeTypes.WorkPackageGuid, null);
+ }
+ return guid;
+ }
+
+ @Override
+ public IAtsWorkPackage getWorkPackage(IAtsWorkItem workItem) throws OseeCoreException {
+ WorkPackageArtifact wpa = null;
+ String workPackageGuid = getWorkPackageId(workItem);
+ if (Strings.isValid(workPackageGuid)) {
+ Artifact workPkgArt = ArtifactQuery.getArtifactFromId(workPackageGuid, AtsUtilCore.getAtsBranch());
+ return new WorkPackageArtifact(workPkgArt);
}
return wpa;
}
@@ -101,4 +108,5 @@ public class AtsEarnedValueImpl implements IAtsEarnedValueService {
}
return workPackageOptions;
}
+
}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/ActivityIdColumnTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/ActivityIdColumnTest.java
index c2eb0e39dfc..84ec9e75184 100644
--- a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/ActivityIdColumnTest.java
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/column/ActivityIdColumnTest.java
@@ -77,7 +77,7 @@ public class ActivityIdColumnTest {
ActivityIdUtility col = new ActivityIdUtility(earnedValueServiceProvider);
Set<IAtsWorkPackage> workPackages = new HashSet<>();
- col.getWorkPackages(teamWf1, workPackages);
+ col.getWorkPackage(teamWf1);
Assert.assertEquals(1, workPackages.size());
Assert.assertEquals(workPkg1, workPackages.iterator().next());
@@ -88,7 +88,7 @@ public class ActivityIdColumnTest {
ActivityIdUtility col = new ActivityIdUtility(earnedValueServiceProvider);
Set<IAtsWorkPackage> workPackages = new HashSet<>();
- col.getWorkPackages(task1, workPackages);
+ col.getWorkPackage(task1);
// Each work flow stores it's own work package, so none should be returned
Assert.assertEquals(0, workPackages.size());
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/column/IActivityIdUtility.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/column/IActivityIdUtility.java
index a99b8fd9d2b..d318b0288b5 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/column/IActivityIdUtility.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/column/IActivityIdUtility.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.osee.ats.core.column;
-import java.util.Collection;
-import java.util.Set;
import org.eclipse.osee.ats.api.IAtsObject;
import org.eclipse.osee.ats.api.ev.IAtsWorkPackage;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
@@ -21,6 +19,10 @@ import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
*/
public interface IActivityIdUtility extends IAtsColumnUtility {
- public abstract Collection<IAtsWorkPackage> getWorkPackages(IAtsObject atsObject, Set<IAtsWorkPackage> workPackages) throws OseeCoreException;
+ IAtsWorkPackage getWorkPackage(IAtsObject atsObject) throws OseeCoreException;
+
+ String getWorkPackageId(Object object);
+
+ String getColumnText(IAtsWorkPackage workPackage);
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/column/ev/ActivityIdUtility.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/column/ev/ActivityIdUtility.java
index 854145026ab..c53efa3a863 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/column/ev/ActivityIdUtility.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/internal/column/ev/ActivityIdUtility.java
@@ -10,15 +10,10 @@
*******************************************************************************/
package org.eclipse.osee.ats.core.internal.column.ev;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
import org.eclipse.osee.ats.api.IAtsObject;
import org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.ats.api.ev.IAtsEarnedValueServiceProvider;
import org.eclipse.osee.ats.api.ev.IAtsWorkPackage;
-import org.eclipse.osee.ats.api.team.IAtsTeamWorkflowProvider;
-import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow;
import org.eclipse.osee.ats.core.column.IActivityIdUtility;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
@@ -36,19 +31,18 @@ public class ActivityIdUtility implements IActivityIdUtility {
}
@Override
+ public String getWorkPackageId(Object object) {
+ return earnedValueServiceProvider.getEarnedValueService().getWorkPackageId((IAtsWorkItem) object);
+ }
+
+ @Override
public String getColumnText(IAtsObject atsObject) {
String result = "";
- StringBuilder sb = new StringBuilder();
try {
- Collection<IAtsWorkPackage> workPackages = getWorkPackages(atsObject, new HashSet<IAtsWorkPackage>());
- if (!workPackages.isEmpty()) {
- for (IAtsWorkPackage workPackage : workPackages) {
- sb.append(workPackage.getActivityId());
- sb.append(" - ");
- sb.append(workPackage.getActivityName());
- sb.append(", ");
- }
- result = sb.toString().replaceFirst(", $", "");
+ IAtsWorkPackage workPackage = null;
+ if (atsObject instanceof IAtsWorkItem) {
+ workPackage = earnedValueServiceProvider.getEarnedValueService().getWorkPackage((IAtsWorkItem) atsObject);
+ result = getText(workPackage);
}
} catch (OseeCoreException ex) {
return AtsColumnUtilities.CELL_ERROR_PREFIX + " - " + ex.getLocalizedMessage();
@@ -56,28 +50,30 @@ public class ActivityIdUtility implements IActivityIdUtility {
return result;
}
+ private String getText(IAtsWorkPackage workPackage) {
+ String result;
+ result = String.format("%s - %s", workPackage.getActivityId(), workPackage.getActivityName());
+ return result;
+ }
+
@Override
- public Collection<IAtsWorkPackage> getWorkPackages(IAtsObject atsObject, Set<IAtsWorkPackage> workPackages) throws OseeCoreException {
- // If object has children team workflows, roll-up results of all work packages
- if (atsObject instanceof IAtsTeamWorkflowProvider) {
- for (IAtsTeamWorkflow team : ((IAtsTeamWorkflowProvider) atsObject).getTeamWorkflows()) {
- getWorkPackages(team, workPackages);
- }
- }
+ public String getColumnText(IAtsWorkPackage workPackage) {
+ return getText(workPackage);
+ }
+ @Override
+ public IAtsWorkPackage getWorkPackage(IAtsObject atsObject) throws OseeCoreException {
+ IAtsWorkPackage workPackage = null;
// Children work items inherit the work packages of their parent team workflow
if (atsObject instanceof IAtsWorkItem) {
- IAtsWorkPackage workPkg =
- earnedValueServiceProvider.getEarnedValueService().getWorkPackage((IAtsWorkItem) atsObject);
- if (workPkg != null) {
- workPackages.add(workPkg);
- }
+ workPackage = earnedValueServiceProvider.getEarnedValueService().getWorkPackage((IAtsWorkItem) atsObject);
}
- return workPackages;
+ return workPackage;
}
@Override
public String getDescription() {
return "Provides Activity Id and Name from the selected Work Package related to the selected workflow.";
}
+
}
diff --git a/plugins/org.eclipse.osee.ats/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats/META-INF/MANIFEST.MF
index 9fa274c2fd3..31c62f821a1 100644
--- a/plugins/org.eclipse.osee.ats/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.ats/META-INF/MANIFEST.MF
@@ -58,7 +58,8 @@ Export-Package: org.eclipse.osee.ats,
org.eclipse.osee.ats.workflow,
org.eclipse.osee.ats.world,
org.eclipse.osee.ats.world.search
-Import-Package: com.google.gson,
+Import-Package: com.google.common.cache,
+ com.google.gson,
com.google.gson.reflect,
com.google.inject,
javax.mail,
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/column/ev/ActivityIdColumnUI.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/column/ev/ActivityIdColumnUI.java
index 8d46608be1e..62a49720163 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/column/ev/ActivityIdColumnUI.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/column/ev/ActivityIdColumnUI.java
@@ -10,11 +10,15 @@
*******************************************************************************/
package org.eclipse.osee.ats.column.ev;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import org.eclipse.jface.window.Window;
import org.eclipse.nebula.widgets.xviewer.IAltLeftClickProvider;
import org.eclipse.nebula.widgets.xviewer.IMultiColumnEditProvider;
@@ -26,17 +30,22 @@ import org.eclipse.osee.ats.api.ev.IAtsWorkPackage;
import org.eclipse.osee.ats.api.workflow.IAtsAction;
import org.eclipse.osee.ats.column.WorkPackageFilterTreeDialog;
import org.eclipse.osee.ats.core.client.action.ActionManager;
+import org.eclipse.osee.ats.core.client.ev.WorkPackageArtifact;
import org.eclipse.osee.ats.core.client.workflow.AbstractWorkflowArtifact;
+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.exception.OseeWrappedException;
import org.eclipse.osee.framework.core.util.Result;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Collections;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.utility.Artifacts;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
import org.eclipse.swt.SWT;
@@ -77,12 +86,33 @@ public class ActivityIdColumnUI extends XViewerAtsColumn implements IMultiColumn
public String getColumnText(Object element, XViewerColumn column, int columnIndex) {
String result = "";
if (element instanceof IAtsObject) {
- result =
- AtsClientService.get().getColumnUtilities().getActivityIdUtility().getColumnText((IAtsObject) element);
+ String workPackageGuid =
+ AtsClientService.get().getColumnUtilities().getActivityIdUtility().getWorkPackageId(element);
+ if (Strings.isValid(workPackageGuid)) {
+ try {
+ IAtsWorkPackage workPackage = workPackageGuidToWorkPackage.get(workPackageGuid);
+ result = AtsClientService.get().getColumnUtilities().getActivityIdUtility().getColumnText(workPackage);
+ } catch (Exception ex) {
+ throw new OseeWrappedException(ex);
+ }
+ }
}
return result;
}
+ // Cache work packages by guid so don't have to re search/create objects constantly.
+ private static final LoadingCache<String, IAtsWorkPackage> workPackageGuidToWorkPackage =
+ CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES).build(
+ new CacheLoader<String, IAtsWorkPackage>() {
+
+ @Override
+ public IAtsWorkPackage load(String workPackageGuid) throws Exception {
+ Artifact workPkgArt = ArtifactQuery.getArtifactFromId(workPackageGuid, AtsUtilCore.getAtsBranch());
+ return new WorkPackageArtifact(workPkgArt);
+ }
+
+ });
+
@Override
public boolean handleAltLeftClick(TreeColumn treeColumn, TreeItem treeItem) {
boolean modified = false;
@@ -123,9 +153,8 @@ public class ActivityIdColumnUI extends XViewerAtsColumn implements IMultiColumn
if (result.isFalse()) {
AWorkbench.popup("Options Invalid", result.getText());
} else {
- WorkPackageFilterTreeDialog dialog =
- new WorkPackageFilterTreeDialog("Select Work Package", getMessage(awas, commonWorkPackageOptions,
- uniqueWorkPackageOptions), commonWorkPackageOptions);
+ WorkPackageFilterTreeDialog dialog = new WorkPackageFilterTreeDialog("Select Work Package",
+ getMessage(awas, commonWorkPackageOptions, uniqueWorkPackageOptions), commonWorkPackageOptions);
dialog.setInput();
if (dialog.open() == Window.OK) {
IAtsWorkPackage workPackage = dialog.getSelection();
@@ -149,10 +178,9 @@ public class ActivityIdColumnUI extends XViewerAtsColumn implements IMultiColumn
private static String getMessage(Collection<? extends AbstractWorkflowArtifact> awas, Set<IAtsWorkPackage> commonWorkPackageOptions, Set<IAtsWorkPackage> uniqueWorkPackageOptions) {
String message = "Select Work Package";
if (awas.size() > 1) {
- message =
- String.format(
- "Select Work Package Option from %d common option(s) out of %d unique options from selected Work Items",
- commonWorkPackageOptions.size(), uniqueWorkPackageOptions.size());
+ message = String.format(
+ "Select Work Package Option from %d common option(s) out of %d unique options from selected Work Items",
+ commonWorkPackageOptions.size(), uniqueWorkPackageOptions.size());
}
return message;
}

Back to the top