Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2016-01-20 18:21:40 -0500
committerdonald.g.dunne2016-01-22 11:26:05 -0500
commit5ecefc3e7fcae20af7bf4a4250fa805c342f9833 (patch)
treebdfa3a5f969c1b63a2e7b88b4ea346e3be4ddb10
parent08566a74201ff7be10b26bd69442446bb1c86043 (diff)
downloadorg.eclipse.osee-5ecefc3e7fcae20af7bf4a4250fa805c342f9833.tar.gz
org.eclipse.osee-5ecefc3e7fcae20af7bf4a4250fa805c342f9833.tar.xz
org.eclipse.osee-5ecefc3e7fcae20af7bf4a4250fa805c342f9833.zip
bug[ats_ATS267321]: Reload ATS Workflow prior to handling transition
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/transition/ITransitionHelper.java2
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/transition/TransitionResult.java51
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsStoreService.java26
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/transition/TransitionHelper.java1
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/transition/TransitionHelperAdapter.java25
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/transition/TransitionManager.java64
6 files changed, 111 insertions, 58 deletions
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/transition/ITransitionHelper.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/transition/ITransitionHelper.java
index f46fbf686b..7d31876bb6 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/transition/ITransitionHelper.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/transition/ITransitionHelper.java
@@ -73,4 +73,6 @@ public interface ITransitionHelper {
public IAtsServices getServices();
+ public void handleWorkflowReload(TransitionResults results);
+
}
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/transition/TransitionResult.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/transition/TransitionResult.java
index a429ad03ce..940181f0c3 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/transition/TransitionResult.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/transition/TransitionResult.java
@@ -17,33 +17,34 @@ import org.eclipse.osee.ats.api.workdef.ITransitionResult;
*/
public class TransitionResult implements ITransitionResult {
- public static TransitionResult MUST_BE_TARGETED_FOR_VERSION = new TransitionResult(
- "Actions must be targeted for a Version. Please set \"Target Version\" before transition.");
- public static TransitionResult NO_WORKFLOWS_PROVIDED_FOR_TRANSITION = new TransitionResult(
- "No Workflows provided for transition; aborting.");
- public static TransitionResult TO_STATE_CANT_BE_NULL = new TransitionResult(
- "To-State can not be null for transition.");
- public static TransitionResult MUST_BE_ASSIGNED =
- new TransitionResult(
- "You must be assigned to transition this workflow.\nContact Assignee or Select Privileged Edit for Authorized Overriders.");
+ public static TransitionResult MUST_BE_TARGETED_FOR_VERSION =
+ new TransitionResult("Actions must be targeted for a Version. Please set \"Target Version\" before transition.");
+ public static TransitionResult NO_WORKFLOWS_PROVIDED_FOR_TRANSITION =
+ new TransitionResult("No Workflows provided for transition; aborting.");
+ public static TransitionResult TO_STATE_CANT_BE_NULL =
+ new TransitionResult("To-State can not be null for transition.");
+ public static TransitionResult MUST_BE_ASSIGNED = new TransitionResult(
+ "You must be assigned to transition this workflow.\nContact Assignee or Select Privileged Edit for Authorized Overriders.");
public static TransitionResult TASK_CANT_TRANSITION_IF_PARENT_COMPLETED = new TransitionResult(
"You can not transition a task that belongs to a completed Workflow. Un-complete workflow first.");
- public static TransitionResult DELETE_WORKING_BRANCH_BEFORE_CANCEL = new TransitionResult(
- "Working Branch exists.\n\nPlease delete working branch before transition to cancel.");
- public static TransitionResult WORKING_BRANCH_BEING_COMMITTED = new TransitionResult(
- "Working Branch is being Committed.\n\nPlease wait till commit completes to transition.");
- public static TransitionResult WORKING_BRANCH_EXISTS = new TransitionResult(
- "Working Branch exists.\n\nPlease commit or delete working branch before transition.");
- public static TransitionResult CAN_NOT_TRANSITION_WITH_SYSTEM_USER_ASSIGNED = new TransitionResult(
- "Can not transition with \"Guest\", or \"OseeSystem\" user as assignee.");
- public static TransitionResult CAN_NOT_TRANSITION_AS_SYSTEM_USER = new TransitionResult(
- "Can not transition as \"Guest\", or \"OseeSystem\".");
- public static TransitionResult COMPLETE_BLOCKING_REVIEWS = new TransitionResult(
- "All Blocking Reviews must be completed before transition.");
- public static TransitionResult CANCEL_REVIEWS_BEFORE_CANCEL = new TransitionResult(
- "All Reviews must be cancelled before Cancelling Workflow.");
- public static TransitionResult TASKS_NOT_COMPLETED = new TransitionResult(
- "Tasks Must be Completed/Cancelled to Transition");
+ public static TransitionResult DELETE_WORKING_BRANCH_BEFORE_CANCEL =
+ new TransitionResult("Working Branch exists.\n\nPlease delete working branch before transition to cancel.");
+ public static TransitionResult WORKING_BRANCH_BEING_COMMITTED =
+ new TransitionResult("Working Branch is being Committed.\n\nPlease wait till commit completes to transition.");
+ public static TransitionResult WORKING_BRANCH_EXISTS =
+ new TransitionResult("Working Branch exists.\n\nPlease commit or delete working branch before transition.");
+ public static TransitionResult CAN_NOT_TRANSITION_WITH_SYSTEM_USER_ASSIGNED =
+ new TransitionResult("Can not transition with \"Guest\", or \"OseeSystem\" user as assignee.");
+ public static TransitionResult CAN_NOT_TRANSITION_AS_SYSTEM_USER =
+ new TransitionResult("Can not transition as \"Guest\", or \"OseeSystem\".");
+ public static TransitionResult COMPLETE_BLOCKING_REVIEWS =
+ new TransitionResult("All Blocking Reviews must be completed before transition.");
+ public static TransitionResult CANCEL_REVIEWS_BEFORE_CANCEL =
+ new TransitionResult("All Reviews must be cancelled before Cancelling Workflow.");
+ public static TransitionResult TASKS_NOT_COMPLETED =
+ new TransitionResult("Tasks Must be Completed/Cancelled to Transition");
+ public static TransitionResult WORKITEM_DELETED =
+ new TransitionResult("Work Item has been deleted. Transition is invalid.");
private final String details;
private final Exception exception;
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsStoreService.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsStoreService.java
index 00b61f12ae..9be6f07096 100644
--- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsStoreService.java
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsStoreService.java
@@ -10,7 +10,9 @@
*******************************************************************************/
package org.eclipse.osee.ats.core.client.internal;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.eclipse.osee.ats.api.IAtsObject;
@@ -21,6 +23,7 @@ import org.eclipse.osee.ats.api.util.IAtsStoreService;
import org.eclipse.osee.ats.core.client.util.AtsChangeSet;
import org.eclipse.osee.ats.core.util.AtsUtilCore;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
/**
* @author Donald G. Dunne
@@ -34,8 +37,27 @@ public class AtsStoreService implements IAtsStoreService {
}
@Override
- public List<IAtsWorkItem> reload(List<IAtsWorkItem> inWorkWorkflows) {
- throw new UnsupportedOperationException("Not Available");
+ public List<IAtsWorkItem> reload(List<IAtsWorkItem> workItems) {
+ List<IAtsWorkItem> results = new ArrayList<>();
+ try {
+ List<Artifact> artifacts = new LinkedList<Artifact>();
+ for (IAtsWorkItem workItem : workItems) {
+ if (workItem.getStoreObject() != null && workItem.getStoreObject() instanceof Artifact) {
+ artifacts.add((Artifact) workItem.getStoreObject());
+ }
+ }
+ for (Artifact art : ArtifactQuery.reloadArtifacts(artifacts)) {
+ if (!art.isDeleted()) {
+ IAtsWorkItem workItem = AtsClientService.get().getWorkItemFactory().getWorkItem(art);
+ if (workItem != null) {
+ results.add(workItem);
+ }
+ }
+ }
+ } catch (Exception ex) {
+ // do nothing
+ }
+ return results;
}
@Override
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/transition/TransitionHelper.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/transition/TransitionHelper.java
index d883080a79..0f4d5e6a45 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/transition/TransitionHelper.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/transition/TransitionHelper.java
@@ -151,4 +151,5 @@ public class TransitionHelper extends TransitionHelperAdapter {
public IAtsServices getServices() {
return services;
}
+
}
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/transition/TransitionHelperAdapter.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/transition/TransitionHelperAdapter.java
index 6b7d95c3ef..0f4ff21130 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/transition/TransitionHelperAdapter.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/transition/TransitionHelperAdapter.java
@@ -10,11 +10,15 @@
*******************************************************************************/
package org.eclipse.osee.ats.core.workflow.transition;
+import java.util.ArrayList;
+import java.util.Collection;
import org.eclipse.osee.ats.api.IAtsServices;
import org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.ats.api.user.IAtsUser;
import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow;
import org.eclipse.osee.ats.api.workflow.transition.ITransitionHelper;
+import org.eclipse.osee.ats.api.workflow.transition.TransitionResult;
+import org.eclipse.osee.ats.api.workflow.transition.TransitionResults;
import org.eclipse.osee.ats.core.users.AtsCoreUsers;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.OseeStateException;
@@ -26,6 +30,7 @@ public abstract class TransitionHelperAdapter implements ITransitionHelper {
private final IAtsServices services;
private IAtsUser transitionUser;
+ private boolean workflowsReloaded = false;
public TransitionHelperAdapter(IAtsServices services) {
this.services = services;
@@ -63,8 +68,8 @@ public abstract class TransitionHelperAdapter implements ITransitionHelper {
@Override
public boolean isSystemUserAssingee(IAtsWorkItem workItem) throws OseeCoreException {
- return workItem.getStateMgr().getAssignees().contains(AtsCoreUsers.GUEST_USER) || workItem.getStateMgr().getAssignees().contains(
- AtsCoreUsers.SYSTEM_USER);
+ return workItem.getStateMgr().getAssignees().contains(
+ AtsCoreUsers.GUEST_USER) || workItem.getStateMgr().getAssignees().contains(AtsCoreUsers.SYSTEM_USER);
}
@Override
@@ -86,4 +91,20 @@ public abstract class TransitionHelperAdapter implements ITransitionHelper {
transitionUser = user;
}
+ @Override
+ public abstract Collection<? extends IAtsWorkItem> getWorkItems();
+
+ @Override
+ public void handleWorkflowReload(TransitionResults results) {
+ if (!workflowsReloaded) {
+ services.getStoreService().reload(new ArrayList<>(getWorkItems()));
+ for (IAtsWorkItem workItem : getWorkItems()) {
+ if (services.getStoreService().isDeleted(workItem)) {
+ results.addResult(workItem, TransitionResult.WORKITEM_DELETED);
+ }
+ }
+ workflowsReloaded = true;
+ }
+ }
+
}
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/transition/TransitionManager.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/transition/TransitionManager.java
index c660405785..45cc8dc902 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/transition/TransitionManager.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/transition/TransitionManager.java
@@ -77,7 +77,10 @@ public class TransitionManager implements IAtsTransitionManager {
@Override
public TransitionResults handleAll() {
TransitionResults results = new TransitionResults();
-
+ handleWorkflowReload(results);
+ if (results.isCancelled() || !results.isEmpty()) {
+ return results;
+ }
handleTransitionValidation(results);
if (results.isCancelled() || !results.isEmpty()) {
return results;
@@ -90,9 +93,13 @@ public class TransitionManager implements IAtsTransitionManager {
return results;
}
+ private void handleWorkflowReload(TransitionResults results) {
+ helper.handleWorkflowReload(results);
+ }
+
/**
* Validate AbstractWorkflowArtifact for transition including checking widget validation, rules, assignment, etc.
- *
+ *
* @return Result.isFalse if failure
*/
@Override
@@ -112,8 +119,8 @@ public class TransitionManager implements IAtsTransitionManager {
return;
}
} catch (OseeCoreException ex) {
- results.addResult(new TransitionResult(String.format("Exception while validating transition [%s]",
- helper.getName()), ex));
+ results.addResult(
+ new TransitionResult(String.format("Exception while validating transition [%s]", helper.getName()), ex));
}
for (IAtsWorkItem workItem : helper.getWorkItems()) {
try {
@@ -122,18 +129,17 @@ public class TransitionManager implements IAtsTransitionManager {
IAtsStateDefinition fromStateDef = workItem.getStateDefinition();
IAtsStateDefinition toStateDef = workItem.getWorkDefinition().getStateByName(helper.getToStateName());
if (toStateDef == null) {
- results.addResult(
- workItem,
- new TransitionResult(String.format(
- "Transition-To State [%s] does not exist for Work Definition [%s]", helper.getToStateName(),
- workItem.getWorkDefinition().getName())));
+ results.addResult(workItem,
+ new TransitionResult(String.format("Transition-To State [%s] does not exist for Work Definition [%s]",
+ helper.getToStateName(), workItem.getWorkDefinition().getName())));
continue;
}
//Ignore transitions to the same state
if (!fromStateDef.equals(toStateDef)) {
// Validate transition from fromState and toState
- if (!helper.isOverrideTransitionValidityCheck() && !fromStateDef.getToStates().contains(toStateDef) && !fromStateDef.getStateType().isCompletedOrCancelledState()) {
+ if (!helper.isOverrideTransitionValidityCheck() && !fromStateDef.getToStates().contains(
+ toStateDef) && !fromStateDef.getStateType().isCompletedOrCancelledState()) {
String errStr =
String.format("Work Definition [%s] is not configured to transition from \"[%s]\" to \"[%s]\"",
fromStateDef.getWorkDefinition().getName(), fromStateDef.getName(), toStateDef.getName());
@@ -143,10 +149,9 @@ public class TransitionManager implements IAtsTransitionManager {
}
// Validate Editable
- boolean stateIsEditable =
- WorkflowManagerCore.isEditable(workItem, workItem.getStateDefinition(),
- helper.isPrivilegedEditEnabled(), helper.getTransitionUser(),
- userService.isAtsAdmin(helper.getTransitionUser()));
+ boolean stateIsEditable = WorkflowManagerCore.isEditable(workItem, workItem.getStateDefinition(),
+ helper.isPrivilegedEditEnabled(), helper.getTransitionUser(),
+ userService.isAtsAdmin(helper.getTransitionUser()));
boolean currentlyUnAssigned =
workItem.getStateMgr().getAssignees().contains(AtsCoreUsers.UNASSIGNED_USER);
workItem.getStateMgr().validateNoBootstrapUser();
@@ -168,7 +173,8 @@ public class TransitionManager implements IAtsTransitionManager {
}
// Validate Assignees (UnAssigned ok cause will be resolve to current user upon transition
- if (!overrideAssigneeCheck && !toStateDef.getStateType().isCancelledState() && helper.isSystemUserAssingee(workItem)) {
+ if (!overrideAssigneeCheck && !toStateDef.getStateType().isCancelledState() && helper.isSystemUserAssingee(
+ workItem)) {
results.addResult(workItem, TransitionResult.CAN_NOT_TRANSITION_WITH_SYSTEM_USER_ASSIGNED);
continue;
}
@@ -206,8 +212,7 @@ public class TransitionManager implements IAtsTransitionManager {
continue;
}
} catch (OseeCoreException ex) {
- results.addResult(
- workItem,
+ results.addResult(workItem,
new TransitionResult(String.format("Exception [%s] while validating transition extensions 1 [%s]",
ex.getMessage(), helper.getName()), ex));
}
@@ -218,13 +223,13 @@ public class TransitionManager implements IAtsTransitionManager {
if (results.isEmpty()) {
for (ITransitionListener listener : helper.getTransitionListeners()) {
try {
- listener.transitioning(results, workItem, fromStateDef, toStateDef, getToAssignees(workItem, toStateDef));
+ listener.transitioning(results, workItem, fromStateDef, toStateDef,
+ getToAssignees(workItem, toStateDef));
if (results.isCancelled() || !results.isEmpty()) {
continue;
}
} catch (OseeCoreException ex) {
- results.addResult(
- workItem,
+ results.addResult(workItem,
new TransitionResult(String.format("Exception [%s] while validating transition extensions 2 [%s]",
ex.getMessage(), helper.getName()), ex));
}
@@ -235,7 +240,7 @@ public class TransitionManager implements IAtsTransitionManager {
/**
* Request extra information if transition requires hours spent prompt, cancellation reason, etc.
- *
+ *
* @return Result.isFalse if failure or Result.isCancelled if canceled
*/
@Override
@@ -258,7 +263,7 @@ public class TransitionManager implements IAtsTransitionManager {
/**
* Process transition and persist changes to given skynet transaction
- *
+ *
* @return Result.isFalse if failure
*/
@Override
@@ -299,9 +304,8 @@ public class TransitionManager implements IAtsTransitionManager {
// Create validation review if in correct state and TeamWorkflow
if (reviewService.isValidationReviewRequired(workItem) && workItem.isTeamWorkflow()) {
- IAtsDecisionReview review =
- reviewService.createValidateReview((IAtsTeamWorkflow) workItem, false, transitionDate,
- transitionUser, helper.getChangeSet());
+ IAtsDecisionReview review = reviewService.createValidateReview((IAtsTeamWorkflow) workItem, false,
+ transitionDate, transitionUser, helper.getChangeSet());
if (review != null) {
helper.getChangeSet().add(review);
}
@@ -326,8 +330,8 @@ public class TransitionManager implements IAtsTransitionManager {
helper.getChangeSet().execute();
}
} catch (Exception ex) {
- results.addResult(new TransitionResult(String.format("Exception while transitioning [%s]", helper.getName()),
- ex));
+ results.addResult(
+ new TransitionResult(String.format("Exception while transitioning [%s]", helper.getName()), ex));
}
}
@@ -381,7 +385,8 @@ public class TransitionManager implements IAtsTransitionManager {
// Loop through this state's blocking reviews to confirm complete
if (workItem.isTeamWorkflow()) {
for (IAtsAbstractReview review : reviewService.getReviewsFromCurrentState((IAtsTeamWorkflow) workItem)) {
- if (reviewService.getReviewBlockType(review) == ReviewBlockType.Transition && !review.getStateMgr().getStateType().isCompletedOrCancelled()) {
+ if (reviewService.getReviewBlockType(
+ review) == ReviewBlockType.Transition && !review.getStateMgr().getStateType().isCompletedOrCancelled()) {
results.addResult(workItem, TransitionResult.COMPLETE_BLOCKING_REVIEWS);
}
}
@@ -406,7 +411,8 @@ public class TransitionManager implements IAtsTransitionManager {
// Loop through this state's tasks to confirm complete
boolean checkTasksCompletedForState = true;
// Don't check for task completion if transition to working state and AllowTransitionWithoutTaskCompletion rule is set
- if (workItem.getStateDefinition().hasRule(RuleDefinitionOption.AllowTransitionWithoutTaskCompletion.name()) && toStateDef.getStateType().isWorkingState()) {
+ if (workItem.getStateDefinition().hasRule(
+ RuleDefinitionOption.AllowTransitionWithoutTaskCompletion.name()) && toStateDef.getStateType().isWorkingState()) {
checkTasksCompletedForState = false;
}
if (checkTasksCompletedForState && workItem.isTeamWorkflow() && !workItem.getStateMgr().getStateType().isCompletedOrCancelled()) {

Back to the top