Package com.webobjects.directtoweb

Examples of com.webobjects.directtoweb.Rule


            String key = (String)e.nextElement();
            if(!"componentLevelKeys".equals(key)) {
                Object value = dictionary().valueForKey(key);
                EOQualifier q = EOQualifier.qualifierWithQualifierFormat( "pageConfiguration = '" + _pageConfiguration + "'" , null);
                Assignment a = createAssigment(key, value);
                arr.addObject(new Rule(level, q, a));
            }
        }
        NSArray keys = (NSArray)_dictionary.valueForKey("displayPropertyKeys");
        if(keys != null && keys.count() > 0) {
            addRulesForPropertyKeys(level, arr, keys);
View Full Code Here


                EOQualifier q = EOQualifier.qualifierWithQualifierFormat( "pageConfiguration = '" + _pageConfiguration + "' and propertyKey = '" + propertyKey + "'" , null);
                for (Enumeration e1 = values.keyEnumerator(); e1.hasMoreElements();) {
                    String key = (String)e1.nextElement();
                    Object value = values.objectForKey(key);
                    Assignment a = createAssigment(key, value);
                    rules.addObject(new Rule(level, q, a));
                }
            }
        }
    }
View Full Code Here

    }

    public NSArray canidateRuleSetForRHSInContext(String rhs, D2WContext context) {
        NSMutableSet canidateSet = new NSMutableSet();
        for (Enumeration e = rules().objectEnumerator(); e.hasMoreElements();) {
            Rule r = (Rule)e.nextElement();
            if (r.rhsKeyPath().equals(rhs) && r.canFireInContext(context))
                canidateSet.addObject(r);
        }
        return canidateSet.count() == 0 ? canidateSet.allObjects() :
            EOSortOrdering.sortedArrayUsingKeyOrderArray(canidateSet.allObjects(), ruleSortOrderingKeyArray());
    }
View Full Code Here

        dependendKeysPerKey.put(D2WModel.PropertyTypeKey,v.clone());
        dependendKeysPerKey.put(D2WModel.PropertyKeyPortionInModelKey,v.clone());

        // then enumerate through all the rules; h
        for (Enumeration e=rules().objectEnumerator(); e.hasMoreElements();) {
            Rule r=(Rule)e.nextElement();
            String rhsKey=r.rhs().keyPath();
            Vector dependendantKeys=(Vector)dependendKeysPerKey.get(rhsKey);
            if (dependendantKeys==null) {
                dependendantKeys=new Vector();
                dependendKeysPerKey.put(rhsKey,dependendantKeys);
            }
            ERDQualifierTraversal.traverseQualifier(r.lhs(),c);
            for (Enumeration e2=c.keys.objectEnumerator(); e2.hasMoreElements(); ) {
                String k=(String)e2.nextElement();
                _addKeyToVector(k,dependendantKeys);
            }
            // also add those from the assignment
            // if the assignment is delayed, do not add them here;
            // they only need to be added if the key that the assignment computes is itself used
            // on the left hand side
            if (r.rhs() instanceof ERDComputingAssignmentInterface) {
                Vector recipientForNewKeys=dependendantKeys;
                if (r.rhs() instanceof ERDDelayedAssignment) {
                    // put those keys away, needed when reducing the graph and
                    recipientForNewKeys=(Vector)delayedDependendKeysPerKey.get(rhsKey);
                    if (recipientForNewKeys ==null) {
                        recipientForNewKeys =new Vector();
                        delayedDependendKeysPerKey.put(rhsKey, recipientForNewKeys);
                    }
                }
                NSArray extraKeys=((ERDComputingAssignmentInterface)r.rhs()).dependentKeys(rhsKey);
                if (extraKeys!=null) {
                    for (Enumeration e6=extraKeys.objectEnumerator(); e6.hasMoreElements(); ) {
                        String k=(String)e6.nextElement();
                        _addKeyToVector(k, recipientForNewKeys);
                    }
                }
            } else if (r.rhs() instanceof DefaultAssignment) {
                // special treatment for the only custom assignment coming for the D2W default rule set
                // since it does not implement ERDComputingAssignmentInterface, we add the required keys explicitely here
                // another way to do this would be to introduce a rule with the required keys in their LHS, but that is
                // quite a few rules and this is a bit more self contained
                _addKeyToVector("task", dependendantKeys);
                _addKeyToVector("entity", dependendantKeys);
                _addKeyToVector("propertyKey", dependendantKeys);
            }
            if(localizationEnabled && r.rhs() instanceof ERDLocalizableAssignmentInterface) {
                _addKeyToVector("session.language", dependendantKeys);
            }
            c.keys=new NSMutableArray();
        }
        // we then reduce the graph
View Full Code Here

            //Vector uniqueAssignments = new Vector();
            //Hashtable _uniqueAssignments=new Hashtable();
            for (int c = 0; c < rules.count() - 1; c++) {
                //if (c % 100 == 0)
                //    log.debug("Out of : " + c + " rules, duplicates: " + uniquedRules);
                Rule r = (Rule)rules.objectAtIndex(c);
                if (r != null && r.rhs() != null) {
                    Vector v = (Vector)_uniqueAssignments.get(r.rhs().keyPath());
                    if (v != null) {
                        Assignment unique = assignmentContainedInVector(r.rhs(), v);
                        if (unique == null) {
                            v.addElement(r.rhs());
                        } else if (!(unique == r.rhs())) {
                            r.setRhs(unique);
                            uniquedRules++;
                        }
                    } else {
                        Vector m = new Vector();
                        m.addElement(r.rhs());
                        _uniqueAssignments.put(r.rhs().keyPath(), m);
                    }
                } else {
                    log.warn("Rule is null: " + r + " or rhs: " + (r != null ? r.rhs() : null));
                }
            }
            //h = null;
            //if (uniquedRules > 0)
            //    ERXExtensions.forceGC(0);
View Full Code Here

                if (c % 100 == 0)
                  if(log.isDebugEnabled())
                    log.debug("Out of : " + c + " rules, qualifiers: " + totalQualifiers + " duplicates: "
                              + uniquedQualifiers + " replaced: " + replacedQualifiers);
               
                Rule r = (Rule)rules.objectAtIndex(c);
                if (r != null && r.lhs() != null) {
                    EOQualifierEvaluation q = r.lhs();
                    try {
                        EOQualifier cache = qualifierInCache((EOQualifier)q);
                        if (cache != null && cache != q) {
                            r.setLhs(cache);
                            //r.setLhs((EOQualifierEvaluation)cache);
                            replacedQualifiers++;
                            //uniquedQualifiers++;
                        }
                    } catch (NullPointerException npe) {
View Full Code Here

    @Override
    public Object fireNow(D2WContext c) {
        Object result = null;
        NSArray rules = (NSArray)value();
        Enumeration ruleEnumerator = rules.objectEnumerator();
        Rule rule;
        while (ruleEnumerator.hasMoreElements()) {
            rule = (Rule)ruleEnumerator.nextElement();
            EOQualifierEvaluation eval = rule.lhs();
            log.debug("Qualifier eval: \n" + eval);
            if (eval.evaluateWithObject(c)) {
                result = rule.rhs().value();
                log.debug("RHS value: " +  result);
                break;
            }
            log.debug("    object.expansionRSF:" +
                               c.valueForKey("object") +
View Full Code Here

        group.insertObjectAtIndex(rule, 0);
        setSelectedRule(rule);
        return null;
    }
    public WOComponent deleteRule() {
        Rule oldRule = selectedRule();
        setSelectedRule(currentRule);
        group.delete();
        setSelectedRule(oldRule);
        return null;
    }
View Full Code Here

TOP

Related Classes of com.webobjects.directtoweb.Rule

Copyright © 2018 www.massapicom. 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.