本文整理汇总了Java中org.activiti.engine.repository.DeploymentBuilder.deploy方法的典型用法代码示例。如果您正苦于以下问题:Java DeploymentBuilder.deploy方法的具体用法?Java DeploymentBuilder.deploy怎么用?Java DeploymentBuilder.deploy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.activiti.engine.repository.DeploymentBuilder
的用法示例。
在下文中一共展示了DeploymentBuilder.deploy方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deploy
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
/**
* 部署流程资源
* 加载ZIP文件中的流程
*/
@PostMapping(value = "/deploy")
public ResponseMessage<Object> deploy(@RequestParam(value = "file") MultipartFile file) throws IOException {
// 获取上传的文件名
String fileName = file.getOriginalFilename();
// 得到输入流(字节流)对象
InputStream fileInputStream = file.getInputStream();
// 文件的扩展名
String extension = FilenameUtils.getExtension(fileName);
// zip或者bar类型的文件用ZipInputStream方式部署
DeploymentBuilder deployment = repositoryService.createDeployment();
if ("zip".equals(extension) || "bar".equals(extension)) {
ZipInputStream zip = new ZipInputStream(fileInputStream);
deployment.addZipInputStream(zip);
} else {
// 其他类型的文件直接部署
deployment.addInputStream(fileName, fileInputStream);
}
deployment.deploy();
return ResponseMessage.ok();
}
示例2: deployResources
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
@Override
public void deployResources(final String deploymentNameHint, final Resource[] resources, final RepositoryService repositoryService) {
// Create a separate deployment for each resource using the resource
// name
for (final Resource resource : resources) {
final String resourceName = determineResourceName(resource);
final DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering().name(resourceName);
try {
if (resourceName.endsWith(".bar") || resourceName.endsWith(".zip") || resourceName.endsWith(".jar")) {
deploymentBuilder.addZipInputStream(new ZipInputStream(resource.getInputStream()));
} else {
deploymentBuilder.addInputStream(resourceName, resource.getInputStream());
}
} catch (IOException e) {
throw new ActivitiException("couldn't auto deploy resource '" + resource + "': " + e.getMessage(), e);
}
deploymentBuilder.deploy();
}
}
示例3: deployResources
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
@Override
public void deployResources(final String deploymentNameHint, final Resource[] resources, final RepositoryService repositoryService) {
// Create a single deployment for all resources using the name hint as
// the literal name
final DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering().name(deploymentNameHint);
for (final Resource resource : resources) {
final String resourceName = determineResourceName(resource);
try {
if (resourceName.endsWith(".bar") || resourceName.endsWith(".zip") || resourceName.endsWith(".jar")) {
deploymentBuilder.addZipInputStream(new ZipInputStream(resource.getInputStream()));
} else {
deploymentBuilder.addInputStream(resourceName, resource.getInputStream());
}
} catch (IOException e) {
throw new ActivitiException("couldn't auto deploy resource '" + resource + "': " + e.getMessage(), e);
}
}
deploymentBuilder.deploy();
}
示例4: deployResources
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
@Override
public void deployResources(final String deploymentNameHint, final Resource[] resources, final RepositoryService repositoryService) {
// Create a deployment for each distinct parent folder using the name
// hint
// as a prefix
final Map<String, Set<Resource>> resourcesMap = createMap(resources);
for (final Entry<String, Set<Resource>> group : resourcesMap.entrySet()) {
final String deploymentName = determineDeploymentName(deploymentNameHint, group.getKey());
final DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering().name(deploymentName);
for (final Resource resource : group.getValue()) {
final String resourceName = determineResourceName(resource);
try {
if (resourceName.endsWith(".bar") || resourceName.endsWith(".zip") || resourceName.endsWith(".jar")) {
deploymentBuilder.addZipInputStream(new ZipInputStream(resource.getInputStream()));
} else {
deploymentBuilder.addInputStream(resourceName, resource.getInputStream());
}
} catch (IOException e) {
throw new ActivitiException("couldn't auto deploy resource '" + resource + "': " + e.getMessage(), e);
}
}
deploymentBuilder.deploy();
}
}
示例5: deployProcesses
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
/**
* Deploys all processes listed in the {@link #PROCESSES_FILE_NAME}-file.
*/
public void deployProcesses() {
// build a single deployment containing all discovered processes
Set<String> resourceNames = getResourceNames();
if (resourceNames.size() == 0) {
logger.fine("Not creating a deployment");
return;
}
logger.fine("Start deploying processes.");
DeploymentBuilder deploymentBuilder = processEngine.getRepositoryService().createDeployment();
for (String string : resourceNames) {
logger.info("Adding '" + string + "' to deployment.");
deploymentBuilder.addClasspathResource(string);
}
// deploy the processes
deploymentBuilder.deploy();
logger.fine("Done deploying processes.");
}
示例6: deploy
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
/**
* 部署流程资源
*/
@RequestMapping(value = "/deploy")
public String deploy(@RequestParam(value = "file", required = true) MultipartFile file) {
// 获取上传的文件名
String fileName = file.getOriginalFilename();
try {
// 得到输入流(字节流)对象
InputStream fileInputStream = file.getInputStream();
// 文件的扩展名
String extension = FilenameUtils.getExtension(fileName);
// zip或者bar类型的文件用ZipInputStream方式部署
DeploymentBuilder deployment = repositoryService.createDeployment();
if (extension.equals("zip") || extension.equals("bar")) {
ZipInputStream zip = new ZipInputStream(fileInputStream);
deployment.addZipInputStream(zip);
} else {
// 其他类型的文件直接部署
deployment.addInputStream(fileName, fileInputStream);
}
deployment.deploy();
} catch (Exception e) {
logger.error("error on deploy process, because of file input stream");
}
return "redirect:process-list";
}
示例7: testClasspathDeployment111
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
@Test
public void testClasspathDeployment111() throws Exception {
// 定义classpath
String bpmnClasspath = "chapter5/candidateUserInUserTask.bpmn";
// 创建部署构建器
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
// 添加资源
deploymentBuilder.addClasspathResource(bpmnClasspath);
// 执行部署
deploymentBuilder.deploy();
// 验证流程定义是否部署成功
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
long count = processDefinitionQuery.processDefinitionKey("candidateUserInUserTask").count();
assertEquals(1, count);
Map<String, Object> vars = new HashMap<String, Object>();
ArrayList<Date> objs = new ArrayList<Date>();
objs.add(new Date());
vars.put("list", objs);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("candidateUserInUserTask", vars);
Task task = taskService.createTaskQuery().includeProcessVariables().singleResult();
assertNotNull(task.getProcessVariables());
}
示例8: deploy
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
/**
* 部署流程资源
*/
@RequestMapping(value = "/deploy")
public String deploy(@RequestParam(value = "file", required = true) MultipartFile file) {
// 获取上传的文件名
String fileName = file.getOriginalFilename();
try {
// 得到输入流(字节流)对象
InputStream fileInputStream = file.getInputStream();
// 文件的扩展名
String extension = FilenameUtils.getExtension(fileName);
// zip或者bar类型的文件用ZipInputStream方式部署
DeploymentBuilder deployment = repositoryService.createDeployment();
if (extension.equals("zip") || extension.equals("bar")) {
ZipInputStream zip = new ZipInputStream(fileInputStream);
deployment.addZipInputStream(zip);
} else {
// 其他类型的文件直接部署
deployment.addInputStream(fileName, fileInputStream);
}
deployment.deploy();
} catch (Exception e) {
logger.error("error on deploy process, because of file input stream");
}
return "redirect:processes";
}
示例9: deployProcess
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
/**
* Deploys a single process
*
* @return the processDefinitionId of the deployed process as returned by
* {@link ProcessDefinition#getId()}
*/
public String deployProcess(String resourceName) {
logger.fine("Start deploying single process.");
// deploy processes as one deployment
DeploymentBuilder deploymentBuilder = processEngine.getRepositoryService().createDeployment();
deploymentBuilder.addClasspathResource(resourceName);
// deploy the processes
Deployment deployment = deploymentBuilder.deploy();
logger.fine("Process deployed");
// retreive the processDefinitionId for this process
return processEngine.getRepositoryService().createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult().getId();
}
示例10: deploy
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
@Override
public Deployment deploy(DeploymentBuilderImpl activiti6DeploymentBuilder) {
try {
DeploymentBuilder deploymentBuilder = getProcessEngine().getRepositoryService().createDeployment();
// Copy settings
deploymentBuilder.name(activiti6DeploymentBuilder.getDeployment().getName());
deploymentBuilder.category(activiti6DeploymentBuilder.getDeployment().getCategory());
deploymentBuilder.tenantId(activiti6DeploymentBuilder.getDeployment().getTenantId());
// Copy flags
if (!activiti6DeploymentBuilder.isBpmn20XsdValidationEnabled()) {
deploymentBuilder.disableSchemaValidation();
}
if (!activiti6DeploymentBuilder.isProcessValidationEnabled()) {
deploymentBuilder.disableBpmnValidation();
}
if (activiti6DeploymentBuilder.isDuplicateFilterEnabled()) {
deploymentBuilder.enableDuplicateFiltering();
}
if (activiti6DeploymentBuilder.getProcessDefinitionsActivationDate() != null) {
deploymentBuilder.activateProcessDefinitionsOn(activiti6DeploymentBuilder.getProcessDefinitionsActivationDate());
}
// Copy resources
DeploymentEntity activiti6DeploymentEntity = activiti6DeploymentBuilder.getDeployment();
Map<String, org.activiti.engine.impl.persistence.entity.ResourceEntity> activiti5Resources = new HashMap<>();
for (String resourceKey : activiti6DeploymentEntity.getResources().keySet()) {
EngineResource activiti6ResourceEntity = activiti6DeploymentEntity.getResources().get(resourceKey);
org.activiti.engine.impl.persistence.entity.ResourceEntity activiti5ResourceEntity = new org.activiti.engine.impl.persistence.entity.ResourceEntity();
activiti5ResourceEntity.setName(activiti6ResourceEntity.getName());
activiti5ResourceEntity.setBytes(activiti6ResourceEntity.getBytes());
activiti5Resources.put(resourceKey, activiti5ResourceEntity);
}
org.activiti.engine.impl.persistence.entity.DeploymentEntity activiti5DeploymentEntity = ((org.activiti.engine.impl.repository.DeploymentBuilderImpl) deploymentBuilder).getDeployment();
activiti5DeploymentEntity.setResources(activiti5Resources);
return new Flowable5DeploymentWrapper(deploymentBuilder.deploy());
} catch (org.activiti.engine.ActivitiException e) {
handleActivitiException(e);
return null;
}
}
示例11: deploy
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
/**
* 发布模型为流程定义
*
* @param id
* @return
* @throws Exception
*/
@RequestMapping(value = "/model/deploy/{id}", method = RequestMethod.POST)
@ResponseBody
public Result deploy(@PathVariable("id") String id, HttpServletRequest request) throws Exception {
//获取模型
Model modelData = repositoryService.getModel(id);
byte[] bytes = repositoryService.getModelEditorSource(modelData.getId());
if (bytes == null) {
return new Result(false, id, "模型数据为空,请先设计流程并成功保存,再进行发布。");
}
JsonNode modelNode = objectMapper.readTree(bytes);
BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode);
if (model.getProcesses().size() == 0) {
return new Result(false, id, "数据模型不符要求,请至少设计一条主线流程。");
}
try {
//----------------生成zip文件-------------------------
byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(model);
Result xml = generateResource("xml", id, request);
Result image = generateResource("image", id, request);
if (xml.getData() == null || image.getData() == null) {
return new Result(false, "部署失败", "流程尚未定义或定义错误,不能生成有效的xml和png文件");
}
String basePath = request.getRealPath("/");
String fileName = modelData.getKey() + ".bpmn20.model.zip";
String zipFileName = DIR_PATH + File.separator + fileName;
File file = new File(basePath + File.separator + zipFileName);
if (file.exists()) {
file.delete();
}
String zipPath = FileUtil.generateZipFile(basePath, zipFileName, xml.getData().toString(),
image.getData().toString());
InputStream inputStream = new FileInputStream(zipPath);
ZipInputStream zipInputStream = new ZipInputStream(inputStream);
//---------------------------------------------------
//发布流程
String processName = modelData.getKey() + ".bpmn20.xml";
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment()
.name(modelData.getName())
.category(modelData.getCategory())
.tenantId(modelData.getTenantId())
//使用addZipInputStream后可以预防flow连线文字丢失的问题
.addZipInputStream(zipInputStream);
//.addString(processName, new String(bpmnBytes, "UTF-8"))
List<JsonNode> forms=modelNode.findValues("formkeydefinition");
for (JsonNode form : forms) {
String formName=form.textValue();
if(!StrUtil.isEmpty(formName)){
InputStream stream=this.getClass().getClassLoader().getResourceAsStream(formName);
deploymentBuilder.addInputStream(formName,stream);
}
}
Deployment deployment=deploymentBuilder.deploy();
//更新流程定义类别,替换掉页面的定义
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId
(deployment.getId()).singleResult();
if (processDefinition != null)
repositoryService.setProcessDefinitionCategory(processDefinition.getId(), deployment.getCategory());
modelData.setDeploymentId(deployment.getId());
repositoryService.saveModel(modelData);
return new Result(true);
} catch (Exception ex) {
return new Result(false, "部署失败", ex.getMessage().toString());
}
}
示例12: testClasspathDeployment
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
@Test
public void testClasspathDeployment() throws Exception {
// 定义classpath
String bpmnClasspath = "chapter5/candidateUserInUserTask.bpmn";
String pngClasspath = "chapter5/candidateUserInUserTask.png";
// 创建部署构建器
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
// 添加资源
deploymentBuilder.addClasspathResource(bpmnClasspath);
deploymentBuilder.addClasspathResource(pngClasspath);
// 执行部署
deploymentBuilder.deploy();
// 验证流程定义是否部署成功
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
long count = processDefinitionQuery.processDefinitionKey("candidateUserInUserTask").count();
assertEquals(1, count);
// 读取图片文件
ProcessDefinition processDefinition = processDefinitionQuery.singleResult();
String diagramResourceName = processDefinition.getDiagramResourceName();
assertEquals(pngClasspath, diagramResourceName);
Map<String, Object> vars = new HashMap<String, Object>();
ArrayList<Date> objs = new ArrayList<Date>();
objs.add(new Date());
vars.put("list", objs);
// vars.put("aaa", "333");
runtimeService.startProcessInstanceByKey("candidateUserInUserTask", vars);
List<Task> list = taskService.createTaskQuery().includeProcessVariables().list();
System.out.println(list);
Task task = taskService.createTaskQuery().taskId(list.get(0).getId())
.includeProcessVariables().includeTaskLocalVariables().singleResult();
CommandContext commandContext = Context.getCommandContext();
System.out.println(task);
System.out.println(commandContext);
// ProcessEngineImpl defaultProcessEngine = (ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine();
// Context.setProcessEngineConfiguration(defaultProcessEngine.getProcessEngineConfiguration());
// Context.setCommandContext(defaultProcessEngine.getProcessEngineConfiguration().getCommandContextFactory().createCommandContext(null));
System.out.println(Context.getCommandContext());
System.out.println(task.getProcessVariables());
}
示例13: checkBundle
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
private void checkBundle(Bundle bundle) {
LOGGER.log(Level.FINE, "Scanning bundle {} for activiti process", bundle.getSymbolicName());
try {
List<URL> pathList = new ArrayList<URL>();
String activitiHeader = (String) bundle.getHeaders().get(BUNDLE_ACTIVITI_HEADER);
if (activitiHeader == null) {
activitiHeader = "OSGI-INF/activiti/";
}
List<PathElement> paths = HeaderParser.parseHeader(activitiHeader);
for (PathElement path : paths) {
String name = path.getName();
if (name.endsWith("/")) {
addEntries(bundle, name, "*.*", pathList);
} else {
String baseName;
String filePattern;
int pos = name.lastIndexOf('/');
if (pos < 0) {
baseName = "/";
filePattern = name;
} else {
baseName = name.substring(0, pos + 1);
filePattern = name.substring(pos + 1);
}
if (hasWildcards(filePattern)) {
addEntries(bundle, baseName, filePattern, pathList);
} else {
addEntry(bundle, name, pathList);
}
}
}
if (!pathList.isEmpty()) {
LOGGER.log(Level.FINE, "Found activiti process in bundle " + bundle.getSymbolicName()
+ " with paths: " + pathList);
ProcessEngine engine = (ProcessEngine) engineServiceTracker.waitForService(timeout);
if (engine == null) {
throw new IllegalStateException("Unable to find a ProcessEngine service");
}
RepositoryService service = engine.getRepositoryService();
DeploymentBuilder builder = service.createDeployment();
builder.name(bundle.getSymbolicName());
for (URL url : pathList) {
InputStream is = url.openStream();
if (is == null) {
throw new IOException("Error opening url: " + url);
}
try {
builder.addInputStream(getPath(url), is);
} finally {
is.close();
}
}
builder.enableDuplicateFiltering();
builder.deploy();
} else {
LOGGER.log(Level.FINE, "No activiti process found in bundle {}", bundle.getSymbolicName());
}
} catch (Throwable t) {
LOGGER.log(Level.SEVERE, "Unable to deploy activiti bundle", t);
}
}
示例14: uploadDeployment
import org.activiti.engine.repository.DeploymentBuilder; //导入方法依赖的package包/类
@Post
public void uploadDeployment(Representation entity) {
try {
if(authenticate(SecuredResource.ADMIN) == false) return;
RestletFileUpload upload = new RestletFileUpload(new DiskFileItemFactory());
List<FileItem> items = upload.parseRepresentation(entity);
FileItem uploadItem = null;
String successMethod = null;
for (FileItem fileItem : items) {
if(fileItem.getName() != null) {
uploadItem = fileItem;
} else if(fileItem.getFieldName().equals("success")){
successMethod = fileItem.getString();
}
}
DeploymentBuilder deploymentBuilder = ActivitiUtil.getRepositoryService().createDeployment();
String fileName = uploadItem.getName();
if (fileName.endsWith(".bpmn20.xml")) {
deploymentBuilder.addInputStream(fileName, uploadItem.getInputStream());
} else if (fileName.endsWith(".bar") || fileName.endsWith(".zip")) {
deploymentBuilder.addZipInputStream(new ZipInputStream(uploadItem.getInputStream()));
} else {
throw new ActivitiException("File must be of type .bpmn20.xml, .bar or .zip");
}
deploymentBuilder.name(fileName);
deploymentBuilder.deploy();
StringBuilder html = new StringBuilder();
html.append("<html>\n");
html.append(" <script type=\"text/javascript\">\n");
html.append(" " + successMethod + "()\n");
html.append(" </script>\n");
html.append("</html>\n");
getResponse().setEntity(html.toString(), MediaType.TEXT_HTML);
} catch (Exception e) {
throw new ActivitiException(e.getMessage(), e);
}
}