Java Code Examples for org.activiti.engine.repository.Model#setName()
The following examples show how to use
org.activiti.engine.repository.Model#setName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RepositoryServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testNewModelPersistence() { Model model = repositoryService.newModel(); assertNotNull(model); model.setName("Test model"); model.setCategory("test"); model.setMetaInfo("meta"); repositoryService.saveModel(model); assertNotNull(model.getId()); model = repositoryService.getModel(model.getId()); assertNotNull(model); assertEquals("Test model", model.getName()); assertEquals("test", model.getCategory()); assertEquals("meta", model.getMetaInfo()); assertNotNull(model.getCreateTime()); assertEquals(Integer.valueOf(1), model.getVersion()); repositoryService.deleteModel(model.getId()); }
Example 2
Source File: FlowableModelManagerController.java From hsweb-framework with Apache License 2.0 | 6 votes |
@PostMapping @ResponseStatus(value = HttpStatus.CREATED) @ApiOperation("创建模型") public ResponseMessage<Model> createModel(@RequestBody ModelCreateRequest model) throws Exception { JSONObject stencilset = new JSONObject(); stencilset.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#"); JSONObject editorNode = new JSONObject(); editorNode.put("id", "canvas"); editorNode.put("resourceId", "canvas"); editorNode.put("stencilset", stencilset); JSONObject modelObjectNode = new JSONObject(); modelObjectNode.put(MODEL_REVISION, 1); modelObjectNode.put(MODEL_DESCRIPTION, model.getDescription()); modelObjectNode.put(MODEL_KEY, model.getKey()); modelObjectNode.put(MODEL_NAME, model.getName()); Model modelData = repositoryService.newModel(); modelData.setMetaInfo(modelObjectNode.toJSONString()); modelData.setName(model.getName()); modelData.setKey(model.getKey()); repositoryService.saveModel(modelData); repositoryService.addModelEditorSource(modelData.getId(), editorNode.toString().getBytes("utf-8")); return ResponseMessage.ok(modelData).status(201); }
Example 3
Source File: ModelQueryTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testByLatestVersion() { ModelQuery query = repositoryService.createModelQuery().latestVersion().modelKey("someKey"); Model model = query.singleResult(); assertNotNull(model); // Add a new version of the model Model newVersion = repositoryService.newModel(); newVersion.setName("my model"); newVersion.setKey("someKey"); newVersion.setCategory("test"); newVersion.setVersion(model.getVersion() + 1); repositoryService.saveModel(newVersion); // Verify query model = query.singleResult(); assertNotNull(model); assertTrue(model.getVersion() == 2); // Cleanup repositoryService.deleteModel(model.getId()); }
Example 4
Source File: ModelUtils.java From openwebflow with BSD 2-Clause "Simplified" License | 6 votes |
public static Model createNewModel(RepositoryService repositoryService, String name, String description) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); Model modelData = repositoryService.newModel(); ObjectNode modelObjectNode = objectMapper.createObjectNode(); modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, name); modelObjectNode.put(ModelDataJsonConstants.MODEL_REVISION, 1); modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, description); modelData.setMetaInfo(modelObjectNode.toString()); modelData.setName(name); repositoryService.saveModel(modelData); repositoryService.addModelEditorSource(modelData.getId(), EMPTY_MODEL_XML.getBytes("utf-8")); return modelData; }
Example 5
Source File: ModelQueryEscapeClauseTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override protected void setUp() throws Exception { Model model = repositoryService.newModel(); model.setTenantId("mytenant%"); model.setName("my model%"); model.setKey("someKey1"); model.setCategory("test%"); repositoryService.saveModel(model); modelOneId = model.getId(); model = repositoryService.newModel(); model.setTenantId("mytenant_"); model.setName("my model_"); model.setKey("someKey2"); model.setCategory("test_"); repositoryService.saveModel(model); modelTwoId = model.getId(); repositoryService.addModelEditorSource(modelOneId, "bytes".getBytes("utf-8")); repositoryService.addModelEditorSource(modelTwoId, "bytes".getBytes("utf-8")); super.setUp(); }
Example 6
Source File: ModelQueryEscapeClauseTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override protected void setUp() throws Exception { Model model = repositoryService.newModel(); model.setTenantId("mytenant%"); model.setName("my model%"); model.setKey("someKey1"); model.setCategory("test%"); repositoryService.saveModel(model); modelOneId = model.getId(); model = repositoryService.newModel(); model.setTenantId("mytenant_"); model.setName("my model_"); model.setKey("someKey2"); model.setCategory("test_"); repositoryService.saveModel(model); modelTwoId = model.getId(); repositoryService.addModelEditorSource(modelOneId, "bytes".getBytes("utf-8")); repositoryService.addModelEditorSource(modelTwoId, "bytes".getBytes("utf-8")); super.setUp(); }
Example 7
Source File: ModelResourceSourceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testSetModelEditorSource() throws Exception { Model model = null; try { model = repositoryService.newModel(); model.setName("Model name"); repositoryService.saveModel(model); HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_MODEL_SOURCE, model.getId())); httpPut.setEntity(HttpMultipartHelper.getMultiPartEntity("sourcefile", "application/octet-stream", new ByteArrayInputStream("This is the new editor source".getBytes()), null)); closeResponse(executeBinaryRequest(httpPut, HttpStatus.SC_NO_CONTENT)); assertEquals("This is the new editor source", new String(repositoryService.getModelEditorSource(model.getId()))); } finally { try { repositoryService.deleteModel(model.getId()); } catch (Throwable ignore) { // Ignore, model might not be created } } }
Example 8
Source File: RepositoryServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testNewModelPersistence() { Model model = repositoryService.newModel(); assertNotNull(model); model.setName("Test model"); model.setCategory("test"); model.setMetaInfo("meta"); repositoryService.saveModel(model); assertNotNull(model.getId()); model = repositoryService.getModel(model.getId()); assertNotNull(model); assertEquals("Test model", model.getName()); assertEquals("test", model.getCategory()); assertEquals("meta", model.getMetaInfo()); assertNotNull(model.getCreateTime()); assertEquals(Integer.valueOf(1), model.getVersion()); repositoryService.deleteModel(model.getId()); }
Example 9
Source File: ModelResourceSourceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testGetModelEditorSourceExtraNoSource() throws Exception { Model model = null; try { model = repositoryService.newModel(); model.setName("Model name"); repositoryService.saveModel(model); HttpGet httpGet = new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_MODEL_SOURCE_EXTRA, model.getId())); closeResponse(executeRequest(httpGet, HttpStatus.SC_NOT_FOUND)); } finally { try { repositoryService.deleteModel(model.getId()); } catch (Throwable ignore) { // Ignore, model might not be created } } }
Example 10
Source File: ModelResourceSourceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testGetModelEditorSourceNoSource() throws Exception { Model model = null; try { model = repositoryService.newModel(); model.setName("Model name"); repositoryService.saveModel(model); HttpGet httpGet = new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_MODEL_SOURCE, model.getId())); closeResponse(executeRequest(httpGet, HttpStatus.SC_NOT_FOUND)); } finally { try { repositoryService.deleteModel(model.getId()); } catch (Throwable ignore) { // Ignore, model might not be created } } }
Example 11
Source File: ModelResource.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@ApiOperation(value = "Update a model", tags = {"Models"}, notes ="All request values are optional. " + "For example, you can only include the name attribute in the request body JSON-object, only updating the name of the model, leaving all other fields unaffected. " + "When an attribute is explicitly included and is set to null, the model-value will be updated to null. " + "Example: ```JSON \n{\"metaInfo\" : null}``` will clear the metaInfo of the model).") @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the model was found and updated."), @ApiResponse(code = 404, message = "Indicates the requested model was not found.") }) @RequestMapping(value = "/repository/models/{modelId}", method = RequestMethod.PUT, produces = "application/json") public ModelResponse updateModel(@ApiParam(name = "modelId") @PathVariable String modelId, @RequestBody ModelRequest modelRequest, HttpServletRequest request) { Model model = getModelFromRequest(modelId); if (modelRequest.isCategoryChanged()) { model.setCategory(modelRequest.getCategory()); } if (modelRequest.isDeploymentChanged()) { model.setDeploymentId(modelRequest.getDeploymentId()); } if (modelRequest.isKeyChanged()) { model.setKey(modelRequest.getKey()); } if (modelRequest.isMetaInfoChanged()) { model.setMetaInfo(modelRequest.getMetaInfo()); } if (modelRequest.isNameChanged()) { model.setName(modelRequest.getName()); } if (modelRequest.isVersionChanged()) { model.setVersion(modelRequest.getVersion()); } if (modelRequest.isTenantIdChanged()) { model.setTenantId(modelRequest.getTenantId()); } repositoryService.saveModel(model); return restResponseFactory.createModelResponse(model); }
Example 12
Source File: ModelController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 创建模型 */ @RequestMapping(value = "create") public void create(@RequestParam("name") String name, @RequestParam("key") String key, @RequestParam(value = "description", required = false) String description, HttpServletRequest request, HttpServletResponse response) { try { ObjectMapper objectMapper = new ObjectMapper(); ObjectNode editorNode = objectMapper.createObjectNode(); editorNode.put("id", "canvas"); editorNode.put("resourceId", "canvas"); ObjectNode stencilSetNode = objectMapper.createObjectNode(); stencilSetNode.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#"); editorNode.put("stencilset", stencilSetNode); ObjectNode modelObjectNode = objectMapper.createObjectNode(); modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, name); modelObjectNode.put(ModelDataJsonConstants.MODEL_REVISION, 1); description = StringUtils.defaultString(description); modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, description); Model newModel = repositoryService.newModel(); newModel.setMetaInfo(modelObjectNode.toString()); newModel.setName(name); newModel.setKey(StringUtils.defaultString(key)); repositoryService.saveModel(newModel); repositoryService.addModelEditorSource(newModel.getId(), editorNode.toString().getBytes("utf-8")); response.sendRedirect(request.getContextPath() + "/mservice/editor?id=" + newModel.getId()); } catch (Exception e) { logger.error("创建模型失败:", e); } }
Example 13
Source File: ModelResourceTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testDeleteModel() throws Exception { Model model = null; try { Calendar now = Calendar.getInstance(); now.set(Calendar.MILLISECOND, 0); processEngineConfiguration.getClock().setCurrentTime(now.getTime()); model = repositoryService.newModel(); model.setCategory("Model category"); model.setKey("Model key"); model.setMetaInfo("Model metainfo"); model.setName("Model name"); model.setVersion(2); repositoryService.saveModel(model); HttpDelete httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_MODEL, model.getId())); closeResponse(executeRequest(httpDelete, HttpStatus.SC_NO_CONTENT)); // Check if the model is really gone assertNull(repositoryService.createModelQuery().modelId(model.getId()).singleResult()); model = null; } finally { if (model != null) { try { repositoryService.deleteModel(model.getId()); } catch (Throwable ignore) { // Ignore, model might not be created } } } }
Example 14
Source File: ModelResourceSourceTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testGetModelEditorSourceExtra() throws Exception { Model model = null; try { model = repositoryService.newModel(); model.setName("Model name"); repositoryService.saveModel(model); repositoryService.addModelEditorSourceExtra(model.getId(), "This is the extra editor source".getBytes()); HttpGet httpGet = new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_MODEL_SOURCE_EXTRA, model.getId())); CloseableHttpResponse response = executeRequest(httpGet, HttpStatus.SC_OK); // Check "OK" status assertEquals("application/octet-stream", response.getEntity().getContentType().getValue()); assertEquals("This is the extra editor source", IOUtils.toString(response.getEntity().getContent())); closeResponse(response); } finally { try { repositoryService.deleteModel(model.getId()); } catch (Throwable ignore) { // Ignore, model might not be created } } }
Example 15
Source File: ModelResourceSourceTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testGetModelEditorSource() throws Exception { Model model = null; try { model = repositoryService.newModel(); model.setName("Model name"); repositoryService.saveModel(model); repositoryService.addModelEditorSource(model.getId(), "This is the editor source".getBytes()); HttpGet httpGet = new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_MODEL_SOURCE, model.getId())); CloseableHttpResponse response = executeRequest(httpGet, HttpStatus.SC_OK); // Check "OK" status assertEquals("application/octet-stream", response.getEntity().getContentType().getValue()); assertEquals("This is the editor source", IOUtils.toString(response.getEntity().getContent())); closeResponse(response); } finally { try { repositoryService.deleteModel(model.getId()); } catch (Throwable ignore) { // Ignore, model might not be created } } }
Example 16
Source File: ModelQueryTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { Model model = repositoryService.newModel(); model.setName("my model"); model.setKey("someKey"); model.setCategory("test"); repositoryService.saveModel(model); modelOneId = model.getId(); repositoryService.addModelEditorSource(modelOneId, "bytes".getBytes("utf-8")); super.setUp(); }
Example 17
Source File: RepositoryServiceTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testUpdateModelPersistence() throws Exception { Model model = repositoryService.newModel(); assertNotNull(model); model.setName("Test model"); model.setCategory("test"); model.setMetaInfo("meta"); repositoryService.saveModel(model); assertNotNull(model.getId()); model = repositoryService.getModel(model.getId()); assertNotNull(model); model.setName("New name"); model.setCategory("New category"); model.setMetaInfo("test"); model.setVersion(2); repositoryService.saveModel(model); assertNotNull(model.getId()); repositoryService.addModelEditorSource(model.getId(), "new".getBytes("utf-8")); repositoryService.addModelEditorSourceExtra(model.getId(), "new".getBytes("utf-8")); model = repositoryService.getModel(model.getId()); assertEquals("New name", model.getName()); assertEquals("New category", model.getCategory()); assertEquals("test", model.getMetaInfo()); assertNotNull(model.getCreateTime()); assertEquals(Integer.valueOf(2), model.getVersion()); assertEquals("new", new String(repositoryService.getModelEditorSource(model.getId()), "utf-8")); assertEquals("new", new String(repositoryService.getModelEditorSourceExtra(model.getId()), "utf-8")); repositoryService.deleteModel(model.getId()); }
Example 18
Source File: ModelEventsTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
/** * Test create, update and delete events of model entities. */ public void testModelEvents() throws Exception { Model model = null; try { model = repositoryService.newModel(); model.setName("My model"); model.setKey("key"); repositoryService.saveModel(model); // Check create event assertEquals(2, listener.getEventsReceived().size()); assertEquals(ActivitiEventType.ENTITY_CREATED, listener.getEventsReceived().get(0).getType()); assertEquals(model.getId(), ((Model) ((ActivitiEntityEvent) listener.getEventsReceived().get(0)).getEntity()).getId()); assertEquals(ActivitiEventType.ENTITY_INITIALIZED, listener.getEventsReceived().get(1).getType()); assertEquals(model.getId(), ((Model) ((ActivitiEntityEvent) listener.getEventsReceived().get(1)).getEntity()).getId()); listener.clearEventsReceived(); // Update model model = repositoryService.getModel(model.getId()); model.setName("Updated"); repositoryService.saveModel(model); assertEquals(1, listener.getEventsReceived().size()); assertEquals(ActivitiEventType.ENTITY_UPDATED, listener.getEventsReceived().get(0).getType()); assertEquals(model.getId(), ((Model) ((ActivitiEntityEvent) listener.getEventsReceived().get(0)).getEntity()).getId()); listener.clearEventsReceived(); // Test additional update-methods (source and extra-source) repositoryService.addModelEditorSource(model.getId(), "test".getBytes()); repositoryService.addModelEditorSourceExtra(model.getId(), "test extra".getBytes()); assertEquals(2, listener.getEventsReceived().size()); assertEquals(ActivitiEventType.ENTITY_UPDATED, listener.getEventsReceived().get(0).getType()); assertEquals(ActivitiEventType.ENTITY_UPDATED, listener.getEventsReceived().get(1).getType()); listener.clearEventsReceived(); // Delete model events repositoryService.deleteModel(model.getId()); assertEquals(1, listener.getEventsReceived().size()); assertEquals(ActivitiEventType.ENTITY_DELETED, listener.getEventsReceived().get(0).getType()); assertEquals(model.getId(), ((Model) ((ActivitiEntityEvent) listener.getEventsReceived().get(0)).getEntity()).getId()); listener.clearEventsReceived(); } finally { if (model != null && repositoryService.getModel(model.getId()) != null) { repositoryService.deleteModel(model.getId()); } } }
Example 19
Source File: ModelEventsTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
/** * Test create, update and delete events of model entities. */ public void testModelEvents() throws Exception { Model model = null; try { model = repositoryService.newModel(); model.setName("My model"); model.setKey("key"); repositoryService.saveModel(model); // Check create event assertEquals(2, listener.getEventsReceived().size()); assertEquals(ActivitiEventType.ENTITY_CREATED, listener.getEventsReceived().get(0).getType()); assertEquals(model.getId(), ((Model) ((ActivitiEntityEvent) listener.getEventsReceived().get(0)).getEntity()).getId()); assertEquals(ActivitiEventType.ENTITY_INITIALIZED, listener.getEventsReceived().get(1).getType()); assertEquals(model.getId(), ((Model) ((ActivitiEntityEvent) listener.getEventsReceived().get(1)).getEntity()).getId()); listener.clearEventsReceived(); // Update model model = repositoryService.getModel(model.getId()); model.setName("Updated"); repositoryService.saveModel(model); assertEquals(1, listener.getEventsReceived().size()); assertEquals(ActivitiEventType.ENTITY_UPDATED, listener.getEventsReceived().get(0).getType()); assertEquals(model.getId(), ((Model) ((ActivitiEntityEvent) listener.getEventsReceived().get(0)).getEntity()).getId()); listener.clearEventsReceived(); // Test additional update-methods (source and extra-source) repositoryService.addModelEditorSource(model.getId(), "test".getBytes()); repositoryService.addModelEditorSourceExtra(model.getId(), "test extra".getBytes()); assertEquals(2, listener.getEventsReceived().size()); assertEquals(ActivitiEventType.ENTITY_UPDATED, listener.getEventsReceived().get(0).getType()); assertEquals(ActivitiEventType.ENTITY_UPDATED, listener.getEventsReceived().get(1).getType()); listener.clearEventsReceived(); // Delete model events repositoryService.deleteModel(model.getId()); assertEquals(1, listener.getEventsReceived().size()); assertEquals(ActivitiEventType.ENTITY_DELETED, listener.getEventsReceived().get(0).getType()); assertEquals(model.getId(), ((Model) ((ActivitiEntityEvent) listener.getEventsReceived().get(0)).getEntity()).getId()); listener.clearEventsReceived(); } finally { if (model != null && repositoryService.getModel(model.getId()) != null) { repositoryService.deleteModel(model.getId()); } } }
Example 20
Source File: ModelResourceTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@Deployment(resources = { "org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml" }) public void testUpdateModelOverrideWithNull() throws Exception { Model model = null; try { Calendar createTime = Calendar.getInstance(); createTime.set(Calendar.MILLISECOND, 0); processEngineConfiguration.getClock().setCurrentTime(createTime.getTime()); model = repositoryService.newModel(); model.setCategory("Model category"); model.setKey("Model key"); model.setMetaInfo("Model metainfo"); model.setName("Model name"); model.setTenantId("myTenant"); model.setVersion(2); repositoryService.saveModel(model); Calendar updateTime = Calendar.getInstance(); updateTime.set(Calendar.MILLISECOND, 0); processEngineConfiguration.getClock().setCurrentTime(updateTime.getTime()); // Create update request ObjectNode requestNode = objectMapper.createObjectNode(); requestNode.put("name", (String) null); requestNode.put("category", (String) null); requestNode.put("key", (String) null); requestNode.put("metaInfo", (String) null); requestNode.put("deploymentId", (String) null); requestNode.put("version", (String) null); requestNode.put("tenantId", (String) null); HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_MODEL, model.getId())); httpPut.setEntity(new StringEntity(requestNode.toString())); CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK); JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent()); closeResponse(response); assertNotNull(responseNode); assertNull(responseNode.get("name").textValue()); assertNull(responseNode.get("key").textValue()); assertNull(responseNode.get("category").textValue()); assertNull(responseNode.get("version").textValue()); assertNull(responseNode.get("metaInfo").textValue()); assertNull(responseNode.get("deploymentId").textValue()); assertNull(responseNode.get("tenantId").textValue()); assertEquals(model.getId(), responseNode.get("id").textValue()); assertEquals(createTime.getTime().getTime(), getDateFromISOString(responseNode.get("createTime").textValue()).getTime()); assertEquals(updateTime.getTime().getTime(), getDateFromISOString(responseNode.get("lastUpdateTime").textValue()).getTime()); assertTrue(responseNode.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_MODEL, model.getId()))); model = repositoryService.getModel(model.getId()); assertNull(model.getName()); assertNull(model.getKey()); assertNull(model.getCategory()); assertNull(model.getMetaInfo()); assertNull(model.getDeploymentId()); assertEquals("", model.getTenantId()); } finally { try { repositoryService.deleteModel(model.getId()); } catch (Throwable ignore) { // Ignore, model might not be created } } }