Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorddunne2009-09-16 00:20:20 +0000
committerddunne2009-09-16 00:20:20 +0000
commite1aeb6a0671f296b70d96bdf0bfdda640824df6f (patch)
tree28c2f1d02dad87e91682d094dad9e5a3fa3b58a4
parent3435cef6e62ccfab37f20735c6699485f059d8ce (diff)
downloadorg.eclipse.osee-e1aeb6a0671f296b70d96bdf0bfdda640824df6f.tar.gz
org.eclipse.osee-e1aeb6a0671f296b70d96bdf0bfdda640824df6f.tar.xz
org.eclipse.osee-e1aeb6a0671f296b70d96bdf0bfdda640824df6f.zip
Fix duplicate relation loading
-rw-r--r--org.eclipse.osee.ats/src/org/eclipse/osee/ats/artifact/StateMachineArtifact.java9
-rw-r--r--org.eclipse.osee.ats/src/org/eclipse/osee/ats/artifact/TeamWorkFlowArtifact.java15
-rw-r--r--org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/DoesNotWorkItemAts.java53
-rw-r--r--org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/OseeSql.java2
-rw-r--r--org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java8
-rw-r--r--org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationLink.java35
-rw-r--r--org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationManager.java80
7 files changed, 100 insertions, 102 deletions
diff --git a/org.eclipse.osee.ats/src/org/eclipse/osee/ats/artifact/StateMachineArtifact.java b/org.eclipse.osee.ats/src/org/eclipse/osee/ats/artifact/StateMachineArtifact.java
index 0db65cbe26a..c3a33c3aa5f 100644
--- a/org.eclipse.osee.ats/src/org/eclipse/osee/ats/artifact/StateMachineArtifact.java
+++ b/org.eclipse.osee.ats/src/org/eclipse/osee/ats/artifact/StateMachineArtifact.java
@@ -931,10 +931,13 @@ public abstract class StateMachineArtifact extends ATSArtifact implements IGroup
return result;
}
- public static List<Artifact> getAllTeamWorkflowArtifacts() throws OseeCoreException {
- List<Artifact> result = new ArrayList<Artifact>();
+ public static List<TeamWorkFlowArtifact> getAllTeamWorkflowArtifacts() throws OseeCoreException {
+ List<TeamWorkFlowArtifact> result = new ArrayList<TeamWorkFlowArtifact>();
for (String artType : TeamWorkflowExtensions.getInstance().getAllTeamWorkflowArtifactNames()) {
- result.addAll(ArtifactQuery.getArtifactListFromType(artType, AtsUtil.getAtsBranch()));
+ List<TeamWorkFlowArtifact> teamArts =
+ org.eclipse.osee.framework.jdk.core.util.Collections.castAll(ArtifactQuery.getArtifactListFromType(
+ artType, AtsUtil.getAtsBranch()));
+ result.addAll(teamArts);
}
return result;
}
diff --git a/org.eclipse.osee.ats/src/org/eclipse/osee/ats/artifact/TeamWorkFlowArtifact.java b/org.eclipse.osee.ats/src/org/eclipse/osee/ats/artifact/TeamWorkFlowArtifact.java
index d1b76dfc26b..9ab83b7b860 100644
--- a/org.eclipse.osee.ats/src/org/eclipse/osee/ats/artifact/TeamWorkFlowArtifact.java
+++ b/org.eclipse.osee.ats/src/org/eclipse/osee/ats/artifact/TeamWorkFlowArtifact.java
@@ -62,13 +62,6 @@ public class TeamWorkFlowArtifact extends TaskableStateMachineArtifact implement
Endorse, Analyze, Authorize, Implement, Completed, Cancelled
}
- /**
- * @param parentFactory
- * @param guid
- * @param humanReadableId
- * @param branch
- * @throws OseeDataStoreException
- */
public TeamWorkFlowArtifact(ArtifactFactory parentFactory, String guid, String humanReadableId, Branch branch, ArtifactType artifactType) throws OseeDataStoreException {
super(parentFactory, guid, humanReadableId, branch, artifactType);
registerSMAEditorRelation(AtsRelation.TeamWorkflowTargetedForVersion_Version);
@@ -158,8 +151,12 @@ public class TeamWorkFlowArtifact extends TaskableStateMachineArtifact implement
@Override
public String getEditorTitle() throws OseeCoreException {
- if (getWorldViewTargetedVersion() != null) {
- return smaMgr.getSma().getWorldViewType() + ": " + "[" + getWorldViewTargetedVersionStr() + "] - " + getName();
+ try {
+ if (getWorldViewTargetedVersion() != null) {
+ return smaMgr.getSma().getWorldViewType() + ": " + "[" + getWorldViewTargetedVersionStr() + "] - " + getName();
+ }
+ } catch (OseeCoreException ex) {
+ OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE, ex);
}
return super.getEditorTitle();
}
diff --git a/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/DoesNotWorkItemAts.java b/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/DoesNotWorkItemAts.java
index cdcd3b6d4f6..067e9ea6ced 100644
--- a/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/DoesNotWorkItemAts.java
+++ b/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/DoesNotWorkItemAts.java
@@ -32,6 +32,8 @@ 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.relation.RelationLink;
+import org.eclipse.osee.framework.skynet.core.relation.RelationTypeManager;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
import org.eclipse.osee.framework.ui.plugin.util.Result;
@@ -50,30 +52,15 @@ public class DoesNotWorkItemAts extends XNavigateItemAction {
* @param parent
*/
public DoesNotWorkItemAts(XNavigateItem parent) {
- super(parent, "Does Not Work - ATS - ??", FrameworkImage.ADMIN);
+ super(parent, "Does Not Work - ATS - Dup Relations", FrameworkImage.ADMIN);
}
@Override
public void run(TableLoadOption... tableLoadOptions) throws OseeCoreException {
if (!MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), getName(), getName())) return;
- // for (Artifact art : ArtifactQuery.getArtifactsFromAttributeType("ats.Branch Id", AtsUtil.getAtsBranch())) {
- // int branchId = art.getSoleAttributeValue("ats.Branch Id");
- // Branch branch = null;
- // try {
- // branch = BranchManager.getBranch(branchId);
- // } catch (BranchDoesNotExist ex) {
- // System.out.println("Branch does not exist for art " + art.getHumanReadableId() + " - " + art);
- // } catch (Exception ex) {
- // System.err.println("Exception getting branch for art " + art.getHumanReadableId() + " - " + art);
- // }
- // if (branch != null) {
- // System.err.println("Branch DOES exist for art " + art.getHumanReadableId() + " - " + art);
- // }
- // }
-
- // SkynetTransaction transaction = new SkynetTransaction(AtsUtil.getAtsBranch());
- // transaction.execute();
+ SkynetTransaction transaction = new SkynetTransaction(AtsUtil.getAtsBranch());
+ transaction.execute();
// convertAtsLogUserIds(transaction);
// deleteUnAssignedUserRelations();
@@ -92,6 +79,36 @@ public class DoesNotWorkItemAts extends XNavigateItemAction {
AWorkbench.popup("Completed", "Complete");
}
+ private void purgeDuplicateVersionRelations() throws OseeCoreException {
+ boolean fix = false;
+ SkynetTransaction transaction = new SkynetTransaction(AtsUtil.getAtsBranch());
+ for (TeamWorkFlowArtifact teamArt : TeamWorkFlowArtifact.getAllTeamWorkflowArtifacts()) {
+ List<RelationLink> relLinks =
+ teamArt.getRelations(RelationTypeManager.getType(AtsRelation.TeamWorkflowTargetedForVersion_Version.getName()));
+ if (relLinks.size() > 1) {
+ String str = "Duplicate verArts found for " + teamArt.getHumanReadableId() + " ";
+ Integer firstId = null;
+ String firstName = null;
+ for (RelationLink relLink : relLinks) {
+ if (firstId == null) {
+ firstId = relLink.getRelationId();
+ firstName = relLink.getArtifactB().getName();
+ } else if (relLink.getRelationId() != firstId && relLink.getArtifactB().getName().equals(firstName)) {
+ str += " Deleteable";
+ if (fix) {
+ relLink.delete(false);
+ teamArt.persist(transaction);
+ }
+ }
+ str += "[" + relLink.getArtifactB().getName() + "(" + relLink.getRelationId() + ")]";
+
+ }
+ System.out.println(str);
+ }
+ }
+ transaction.execute();
+ }
+
private void purgeHrids() throws OseeCoreException {
String[] hrids = AFile.readFile("O:\\hrids_to_delete.txt").split("\r\n");
int x = 0;
diff --git a/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/OseeSql.java b/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/OseeSql.java
index eb1a03b2e2d..c487e6154ed 100644
--- a/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/OseeSql.java
+++ b/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/OseeSql.java
@@ -44,7 +44,7 @@ public enum OseeSql {
LOAD_CURRENT_ATTRIBUTES(Strings.SELECT_CURRENT_ATTRIBUTES_PREFIX + "= 1 order by al1.branch_id, al1.art_id, att1.attr_id, txd1.transaction_id desc"),
LOAD_CURRENT_ATTRIBUTES_WITH_DELETED(Strings.SELECT_CURRENT_ATTRIBUTES_PREFIX + "IN (1, 3) order by al1.branch_id, al1.art_id, att1.attr_id, txd1.transaction_id desc"),
LOAD_ALL_CURRENT_ATTRIBUTES(Strings.SELECT_CURRENT_ATTRIBUTES_PREFIX + "IN (1, 2, 3) order by al1.branch_id, al1.art_id, att1.attr_id, txd1.transaction_id desc"),
- LOAD_RELATIONS("SELECT%s txs1.mod_type, rel_link_id, a_art_id, b_art_id, rel_link_type_id, a_order, b_order, rel1.gamma_id, rationale, al1.branch_id FROM osee_join_artifact al1, osee_relation_link rel1, osee_txs txs1, osee_tx_details txd1 WHERE al1.query_id = ? AND (al1.art_id = rel1.a_art_id OR al1.art_id = rel1.b_art_id) AND rel1.gamma_id = txs1.gamma_id AND txs1.tx_current=1 AND txs1.transaction_id = txd1.transaction_id AND txd1.branch_id = al1.branch_id"),
+ LOAD_RELATIONS("SELECT%s txs1.mod_type, rel_link_id, a_art_id, b_art_id, rel_link_type_id, a_order, b_order, rel1.gamma_id, rationale, al1.branch_id FROM osee_join_artifact al1, osee_relation_link rel1, osee_txs txs1, osee_tx_details txd1 WHERE al1.query_id = ? AND (al1.art_id = rel1.a_art_id OR al1.art_id = rel1.b_art_id) AND rel1.gamma_id = txs1.gamma_id AND txs1.tx_current = " + TxChange.CURRENT.getValue() + " AND txs1.transaction_id = txd1.transaction_id AND txd1.branch_id = al1.branch_id"),
LOAD_CURRENT_ARTIFACTS(Strings.SELECT_CURRENT_ARTIFACTS_PREFIX + "= 1"),
LOAD_CURRENT_ARTIFACTS_WITH_DELETED(Strings.SELECT_CURRENT_ARTIFACTS_PREFIX + "in (1, 2)"),
diff --git a/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java b/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java
index 2d2c57df2b0..e0ebd02e444 100644
--- a/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java
+++ b/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java
@@ -1743,7 +1743,7 @@ public class Artifact implements IAdaptable, Comparable<Artifact>, IAccessContro
}
public List<RelationLink> getRelationsAll(boolean includeDeleted) {
- return RelationManager.getRelationsAll(this, includeDeleted);
+ return RelationManager.getRelationsAll(getArtId(), getBranch().getBranchId(), includeDeleted);
}
/**
@@ -1756,12 +1756,6 @@ public class Artifact implements IAdaptable, Comparable<Artifact>, IAccessContro
/**
* This method should never be called from outside the OSEE Application Framework
- *
- * @param gammaId
- * @param transactionId
- * @param modType
- * @param lastModified
- * @param historical
*/
void internalSetPersistenceData(int gammaId, TransactionId transactionId, ModificationType modType, boolean historical) {
this.gammaId = gammaId;
diff --git a/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationLink.java b/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationLink.java
index aebbb245e0d..235913d3e24 100644
--- a/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationLink.java
+++ b/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationLink.java
@@ -44,6 +44,8 @@ public class RelationLink {
private ModificationType modificationType;
private static final boolean SET_DIRTY = true;
private static final boolean SET_NOT_DIRTY = false;
+ // Set to relationId to determine loading/caching of certain relationIds; set to 0 for production release
+ public static int RELATION_ID_UNDER_TEST = 0;
/**
* Private constructor. Use getOrCreate().
@@ -65,15 +67,21 @@ public class RelationLink {
this.modificationType = modificationType;
}
+ public static boolean isRelationUnderTest() {
+ return RELATION_ID_UNDER_TEST != 0;
+ }
+
/**
* Return existing RelationLink or create new one. This needs to be synchronized so two threads don't create the same
* link object twice.
*/
public static synchronized RelationLink getOrCreate(int aArtifactId, int bArtifactId, Branch aBranch, Branch bBranch, RelationType relationType, int relationId, int gammaId, String rationale, int aOrder, int bOrder, ModificationType modificationType) {
- RelationLink relation =
- RelationManager.getLoadedRelation(relationType, aArtifactId, bArtifactId, aBranch, bBranch);
- if (relation == null || relation.modificationType != modificationType) {
+ RelationLink relation = RelationManager.getLoadedRelation(relationId, aArtifactId, bArtifactId, aBranch, bBranch);
+ if (isRelationUnderTest() && relationId == RELATION_ID_UNDER_TEST) {
+ System.out.println("RelationLink.getOrCreate relationId == " + RELATION_ID_UNDER_TEST);
+ }
+ if (relation == null || relation.modificationType != modificationType) {
relation =
new RelationLink(aArtifactId, bArtifactId, aBranch, bBranch, relationType, relationId, gammaId,
rationale, aOrder, bOrder, modificationType);
@@ -312,9 +320,24 @@ public class RelationLink {
@Override
public String toString() {
- return String.format("%s id[%d] modType[%s] [%s]: aId[%d] aOrder[%d] <--> bId[%s] bOrder[%d]",
- relationType.getName(), relationId, getModificationType(), (isDirty() ? "dirty" : "not dirty"),
- aArtifactId, aOrder, bArtifactId, bOrder);
+ String artAName = "Unloaded";
+ String artBName = "Unloaded";
+ try {
+ Artifact artA = ArtifactCache.getActive(getAArtifactId(), getABranch());
+ if (artA != null) {
+ artAName = artA.getSafeName();
+ }
+ Artifact artB = ArtifactCache.getActive(getBArtifactId(), getBBranch());
+ if (artB != null) {
+ artBName = artB.getSafeName();
+ }
+ } catch (Exception ex) {
+ // do nothing
+ }
+ return String.format(
+ "type[%s] id[%d] modType[%s] [%s]: aName[%s] aId[%d] aOrder[%d] <--> bName[%s] bId[%s] bOrder[%d]",
+ relationType.getName(), relationId, getModificationType(), (isDirty() ? "dirty" : "not dirty"), artAName,
+ aArtifactId, aOrder, artBName, bArtifactId, bOrder);
}
public boolean isExplorable() {
diff --git a/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationManager.java b/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationManager.java
index 7935e3a9766..e81a329558f 100644
--- a/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationManager.java
+++ b/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationManager.java
@@ -126,47 +126,18 @@ public class RelationManager {
return relationLink;
}
- /**
- * This method should never be called by application code.
- */
- public static RelationLink getLoadedRelation(RelationType relationType, int aArtifactId, int bArtifactId, Branch aBranch, Branch bBranch) {
- RelationLink relation = null;
- List<RelationLink> relations = getLoadedRelations(aArtifactId, aBranch.getBranchId(), relationType, true);
- for (RelationLink rel : relations) {
- if (rel.getBArtifactId() == bArtifactId) {
- relation = rel;
- break;
- }
- }
-
- if (relation == null) {
- relations = getLoadedRelations(bArtifactId, bBranch.getBranchId(), relationType, true);
- for (RelationLink rel : relations) {
- if (rel.getAArtifactId() == aArtifactId) {
- relation = rel;
- break;
- }
- }
- }
- return relation;
- }
-
public static RelationLink getLoadedRelation(int relLinkId, int aArtifactId, int bArtifactId, Branch aBranch, Branch bBranch) {
- Artifact artifactA = ArtifactCache.getActive(aArtifactId, aBranch);
- Artifact artifactB = ArtifactCache.getActive(bArtifactId, bBranch);
RelationLink relation = null;
- if (artifactA != null) {
- for (RelationLink link : getRelationsAll(artifactA, true)) {
- if (link.getRelationId() == relLinkId) {
- relation = link;
- }
+ for (RelationLink link : getRelationsAll(aArtifactId, aBranch.getBranchId(), true)) {
+ if (link.getRelationId() == relLinkId) {
+ relation = link;
+ break;
}
}
- if (artifactB != null && relation == null) {
- for (RelationLink link : getRelationsAll(artifactB, true)) {
- if (link.getRelationId() == relLinkId) {
- relation = link;
- }
+ for (RelationLink link : getRelationsAll(bArtifactId, bBranch.getBranchId(), true)) {
+ if (link.getRelationId() == relLinkId) {
+ relation = link;
+ break;
}
}
return relation;
@@ -176,6 +147,9 @@ public class RelationManager {
* Store the newly instantiated relation from the perspective of relationSide in its appropriate order
*/
public static void manageRelation(RelationLink newRelation, RelationSide relationSide) {
+ if (RelationLink.isRelationUnderTest() && newRelation.getRelationId() == RelationLink.RELATION_ID_UNDER_TEST) {
+ System.out.println("RelationManager.manageRelation relationId == " + RelationLink.RELATION_ID_UNDER_TEST + " for side " + relationSide);
+ }
Artifact artifact =
ArtifactCache.getActive(newRelation.getArtifactId(relationSide), newRelation.getBranch(relationSide));
if (artifact != null) {
@@ -185,29 +159,19 @@ public class RelationManager {
artifactsRelations = new CopyOnWriteArrayList<RelationLink>();
}
if (artifactsRelations.contains(newRelation)) {
- // Log error cause this should never happen; only one relation link object should be created
- for (RelationLink relation : artifactsRelations) {
- if (relation.equals(newRelation) && relation != newRelation) {
- String artAName = "Unknown";
- String artBName = "Unknown";
- try {
- artAName = relation.getArtifactA().getSafeName();
- artBName = relation.getArtifactB().getSafeName();
- } catch (Exception ex) {
- // do nothing
- }
- OseeLog.log(
- Activator.class,
- Level.SEVERE,
- String.format(
- "Duplicate relation objects for same relation for Relation [%s] - ArtA (%s)[%s] <-> ArtB (%s)[%s]",
- relation, relation.getAArtifactId(), artAName, relation.getBArtifactId(), artBName));
- }
- }
// Always want to return if relation link is already managed
return;
}
+ // Verify that relation is unique by aArtId, bArtId and relTypeId; Needs to be cleaned up in DB, Only log problem.
+ for (RelationLink relation : artifactsRelations) {
+ if (relation.getAArtifactId() == newRelation.getAArtifactId() && relation.getBArtifactId() == newRelation.getBArtifactId() && relation.getRelationType() == newRelation.getRelationType() && relation != newRelation) {
+ OseeLog.log(Activator.class, Level.SEVERE, String.format(
+ "Duplicate relation objects for same relation for RELATION 1 [%s] RELATION 2 [%s]", relation,
+ newRelation));
+ }
+ }
+
artifactsRelations.add(newRelation);
List<RelationLink> selectedRelations =
@@ -546,9 +510,9 @@ public class RelationManager {
}
}
- public static List<RelationLink> getRelationsAll(Artifact artifact, boolean includeDeleted) {
+ public static List<RelationLink> getRelationsAll(int artId, int branchId, boolean includeDeleted) {
List<RelationLink> selectedRelations =
- getFlattenedList(relationsByType.getValues(threadLocalKey.get().getKey(artifact)));
+ getFlattenedList(relationsByType.getValues(threadLocalKey.get().getKey(artId, branchId)));
if (selectedRelations == null) {
return Collections.emptyList();

Back to the top