Problems encountered when integrating the activiti-modeler process editor

1. According to the online process, when copying files under the model into the project, inject ObjectMapper reddening


Solution:
Inject objectMapper's bean s into the spring-activiti.xml configuration file

    <!-- objectMapper register as bean for activiti Use -->
    <bean id="objectMapper" class="com.fasterxml.jackson.databind.ObjectMapper"/>

2. How to Jump to Edit Page

1) First configure the activiti-editor resource file in spring-mvc.xml

<mvc:resources location="/activiti-editor/" mapping="/activiti-editor/**" />

2) Direct access to resource file activiti-editor/modeler.html?model=xxx
xxx is the id of the model (if you want to access the process editing page normally, you need to create a model first)
Following is a code to create a model that will create a record in the act_re_model table when created successfully

    @RequestMapping("/createModel")
    @ResponseBody
    public String createModel() throws UnsupportedEncodingException {
        ObjectMapper objectMapper = new ObjectMapper();
        ObjectNode editorNode = objectMapper.createObjectNode();
        editorNode.put("id", "canvs");
        editorNode.put("resourceId", "canvs");
        ObjectNode stencilSetNode = objectMapper.createObjectNode();
        stencilSetNode.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#";//namespace (no modifications)
        stencilSetNode.put("author", "");											//Process Node Author
        editorNode.set("stencilset", stencilSetNode);
        ObjectNode propertiesNode = objectMapper.createObjectNode();
        propertiesNode.put("process_id",1);		 						//Process Unique Identification
        propertiesNode.put("process_author",2);						//Process Author
        propertiesNode.put("name",3);	 			 							//Process Name
        editorNode.set("properties", propertiesNode);
        ObjectNode modelObjectNode = objectMapper.createObjectNode();
        modelObjectNode.put("name", 4);					//Model Name
        modelObjectNode.put("revision", 1);						//Model Version
        modelObjectNode.put("description", 5);		//Model Description
        org.activiti.engine.repository.Model modelData = repositoryService.newModel();
        modelData.setCategory("setCategory");						//Model Classification
        modelData.setDeploymentId(null);
        modelData.setKey(null);
        modelData.setMetaInfo(modelObjectNode.toString());
        modelData.setName("setName");							//Model Name
        modelData.setTenantId("setTenantId");
        modelData.setVersion(1);
        repositoryService.saveModel(modelData);					//Save model, store data to table: act_re_model process design model deployment table
        repositoryService.addModelEditorSource(modelData.getId(), editorNode.toString().getBytes("utf-8"));//Save resources to store data to tables: act_ge_bytearray binary data table
        return modelData.getId();
    }

3. Access controller s in activitieditor 404, 406

404: No controller access
1) Check Path
2) If the path is correct, the relationship between access prefix and suffix may be configured
Solution:
1. Open app-cfg.js in the activiti-editor folder

ACTIVITI.CONFIG = {
	'contextRoot' : '/web/act',//Prefix (default is none, you need to adapt your own path)
	"suffix":".action"//Add this suffix
};

2. Open url-config.js with ACTIVITI.CONFIG.suffix after each path

KISBPM.URL = {
    getModel: function(modelId) {
        return ACTIVITI.CONFIG.contextRoot + '/model/' + modelId + '/json' + ACTIVITI.CONFIG.suffix;
    },
    getStencilSet: function() {
        return ACTIVITI.CONFIG.contextRoot + '/editor/stencilset' + ACTIVITI.CONFIG.suffix + '?version=' + Date.now();
    },
    putModel: function(modelId) {
        return ACTIVITI.CONFIG.contextRoot + '/model/' + modelId + '/save' +ACTIVITI.CONFIG.suffix;
    }
};

406: Indicates that the controller has been accessed, but the return value cannot be received correctly
This may occur if access suffix *.html is configured

    <servlet-mapping>
        <servlet-name>springmvc</servlet-name>
        <url-pattern>*.html</url-pattern>
    </servlet-mapping>

Solution:
1) Change the suffix to *.action, *.do or cancel the suffix directly
2) Configure a <url-pattern>/act/*</url-pattern> to match access paths (I haven't tried it yet and I'm not sure what the problem is)
2) Configure another <url-pattern>/</url-pattern>but this configuration overrides the access suffix

4. Other access is normal, but access to stencilset path 404


In general, this problem occurs when an access suffix is configured, and you can see that there is no access suffix in this url.But we've configured it before.
Solution:
Open line oryx.debug.js 8190

new Ajax.Request(ACTIVITI.CONFIG.contextRoot + '/editor/stencilset?version=' + Date.now(), {
	            asynchronous: false,
	            method: 'get',
	            onSuccess: this._init.bind(this),
	            onFailure: this._cancelInit.bind(this)
	        });

You can see that the code here splices itself into a url (this should be a small bug)
Replace ACTIVITI.CONFIG.contextRoot +'/editor/stencilset? Version='+ Date.now() here with KISBPM.URL.getStencilSet() (that is, the url we just configured with the suffix)

Published 7 original articles. Accepted 2. Visited 173
Private letter follow

Tags: Spring xml JSON

Posted on Thu, 13 Feb 2020 23:09:43 -0500 by Xanthis