Search in sources :

Example 1 with Artifact

use of org.kie.dmn.model.v1_1.Artifact in project drools by kiegroup.

the class XStreamMarshaller method newXStream.

private XStream newXStream() {
    XStream xStream = createTrustingXStream(staxDriver, Definitions.class.getClassLoader());
    xStream.alias("artifact", Artifact.class);
    xStream.alias("definitions", Definitions.class);
    xStream.alias("inputData", InputData.class);
    xStream.alias("decision", Decision.class);
    xStream.alias("variable", InformationItem.class);
    xStream.alias("informationRequirement", InformationRequirement.class);
    xStream.alias("requiredInput", DMNElementReference.class);
    xStream.alias("literalExpression", LiteralExpression.class);
    // TODO will need to remove dups and find missing element not captured?
    xStream.alias("DMNElement", DMNElement.class);
    xStream.alias("allowedValues", UnaryTests.class);
    xStream.alias("artifact", Artifact.class);
    xStream.alias("association", Association.class);
    xStream.alias("authorityRequirement", AuthorityRequirement.class);
    xStream.alias("authorityRequirement", AuthorityRequirement.class);
    xStream.alias("authorityRequirement", AuthorityRequirement.class);
    xStream.alias("binding", Binding.class);
    xStream.alias("businessContextElement", BusinessContextElement.class);
    xStream.alias("businessKnowledgeModel", BusinessKnowledgeModel.class);
    xStream.alias("column", InformationItem.class);
    xStream.alias("context", Context.class);
    xStream.alias("contextEntry", ContextEntry.class);
    xStream.alias("decision", Decision.class);
    xStream.alias("decisionMade", DMNElementReference.class);
    xStream.alias("decisionMaker", DMNElementReference.class);
    xStream.alias("decisionOwned", DMNElementReference.class);
    xStream.alias("decisionOwner", DMNElementReference.class);
    xStream.alias("decisionService", DecisionService.class);
    xStream.alias("decisionTable", DecisionTable.class);
    xStream.alias("defaultOutputEntry", LiteralExpression.class);
    xStream.alias("definitions", Definitions.class);
    xStream.alias("drgElement", DMNElementReference.class);
    // xStream.alias("drgElement", DRGElement.class ); ambiguity, also referring to top-level xsd element just under xsd root.
    xStream.alias("elementCollection", ElementCollection.class);
    xStream.alias("elementCollection", ElementCollection.class);
    xStream.alias("encapsulatedDecision", DMNElementReference.class);
    xStream.alias("encapsulatedLogic", FunctionDefinition.class);
    xStream.alias("expression", Expression.class);
    xStream.alias("formalParameter", InformationItem.class);
    xStream.alias("functionDefinition", FunctionDefinition.class);
    xStream.alias("impactedPerformanceIndicator", DMNElementReference.class);
    xStream.alias("impactingDecision", DMNElementReference.class);
    xStream.alias("import", Import.class);
    xStream.alias("import", Import.class);
    // TODO where?
    xStream.alias("importedElement", String.class);
    xStream.alias("importedValues", ImportedValues.class);
    xStream.alias("informationItem", InformationItem.class);
    xStream.alias("informationRequirement", InformationRequirement.class);
    xStream.alias("input", InputClause.class);
    xStream.alias("inputData", DMNElementReference.class);
    xStream.alias("inputData", InputData.class);
    xStream.alias("inputDecision", DMNElementReference.class);
    xStream.alias("inputEntry", UnaryTests.class);
    xStream.alias("inputExpression", LiteralExpression.class);
    xStream.alias("inputValues", UnaryTests.class);
    xStream.alias("invocation", Invocation.class);
    xStream.alias("itemComponent", ItemDefinition.class);
    xStream.alias("itemDefinition", ItemDefinition.class);
    xStream.alias("itemDefinition", ItemDefinition.class);
    xStream.alias("knowledgeRequirement", KnowledgeRequirement.class);
    xStream.alias("knowledgeRequirement", KnowledgeRequirement.class);
    xStream.alias("knowledgeSource", KnowledgeSource.class);
    xStream.alias("literalExpression", LiteralExpression.class);
    xStream.alias("namedElement", NamedElement.class);
    xStream.alias("organizationUnit", OrganizationUnit.class);
    xStream.alias("output", OutputClause.class);
    xStream.alias("outputDecision", DMNElementReference.class);
    xStream.alias("outputEntry", LiteralExpression.class);
    xStream.alias("outputValues", UnaryTests.class);
    xStream.alias("owner", DMNElementReference.class);
    xStream.alias("parameter", InformationItem.class);
    xStream.alias("performanceIndicator", PerformanceIndicator.class);
    xStream.alias("relation", Relation.class);
    xStream.alias("requiredAuthority", DMNElementReference.class);
    xStream.alias("requiredDecision", DMNElementReference.class);
    xStream.alias("requiredDecision", DMNElementReference.class);
    xStream.alias("requiredInput", DMNElementReference.class);
    xStream.alias("requiredInput", DMNElementReference.class);
    xStream.alias("requiredKnowledge", DMNElementReference.class);
    xStream.alias("rule", DecisionRule.class);
    xStream.alias("sourceRef", DMNElementReference.class);
    xStream.alias("supportedObjective", DMNElementReference.class);
    xStream.alias("targetRef", DMNElementReference.class);
    xStream.alias("textAnnotation", TextAnnotation.class);
    // TODO where?
    xStream.alias("type", String.class);
    xStream.alias("typeRef", QName.class);
    xStream.alias("usingProcess", DMNElementReference.class);
    xStream.alias("usingTask", DMNElementReference.class);
    xStream.alias("variable", InformationItem.class);
    xStream.alias("variable", InformationItem.class);
    xStream.alias("variable", InformationItem.class);
    xStream.alias("variable", InformationItem.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.List.class);
    xStream.alias("list", org.kie.dmn.model.v1_1.List.class);
    xStream.alias("extensionElements", DMNElement.ExtensionElements.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;
}
Also used : DMNElement(org.kie.dmn.model.v1_1.DMNElement) XStream(com.thoughtworks.xstream.XStream) XStreamUtils.createTrustingXStream(org.kie.soup.commons.xstream.XStreamUtils.createTrustingXStream) Definitions(org.kie.dmn.model.v1_1.Definitions) DMNExtensionRegister(org.kie.dmn.api.marshalling.v1_1.DMNExtensionRegister)

Example 2 with Artifact

use of org.kie.dmn.model.v1_1.Artifact in project pravega by pravega.

the class RemoteSequential method newJob.

private Job newJob(String id, String className, String methodName) {
    Map<String, String> labels = new HashMap<>(1);
    labels.put("testMethodName", methodName);
    // This can be used to set environment variables while executing the job on Metronome.
    Map<String, String> env = new HashMap<>(2);
    env.put("masterIP", System.getProperty("masterIP"));
    env.put("env2", "value102");
    Artifact art = new Artifact();
    // It caches the artifacts, disabling it for now.
    art.setCache(false);
    // jar is not executable.
    art.setExecutable(false);
    art.setExtract(false);
    art.setUri(System.getProperty("testArtifactUrl", "InvalidTestArtifactURL"));
    Restart restart = new Restart();
    // the tests are expected to finish in 2 mins, this can be changed to
    restart.setActiveDeadlineSeconds(120);
    // a higher value if required.
    restart.setPolicy("NEVER");
    Run run = new Run();
    run.setArtifacts(Collections.singletonList(art));
    run.setCmd("docker run --rm -v $(pwd):/data " + System.getProperty("dockerImageRegistry") + "/java:8 java" + " -DmasterIP=" + LoginClient.MESOS_MASTER + " -DskipServiceInstallation=" + Utils.isSkipServiceInstallationEnabled() + " -cp /data/pravega-test-system-" + System.getProperty("testVersion") + ".jar io.pravega.test.system.SingleJUnitTestRunner " + className + "#" + methodName + " > server.log 2>&1" + "; exit $?");
    // CPU shares.
    run.setCpus(0.5);
    // amount of memory required for running test in MB.
    run.setMem(512.0);
    run.setDisk(50.0);
    run.setEnv(env);
    run.setMaxLaunchDelay(3600);
    run.setRestart(restart);
    run.setUser("root");
    Job job = new Job();
    job.setId(id);
    job.setDescription(id);
    job.setLabels(labels);
    job.setRun(run);
    return job;
}
Also used : HashMap(java.util.HashMap) Run(io.pravega.test.system.framework.metronome.model.v1.Run) Restart(io.pravega.test.system.framework.metronome.model.v1.Restart) Job(io.pravega.test.system.framework.metronome.model.v1.Job) Artifact(io.pravega.test.system.framework.metronome.model.v1.Artifact)

Example 3 with Artifact

use of org.kie.dmn.model.v1_1.Artifact in project kie-wb-common by kiegroup.

the class Bpmn2JsonMarshaller method findOutgoingAssociation.

protected Association findOutgoingAssociation(BPMNPlane plane, BaseElement baseElement) {
    Association result = _diagramAssociations.get(baseElement.getId());
    if (result != null) {
        return result;
    }
    if (!(plane.getBpmnElement() instanceof Process)) {
        throw new IllegalArgumentException("Don't know how to get associations from a non-Process Diagram");
    }
    Process process = (Process) plane.getBpmnElement();
    for (Artifact artifact : process.getArtifacts()) {
        if (artifact instanceof Association) {
            Association association = (Association) artifact;
            if (association.getSourceRef() == baseElement) {
                _diagramAssociations.put(baseElement.getId(), association);
                return association;
            }
        }
    }
    return null;
}
Also used : Association(org.eclipse.bpmn2.Association) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) Process(org.eclipse.bpmn2.Process) SubProcess(org.eclipse.bpmn2.SubProcess) Artifact(org.eclipse.bpmn2.Artifact)

Example 4 with Artifact

use of org.kie.dmn.model.v1_1.Artifact in project kie-wb-common by kiegroup.

the class Bpmn2JsonMarshaller method marshallDataObject.

protected void marshallDataObject(DataObject dataObject, BPMNPlane plane, JsonGenerator generator, float xOffset, float yOffset, Map<String, Object> flowElementProperties) throws JsonGenerationException, IOException {
    Map<String, Object> properties = new LinkedHashMap<String, Object>(flowElementProperties);
    putDocumentationProperty(dataObject, properties);
    if (dataObject.getName() != null && dataObject.getName().length() > 0) {
        properties.put(NAME, StringEscapeUtils.unescapeXml(dataObject.getName()));
    } else {
        // we need a name, use id instead
        properties.put(NAME, dataObject.getId());
    }
    // overwrite name if elementname extension element is present
    String elementName = Utils.getMetaDataValue(dataObject.getExtensionValues(), "elementname");
    if (elementName != null) {
        properties.put(NAME, elementName);
    }
    if (dataObject.getItemSubjectRef().getStructureRef() != null && dataObject.getItemSubjectRef().getStructureRef().length() > 0) {
        if (defaultTypesList.contains(dataObject.getItemSubjectRef().getStructureRef())) {
            properties.put(STANDARDTYPE, dataObject.getItemSubjectRef().getStructureRef());
        } else {
            properties.put(CUSTOMTYPE, dataObject.getItemSubjectRef().getStructureRef());
        }
    }
    Association outgoingAssociaton = findOutgoingAssociation(plane, dataObject);
    Association incomingAssociation = null;
    Process process = (Process) plane.getBpmnElement();
    for (Artifact artifact : process.getArtifacts()) {
        if (artifact instanceof Association) {
            Association association = (Association) artifact;
            if (association.getTargetRef() == dataObject) {
                incomingAssociation = association;
            }
        }
    }
    if (outgoingAssociaton != null && incomingAssociation == null) {
        properties.put(INPUT_OUTPUT, "Input");
    }
    if (outgoingAssociaton == null && incomingAssociation != null) {
        properties.put(INPUT_OUTPUT, "Output");
    }
    marshallProperties(properties, generator);
    generator.writeObjectFieldStart("stencil");
    generator.writeObjectField("id", "DataObject");
    generator.writeEndObject();
    generator.writeArrayFieldStart("childShapes");
    generator.writeEndArray();
    generator.writeArrayFieldStart("outgoing");
    List<Association> associations = findOutgoingAssociations(plane, dataObject);
    if (associations != null) {
        for (Association as : associations) {
            generator.writeStartObject();
            generator.writeObjectField("resourceId", as.getId());
            generator.writeEndObject();
        }
    }
    generator.writeEndArray();
    Bounds bounds = ((BPMNShape) findDiagramElement(plane, dataObject)).getBounds();
    generator.writeObjectFieldStart("bounds");
    generator.writeObjectFieldStart("lowerRight");
    generator.writeObjectField("x", bounds.getX() + bounds.getWidth() - xOffset);
    generator.writeObjectField("y", bounds.getY() + bounds.getHeight() - yOffset);
    generator.writeEndObject();
    generator.writeObjectFieldStart("upperLeft");
    generator.writeObjectField("x", bounds.getX() - xOffset);
    generator.writeObjectField("y", bounds.getY() - yOffset);
    generator.writeEndObject();
    generator.writeEndObject();
}
Also used : Association(org.eclipse.bpmn2.Association) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation) Bounds(org.eclipse.dd.dc.Bounds) DataObject(org.eclipse.bpmn2.DataObject) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) Process(org.eclipse.bpmn2.Process) SubProcess(org.eclipse.bpmn2.SubProcess) BPMNShape(org.eclipse.bpmn2.di.BPMNShape) Artifact(org.eclipse.bpmn2.Artifact) LinkedHashMap(java.util.LinkedHashMap)

Example 5 with Artifact

use of org.kie.dmn.model.v1_1.Artifact in project kie-wb-common by kiegroup.

the class Bpmn2JsonMarshaller method marshallProcess.

protected void marshallProcess(Process process, Definitions def, JsonGenerator generator, String preProcessingData) throws JsonGenerationException, IOException {
    BPMNPlane plane = null;
    for (BPMNDiagram d : def.getDiagrams()) {
        if (d != null) {
            BPMNPlane p = d.getPlane();
            if (p != null) {
                if (p.getBpmnElement() == process) {
                    plane = p;
                    break;
                }
            }
        }
    }
    if (plane == null) {
        throw new IllegalArgumentException("Could not find BPMNDI information");
    }
    generator.writeArrayFieldStart("childShapes");
    List<String> laneFlowElementsIds = new ArrayList<String>();
    for (LaneSet laneSet : process.getLaneSets()) {
        for (Lane lane : laneSet.getLanes()) {
            // we only want to marshall lanes if we have the bpmndi info for them!
            if (findDiagramElement(plane, lane) != null) {
                laneFlowElementsIds.addAll(marshallLanes(lane, plane, generator, 0, 0, preProcessingData, def));
            }
        }
    }
    for (FlowElement flowElement : process.getFlowElements()) {
        if (!laneFlowElementsIds.contains(flowElement.getId())) {
            marshallFlowElement(flowElement, plane, generator, 0, 0, preProcessingData, def);
        }
    }
    for (Artifact artifact : process.getArtifacts()) {
        marshallArtifact(artifact, plane, generator, 0, 0, preProcessingData, def);
    }
    generator.writeEndArray();
}
Also used : BPMNDiagram(org.eclipse.bpmn2.di.BPMNDiagram) FlowElement(org.eclipse.bpmn2.FlowElement) ArrayList(java.util.ArrayList) Lane(org.eclipse.bpmn2.Lane) LaneSet(org.eclipse.bpmn2.LaneSet) BPMNPlane(org.eclipse.bpmn2.di.BPMNPlane) Artifact(org.eclipse.bpmn2.Artifact)

Aggregations

Artifact (org.eclipse.bpmn2.Artifact)11 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)9 SubProcess (org.eclipse.bpmn2.SubProcess)9 DataInputAssociation (org.eclipse.bpmn2.DataInputAssociation)8 DataOutputAssociation (org.eclipse.bpmn2.DataOutputAssociation)8 Process (org.eclipse.bpmn2.Process)8 ArrayList (java.util.ArrayList)7 Association (org.eclipse.bpmn2.Association)7 FlowElement (org.eclipse.bpmn2.FlowElement)6 DataObject (org.eclipse.bpmn2.DataObject)5 SequenceFlow (org.eclipse.bpmn2.SequenceFlow)5 BoundaryEvent (org.eclipse.bpmn2.BoundaryEvent)4 RootElement (org.eclipse.bpmn2.RootElement)4 FlowNode (org.eclipse.bpmn2.FlowNode)3 Group (org.eclipse.bpmn2.Group)3 Lane (org.eclipse.bpmn2.Lane)3 Bounds (org.eclipse.dd.dc.Bounds)3 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)3 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2