Coverage Report - org.kuali.rice.krms.api.engine.SelectionCriteria
 
Classes in this File Line Coverage Branch Coverage Complexity
SelectionCriteria
0%
0/18
0%
0/6
1.667
 
 1  
 package org.kuali.rice.krms.api.engine;
 2  
 
 3  
 import java.util.Collections;
 4  
 import java.util.HashMap;
 5  
 import java.util.Map;
 6  
 
 7  
 import org.joda.time.DateTime;
 8  
 
 9  
 public final class SelectionCriteria {
 10  
 
 11  
         private final Long effectiveExecutionTime;
 12  
         private final String eventName;
 13  
         private final Map<String, String> contextQualifiers;
 14  
         private final Map<String, String> agendaQualifiers;
 15  
         
 16  0
         private SelectionCriteria(String eventName, DateTime effectiveDate) {
 17  0
                 if (eventName == null || "".equals(eventName.trim())) {
 18  0
                         throw new IllegalArgumentException("Event name must not be null or empty.");
 19  
                 }
 20  0
                 this.eventName = eventName;
 21  
                 
 22  0
                 if (effectiveDate != null) {
 23  0
                         this.effectiveExecutionTime = effectiveDate.getMillis();
 24  
                 } else {
 25  0
                         this.effectiveExecutionTime = null;
 26  
                 }
 27  
                 
 28  0
                 this.contextQualifiers = new HashMap<String, String>();
 29  0
                 this.agendaQualifiers = new HashMap<String, String>();
 30  0
         }
 31  
         
 32  
         /**
 33  
          * This static factory method creates a SelectionCriteria used to select an Agenda to execute.
 34  
          * 
 35  
          * @param eventName the event that is triggering rule execution.  Must not be null.
 36  
          * @param effectiveExecutionTime the time that the rule is being executed at.  If null, the time of engine execution will be used.
 37  
          * @param contextQualifiers qualifiers used to select the context
 38  
          * @param agendaQualifiers qualifiers used to select the agenda from the context
 39  
          * @return the {@link SelectionCriteria}
 40  
          */
 41  
         public static SelectionCriteria createCriteria(String eventName, DateTime effectiveExecutionTime, Map<String, String> contextQualifiers, Map<String, String> agendaQualifiers) {
 42  0
                 SelectionCriteria criteria = new SelectionCriteria(eventName, effectiveExecutionTime);
 43  0
                 criteria.contextQualifiers.putAll(contextQualifiers);
 44  0
                 criteria.agendaQualifiers.putAll(agendaQualifiers);
 45  0
                 return criteria;
 46  
         }
 47  
 
 48  
         public String getEventName() {
 49  0
                 return eventName;
 50  
         }
 51  
         
 52  
         /**
 53  
          * This method gets the effective date/time in epoch time, suitable for 
 54  
          * converting to a {@link java.util.Date} via {@link java.util.Date#Date(long)}
 55  
          * @return the epoch time for effective execution, or null 
 56  
          * (which defers to the {@link Engine} but implies that the actual time when execution begins will be used).
 57  
          */
 58  
         public Long getEffectiveExecutionTime() {
 59  0
                 return effectiveExecutionTime;
 60  
         }
 61  
 
 62  
         public Map<String, String> getContextQualifiers() {
 63  0
                 return Collections.unmodifiableMap(contextQualifiers);
 64  
         }
 65  
 
 66  
         public Map<String, String> getAgendaQualifiers() {
 67  0
                 return Collections.unmodifiableMap(agendaQualifiers);
 68  
         }
 69  
 
 70  
 }