Search in sources :

Example 11 with SysBpmnResourceVO

use of com.netsteadfast.greenstep.vo.SysBpmnResourceVO in project bamboobsc by billchen198318.

the class BusinessProcessManagementUtils method deployment.

public static String deployment(SysBpmnResourceVO sysBpmnResource) throws ServiceException, Exception {
    DefaultResult<SysBpmnResourceVO> result = sysBpmnResourceService.findByUK(sysBpmnResource);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    ZipInputStream zip = new ZipInputStream(new ByteArrayInputStream(result.getValue().getContent()));
    Deployment deployment = null;
    try {
        deployment = repositoryService.createDeployment().name(result.getValue().getName()).addZipInputStream(zip).deploy();
        result.getValue().setDeploymentId(deployment.getId());
        byte[] content = result.getValue().getContent();
        // 先清掉content
        result.getValue().setContent(null);
        // 先清掉content
        sysBpmnResourceService.updateObject(result.getValue());
        // 填回content
        result.getValue().setContent(content);
        // 填回content	
        sysBpmnResourceService.updateObject(result.getValue());
        logger.info("deployment Id: " + deployment.getId() + " , name: " + deployment.getName());
    } catch (Exception e) {
        e.printStackTrace();
        logger.error(e.getMessage().toString());
        throw e;
    } finally {
        zip.close();
        zip = null;
    }
    return deployment.getId();
}
Also used : ZipInputStream(java.util.zip.ZipInputStream) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ByteArrayInputStream(java.io.ByteArrayInputStream) SysBpmnResourceVO(com.netsteadfast.greenstep.vo.SysBpmnResourceVO) Deployment(org.activiti.engine.repository.Deployment) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException)

Example 12 with SysBpmnResourceVO

use of com.netsteadfast.greenstep.vo.SysBpmnResourceVO in project bamboobsc by billchen198318.

the class SystemBpmnResourceSaveOrUpdateAction method delete.

private void delete() throws ControllerException, AuthorityException, ServiceException, Exception {
    SysBpmnResourceVO resource = new SysBpmnResourceVO();
    resource.setOid(this.getFields().get("oid"));
    DefaultResult<SysBpmnResourceVO> result = this.sysBpmnResourceService.findObjectByOid(resource);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    resource = result.getValue();
    sysBpmnResourceService.hibernateSessionClear();
    if (!StringUtils.isBlank(resource.getDeploymentId())) {
        BusinessProcessManagementUtils.deleteDeployment(resource, false);
        result = this.sysBpmnResourceService.findObjectByOid(resource);
        if (result.getValue() == null) {
            throw new ServiceException(result.getSystemMessage().getValue());
        }
        resource = result.getValue();
        sysBpmnResourceService.hibernateSessionClear();
        if (!StringUtils.isBlank(resource.getDeploymentId())) {
            this.message = "Cannot delete deployment!";
            return;
        }
    }
    DefaultResult<Boolean> delResult = sysBpmnResourceService.deleteObject(resource);
    this.message = delResult.getSystemMessage().getValue();
    if (delResult.getValue() != null && delResult.getValue()) {
        this.success = IS_YES;
    }
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysBpmnResourceVO(com.netsteadfast.greenstep.vo.SysBpmnResourceVO)

Aggregations

SysBpmnResourceVO (com.netsteadfast.greenstep.vo.SysBpmnResourceVO)12 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)10 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ZipInputStream (java.util.zip.ZipInputStream)1 Deployment (org.activiti.engine.repository.Deployment)1 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)1 ProcessDefinitionQuery (org.activiti.engine.repository.ProcessDefinitionQuery)1 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)1 Task (org.activiti.engine.task.Task)1