use of org.activiti.engine.repository.Model in project Activiti by Activiti.
the class ModelQueryTest method testVerifyModelProperties.
public void testVerifyModelProperties() {
List<Model> models = repositoryService.createModelQuery().orderByModelName().asc().list();
Model modelOne = models.get(0);
assertThat(modelOne.getName()).isEqualTo("my model");
assertThat(modelOne.getId()).isEqualTo(modelOneId);
models = repositoryService.createModelQuery().modelNameLike("%model%").orderByModelName().asc().list();
assertThat(models.get(0).getName()).isEqualTo("my model");
assertThat(models).hasSize(1);
assertThat(repositoryService.createModelQuery().orderByModelId().asc().list()).hasSize(1);
}
use of org.activiti.engine.repository.Model in project Activiti by Activiti.
the class ModelQueryTest method testQueryByNameAndKey.
public void testQueryByNameAndKey() {
ModelQuery query = repositoryService.createModelQuery().modelKey("someKey");
Model model = query.singleResult();
assertThat(model).isNotNull();
assertThat(query.list()).hasSize(1);
assertThat(query.count()).isEqualTo(1);
}
use of org.activiti.engine.repository.Model in project Activiti by Activiti.
the class RepositoryServiceTest method testUpdateModelPersistence.
public void testUpdateModelPersistence() throws Exception {
Model model = repositoryService.newModel();
assertThat(model).isNotNull();
model.setName("Test model");
model.setCategory("test");
model.setMetaInfo("meta");
repositoryService.saveModel(model);
assertThat(model.getId()).isNotNull();
model = repositoryService.getModel(model.getId());
assertThat(model).isNotNull();
model.setName("New name");
model.setCategory("New category");
model.setMetaInfo("test");
model.setVersion(2);
repositoryService.saveModel(model);
assertThat(model.getId()).isNotNull();
repositoryService.addModelEditorSource(model.getId(), "new".getBytes("utf-8"));
repositoryService.addModelEditorSourceExtra(model.getId(), "new".getBytes("utf-8"));
model = repositoryService.getModel(model.getId());
assertThat(model.getName()).isEqualTo("New name");
assertThat(model.getCategory()).isEqualTo("New category");
assertThat(model.getMetaInfo()).isEqualTo("test");
assertThat(model.getCreateTime()).isNotNull();
assertThat(model.getVersion()).isEqualTo(Integer.valueOf(2));
assertThat(new String(repositoryService.getModelEditorSource(model.getId()), "utf-8")).isEqualTo("new");
assertThat(new String(repositoryService.getModelEditorSourceExtra(model.getId()), "utf-8")).isEqualTo("new");
repositoryService.deleteModel(model.getId());
}
use of org.activiti.engine.repository.Model in project Activiti by Activiti.
the class ModelQueryEscapeClauseTest method testQueryByNameLike.
public void testQueryByNameLike() throws Exception {
ModelQuery query = repositoryService.createModelQuery().modelNameLike("%\\%%");
Model model = query.singleResult();
assertThat(model).isNotNull();
assertThat(model.getKey()).isEqualTo("someKey1");
assertThat(new String(repositoryService.getModelEditorSource(model.getId()), "utf-8")).isEqualTo("bytes");
assertThat(query.list()).hasSize(1);
assertThat(query.count()).isEqualTo(1);
query = repositoryService.createModelQuery().modelNameLike("%\\_%");
model = query.singleResult();
assertThat(model).isNotNull();
assertThat(model.getKey()).isEqualTo("someKey2");
assertThat(new String(repositoryService.getModelEditorSource(model.getId()), "utf-8")).isEqualTo("bytes");
assertThat(query.list()).hasSize(1);
assertThat(query.count()).isEqualTo(1);
}
use of org.activiti.engine.repository.Model in project my_curd by qinyou.
the class ProcessModelController method modelDeploy.
// 模型部署
@Before(IdRequired.class)
public void modelDeploy() throws IOException {
String modelId = get("id");
Model model = ActivitiUtils.getRepositoryService().getModel(modelId);
if (model == null) {
renderFail("参数错误");
return;
}
ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(ActivitiUtils.getRepositoryService().getModelEditorSource(model.getId()));
BpmnModel bpmnModel = new BpmnJsonConverter().convertToBpmnModel(modelNode);
// 这样是为了 流程定义转换为 模型是 ,模型能有 名称和 描述
if (StringUtils.isEmpty(bpmnModel.getMainProcess().getDocumentation())) {
bpmnModel.getMainProcess().setDocumentation((String) JSON.parseObject(model.getMetaInfo()).get("description"));
}
if (StringUtils.isEmpty(bpmnModel.getMainProcess().getName())) {
bpmnModel.getMainProcess().setName(model.getName());
}
byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(bpmnModel);
Deployment deployment = ActivitiUtils.getRepositoryService().createDeployment().name("通过model部署,modelId: " + model.getId()).addString(bpmnModel.getMainProcess().getId() + ".bpmn", new String(bpmnBytes, ActConst.DEFAULT_CHARSET)).deploy();
renderSuccess("部署成功,部署ID=" + deployment.getId());
}
Aggregations