优化代码
This commit is contained in:
@@ -11,7 +11,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
|||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||||
|
|
||||||
@@ -21,8 +20,8 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
|||||||
* @author lanyuanxiaoyao
|
* @author lanyuanxiaoyao
|
||||||
* @version 20250103
|
* @version 20250103
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan
|
|
||||||
@EnableJpaRepositories("com.lanyuanxiaoyao.flowable.jpa.repository")
|
@EnableJpaRepositories("com.lanyuanxiaoyao.flowable.jpa.repository")
|
||||||
@EnableConfigurationProperties(SpringFlowableConfiguration.class)
|
@EnableConfigurationProperties(SpringFlowableConfiguration.class)
|
||||||
public class SpringFlowableAutoConfiguration {
|
public class SpringFlowableAutoConfiguration {
|
||||||
|
|||||||
@@ -81,11 +81,16 @@ public abstract class FlowableManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String start(String nodeId, Map<String, Object> metadata) {
|
public String start(String nodeId, Map<String, Object> metadata) {
|
||||||
|
return start(nodeId, metadata, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String start(String nodeId, Map<String, Object> metadata, String extra) {
|
||||||
FlowableNode node = repository.getNode(nodeId);
|
FlowableNode node = repository.getNode(nodeId);
|
||||||
FlowableInstance instance = FlowableInstance.builder()
|
FlowableInstance instance = FlowableInstance.builder()
|
||||||
.instanceId(createId())
|
.instanceId(createId())
|
||||||
.currentNodeId(node.getNodeId())
|
.currentNodeId(node.getNodeId())
|
||||||
.metadata(new FlowableMetadata(metadata))
|
.metadata(new FlowableMetadata(metadata))
|
||||||
|
.extra(extra)
|
||||||
.build();
|
.build();
|
||||||
repository.saveInstance(instance);
|
repository.saveInstance(instance);
|
||||||
callListeners(node.getListeners(), listener -> listener.onFlowStart(instance, node));
|
callListeners(node.getListeners(), listener -> listener.onFlowStart(instance, node));
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ public class FlowableMetadata implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FlowableMetadata(Map<String, Object> metadata) {
|
public FlowableMetadata(Map<String, Object> metadata) {
|
||||||
|
if (metadata == null) {
|
||||||
|
metadata = new HashMap<>();
|
||||||
|
}
|
||||||
this.metadata = metadata;
|
this.metadata = metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user