Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-09-28 12:51:22 -0400
committerRyan D. Brooks2010-09-28 12:51:22 -0400
commitcb846ab0223e0f8700e2015b742e9764c55e451f (patch)
tree28a5132f2d4987cb8a48131c910a9acdd943b78c /plugins
parent9f546b17bf52f6253adb77df8ec9baff393e41b6 (diff)
downloadorg.eclipse.osee-cb846ab0223e0f8700e2015b742e9764c55e451f.tar.gz
org.eclipse.osee-cb846ab0223e0f8700e2015b742e9764c55e451f.tar.xz
org.eclipse.osee-cb846ab0223e0f8700e2015b742e9764c55e451f.zip
bug: Improve Artifact.getParent and getRelatedArtifact method performance
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java12
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationManager.java3
2 files changed, 10 insertions, 5 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java
index 0e17d1cf78..365c4626b5 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java
@@ -320,10 +320,15 @@ public class Artifact extends NamedIdentity implements IArtifact, IAdaptable, Co
* hasParent() to safely determine whether
*/
public Artifact getParent() throws OseeCoreException {
- if (hasParent()) {
- return RelationManager.getRelatedArtifact(this, CoreRelationTypes.Default_Hierarchical__Parent);
+ Artifact toReturn = null;
+ List<Artifact> artifacts = getRelatedArtifactsUnSorted(CoreRelationTypes.Default_Hierarchical__Parent);
+ int parentCount = artifacts.size();
+ if (parentCount == 1) {
+ toReturn = artifacts.iterator().next();
+ } else if (parentCount > 1) {
+ throw new MultipleArtifactsExist("artifact [%s] has %d parents", humanReadableId, parentCount);
}
- return null;
+ return toReturn;
}
public Attribute<?> getAttributeById(int attrId, boolean includeDeleted) throws OseeCoreException {
@@ -344,7 +349,6 @@ public class Artifact extends NamedIdentity implements IArtifact, IAdaptable, Co
if (parentCount > 1) {
throw new MultipleArtifactsExist("artifact [%s] has %d parents", humanReadableId, parentCount);
}
-
return parentCount == 1;
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationManager.java
index 47da2f0876..5daef53dd8 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationManager.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationManager.java
@@ -392,7 +392,7 @@ public class RelationManager {
}
private static Artifact getRelatedArtifact(Artifact artifact, RelationType relationType, RelationSide relationSide) throws OseeCoreException {
- List<Artifact> artifacts = getRelatedArtifacts(artifact, relationType, relationSide);
+ List<Artifact> artifacts = getRelatedArtifactsUnSorted(artifact, relationType, relationSide);
if (artifacts.isEmpty()) {
throw new ArtifactDoesNotExist("There is no artifact related to [%s] by a relation of type [%s]", artifact,
@@ -768,4 +768,5 @@ public class RelationManager {
public static void deCache(Artifact artifact) {
relationsByType.removeValues(new ArtifactKey(artifact));
}
+
}

Back to the top