Java Code Examples for org.flowable.bpmn.model.BpmnModel#getArtifact()

The following examples show how to use org.flowable.bpmn.model.BpmnModel#getArtifact() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractBpmnParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected void createAssociation(BpmnParse bpmnParse, Association association) {
    BpmnModel bpmnModel = bpmnParse.getBpmnModel();
    if (bpmnModel.getArtifact(association.getSourceRef()) != null || bpmnModel.getArtifact(association.getTargetRef()) != null) {

        // connected to a text annotation so skipping it
    }

    // ActivityImpl sourceActivity =
    // parentScope.findActivity(association.getSourceRef());
    // ActivityImpl targetActivity =
    // parentScope.findActivity(association.getTargetRef());

    // an association may reference elements that are not parsed as
    // activities (like for instance
    // text annotations so do not throw an exception if sourceActivity or
    // targetActivity are null)
    // However, we make sure they reference 'something':
    // if (sourceActivity == null) {
    // bpmnModel.addProblem("Invalid reference sourceRef '" +
    // association.getSourceRef() + "' of association element ",
    // association.getId());
    // } else if (targetActivity == null) {
    // bpmnModel.addProblem("Invalid reference targetRef '" +
    // association.getTargetRef() + "' of association element ",
    // association.getId());
    /*
     * } else { if (sourceActivity.getProperty("type").equals("compensationBoundaryCatch" )) { Object isForCompensation = targetActivity.getProperty(PROPERTYNAME_IS_FOR_COMPENSATION); if
     * (isForCompensation == null || !(Boolean) isForCompensation) { LOGGER.warn( "compensation boundary catch must be connected to element with isForCompensation=true" ); } else { ActivityImpl
     * compensatedActivity = sourceActivity.getParentActivity(); compensatedActivity.setProperty(BpmnParse .PROPERTYNAME_COMPENSATION_HANDLER_ID, targetActivity.getId()); } } }
     */
}
 
Example 2
Source File: AbstractBpmnParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected void createAssociation(BpmnParse bpmnParse, Association association, ScopeImpl parentScope) {
    BpmnModel bpmnModel = bpmnParse.getBpmnModel();
    if (bpmnModel.getArtifact(association.getSourceRef()) != null ||
            bpmnModel.getArtifact(association.getTargetRef()) != null) {

        // connected to a text annotation so skipping it
        return;
    }

    ActivityImpl sourceActivity = parentScope.findActivity(association.getSourceRef());
    ActivityImpl targetActivity = parentScope.findActivity(association.getTargetRef());

    // an association may reference elements that are not parsed as activities (like for instance
    // text annotations so do not throw an exception if sourceActivity or targetActivity are null)
    // However, we make sure they reference 'something':
    if (sourceActivity == null) {
        // bpmnModel.addProblem("Invalid reference sourceRef '" + association.getSourceRef() + "' of association element ", association.getId());
    } else if (targetActivity == null) {
        // bpmnModel.addProblem("Invalid reference targetRef '" + association.getTargetRef() + "' of association element ", association.getId());
    } else {
        if (sourceActivity.getProperty("type").equals("compensationBoundaryCatch")) {
            Object isForCompensation = targetActivity.getProperty(PROPERTYNAME_IS_FOR_COMPENSATION);
            if (isForCompensation == null || !(Boolean) isForCompensation) {
                LOGGER.warn("compensation boundary catch must be connected to element with isForCompensation=true");
            } else {
                ActivityImpl compensatedActivity = sourceActivity.getParentActivity();
                compensatedActivity.setProperty(BpmnParse.PROPERTYNAME_COMPENSATION_HANDLER_ID, targetActivity.getId());
            }
        }
    }
}