本文整理汇总了Java中org.activiti.engine.repository.ProcessDefinition类的典型用法代码示例。如果您正苦于以下问题:Java ProcessDefinition类的具体用法?Java ProcessDefinition怎么用?Java ProcessDefinition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProcessDefinition类属于org.activiti.engine.repository包,在下文中一共展示了ProcessDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deploy
import org.activiti.engine.repository.ProcessDefinition; //导入依赖的package包/类
/**
* 发布流程.
*/
@RequestMapping("console-deploy")
public String deploy(@RequestParam("xml") String xml) throws Exception {
RepositoryService repositoryService = processEngine
.getRepositoryService();
ByteArrayInputStream bais = new ByteArrayInputStream(
xml.getBytes("UTF-8"));
Deployment deployment = repositoryService.createDeployment()
.addInputStream("process.bpmn20.xml", bais).deploy();
List<ProcessDefinition> processDefinitions = repositoryService
.createProcessDefinitionQuery()
.deploymentId(deployment.getId()).list();
for (ProcessDefinition processDefinition : processDefinitions) {
processEngine.getManagementService().executeCommand(
new SyncProcessCmd(processDefinition.getId()));
}
return "redirect:/bpm/console-listProcessDefinitions.do";
}
示例2: getAllDefinitionsByName
import org.activiti.engine.repository.ProcessDefinition; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public List<WorkflowDefinition> getAllDefinitionsByName(String workflowName)
{
try
{
String key = factory.getProcessKey(workflowName);
List<ProcessDefinition> definitions = repoService.createProcessDefinitionQuery()
.processDefinitionKey(key)
.list();
return getValidWorkflowDefinitions(definitions);
}
catch (ActivitiException ae)
{
String msg = messageService.getMessage(ERR_GET_ALL_DEFS_BY_NAME, workflowName);
if(logger.isDebugEnabled())
{
logger.debug(msg, ae);
}
throw new WorkflowException(msg, ae);
}
}
示例3: getDefinitionByName
import org.activiti.engine.repository.ProcessDefinition; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public WorkflowDefinition getDefinitionByName(String workflowName)
{
try
{
String key = factory.getLocalEngineId(workflowName);
if(activitiUtil.isMultiTenantWorkflowDeploymentEnabled())
{
key = factory.getDomainProcessKey(workflowName);
}
ProcessDefinition definition = activitiUtil.getProcessDefinitionByKey(key);
return typeConverter.convert(definition);
}
catch (ActivitiException ae)
{
String msg = messageService.getMessage(ERR_GET_WORKFLOW_DEF_BY_NAME, workflowName);
if(logger.isDebugEnabled())
{
logger.debug(msg, ae);
}
throw new WorkflowException(msg, ae);
}
}
示例4: getWorkflowsInternal
import org.activiti.engine.repository.ProcessDefinition; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private List<WorkflowInstance> getWorkflowsInternal(WorkflowInstanceQuery workflowInstanceQuery, boolean isActive, int maxItems, int skipCount)
{
// MNT-9074 My Tasks fails to render if tasks quantity is excessive
HistoricProcessInstanceQuery query = createQuery(workflowInstanceQuery, isActive);
LinkedList<WorkflowInstance> results = new LinkedList<WorkflowInstance>();
List<HistoricProcessInstance> completedInstances;
if (maxItems > 0)
{
completedInstances = query.orderByProcessInstanceDuration().desc().listPage(skipCount, maxItems);
}
else
{
completedInstances = query.list();
}
List<WorkflowInstance> completedResults = typeConverter.doSpecialTenantFilterAndSafeConvert(completedInstances, new Function<HistoricProcessInstance, String>()
{
public String apply(HistoricProcessInstance historicProcessInstance)
{
ProcessDefinition procDef = activitiUtil.getProcessDefinition(historicProcessInstance.getProcessDefinitionId());
return procDef.getKey();
}
});
results.addAll(completedResults);
return results;
}
示例5: convert
import org.activiti.engine.repository.ProcessDefinition; //导入依赖的package包/类
/**
* Convert a {@link ProcessDefinition} into a {@link WorkflowDefinition}.
* @param definition ProcessDefinition
* @return WorkflowDefinition
*/
public WorkflowDefinition convert(ProcessDefinition definition)
{
if(definition==null)
return null;
String defId = definition.getId();
String defName = definition.getKey();
int version = definition.getVersion();
String defaultTitle = definition.getName();
String startTaskName = null;
StartFormData startFormData = getStartFormData(defId, defName);
if(startFormData != null)
{
startTaskName = startFormData.getFormKey();
}
ReadOnlyProcessDefinition def = activitiUtil.getDeployedProcessDefinition(defId);
PvmActivity startEvent = def.getInitial();
WorkflowTaskDefinition startTask = getTaskDefinition(startEvent, startTaskName, definition.getKey(), true);
return factory.createDefinition(defId,
defName, version, defaultTitle,
null, startTask);
}
示例6: convertToInstanceAndSetVariables
import org.activiti.engine.repository.ProcessDefinition; //导入依赖的package包/类
public WorkflowInstance convertToInstanceAndSetVariables(HistoricProcessInstance historicProcessInstance, Map<String, Object> collectedVariables)
{
String processInstanceId = historicProcessInstance.getId();
String id = processInstanceId;
ProcessDefinition procDef = activitiUtil.getProcessDefinition(historicProcessInstance.getProcessDefinitionId());
WorkflowDefinition definition = convert(procDef);
// Set process variables based on historic detail query
Map<String, Object> variables = propertyConverter.getHistoricProcessVariables(processInstanceId);
Date startDate = historicProcessInstance.getStartTime();
Date endDate = historicProcessInstance.getEndTime();
// Copy all variables to map, if not null
if(collectedVariables != null)
{
collectedVariables.putAll(variables);
}
boolean isActive = endDate == null;
return factory.createInstance(id, definition, variables, isActive, startDate, endDate);
}
示例7: confImportSave
import org.activiti.engine.repository.ProcessDefinition; //导入依赖的package包/类
/**
* 导入.
*/
@RequestMapping("conf-import-save")
public String confImportSave(@RequestParam("text") String text)
throws Exception {
Map<String, Object> json = jsonMapper.fromJson(text, Map.class);
// xml
ProcessDefinition processDefinition = this.importXml((String) json
.get("xml"));
// process
BpmProcess bpmProcess = this.importProcess(json);
// conf
BpmConfBase bpmConfBase = this.importConf(json, processDefinition);
bpmProcess.setBpmConfBase(bpmConfBase);
bpmProcessManager.save(bpmProcess);
return "bpm/dev/conf-import-save";
}
示例8: importConf
import org.activiti.engine.repository.ProcessDefinition; //导入依赖的package包/类
public BpmConfBase importConf(Map<String, Object> json,
ProcessDefinition processDefinition) {
BpmConfBase bpmConfBase = new BpmConfBase();
bpmConfBase.setProcessDefinitionId(processDefinition.getId());
bpmConfBase.setProcessDefinitionKey(processDefinition.getKey());
bpmConfBase.setProcessDefinitionVersion(processDefinition.getVersion());
bpmConfBaseManager.save(bpmConfBase);
List<Map<String, Object>> nodes = (List<Map<String, Object>>) json
.get("nodes");
for (Map<String, Object> nodeMap : nodes) {
this.importNode(nodeMap, bpmConfBase);
}
return bpmConfBase;
}
示例9: processUpload
import org.activiti.engine.repository.ProcessDefinition; //导入依赖的package包/类
/**
* 上传发布流程定义.
*/
@RequestMapping("console-process-upload")
public String processUpload(@RequestParam("file") MultipartFile file,
RedirectAttributes redirectAttributes) throws Exception {
String tenantId = tenantHolder.getTenantId();
String fileName = file.getOriginalFilename();
Deployment deployment = processEngine.getRepositoryService()
.createDeployment()
.addInputStream(fileName, file.getInputStream())
.tenantId(tenantId).deploy();
List<ProcessDefinition> processDefinitions = processEngine
.getRepositoryService().createProcessDefinitionQuery()
.deploymentId(deployment.getId()).list();
for (ProcessDefinition processDefinition : processDefinitions) {
processEngine.getManagementService().executeCommand(
new SyncProcessCmd(processDefinition.getId()));
}
return "redirect:/bpm/console-listProcessDefinitions.do";
}
示例10: viewXml
import org.activiti.engine.repository.ProcessDefinition; //导入依赖的package包/类
/**
* 显示流程定义的xml.
*/
@RequestMapping("console-viewXml")
public void viewXml(
@RequestParam("processDefinitionId") String processDefinitionId,
HttpServletResponse response) throws Exception {
RepositoryService repositoryService = processEngine
.getRepositoryService();
ProcessDefinition processDefinition = repositoryService
.createProcessDefinitionQuery()
.processDefinitionId(processDefinitionId).singleResult();
String resourceName = processDefinition.getResourceName();
InputStream resourceAsStream = repositoryService.getResourceAsStream(
processDefinition.getDeploymentId(), resourceName);
response.setContentType("text/xml;charset=UTF-8");
IOUtils.copy(resourceAsStream, response.getOutputStream());
}
示例11: beforeUpdateProcess
import org.activiti.engine.repository.ProcessDefinition; //导入依赖的package包/类
/**
* 更新流程之前,填写xml.
*/
@RequestMapping("console-beforeUpdateProcess")
public String beforeUpdateProcess(
@RequestParam("processDefinitionId") String processDefinitionId,
Model model) throws Exception {
ProcessDefinition processDefinition = processEngine
.getRepositoryService().getProcessDefinition(
processDefinitionId);
InputStream is = processEngine.getRepositoryService()
.getResourceAsStream(processDefinition.getDeploymentId(),
processDefinition.getResourceName());
String xml = IoUtils.readString(is);
model.addAttribute("xml", xml);
return "bpm/console-beforeUpdateProcess";
}
示例12: init
import org.activiti.engine.repository.ProcessDefinition; //导入依赖的package包/类
@PostConstruct
public void init() {
if (!autoDeploy) {
return;
}
try {
TenantDTO tenantDto = tenantConnector.findByCode(defaultTenantCode);
Page page = processConnector.findProcessDefinitions(
tenantDto.getId(), new Page());
List<ProcessDefinition> processDefinitions = (List<ProcessDefinition>) page
.getResult();
for (ProcessDefinition processDefinition : processDefinitions) {
this.processBusiness(processDefinition);
}
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}
}
示例13: createProcessMetaData
import org.activiti.engine.repository.ProcessDefinition; //导入依赖的package包/类
private Map<String, Object> createProcessMetaData(Map<String, Object> processInstance) {
Map<String, Object> payload = new HashMap<String, Object>();
String processDefinitionId = (String) processInstance.get("processDefinitionId");
payload.put("procInstanceId", processInstance.get("processInstanceId"));
payload.put("procDefinitionId", processDefinitionId);
Map<String, Object> processMetaData = new HashMap<String, Object>();
ProcessDefinition pd = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId)
.singleResult();
processMetaData.put("PROCESSDEFINITIONID", processDefinitionId);
processMetaData.put("PROCESSNAME", pd.getName());
processMetaData.put("PROCESSVERSION", pd.getVersion());
processMetaData.put("DEPLOYMENTID", pd.getDeploymentId());
Deployment dep = repositoryService.createDeploymentQuery().deploymentId(pd.getDeploymentId()).singleResult();
processMetaData.put("APPNAME", dep.getName());
payload.put("processMetaData", processMetaData);
logger.debug("createProcessMetaData() return payload is: " + payload);
return payload;
}
示例14: loadByDeployment
import org.activiti.engine.repository.ProcessDefinition; //导入依赖的package包/类
/**
* 读取资源,通过部署ID
*
* @param processDefinitionId 流程定义
* @param resourceType 资源类型(xml|image)
* @throws Exception
*/
@RequestMapping(value = "/resource/read")
public void loadByDeployment(@RequestParam("processDefinitionId") String processDefinitionId,
@RequestParam("resourceType") String resourceType,
HttpServletResponse response) throws Exception {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
String resourceName = "";
if (resourceType.equals("image")) {
resourceName = processDefinition.getDiagramResourceName();
} else if (resourceType.equals("xml")) {
resourceName = processDefinition.getResourceName();
}
InputStream resourceAsStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), resourceName);
byte[] b = new byte[1024];
int len = -1;
while ((len = resourceAsStream.read(b, 0, 1024)) != -1) {
response.getOutputStream().write(b, 0, len);
}
}
示例15: loadByProcessInstance
import org.activiti.engine.repository.ProcessDefinition; //导入依赖的package包/类
/**
* 读取资源,通过流程ID
*
* @param resourceType 资源类型(xml|image)
* @param processInstanceId 流程实例ID
* @param response
* @throws Exception
*/
@RequestMapping(value = "/resource/process-instance")
public void loadByProcessInstance(@RequestParam("type") String resourceType, @RequestParam("pid") String processInstanceId, HttpServletResponse response)
throws Exception {
InputStream resourceAsStream = null;
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processInstance.getProcessDefinitionId())
.singleResult();
String resourceName = "";
if (resourceType.equals("image")) {
resourceName = processDefinition.getDiagramResourceName();
} else if (resourceType.equals("xml")) {
resourceName = processDefinition.getResourceName();
}
resourceAsStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), resourceName);
byte[] b = new byte[1024];
int len = -1;
while ((len = resourceAsStream.read(b, 0, 1024)) != -1) {
response.getOutputStream().write(b, 0, len);
}
}