congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
Declaration
Code IndexAdd Tabnine to your IDE (free)

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

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

Refine searchRefine arrow

  • InternalFactHandle
  • Operator
  • RuleImpl
  • InternalKnowledgePackage
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

public boolean evaluate(InternalFactHandle handle,
            Tuple tuple,
            Declaration[] previousDeclarations,
            Declaration[] localDeclarations,
            WorkingMemory workingMemory,
            Object context) {
  int price1 = previousDeclarations[0].getIntValue( (InternalWorkingMemory) workingMemory,
                           tuple.getObject( previousDeclarations[0] ) );
  int price2 = localDeclarations[0].getIntValue( (InternalWorkingMemory) workingMemory,
                          handle.getObject() );
  return (price2 == (price1 * 2));
}
origin: org.drools/drools-compiler

DialectCompiletimeRegistry dialectRegistry = pkgBuilder.getPackageRegistry( pkg.getName() ).getDialectCompiletimeRegistry();
MVELDialect mvelDialect = (MVELDialect) dialectRegistry.getDialect( "mvel" );
final Declaration declaration = new Declaration( "p",
                         extractor,
                         pattern );
((MVELSalienceExpression) context.getRule().getSalience()).compile( (MVELDialectRuntimeData) context.getPkg().getDialectRuntimeRegistry().getDialectData( "mvel" ) );
origin: org.drools/drools-core

protected BetaNodeFieldConstraint getConstraint(String identifier,
                        Operator operator,
                        String fieldName,
                        Class clazz) {
  ClassFieldAccessorStore store = new ClassFieldAccessorStore();
  store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) );
  store.setEagerWire( true );
  InternalReadAccessor extractor = store.getReader( clazz,
                           fieldName );
  Declaration declaration = new Declaration( identifier,
                        extractor,
                        new Pattern( 0,
                              new ClassObjectType( clazz ) ) );
  String expression = fieldName + " " + operator.getOperatorString() + " " + declaration.getIdentifier();
  return new MvelConstraintTestUtil(expression, declaration, extractor);
}
origin: org.drools/drools-compiler

final Declaration[] declarations = new Declaration[]{new Declaration( "name",
                                   null,
                                   null ), new Declaration( "age",
                                                null,
                                                null )};
final Declaration[] inner = new Declaration[]{new Declaration( "cheese",
                                new PatternExtractor( new ClassObjectType( Cheese.class ) ),
                                null ), new Declaration( "price",
                                            store.getReader( Cheese.class,
                                                     "price" ),
origin: org.drools/drools-core

@Test
public void testDeclaration() {
  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 );
  assertEquals( "typeOfCheese",
         declaration.getIdentifier() );
  assertSame( String.class,
        declaration.getDeclarationClass() );
  assertSame( extractor,
        declaration.getExtractor() );
  assertEquals( 5,
         declaration.getPattern().getOffset() );
}
origin: org.drools/drools-compiler

PackageRegistry pkgRegistry = pkgBuilder.getPackageRegistry( pkg.getName() );
DialectCompiletimeRegistry dialectRegistry = pkgBuilder.getPackageRegistry( pkg.getName() ).getDialectCompiletimeRegistry();
MVELDialect mvelDialect = (MVELDialect) dialectRegistry.getDialect( pkgRegistry.getDialect() );
final Declaration declaration = new Declaration( "cheese",
                         extractor,
                         pattern );
kbHelper.setActivation( item );
try {
  ((MVELConsequence) context.getRule().getConsequence()).compile( (MVELDialectRuntimeData) pkgBuilder.getPackageRegistry( pkg.getName() ).getDialectRuntimeRegistry().getDialectData( "mvel" ) );
  context.getRule().getConsequence().evaluate( kbHelper,
                         ksession );
  fail( "should throw an exception, as 'if' is not allowed" );
origin: org.drools/drools-compiler

DialectCompiletimeRegistry dialectRegistry = pkgBuilder.getPackageRegistry( pkg.getName() ).getDialectCompiletimeRegistry();
MVELDialect mvelDialect = ( MVELDialect ) dialectRegistry.getDialect( "mvel" );
final Declaration declaration = new Declaration( "a",
                         extractor,
                         pattern );
final EvalCondition eval = (EvalCondition) builder.build( context,
                             evalDescr );
((MVELEvalExpression) eval.getEvalExpression()).compile( (MVELDialectRuntimeData) pkgBuilder.getPackageRegistry( pkg.getName() ).getDialectRuntimeRegistry().getDialectData( "mvel" ) );
f0.removeLeftTuple(tuple);
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

protected BetaNodeFieldConstraint getConstraint(String identifier,
                        Operator operator,
                        String fieldName,
                        Class clazz) {
  ClassFieldAccessorStore store = new ClassFieldAccessorStore();
  store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) );
  store.setEagerWire( true );
  InternalReadAccessor extractor = store.getReader( clazz,
                           fieldName );
  Declaration declaration = new Declaration( identifier,
                        extractor,
                        new Pattern( 0,
                              new ClassObjectType( clazz ) ) );
  String expression = fieldName + " " + operator.getOperatorString() + " " + identifier;
  return new MvelConstraintTestUtil(expression, operator.getOperatorString(), declaration, extractor);
}
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-compiler

public BetaNodeFieldConstraint getBoundVariableConstraint(final Class clazz,
                             final String fieldName,
                             final Declaration declaration,
                             final String evaluatorString) {
  final InternalReadAccessor extractor = store.getReader(clazz,
                              fieldName);
  String expression = fieldName + " " + evaluatorString + " " + declaration.getIdentifier();
  return new MvelConstraintTestUtil(expression, declaration, extractor);
}
origin: org.drools/drools-core

protected BetaNodeFieldConstraint getConstraint(String identifier,
                        Operator operator,
                        String fieldName,
                        Class clazz) {
  ClassFieldAccessorStore store = new ClassFieldAccessorStore();
  store.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) );
  store.setEagerWire( true );
  InternalReadAccessor extractor = store.getReader( clazz,
                           fieldName );
  Declaration declaration = new Declaration( identifier,
                        extractor,
                        new Pattern( 0,
                              new ClassObjectType( clazz ) ) );
  String expression = fieldName + " " + operator.getOperatorString() + " " + declaration.getIdentifier();
  return new MvelConstraintTestUtil(expression, declaration, extractor);
}

origin: org.drools/drools-compiler

final Declaration[] declarations = new Declaration[]{new Declaration( "name",
                                   store.getReader( Person.class,
                                            "name" ),
                                   null ), new Declaration( "age",
                                                store.getReader( Person.class,
                                                        "age" ),
                                                null )};
final Declaration[] inner = new Declaration[]{new Declaration( "cheese",
                                new PatternExtractor( new ClassObjectType( Cheese.class ) ),
                                null ), new Declaration( "price",
                                            store.getReader( Cheese.class,
                                                     "price" ),
origin: org.drools/drools-core

                 new FactTemplateObjectType( cheese ) );
final Declaration declaration = new Declaration( "typeOfCheese",
                         extractName,
                         pattern );
       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;
}

origin: org.drools/drools-compiler

final Declaration[] declarations = new Declaration[]{new Declaration( "name",
                                   store.getReader( Person.class,
                                            "name" ),
                                   null ), new Declaration( "age",
                                                store.getReader( Person.class,
                                                        "age" ),
                                                null )};
final Declaration[] inner = new Declaration[]{new Declaration( "$cheese",
                                new PatternExtractor( new ClassObjectType( Cheese.class ) ),
                                null ), new Declaration( "$person",
                                            new PatternExtractor( new ClassObjectType( Person.class ) ),
                                            null )};
origin: org.drools/drools-core

                     final Object[] row,
                     final boolean left) {
final Declaration declaration = new Declaration( "test",
                         extractor,
                         null );
origin: org.drools/drools-core

                       new Declaration("id", extractor, null) ,
                       MvelConstraint.INDEX_EVALUATOR );
final SingleIndex singleIndex = new SingleIndex( new FieldIndex[]{fieldIndex},
org.drools.core.ruleDeclaration

Most used methods

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

Popular in Java

  • Creating JSON documents from java classes using gson
  • putExtra (Intent)
  • compareTo (BigDecimal)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Kernel (java.awt.image)
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • PhpStorm for WordPress
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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