View Javadoc
1   package org.kuali.ole.ingest.resolver;
2   
3   import org.kuali.ole.OLEConstants;
4   import org.kuali.ole.ingest.pojo.ProfileTerm;
5   import org.kuali.rice.krms.api.engine.TermResolutionException;
6   import org.kuali.rice.krms.api.engine.TermResolver;
7   
8   import java.util.Collections;
9   import java.util.Map;
10  import java.util.Set;
11  
12  /**
13   * Created by IntelliJ IDEA.
14   * User: pvsubrah
15   * Date: 3/28/12
16   * Time: 3:09 PM
17   * To change this template use File | Settings | File Templates.
18   */
19  public abstract class AbstractProfileTermResolver implements TermResolver<Object> {
20      /**
21       *  This method gets the unique prerequisites based on OleConstant value.
22       * @return  prerequisite.
23       */
24      @Override
25      public Set<String> getPrerequisites() {
26          return Collections.singleton(OLEConstants.ISBN_TERM);
27      }
28  
29      /**
30       * This method gets the empty immutable set of parameterNames
31       * @return  parameterNames.
32       */
33      @Override
34      public Set<String> getParameterNames() {
35          return Collections.emptySet();
36      }
37  
38      /**
39       * Gets the cost attribute value
40       * @return  1.
41       */
42      @Override
43      public int getCost() {
44          return 1;
45      }
46  
47      /**
48       *  Returns the resolved prerequisites as profileTerm object
49       * @param resolvedPrereqs
50       * @param parameters
51       * @return   profileTerm
52       * @throws org.kuali.rice.krms.api.engine.TermResolutionException
53       */
54      @Override
55      public Object resolve(Map<String, Object> resolvedPrereqs,
56                            Map<String, String> parameters) throws TermResolutionException {
57          ProfileTerm profileTerm = (ProfileTerm) resolvedPrereqs.get("ISBN Term");
58          if (profileTerm == null) {
59              throw new TermResolutionException("Failed to locate Patron prereq", this, parameters);
60          }
61          return resolveFromProfileTerm(profileTerm);
62      }
63  
64      protected abstract Object resolveFromProfileTerm(ProfileTerm profileTerm);
65  }