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; }
MVELDialectRuntimeData data = ( MVELDialectRuntimeData ) ((KnowledgePackageImpl) pkg).getDialectRuntimeRegistry().getDialectData( id ); factory.setNextFactory( data.getFunctionFactory() );
.getDialectRuntimeRegistry().getDialectData(javaDialect.getId()); data.putInvoker(className, (Wireable) invoker);
@Test public void testAddSingleBranchAnd() { final GroupElement and1 = GroupElementFactory.newAndInstance(); final Pattern pattern = new Pattern( 0, null ); and1.addChild( pattern ); assertEquals( 1, and1.getChildren().size() ); assertSame( pattern, and1.getChildren().get( 0 ) ); final GroupElement or1 = GroupElementFactory.newOrInstance(); or1.addChild( and1 ); or1.pack(); assertEquals( 1, or1.getChildren().size() ); assertSame( pattern, or1.getChildren().get( 0 ) ); }
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); }
@Test public void testPackNestedExists() { final GroupElement exists1 = GroupElementFactory.newExistsInstance(); final Pattern pattern1 = new Pattern( 0, null ); exists1.addChild( pattern1 ); assertEquals( 1, exists1.getChildren().size() ); assertSame( pattern1, exists1.getChildren().get( 0 ) ); final GroupElement exists2 = GroupElementFactory.newExistsInstance(); exists2.addChild( exists1 ); exists2.pack(); assertEquals( 1, exists2.getChildren().size() ); assertSame( pattern1, exists2.getChildren().get( 0 ) ); }
wm.setGlobal( "list", list ); MVELDialectRuntimeData data = (MVELDialectRuntimeData) pkgBuilder.getPackage("pkg1").getDialectRuntimeRegistry().getDialectData( "mvel");
MVELDialectRuntimeData data = (MVELDialectRuntimeData) context.getPkg().getDialectRuntimeRegistry().getDialectData( dialect.getId() ); data.addCompileable( constraintNode, expr );
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); }
@Test public void testAddMultipleChildsIntoNot() { final GroupElement not = GroupElementFactory.newNotInstance(); final Pattern pattern1 = new Pattern( 0, null ); try { not.addChild( pattern1 ); } catch ( final RuntimeException rde ) { fail( "Adding a single child is not supposed to throw Exception for NOT GE: " + rde.getMessage() ); } final Pattern pattern2 = new Pattern( 0, null ); try { not.addChild( pattern2 ); fail( "Adding a second child into a NOT GE should throw Exception" ); } catch ( final RuntimeException rde ) { // everything is fine } }
public AlphaNodeFieldConstraint getLiteralConstraint(final Pattern pattern, final String fieldName, final String evaluatorString, final String value) { final Class<?> clazz = ((ClassObjectType) pattern.getObjectType()).getClassType(); final InternalReadAccessor extractor = store.getReader(clazz, fieldName); FieldValue fieldValue = FieldFactory.getInstance().getFieldValue(value, extractor.getValueType()); return new MvelConstraintTestUtil(fieldName + evaluatorString + value, fieldValue, extractor); }
@Before public void setUp() throws Exception { data = new JavaDialectRuntimeData(); }
pkgRegistry.getDialectRuntimeRegistry().onBeforeExecute();
private PredicateConstraint getPredicateConstraint(Pattern pattern) { for (Constraint constraint : pattern.getConstraints()) { if (constraint instanceof PredicateConstraint) return (PredicateConstraint)constraint; } return null; }
public MvelConstraintTestUtil(String expression, FieldValue fieldValue, InternalReadAccessor extractor) { super(null, expression, null, findConstraintTypeForExpression(expression), fieldValue, extractor, null); }
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)); }
@Test public void testAddSingleBranchOr() { final GroupElement or1 = GroupElementFactory.newOrInstance(); final Pattern pattern = new Pattern( 0, null ); or1.addChild( pattern ); assertEquals( 1, or1.getChildren().size() ); assertSame( pattern, or1.getChildren().get( 0 ) ); final GroupElement and1 = GroupElementFactory.newAndInstance(); and1.addChild( or1 ); and1.pack(); assertEquals( 1, and1.getChildren().size() ); assertSame( pattern, and1.getChildren().get( 0 ) ); }
wm.setGlobal( "list", list ); MVELDialectRuntimeData data = (MVELDialectRuntimeData) pkgBuilder.getPackage("pkg1").getDialectRuntimeRegistry().getDialectData( "mvel");
= (MVELDialectRuntimeData) context.getPkg().getDialectRuntimeRegistry().getDialectData( dialect.getId() ); data.addCompileable( action, expr );
splitInstance.setProcessInstance( processInstance ); MVELDialectRuntimeData data = (MVELDialectRuntimeData) pkgBuilder.getPackage("pkg1").getDialectRuntimeRegistry().getDialectData( "mvel");