Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #840 from Netflix/revert-835-compatibility_fix
Browse files Browse the repository at this point in the history
Revert "fix compatibility with 1.x"
  • Loading branch information
apanicker-nflx authored Oct 26, 2018
2 parents f211acb + 8539330 commit 86a9eae
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 65 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/**
* Copyright 2016 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -13,6 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
*/
package com.netflix.conductor.common.metadata.workflow;

import com.github.vmg.protogen.annotations.ProtoField;
Expand All @@ -21,51 +24,22 @@

import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

/**
* @author Viren
*
* This is the task definition defined as part of the {@link WorkflowDef}. The tasks definied in the Workflow definition are saved
* This is the task definition definied as part of the {@link WorkflowDef}. The tasks definied in the Workflow definition are saved
* as part of {@link WorkflowDef#tasks}
*/
@ProtoMessage
public class WorkflowTask {

/**
* This field is deprecated and will be removed in the next version.
* Please use {@link TaskType} instead.
*/
@Deprecated
public enum Type {
SIMPLE, DYNAMIC, FORK_JOIN, FORK_JOIN_DYNAMIC, DECISION, JOIN, SUB_WORKFLOW, EVENT, WAIT, USER_DEFINED;

private static Set<String> systemTasks = new HashSet<>();
static {
systemTasks.add(Type.SIMPLE.name());
systemTasks.add(Type.DYNAMIC.name());
systemTasks.add(Type.FORK_JOIN.name());
systemTasks.add(Type.FORK_JOIN_DYNAMIC.name());
systemTasks.add(Type.DECISION.name());
systemTasks.add(Type.JOIN.name());
systemTasks.add(Type.SUB_WORKFLOW.name());
systemTasks.add(Type.EVENT.name());
systemTasks.add(Type.WAIT.name());
//Do NOT add USER_DEFINED here...
}

public static boolean isSystemTask(String name) {
return systemTasks.contains(name);
}
}

@ProtoField(id = 1)
private String name;

Expand All @@ -78,7 +52,7 @@ public static boolean isSystemTask(String name) {
//Key: Name of the input parameter. MUST be one of the keys defined in TaskDef (e.g. fileName)
//Value: mapping of the parameter from another task (e.g. task1.someOutputParameterAsFileName)
@ProtoField(id = 4)
private Map<String, Object> inputParameters = new HashMap<>();
private Map<String, Object> inputParameters = new HashMap<String, Object>();

@ProtoField(id = 5)
private String type = TaskType.SIMPLE.name();
Expand Down Expand Up @@ -201,7 +175,7 @@ public Map<String, Object> getInputParameters() {
public void setInputParameters(Map<String, Object> inputParameters) {
this.inputParameters = inputParameters;
}

/**
* @return the type
*/
Expand All @@ -212,7 +186,7 @@ public String getType() {
public void setWorkflowTaskType(TaskType type) {
this.type = type.name();
}

/**
* @param type the type to set
*/
Expand All @@ -234,7 +208,7 @@ public void setDecisionCases(Map<String, List<WorkflowTask>> decisionCases) {
this.decisionCases = decisionCases;
}


/**
* @return the defaultCase
*/
Expand Down Expand Up @@ -263,7 +237,7 @@ public void setForkTasks(List<List<WorkflowTask>> forkTasks) {
this.forkTasks = forkTasks;
}


/**
* @return the startDelay in seconds
*/
Expand All @@ -278,7 +252,7 @@ public void setStartDelay(int startDelay) {
this.startDelay = startDelay;
}


/**
* @return the dynamicTaskNameParam
*/
Expand All @@ -288,13 +262,13 @@ public String getDynamicTaskNameParam() {

/**
* @param dynamicTaskNameParam the dynamicTaskNameParam to set to be used by DYNAMIC tasks
*
*
*/
public void setDynamicTaskNameParam(String dynamicTaskNameParam) {
this.dynamicTaskNameParam = dynamicTaskNameParam;
}


/**
* @return the caseValueParam
*/
Expand All @@ -311,19 +285,19 @@ public String getDynamicForkJoinTasksParam() {
public void setDynamicForkJoinTasksParam(String dynamicForkJoinTasksParam) {
this.dynamicForkJoinTasksParam = dynamicForkJoinTasksParam;
}

public String getDynamicForkTasksParam() {
return dynamicForkTasksParam;
}

public void setDynamicForkTasksParam(String dynamicForkTasksParam) {
this.dynamicForkTasksParam = dynamicForkTasksParam;
}

public String getDynamicForkTasksInputParamName() {
return dynamicForkTasksInputParamName;
}

public void setDynamicForkTasksInputParamName(String dynamicForkTasksInputParamName) {
this.dynamicForkTasksInputParamName = dynamicForkTasksInputParamName;
}
Expand All @@ -334,25 +308,25 @@ public void setDynamicForkTasksInputParamName(String dynamicForkTasksInputParamN
public void setCaseValueParam(String caseValueParam) {
this.caseValueParam = caseValueParam;
}

/**
*
*
* @return A javascript expression for decision cases. The result should be a scalar value that is used to decide the case branches.
* @see #getDecisionCases()
*/
public String getCaseExpression() {
return caseExpression;
}

/**
*
*
* @param caseExpression A javascript expression for decision cases. The result should be a scalar value that is used to decide the case branches.
*/
public void setCaseExpression(String caseExpression) {
this.caseExpression = caseExpression;
}


/**
* @return the subWorkflow
*/
Expand Down Expand Up @@ -382,21 +356,21 @@ public void setJoinOn(List<String> joinOn) {
}

/**
*
*
* @return Sink value for the EVENT type of task
*/
public String getSink() {
return sink;
}

/**
*
*
* @param sink Name of the sink
*/
public void setSink(String sink) {
this.sink = sink;
}

/**
*
* @return If the task is optional. When set to true, the workflow execution continues even when the task is in failed status.
Expand All @@ -421,7 +395,7 @@ public void setTaskDefinition(TaskDef taskDefinition) {
}

/**
*
*
* @param optional when set to true, the task is marked as optional
*/
public void setOptional(boolean optional) {
Expand Down Expand Up @@ -532,38 +506,38 @@ public WorkflowTask next(String taskReferenceName, WorkflowTask parent) {
}
return null;
}

public boolean has(String taskReferenceName){

if(this.getTaskReferenceName().equals(taskReferenceName)){
return true;
}

TaskType tt = TaskType.USER_DEFINED;
if(TaskType.isSystemTask(type)) {
tt = TaskType.valueOf(type);
}

switch(tt){

case DECISION:
case FORK_JOIN:
case FORK_JOIN:
for(List<WorkflowTask> childx : children()){
for(WorkflowTask child : childx){
if(child.has(taskReferenceName)){
return true;
}
}
}
}
break;
default:
break;
}

return false;

}

public WorkflowTask get(String taskReferenceName){

if(this.getTaskReferenceName().equals(taskReferenceName)){
Expand All @@ -578,9 +552,9 @@ public WorkflowTask get(String taskReferenceName){
}
}
return null;

}

@Override
public String toString() {
return name + "/" + taskReferenceName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public void setCorrelationId(String correlationId) {
*/
@Deprecated
public String getWorkflowType() {
return getWorkflowName();
return workflowType;
}

/**
Expand All @@ -261,7 +261,7 @@ public void setWorkflowType(String workflowType) {
*/
@Deprecated
public int getVersion() {
return getWorkflowVersion();
return version;
}

/**
Expand Down

0 comments on commit 86a9eae

Please sign in to comment.