diff options
author | ddunne | 2011-10-25 22:14:11 +0000 |
---|---|---|
committer | Ryan D. Brooks | 2011-10-25 22:14:11 +0000 |
commit | 5b427b7e6a0d8f8800e9fd0dbdbc314c57381d16 (patch) | |
tree | 3bf2dae92af4c9f61a0153829924b9bbe4318634 | |
parent | 7afa5c6b7a6d7bc542a354cda3b9b435c953d80f (diff) | |
download | org.eclipse.osee-5b427b7e6a0d8f8800e9fd0dbdbc314c57381d16.tar.gz org.eclipse.osee-5b427b7e6a0d8f8800e9fd0dbdbc314c57381d16.tar.xz org.eclipse.osee-5b427b7e6a0d8f8800e9fd0dbdbc314c57381d16.zip |
refinement: Extract testAttrtibutes to static in ValidateAtsDatabase
-rw-r--r-- | plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/health/ValidateAtsDatabase.java | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/health/ValidateAtsDatabase.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/health/ValidateAtsDatabase.java index 27c28085db2..07795935a7d 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/health/ValidateAtsDatabase.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/health/ValidateAtsDatabase.java @@ -192,7 +192,7 @@ public class ValidateAtsDatabase extends WorldXNavigateItemAction { count += artifacts.size(); testArtifactIds(artifacts); - testAtsAttributeValues(artifacts); + testAtsAttributevaluesWithPersist(artifacts); testStateInWorkDefinition(artifacts); testAttributeSetWorkDefinitionsExist(artifacts); testAtsActionsHaveTeamWorkflow(artifacts); @@ -229,6 +229,17 @@ public class ValidateAtsDatabase extends WorldXNavigateItemAction { } } + public void testAtsAttributevaluesWithPersist(Collection<Artifact> artifacts) { + try { + SkynetTransaction transaction = new SkynetTransaction(AtsUtil.getAtsBranch(), "Validate ATS Database"); + testAtsAttributeValues(transaction, testNameToResultsMap, fixAttributeValues, artifacts); + transaction.execute(); + } catch (OseeCoreException ex) { + OseeLog.log(Activator.class, Level.SEVERE, ex); + testNameToResultsMap.put("testAtsAttributeValues", "Error: Exception: " + ex.getLocalizedMessage()); + } + } + private void addTestTimeMapToResultData(XResultData xResultData) { xResultData.log("\n\nTime Spent in Tests"); long totalTime = 0; @@ -473,48 +484,39 @@ public class ValidateAtsDatabase extends WorldXNavigateItemAction { return Collections.subDivide(artIds, 5000); } - private void testAtsAttributeValues(Collection<Artifact> artifacts) { + public static void testAtsAttributeValues(SkynetTransaction transaction, HashCollection<String, String> testNameToResultsMap, boolean fixAttributeValues, Collection<Artifact> artifacts) { Date date = new Date(); - try { - SkynetTransaction transaction = new SkynetTransaction(AtsUtil.getAtsBranch(), "Validate ATS Database"); - for (Artifact artifact : artifacts) { - - try { - // Test for null attribute values - for (Attribute<?> attr : artifact.getAttributes()) { - if (attr.getValue() == null) { - testNameToResultsMap.put( - "testAtsAttributeValues", - "Error: Artifact: " + XResultDataUI.getHyperlink(artifact) + " Types: " + artifact.getArtifactTypeName() + " - Null Attribute"); - if (fixAttributeValues) { - attr.delete(); - } + for (Artifact artifact : artifacts) { + try { + // Test for null attribute values + for (Attribute<?> attr : artifact.getAttributes()) { + if (attr.getValue() == null) { + testNameToResultsMap.put( + "testAtsAttributeValues", + "Error: Artifact: " + XResultDataUI.getHyperlink(artifact) + " Types: " + artifact.getArtifactTypeName() + " - Null Attribute"); + if (fixAttributeValues) { + attr.delete(); } } + } - if (artifact instanceof AbstractWorkflowArtifact) { - checkAndResolveDuplicateAttributes(artifact, fixAttributeValues, testNameToResultsMap, transaction); - } + if (artifact instanceof AbstractWorkflowArtifact) { + checkAndResolveDuplicateAttributes(artifact, fixAttributeValues, testNameToResultsMap, transaction); + } - if (artifact.hasDirtyAttributes()) { - artifact.persist(transaction); - } - } catch (OseeCoreException ex) { - OseeLog.log(Activator.class, Level.SEVERE, ex); - testNameToResultsMap.put( - "testAtsAttributeValues", - "Error: Artifact: " + XResultDataUI.getHyperlink(artifact) + " Exception: " + ex.getLocalizedMessage()); + if (artifact.hasDirtyAttributes()) { + artifact.persist(transaction); } + } catch (OseeCoreException ex) { + OseeLog.log(Activator.class, Level.SEVERE, ex); + testNameToResultsMap.put("testAtsAttributeValues", + "Error: Artifact: " + XResultDataUI.getHyperlink(artifact) + " Exception: " + ex.getLocalizedMessage()); } - transaction.execute(); - } catch (OseeCoreException ex) { - OseeLog.log(Activator.class, Level.SEVERE, ex); - testNameToResultsMap.put("testAtsAttributeValues", "Error: Exception: " + ex.getLocalizedMessage()); } - logTestTimeSpent(date, "testAtsAttributeValues", testNameToTimeSpentMap); + // logTestTimeSpent(date, "testAtsAttributeValues", testNameToTimeSpentMap); } - private void checkAndResolveDuplicateAttributes(Artifact artifact, boolean fixAttributeValues, HashCollection<String, String> resultsMap, SkynetTransaction transaction) throws OseeCoreException { + private static void checkAndResolveDuplicateAttributes(Artifact artifact, boolean fixAttributeValues, HashCollection<String, String> resultsMap, SkynetTransaction transaction) throws OseeCoreException { for (AttributeType attrType : artifact.getAttributeTypesUsed()) { int count = artifact.getAttributeCount(attrType); if (count > attrType.getMaxOccurrences()) { |