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 #835 from Netflix/compatibility_fix
Browse files Browse the repository at this point in the history
fix compatibility with 1.x
  • Loading branch information
apanicker-nflx authored Oct 25, 2018
2 parents 3f740ac + f241c42 commit f211acb
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 39 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,9 +13,6 @@
* 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 @@ -24,22 +21,51 @@

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 definied as part of the {@link WorkflowDef}. The tasks definied in the Workflow definition are saved
* This is the task definition defined 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 @@ -52,7 +78,7 @@ public class WorkflowTask {
//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<String, Object>();
private Map<String, Object> inputParameters = new HashMap<>();

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

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

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


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


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


/**
* @return the dynamicTaskNameParam
*/
Expand All @@ -262,13 +288,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 @@ -285,19 +311,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 @@ -308,25 +334,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 @@ -356,21 +382,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 @@ -395,7 +421,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 @@ -506,38 +532,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 @@ -552,9 +578,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 workflowType;
return getWorkflowName();
}

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

/**
Expand Down

0 comments on commit f211acb

Please sign in to comment.