use of org.activiti.engine.repository.Model in project Activiti by Activiti.
the class ModelQueryTest method testModelProperties.
public void testModelProperties() {
ModelQuery query = repositoryService.createModelQuery();
Model model = query.singleResult();
assertNotNull(model.getId());
assertNotNull(model.getCategory());
assertNotNull(model.getKey());
assertNotNull(model.getName());
assertNotNull(model.getVersion());
assertNotNull(model.getCreateTime());
assertNotNull(model.getLastUpdateTime());
}
use of org.activiti.engine.repository.Model in project Activiti by Activiti.
the class ModelResource method deleteModel.
@RequestMapping(value = "/repository/models/{modelId}", method = RequestMethod.DELETE)
public void deleteModel(@PathVariable String modelId, HttpServletResponse response) {
Model model = getModelFromRequest(modelId);
repositoryService.deleteModel(model.getId());
response.setStatus(HttpStatus.NO_CONTENT.value());
}
use of org.activiti.engine.repository.Model in project Activiti by Activiti.
the class RestResponseFactory method createModelResponseList.
public List<ModelResponse> createModelResponseList(List<Model> models) {
RestUrlBuilder urlBuilder = createUrlBuilder();
List<ModelResponse> responseList = new ArrayList<ModelResponse>();
for (Model instance : models) {
responseList.add(createModelResponse(instance, urlBuilder));
}
return responseList;
}
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();
assertNotNull(model);
assertEquals("someKey1", model.getKey());
assertEquals("bytes", new String(repositoryService.getModelEditorSource(model.getId()), "utf-8"));
assertEquals(1, query.list().size());
assertEquals(1, query.count());
query = repositoryService.createModelQuery().modelNameLike("%\\_%");
model = query.singleResult();
assertNotNull(model);
assertEquals("someKey2", model.getKey());
assertEquals("bytes", new String(repositoryService.getModelEditorSource(model.getId()), "utf-8"));
assertEquals(1, query.list().size());
assertEquals(1, query.count());
}
use of org.activiti.engine.repository.Model in project Activiti by Activiti.
the class ModelEditorJsonRestResource method getEditorJson.
@RequestMapping(value = "/model/{modelId}/json", method = RequestMethod.GET, produces = "application/json")
public ObjectNode getEditorJson(@PathVariable String modelId) {
ObjectNode modelNode = null;
Model model = repositoryService.getModel(modelId);
if (model != null) {
try {
if (StringUtils.isNotEmpty(model.getMetaInfo())) {
modelNode = (ObjectNode) objectMapper.readTree(model.getMetaInfo());
} else {
modelNode = objectMapper.createObjectNode();
modelNode.put(MODEL_NAME, model.getName());
}
modelNode.put(MODEL_ID, model.getId());
ObjectNode editorJsonNode = (ObjectNode) objectMapper.readTree(new String(repositoryService.getModelEditorSource(model.getId()), "utf-8"));
modelNode.put("model", editorJsonNode);
} catch (Exception e) {
LOGGER.error("Error creating model JSON", e);
throw new ActivitiException("Error creating model JSON", e);
}
}
return modelNode;
}
Aggregations