use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class DemoDataConfiguration method createModelData.
protected void createModelData(String name, String description, String jsonFile) {
List<Model> modelList = repositoryService.createModelQuery().modelName("Demo model").list();
if (modelList == null || modelList.isEmpty()) {
Model model = repositoryService.newModel();
model.setName(name);
ObjectNode modelObjectNode = new ObjectMapper().createObjectNode();
modelObjectNode.put("name", name);
modelObjectNode.put("description", description);
model.setMetaInfo(modelObjectNode.toString());
repositoryService.saveModel(model);
try {
InputStream svgStream = this.getClass().getClassLoader().getResourceAsStream("org/activiti/rest/demo/model/test.svg");
repositoryService.addModelEditorSourceExtra(model.getId(), IOUtils.toByteArray(svgStream));
} catch (Exception e) {
LOGGER.warn("Failed to read SVG", e);
}
try {
InputStream editorJsonStream = this.getClass().getClassLoader().getResourceAsStream(jsonFile);
repositoryService.addModelEditorSource(model.getId(), IOUtils.toByteArray(editorJsonStream));
} catch (Exception e) {
LOGGER.warn("Failed to read editor JSON", e);
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class UelExpressionCondition method evaluate.
public boolean evaluate(String sequenceFlowId, DelegateExecution execution) {
String conditionExpression = null;
if (Context.getProcessEngineConfiguration().isEnableProcessDefinitionInfoCache()) {
ObjectNode elementProperties = Context.getBpmnOverrideElementProperties(sequenceFlowId, execution.getProcessDefinitionId());
conditionExpression = getActiveValue(initialConditionExpression, DynamicBpmnConstants.SEQUENCE_FLOW_CONDITION, elementProperties);
} else {
conditionExpression = initialConditionExpression;
}
Expression expression = Context.getProcessEngineConfiguration().getExpressionManager().createExpression(conditionExpression);
Object result = expression.getValue(execution);
if (result == null) {
throw new ActivitiException("condition expression returns null");
}
if (!(result instanceof Boolean)) {
throw new ActivitiException("condition expression returns non-Boolean: " + result + " (" + result.getClass().getName() + ")");
}
return (Boolean) result;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class ImportUploadReceiver method deployUploadedFile.
protected void deployUploadedFile() {
try {
try {
if (fileName.endsWith(".bpmn20.xml") || fileName.endsWith(".bpmn")) {
validFile = true;
XMLInputFactory xif = XmlUtil.createSafeXmlInputFactory();
InputStreamReader in = new InputStreamReader(new ByteArrayInputStream(outputStream.toByteArray()), "UTF-8");
XMLStreamReader xtr = xif.createXMLStreamReader(in);
BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);
if (bpmnModel.getMainProcess() == null || bpmnModel.getMainProcess().getId() == null) {
notificationManager.showErrorNotification(Messages.MODEL_IMPORT_FAILED, i18nManager.getMessage(Messages.MODEL_IMPORT_INVALID_BPMN_EXPLANATION));
} else {
if (bpmnModel.getLocationMap().isEmpty()) {
notificationManager.showErrorNotification(Messages.MODEL_IMPORT_INVALID_BPMNDI, i18nManager.getMessage(Messages.MODEL_IMPORT_INVALID_BPMNDI_EXPLANATION));
} else {
String processName = null;
if (StringUtils.isNotEmpty(bpmnModel.getMainProcess().getName())) {
processName = bpmnModel.getMainProcess().getName();
} else {
processName = bpmnModel.getMainProcess().getId();
}
modelData = repositoryService.newModel();
ObjectNode modelObjectNode = new ObjectMapper().createObjectNode();
modelObjectNode.put(MODEL_NAME, processName);
modelObjectNode.put(MODEL_REVISION, 1);
modelData.setMetaInfo(modelObjectNode.toString());
modelData.setName(processName);
repositoryService.saveModel(modelData);
BpmnJsonConverter jsonConverter = new BpmnJsonConverter();
ObjectNode editorNode = jsonConverter.convertToJson(bpmnModel);
repositoryService.addModelEditorSource(modelData.getId(), editorNode.toString().getBytes("utf-8"));
}
}
} else {
notificationManager.showErrorNotification(Messages.MODEL_IMPORT_INVALID_FILE, i18nManager.getMessage(Messages.MODEL_IMPORT_INVALID_FILE_EXPLANATION));
}
} catch (Exception e) {
String errorMsg = e.getMessage().replace(System.getProperty("line.separator"), "<br/>");
notificationManager.showErrorNotification(Messages.MODEL_IMPORT_FAILED, errorMsg);
}
} finally {
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
notificationManager.showErrorNotification("Server-side error", e.getMessage());
}
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class CopyModelPopupWindow method addButtons.
protected void addButtons() {
// Cancel
Button cancelButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL));
cancelButton.addStyleName(Reindeer.BUTTON_SMALL);
cancelButton.addListener(new ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
close();
}
});
// Create
Button createButton = new Button(i18nManager.getMessage(Messages.PROCESS_NEW_POPUP_CREATE_BUTTON));
createButton.addStyleName(Reindeer.BUTTON_SMALL);
createButton.addListener(new ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
if (StringUtils.isEmpty((String) nameTextField.getValue())) {
form.setComponentError(new UserError("The name field is required."));
return;
}
Model newModelData = repositoryService.newModel();
ObjectNode modelObjectNode = new ObjectMapper().createObjectNode();
modelObjectNode.put(MODEL_NAME, (String) nameTextField.getValue());
String description = null;
if (StringUtils.isNotEmpty((String) descriptionTextArea.getValue())) {
description = (String) descriptionTextArea.getValue();
} else {
description = "";
}
modelObjectNode.put(MODEL_DESCRIPTION, description);
newModelData.setMetaInfo(modelObjectNode.toString());
newModelData.setName((String) nameTextField.getValue());
repositoryService.saveModel(newModelData);
repositoryService.addModelEditorSource(newModelData.getId(), repositoryService.getModelEditorSource(modelData.getId()));
repositoryService.addModelEditorSourceExtra(newModelData.getId(), repositoryService.getModelEditorSourceExtra(modelData.getId()));
close();
ExplorerApp.get().getViewManager().showEditorProcessDefinitionPage(newModelData.getId());
}
});
// Alignment
HorizontalLayout buttonLayout = new HorizontalLayout();
buttonLayout.setSpacing(true);
buttonLayout.addComponent(cancelButton);
buttonLayout.addComponent(createButton);
addComponent(buttonLayout);
windowLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class EditorProcessDefinitionDetailPanel method deployModel.
protected void deployModel() {
try {
if (SimpleTableEditorConstants.TABLE_EDITOR_CATEGORY.equals(modelData.getCategory())) {
deploySimpleTableEditorModel(repositoryService.getModelEditorSource(modelData.getId()));
} else {
final ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
deployModelerModel(modelNode);
}
} catch (Exception e) {
LOGGER.error("Failed to deploy model", e);
ExplorerApp.get().getNotificationManager().showErrorNotification(Messages.PROCESS_TOXML_FAILED, e);
}
}
Aggregations