the functions should do it ,.. 
which spec are you speaking of ? 

public void accumulate(Serializable context , Object request) {
                List<ResourceMatch> counts = (List<ResourceMatch>) context;
                RequestCtx xacml = (RequestCtx) request;
                for (Iterator<Attribute> iterator = 
xacml.getResourceAsList().iterator();
iterator.hasNext();) {
                        Attribute resource = (Attribute) iterator.next();
                        if (counts.size() == 0 &&
resource.getId().toString().equalsIgnoreCase("urn:oasis:names:tc:xacml:1.0:resource:resource-id"))
{
                                try {
                                        counts.add(new ResourceMatch(new
URI(DroolsUtils.getAttributeIDValue(resource)),0));
                                } catch (URISyntaxException e) {
                                        // shouldnt appear cause the method 
from DroolsUtils has casted the
returning String from an URI!
                                        e.printStackTrace();
                                }
                        }

                        for (int i = 0; i < counts.size(); i++) {
                                
                                ResourceMatch resourcematch = counts.get(i);
                                try {
                                        if (resourcematch.matches(new
URI(DroolsUtils.getAttributeIDValue(resource)))
                                                        &&
resource.getId().toString().equalsIgnoreCase("urn:oasis:names:tc:xacml:1.0:resource:resource-id")
) {
                                                resourcematch.increment();
                                        }else if (counts.size() == i-1 &&
resource.getId().toString().equalsIgnoreCase("urn:oasis:names:tc:xacml:1.0:resource:resource-id"))
{
                                                counts.add(new ResourceMatch(new
URI(DroolsUtils.getAttributeIDValue(resource)),1));
                                        }
                                } catch (URISyntaxException e) {
                                        // shouldnt appear cause the method 
from DroolsUtils has casted the
returning String from an URI!
                                        e.printStackTrace();
                                }
                        }
                }
        }

        /* (non-Javadoc)
         * @see
org.drools.runtime.rule.AccumulateFunction#reverse(java.io.Serializable,
java.lang.Object)
         */
        public void reverse(Serializable context, Object request) throws 
Exception
{
                List<ResourceMatch> counts = (List<ResourceMatch>) context;
                RequestCtx xacml = (RequestCtx) request;
                for (Iterator&lt;List&lt;Attribute&gt;> iterator =
xacml.getResourceAsList().iterator(); iterator.hasNext();) {
                        List<Attribute> resource = (List<Attribute>) 
iterator.next();
                        for (int i = 0; i < counts.size(); i++) {
                                ResourceMatch resourcematch = counts.get(i);
                                try {
                                        if (resourcematch.matches(new
URI(DroolsUtils.getResourceID(resource)))) {
                                                resourcematch.decrement();
                                        }               
                                } catch (URISyntaxException e) {
                                        // shouldnt appear cause the method 
from DroolsUtils has casted the
returning String from an URI!
                                        e.printStackTrace();
                                }
                        }
                }
        }

--
View this message in context: 
http://drools.46999.n3.nabble.com/SlidingTimeWindow-BehaviorExpireWMAction-tp3163096p3165597.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to