Skip to content

Commit

Permalink
deprecate State.name in rest api. Fix javadocs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Edvard Fonsell committed Sep 17, 2014
1 parent 5119a0b commit 7326265
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public interface StateExecution {
* The name of the variable.
* @param type
* The class of the variable.
* @return The deserialized value of class {code <T>}.
* @param <T>
* The type of object to be deserialized.
* @return The deserialized value of class {code T}.
*/
<T> T getVariable(String name, Class<T> type);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public interface WorkflowState {
* Return the name of the workflow state.
*
* @return The name.
* @deprecate Use name() instead. Will be removed in 2.0.
* @deprecated Use name() instead. Will be removed in 2.0.
* TODO 2.0: remove
*/
@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ListWorkflowDefinitionResponse convert(WorkflowDefinition<? extends Workf
Map<String, State> states = new LinkedHashMap<>();
for (WorkflowState state : definition.getStates()) {
states.put(state.name(), new State(state.name(), state.getType().name(),
state.getName(), state.getDescription()));
state.getDescription()));
}
for (Entry<String, List<String>> entry : definition.getAllowedTransitions().entrySet()) {
State state = states.get(entry.getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,57 @@
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

@ApiModel(value = "Workflow definition states and transition to next states")
@SuppressFBWarnings(value="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD", justification="jackson reads dto fields")
@SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD", justification = "jackson reads dto fields")
public class State {

/**
* Create a state.
*
* @deprecated Use the version that does not take name parameter. This
* constructor will be removed in 2.0.
* @param id
* The state identifier.
* @param type
* The state type.
* @param name
* The state name.
* @param description
* The state description.
*/
@Deprecated
public State(String id, String type, String name, String description) {
this.id = id;
this.type = type;
this.name = name;
this.description = description;
}

@ApiModelProperty(value = "State identifier", required=true)
public State(String id, String type, String description) {
this.id = id;
this.type = type;
this.name = id;
this.description = description;
}

@ApiModelProperty(value = "State identifier", required = true)
public String id;

@ApiModelProperty(value = "State type", required=true)
@ApiModelProperty(value = "State type", required = true)
public String type;

@ApiModelProperty(value = "State name", required=true)
/**
* @deprecated Use id instead. Will be removed in 2.0.
*/
@Deprecated
@ApiModelProperty(value = "State name", required = true)
public String name;

@ApiModelProperty(value = "State description", required=true)
@ApiModelProperty(value = "State description", required = true)
public String description;

@ApiModelProperty(value = "Alternative transitions from this state", required=false)
@ApiModelProperty(value = "Alternative transitions from this state", required = false)
public Set<String> transitions = new LinkedHashSet<>();

@ApiModelProperty(value = "Failure state for the this state", required=false)
@ApiModelProperty(value = "Failure state for the this state", required = false)
public String onFailure;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@
public class DummyTestWorkflow extends WorkflowDefinition<DummyTestWorkflow.State> {

public static enum State implements com.nitorcreations.nflow.engine.workflow.definition.WorkflowState {
start(WorkflowStateType.start, "start", "start desc"),
error(WorkflowStateType.manual, "error", "error desc"),
end(WorkflowStateType.end, "end", "end desc");
start(WorkflowStateType.start, "start desc"),
error(WorkflowStateType.manual, "error desc"),
end(WorkflowStateType.end, "end desc");

private WorkflowStateType type;
private String name;
private String description;

private State(WorkflowStateType type, String name, String description) {
private State(WorkflowStateType type, String description) {
this.type = type;
this.name = name;
this.description = description;
}

Expand All @@ -36,14 +34,13 @@ public WorkflowStateType getType() {

@Override
public String getName() {
return name;
return name();
}

@Override
public String getDescription() {
return description;
}

}

public DummyTestWorkflow() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void convertWorks() {
private State getResponseState(DummyTestWorkflow.State workflowState,
List<String> nextStateNames, String errorStateName) {
State state = new State(workflowState.name(),
workflowState.getType().name(), workflowState.getName(), workflowState.getDescription());
workflowState.getType().name(), workflowState.getDescription());
state.transitions.addAll(nextStateNames);
state.onFailure = errorStateName;
return state;
Expand Down

0 comments on commit 7326265

Please sign in to comment.