@Test public void testConvertJsonToDmn_empty_expressions() throws Exception { JsonNode testJsonResource = parseJson(JSON_RESOURCE_4); DmnDefinition dmnDefinition = new DmnJsonConverter().convertToDmn(testJsonResource, "xyz", 1, new Date()); Assert.assertNotNull(dmnDefinition); }
public DmnDefinition convertToDmn(JsonNode modelNode, String modelId, int modelVersion, Date lastUpdated) { DmnDefinition definition = new DmnDefinition(); definition.setId("definition_"+modelId); definition.setName(DmnJsonConverterUtil.getValueAsString("name", modelNode)); definition.setNamespace(MODEL_NAMESPACE); definition.setTypeLanguage(URI_JSON); Decision decision = new Decision(); decision.setId(DmnJsonConverterUtil.getValueAsString("key", modelNode)); decision.setName(DmnJsonConverterUtil.getValueAsString("name", modelNode)); decision.setDescription(DmnJsonConverterUtil.getValueAsString("description", modelNode)); definition.addDecision(decision); DecisionTable decisionTable = new DecisionTable(); decisionTable.setId("decisionTable_"+DmnJsonConverterUtil.getValueAsString("id", modelNode)); if (modelNode.has("hitIndicator")) { decisionTable.setHitPolicy(HitPolicy.valueOf(DmnJsonConverterUtil.getValueAsString("hitIndicator", modelNode))); } else { decisionTable.setHitPolicy(HitPolicy.FIRST); } decisionTable.setPreferredOrientation(DecisionTableOrientation.RULE_AS_ROW); decision.setExpression(decisionTable); processDecisionTable(modelNode, definition, decisionTable); return definition; }
DmnJsonConverter { public DmnDefinition convertToDmn(JsonNode modelNode, String modelId, int modelVersion, Date lastUpdated) { DmnDefinition definition = new DmnDefinition(); definition.setId("definition_"+modelId); definition.setName(DmnJsonConverterUtil.getValueAsString("name", modelNode)); definition.setNamespace(MODEL_NAMESPACE); definition.setTypeLanguage(URI_JSON); Decision decision = new Decision(); decision.setId(DmnJsonConverterUtil.getValueAsString("key", modelNode)); decision.setName(DmnJsonConverterUtil.getValueAsString("name", modelNode)); decision.setDescription(DmnJsonConverterUtil.getValueAsString("description", modelNode)); definition.addDecision(decision); DecisionTable decisionTable = new DecisionTable(); decisionTable.setId("decisionTable_"+DmnJsonConverterUtil.getValueAsString("id", modelNode)); if (modelNode.has("hitIndicator")) { decisionTable.setHitPolicy(HitPolicy.valueOf(DmnJsonConverterUtil.getValueAsString("hitIndicator", modelNode))); } else { decisionTable.setHitPolicy(HitPolicy.FIRST); } decisionTable.setPreferredOrientation(DecisionTableOrientation.RULE_AS_ROW); decision.setExpression(decisionTable); processDecisionTable(modelNode, definition, decisionTable); return definition; } }
DmnJsonConverter { public DmnDefinition convertToDmn(JsonNode modelNode, String modelId, int modelVersion, Date lastUpdated) { DmnDefinition definition = new DmnDefinition(); definition.setId("definition_"+modelId); definition.setName(DmnJsonConverterUtil.getValueAsString("name", modelNode)); definition.setNamespace(MODEL_NAMESPACE); definition.setTypeLanguage(URI_JSON); Decision decision = new Decision(); decision.setId(DmnJsonConverterUtil.getValueAsString("key", modelNode)); decision.setName(DmnJsonConverterUtil.getValueAsString("name", modelNode)); decision.setDescription(DmnJsonConverterUtil.getValueAsString("description", modelNode)); definition.addDecision(decision); DecisionTable decisionTable = new DecisionTable(); decisionTable.setId("decisionTable_"+DmnJsonConverterUtil.getValueAsString("id", modelNode)); if (modelNode.has("hitIndicator")) { decisionTable.setHitPolicy(HitPolicy.valueOf(DmnJsonConverterUtil.getValueAsString("hitIndicator", modelNode))); } else { decisionTable.setHitPolicy(HitPolicy.FIRST); } decisionTable.setPreferredOrientation(DecisionTableOrientation.RULE_AS_ROW); decision.setExpression(decisionTable); processDecisionTable(modelNode, definition, decisionTable); return definition; }  }
DmnJsonConverter { public DmnDefinition convertToDmn(JsonNode modelNode, String modelId, int modelVersion, Date lastUpdated) { DmnDefinition definition = new DmnDefinition(); definition.setId("definition_"+modelId); definition.setName(DmnJsonConverterUtil.getValueAsString("name", modelNode)); definition.setNamespace(MODEL_NAMESPACE); definition.setTypeLanguage(URI_JSON); Decision decision = new Decision(); decision.setId(DmnJsonConverterUtil.getValueAsString("key", modelNode)); decision.setName(DmnJsonConverterUtil.getValueAsString("name", modelNode)); decision.setDescription(DmnJsonConverterUtil.getValueAsString("description", modelNode)); definition.addDecision(decision); DecisionTable decisionTable = new DecisionTable(); decisionTable.setId("decisionTable_"+DmnJsonConverterUtil.getValueAsString("id", modelNode)); if (modelNode.has("hitIndicator")) { decisionTable.setHitPolicy(HitPolicy.valueOf(DmnJsonConverterUtil.getValueAsString("hitIndicator", modelNode))); } else { decisionTable.setHitPolicy(HitPolicy.FIRST); } decisionTable.setPreferredOrientation(DecisionTableOrientation.RULE_AS_ROW); decision.setExpression(decisionTable); processDecisionTable(modelNode, definition, decisionTable); return definition; }  DmnDefinition convertToDmn(JsonNode modelNode, String modelId, int modelVersion, Date lastUpdated); ObjectNode convertToJson(DmnDefinition definition); }
DmnJsonConverter { public DmnDefinition convertToDmn(JsonNode modelNode, String modelId, int modelVersion, Date lastUpdated) { DmnDefinition definition = new DmnDefinition(); definition.setId("definition_"+modelId); definition.setName(DmnJsonConverterUtil.getValueAsString("name", modelNode)); definition.setNamespace(MODEL_NAMESPACE); definition.setTypeLanguage(URI_JSON); Decision decision = new Decision(); decision.setId(DmnJsonConverterUtil.getValueAsString("key", modelNode)); decision.setName(DmnJsonConverterUtil.getValueAsString("name", modelNode)); decision.setDescription(DmnJsonConverterUtil.getValueAsString("description", modelNode)); definition.addDecision(decision); DecisionTable decisionTable = new DecisionTable(); decisionTable.setId("decisionTable_"+DmnJsonConverterUtil.getValueAsString("id", modelNode)); if (modelNode.has("hitIndicator")) { decisionTable.setHitPolicy(HitPolicy.valueOf(DmnJsonConverterUtil.getValueAsString("hitIndicator", modelNode))); } else { decisionTable.setHitPolicy(HitPolicy.FIRST); } decisionTable.setPreferredOrientation(DecisionTableOrientation.RULE_AS_ROW); decision.setExpression(decisionTable); processDecisionTable(modelNode, definition, decisionTable); return definition; }  DmnDefinition convertToDmn(JsonNode modelNode, String modelId, int modelVersion, Date lastUpdated); ObjectNode convertToJson(DmnDefinition definition); final static String MODEL_NAMESPACE; final static String URI_JSON; }