Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshawn.f.cook2012-01-24 19:38:19 +0000
committerRyan D. Brooks2012-01-24 19:38:19 +0000
commit378643aabf810e81b02dd6847fc3e463914a10ba (patch)
treeef8c4bc18489e80ffa03d5ff473dbb0952536d94
parent89bfb913fe0c9ae1ad336e247d8694a27d323199 (diff)
downloadorg.eclipse.osee-378643aabf810e81b02dd6847fc3e463914a10ba.tar.gz
org.eclipse.osee-378643aabf810e81b02dd6847fc3e463914a10ba.tar.xz
org.eclipse.osee-378643aabf810e81b02dd6847fc3e463914a10ba.zip
bug[bgz_369581]: HierarchyIndexColumn class had an inefficient algorithm
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xviewer/skynet/column/HierarchyIndexColumn.java33
2 files changed, 25 insertions, 11 deletions
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF
index 151c3cd172c..614dd9df95b 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF
@@ -37,7 +37,8 @@ Require-Bundle: javax.mail.glassfish,
org.eclipse.core.filesystem
Bundle-ActivationPolicy: lazy
Bundle-Vendor: Eclipse Open System Engineering Environment
-Import-Package: com.lowagie.text;version="2.1.7",
+Import-Package: com.google.common.collect,
+ com.lowagie.text;version="2.1.7",
com.lowagie.text.html;version="2.1.7",
com.lowagie.text.pdf;version="2.1.7",
com.lowagie.text.rtf;version="2.1.7",
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xviewer/skynet/column/HierarchyIndexColumn.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xviewer/skynet/column/HierarchyIndexColumn.java
index c34c898e0aa..d4de095383c 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xviewer/skynet/column/HierarchyIndexColumn.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xviewer/skynet/column/HierarchyIndexColumn.java
@@ -13,14 +13,18 @@ package org.eclipse.osee.framework.ui.skynet.widgets.xviewer.skynet.column;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.TimeUnit;
import org.eclipse.nebula.widgets.xviewer.XViewerColumn;
import org.eclipse.nebula.widgets.xviewer.XViewerValueColumn;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeStateException;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.skynet.core.OseeSystemArtifacts;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.change.Change;
import org.eclipse.swt.SWT;
+import com.google.common.collect.MapMaker;
/**
* @author Roberto E. Escobar
@@ -72,20 +76,29 @@ public class HierarchyIndexColumn extends XViewerValueColumn {
}
}
+ private final ConcurrentMap<Artifact, String> artToIndexStr = new MapMaker()//
+ .expiration(2, TimeUnit.MINUTES)//
+ .makeMap();
+
private String computeHierarchyIndex(Artifact artifact) throws OseeCoreException {
- StringBuilder builder = new StringBuilder();
- Artifact artifactCursor = artifact;
- Artifact root = OseeSystemArtifacts.getDefaultHierarchyRootArtifact(artifact.getBranch());
+ String indexStr = artToIndexStr.get(artifact);
+ if (!Strings.isValid(indexStr)) {
+ StringBuilder builder = new StringBuilder(20);
+ Artifact artifactCursor = artifact;
+ Artifact root = OseeSystemArtifacts.getDefaultHierarchyRootArtifact(artifact.getBranch());
- while (!artifactCursor.equals(root)) {
- Artifact parent = artifactCursor.getParent();
- if (parent == null) {
- return "not connected to root";
+ while (!artifactCursor.equals(root)) {
+ Artifact parent = artifactCursor.getParent();
+ if (parent == null) {
+ return "not connected to root";
+ }
+ builder.insert(0, getPosition(artifactCursor) + ".");
+ artifactCursor = parent;
}
- builder.insert(0, getPosition(artifactCursor) + ".");
- artifactCursor = parent;
+ indexStr = builder.substring(0, builder.length() - 1);
+ artToIndexStr.put(artifact, indexStr);
}
- return builder.substring(0, builder.length() - 1);
+ return indexStr;
}
private int getPosition(Artifact artifact) throws OseeCoreException {

Back to the top