use of org.kie.dmn.model.api.Definitions in project kie-wb-common by kiegroup.
the class DMNMarshallerImportsHelperStandaloneImplTest method testGetOtherDMNDiagramsDefinitionsWhenProjectCannotBeFound.
@Test
public void testGetOtherDMNDiagramsDefinitionsWhenProjectCannotBeFound() {
final Metadata metadata = mock(Metadata.class);
final Path path1 = makePath("../file1.dmn");
final Path path2 = makePath("../file2.dmn");
final Path path3 = makePath("../file3.dmn");
final InputStream inputStream1 = mock(InputStream.class);
final InputStream inputStream2 = mock(InputStream.class);
final InputStream inputStream3 = mock(InputStream.class);
final InputStreamReader inputStreamReader1 = mock(InputStreamReader.class);
final InputStreamReader inputStreamReader2 = mock(InputStreamReader.class);
final InputStreamReader inputStreamReader3 = mock(InputStreamReader.class);
final Definitions definitions1 = mock(Definitions.class);
final Definitions definitions2 = mock(Definitions.class);
final Definitions definitions3 = mock(Definitions.class);
final List<Path> paths = asList(path1, path2, path3);
when(projectService.resolveProject(any(Path.class))).thenThrow(new NullPointerException());
when(pathsHelper.getDMNModelsPaths(any())).thenReturn(paths);
when(metadata.getPath()).thenReturn(path2);
doReturn(Optional.of(inputStream1)).when(helper).loadPath(path1);
doReturn(Optional.of(inputStream2)).when(helper).loadPath(path2);
doReturn(Optional.of(inputStream3)).when(helper).loadPath(path3);
doReturn(inputStreamReader1).when(helper).toInputStreamReader(inputStream1);
doReturn(inputStreamReader2).when(helper).toInputStreamReader(inputStream2);
doReturn(inputStreamReader3).when(helper).toInputStreamReader(inputStream3);
when(marshaller.unmarshal(inputStreamReader1)).thenReturn(definitions1);
when(marshaller.unmarshal(inputStreamReader2)).thenReturn(definitions2);
when(marshaller.unmarshal(inputStreamReader3)).thenReturn(definitions3);
final List<Definitions> actualDefinitions = helper.getOtherDMNDiagramsDefinitions(metadata);
final List<Definitions> expectedDefinitions = asList(definitions1, definitions3);
assertEquals(expectedDefinitions, actualDefinitions);
}
use of org.kie.dmn.model.api.Definitions in project drools by kiegroup.
the class XStreamMarshaller method newXStream.
private XStream newXStream() {
XStream xStream = XStreamUtils.createNonTrustingXStream(staxDriver, Definitions.class.getClassLoader(), DMNXStream::from);
xStream.addPermission(new TypeHierarchyPermission(QName.class));
xStream.addPermission(new TypeHierarchyPermission(KieDMNModelInstrumentedBase.class));
xStream.alias("artifact", TArtifact.class);
xStream.alias("definitions", TDefinitions.class);
xStream.alias("inputData", TInputData.class);
xStream.alias("decision", TDecision.class);
xStream.alias("variable", TInformationItem.class);
xStream.alias("informationRequirement", TInformationRequirement.class);
xStream.alias("requiredInput", TDMNElementReference.class);
xStream.alias("literalExpression", TLiteralExpression.class);
// TODO will need to remove dups and find missing element not captured?
xStream.alias("DMNElement", TDMNElement.class);
xStream.alias("allowedValues", TUnaryTests.class);
xStream.alias("artifact", TArtifact.class);
xStream.alias("association", TAssociation.class);
xStream.alias("authorityRequirement", TAuthorityRequirement.class);
xStream.alias("authorityRequirement", TAuthorityRequirement.class);
xStream.alias("authorityRequirement", TAuthorityRequirement.class);
xStream.alias("binding", TBinding.class);
xStream.alias("businessContextElement", TBusinessContextElement.class);
xStream.alias("businessKnowledgeModel", TBusinessKnowledgeModel.class);
xStream.alias("column", TInformationItem.class);
xStream.alias("context", TContext.class);
xStream.alias("contextEntry", TContextEntry.class);
xStream.alias("decision", TDecision.class);
xStream.alias("decisionMade", TDMNElementReference.class);
xStream.alias("decisionMaker", TDMNElementReference.class);
xStream.alias("decisionOwned", TDMNElementReference.class);
xStream.alias("decisionOwner", TDMNElementReference.class);
xStream.alias("decisionService", TDecisionService.class);
xStream.alias("decisionTable", TDecisionTable.class);
xStream.alias("defaultOutputEntry", TLiteralExpression.class);
xStream.alias("definitions", TDefinitions.class);
xStream.alias("drgElement", TDMNElementReference.class);
// xStream.alias("drgElement", DRGElement.class ); ambiguity, also referring to top-level xsd element just under xsd root.
xStream.alias("elementCollection", TElementCollection.class);
xStream.alias("elementCollection", TElementCollection.class);
xStream.alias("encapsulatedDecision", TDMNElementReference.class);
xStream.alias("encapsulatedLogic", TFunctionDefinition.class);
xStream.alias("expression", TExpression.class);
xStream.alias("formalParameter", TInformationItem.class);
xStream.alias("functionDefinition", TFunctionDefinition.class);
xStream.alias("impactedPerformanceIndicator", TDMNElementReference.class);
xStream.alias("impactingDecision", TDMNElementReference.class);
xStream.alias("import", TImport.class);
xStream.alias("import", TImport.class);
// TODO where?
xStream.alias("importedElement", String.class);
xStream.alias("importedValues", TImportedValues.class);
xStream.alias("informationItem", TInformationItem.class);
xStream.alias("informationRequirement", TInformationRequirement.class);
xStream.alias("input", TInputClause.class);
xStream.alias("inputData", TDMNElementReference.class);
xStream.alias("inputData", TInputData.class);
xStream.alias("inputDecision", TDMNElementReference.class);
xStream.alias("inputEntry", TUnaryTests.class);
xStream.alias("inputExpression", TLiteralExpression.class);
xStream.alias("inputValues", TUnaryTests.class);
xStream.alias("invocation", TInvocation.class);
xStream.alias("itemComponent", TItemDefinition.class);
xStream.alias("itemDefinition", TItemDefinition.class);
xStream.alias("itemDefinition", TItemDefinition.class);
xStream.alias("knowledgeRequirement", TKnowledgeRequirement.class);
xStream.alias("knowledgeRequirement", TKnowledgeRequirement.class);
xStream.alias("knowledgeSource", TKnowledgeSource.class);
xStream.alias("literalExpression", TLiteralExpression.class);
xStream.alias("namedElement", TNamedElement.class);
xStream.alias("organizationUnit", TOrganizationUnit.class);
xStream.alias("output", TOutputClause.class);
xStream.alias("outputDecision", TDMNElementReference.class);
xStream.alias("outputEntry", TLiteralExpression.class);
xStream.alias("outputValues", TUnaryTests.class);
xStream.alias("owner", TDMNElementReference.class);
xStream.alias("parameter", TInformationItem.class);
xStream.alias("performanceIndicator", TPerformanceIndicator.class);
xStream.alias("relation", TRelation.class);
xStream.alias("requiredAuthority", TDMNElementReference.class);
xStream.alias("requiredDecision", TDMNElementReference.class);
xStream.alias("requiredDecision", TDMNElementReference.class);
xStream.alias("requiredInput", TDMNElementReference.class);
xStream.alias("requiredInput", TDMNElementReference.class);
xStream.alias("requiredKnowledge", TDMNElementReference.class);
xStream.alias("rule", TDecisionRule.class);
xStream.alias("sourceRef", TDMNElementReference.class);
xStream.alias("supportedObjective", TDMNElementReference.class);
xStream.alias("targetRef", TDMNElementReference.class);
xStream.alias("textAnnotation", TTextAnnotation.class);
// TODO where?
xStream.alias("type", String.class);
xStream.alias("typeRef", QName.class);
xStream.alias("usingProcess", TDMNElementReference.class);
xStream.alias("usingTask", TDMNElementReference.class);
xStream.alias("variable", TInformationItem.class);
xStream.alias("variable", TInformationItem.class);
xStream.alias("variable", TInformationItem.class);
xStream.alias("variable", TInformationItem.class);
// xStream.alias("allowedAnswers", xsd:string.class );
// xStream.alias("description", xsd:string.class );
// xStream.alias("question", xsd:string.class );
// xStream.alias("text", xsd:string.class );
// xStream.alias("text", xsd:string.class );
// xStream.alias("text", xsd:string.class );
xStream.alias("row", org.kie.dmn.model.v1_1.TList.class);
xStream.alias("list", org.kie.dmn.model.v1_1.TList.class);
xStream.alias("extensionElements", TDMNElement.TExtensionElements.class);
// Manually imported TEXT = String
xStream.alias(LiteralExpressionConverter.TEXT, String.class);
xStream.alias(TextAnnotationConverter.TEXT, String.class);
xStream.alias(UnaryTestsConverter.TEXT, String.class);
xStream.alias(DecisionConverter.QUESTION, String.class);
xStream.alias(DecisionConverter.ALLOWED_ANSWERS, String.class);
xStream.alias(DMNElementConverter.DESCRIPTION, String.class);
xStream.registerConverter(new AssociationConverter(xStream));
xStream.registerConverter(new AuthorityRequirementConverter(xStream));
xStream.registerConverter(new BindingConverter(xStream));
xStream.registerConverter(new BusinessKnowledgeModelConverter(xStream));
xStream.registerConverter(new ContextConverter(xStream));
xStream.registerConverter(new ContextEntryConverter(xStream));
xStream.registerConverter(new DecisionConverter(xStream));
xStream.registerConverter(new DecisionRuleConverter(xStream));
xStream.registerConverter(new DecisionServiceConverter(xStream));
xStream.registerConverter(new DecisionTableConverter(xStream));
xStream.registerConverter(new DefinitionsConverter(xStream));
xStream.registerConverter(new DMNElementReferenceConverter(xStream));
xStream.registerConverter(new FunctionDefinitionConverter(xStream));
xStream.registerConverter(new ImportConverter(xStream));
xStream.registerConverter(new ImportedValuesConverter(xStream));
xStream.registerConverter(new InformationItemConverter(xStream));
xStream.registerConverter(new InformationRequirementConverter(xStream));
xStream.registerConverter(new InputClauseConverter(xStream));
xStream.registerConverter(new InputDataConverter(xStream));
xStream.registerConverter(new InvocationConverter(xStream));
xStream.registerConverter(new ItemDefinitionConverter(xStream));
xStream.registerConverter(new KnowledgeRequirementConverter(xStream));
xStream.registerConverter(new KnowledgeSourceConverter(xStream));
xStream.registerConverter(new LiteralExpressionConverter(xStream));
xStream.registerConverter(new OrganizationUnitConverter(xStream));
xStream.registerConverter(new OutputClauseConverter(xStream));
xStream.registerConverter(new PerformanceIndicatorConverter(xStream));
xStream.registerConverter(new RelationConverter(xStream));
xStream.registerConverter(new TextAnnotationConverter(xStream));
xStream.registerConverter(new UnaryTestsConverter(xStream));
xStream.registerConverter(new QNameConverter());
xStream.registerConverter(new DMNListConverter(xStream));
xStream.registerConverter(new ElementCollectionConverter(xStream));
xStream.registerConverter(new ExtensionElementsConverter(xStream, extensionRegisters));
xStream.ignoreUnknownElements();
for (DMNExtensionRegister extensionRegister : extensionRegisters) {
extensionRegister.registerExtensionConverters(xStream);
}
return xStream;
}
use of org.kie.dmn.model.api.Definitions in project drools by kiegroup.
the class DefinitionsConverter method writeAttributes.
@Override
protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) {
super.writeAttributes(writer, parent);
Definitions def = (Definitions) parent;
if (def.getExpressionLanguage() != null)
writer.addAttribute(EXPRESSION_LANGUAGE, def.getExpressionLanguage());
if (def.getTypeLanguage() != null)
writer.addAttribute(TYPE_LANGUAGE, def.getTypeLanguage());
if (def.getNamespace() != null)
writer.addAttribute(NAMESPACE, def.getNamespace());
if (def.getExporter() != null)
writer.addAttribute(EXPORTER, def.getExporter());
if (def.getExporterVersion() != null)
writer.addAttribute(EXPORTER_VERSION, def.getExporterVersion());
}
use of org.kie.dmn.model.api.Definitions in project drools by kiegroup.
the class DefinitionsConverter method assignAttributes.
@Override
protected void assignAttributes(HierarchicalStreamReader reader, Object parent) {
super.assignAttributes(reader, parent);
Definitions def = (Definitions) parent;
String exprLang = reader.getAttribute(EXPRESSION_LANGUAGE);
String typeLang = reader.getAttribute(TYPE_LANGUAGE);
String namespace = reader.getAttribute(NAMESPACE);
String exporter = reader.getAttribute(EXPORTER);
String exporterVersion = reader.getAttribute(EXPORTER_VERSION);
def.setExpressionLanguage(exprLang);
def.setTypeLanguage(typeLang);
def.setNamespace(namespace);
def.setExporter(exporter);
def.setExporterVersion(exporterVersion);
}
use of org.kie.dmn.model.api.Definitions in project drools by kiegroup.
the class XStreamMarshaller method newXStream.
private XStream newXStream() {
XStream xStream = XStreamUtils.createNonTrustingXStream(staxDriver, Definitions.class.getClassLoader(), DMNXStream::from);
xStream.addPermission(new TypeHierarchyPermission(QName.class));
xStream.addPermission(new TypeHierarchyPermission(KieDMNModelInstrumentedBase.class));
xStream.alias("artifact", TArtifact.class);
xStream.alias("definitions", TDefinitions.class);
xStream.alias("inputData", TInputData.class);
xStream.alias("decision", TDecision.class);
xStream.alias("variable", TInformationItem.class);
xStream.alias("informationRequirement", TInformationRequirement.class);
xStream.alias("requiredInput", TDMNElementReference.class);
xStream.alias("literalExpression", TLiteralExpression.class);
xStream.alias("DMNElement", TDMNElement.class);
xStream.alias("allowedValues", TUnaryTests.class);
xStream.alias("artifact", TArtifact.class);
xStream.alias("association", TAssociation.class);
xStream.alias("authorityRequirement", TAuthorityRequirement.class);
xStream.alias("binding", TBinding.class);
xStream.alias("businessContextElement", TBusinessContextElement.class);
xStream.alias("businessKnowledgeModel", TBusinessKnowledgeModel.class);
xStream.alias("column", TInformationItem.class);
xStream.alias("context", TContext.class);
xStream.alias("contextEntry", TContextEntry.class);
xStream.alias("decision", TDecision.class);
xStream.alias("decisionMade", TDMNElementReference.class);
xStream.alias("decisionMaker", TDMNElementReference.class);
xStream.alias("decisionOwned", TDMNElementReference.class);
xStream.alias("decisionOwner", TDMNElementReference.class);
xStream.alias("decisionService", TDecisionService.class);
xStream.alias("decisionTable", TDecisionTable.class);
xStream.alias("defaultOutputEntry", TLiteralExpression.class);
xStream.alias("definitions", TDefinitions.class);
xStream.alias("drgElement", TDMNElementReference.class);
xStream.alias("elementCollection", TElementCollection.class);
xStream.alias("encapsulatedDecision", TDMNElementReference.class);
xStream.alias("encapsulatedLogic", TFunctionDefinition.class);
xStream.alias("expression", TExpression.class);
xStream.alias("formalParameter", TInformationItem.class);
xStream.alias("functionDefinition", TFunctionDefinition.class);
xStream.alias("impactedPerformanceIndicator", TDMNElementReference.class);
xStream.alias("impactingDecision", TDMNElementReference.class);
xStream.alias("import", TImport.class);
xStream.alias("import", TImport.class);
// TODO where?
xStream.alias("importedElement", String.class);
xStream.alias("importedValues", TImportedValues.class);
xStream.alias("informationItem", TInformationItem.class);
xStream.alias("informationRequirement", TInformationRequirement.class);
xStream.alias("input", TInputClause.class);
xStream.alias("inputData", TInputData.class);
xStream.alias("inputDecision", TDMNElementReference.class);
xStream.alias("inputEntry", TUnaryTests.class);
xStream.alias("inputExpression", TLiteralExpression.class);
xStream.alias("inputValues", TUnaryTests.class);
xStream.alias("invocation", TInvocation.class);
xStream.alias("itemComponent", TItemDefinition.class);
xStream.alias("itemDefinition", TItemDefinition.class);
xStream.alias("knowledgeRequirement", TKnowledgeRequirement.class);
xStream.alias("knowledgeSource", TKnowledgeSource.class);
xStream.alias("literalExpression", TLiteralExpression.class);
xStream.alias("namedElement", TNamedElement.class);
xStream.alias("organizationUnit", TOrganizationUnit.class);
xStream.alias("output", TOutputClause.class);
xStream.alias("outputDecision", TDMNElementReference.class);
xStream.alias("outputEntry", TLiteralExpression.class);
xStream.alias("outputValues", TUnaryTests.class);
xStream.alias("owner", TDMNElementReference.class);
xStream.alias("parameter", TInformationItem.class);
xStream.alias("performanceIndicator", TPerformanceIndicator.class);
xStream.alias("relation", TRelation.class);
xStream.alias("requiredAuthority", TDMNElementReference.class);
xStream.alias("requiredDecision", TDMNElementReference.class);
xStream.alias("requiredInput", TDMNElementReference.class);
xStream.alias("requiredKnowledge", TDMNElementReference.class);
xStream.alias("rule", TDecisionRule.class);
xStream.alias("sourceRef", TDMNElementReference.class);
xStream.alias("supportedObjective", TDMNElementReference.class);
xStream.alias("targetRef", TDMNElementReference.class);
xStream.alias("textAnnotation", TTextAnnotation.class);
// TODO where?
xStream.alias("type", String.class);
xStream.alias("typeRef", QName.class);
xStream.alias("usingProcess", TDMNElementReference.class);
xStream.alias("usingTask", TDMNElementReference.class);
xStream.alias("variable", TInformationItem.class);
xStream.alias("row", org.kie.dmn.model.v1_2.TList.class);
xStream.alias("list", org.kie.dmn.model.v1_2.TList.class);
xStream.alias("extensionElements", TDMNElement.TExtensionElements.class);
// Manually imported TEXT = String
xStream.alias(LiteralExpressionConverter.TEXT, String.class);
// unnecessary 'text' key repetition: xStream.alias( TextAnnotationConverter.TEXT, String.class );
// unnecessary 'text' key repetition: xStream.alias( UnaryTestsConverter.TEXT, String.class );
xStream.alias(DecisionConverter.QUESTION, String.class);
xStream.alias(DecisionConverter.ALLOWED_ANSWERS, String.class);
xStream.alias(DMNElementConverter.DESCRIPTION, String.class);
// unnecessary 'text' key repetition: xStream.alias("text", xsd:string.class );
// unnecessary 'text' key repetition: xStream.alias("text", xsd:string.class );
// unnecessary 'text' key repetition: xStream.alias("text", xsd:string.class );
// xStream.alias("question", xsd:string.class );
// xStream.alias("allowedAnswers", xsd:string.class );
// xStream.alias("description", xsd:string.class );
// DMN v1.2:
// Note, to comply with NS for XStream need also to adjust entries inside DMNModelInstrumentedBaseConverter
xStream.alias("annotation", TRuleAnnotationClause.class);
xStream.alias("annotationEntry", TRuleAnnotation.class);
xStream.registerConverter(new RuleAnnotationClauseConverter(xStream));
xStream.registerConverter(new RuleAnnotationConverter(xStream));
xStream.alias("DMNDI", DMNDI.class);
xStream.registerConverter(new DMNDIConverter(xStream));
xStream.alias("DMNDiagram", DMNDiagram.class);
xStream.registerConverter(new DMNDiagramConverter(xStream));
xStream.alias("DMNStyle", DMNStyle.class);
xStream.registerConverter(new DMNStyleConverter(xStream));
xStream.alias("Size", Dimension.class);
xStream.registerConverter(new DimensionConverter(xStream));
xStream.alias("DMNShape", DMNShape.class);
xStream.registerConverter(new DMNShapeConverter(xStream));
xStream.alias("FillColor", Color.class);
xStream.alias("StrokeColor", Color.class);
xStream.alias("FontColor", Color.class);
xStream.registerConverter(new ColorConverter(xStream));
xStream.alias("Bounds", Bounds.class);
xStream.registerConverter(new BoundsConverter(xStream));
xStream.alias("DMNLabel", DMNLabel.class);
xStream.registerConverter(new DMNLabelConverter(xStream));
xStream.alias("DMNEdge", DMNEdge.class);
xStream.registerConverter(new DMNEdgeConverter(xStream));
xStream.alias("DMNDecisionServiceDividerLine", DMNDecisionServiceDividerLine.class);
xStream.registerConverter(new DMNDecisionServiceDividerLineConverter(xStream));
xStream.alias("waypoint", Point.class);
xStream.registerConverter(new PointConverter(xStream));
xStream.alias("extension", DiagramElement.Extension.class);
xStream.alias(DMNLabelConverter.TEXT, String.class);
xStream.registerConverter(new AssociationConverter(xStream));
xStream.registerConverter(new AuthorityRequirementConverter(xStream));
xStream.registerConverter(new BindingConverter(xStream));
xStream.registerConverter(new BusinessKnowledgeModelConverter(xStream));
xStream.registerConverter(new ContextConverter(xStream));
xStream.registerConverter(new ContextEntryConverter(xStream));
xStream.registerConverter(new DecisionConverter(xStream));
xStream.registerConverter(new DecisionRuleConverter(xStream));
xStream.registerConverter(new DecisionServiceConverter(xStream));
xStream.registerConverter(new DecisionTableConverter(xStream));
xStream.registerConverter(new DefinitionsConverter(xStream));
xStream.registerConverter(new DMNElementReferenceConverter(xStream));
xStream.registerConverter(new FunctionDefinitionConverter(xStream));
xStream.registerConverter(new ImportConverter(xStream));
xStream.registerConverter(new ImportedValuesConverter(xStream));
xStream.registerConverter(new InformationItemConverter(xStream));
xStream.registerConverter(new InformationRequirementConverter(xStream));
xStream.registerConverter(new InputClauseConverter(xStream));
xStream.registerConverter(new InputDataConverter(xStream));
xStream.registerConverter(new InvocationConverter(xStream));
xStream.registerConverter(new ItemDefinitionConverter(xStream));
xStream.registerConverter(new KnowledgeRequirementConverter(xStream));
xStream.registerConverter(new KnowledgeSourceConverter(xStream));
xStream.registerConverter(new LiteralExpressionConverter(xStream));
xStream.registerConverter(new OrganizationUnitConverter(xStream));
xStream.registerConverter(new OutputClauseConverter(xStream));
xStream.registerConverter(new PerformanceIndicatorConverter(xStream));
xStream.registerConverter(new RelationConverter(xStream));
xStream.registerConverter(new TextAnnotationConverter(xStream));
xStream.registerConverter(new UnaryTestsConverter(xStream));
xStream.registerConverter(new QNameConverter());
xStream.registerConverter(new DMNListConverter(xStream));
xStream.registerConverter(new ElementCollectionConverter(xStream));
xStream.registerConverter(new ExtensionElementsConverter(xStream, extensionRegisters));
xStream.registerConverter(new DiagramElementExtensionConverter(xStream, extensionRegisters));
xStream.ignoreUnknownElements();
for (DMNExtensionRegister extensionRegister : extensionRegisters) {
extensionRegister.registerExtensionConverters(xStream);
}
return xStream;
}
Aggregations