/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ssos.flowable.modeler.service;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.ssos.flowable.modeler.model.*;
import com.ssos.flowable.modeler.model.decisiontable.DecisionTableDefinitionRepresentation;
import com.ssos.flowable.modeler.repository.ModelHistoryRepository;
import com.ssos.flowable.modeler.repository.ModelRelationRepository;
import com.ssos.flowable.modeler.repository.ModelRepository;
import com.ssos.flowable.modeler.repository.ModelSort;
import com.ssos.flowable.modeler.serviceapi.ModelService;
import com.ssos.flowable.modeler.util.XmlUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.javassist.NotFoundException;
import org.flowable.bpmn.converter.BpmnXMLConverter;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.ExtensionElement;
import org.flowable.bpmn.model.Process;
import org.flowable.bpmn.model.UserTask;
import org.flowable.cmmn.converter.CmmnXmlConverter;
import org.flowable.cmmn.editor.json.converter.CmmnJsonConverter;
import org.flowable.cmmn.editor.json.converter.util.CmmnModelJsonConverterUtil;
import org.flowable.cmmn.model.CmmnModel;
import org.flowable.editor.language.json.converter.BpmnJsonConverter;
import org.flowable.editor.language.json.converter.util.CollectionUtils;
import org.flowable.editor.language.json.converter.util.JsonConverterUtil;
import org.flowable.form.model.SimpleFormModel;
import org.flowable.idm.api.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
@Service
@Transactional
public class ModelServiceImpl implements ModelService {
private static final Logger LOGGER = LoggerFactory.getLogger(ModelServiceImpl.class);
public static final String NAMESPACE = "http://flowable.org/modeler";
protected static final String PROCESS_NOT_FOUND_MESSAGE_KEY = "PROCESS.ERROR.NOT-FOUND";
@Autowired
protected ModelImageService modelImageService;
@Autowired
protected ModelRepository modelRepository;
@Autowired
protected ModelHistoryRepository modelHistoryRepository;
@Autowired
protected ModelRelationRepository modelRelationRepository;
@Autowired
protected ObjectMapper objectMapper;
protected BpmnJsonConverter bpmnJsonConverter = new BpmnJsonConverter();
protected BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter();
protected CmmnJsonConverter cmmnJsonConverter = new CmmnJsonConverter();
protected CmmnXmlConverter cmmnXMLConverter = new CmmnXmlConverter();
@Override
public Model getModel(String modelId) {
Model model = modelRepository.get(modelId);
if (model == null) {
System.out.println("null");
}
return model;
}
public ModelRepresentation getModelRepresentation(String modelId) {
Model model = getModel(modelId);
return new ModelRepresentation(model);
}
@Override
public List<AbstractModel> getModelsByModelType(Integer modelType) {
return new ArrayList<AbstractModel>(modelRepository.findByModelType(modelType, ModelSort.NAME_ASC));
}
@Override
public ModelHistory getModelHistory(String modelId, String modelHistoryId) {
// Check if the user has read-rights on the process-model in order to fetch history
Model model = getModel(modelId);
ModelHistory modelHistory = modelHistoryRepository.get(modelHistoryId);
// Check if history corresponds to the current model and is not deleted
if (modelHistory == null || modelHistory.getRemovalDate() != null || !modelHistory.getModelId().equals(model.getId())) {
try {
throw new NotFoundException("Process model history not found: " + modelHistoryId);
} catch (NotFoundException e) {
}
}
return modelHistory;
}
@Override
public byte[] getBpmnXML(AbstractModel model) {
BpmnModel bpmnModel = getBpmnModel(model);
return getBpmnXML(bpmnModel);
}
@Override
public byte[] getBpmnXML(BpmnModel bpmnModel) {
for (Process process : bpmnModel.getProcesses()) {
if (StringUtils.isNotEmpty(process.getId())) {
char firstCharacter = process.getId().charAt(0);
// no digit is allowed as first character
if (Character.isDigit(firstCharacter)) {
process.setId("a" + process.getId());
}
}
}
byte[] xmlBytes = bpmnXMLConverter.convertToXML(bpmnModel);
return xmlBytes;
}
@Override
public byte[] getCmmnXML(AbstractModel model) {
CmmnModel cmmnModel = getCmmnModel(model);
return getCmmnXML(cmmnModel);
}
@Override
public byte[] getCmmnXML(CmmnModel cmmnModel) {
byte[] xmlBytes = cmmnXMLConverter.convertToXML(cmmnModel);
return xmlBytes;
}
public ModelKeyRepresentation validateModelKey(Model model, Integer modelType, String key) {
ModelKeyRepresentation modelKeyResponse = new ModelKeyRepresentation();
modelKeyResponse.setKey(key);
List<Model> models = modelRepository.findByKeyAndType(key, modelType);
for (Model modelInfo : models) {
if (model == null || !modelInfo.getId().equals(model.getId())) {
modelKeyResponse.setKeyAlreadyExists(true);
modelKeyResponse.setId(modelInfo.getId());
modelKeyResponse.setName(modelInfo.getName());
break;
}
}
return modelKeyResponse;
}
@Override
public String createModelJson(ModelRepresentation model) {
String json = null;
if (Integer.valueOf(AbstractModel.MODEL_TYPE_FORM).equals(model.getModelType())) {
try {
json = objectMapper.writeValueAsString(new SimpleFormModel());
} catch (Exception e) {
LOGGER.error("Error creating form model", e);
throw new RuntimeException("Error creating form");
}
} else if (Integer.valueOf(AbstractModel.MODEL_TYPE_DECISION_TABLE).equals(model.getModelType())) {
try {
DecisionTableDefinitionRepresentation decisionTableDefinition = new DecisionTableDefinitionRepresentation();
String decisionTableDefinitionKey = model.getName().replaceAll(" ", "");
decisionTableDefinition.setKey(decisionTableDefinitionKey);
json = objectMapper.writeValueAsString(decisionTableDefinition);
} catch (Exception e) {
LOGGER.error("Error creating decision table model", e);
throw new RuntimeException("Error creating decision table");
}
} else if (Integer.valueOf(AbstractModel.MODEL_TYPE_APP).equals(model.getModelType())) {
try {
json = objectMapper.writeValueAsString(new AppDefinition());
没有合适的资源?快使用搜索试试~ 我知道了~
ssos框架,记录平时使用的一些工具类,集成权限、数据权限、动态表单、自定义字段.zip
共947个文件
java:282个
js:206个
png:165个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 77 浏览量
2024-01-04
03:07:47
上传
评论
收藏 4.64MB ZIP 举报
温馨提示
ssos框架,记录平时使用的一些工具类,集成权限、数据权限、动态表单、自定义字段
资源推荐
资源详情
资源评论
收起资源包目录
ssos框架,记录平时使用的一些工具类,集成权限、数据权限、动态表单、自定义字段.zip (947个子文件)
gradlew.bat 3KB
CHANGES 3KB
bootstrap.css 118KB
bootstrap.min.css 98KB
bootstrap.min.css 97KB
style.css 62KB
ui-grid.css 52KB
ui-grid.min.css 38KB
style-editor.css 34KB
style.css 25KB
handsontable.full.min.css 22KB
bootstrap-theme.css 15KB
spectrum.css 14KB
bootstrap-theme.min.css 13KB
jquery.qtip.min.css 9KB
nvd3.min.css 8KB
daterangepicker-bs3.css 5KB
qunit.css 5KB
editor.css 4KB
loading-bar.min.css 2KB
jasmine.css 2KB
angular-gridster.min.css 2KB
hotkeys.css 2KB
bootstrap-tour.min.css 2KB
hotkeys.min.css 1KB
style-retina.css 856B
displaymodel.css 484B
displaymodel.css 476B
fontawesome-webfont.eot 59KB
lato-bold-webfont.eot 28KB
lato-regular-webfont.eot 28KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.eot 20KB
ui-grid.eot 10KB
activiti-admin-webfont.eot 5KB
cherokee-webfont.eot 4KB
spring.factories 120B
spring.factories 107B
tour-dnd.gif 80KB
sequenceflow-bendpoint.gif 72KB
open-group.gif 43KB
loading.gif 17KB
grid.gif 1KB
nw-handle-dark.gif 839B
se-handle-dark.gif 838B
.gitignore 382B
.gitignore 44B
.gitignore 23B
build.gradle 2KB
build.gradle 665B
build.gradle 418B
build.gradle 374B
build.gradle 357B
build.gradle 188B
settings.gradle 137B
build.gradle 0B
gradlew 8KB
assignment-popup.html 17KB
model.html 17KB
formfield-edit-popover.html 13KB
event-listeners-popup.html 12KB
editor.html 10KB
index.html 10KB
form-properties-popup.html 10KB
plan-item-lifecycle-listeners-popup.html 8KB
app-definition-builder.html 8KB
execution-listeners-popup.html 8KB
app-definition.html 8KB
form-builder.html 7KB
task-listeners-popup.html 7KB
form-builder-element-template.html 7KB
app-definition-save-model.html 6KB
duedate-popup.html 6KB
save-model.html 6KB
app-definitions.html 6KB
decision-tables.html 6KB
decision-table-edit-output-expression.html 6KB
decision-table-edit-input-expression.html 6KB
decisiontable-reference-popup.html 5KB
forms.html 5KB
decision-table.html 5KB
decision-table-editor.html 5KB
processes.html 5KB
casemodels.html 5KB
form-reference-popup.html 5KB
assignment-display-template.html 5KB
data-properties-popup.html 4KB
decision-table-save-model.html 4KB
app-definition-models-included.html 4KB
app-definition-import.html 4KB
app-definitions-import.html 4KB
decision-table-import.html 4KB
process-import.html 4KB
casemodel-import.html 4KB
app-definition-publish.html 4KB
fields-popup.html 4KB
404.html 3KB
select-group-popover.html 3KB
decision-table-edit-hit-policy.html 3KB
共 947 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
马coder
- 粉丝: 1203
- 资源: 6602
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功