Comments (5)
I propose the following interface
public interface RestCallIntf
{
String postJson(EndPoint endPoint, String urlSuffix, String content);
String putJson(EndPoint endPoint, String urlSuffix, String content);
String getJson(EndPoint endPoint, String urlSuffix, Map<String, String> params);
String deleteJson(EndPoint endPoint, String urlSuffix, Map<String, String> params);
}
where
public class EndPoint implements Serializable
{
private String id;
private String url;
private String user;
private String password;
private int connectTimeout;
private int readTimeout;
...
}
EndPoints could be built via EL expression on a first step of workflow like this:
${
execution.setVariables(endPoints.builder
.add("endPoint1", "http://somehost:8080/restService", null, null, 10000, 10000)
.map())
}
and a call from a Rest service task made like this:
${
restCall.getJson(endPoint1, "?param1=value1", null))
}
And the spring beans defined like this:
package org.flowable.app.service.addon;
@Component("endPoints")`
public class EndPoints
{
public EndPointsBuilder getBuilder()
{
return new EndPointsBuilder();
}
}
package org.flowable.app.service.addon;
@Component("restCall")
public class RestCall implements RestCallIntf
{
}
from flowable-engine.
And JsonTool for parsing
package org.flowable.app.service.addon;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@Component("jsonTool")
public class JsonTool
{
private static final ObjectMapper mapper = new ObjectMapper();
static
{
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
}
public <T> T toObject(String json, Class<T> clazz)
{
try
{
return mapper.readValue(json, clazz);
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
public <T> T[] toArray(String json, Class<T[]> clazz)
{
return toObject(json, clazz);
}
public <T> List<T> toList(String json, Class<T[]> clazz)
{
return Arrays.asList(toArray(json, clazz));
}
public <T> Map<String, T> toMap(String json, Class<T> clazz)
{
try
{
return mapper.readValue(json, mapper.getTypeFactory().constructMapType(Map.class, String.class, clazz));
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
public String toJsonString(Object val)
{
try
{
return mapper.writeValueAsString(val);
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}
public Object toObj(String json)
{
return toObject(json, Object.class);
}
public Object[] toArr(String json)
{
return toArray(json, Object[].class);
}
}
so call EL can be like this:
${
jsonTool.toObj(restCall.getJson(endPoint1, "?param1=value1", null))
}
from flowable-engine.
Looks like if this one is implemented together with
#183 (#183)
(Especially with approach from #183 to call many functions in single EL expression)
it will be possible to use flowable with REST services "as-is".
Workflow can be directly created in flowable-modeler with EL language and mix of REST calls
(No Java coding at ALL to create an application ready to run).
No writing custom beans, no spring configurations would be necessary
Thanks
from flowable-engine.
Please feel free to implement and submit a pull request.
from flowable-engine.
REST task has been added
from flowable-engine.
Related Issues (20)
- flowable-ui的版本和flowable-engine的版本不太一致
- Delay in seconds before script condition executed HOT 6
- task complete before report NoSuchMethodError: org.flowable.bpmn.model.UserTask.getTaskCompleterVariableName() , flowable version: 7.0.1 HOT 2
- Flowable 7.0.1 not getting installed in ecliupse HOT 1
- Conditions should support more than JUEL expressions
- suspendProcessInstanceById question
- BpmnXMLUtil.parseExtensionElement setElementText has bug of Line wrap cover HOT 1
- Process migration cannot migrate processes HOT 1
- Process definition id of an async external worker service task job is not updated after direct migration HOT 2
- 是否有审批人驳回到上级,上级修改后在发起继续审批流程 HOT 1
- Invalid SQL upgrade scripts for HSQL database (7.0.0 -> 7.0.1)
- The DefaultIdentityLinkIterceptor.java creates duplicate identityLinks on ProcessInstance
- AsyncTaskInvokerTaskExecutor supplied by Spring Boot autoconfiguration is not started
- Not possible to exclude the `flowable-event-registry` JAR even if EventRegistry disabled
- startProcessInstanceByKey does not always trigger the process HOT 3
- Liquibase first up does not work with JtaProcessEngineConfiguration HOT 1
- Timer job never unlocked after an exception
- Query the sorting exception of HistoricActivityInstance
- After running runtimeService().deleteProcessInstance(processInstance.getId()) to delete the parent process instance, the CallActivity subprocessInstance query is null HOT 1
- Flowable Open Source Documentation should support dark mode
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flowable-engine.