Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions src/main/java/com/apiflows/model/Action.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.apiflows.model;

import java.util.ArrayList;
import java.util.List;

public abstract class Action {

private String name;
private String type;
private String workflowId;
private String stepId;
private List<Criterion> criteria;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getWorkflowId() {
return workflowId;
}

public void setWorkflowId(String workflowId) {
this.workflowId = workflowId;
}

public String getStepId() {
return stepId;
}

public void setStepId(String stepId) {
this.stepId = stepId;
}

public List<Criterion> getCriteria() {
return criteria;
}

public void setCriteria(List<Criterion> criteria) {
this.criteria = criteria;
}

public void addCriteria(Criterion criterion) {
if (this.criteria == null) {
this.criteria = new ArrayList<>();
}
this.criteria.add(criterion);
}
}
24 changes: 22 additions & 2 deletions src/main/java/com/apiflows/model/Criterion.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package com.apiflows.model;

import com.apiflows.parser.util.CriterionTypeDeserializer;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

public class Criterion {

private String condition;
private String context;
private String type;

@JsonDeserialize(using = CriterionTypeDeserializer.class)
private Object type;

public String getCondition() {
return condition;
Expand All @@ -24,14 +28,25 @@
this.context = context;
}

/** Returns the simple string type (e.g. "simple", "regex") or null if an expression type object is used. */
@JsonProperty("type")
public String getType() {
return type;
return type instanceof String ? (String) type : null;

Check warning on line 34 in src/main/java/com/apiflows/model/Criterion.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this instanceof check and cast with 'instanceof String string'

See more on https://sonarcloud.io/project/issues?id=API-Flows_openapi-workflow-parser&issues=AZ05ZtFk1XV5X7ZcKJAZ&open=AZ05ZtFk1XV5X7ZcKJAZ&pullRequest=77
}

public void setType(String type) {
this.type = type;
}

/** Returns the expression type object when type is "jsonpath" or "xpath" with a version, or null otherwise. */
public CriterionExpressionType getExpressionType() {
return type instanceof CriterionExpressionType ? (CriterionExpressionType) type : null;

Check warning on line 43 in src/main/java/com/apiflows/model/Criterion.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this instanceof check and cast with 'instanceof CriterionExpressionType criterionexpressiontype'

See more on https://sonarcloud.io/project/issues?id=API-Flows_openapi-workflow-parser&issues=AZ05ZtFk1XV5X7ZcKJAa&open=AZ05ZtFk1XV5X7ZcKJAa&pullRequest=77
}

public void setExpressionType(CriterionExpressionType expressionType) {
this.type = expressionType;
}

public Criterion condition(String condition) {
this.condition = condition;
return this;
Expand All @@ -46,5 +61,10 @@
this.type = type;
return this;
}

public Criterion expressionType(CriterionExpressionType expressionType) {
this.type = expressionType;
return this;
}
}

37 changes: 37 additions & 0 deletions src/main/java/com/apiflows/model/CriterionExpressionType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.apiflows.model;

import com.fasterxml.jackson.annotation.JsonProperty;

public class CriterionExpressionType {

private String type;
private String version;

@JsonProperty("type")
public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

@JsonProperty("version")
public String getVersion() {
return version;
}

public void setVersion(String version) {
this.version = version;
}

public CriterionExpressionType type(String type) {
this.type = type;
return this;
}

public CriterionExpressionType version(String version) {
this.version = version;
return this;
}
}
55 changes: 7 additions & 48 deletions src/main/java/com/apiflows/model/FailureAction.java
Original file line number Diff line number Diff line change
@@ -1,40 +1,9 @@
package com.apiflows.model;

import java.util.ArrayList;
import java.util.List;
public class FailureAction extends Action {

public class FailureAction {

private String type;
private String workflowId;
private String stepId;
private Double retryAfter;
private Integer retryLimit;
private List<Criterion> criteria;

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getWorkflowId() {
return workflowId;
}

public void setWorkflowId(String workflowId) {
this.workflowId = workflowId;
}

public String getStepId() {
return stepId;
}

public void setStepId(String stepId) {
this.stepId = stepId;
}

public Double getRetryAfter() {
return retryAfter;
Expand All @@ -52,26 +21,23 @@ public void setRetryLimit(Integer retryLimit) {
this.retryLimit = retryLimit;
}

public List<Criterion> getCriteria() {
return criteria;
}

public void setCriteria(List<Criterion> criteria) {
this.criteria = criteria;
public FailureAction name(String name) {
setName(name);
return this;
}

public FailureAction type(String type) {
this.type = type;
setType(type);
return this;
}

public FailureAction stepId(String stepId) {
this.stepId = stepId;
setStepId(stepId);
return this;
}

public FailureAction workflowId(String workflowId) {
this.workflowId = workflowId;
setWorkflowId(workflowId);
return this;
}

Expand All @@ -84,11 +50,4 @@ public FailureAction retryLimit(Integer retryLimit) {
this.retryLimit = retryLimit;
return this;
}

public void addCriteria(Criterion criterion) {
if(this.criteria == null) {
this.criteria = new ArrayList<>();
}
this.criteria.add(criterion);
}
}
15 changes: 15 additions & 0 deletions src/main/java/com/apiflows/model/Info.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
public class Info {

private String title;
private String summary;
private String version;
private String description;

Expand All @@ -17,6 +18,15 @@ public void setTitle(String title) {
this.title = title;
}

@JsonProperty("summary")
public String getSummary() {
return summary;
}

public void setSummary(String summary) {
this.summary = summary;
}

@JsonProperty("version")
public String getVersion() {
return version;
Expand All @@ -40,6 +50,11 @@ public Info title(String title) {
return this;
}

public Info summary(String summary) {
this.summary = summary;
return this;
}

public Info version(String version) {
this.version = version;
return this;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/apiflows/model/Parameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class Parameter {

private String name;
private String in;
private String value;
private Object value;
private String reference;

@JsonProperty("name")
Expand All @@ -28,11 +28,11 @@ public void setIn(String in) {
}

@JsonProperty("value")
public String getValue() {
public Object getValue() {
return value;
}

public void setValue(String value) {
public void setValue(Object value) {
this.value = value;
}

Expand All @@ -55,7 +55,7 @@ public Parameter in(String in) {
return this;
}

public Parameter value(String value) {
public Parameter value(Object value) {
this.value = value;
return this;
}
Expand Down
56 changes: 7 additions & 49 deletions src/main/java/com/apiflows/model/SuccessAction.java
Original file line number Diff line number Diff line change
@@ -1,66 +1,24 @@
package com.apiflows.model;

import java.util.ArrayList;
import java.util.List;
public class SuccessAction extends Action {

public class SuccessAction {

private String type;
private String workflowId;
private String stepId;
private List<Criterion> criteria;

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getWorkflowId() {
return workflowId;
}

public void setWorkflowId(String workflowId) {
this.workflowId = workflowId;
}

public String getStepId() {
return stepId;
}

public void setStepId(String stepId) {
this.stepId = stepId;
}

public List<Criterion> getCriteria() {
return criteria;
}

public void setCriteria(List<Criterion> criteria) {
this.criteria = criteria;
}

public void addCriteria(Criterion criterion) {
if(this.criteria == null) {
this.criteria = new ArrayList<>();
}
this.criteria.add(criterion);
public SuccessAction name(String name) {
setName(name);
return this;
}

public SuccessAction type(String type) {
this.type = type;
setType(type);
return this;
}

public SuccessAction workflowId(String workflowId) {
this.workflowId = workflowId;
setWorkflowId(workflowId);
return this;
}

public SuccessAction stepId(String stepId) {
this.stepId = stepId;
setStepId(stepId);
return this;
}
}
Loading
Loading