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