Examples of Variable


Examples of org.drools.beliefs.bayes.model.Variable

        assertEquals( "package = org.drools.beliefs.bayes.integration", network.getProperties().get(0) );

        Map<String, Variable> varMap = varToMap( network.getVariables() );
        assertEquals(4, varMap.size());

        Variable var = varMap.get("WetGrass");
        assertEquals("WetGrass", var.getName());
        assertEquals(2, var.getOutComes().size());
        assertEquals(var.getOutComes(), Arrays.asList(new String[]{"false", "true"}));
        assertEquals("position = (0,10)", var.getProperties().get(0));

        var = varMap.get("Cloudy");
        assertEquals( "Cloudy", var.getName());
        assertEquals(2, var.getOutComes().size());
        assertEquals(var.getOutComes(), Arrays.asList(new String[]{"false", "true"}));
        assertEquals( "position = (0,-10)", var.getProperties().get(0) );

        var = varMap.get("Sprinkler");
        assertEquals( "Sprinkler", var.getName());
        assertEquals( 2, var.getOutComes().size() );
        assertEquals(var.getOutComes(), Arrays.asList(new String[]{"false", "true"}));
        assertEquals("position = (13,0)", var.getProperties().get(0) );

        var = varMap.get("Rain");
        assertEquals( "Rain", var.getName());
        assertEquals( 2, var.getOutComes().size() );
        assertEquals(var.getOutComes(), Arrays.asList(new String[]{"false", "true"}));
        assertEquals("position = (-12,0)", var.getProperties().get(0) );

        Map<String, Definition> defMap = defToMap( network.getDefinitions() );
        assertEquals( 4, defMap.size() );

        Definition def = defMap.get( "WetGrass");
View Full Code Here

Examples of org.drools.decisiontable.model.Variable

    public void testListVariables()
    {
        List varList = RuleSheetParserUtil.getVariableList("Var1 var1, Var2 var2,Var3 var3");
        assertNotNull(varList);
        assertEquals(3, varList.size());
        Variable var = (Variable) varList.get(0);
        assertEquals("Var1", var.getClassName());
        var = (Variable) varList.get(2);
        assertEquals("Var3", var.getClassName());
        assertEquals("var3", var.getIdentifier());
    }
View Full Code Here

Examples of org.drools.rule.Variable

            Object tupleObject = leftTuple.get( declr ).getObject();

            if ( tupleObject instanceof DroolsQuery ) {
                ArrayElementReader reader = (ArrayElementReader) declr.getExtractor();
                DroolsQuery q = (DroolsQuery) tupleObject;
                Variable v = q.getVariables()[reader.getIndex()];

                // is that parameter an output Variable
                if ( v != null ) {
                    if ( !v.isSet() ) {
                        // it's not set yet, so we need to pass back any unified values

                        // If the declaration resolves to a variable being passed in, we need to add that to the variable indexes, so it's copied
                        if ( srcVarIndexes == null ) {
                            srcVarIndexes = new ArrayList<Integer>();
                            trgVars = new ArrayList<Variable>();
                        }
                        trgVars.add( v ); // this needs to be here, so we can pass the value back
                        srcVarIndexes.add( declIndexes[i] );

                        args[declIndexes[i]] = Variable.variable;
                        continue;
                    }
                }
            }

            Object o = declr.getValue( workingMemory,
                                       tupleObject );

            args[declIndexes[i]] = o;
        }

        int[] varIndexes = this.queryElement.getVariableIndexes();
        if ( srcVarIndexes != null ) {
            // we have Variable inputs to handle           
            // now merge the two, by adding new onto the end of the old
            int length = varIndexes.length;
            varIndexes = new int[varIndexes.length + srcVarIndexes.size()];
            System.arraycopy( this.queryElement.getVariableIndexes(),
                              0,
                              varIndexes,
                              0,
                              length );
            for ( int i = 0; i < srcVarIndexes.size(); i++ ) {
                varIndexes[i + length] = srcVarIndexes.get( i );
            }
        }

        UnificationNodeViewChangedEventListener collector = new UnificationNodeViewChangedEventListener( leftTuple,
                                                                                                         varIndexes,
                                                                                                         this.sink,
                                                                                                         this.tupleMemoryEnabled );

        DroolsQuery queryObject = new DroolsQuery( this.queryElement.getQueryName(),
                                                   args,
                                                   collector,
                                                   false );
       
        collector.setDroolsQuery( queryObject );       

        InternalFactHandle handle = workingMemory.getFactHandleFactory().newFactHandle( queryObject,
                                                                                        workingMemory.getObjectTypeConfigurationRegistry().getObjectTypeConf( EntryPoint.DEFAULT,
                                                                                                                                                              queryObject ),
                                                                                        workingMemory,
                                                                                        null );

        workingMemory.insert( handle,
                              queryObject,
                              null,
                              null,
                              workingMemory.getObjectTypeConfigurationRegistry().getObjectTypeConf( workingMemory.getEntryPoint(),
                                                                                                    queryObject ) );

        workingMemory.getFactHandleFactory().destroyFactHandle( handle );

        LeftTuple childLeftTuple = leftTuple.firstChild;
        LeftTuple temp = null;
        while ( childLeftTuple != null ) {
            int varsLength = this.queryElement.getVariableIndexes().length;
            if ( srcVarIndexes != null ) {
                QueryElementFactHandle qeh = (QueryElementFactHandle) childLeftTuple.getLastHandle();
                Object[] resultObjects = (Object[]) qeh.getObject();
                for ( int j = 0, i = varsLength; i < varIndexes.length; i++, j++ ) {
                    Variable v = trgVars.get( j );
                    v.setValue( resultObjects[i] );
                }
            }

            temp = childLeftTuple;
            this.sink.doPropagateAssertLeftTuple( context,
                                                  workingMemory,
                                                  childLeftTuple,
                                                  childLeftTuple.getLeftTupleSink() );
            if ( srcVarIndexes != null ) {
                QueryElementFactHandle qeh = (QueryElementFactHandle) childLeftTuple.getLastHandle();
                for ( int i = 0; i < trgVars.size(); i++ ) {
                    Variable v = trgVars.get( i );
                    v.unSet();
                }
            }

            childLeftTuple = childLeftTuple.getLeftParentNext();
            temp.setLeftParentNext( null );
View Full Code Here

Examples of org.drools.ruleflow.core.Variable

        }
        if ( !endNodeFound ) {
            errors.add( new RuleFlowProcessValidationErrorImpl( RuleFlowProcessValidationError.NO_END_NODE ) );
        }
        for ( final Iterator it = process.getVariables().iterator(); it.hasNext(); ) {
            final Variable variable = (Variable) it.next();
            if ( variable.getType() == null ) {
                errors.add( new RuleFlowProcessValidationErrorImpl( RuleFlowProcessValidationError.VARIABLE_WITHOUT_TYPE, "name = " + variable.getName() ) );
            }
        }

        checkAllNodesConnectedToStart( process,
                                       errors );
View Full Code Here

Examples of org.drools.runtime.rule.Variable

    }

    public boolean isAllowedCachedRight(LeftTuple tuple, ContextEntry context) {
        if (isUnification) {
            DroolsQuery query = ( DroolsQuery ) tuple.get( 0 ).getObject();
            Variable v = query.getVariables()[ ((UnificationContextEntry)context).getReader().getIndex() ];

            if (v != null) {
                return true;
            }
            context = ((UnificationContextEntry)context).getContextEntry();
View Full Code Here

Examples of org.drools.verifier.components.Variable

            if ( rule.getMetadata().containsKey( "category" ) ) {
                rulesByCategory.put( rule.getMetaAttribute("category"),
                                     rule );
            }
        } else if ( VerifierComponentType.VARIABLE.equals( object.getVerifierComponentType() ) ) {
            Variable variable = (Variable) object;
            variablesByRuleAndVariableName.put( variable.getRuleName() + "." + variable.getName(),
                                                variable );
        } else if ( VerifierComponentType.PATTERN.equals( object.getVerifierComponentType() ) ) {
            Pattern pattern = (Pattern) object;

            patternsByObjectTypeId.put( pattern.getObjectTypePath(),
View Full Code Here

Examples of org.eclipse.bpel.model.Variable

   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setFaultVariable(Variable newFaultVariable) {
    Variable oldFaultVariable = faultVariable;
    faultVariable = newFaultVariable;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, BPELPackage.THROW__FAULT_VARIABLE, oldFaultVariable, faultVariable));
  }
View Full Code Here

Examples of org.eclipse.ocl.ecore.Variable

     * @generated
     */
    private static Variable createVar(
        Environment<?, EClassifier, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?> ecoreEnv,
        String name, EClassifier type) {
      Variable var = EcoreFactory.eINSTANCE.createVariable();
      var.setName(name);
      var.setType(ecoreEnv.getUMLReflection().getOCLType(type));
      return var;
    }
View Full Code Here

Examples of org.eclipse.ocl.expressions.Variable

    /**
     * @generated
     */
    private static Variable createVar(Environment ecoreEnv, String name,
        EClassifier type) {
      Variable var = EcoreFactory.eINSTANCE.createVariable();
      var.setName(name);
      var.setType(ecoreEnv.getUMLReflection().getOCLType(type));
      return var;
    }
View Full Code Here

Examples of org.eclipse.ocl.uml.Variable

 
  @SuppressWarnings("rawtypes")
  public static String oclAtomConstraintToAMPL(TCGOCLAtomImpl tcgOCLAtomConstraint){
    StringBuilder result = new StringBuilder();
   
    Variable oVar = null;
    if (tcgOCLAtomConstraint.getElement() instanceof Variable) {  //input parameter
      oVar = (Variable)tcgOCLAtomConstraint.getElement();
      if (oVar != null) {
        result.append(oVar.getName());
      }   
    }
    else if (tcgOCLAtomConstraint.getElement() instanceof Property) {  //class property
      Property oProp = (Property) tcgOCLAtomConstraint.getElement();
      result.append(oProp.getName());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.