1 package org.kuali.ole.ingest.resolver;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 import org.apache.log4j.Logger;
18 import org.kuali.ole.OLEConstants;
19 import org.kuali.ole.ingest.function.*;
20 import org.kuali.rice.krms.api.repository.function.FunctionDefinition;
21 import org.kuali.rice.krms.framework.engine.Function;
22 import org.kuali.rice.krms.framework.type.FunctionTypeService;
23
24 public class FunctionLoader implements FunctionTypeService {
25
26 private ISBNFunction isbnFunction;
27 private OleCurrentDateComparison oleCurrentDateComparison;
28 private CheckDigitRoutine checkDigitRoutine;
29 private OleContainsComparison containsComparison;
30 private ISSNFunction issnFunction;
31 private OCLCFunction oclcFunction;
32 private LocationFunction locationFunction;
33 private ItemBarcodeFunction itemBarcodeFunction;
34 private VendorLineItemReferenceFunction vendorLineItemReferenceFunction;
35 private static final Logger LOG = Logger.getLogger(FunctionLoader.class);
36
37
38
39
40
41
42 @Override
43 public Function loadFunction(FunctionDefinition functionDefinition) {
44 if (functionDefinition.getName().equals(OLEConstants.ISBN_FUNCTION_DEF_NAME)) {
45 return getISBNFunction();
46 } else if(functionDefinition.getName().equals(OLEConstants.ISSN_FUNCTION_DEF_NAME)) {
47 return getISSNFunction();
48 } else if(functionDefinition.getName().equals(OLEConstants.OCLC_FUNCTION_DEF_NAME)) {
49 return getOCLCFunction();
50 } else if (functionDefinition.getName().equals(OLEConstants.OLE_CURRENT_DATE_FUNCTION)) {
51 return getOleCurrentDateComparison();
52 } else if(functionDefinition.getName().equals(OLEConstants.CHECK_DIGIT_ROUTINE)) {
53 return getCheckDigitRoutine();
54 } else if(functionDefinition.getName().equals(OLEConstants.LOCATION_FUNCTION_DEF_NAME)){
55 return getLocationFunction();
56 } else if(functionDefinition.getName().equals(OLEConstants.ITEM_BARCODE_FUNCTION_DEF_NAME)) {
57 return getItemBarcodeFunction();
58 }
59 else if(functionDefinition.getName().equals(OLEConstants.VENDOR_LINEITEM_REF_NUM_FUNCTION_DEF_NAME)){
60 return getVendorLineItemReferenceFunction();
61 }
62 else if(functionDefinition.getName().equals(OLEConstants.OLE_CONTAINS_FUNCTION)){
63 return getContainsComparison();
64 } else if(functionDefinition.getName().equals(OLEConstants.OLE_CIRC_POLICY_FOUND_FUNCTION)) {
65 return new CirculationPolicyFoundFunction();
66 }
67 else if(functionDefinition.getName().equals(OLEConstants.OLE_RENEWAL_DATE_FUNCTION)) {
68 return new OleRenewalDateComparison();
69 }
70 throw new IllegalArgumentException("Failed to load function for the given definition: " + functionDefinition.getName());
71 }
72
73
74
75
76
77
78 public VendorLineItemReferenceFunction getVendorLineItemReferenceFunction() {
79 if (null == vendorLineItemReferenceFunction) {
80 vendorLineItemReferenceFunction = new VendorLineItemReferenceFunction();
81 }
82 return vendorLineItemReferenceFunction;
83 }
84
85
86
87
88
89
90 public LocationFunction getLocationFunction() {
91 if (null == locationFunction) {
92 locationFunction = new LocationFunction();
93 }
94 return locationFunction;
95 }
96
97
98
99
100
101
102 public ItemBarcodeFunction getItemBarcodeFunction() {
103 if(null == itemBarcodeFunction){
104 itemBarcodeFunction = new ItemBarcodeFunction();
105 }
106 return itemBarcodeFunction;
107 }
108
109
110
111
112
113
114 private Function getISBNFunction() {
115 if (null == isbnFunction) {
116 isbnFunction = new ISBNFunction();
117 }
118 return isbnFunction;
119 }
120
121
122
123
124
125 private Function getISSNFunction() {
126 if (null == issnFunction) {
127 issnFunction = new ISSNFunction();
128 }
129 return issnFunction;
130 }
131
132
133
134
135
136
137 private Function getOCLCFunction() {
138 if (null == oclcFunction) {
139 oclcFunction = new OCLCFunction();
140 }
141 return oclcFunction;
142 }
143
144
145
146
147
148
149 private Function getOleCurrentDateComparison(){
150 if(null == oleCurrentDateComparison){
151 oleCurrentDateComparison = new OleCurrentDateComparison();
152 }
153 return oleCurrentDateComparison;
154 }
155
156
157
158
159
160 public OleContainsComparison getContainsComparison() {
161 if(null == containsComparison){
162 containsComparison = new OleContainsComparison();
163 }
164 return containsComparison;
165 }
166
167
168
169
170
171
172 public CheckDigitRoutine getCheckDigitRoutine() {
173 if(null == checkDigitRoutine){
174 checkDigitRoutine = new CheckDigitRoutine();
175 }
176 return checkDigitRoutine;
177 }
178 }