| author | jmisinco | 2011-04-05 17:45:04 (EDT) |
|---|---|---|
| committer | Ryan D. Brooks | 2011-04-05 17:45:04 (EDT) |
| commit | b4bf85d66c5ff6e2e6d2a04e03bab1a7257abda1 (patch) (side-by-side diff) | |
| tree | 779a597c9149b7c36bce04ad17049ea210167fd6 | |
| parent | d977765b1948c098940324686c0ad105711db8c8 (diff) | |
| download | org.eclipse.osee-b4bf85d66c5ff6e2e6d2a04e03bab1a7257abda1.zip org.eclipse.osee-b4bf85d66c5ff6e2e6d2a04e03bab1a7257abda1.tar.gz org.eclipse.osee-b4bf85d66c5ff6e2e6d2a04e03bab1a7257abda1.tar.bz2 | |
bug[bgz_342091]: ArtifactQuery.getArtifactListFromType without branch causes sql exception
2 files changed, 31 insertions, 3 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/cases/ArtifactQueryTestDemo.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/cases/ArtifactQueryTestDemo.java index c731d22..d93ad95 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/cases/ArtifactQueryTestDemo.java +++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/cases/ArtifactQueryTestDemo.java @@ -8,24 +8,28 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ + package org.eclipse.osee.framework.skynet.core.test.cases; import static org.eclipse.osee.framework.core.enums.DeletionFlag.INCLUDE_DELETED; +import java.util.List; import junit.framework.Assert; import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; +import org.eclipse.osee.framework.core.enums.DeletionFlag; import org.eclipse.osee.framework.core.exception.ArtifactDoesNotExist; import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery; +import org.junit.Test; /** * @author Donald G. Dunne */ public class ArtifactQueryTestDemo { - @org.junit.Test + @Test public void testGetArtifactFromGUIDDeleted() throws OseeCoreException { Artifact newArtifact = ArtifactTypeManager.addArtifact(CoreArtifactTypes.GeneralData, BranchManager.getCommonBranch()); @@ -64,4 +68,28 @@ public class ArtifactQueryTestDemo { Assert.assertNotNull(searchedArtifact); } + + @Test + public void testGetArtifactListFromType() throws OseeCoreException { + // Should exist + List<Artifact> searchedArtifacts = + ArtifactQuery.getArtifactListFromType(CoreArtifactTypes.SoftwareRequirement, DeletionFlag.INCLUDE_DELETED); + // make sure at least one artifact exists + Assert.assertTrue("No artifacts found", searchedArtifacts.size() > 0); + + //check to see if there are multiple branches found + String firstGuid = ""; + Boolean pass = false; + for (Artifact a : searchedArtifacts) { + if ("" == firstGuid) { + firstGuid = a.getBranchGuid(); + } else { + if (firstGuid != a.getBranchGuid()) { + pass = true; + break; + } + } + } + Assert.assertTrue("No artifacts on multiple branches found", pass); + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java index 410241c..b7828ac 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java @@ -383,7 +383,6 @@ public class ArtifactQueryBuilder { } } - sql.append(" AND "); addBranchTxSql(txsAlias); if (isHistorical) { @@ -453,11 +452,12 @@ public class ArtifactQueryBuilder { private void addCurrentTxSql(String txsAlias) { sql.append(txsAlias); - sql.append(".tx_current=1 AND "); + sql.append(".tx_current=1 "); } private void addBranchTxSql(String txsAlias) throws OseeCoreException { if (branch != null) { + sql.append(" AND "); sql.append(txsAlias); sql.append(".branch_id=?"); addParameter(BranchManager.getBranchId(branch)); |

