Search in sources :

Example 1 with WorkDefinitionImpl

use of org.jbpm.process.workitem.WorkDefinitionImpl in project kie-wb-common by kiegroup.

the class WorkItemDefinitionParser method parseJBPMWorkItemDefinitions.

@SuppressWarnings("unchecked")
private static Map<String, WorkDefinitionImpl> parseJBPMWorkItemDefinitions(final String content, final Function<String, String> dataUriProvider) throws Exception {
    final List<Map<String, Object>> workDefinitionsMaps = (List<Map<String, Object>>) WidMVELEvaluator.eval(content);
    final Map<String, WorkDefinitionImpl> result = new HashMap<>(workDefinitionsMaps.size());
    for (Map<String, Object> workDefinitionMap : workDefinitionsMaps) {
        if (workDefinitionMap != null) {
            String origWidName = ((String) workDefinitionMap.get("name")).replaceAll("\\s", "");
            Matcher widNameMatcher = UNICODE_WORDS_PATTERN.matcher(origWidName);
            if (widNameMatcher.matches()) {
                final WorkDefinitionImpl workDefinition = parseMVELWorkItemDefinition(workDefinitionMap, dataUriProvider, widNameMatcher.group());
                result.put(workDefinition.getName(), workDefinition);
            } else {
                LOG.error("The work item has an invalid name [ " + workDefinitionMap.get("name") + "]." + "It must contain words only, skipping it.");
            }
        }
    }
    return result;
}
Also used : WorkDefinitionImpl(org.jbpm.process.workitem.WorkDefinitionImpl) HashMap(java.util.HashMap) Matcher(java.util.regex.Matcher) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with WorkDefinitionImpl

use of org.jbpm.process.workitem.WorkDefinitionImpl in project jbpm-work-items by kiegroup.

the class JavaHandlerWorkitemIntegrationTest method testWorkitemValidity.

@Test
public void testWorkitemValidity() {
    String repoPath = "file://" + System.getProperty("builddir") + "/" + System.getProperty("artifactId") + "-" + System.getProperty("version") + "/repository";
    Map<String, WorkDefinitionImpl> repoResults = new WorkItemRepository().getWorkDefinitions(repoPath, null, System.getProperty("artifactId"));
    assertNotNull(repoResults);
    assertEquals(2, repoResults.size());
    assertTrue(repoResults.containsKey("Java"));
    assertTrue(repoResults.containsKey("JavaInvocation"));
}
Also used : WorkDefinitionImpl(org.jbpm.process.workitem.WorkDefinitionImpl) WorkItemRepository(org.jbpm.process.workitem.WorkItemRepository) Test(org.junit.Test)

Example 3 with WorkDefinitionImpl

use of org.jbpm.process.workitem.WorkDefinitionImpl in project jbpm-work-items by kiegroup.

the class JiraWorkitemIntegrationTest method testWorkitemValidity.

@Test
public void testWorkitemValidity() {
    String repoPath = "file://" + System.getProperty("builddir") + "/" + System.getProperty("artifactId") + "-" + System.getProperty("version") + "/repository";
    Map<String, WorkDefinitionImpl> repoResults = new WorkItemRepository().getWorkDefinitions(repoPath, null, System.getProperty("artifactId"));
    assertNotNull(repoResults);
    assertEquals(4, repoResults.size());
    assertTrue(repoResults.containsKey("JiraAddComment"));
    assertTrue(repoResults.containsKey("JiraCreateIssue"));
    assertTrue(repoResults.containsKey("JiraJqlSearch"));
    assertTrue(repoResults.containsKey("JiraResolveIssue"));
}
Also used : WorkDefinitionImpl(org.jbpm.process.workitem.WorkDefinitionImpl) WorkItemRepository(org.jbpm.process.workitem.WorkItemRepository) Test(org.junit.Test)

Example 4 with WorkDefinitionImpl

use of org.jbpm.process.workitem.WorkDefinitionImpl in project jbpm-work-items by kiegroup.

the class ParserWorkitemIntegrationTest method testWorkitemValidity.

@Test
public void testWorkitemValidity() {
    String repoPath = "file://" + System.getProperty("builddir") + "/" + System.getProperty("artifactId") + "-" + System.getProperty("version") + "/repository";
    Map<String, WorkDefinitionImpl> repoResults = new WorkItemRepository().getWorkDefinitions(repoPath, null, System.getProperty("artifactId"));
    assertNotNull(repoResults);
    assertEquals(1, repoResults.size());
    assertTrue(repoResults.containsKey("Parser"));
}
Also used : WorkDefinitionImpl(org.jbpm.process.workitem.WorkDefinitionImpl) WorkItemRepository(org.jbpm.process.workitem.WorkItemRepository) Test(org.junit.Test)

Example 5 with WorkDefinitionImpl

use of org.jbpm.process.workitem.WorkDefinitionImpl in project jbpm-work-items by kiegroup.

the class TwitterWorkitemIntegrationTest method testWorkitemValidity.

@Test
public void testWorkitemValidity() {
    String repoPath = "file://" + System.getProperty("builddir") + "/" + System.getProperty("artifactId") + "-" + System.getProperty("version") + "/repository";
    Map<String, WorkDefinitionImpl> repoResults = new WorkItemRepository().getWorkDefinitions(repoPath, null, System.getProperty("artifactId"));
    assertNotNull(repoResults);
    assertEquals(2, repoResults.size());
    assertTrue(repoResults.containsKey("TwitterUpdateStatus"));
    assertTrue(repoResults.containsKey("TwitterSendDirectMessage"));
}
Also used : WorkDefinitionImpl(org.jbpm.process.workitem.WorkDefinitionImpl) WorkItemRepository(org.jbpm.process.workitem.WorkItemRepository) Test(org.junit.Test)

Aggregations

WorkDefinitionImpl (org.jbpm.process.workitem.WorkDefinitionImpl)27 Test (org.junit.Test)23 WorkItemRepository (org.jbpm.process.workitem.WorkItemRepository)21 HashMap (java.util.HashMap)4 Map (java.util.Map)4 WorkDefinition (org.jbpm.process.core.WorkDefinition)3 HashSet (java.util.HashSet)2 List (java.util.List)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 PortableWorkDefinition (org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition)1 ParameterDefinition (org.jbpm.process.core.ParameterDefinition)1 DataType (org.jbpm.process.core.datatype.DataType)1 ParameterDefinitionImpl (org.jbpm.process.core.impl.ParameterDefinitionImpl)1 ParserContext (org.mvel2.ParserContext)1 Path (org.uberfire.backend.vfs.Path)1 FileAlreadyExistsException (org.uberfire.java.nio.file.FileAlreadyExistsException)1