Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2012-11-27 18:03:10 +0000
committerRoberto E. Escobar2012-11-27 18:03:10 +0000
commit26cd94656ce1449825f1ac0c103edc485e66d5de (patch)
tree39bf7356cc3065b1951c1db6e3e256deeabc39ed
parentc533048ede9a95fa79d92fef2ae9f090ef2155b1 (diff)
downloadorg.eclipse.osee-26cd94656ce1449825f1ac0c103edc485e66d5de.tar.gz
org.eclipse.osee-26cd94656ce1449825f1ac0c103edc485e66d5de.tar.xz
org.eclipse.osee-26cd94656ce1449825f1ac0c103edc485e66d5de.zip
feature[ats_5RYSH]: Create "Convert Workflow States" blam to aid in work definition state modifications
-rw-r--r--plugins/org.eclipse.osee.ats.core.client.test/src/org/eclipse/osee/ats/core/client/AtsCoreClient_PT_Suite.java2
-rw-r--r--plugins/org.eclipse.osee.ats.core.client.test/src/org/eclipse/osee/ats/core/client/workflow/AtsCoreClient_Workflow_PT_Suite.java37
-rw-r--r--plugins/org.eclipse.osee.ats.core.client.test/src/org/eclipse/osee/ats/core/client/workflow/ConvertWorkflowStatesOperationTest.java144
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/ConvertWorkflowStatesOperation.java180
-rw-r--r--plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/AtsNavigateViewItems.java2
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ConvertWorkflowStatesBlam.java134
7 files changed, 500 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.ats.core.client.test/src/org/eclipse/osee/ats/core/client/AtsCoreClient_PT_Suite.java b/plugins/org.eclipse.osee.ats.core.client.test/src/org/eclipse/osee/ats/core/client/AtsCoreClient_PT_Suite.java
index 86ca7f9f9c1..812dbe374d3 100644
--- a/plugins/org.eclipse.osee.ats.core.client.test/src/org/eclipse/osee/ats/core/client/AtsCoreClient_PT_Suite.java
+++ b/plugins/org.eclipse.osee.ats.core.client.test/src/org/eclipse/osee/ats/core/client/AtsCoreClient_PT_Suite.java
@@ -15,6 +15,7 @@ import org.eclipse.osee.ats.core.client.operation.AtsCoreClient_Operation_PT_Sui
import org.eclipse.osee.ats.core.client.review.AtsCoreClient_Review_PT_Suite;
import org.eclipse.osee.ats.core.client.task.AtsCoreClient_Task_PT_Suite;
import org.eclipse.osee.ats.core.client.util.AtsCoreClient_Util_PT_Suite;
+import org.eclipse.osee.ats.core.client.workflow.AtsCoreClient_Workflow_PT_Suite;
import org.eclipse.osee.ats.core.client.workflow.transition.AtsCoreClient_Transition_PT_Suite;
import org.eclipse.osee.framework.jdk.core.util.OseeProperties;
import org.junit.AfterClass;
@@ -27,6 +28,7 @@ import org.junit.runners.Suite;
AtsCoreClient_Transition_PT_Suite.class,
AtsTestUtilTest.class,
AtsCoreClient_Util_PT_Suite.class,
+ AtsCoreClient_Workflow_PT_Suite.class,
AtsCoreClient_Notify_PT_Suite.class,
AtsCoreClient_Operation_PT_Suite.class,
AtsCoreClient_Review_PT_Suite.class,
diff --git a/plugins/org.eclipse.osee.ats.core.client.test/src/org/eclipse/osee/ats/core/client/workflow/AtsCoreClient_Workflow_PT_Suite.java b/plugins/org.eclipse.osee.ats.core.client.test/src/org/eclipse/osee/ats/core/client/workflow/AtsCoreClient_Workflow_PT_Suite.java
new file mode 100644
index 00000000000..433b0e3511f
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.client.test/src/org/eclipse/osee/ats/core/client/workflow/AtsCoreClient_Workflow_PT_Suite.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.ats.core.client.workflow;
+
+import org.eclipse.osee.framework.jdk.core.util.OseeProperties;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({ConvertWorkflowStatesOperationTest.class})
+/**
+ * This test suite contains tests that must be run against demo database as Plugin JUnit (PT)
+ *
+ * @author Donald G. Dunne
+ */
+public class AtsCoreClient_Workflow_PT_Suite {
+ @BeforeClass
+ public static void setUp() throws Exception {
+ OseeProperties.setIsInTest(true);
+ System.out.println("\n\nBegin " + AtsCoreClient_Workflow_PT_Suite.class.getSimpleName());
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ System.out.println("End " + AtsCoreClient_Workflow_PT_Suite.class.getSimpleName());
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.core.client.test/src/org/eclipse/osee/ats/core/client/workflow/ConvertWorkflowStatesOperationTest.java b/plugins/org.eclipse.osee.ats.core.client.test/src/org/eclipse/osee/ats/core/client/workflow/ConvertWorkflowStatesOperationTest.java
new file mode 100644
index 00000000000..8444a5fd17b
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.client.test/src/org/eclipse/osee/ats/core/client/workflow/ConvertWorkflowStatesOperationTest.java
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.ats.core.client.workflow;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import junit.framework.Assert;
+import org.eclipse.osee.ats.api.data.AtsArtifactTypes;
+import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
+import org.eclipse.osee.ats.core.client.util.AtsUtilCore;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.XResultData;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactCache;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
+import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test case for {@link ConvertWorkflowStatesOperation}
+ *
+ * @author Donald G. Dunne
+ */
+public class ConvertWorkflowStatesOperationTest {
+
+ @BeforeClass
+ @AfterClass
+ public static void cleanup() throws OseeCoreException {
+ SkynetTransaction transaction =
+ TransactionManager.createTransaction(AtsUtilCore.getAtsBranchToken(),
+ "ConvertWorkflowStatesOperationTest.cleanup");
+ for (Artifact art : ArtifactQuery.getArtifactListFromTypeAndName(AtsArtifactTypes.TeamWorkflow,
+ "ConvertWorkflowStatesOperationTest%", AtsUtilCore.getAtsBranchToken())) {
+ art.deleteAndPersist(transaction);
+ }
+ transaction.execute();
+ }
+
+ @Test
+ public void testDoWork_errorChecking() throws Exception {
+ Map<String, String> fromStateToStateMap = new HashMap<String, String>();
+ List<AbstractWorkflowArtifact> workflows = new ArrayList<AbstractWorkflowArtifact>();
+ boolean persist = false;
+ XResultData rd = new XResultData(false);
+ ConvertWorkflowStatesOperation operation =
+ new ConvertWorkflowStatesOperation(fromStateToStateMap, workflows, persist, rd);
+
+ operation.doWork(null);
+ Assert.assertEquals("Error: Must enter FromToState pairs\n", rd.toString());
+
+ fromStateToStateMap.put("Endor;se", "New\"StateName");
+ rd.clear();
+ operation.doWork(null);
+ Assert.assertEquals("Should be two state name errors\n", 2, rd.getNumErrors());
+
+ fromStateToStateMap.clear();
+ fromStateToStateMap.put("Endorse", "NewStateName");
+
+ rd.clear();
+ operation.doWork(null);
+ Assert.assertEquals("Error: No workflows entered\n", rd.toString());
+ }
+
+ @Test
+ public void testDoWork() throws Exception {
+ Map<String, String> fromStateToStateMap = new HashMap<String, String>();
+ fromStateToStateMap.put("Endorse", "NewEndorse");
+ fromStateToStateMap.put("Analyze", "NewAnalyze");
+
+ List<AbstractWorkflowArtifact> workflows = new ArrayList<AbstractWorkflowArtifact>();
+ Artifact teamWf =
+ ArtifactTypeManager.addArtifact(AtsArtifactTypes.TeamWorkflow, AtsUtilCore.getAtsBranchToken(),
+ "ConvertWorkflowStatesOperationTest.testDoWork");
+ teamWf.addAttribute(AtsAttributeTypes.CurrentState, "Endorse;");
+ teamWf.addAttribute(AtsAttributeTypes.State, "Analyze;");
+ teamWf.addAttribute(AtsAttributeTypes.State, "Endorse;");
+ teamWf.addAttribute(AtsAttributeTypes.CompletedFromState, "Analyze");
+ teamWf.addAttribute(AtsAttributeTypes.CancelledFromState, "Endorse");
+ teamWf.addAttribute(AtsAttributeTypes.Log, "log state=\"Endorse\", state=\"Analyze\"");
+ workflows.add((AbstractWorkflowArtifact) teamWf);
+
+ boolean persist = false;
+ XResultData rd = new XResultData(false);
+
+ ConvertWorkflowStatesOperation operation =
+ new ConvertWorkflowStatesOperation(fromStateToStateMap, workflows, persist, rd);
+ operation.doWork(null);
+
+ Assert.assertFalse(rd.isErrors());
+ Assert.assertEquals("NewEndorse;", teamWf.getSoleAttributeValue(AtsAttributeTypes.CurrentState, ""));
+ List<String> stateNames = teamWf.getAttributesToStringList(AtsAttributeTypes.State);
+ Assert.assertEquals(2, stateNames.size());
+ Assert.assertTrue(stateNames.contains("NewAnalyze;"));
+ Assert.assertTrue(stateNames.contains("NewEndorse;"));
+ Assert.assertEquals("NewAnalyze", teamWf.getSoleAttributeValue(AtsAttributeTypes.CompletedFromState, ""));
+ Assert.assertEquals("NewEndorse", teamWf.getSoleAttributeValue(AtsAttributeTypes.CancelledFromState, ""));
+ Assert.assertEquals("log state=\"NewEndorse\", state=\"NewAnalyze\"",
+ teamWf.getSoleAttributeValue(AtsAttributeTypes.Log, ""));
+
+ Assert.assertTrue(teamWf.isDirty());
+ // decache to cleanup test, cause artifact is not persisted
+ ArtifactCache.deCache(teamWf);
+ }
+
+ @Test
+ public void testDoWork_persist() throws Exception {
+ Map<String, String> fromStateToStateMap = new HashMap<String, String>();
+ fromStateToStateMap.put("Endorse", "NewEndorse");
+
+ List<AbstractWorkflowArtifact> workflows = new ArrayList<AbstractWorkflowArtifact>();
+ Artifact teamWf =
+ ArtifactTypeManager.addArtifact(AtsArtifactTypes.TeamWorkflow, AtsUtilCore.getAtsBranchToken(),
+ "ConvertWorkflowStatesOperationTest.testDoWork_persist");
+ teamWf.addAttribute(AtsAttributeTypes.CurrentState, "Endorse;");
+ workflows.add((AbstractWorkflowArtifact) teamWf);
+
+ boolean persist = true;
+ XResultData rd = new XResultData(false);
+
+ ConvertWorkflowStatesOperation operation =
+ new ConvertWorkflowStatesOperation(fromStateToStateMap, workflows, persist, rd);
+ operation.doWork(null);
+
+ Assert.assertFalse(rd.isErrors());
+ Assert.assertEquals("NewEndorse;", teamWf.getSoleAttributeValue(AtsAttributeTypes.CurrentState, ""));
+
+ Assert.assertFalse(teamWf.isDirty());
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/ConvertWorkflowStatesOperation.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/ConvertWorkflowStatesOperation.java
new file mode 100644
index 00000000000..646d7109608
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/ConvertWorkflowStatesOperation.java
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.ats.core.client.workflow;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.logging.Level;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
+import org.eclipse.osee.ats.core.client.internal.Activator;
+import org.eclipse.osee.ats.core.client.util.AtsUtilCore;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.operation.AbstractOperation;
+import org.eclipse.osee.framework.core.util.XResultData;
+import org.eclipse.osee.framework.jdk.core.util.AXml;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.skynet.core.artifact.Attribute;
+import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
+import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager;
+
+/**
+ * This operation will take source workflows and convert state names. Use this BLAM when Work Definition changes require
+ * state re-name or removal. This BLAM will fix old workflows. This works by reading the attributes on the workflow and
+ * search/replacing the fromStateName to the toStateName. NOTE: ATS log will show name changes, but not OSEE history.";
+ *
+ * @author Donald G. Dunne
+ */
+public class ConvertWorkflowStatesOperation extends AbstractOperation {
+
+ private final Collection<? extends AbstractWorkflowArtifact> workflows;
+ private final Map<String, String> fromStateToStateMap;
+ private final XResultData rd;
+ private final boolean persist;
+ private final Pattern pattern = Pattern.compile("^[0-9A-Za-z-_ ]+$");
+
+ /**
+ * @param fromStateToStateMap mapping of pairs of fromStateName and toStateName strings
+ * @param persist true if changes are to be persisted to database
+ * @param rd will contain results of changes which should be reviewed before persisting to DB
+ */
+ public ConvertWorkflowStatesOperation(Map<String, String> fromStateToStateMap, Collection<? extends AbstractWorkflowArtifact> workflows, boolean persist, XResultData rd) {
+ super("Convert ATS Workflow States", Activator.PLUGIN_ID);
+ this.fromStateToStateMap = fromStateToStateMap;
+ this.workflows = workflows;
+ this.persist = persist;
+ this.rd = rd;
+ }
+
+ @Override
+ protected void doWork(IProgressMonitor monitor) throws Exception {
+ SkynetTransaction transaction = null;
+ if (persist) {
+ transaction = TransactionManager.createTransaction(AtsUtilCore.getAtsBranchToken(), getName());
+ }
+ if (fromStateToStateMap.isEmpty()) {
+ rd.logError("Must enter FromToState pairs");
+ } else if (!stateNamesAreValid(fromStateToStateMap, rd)) {
+ return;
+ } else if (workflows.isEmpty()) {
+ rd.logError("No workflows entered");
+ } else {
+ try {
+ for (AbstractWorkflowArtifact awa : workflows) {
+ convertCurrentState(awa);
+ convertStates(awa);
+ convertCompletedFromState(awa);
+ convertCancelledFromState(awa);
+ convertLogStates(awa);
+ if (persist) {
+ awa.persist(transaction);
+ }
+ }
+ } catch (OseeCoreException ex) {
+ rd.logError(ex.getLocalizedMessage() + " (see error log)");
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+ if (persist) {
+ transaction.execute();
+ }
+ }
+
+ private boolean stateNamesAreValid(Map<String, String> fromStateToStateMap, XResultData rd) {
+ boolean valid = true;
+ for (Entry<String, String> fromStateNameToStateName : fromStateToStateMap.entrySet()) {
+ String fromStateName = fromStateNameToStateName.getKey();
+ if (!stateNameIsValid(fromStateName, rd)) {
+ valid = false;
+ }
+ String toStateName = fromStateNameToStateName.getValue();
+ if (!stateNameIsValid(toStateName, rd)) {
+ valid = false;
+ }
+ }
+ return valid;
+ }
+
+ private boolean stateNameIsValid(String stateName, XResultData rd) {
+ Matcher m = pattern.matcher(stateName);
+ if (!m.find()) {
+ rd.logErrorWithFormat(
+ "State name must be alpha-numeric with dashes, spaces or underscores. Invalid for [%s]", stateName);
+ return false;
+ }
+ return true;
+ }
+
+ private void convertLogStates(AbstractWorkflowArtifact awa) throws OseeCoreException {
+ String logStr = awa.getSoleAttributeValue(AtsAttributeTypes.Log, "");
+ String resultLogStr = logStr;
+ for (Entry<String, String> fromToState : fromStateToStateMap.entrySet()) {
+ String fromStr = fromToState.getKey();
+ String toStr = fromToState.getValue();
+ resultLogStr = resultLogStr.replaceAll("state=\"" + fromStr + "\"", "state=\"" + toStr + "\"");
+ }
+ if (!logStr.equals(resultLogStr)) {
+ awa.setSoleAttributeValue(AtsAttributeTypes.Log, resultLogStr);
+ rd.logWithFormat("Converted <can't display>\n", AXml.xmlToText(logStr), AXml.xmlToText(resultLogStr));
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ private void convertStateAttributes(AbstractWorkflowArtifact awa, IAttributeType attrType) throws OseeCoreException {
+ for (Attribute<Object> attribute : awa.getAttributes(attrType)) {
+ for (Entry<String, String> fromToState : fromStateToStateMap.entrySet()) {
+ if (((String) attribute.getValue()).startsWith(fromToState.getKey() + ";")) {
+ String fromStr = ((String) attribute.getValue());
+ String toStr = fromStr.replaceFirst(fromToState.getKey() + ";", fromToState.getValue() + ";");
+ attribute.setValue(toStr);
+ rd.logWithFormat("Convert [%s] \n [%s] to \n [%s]\n", attrType.getName(), fromStr, toStr);
+ }
+ }
+ }
+ }
+
+ private void convertCurrentState(AbstractWorkflowArtifact awa) throws OseeCoreException {
+ convertStateAttributes(awa, AtsAttributeTypes.CurrentState);
+ }
+
+ private void convertStates(AbstractWorkflowArtifact awa) throws OseeCoreException {
+ convertStateAttributes(awa, AtsAttributeTypes.State);
+ }
+
+ private void convertCompletedFromState(AbstractWorkflowArtifact awa) throws OseeCoreException {
+ convertExactMatchAttributeValue(awa, AtsAttributeTypes.CompletedFromState);
+ }
+
+ private void convertCancelledFromState(AbstractWorkflowArtifact awa) throws OseeCoreException {
+ convertExactMatchAttributeValue(awa, AtsAttributeTypes.CancelledFromState);
+ }
+
+ private void convertExactMatchAttributeValue(AbstractWorkflowArtifact awa, IAttributeType attrType) throws OseeCoreException {
+ List<Attribute<Object>> attributes = awa.getAttributes(attrType);
+ if (attributes != null && !attributes.isEmpty()) {
+ for (Attribute<Object> attribute : attributes) {
+ for (Entry<String, String> fromToState : fromStateToStateMap.entrySet()) {
+ if (attribute.getValue().equals(fromToState.getKey())) {
+ String fromStr = ((String) attribute.getValue());
+ String toStr = fromToState.getValue();
+ attribute.setValue(toStr);
+ rd.logWithFormat("Convert [%s] \n [%s] to \n [%s]\n", attrType.getName(), fromStr, toStr);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF
index 791602f2102..2675912ab68 100644
--- a/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF
@@ -31,6 +31,7 @@ Import-Package: com.google.inject,
org.eclipse.osee.framework.core.data,
org.eclipse.osee.framework.core.enums,
org.eclipse.osee.framework.core.exception,
+ org.eclipse.osee.framework.core.operation,
org.eclipse.osee.framework.core.util,
org.eclipse.osee.framework.jdk.core.type,
org.eclipse.osee.framework.jdk.core.util,
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/AtsNavigateViewItems.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/AtsNavigateViewItems.java
index f013e7f151c..0dfc62b6e4f 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/AtsNavigateViewItems.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/AtsNavigateViewItems.java
@@ -40,6 +40,7 @@ import org.eclipse.osee.ats.internal.Activator;
import org.eclipse.osee.ats.navigate.EmailTeamsItem.MemberType;
import org.eclipse.osee.ats.notify.AtsNotificationNavigateItem;
import org.eclipse.osee.ats.notify.EmailActionsBlam;
+import org.eclipse.osee.ats.operation.ConvertWorkflowStatesBlam;
import org.eclipse.osee.ats.operation.MoveTeamWorkflowsBlam;
import org.eclipse.osee.ats.search.AtsQuickSearchOperationFactory;
import org.eclipse.osee.ats.util.AtsEditor;
@@ -194,6 +195,7 @@ public final class AtsNavigateViewItems implements XNavigateViewItems, IXNavigat
new ConvertAIsAndTeamDefinitions(dbConvertItems);
new ImportAIsAndTeamDefinitionsItem(dbConvertItems);
new ImportWorkDefinitionsItem(dbConvertItems);
+ new XNavigateItemBlam(dbConvertItems, new ConvertWorkflowStatesBlam());
new AtsNotificationNavigateItem(adminItems);
new AtsNotificationNavigateItem(adminItems, true);
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ConvertWorkflowStatesBlam.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ConvertWorkflowStatesBlam.java
new file mode 100644
index 00000000000..9e7703c6414
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ConvertWorkflowStatesBlam.java
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.ats.operation;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact;
+import org.eclipse.osee.ats.core.client.workflow.ConvertWorkflowStatesOperation;
+import org.eclipse.osee.ats.internal.Activator;
+import org.eclipse.osee.framework.core.operation.Operations;
+import org.eclipse.osee.framework.core.util.XResultData;
+import org.eclipse.osee.framework.logging.OseeLevel;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
+import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
+import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
+import org.eclipse.osee.framework.ui.skynet.results.XResultDataUI;
+import org.eclipse.osee.framework.ui.swt.Displays;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class ConvertWorkflowStatesBlam extends AbstractBlam {
+
+ private final static String SOURCE_TEAM_WORKFLOWS = "Team Workflow(s) (drop here)";
+ private final static String FROM_TO_MAP = "From State to State mapping (from:to;from:to)";
+ private final static String PERSIST = "Persist (else report only)";
+
+ public ConvertWorkflowStatesBlam() {
+ // do nothing
+ }
+
+ @Override
+ public void runOperation(final VariableMap variableMap, IProgressMonitor monitor) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ List<TeamWorkFlowArtifact> sourceTeamArts =
+ org.eclipse.osee.framework.jdk.core.util.Collections.castAll(TeamWorkFlowArtifact.class,
+ variableMap.getArtifacts(SOURCE_TEAM_WORKFLOWS));
+ String fromToMapStr = variableMap.getString(FROM_TO_MAP);
+ boolean persist = variableMap.getBoolean(PERSIST);
+
+ if (sourceTeamArts.isEmpty()) {
+ AWorkbench.popup("ERROR", "Must drag in Source Team Workflow(s).");
+ return;
+ }
+ if (fromToMapStr.isEmpty()) {
+ AWorkbench.popup("ERROR", "Must enter from/to mappings.");
+ return;
+ }
+ Map<String, String> fromToMap = createFromToMap(fromToMapStr);
+ if (fromToMap == null) {
+ return;
+ }
+ if (fromToMap.isEmpty()) {
+ AWorkbench.popup("ERROR", "No From/To values extracted.");
+ return;
+ }
+ final XResultData rd = new XResultData();
+ ConvertWorkflowStatesOperation operation =
+ new ConvertWorkflowStatesOperation(fromToMap, sourceTeamArts, persist, rd);
+ Operations.executeAsJob(operation, true, Job.LONG, new JobChangeAdapter() {
+
+ @Override
+ public void done(IJobChangeEvent event) {
+ XResultDataUI.report(rd, getName());
+ }
+
+ });
+ } catch (Exception ex) {
+ OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ }
+
+ });
+ }
+
+ private Map<String, String> createFromToMap(String fromToMapStr) {
+ Map<String, String> fromToMap = new HashMap<String, String>();
+ for (String line : fromToMapStr.split(";")) {
+ String[] fromTo = line.split(":");
+ if (fromTo.length != 2 || fromTo[0].isEmpty() || fromTo[1].isEmpty()) {
+ AWorkbench.popup(String.format("Invalid from:to values [%s]", line));
+ return null;
+ }
+ fromToMap.put(fromTo[0], fromTo[1]);
+ }
+ return fromToMap;
+ };
+
+ @Override
+ public String getXWidgetsXml() {
+ return "<xWidgets><XWidget xwidgetType=\"XListDropViewer\" displayName=\"" + SOURCE_TEAM_WORKFLOWS + "\" />" +
+ //
+ "<XWidget xwidgetType=\"XText\" displayName=\"" + FROM_TO_MAP + "\" horizontalLabel=\"true\" />" +
+ //
+ "<XWidget xwidgetType=\"XCheckBox\" displayName=\"" + PERSIST + "\" defaultValue=\"false\"/>" +
+ //
+ "</xWidgets>";
+ }
+
+ @Override
+ public String getDescriptionUsage() {
+ return "Takes source Team Workflow(s) and converts state names. \nUse this BLAM when Work Definition changes require state re-name or removal. \nThis BLAM will fix old workflows\nNOTE: ATS log will show name changes, but not OSEE history.";
+ }
+
+ @Override
+ public String getName() {
+ return "Convert Workflow State Names";
+ }
+
+ @Override
+ public Collection<String> getCategories() {
+ return Arrays.asList("ATS");
+ }
+
+} \ No newline at end of file

Back to the top