Search in sources :

Example 1 with ActivityDefinition

use of org.apache.camel.bam.model.ActivityDefinition in project camel by apache.

the class ProcessBuilder method findOrCreateActivityDefinition.

// Implementation methods
// -------------------------------------------------------------------------
public ActivityDefinition findOrCreateActivityDefinition(String activityName) {
    ProcessDefinition definition = getProcessDefinition();
    Map<String, Object> params = new HashMap<String, Object>(2);
    params.put("definition", definition);
    params.put("name", activityName);
    List<ActivityDefinition> list = entityManagerTemplate.find(ActivityDefinition.class, "select x from " + QueryUtils.getTypeName(ActivityDefinition.class) + " x where x.processDefinition = :definition and x.name = :name", params);
    if (!list.isEmpty()) {
        return list.get(0);
    } else {
        ActivityDefinition answer = new ActivityDefinition();
        answer.setName(activityName);
        answer.setProcessDefinition(ProcessDefinition.getRefreshedProcessDefinition(entityManagerTemplate, definition));
        entityManagerTemplate.persist(answer);
        return answer;
    }
}
Also used : HashMap(java.util.HashMap) ProcessDefinition(org.apache.camel.bam.model.ProcessDefinition) ActivityDefinition(org.apache.camel.bam.model.ActivityDefinition)

Aggregations

HashMap (java.util.HashMap)1 ActivityDefinition (org.apache.camel.bam.model.ActivityDefinition)1 ProcessDefinition (org.apache.camel.bam.model.ProcessDefinition)1