Tabnine Logo
org.drools.core.util
Code IndexAdd Tabnine to your IDE (free)

How to use org.drools.core.util

Best Java code snippets using org.drools.core.util (Showing top 20 results out of 315)

origin: kiegroup/jbpm

@SuppressWarnings("unchecked")
public static <T> T serializeObject(T obj,
                  ClassLoader classLoader) throws IOException,
                              ClassNotFoundException {
  return (T) DroolsStreamUtils.streamIn( DroolsStreamUtils.streamOut( obj ),
                      classLoader );
}
origin: kiegroup/jbpm

private static String[] getDirectories(String path) {
  String content = null;
  try {
    content = ConfFileUtils.URLContentsToString(
      new URL(path + "/index.conf"));
  } catch (Exception e) {
    // directory has no index.conf - do nothing
  }
  if (content == null) {
    return new String[0];
  }
  return content.split("\n");
}
origin: kiegroup/jbpm

@Override
public Object transform(Object expression, Map<String, Object> parameters) {
  logger.debug("About to execute mvel expression {} with parameters {}", expression, parameters);
  return MVELSafeHelper.getEvaluator().executeExpression(expression, parameters);
}
origin: kiegroup/jbpm

@Override
public OrganizationalEntity persistOrgEntity(OrganizationalEntity orgEntity) {
  check();
  if (!StringUtils.isEmpty(orgEntity.getId())) {
    try {
      this.em.persist( orgEntity );
      if( this.pessimisticLocking ) {
        this.em.flush();
        return this.em.find(OrganizationalEntityImpl.class, orgEntity.getId(), LockModeType.PESSIMISTIC_WRITE );
      }
    } catch (EntityExistsException e) {
      throw new RuntimeException("Organizational entity already exists with " + orgEntity
          + " id, please check that there is no group and user with same id");
    }
  }
  return orgEntity;
}
origin: kiegroup/jbpm

  @Test
  public void testProcessWithBrokenItemDefinitionUri() throws Exception {
    InputStream inputBpmn = getClass().getResourceAsStream("/BPMN2-BrokenStructureRef.bpmn2");
    XmlProcessDumper dumper = XmlProcessDumperFactory.getXmlProcessDumperFactoryService().newXmlProcessDumper();
    Assert.assertNotNull(dumper);
    String processXml = new String(IoUtils.readBytesFromInputStream(inputBpmn), "UTF-8");
    Assert.assertNotNull(processXml);
    org.kie.api.definition.process.Process proc = dumper.readProcess(processXml);
    Assert.assertNotNull(proc);
    Assert.assertEquals("BrokenStructureRef", proc.getId());
  }
}
origin: kiegroup/jbpm

public void generateTemplates(final String ruleTemplate,
               final String invokerTemplate,
               final ProcessBuildContext context,
               final String className,
               final Map vars,
               final Object invokerLookup,
               final BaseDescr descrLookup) {
  TemplateRegistry registry = getRuleTemplateRegistry();
  context.getMethods().add((String)
      TemplateRuntime.execute(registry.getNamedTemplate(ruleTemplate), null, new MapVariableResolverFactory(vars), registry)
  );
  registry = getInvokerTemplateRegistry();
  final String invokerClassName = context.getPkg().getName() + "." + context.getProcessDescr().getClassName() + StringUtils.ucFirst(className) + "Invoker";
  context.getInvokers().put(invokerClassName,
      (String)TemplateRuntime.execute(registry.getNamedTemplate(invokerTemplate), null, new MapVariableResolverFactory(vars), registry)
  );
  context.addInvokerLookup(invokerClassName, invokerLookup);
  context.addDescrLookups(invokerClassName, descrLookup);
}

origin: kiegroup/jbpm

protected User addUserFromCallbackOperation(String userId, TaskContext context) {
  User user = context.getPersistenceContext().findUser(userId);
  boolean userExists = user != null;
  if (!StringUtils.isEmpty(userId) && !userExists) {
    user = TaskModelProvider.getFactory().newUser();
    ((InternalOrganizationalEntity) user).setId(userId);
    
    persistIfNotExists(user, context);
  } 
  
  return user;
}

origin: kiegroup/jbpm

@Test
public void testRuleFlow() throws Exception {
  InputStream in = this.getClass().getResourceAsStream( "/org/jbpm/integrationtests/ruleflow.rfm" );
  assertNotNull( in );
  builder.addPackage( new PackageDescr( "com.sample" ) );
  builder.addRuleFlow( new InputStreamReader( in ) );
  InternalKnowledgePackage pkg = builder.getPackage("com.sample");
  assertNotNull( pkg );
  Map<String, Process> flows = pkg.getRuleFlows();
  assertNotNull( flows );
  assertEquals( 1,
         flows.size() );
  assertTrue( flows.containsKey( "0" ) );
  Process p = (Process) flows.get( "0" );
  assertTrue( p instanceof WorkflowProcessImpl );
  //now serialization
  InternalKnowledgePackage pkg2 = (InternalKnowledgePackage) DroolsStreamUtils.streamIn( DroolsStreamUtils.streamOut( pkg ) );
  assertNotNull( pkg2 );
  flows = pkg2.getRuleFlows();
  assertNotNull( flows );
  assertEquals( 1,
         flows.size() );
  assertTrue( flows.containsKey( "0" ) );
  p = (Process) flows.get( "0" );
  assertTrue( p instanceof WorkflowProcessImpl );
}
origin: kiegroup/jbpm

private boolean evaluateCompletionCondition(String expression, Map<String, Object> tempVariables) {
  if (expression == null || expression.isEmpty()) {
    return false;
  }
  try {
    Object result = MVELSafeHelper.getEvaluator().eval(expression, new ForEachNodeInstanceResolverFactory(this, tempVariables));
    if ( !(result instanceof Boolean) ) {
      throw new RuntimeException( "Completion condition expression must return boolean values: " + result 
          + " for expression " + expression);
    }
    return ((Boolean) result).booleanValue();
    
  } catch (Throwable t) {
    t.printStackTrace();
    throw new IllegalArgumentException("Could not evaluate completion condition  " + expression);
  }
}

origin: kiegroup/jbpm

private static List<Map<String, Object>> getWorkDefinitionsForPath(String parentPath, String path, String file) {
  String content = null;
  try {
    content = ConfFileUtils.URLContentsToString(new URL(path));
  } catch (Exception e) {
origin: kiegroup/jbpm

protected void addGroupFromCallbackOperation(String groupId, TaskContext context) {
  Group group = context.getPersistenceContext().findGroup(groupId);
  boolean groupExists = group != null;
  if (!StringUtils.isEmpty(groupId) && !groupExists) {
    group = TaskModelProvider.getFactory().newGroup();
    ((InternalOrganizationalEntity) group).setId(groupId);
    persistIfNotExists(group, context);
  }    
}
origin: kiegroup/jbpm

Object variableValue = MVELSafeHelper.getEvaluator().eval(paramName, new NodeInstanceResolverFactory(this));
if (variableValue != null) {
  return variableValue;
origin: kiegroup/jbpm

private static RuntimeEnvironmentBuilder setupClasspathKmoduleBuilder( KieContainer kieContainer,
                                    String kbaseName,
                                    String ksessionName ) {
  if (StringUtils.isEmpty(kbaseName)) {
    KieBaseModel defaultKBaseModel = ((KieContainerImpl)kieContainer).getKieProject().getDefaultKieBaseModel();
    if (defaultKBaseModel != null) {
      kbaseName = defaultKBaseModel.getName();
    } else {
      kbaseName = DEFAULT_KBASE_NAME;
    }
  }
  InternalKieModule module = (InternalKieModule) ((KieContainerImpl)kieContainer).getKieModuleForKBase(kbaseName);
  if (module == null) {
    throw new IllegalStateException("Cannot find kbase with name " + kbaseName);
  }
  KieBase kbase = kieContainer.getKieBase(kbaseName);
  return getDefault()
      .knowledgeBase(kbase)
      .classLoader(kieContainer.getClassLoader())
      .registerableItemsFactory(new KModuleRegisterableItemsFactory(kieContainer, ksessionName));
}
origin: kiegroup/jbpm

protected Map<String, Object> getSourceParameters(DataAssociation association) {
  Map<String, Object> parameters = new HashMap<String, Object>();
  for (String sourceParam : association.getSources()) {
    Object parameterValue = null;
    VariableScopeInstance variableScopeInstance = (VariableScopeInstance) resolveContextInstance(VariableScope.VARIABLE_SCOPE, sourceParam);
    if (variableScopeInstance != null) {
      parameterValue = variableScopeInstance.getVariable(sourceParam);
    } else {
      try {
        parameterValue = MVELSafeHelper.getEvaluator().eval(sourceParam, new NodeInstanceResolverFactory(this));
      } catch (Throwable t) {
        logger.warn("Could not find variable scope for variable {}", sourceParam);
      }
    }
    if (parameterValue != null) {
      parameters.put(association.getTarget(), parameterValue);
    }
  }
  return parameters;
}
origin: kiegroup/jbpm

protected Map<String, Object> getSourceParameters(DataAssociation association) {
  Map<String, Object> parameters = new HashMap<String, Object>();
  for (String sourceParam : association.getSources()) {
    Object parameterValue = null;
    VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
    resolveContextInstance(VariableScope.VARIABLE_SCOPE, sourceParam);
    if (variableScopeInstance != null) {
      parameterValue = variableScopeInstance.getVariable(sourceParam);
    } else {
      try {
        parameterValue = MVELSafeHelper.getEvaluator().eval(sourceParam, new NodeInstanceResolverFactory(this));
      } catch (Throwable t) {
        logger.warn("Could not find variable scope for variable {}", sourceParam);
      }
    }
    if (parameterValue != null) {
      parameters.put(association.getTarget(), parameterValue);
    }
  }
  return parameters;
}
origin: kiegroup/jbpm

protected Map<String, Object> getSourceParameters(DataAssociation association) {
  Map<String, Object> parameters = new HashMap<String, Object>();
  for (String sourceParam : association.getSources()) {
    Object parameterValue = null;
    VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
    resolveContextInstance(VariableScope.VARIABLE_SCOPE, sourceParam);
    if (variableScopeInstance != null) {
      parameterValue = variableScopeInstance.getVariable(sourceParam);
    } else {
      try {
        parameterValue = MVELSafeHelper.getEvaluator().eval(sourceParam, new NodeInstanceResolverFactory(this));
      } catch (Throwable t) {
        logger.warn("Could not find variable scope for variable {}", sourceParam);
      }
    }
    if (parameterValue != null) {
      parameters.put(association.getTarget(), parameterValue);
    }
  }
  
  return parameters;
}

origin: kiegroup/jbpm

  public static Object eval(String str, Map<String, Object> vars) {
    ParserConfiguration pconf = new ParserConfiguration();
    pconf.addPackageImport("org.jbpm.services.task");
//        pconf.addPackageImport("org.jbpm.services.task.service");
    
    pconf.addPackageImport("org.jbpm.services.task.query");
    pconf.addPackageImport("java.util");
    
    for(String entry : getInputs().keySet()){
      pconf.addImport(entry, getInputs().get(entry));
    }
    ParserContext context = new ParserContext(pconf);
    Serializable s = MVEL.compileExpression(str.trim(), context);

    if( vars != null ) { 
    return MVELSafeHelper.getEvaluator().executeExpression(s, vars);
  }
    else { 
      return MVELSafeHelper.getEvaluator().executeExpression(s);
    }
  }
  public static String toString(Reader reader) throws IOException {
origin: kiegroup/jbpm

public static Object eval(String str, Map<String, Object> vars) {
  ParserConfiguration pconf = new ParserConfiguration();
  pconf.addPackageImport("org.kie.internal.task.api.model");
  pconf.addPackageImport("org.jbpm.services.task");
  pconf.addPackageImport("org.jbpm.services.task.impl.model");
  pconf.addPackageImport("org.jbpm.services.task.query");
  pconf.addPackageImport("org.jbpm.services.task.internals.lifecycle");
  pconf.addImport(Status.class);
  pconf.addImport(Allowed.class);
  pconf.addPackageImport("java.util");
  ParserContext context = new ParserContext(pconf);
  Serializable s = MVEL.compileExpression(str.trim(), context);
  if (vars != null) {
    return MVELSafeHelper.getEvaluator().executeExpression(s, vars);
  } else {
    return MVELSafeHelper.getEvaluator().executeExpression(s);
  }
}
origin: kiegroup/jbpm

public Object eval(String str, Map vars) {
  ParserContext context = new ParserContext();
  context.addPackageImport("org.jbpm.task");
  context.addPackageImport("org.jbpm.task.service");
  context.addPackageImport("org.jbpm.task.query");
  context.addPackageImport("java.util");
  vars.put("now", new Date());
  return MVELSafeHelper.getEvaluator().executeExpression(MVEL.compileExpression(str, context),
      vars);
}

origin: kiegroup/jbpm

MVELSafeHelper.getEvaluator().executeExpression( this.expr,
            null,
            factory );
org.drools.core.util

Most used classes

  • StringUtils
    Ripped form commons StringUtil, unless specified:Operations on java.lang.String that arenull safe.
  • DroolsStreamUtils
    Created by IntelliJ IDEA. User: sg0521861 Date: Mar 27, 2008 Time: 8:56:14 AM Provide Drools specifi
  • IoUtils
  • DateUtils
  • FileManager
  • ClassFieldInspector,
  • ClassUtils,
  • Iterator,
  • LinkedList,
  • ObjectHashMap,
  • Entry,
  • FastIterator,
  • KeyStoreHelper,
  • LinkedListEntry,
  • LinkedListNode,
  • ObjectHashMap$ObjectEntry,
  • Triple,
  • TripleStore,
  • TupleList
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now