Tabnine Logo
Declaration.getValue
Code IndexAdd Tabnine to your IDE (free)

How to use
getValue
method
in
org.drools.core.rule.Declaration

Best Java code snippets using org.drools.core.rule.Declaration.getValue (Showing top 6 results out of 315)

origin: kiegroup/jbpm

protected boolean checkProcessInstance(Activation activation) {
  final Map<?, ?> declarations = activation.getSubRule().getOuterDeclarations();
  for ( Iterator<?> it = declarations.values().iterator(); it.hasNext(); ) {
    Declaration declaration = (Declaration) it.next();
    if ("processInstance".equals(declaration.getIdentifier())
        || "org.kie.api.runtime.process.WorkflowProcessInstance".equals(declaration.getTypeName())) {
      Object value = declaration.getValue(
        ((StatefulKnowledgeSessionImpl) getProcessInstance().getKnowledgeRuntime()).getInternalWorkingMemory(),
        ((InternalFactHandle) activation.getTuple().get(declaration)).getObject());
      if (value instanceof ProcessInstance) {
        return ((ProcessInstance) value).getId() == getProcessInstance().getId();
      }
    }
  }
  return true;
}

origin: org.drools/drools-core

@Test
public void testGetFieldValue() {
  final InternalReadAccessor extractor = store.getReader( Cheese.class,
                              "type" );
  final Pattern pattern = new Pattern( 5,
                     new ClassObjectType( Cheese.class ) );
  // Bind the extractor to a decleration 
  // Declarations know the pattern they derive their value from 
  final Declaration declaration = new Declaration( "typeOfCheese",
                           extractor,
                           pattern );
  // Create some facts
  final Cheese cheddar = new Cheese( "cheddar",
                    5 );
  // Check we can extract Declarations correctly
  assertEquals( "cheddar",
         declaration.getValue( null,
                    cheddar ) );
}
origin: org.drools/drools-core

@Test
public void testDeclarationsObjectType() throws Exception {
  final ObjectType type = new ClassObjectType( Cheese.class );
  final Pattern col = new Pattern( 0,
                  type,
                  "foo" );
  final Declaration dec = col.getDeclaration();
  final InternalReadAccessor ext = dec.getExtractor();
  assertEquals( Cheese.class,
         ext.getExtractToClass() );
  final Cheese stilton = new Cheese( "stilton",
                    42 );
  assertEquals( stilton,
         dec.getValue( null, stilton ) );
}
origin: org.drools/drools-core

declaration.getValue( null, brie ) );
origin: org.drools/drools-core

@Test
public void testDeclarationsFactTemplate() throws Exception {
  InternalKnowledgePackage pkg = new KnowledgePackageImpl( "org.store" );
  final FieldTemplate cheeseName = new FieldTemplateImpl( "name",
                              0,
                              String.class );
  final FieldTemplate cheesePrice = new FieldTemplateImpl( "price",
                               1,
                               Integer.class );
  final FieldTemplate[] fields = new FieldTemplate[]{cheeseName, cheesePrice};
  final FactTemplate cheese = new FactTemplateImpl( pkg,
                           "Cheese",
                           fields );
  final ObjectType type = new FactTemplateObjectType( cheese );
  final Pattern col = new Pattern( 0,
                  type,
                  "foo" );
  final Declaration dec = col.getDeclaration();
  final InternalReadAccessor ext = dec.getExtractor();
  assertEquals( Fact.class,
         ext.getExtractToClass() );
  final Fact stilton = cheese.createFact( 10 );
  stilton.setFieldValue( "name",
              "stilton" );
  stilton.setFieldValue( "price",
              new Integer( 200 ) );
  assertEquals( stilton,
         dec.getValue( null, stilton ) );
}
origin: org.jbpm/jbpm-flow

protected boolean checkProcessInstance(Activation activation) {
  final Map<?, ?> declarations = activation.getSubRule().getOuterDeclarations();
  for ( Iterator<?> it = declarations.values().iterator(); it.hasNext(); ) {
    Declaration declaration = (Declaration) it.next();
    if ("processInstance".equals(declaration.getIdentifier())
        || "org.kie.api.runtime.process.WorkflowProcessInstance".equals(declaration.getTypeName())) {
      Object value = declaration.getValue(
        ((StatefulKnowledgeSessionImpl) getProcessInstance().getKnowledgeRuntime()).getInternalWorkingMemory(),
        ((InternalFactHandle) activation.getTuple().get(declaration)).getObject());
      if (value instanceof ProcessInstance) {
        return ((ProcessInstance) value).getId() == getProcessInstance().getId();
      }
    }
  }
  return true;
}

org.drools.core.ruleDeclarationgetValue

Popular methods of Declaration

  • <init>
  • getIdentifier
  • getDeclarationClass
  • getExtractor
  • getIntValue
  • getPattern
  • getTypeName

Popular in Java

  • Reading from database using SQL prepared statement
  • scheduleAtFixedRate (ScheduledExecutorService)
  • startActivity (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • JList (javax.swing)
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Top PhpStorm plugins
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