Search in sources :

Example 41 with Model

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());
}
Also used : Model(org.activiti.engine.repository.Model) ModelQuery(org.activiti.engine.repository.ModelQuery)

Example 42 with Model

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());
}
Also used : Model(org.activiti.engine.repository.Model) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 43 with Model

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;
}
Also used : ModelResponse(org.activiti.rest.service.api.repository.ModelResponse) ArrayList(java.util.ArrayList) Model(org.activiti.engine.repository.Model)

Example 44 with Model

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());
}
Also used : Model(org.activiti.engine.repository.Model) ModelQuery(org.activiti.engine.repository.ModelQuery)

Example 45 with Model

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;
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Model(org.activiti.engine.repository.Model) ActivitiException(org.activiti.engine.ActivitiException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Model (org.activiti.engine.repository.Model)49 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)12 ModelQuery (org.activiti.engine.repository.ModelQuery)9 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 Calendar (java.util.Calendar)6 Deployment (org.activiti.engine.test.Deployment)6 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 InputStream (java.io.InputStream)5 HttpGet (org.apache.http.client.methods.HttpGet)5 HttpPut (org.apache.http.client.methods.HttpPut)5 BpmnModel (org.activiti.bpmn.model.BpmnModel)4 ActivitiException (org.activiti.engine.ActivitiException)4 StringEntity (org.apache.http.entity.StringEntity)4 Button (com.vaadin.ui.Button)3 ClickEvent (com.vaadin.ui.Button.ClickEvent)3 ClickListener (com.vaadin.ui.Button.ClickListener)3 HorizontalLayout (com.vaadin.ui.HorizontalLayout)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3