1 package org.kuali.ole.batch.controller;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.kuali.ole.OLEConstants;
5 import org.kuali.ole.batch.bo.*;
6 import org.kuali.ole.batch.util.BatchBibImportUtil;
7 import org.kuali.ole.docstore.model.enums.DocType;
8 import org.kuali.ole.batch.bo.xstream.OLEBatchProcessProfileRecordProcessor;
9 import org.kuali.ole.select.OleSelectConstant;
10 import org.kuali.ole.select.bo.OleGloballyProtectedField;
11 import org.kuali.ole.select.document.service.OleInvoiceService;
12 import org.kuali.ole.select.document.service.OleSelectDocumentService;
13 import org.kuali.ole.service.OleOrderRecordService;
14 import org.kuali.ole.sys.context.SpringContext;
15 import org.kuali.ole.vnd.businessobject.OleExchangeRate;
16 import org.kuali.rice.krad.maintenance.MaintenanceDocument;
17 import org.kuali.rice.krad.service.BusinessObjectService;
18 import org.kuali.rice.krad.service.KRADServiceLocator;
19 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
20 import org.kuali.rice.krad.service.LookupService;
21 import org.kuali.rice.krad.uif.UifParameters;
22 import org.kuali.rice.krad.uif.container.CollectionGroup;
23 import org.kuali.rice.krad.uif.util.ObjectPropertyUtils;
24 import org.kuali.rice.krad.uif.view.View;
25 import org.kuali.rice.krad.util.GlobalVariables;
26 import org.kuali.rice.krad.util.KRADConstants;
27 import org.kuali.rice.krad.web.controller.MaintenanceDocumentController;
28 import org.kuali.rice.krad.web.form.DocumentFormBase;
29 import org.kuali.rice.krad.web.form.MaintenanceDocumentForm;
30 import org.kuali.rice.krad.web.form.UifFormBase;
31 import org.springframework.stereotype.Controller;
32 import org.springframework.validation.BindingResult;
33 import org.springframework.web.bind.annotation.ModelAttribute;
34 import org.springframework.web.bind.annotation.RequestMapping;
35 import org.springframework.web.bind.annotation.RequestMethod;
36 import org.springframework.web.servlet.ModelAndView;
37
38 import javax.servlet.http.HttpServletRequest;
39 import javax.servlet.http.HttpServletResponse;
40 import java.text.ParseException;
41 import java.text.SimpleDateFormat;
42 import java.util.*;
43 import java.util.regex.Pattern;
44 import static org.kuali.ole.OLEConstants.OLEBatchProcess.*;
45
46
47
48
49
50
51
52
53
54 @Controller
55 @RequestMapping(value = "/oleBatchProcessProfile")
56 public class OLEBatchProcessProfileController extends MaintenanceDocumentController {
57
58
59 BusinessObjectService businessObject = SpringContext.getBean(BusinessObjectService.class);
60
61
62 private OleSelectDocumentService oleSelectDocumentService;
63 private OleOrderRecordService oleOrderRecordService;
64 private OleInvoiceService oleInvoiceService;
65 private OLEBatchProcessProfileRecordProcessor oleBatchProcessProfileRecordProcessor;
66 private static List<OLEBatchProcessBibDataMappingNew> oleBatchProcessBibDataMappingNewList= new ArrayList<>();
67
68
69 private static List<OLEBatchProcessProfileDataMappingOptionsBo> oleBatchProcessProfileDataMappingOptionsBoList = new ArrayList<>();
70
71 static {
72 Map<String, String> eHoldingsMapping = new TreeMap<>();
73 Map<String, String> gokbMapping = new TreeMap<>();
74 Map<String, String> gokbMappingForBib = new TreeMap<>();
75
76 eHoldingsMapping.put(E_HOLDINGS_URL_MAPPING, DESTINATION_FIELD_LINK_URL);
77 eHoldingsMapping.put(E_HOLDINGS_START_DATE_MAPPING, DESTINATION_FIELD_COVERAGE_START_DATE);
78 eHoldingsMapping.put(E_HOLDINGS_START_VOLUME_MAPPING, DESTINATION_FIELD_COVERAGE_START_VOLUME);
79 eHoldingsMapping.put(E_HOLDINGS_START_ISSUE_MAPPING, DESTINATION_FIELD_COVERAGE_START_ISSUE);
80 eHoldingsMapping.put(E_HOLDINGS_END_DATE_MAPPING, DESTINATION_FIELD_COVERAGE_END_DATE);
81 eHoldingsMapping.put(E_HOLDINGS_END_VOLUME_MAPPING, DESTINATION_FIELD_COVERAGE_END_VOLUME);
82 eHoldingsMapping.put(E_HOLDINGS_END_ISSUE_MAPPING, DESTINATION_FIELD_COVERAGE_END_ISSUE);
83 eHoldingsMapping.put(E_HOLDINGS_PLATFORM, DESTINATION_FIELD_PLATFORM);
84 eHoldingsMapping.put(E_HOLDINGS_E_RESOURCE_ID, DESTINATION_FIELD_ERESOURCE_ID);
85 eHoldingsMapping.put(E_HOLDINGS_GOKB_ID , DESTINATION_FIELD_GOKB_ID);
86 eHoldingsMapping.put(E_HOLDINGS_PUBLISHER , DESTINATION_FIELD_PUBLISHER);
87 eHoldingsMapping.put(E_HOLDINGS_IMPRINT , DESTINATION_FIELD_IMPRINT);
88
89
90
91 gokbMapping.put(E_HOLDINGS_URL_MAPPING, "Platform.host.URL");
92 gokbMapping.put(E_HOLDINGS_START_DATE_MAPPING, "Start date");
93 gokbMapping.put(E_HOLDINGS_START_VOLUME_MAPPING, "Start volume");
94 gokbMapping.put(E_HOLDINGS_START_ISSUE_MAPPING, "Start issue");
95 gokbMapping.put(E_HOLDINGS_END_DATE_MAPPING, "End date");
96 gokbMapping.put(E_HOLDINGS_END_VOLUME_MAPPING, "End volume");
97 gokbMapping.put(E_HOLDINGS_END_ISSUE_MAPPING, "End issue");
98 gokbMapping.put(E_HOLDINGS_GOKB_ID , "GOKb UID");
99 gokbMapping.put(E_HOLDINGS_PUBLISHER , DESTINATION_FIELD_PUBLISHER);
100 gokbMapping.put(E_HOLDINGS_IMPRINT , DESTINATION_FIELD_IMPRINT);
101
102
103 gokbMappingForBib.put("GOKb UID","035 ## $a");
104 gokbMappingForBib.put("Name","245 00 $a");
105 gokbMappingForBib.put("VariantName","246 3# $a");
106 gokbMappingForBib.put("TI ISSN (Online)","022 ## $a");
107 gokbMappingForBib.put("TI ISSN (Print)","022 ## $a");
108 gokbMappingForBib.put("TI ISSN-L","022 ## $l");
109 gokbMappingForBib.put("OCLC Number","035 ## $a");
110 gokbMappingForBib.put("TI DOI","035 ## $a");
111 gokbMappingForBib.put("TI Publisher ID","035 ## $a");
112 gokbMappingForBib.put("TI Proprietary ID","035 ## $a");
113 gokbMappingForBib.put("TI SUNCAT","035 ## $a");
114 gokbMappingForBib.put("TI LCCN","010 ## $a");
115
116
117
118 for (String key : eHoldingsMapping.keySet()) {
119 OLEBatchProcessProfileDataMappingOptionsBo oleBatchProcessProfileDataMappingOptionsBo = new OLEBatchProcessProfileDataMappingOptionsBo();
120 oleBatchProcessProfileDataMappingOptionsBo.setDataType(BATCH_PROCESS_PROFILE_DATATYPE_BIBMARC);
121 oleBatchProcessProfileDataMappingOptionsBo.setSourceFieldText(key);
122 oleBatchProcessProfileDataMappingOptionsBo.setDataTypeDestinationField(BATCH_PROCESS_PROFILE_DATATYPE_EHOLDINGS);
123 oleBatchProcessProfileDataMappingOptionsBo.setDestinationField(eHoldingsMapping.get(key));
124 oleBatchProcessProfileDataMappingOptionsBo.setGokbField(gokbMapping.get(key));
125 oleBatchProcessProfileDataMappingOptionsBoList.add(oleBatchProcessProfileDataMappingOptionsBo);
126 }
127
128 for (String key : gokbMappingForBib.keySet()) {
129 OLEBatchProcessBibDataMappingNew oleBatchProcessBibDataMappingNew = new OLEBatchProcessBibDataMappingNew();
130 oleBatchProcessBibDataMappingNew.setGokbFieldBib(key);
131 oleBatchProcessBibDataMappingNew.setTag(gokbMappingForBib.get(key));
132 oleBatchProcessBibDataMappingNewList.add(oleBatchProcessBibDataMappingNew);
133 }
134 }
135
136
137 public OleSelectDocumentService getOleSelectDocumentService() {
138 if (oleSelectDocumentService == null) {
139 oleSelectDocumentService = SpringContext.getBean(OleSelectDocumentService.class);
140 }
141 return oleSelectDocumentService;
142 }
143
144 public OleOrderRecordService getOleOrderRecordService() {
145 if (oleOrderRecordService == null) {
146 oleOrderRecordService = SpringContext.getBean(OleOrderRecordService.class);
147 }
148 return oleOrderRecordService;
149 }
150
151 public OleInvoiceService getOleInvoiceService() {
152 if (oleInvoiceService == null) {
153 oleInvoiceService = SpringContext.getBean(OleInvoiceService.class);
154 }
155 return oleInvoiceService;
156 }
157
158 private LookupService getLookupService() {
159 return KRADServiceLocatorWeb.getLookupService();
160 }
161
162 @Override
163 protected MaintenanceDocumentForm createInitialForm(HttpServletRequest request) {
164 return new MaintenanceDocumentForm();
165 }
166
167
168
169
170
171
172
173
174
175 @Override
176 @RequestMapping(params = "methodToCall=start")
177 public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
178 HttpServletRequest request, HttpServletResponse response) {
179 LOG.debug("Start -- Start Method of OlePatronRecordForm");
180 MaintenanceDocumentForm maintenanceForm = (MaintenanceDocumentForm) form;
181 setupMaintenance(maintenanceForm, request, KRADConstants.MAINTENANCE_NEW_ACTION);
182 MaintenanceDocument document = (MaintenanceDocument) maintenanceForm.getDocument();
183 OLEBatchProcessProfileBo batchProcessProfileBo = (OLEBatchProcessProfileBo) document.getDocumentDataObject();
184 List<OleGloballyProtectedField> oleGloballyProtectedFields = (List<OleGloballyProtectedField>) KRADServiceLocator.getBusinessObjectService().findAll(OleGloballyProtectedField.class);
185 if(oleGloballyProtectedFields.size()>0){
186 List<OLEBatchGloballyProtectedField> batchGloballyProtectedFields = new ArrayList<OLEBatchGloballyProtectedField>();
187 for(OleGloballyProtectedField globallyProtectedField : oleGloballyProtectedFields){
188 OLEBatchGloballyProtectedField oleBatchGloballyProtectedField = new OLEBatchGloballyProtectedField();
189 oleBatchGloballyProtectedField.setGloballyProtectedFieldId(globallyProtectedField.getOleGloballyProtectedFieldId());
190 oleBatchGloballyProtectedField.setTag(globallyProtectedField.getTag());
191 oleBatchGloballyProtectedField.setFirstIndicator(globallyProtectedField.getFirstIndicator());
192 oleBatchGloballyProtectedField.setSecondIndicator(globallyProtectedField.getSecondIndicator());
193 oleBatchGloballyProtectedField.setSubField(globallyProtectedField.getSubField());
194 batchGloballyProtectedFields.add(oleBatchGloballyProtectedField);
195 }
196 batchProcessProfileBo.setOleBatchGloballyProtectedFieldList(batchGloballyProtectedFields);
197 }
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212 return super.start(form, result, request, response);
213 }
214
215 @Override
216 @RequestMapping(params = "methodToCall=maintenanceEdit")
217 public ModelAndView maintenanceEdit(@ModelAttribute("KualiForm") MaintenanceDocumentForm form, BindingResult result,
218 HttpServletRequest request, HttpServletResponse response) throws Exception {
219 MaintenanceDocumentForm maintenanceForm = (MaintenanceDocumentForm) form;
220 setupMaintenance(form, request, KRADConstants.MAINTENANCE_EDIT_ACTION);
221 MaintenanceDocument document = (MaintenanceDocument) maintenanceForm.getDocument();
222 OLEBatchProcessProfileBo oldOleBatchProcessProfileBo = (OLEBatchProcessProfileBo) document.getOldMaintainableObject().getDataObject();
223 OLEBatchProcessProfileBo newOleBatchProcessProfileBo = (OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
224
225 Map<String,String> map=new HashMap<String,String>();
226 map.put("batchProcessProfileId",oldOleBatchProcessProfileBo.getBatchProcessProfileId());
227 List<OLEBatchGloballyProtectedField> existBatchGloballyProtectedFields = (List<OLEBatchGloballyProtectedField>) KRADServiceLocator.getBusinessObjectService().findMatching(OLEBatchGloballyProtectedField.class,map);
228 List<OleGloballyProtectedField> oleGloballyProtectedFields = (List<OleGloballyProtectedField>) KRADServiceLocator.getBusinessObjectService().findAll(OleGloballyProtectedField.class);
229 if (oleGloballyProtectedFields.size() > 0) {
230 List<OLEBatchGloballyProtectedField> batchGloballyProtectedFields = new ArrayList<OLEBatchGloballyProtectedField>();
231 for (OleGloballyProtectedField globallyProtectedField : oleGloballyProtectedFields) {
232 OLEBatchGloballyProtectedField oleBatchGloballyProtectedField = new OLEBatchGloballyProtectedField();
233 oleBatchGloballyProtectedField.setGloballyProtectedFieldId(globallyProtectedField.getOleGloballyProtectedFieldId());
234 oleBatchGloballyProtectedField.setTag(globallyProtectedField.getTag());
235 oleBatchGloballyProtectedField.setFirstIndicator(globallyProtectedField.getFirstIndicator());
236 oleBatchGloballyProtectedField.setSecondIndicator(globallyProtectedField.getSecondIndicator());
237 oleBatchGloballyProtectedField.setSubField(globallyProtectedField.getSubField());
238 for (OLEBatchGloballyProtectedField existBatchGloballyProtectedField : existBatchGloballyProtectedFields) {
239 if (existBatchGloballyProtectedField.getGloballyProtectedFieldId().equals(globallyProtectedField.getOleGloballyProtectedFieldId())) {
240 oleBatchGloballyProtectedField.setIgnoreValue(existBatchGloballyProtectedField.isIgnoreValue());
241 oleBatchGloballyProtectedField.setId(existBatchGloballyProtectedField.getId());
242 }
243 }
244 batchGloballyProtectedFields.add(oleBatchGloballyProtectedField);
245 }
246 oldOleBatchProcessProfileBo.setOleBatchGloballyProtectedFieldList(batchGloballyProtectedFields);
247 }
248
249 for (OLEBatchProcessProfileMatchPoint oleBatchProcessProfileMatchPoint : oldOleBatchProcessProfileBo.getOleBatchProcessProfileMatchPointList()) {
250 if(oleBatchProcessProfileMatchPoint.getMatchPointType() != null && oleBatchProcessProfileMatchPoint.getMatchPointType().equalsIgnoreCase("bibliographic")) {
251 oldOleBatchProcessProfileBo.getOleBatchProcessProfileBibliographicMatchPointList().add(oleBatchProcessProfileMatchPoint);
252 } else if(oleBatchProcessProfileMatchPoint.getMatchPointType() != null && oleBatchProcessProfileMatchPoint.getMatchPointType().equalsIgnoreCase("holdings")) {
253 oldOleBatchProcessProfileBo.getOleBatchProcessProfileHoldingMatchPointList().add(oleBatchProcessProfileMatchPoint);
254 } else if(oleBatchProcessProfileMatchPoint.getMatchPointType() != null && oleBatchProcessProfileMatchPoint.getMatchPointType().equalsIgnoreCase("item")) {
255 oldOleBatchProcessProfileBo.getOleBatchProcessProfileItemMatchPointList().add(oleBatchProcessProfileMatchPoint);
256 } else if(oleBatchProcessProfileMatchPoint.getMatchPointType() != null && oleBatchProcessProfileMatchPoint.getMatchPointType().equalsIgnoreCase("eHoldings")) {
257 oldOleBatchProcessProfileBo.getOleBatchProcessProfileEholdingMatchPointList().add(oleBatchProcessProfileMatchPoint);
258 }
259 }
260 return super.maintenanceEdit(form, result, request, response);
261 }
262
263 @Override
264 @RequestMapping(params = "methodToCall=route")
265 public ModelAndView route(@ModelAttribute("KualiForm") DocumentFormBase form, BindingResult result,
266 HttpServletRequest request, HttpServletResponse response) {
267 MaintenanceDocumentForm mainForm = (MaintenanceDocumentForm) form;
268 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
269
270
271 OLEBatchProcessProfileBo newOleBatchProcessProfileBo = (OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
272 MatchingProfile matchingProfile = newOleBatchProcessProfileBo.getMatchingProfileObj();
273 newOleBatchProcessProfileBo.setMatchingProfile(matchingProfile.toString());
274 List<OLEBatchProcessProfileFilterCriteriaBo> filterCriteriaBoList=new ArrayList<OLEBatchProcessProfileFilterCriteriaBo>();
275 if(newOleBatchProcessProfileBo.getOleBatchProcessProfileFilterCriteriaList().size()>0){
276 for(OLEBatchProcessProfileFilterCriteriaBo oleBatchProcessProfileFilterCriteriaBo:newOleBatchProcessProfileBo.getOleBatchProcessProfileFilterCriteriaList()){
277 if((oleBatchProcessProfileFilterCriteriaBo.getFilterFieldName().isEmpty() || oleBatchProcessProfileFilterCriteriaBo.getFilterFieldName()==null) ){
278 oleBatchProcessProfileFilterCriteriaBo.setFilterFieldName(oleBatchProcessProfileFilterCriteriaBo.getFilterFieldNameText());
279 }
280 filterCriteriaBoList.add(oleBatchProcessProfileFilterCriteriaBo);
281 }
282 ((OLEBatchProcessProfileBo) document.getNewMaintainableObject().getDataObject()).setOleBatchProcessProfileFilterCriteriaList(filterCriteriaBoList);
283 ((MaintenanceDocumentForm) form).setDocument(document);
284 }
285 if (!newOleBatchProcessProfileBo.getRemoveValueFrom001()){
286 newOleBatchProcessProfileBo.setValueToRemove("");
287 }
288
289 if (!validateMatchPoints(newOleBatchProcessProfileBo,matchingProfile)) {
290 return getUIFModelAndView(form);
291 }
292 List<OLEBatchProcessProfileBibStatus> oleBatchProcessProfileBibStatuses=newOleBatchProcessProfileBo.getDeleteBatchProcessProfileBibStatusList();
293 KRADServiceLocator.getBusinessObjectService().save(oleBatchProcessProfileBibStatuses);
294 for(OLEBatchProcessProfileBibStatus oleBatchProcessProfileBibStatus:oleBatchProcessProfileBibStatuses){
295 Map<String,String> map=new HashMap<String,String>();
296 map.put("batchProcessBibStatusId",oleBatchProcessProfileBibStatus.getBatchProcessBibStatusId());
297 KRADServiceLocator.getBusinessObjectService().deleteMatching(OLEBatchProcessProfileBibStatus.class,map);
298 }
299
300 List<OLEBatchProcessProfileDeleteField> oleBatchProcessProfileDeleteFields=newOleBatchProcessProfileBo.getDeletedBatchProcessProfileDeleteFieldsList();
301 KRADServiceLocator.getBusinessObjectService().save(oleBatchProcessProfileDeleteFields);
302 for(OLEBatchProcessProfileDeleteField oleBatchProcessProfileDeleteField:oleBatchProcessProfileDeleteFields){
303 Map<String,String> map=new HashMap<String,String>();
304 map.put("id",oleBatchProcessProfileDeleteField.getId());
305 KRADServiceLocator.getBusinessObjectService().deleteMatching(OLEBatchProcessProfileDeleteField.class,map);
306 }
307
308 List<OLEBatchProcessProfileRenameField> oleBatchProcessProfileRenameFields=newOleBatchProcessProfileBo.getDeletedBatchProcessProfileRenameFieldsList();
309 for(OLEBatchProcessProfileRenameField oleBatchProcessProfileRenameField:oleBatchProcessProfileRenameFields){
310 Map<String,String> map=new HashMap<String,String>();
311 map.put("id",oleBatchProcessProfileRenameField.getId());
312 KRADServiceLocator.getBusinessObjectService().deleteMatching(OLEBatchProcessProfileRenameField.class,map);
313 }
314 List<OLEBatchProcessProfileFilterCriteriaBo> oleBatchProcessProfileFilterCriteriaBos=newOleBatchProcessProfileBo.getDeleteBatchProcessProfileFilterCriteriaList();
315 for(OLEBatchProcessProfileFilterCriteriaBo oleBatchProcessProfileFilterCriteriaBo:oleBatchProcessProfileFilterCriteriaBos){
316 Map<String,String> map=new HashMap<String,String>();
317 map.put("filterId",oleBatchProcessProfileFilterCriteriaBo.getFilterId());
318 KRADServiceLocator.getBusinessObjectService().deleteMatching(OLEBatchProcessProfileFilterCriteriaBo.class,map);
319 }
320 List<OLEBatchProcessProfileDataMappingOptionsBo> oleBatchProcessProfileDataMappingOptionsBos=newOleBatchProcessProfileBo.getDeletedBatchProcessProfileDataMappingOptionsList();
321 for(OLEBatchProcessProfileDataMappingOptionsBo oleBatchProcessProfileDataMappingOptionsBo:oleBatchProcessProfileDataMappingOptionsBos){
322 Map<String,String> map=new HashMap<String,String>();
323 map.put("oleBatchProcessProfileDataMappingOptionId",oleBatchProcessProfileDataMappingOptionsBo.getOleBatchProcessProfileDataMappingOptionId());
324 KRADServiceLocator.getBusinessObjectService().deleteMatching(OLEBatchProcessProfileDataMappingOptionsBo.class,map);
325 }
326 List<OLEBatchProcessProfileMappingOptionsBo> oleBatchProcessProfileMappingOptionsBos=newOleBatchProcessProfileBo.getDeletedBatchProcessProfileMappingOptionsList();
327 for(OLEBatchProcessProfileMappingOptionsBo oleBatchProcessProfileMappingOptionsBo:oleBatchProcessProfileMappingOptionsBos){
328 Map<String,String> map=new HashMap<String,String>();
329 map.put("oleBatchProcessDataMapId",oleBatchProcessProfileMappingOptionsBo.getOleBatchProcessDataMapId());
330 KRADServiceLocator.getBusinessObjectService().deleteMatching(OLEBatchProcessProfileMappingOptionsBo.class,map);
331 }
332 List<OLEBatchProcessProfileConstantsBo> oleBatchProcessProfileConstantsBos=newOleBatchProcessProfileBo.getDeletedBatchProcessProfileConstantsList();
333 for(OLEBatchProcessProfileConstantsBo oleBatchProcessProfileConstantsBo:oleBatchProcessProfileConstantsBos){
334 Map<String,String> map=new HashMap<String,String>();
335 map.put("oleBatchProcessProfileConstantsId",oleBatchProcessProfileConstantsBo.getOleBatchProcessProfileConstantsId());
336 KRADServiceLocator.getBusinessObjectService().deleteMatching(OLEBatchProcessProfileConstantsBo.class,map);
337 }
338 List<OLEBatchProcessProfileProtectedField> oleBatchProcessProfileProtectedFields=newOleBatchProcessProfileBo.getDeletedBatchProcessProfileProtectedFieldList();
339 for(OLEBatchProcessProfileProtectedField oleBatchProcessProfileProtectedField:oleBatchProcessProfileProtectedFields){
340 Map<String,String> map=new HashMap<String,String>();
341 map.put("oleProfileProtectedFieldId",oleBatchProcessProfileProtectedField.getOleProfileProtectedFieldId());
342 KRADServiceLocator.getBusinessObjectService().deleteMatching(OLEBatchProcessProfileProtectedField.class,map);
343 }
344 List<OLEBatchProcessBibDataMappingNew> oleBatchProcessBibDataMappingNews = newOleBatchProcessProfileBo.getDeleteBatchProcessBibDataMappingNewList();
345 for(OLEBatchProcessBibDataMappingNew oleBatchProcessBibDataMappingNew:oleBatchProcessBibDataMappingNews) {
346 if (oleBatchProcessBibDataMappingNew!=null && StringUtils.isNotBlank(oleBatchProcessBibDataMappingNew.getOleBatchProcessBibDataMappingNewId())) {
347 Map<String, String> map = new HashMap<String, String>();
348 map.put("oleBatchProcessBibDataMappingNewId", oleBatchProcessBibDataMappingNew.getOleBatchProcessBibDataMappingNewId());
349 KRADServiceLocator.getBusinessObjectService().deleteMatching(OLEBatchProcessBibDataMappingNew.class, map);
350 }
351 }
352 List<OLEBatchProcessBibDataMappingOverlay> oleBatchProcessBibDataMappingOverlays = newOleBatchProcessProfileBo.getDeleteBatchProcessBibDataMappingOverlayList();
353 for (OLEBatchProcessBibDataMappingOverlay oleBatchProcessBibDataMappingOverlay : oleBatchProcessBibDataMappingOverlays) {
354 if (oleBatchProcessBibDataMappingOverlay!=null && StringUtils.isNotBlank(oleBatchProcessBibDataMappingOverlay.getOleBatchProcessBibDataMappingOverlayId())) {
355 Map<String, String> map = new HashMap<String, String>();
356 map.put("oleBatchProcessBibDataMappingOverlayId", oleBatchProcessBibDataMappingOverlay.getOleBatchProcessBibDataMappingOverlayId());
357 KRADServiceLocator.getBusinessObjectService().deleteMatching(OLEBatchProcessBibDataMappingOverlay.class, map);
358 }
359 }
360 List<OLEBatchProcessProfileMatchPoint> oleBatchProcessProfileMatchPointList = newOleBatchProcessProfileBo.getDeletedBatchProcessProfileMatchPointList();
361 newOleBatchProcessProfileBo.getOleBatchProcessProfileMatchPointList().removeAll(oleBatchProcessProfileMatchPointList);
362 for (OLEBatchProcessProfileMatchPoint oleBatchProcessProfileMatchPoint : oleBatchProcessProfileMatchPointList) {
363 KRADServiceLocator.getBusinessObjectService().delete(oleBatchProcessProfileMatchPoint);
364 }
365 List<OLEBatchGloballyProtectedField> batchGloballyProtectedFields = new ArrayList<OLEBatchGloballyProtectedField>();
366 batchGloballyProtectedFields.addAll(newOleBatchProcessProfileBo.getOleBatchGloballyProtectedFieldList());
367
368 if (StringUtils.isNotBlank(newOleBatchProcessProfileBo.getBatchProcessProfileId())) {
369 for (OLEBatchGloballyProtectedField globallyProtectedField : batchGloballyProtectedFields) {
370 Map<String, String> map = new HashMap<String, String>();
371 map.put("batchProcessProfileId", newOleBatchProcessProfileBo.getBatchProcessProfileId());
372 KRADServiceLocator.getBusinessObjectService().deleteMatching(OLEBatchGloballyProtectedField.class, map);
373 }
374
375 List<OLEBatchGloballyProtectedField> batchGloballyProtectedFieldList = new ArrayList<OLEBatchGloballyProtectedField>();
376 for (OLEBatchGloballyProtectedField globallyProtectedField : batchGloballyProtectedFields) {
377
378 globallyProtectedField.setBatchProcessProfileId(newOleBatchProcessProfileBo.getBatchProcessProfileId());
379 batchGloballyProtectedFieldList.add(globallyProtectedField);
380
381 }
382 newOleBatchProcessProfileBo.setOleBatchGloballyProtectedFieldList(batchGloballyProtectedFieldList);
383 KRADServiceLocator.getBusinessObjectService().linkAndSave(batchGloballyProtectedFieldList);
384 } else {
385
386 List<OLEBatchGloballyProtectedField> batchGloballyProtectedFieldList = new ArrayList<OLEBatchGloballyProtectedField>();
387 for (OLEBatchGloballyProtectedField globallyProtectedField : batchGloballyProtectedFields) {
388
389
390 batchGloballyProtectedFieldList.add(globallyProtectedField);
391
392 }
393 newOleBatchProcessProfileBo.setOleBatchGloballyProtectedFieldList(batchGloballyProtectedFieldList);
394 }
395 return super.route(form, result, request, response);
396 }
397
398 private boolean validateMatchPoints(OLEBatchProcessProfileBo newOleBatchProcessProfileBo, MatchingProfile matchingProfile) {
399 boolean isValid = true;
400 if (newOleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_BIB_IMPORT)) {
401 if (matchingProfile.isMatchBibs()) {
402 List<OLEBatchProcessProfileMatchPoint> oleBatchProcessProfileMatchPointList = newOleBatchProcessProfileBo.getOleBatchProcessProfileBibliographicMatchPointList();
403 if (oleBatchProcessProfileMatchPointList.size() == 0) {
404 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_BIB_MATCH_POINT);
405 isValid = false;
406 }
407 if (matchingProfile.isMatchHoldings()) {
408 if (OLEConstants.OLEBatchProcess.DATA_TO_IMPORT_BIB_INSTANCE.equalsIgnoreCase(newOleBatchProcessProfileBo.getDataToImport()) ||
409 OLEConstants.OLEBatchProcess.DATA_TO_IMPORT_BIB_INSTANCE_EINSTANCE.equalsIgnoreCase(newOleBatchProcessProfileBo.getDataToImport())) {
410 oleBatchProcessProfileMatchPointList = newOleBatchProcessProfileBo.getOleBatchProcessProfileHoldingMatchPointList();
411 if (oleBatchProcessProfileMatchPointList.size() == 0) {
412 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_HOLDINGS_MATCH_POINT);
413 isValid = false;
414 }
415
416 if (matchingProfile.isMatchItems()) {
417 oleBatchProcessProfileMatchPointList = newOleBatchProcessProfileBo.getOleBatchProcessProfileItemMatchPointList();
418 if (oleBatchProcessProfileMatchPointList.size() == 0) {
419 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_ITEM_MATCH_POINT);
420 isValid = false;
421 }
422 }
423 }
424 if (OLEConstants.OLEBatchProcess.DATA_TO_IMPORT_BIB_EINSTANCE.equalsIgnoreCase(newOleBatchProcessProfileBo.getDataToImport()) ||
425 OLEConstants.OLEBatchProcess.DATA_TO_IMPORT_BIB_INSTANCE_EINSTANCE.equalsIgnoreCase(newOleBatchProcessProfileBo.getDataToImport())) {
426 oleBatchProcessProfileMatchPointList = newOleBatchProcessProfileBo.getOleBatchProcessProfileEholdingMatchPointList();
427 if (oleBatchProcessProfileMatchPointList.size() == 0) {
428 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_EHOLDINGS_MATCH_POINT);
429 isValid = false;
430 }
431 }
432 }
433
434 }
435
436 }
437 return isValid;
438 }
439
440 @Override
441 @RequestMapping(params = "methodToCall=blanketApprove")
442 public ModelAndView blanketApprove(@ModelAttribute("KualiForm") DocumentFormBase form, BindingResult result,
443 HttpServletRequest request, HttpServletResponse response) throws Exception {
444 route(form, result, request, response);
445 return super.blanketApprove(form, result, request, response);
446 }
447
448 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=addBibMatch")
449 public ModelAndView addBibMatch(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
450 HttpServletRequest request, HttpServletResponse response) {
451 LOG.debug("Initialized addLine method");
452 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
453 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
454 OLEBatchProcessProfileBo oleBatchProcessProfileBo = (OLEBatchProcessProfileBo) document.getNewMaintainableObject().getDataObject();
455
456 String selectedCollectionPath = form.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH);
457 CollectionGroup collectionGroup = form.getPostedView().getViewIndex().getCollectionGroupByPath(selectedCollectionPath);
458 String addLinePath = collectionGroup.getAddLineBindingInfo().getBindingPath();
459 Object eventObject = ObjectPropertyUtils.getPropertyValue(form, addLinePath);
460 OLEBatchProcessProfileMatchPoint oleBatchProcessProfileMatchPoint = (OLEBatchProcessProfileMatchPoint) eventObject;
461 if(oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_BIB_IMPORT)){
462 if(validateBibMatchPoint(oleBatchProcessProfileMatchPoint.getMatchPoint())==Boolean.FALSE){
463 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_BIB_MATCH_POINT_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_BIB_MATCH_POINT_ERR);
464 return getUIFModelAndView(form);
465 }
466 }
467 View view = form.getPostedView();
468 view.getViewHelperService().processCollectionAddLine(view, form, selectedCollectionPath);
469 oleBatchProcessProfileBo.getOleBatchProcessProfileBibliographicMatchPointList().remove(oleBatchProcessProfileMatchPoint);
470 int lastIndex=oleBatchProcessProfileBo.getOleBatchProcessProfileBibliographicMatchPointList().size();
471 oleBatchProcessProfileBo.getOleBatchProcessProfileBibliographicMatchPointList().add(lastIndex,oleBatchProcessProfileMatchPoint);
472 oleBatchProcessProfileBo.getOleBatchProcessProfileMatchPointList().add(lastIndex,oleBatchProcessProfileMatchPoint);
473
474
475 return getUIFModelAndView(form);
476 }
477
478 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=addHoldingMatch")
479 public ModelAndView addHoldingMatch(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
480 HttpServletRequest request, HttpServletResponse response) {
481 LOG.debug("Initialized addLine method");
482 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
483 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
484 OLEBatchProcessProfileBo oleBatchProcessProfileBo = (OLEBatchProcessProfileBo) document.getNewMaintainableObject().getDataObject();
485
486 String selectedCollectionPath = form.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH);
487 CollectionGroup collectionGroup = form.getPostedView().getViewIndex().getCollectionGroupByPath(selectedCollectionPath);
488 String addLinePath = collectionGroup.getAddLineBindingInfo().getBindingPath();
489 Object eventObject = ObjectPropertyUtils.getPropertyValue(form, addLinePath);
490 OLEBatchProcessProfileMatchPoint oleBatchProcessProfileMatchPoint = (OLEBatchProcessProfileMatchPoint) eventObject;
491 if(oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_BIB_IMPORT)){
492
493
494
495
496 }
497 View view = form.getPostedView();
498 view.getViewHelperService().processCollectionAddLine(view, form, selectedCollectionPath);
499 oleBatchProcessProfileBo.getOleBatchProcessProfileHoldingMatchPointList().remove(oleBatchProcessProfileMatchPoint);
500 int lastIndex=oleBatchProcessProfileBo.getOleBatchProcessProfileHoldingMatchPointList().size();
501 oleBatchProcessProfileBo.getOleBatchProcessProfileHoldingMatchPointList().add(lastIndex,oleBatchProcessProfileMatchPoint);
502 oleBatchProcessProfileBo.getOleBatchProcessProfileMatchPointList().add(lastIndex,oleBatchProcessProfileMatchPoint);
503
504
505 return getUIFModelAndView(form);
506 }
507
508 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=addItemMatch")
509 public ModelAndView addItemMatch(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
510 HttpServletRequest request, HttpServletResponse response) {
511 LOG.debug("Initialized addLine method");
512 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
513 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
514 OLEBatchProcessProfileBo oleBatchProcessProfileBo = (OLEBatchProcessProfileBo) document.getNewMaintainableObject().getDataObject();
515
516 String selectedCollectionPath = form.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH);
517 CollectionGroup collectionGroup = form.getPostedView().getViewIndex().getCollectionGroupByPath(selectedCollectionPath);
518 String addLinePath = collectionGroup.getAddLineBindingInfo().getBindingPath();
519 Object eventObject = ObjectPropertyUtils.getPropertyValue(form, addLinePath);
520 OLEBatchProcessProfileMatchPoint oleBatchProcessProfileMatchPoint = (OLEBatchProcessProfileMatchPoint) eventObject;
521 if(oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_BIB_IMPORT)){
522
523
524
525
526 View view = form.getPostedView();
527 view.getViewHelperService().processCollectionAddLine(view, form, selectedCollectionPath);
528 oleBatchProcessProfileBo.getOleBatchProcessProfileItemMatchPointList().remove(oleBatchProcessProfileMatchPoint);
529 int lastIndex=oleBatchProcessProfileBo.getOleBatchProcessProfileItemMatchPointList().size();
530 oleBatchProcessProfileBo.getOleBatchProcessProfileItemMatchPointList().add(lastIndex,oleBatchProcessProfileMatchPoint);
531 oleBatchProcessProfileBo.getOleBatchProcessProfileMatchPointList().add(lastIndex,oleBatchProcessProfileMatchPoint);
532 }
533
534
535
536 return getUIFModelAndView(form);
537 }
538
539
540
541 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=addEholdingMatch")
542 public ModelAndView addEholdingMatch(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
543 HttpServletRequest request, HttpServletResponse response) {
544 LOG.debug("Initialized addLine method");
545 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
546 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
547 OLEBatchProcessProfileBo oleBatchProcessProfileBo = (OLEBatchProcessProfileBo) document.getNewMaintainableObject().getDataObject();
548
549 String selectedCollectionPath = form.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH);
550 CollectionGroup collectionGroup = form.getPostedView().getViewIndex().getCollectionGroupByPath(selectedCollectionPath);
551 String addLinePath = collectionGroup.getAddLineBindingInfo().getBindingPath();
552 Object eventObject = ObjectPropertyUtils.getPropertyValue(form, addLinePath);
553 OLEBatchProcessProfileMatchPoint oleBatchProcessProfileMatchPoint = (OLEBatchProcessProfileMatchPoint) eventObject;
554 if(oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_BIB_IMPORT)){
555
556
557
558
559 }
560 View view = form.getPostedView();
561 view.getViewHelperService().processCollectionAddLine(view, form, selectedCollectionPath);
562 oleBatchProcessProfileBo.getOleBatchProcessProfileEholdingMatchPointList().remove(oleBatchProcessProfileMatchPoint);
563 int lastIndex=oleBatchProcessProfileBo.getOleBatchProcessProfileEholdingMatchPointList().size();
564 oleBatchProcessProfileBo.getOleBatchProcessProfileEholdingMatchPointList().add(lastIndex,oleBatchProcessProfileMatchPoint);
565 oleBatchProcessProfileBo.getOleBatchProcessProfileMatchPointList().add(lastIndex,oleBatchProcessProfileMatchPoint);
566
567
568 return getUIFModelAndView(form);
569 }
570
571
572 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=addFilterCriteriaMapping")
573 public ModelAndView addFilterCriteriaMapping(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
574 HttpServletRequest request, HttpServletResponse response) {
575
576 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
577 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
578 OLEBatchProcessProfileBo oleBatchProcessProfileBo = (OLEBatchProcessProfileBo) document.getNewMaintainableObject().getDataObject();
579 String selectedCollectionPath = form.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH);
580 CollectionGroup collectionGroup = form.getPostedView().getViewIndex().getCollectionGroupByPath(selectedCollectionPath);
581 String addLinePath = collectionGroup.getAddLineBindingInfo().getBindingPath();
582 Object eventObject = ObjectPropertyUtils.getPropertyValue(form, addLinePath);
583 OLEBatchProcessProfileFilterCriteriaBo oleBatchProcessProfileFilterCriteriaBo = (OLEBatchProcessProfileFilterCriteriaBo) eventObject;
584 boolean matchPointFlag1 = true;
585 if ((oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_EXPORT)) && oleBatchProcessProfileFilterCriteriaBo != null && oleBatchProcessProfileFilterCriteriaBo.getFilterFieldName()!=null && oleBatchProcessProfileFilterCriteriaBo.getFilterFieldNameText()!=null) {
586 if(!StringUtils.isEmpty(oleBatchProcessProfileFilterCriteriaBo.getFilterFieldName()) && !StringUtils.isEmpty(oleBatchProcessProfileFilterCriteriaBo.getFilterFieldNameText()) && !StringUtils.isEmpty(oleBatchProcessProfileFilterCriteriaBo.getFilterFieldValue())){
587 matchPointFlag1 = validateFilterCriteriaFieldValue(oleBatchProcessProfileFilterCriteriaBo.getFilterFieldName());
588 if (!matchPointFlag1) {
589 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_FILTER_CRITERIA_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_BIB_FILTER_CRITERIA_FIELD_ERR);
590 return getUIFModelAndView(form);
591 }
592 } else if(!StringUtils.isEmpty(oleBatchProcessProfileFilterCriteriaBo.getFilterFieldName()) && StringUtils.isEmpty(oleBatchProcessProfileFilterCriteriaBo.getFilterFieldNameText())){
593 return super.addLine(uifForm, result, request, response);
594 } else {
595 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_FILTER_CRITERIA_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_BIB_FILTER_CRITERIA_FIELD_ERR);
596 return getUIFModelAndView(form);
597 }
598 } else {
599 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_FILTER_CRITERIA_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_BIB_FILTER_CRITERIA_FIELD_ERR);
600 return getUIFModelAndView(form);
601 }
602 return super.addLine(uifForm, result, request, response);
603 }
604
605 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=addLineDataMapping")
606 public ModelAndView addLineDataMapping(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
607 HttpServletRequest request, HttpServletResponse response) {
608
609 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
610 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
611 OLEBatchProcessProfileBo oleBatchProcessProfileBo = (OLEBatchProcessProfileBo) document.getNewMaintainableObject().getDataObject();
612 String selectedCollectionPath = form.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH);
613 CollectionGroup collectionGroup = form.getPostedView().getViewIndex().getCollectionGroupByPath(selectedCollectionPath);
614 String addLinePath = collectionGroup.getAddLineBindingInfo().getBindingPath();
615 Object eventObject = ObjectPropertyUtils.getPropertyValue(form, addLinePath);
616 OLEBatchProcessProfileDataMappingOptionsBo oleBatchProcessProfileDataMappingOptionsBo = (OLEBatchProcessProfileDataMappingOptionsBo) eventObject;
617
618
619 if (!validateRequiredForMapping(oleBatchProcessProfileDataMappingOptionsBo, oleBatchProcessProfileBo, form)) {
620 return getUIFModelAndView(form);
621 }
622 boolean matchPointFlag1 = true;
623 boolean matchPointFlag2 = true;
624 if ((oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_BIB_IMPORT) || oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_EXPORT) || oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.ORDER_RECORD_IMPORT)) && oleBatchProcessProfileDataMappingOptionsBo != null) {
625 if (oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_BIB_IMPORT) || oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_EXPORT)){
626 if (oleBatchProcessProfileDataMappingOptionsBo.getDataType().equals(OLEConstants.OLEBatchProcess.BATCH_PROCESS_PROFILE_DATATYPE_BIBMARC)) {
627 matchPointFlag1 = validateDataMappingFieldValue(oleBatchProcessProfileDataMappingOptionsBo.getSourceFieldText());
628 }
629 if (oleBatchProcessProfileDataMappingOptionsBo.getDataTypeDestinationField().equals(OLEConstants.OLEBatchProcess.BATCH_PROCESS_PROFILE_DATATYPE_BIBMARC)) {
630 matchPointFlag2 = validateDataMappingFieldValue(oleBatchProcessProfileDataMappingOptionsBo.getDestinationFieldText());
631 }
632 if (!matchPointFlag1 || !matchPointFlag2) {
633 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_BIB_DATA_MAPPING_FIELD_ERR);
634 return getUIFModelAndView(form);
635 }
636 }
637
638 boolean dupTagFlag = false;
639 List<OLEBatchProcessProfileMappingOptionsBo> oleBatchProcessProfileMappingOptionsList = oleBatchProcessProfileBo.getOleBatchProcessProfileMappingOptionsList();
640 for (OLEBatchProcessProfileMappingOptionsBo oleBatchProcessProfileMappingOptionsBo : oleBatchProcessProfileMappingOptionsList) {
641 List<OLEBatchProcessProfileDataMappingOptionsBo> oleBatchProcessProfileDataMappingOptionsBoList = oleBatchProcessProfileMappingOptionsBo.getOleBatchProcessProfileDataMappingOptionsBoList();
642 for (OLEBatchProcessProfileDataMappingOptionsBo batchProcessProfileDataMappingOptionsBo : oleBatchProcessProfileDataMappingOptionsBoList) {
643
644 boolean isEResourceIdField = false;
645 boolean isEResourceNameField = false;
646
647 batchProcessProfileDataMappingOptionsBo.setOleBatchProcessProfileMappingOptionsBo(oleBatchProcessProfileMappingOptionsBo);
648 oleBatchProcessProfileDataMappingOptionsBo.setOleBatchProcessProfileMappingOptionsBo(oleBatchProcessProfileMappingOptionsBo);
649 if (oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_BIB_IMPORT)) {
650 oleBatchProcessProfileDataMappingOptionsBo.setSourceField(oleBatchProcessProfileDataMappingOptionsBo.getSourceFieldText());
651 if (oleBatchProcessProfileDataMappingOptionsBo.getDataType().equals(OLEConstants.OLEBatchProcess.BATCH_PROCESS_PROFILE_DATATYPE_BIBMARC)) {
652 if (batchProcessProfileDataMappingOptionsBo.getDataTypeDestinationField().equals(oleBatchProcessProfileDataMappingOptionsBo.getDataTypeDestinationField())) {
653 if (batchProcessProfileDataMappingOptionsBo.getDestinationField().equals(oleBatchProcessProfileDataMappingOptionsBo.getDestinationField())
654 && batchProcessProfileDataMappingOptionsBo.getPriority() == oleBatchProcessProfileDataMappingOptionsBo.getPriority()) {
655 dupTagFlag = true;
656 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_BIB_DATA_MAPPING_IMPORT_DESTINATION_FIELD_ERR, oleBatchProcessProfileDataMappingOptionsBo.getDestinationField(), oleBatchProcessProfileDataMappingOptionsBo.getDataTypeDestinationField(), batchProcessProfileDataMappingOptionsBo.getSourceField());
657 break;
658 }
659 if(batchProcessProfileDataMappingOptionsBo.getDestinationField().equals(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_ERESOURCE_NAME)) {
660 isEResourceNameField = true;
661 }
662 if(batchProcessProfileDataMappingOptionsBo.getDestinationField().equals(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_ERESOURCE_ID)) {
663 isEResourceIdField = true;
664 }
665
666 if(isEResourceIdField) {
667 if (oleBatchProcessProfileDataMappingOptionsBo.getDestinationField().equals(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_ERESOURCE_NAME)) {
668 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_BIB_DATA_MAPPING_IMPORT_DESTINATION_FIELD_ERESOURCE_ERR);
669 return getUIFModelAndView(form);
670 }
671 } else if (isEResourceNameField) {
672 if (oleBatchProcessProfileDataMappingOptionsBo.getDestinationField().equals(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_ERESOURCE_ID)) {
673 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_BIB_DATA_MAPPING_IMPORT_DESTINATION_FIELD_ERESOURCE_ERR);
674 return getUIFModelAndView(form);
675 }
676 }
677 }
678 }
679 } else if (oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_EXPORT)) {
680 oleBatchProcessProfileDataMappingOptionsBo.setDestinationField(oleBatchProcessProfileDataMappingOptionsBo.getDestinationFieldText());
681 if (!convertEnterDataField(batchProcessProfileDataMappingOptionsBo.getDestinationField()).equals(convertEnterDataField(oleBatchProcessProfileDataMappingOptionsBo.getDestinationField()))) {
682 if (oleBatchProcessProfileDataMappingOptionsBo.getDataTypeDestinationField().equals(OLEConstants.OLEBatchProcess.BATCH_PROCESS_PROFILE_DATATYPE_BIBMARC)) {
683 if (batchProcessProfileDataMappingOptionsBo.getSourceField().equals(oleBatchProcessProfileDataMappingOptionsBo.getSourceField())) {
684 if (batchProcessProfileDataMappingOptionsBo.getDataType().equals(oleBatchProcessProfileDataMappingOptionsBo.getDataType())) {
685 dupTagFlag = true;
686 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_BIB_DATA_MAPPING_EXPORT_SOURCE_FIELD_ERR, oleBatchProcessProfileDataMappingOptionsBo.getSourceField(), oleBatchProcessProfileDataMappingOptionsBo.getDataType(), batchProcessProfileDataMappingOptionsBo.getDestinationField());
687 break;
688 }
689 }
690 }
691 } else {
692 dupTagFlag = true;
693 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_BIB_DATA_MAPPING_EXPORT_DESTINATION_FIELD_ERR, oleBatchProcessProfileDataMappingOptionsBo.getDestinationField(), oleBatchProcessProfileDataMappingOptionsBo.getDataTypeDestinationField(), batchProcessProfileDataMappingOptionsBo.getDataType(), batchProcessProfileDataMappingOptionsBo.getSourceField());
694 break;
695 }
696 } else if (oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.ORDER_RECORD_IMPORT)) {
697 if (batchProcessProfileDataMappingOptionsBo.getDestinationField().equals(oleBatchProcessProfileDataMappingOptionsBo.getDestinationField())
698 && batchProcessProfileDataMappingOptionsBo.getPriority() == oleBatchProcessProfileDataMappingOptionsBo.getPriority()) {
699 dupTagFlag = true;
700 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_PRIORITY);
701 break;
702 }
703 }
704 }
705 }
706
707 if (dupTagFlag) {
708 return getUIFModelAndView(form);
709 }
710 }
711 return super.addLine(uifForm, result, request, response);
712 }
713
714
715 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=addLineForProfileConstants")
716 public ModelAndView addLineForProfileConstants(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
717 HttpServletRequest request, HttpServletResponse response) {
718
719 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
720 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
721 OLEBatchProcessProfileBo oleBatchProcessProfileBo = (OLEBatchProcessProfileBo) document.getNewMaintainableObject().getDataObject();
722 String selectedCollectionPath = form.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH);
723 CollectionGroup collectionGroup = form.getPostedView().getViewIndex().getCollectionGroupByPath(selectedCollectionPath);
724 String addLinePath = collectionGroup.getAddLineBindingInfo().getBindingPath();
725 Object eventObject = ObjectPropertyUtils.getPropertyValue(form, addLinePath);
726 OLEBatchProcessProfileConstantsBo oleBatchProcessProfileConstantsBo = (OLEBatchProcessProfileConstantsBo ) eventObject;
727 if (oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_BIB_IMPORT)) {
728 setAttributeValueForBibImport(oleBatchProcessProfileConstantsBo);
729 boolean isValid = validateEResourceNameAndId(oleBatchProcessProfileConstantsBo, oleBatchProcessProfileBo.getOleBatchProcessProfileConstantsList());
730 if(!isValid) {
731 return getUIFModelAndView(form);
732 }
733
734 }
735 if(oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.ORDER_RECORD_IMPORT)){
736 oleBatchProcessProfileConstantsBo.setOldAttributeName(null);
737 setAttributeValueForOrderImport(oleBatchProcessProfileConstantsBo);
738 boolean isRequired = validateRequiredFieldsForProfileConstants(oleBatchProcessProfileConstantsBo);
739 if(!isRequired){
740 return getUIFModelAndView(form);
741 }
742 boolean isDupFound = validateDuplicateValuesForAttributeName(oleBatchProcessProfileBo.getOleBatchProcessProfileConstantsList(),oleBatchProcessProfileConstantsBo);
743 if(isDupFound){
744 return getUIFModelAndView(form);
745 }
746 boolean invalidFieldValue = validateFieldValuesForConstantsAndDefaultForOrderImport(oleBatchProcessProfileConstantsBo);
747 if(invalidFieldValue){
748 return getUIFModelAndView(form);
749 }
750 }
751 if(oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.INVOICE_RECORD_IMPORT)){
752 oleBatchProcessProfileConstantsBo.setOldAttributeName(null);
753 setAttributeValueForInvoiceImport(oleBatchProcessProfileConstantsBo);
754 boolean isRequired = validateRequiredFieldsForProfileConstants(oleBatchProcessProfileConstantsBo);
755 if(!isRequired){
756 return getUIFModelAndView(form);
757 }
758 boolean isDupFound = validateDuplicateValuesForAttributeName(oleBatchProcessProfileBo.getOleBatchProcessProfileConstantsList(),oleBatchProcessProfileConstantsBo);
759 if(isDupFound){
760 return getUIFModelAndView(form);
761 }
762 boolean invalidFieldValue = validateFieldValuesForConstantsAndDefaultForInvoiceImport(oleBatchProcessProfileConstantsBo);
763 if(invalidFieldValue){
764 return getUIFModelAndView(form);
765 }
766 }
767 return super.addLine(uifForm, result, request, response);
768 }
769
770 private boolean validateEResourceNameAndId(OLEBatchProcessProfileConstantsBo oleBatchProcessProfileConstantsBo, List<OLEBatchProcessProfileConstantsBo> oleBatchProcessProfileConstantsList) {
771
772 boolean isEResourceIdField = false;
773 boolean isEResourceNameField = false;
774
775 if(oleBatchProcessProfileConstantsBo.getAttributeName().equals(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_ERESOURCE_NAME)) {
776 isEResourceNameField = true;
777 }
778
779 if(oleBatchProcessProfileConstantsBo.getAttributeName().equals(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_ERESOURCE_ID)) {
780 isEResourceIdField = true;
781 }
782
783 if(isEResourceIdField || isEResourceNameField) {
784 for(OLEBatchProcessProfileConstantsBo batchProcessProfileConstantsBo : oleBatchProcessProfileConstantsList) {
785
786
787 if(isEResourceIdField) {
788 if (batchProcessProfileConstantsBo.getAttributeName().equals(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_ERESOURCE_NAME)) {
789 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_BIB_DATA_MAPPING_IMPORT_DESTINATION_FIELD_ERESOURCE_ERR);
790 return false;
791 }
792 } else if (isEResourceNameField) {
793 if (batchProcessProfileConstantsBo.getAttributeName().equals(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_ERESOURCE_ID)) {
794 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_BIB_DATA_MAPPING_IMPORT_DESTINATION_FIELD_ERESOURCE_ERR);
795 return false;
796 }
797 }
798
799
800 }
801 }
802 return true;
803 }
804
805
806
807 private boolean validateDuplicateValuesForAttributeName(List<OLEBatchProcessProfileConstantsBo> oleBatchProcessProfileConstantsBoList,OLEBatchProcessProfileConstantsBo oleBatchProcessProfileConstantsBo){
808 for(int constantList = 0;constantList < oleBatchProcessProfileConstantsBoList.size();constantList++){
809 if(oleBatchProcessProfileConstantsBoList.get(constantList).getAttributeName().equalsIgnoreCase(oleBatchProcessProfileConstantsBo.getAttributeName())){
810 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_DUPLICATE ,"This field name" );
811 return true;
812 }
813 }
814 return false;
815 }
816
817 private boolean validateRequiredFieldsForProfileConstants(OLEBatchProcessProfileConstantsBo oleBatchProcessProfileConstantsBo) {
818 boolean valid = true;
819 if (StringUtils.isBlank(oleBatchProcessProfileConstantsBo.getDataType())){
820 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Data Type");
821 valid = false;
822 }
823 if(StringUtils.isBlank(oleBatchProcessProfileConstantsBo.getAttributeName())){
824 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Field Name");
825 valid = false;
826 }
827 if(StringUtils.isBlank(oleBatchProcessProfileConstantsBo.getAttributeValue())){
828 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Field Value");
829 valid = false;
830 }
831 return valid;
832 }
833
834 private boolean validateFieldValuesForConstantsAndDefaultForOrderImport(OLEBatchProcessProfileConstantsBo oleBatchProcessProfileConstantsBo) {
835 String attributeName = oleBatchProcessProfileConstantsBo.getAttributeName();
836 if(OLEConstants.OLEBatchProcess.PERCENT.equals(attributeName)){
837 String percent = oleBatchProcessProfileConstantsBo.getAttributeValue();
838 if(!getOleOrderRecordService().validateForPercentage(percent)){
839 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.INVALID_PERCENT);
840 return true;
841 }
842 }
843 else if(OLEConstants.OLEBatchProcess.LIST_PRICE.equals(attributeName)){
844 String listPrice = oleBatchProcessProfileConstantsBo.getAttributeValueText();
845 if(!getOleOrderRecordService().validateDestinationFieldValues(listPrice)){
846 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.INVALID_LIST_PRICE);
847 return true;
848 }
849 }
850 else if(OLEConstants.OLEBatchProcess.DISCOUNT.equals(attributeName)){
851 String discount = oleBatchProcessProfileConstantsBo.getAttributeValue();
852 if(!getOleOrderRecordService().validateDestinationFieldValues(discount)){
853 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.INVALID_DISCOUNT);
854 return true;
855 }
856 }
857 else if(OLEConstants.OLEBatchProcess.QUANTITY.equals(attributeName)){
858 String quantity = oleBatchProcessProfileConstantsBo.getAttributeValue();
859 if(!getOleOrderRecordService().validateForNumber(quantity)){
860 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.INVALID_QUANTITY);
861 return true;
862 }
863 }
864 else if(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS.equals(attributeName)){
865 String itemNoOfParts = oleBatchProcessProfileConstantsBo.getAttributeValue();
866 if(!getOleOrderRecordService().validateForNumber(itemNoOfParts)){
867 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.INVALID_NO_OF_PARTS);
868 return true;
869 }
870 }
871 else if(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_BEGIN_DT.equals(oleBatchProcessProfileConstantsBo.getAttributeName()) || OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_END_DT.equals(oleBatchProcessProfileConstantsBo.getAttributeName())){
872 boolean validRecurringPaymenteDate = validateRecurringPaymentDate(oleBatchProcessProfileConstantsBo.getAttributeValue());
873 if(!validRecurringPaymenteDate){
874 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.INVALID_RECURRING_PAYMENT_DATE);
875 return true;
876 }
877 }
878
879 return false;
880 }
881
882 private void setAttributeValueForOrderImport(OLEBatchProcessProfileConstantsBo oleBatchProcessProfileConstantsBo){
883 String attributeName = oleBatchProcessProfileConstantsBo.getAttributeName();
884 if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.PERCENT) || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.LIST_PRICE) ||
885 attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DISCOUNT) || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.QUANTITY) || OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS.equals(attributeName) ||
886 attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.RECURR_PAY_BEGIN_DATE) || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.RECURR_PAY_END_DATE)){
887 oleBatchProcessProfileConstantsBo.setAttributeValue(oleBatchProcessProfileConstantsBo.getAttributeValueText());
888 }
889 }
890 private void setAttributeValueForInvoiceImport(OLEBatchProcessProfileConstantsBo oleBatchProcessProfileConstantsBo){
891 String attributeName = oleBatchProcessProfileConstantsBo.getAttributeName();
892 if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.LIST_PRICE) || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.INVOICE_NUMBER) ||
893 attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.QUANTITY) || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.VENDOR_INVOICE_AMOUNT) ||
894 attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.INVOICE_DATE) || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.EXCHANGE_RATE) || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.FOREIGN_LIST_PRICE)){
895 oleBatchProcessProfileConstantsBo.setAttributeValue(oleBatchProcessProfileConstantsBo.getAttributeValueText());
896 }
897 }
898
899 private void setAttributeValueForBibImport(OLEBatchProcessProfileConstantsBo oleBatchProcessProfileConstantsBo) {
900 String attributeName = oleBatchProcessProfileConstantsBo.getAttributeName();
901 if (attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_CALL_NUMBER)
902 || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_CALL_NUMBER_TYPE_PREFIX)
903 || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_COPY_NUMBER)
904 || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER)
905 || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_ITEM_HOLDINGS_CALL_NUMBER_PREFIX)
906 || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_ITEM_HOLDINGS_COPY_NUMBER)
907 || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.SOURCE_FIELD_DATE_CREATED)
908 || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_ITEM_ITEM_BARCODE)
909 || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_LINK_URL)
910 || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_PERSISTENTLINK)
911 || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_LINK_TEXT)
912 || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_PUBLIC_DISPLAY_NOTE)
913 || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_COVERAGE_START_DATE)
914 || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_COVERAGE_START_ISSUE)
915 || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_COVERAGE_START_VOLUME)
916 || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_COVERAGE_END_DATE)
917 || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_COVERAGE_END_ISSUE)
918 || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_COVERAGE_END_VOLUME)) {
919 oleBatchProcessProfileConstantsBo.setAttributeValue(oleBatchProcessProfileConstantsBo.getAttributeValueText());
920 }
921 }
922
923 private boolean validateRequiredForMapping(OLEBatchProcessProfileDataMappingOptionsBo dataMappingOptionsBo, OLEBatchProcessProfileBo profileBo , MaintenanceDocumentForm form) {
924 boolean valid = true;
925 if ((profileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_BIB_IMPORT))) {
926 if (StringUtils.isBlank(dataMappingOptionsBo.getDataType())){
927 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Data Type");
928 valid = false;
929 }
930 if(StringUtils.isBlank(dataMappingOptionsBo.getSourceFieldText())){
931 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Source Field");
932 valid = false;
933 }
934 if(StringUtils.isBlank(dataMappingOptionsBo.getDataTypeDestinationField())){
935 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Destination Data Type");
936 valid = false;
937 }
938 if(StringUtils.isBlank(dataMappingOptionsBo.getDestinationField())){
939 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Destination Field");
940 valid = false;
941 }
942 }
943 if ((profileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_EXPORT))) {
944 if(StringUtils.isBlank(dataMappingOptionsBo.getDataType())){
945 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Data Type");
946 valid = false;
947 }
948 if(StringUtils.isBlank(dataMappingOptionsBo.getSourceField())){
949 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Source Field");
950 valid = false;
951 }
952 if(StringUtils.isBlank(dataMappingOptionsBo.getDataTypeDestinationField())){
953 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Destination Field");
954 valid = false;
955 }
956 if(StringUtils.isBlank(dataMappingOptionsBo.getDestinationFieldText())){
957 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Destination Field Value");
958 valid = false;
959 }
960 }
961 if ((profileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.ORDER_RECORD_IMPORT))) {
962 if(StringUtils.isBlank(dataMappingOptionsBo.getSourceField())){
963 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Source Field");
964 valid = false;
965 }
966 if(StringUtils.isBlank(dataMappingOptionsBo.getDataTypeDestinationField())){
967 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Destination Data Type");
968 valid = false;
969 }
970 if(StringUtils.isBlank(dataMappingOptionsBo.getDestinationField())){
971 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Destination Field");
972 valid = false;
973 }
974 }
975 if ((profileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.INVOICE_RECORD_IMPORT))) {
976 if(StringUtils.isBlank(dataMappingOptionsBo.getSourceField())){
977 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Source Field");
978 valid = false;
979 }
980 if(StringUtils.isBlank(dataMappingOptionsBo.getDataTypeDestinationField())){
981 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Destination Data Type");
982 valid = false;
983 }
984 if(StringUtils.isBlank(dataMappingOptionsBo.getDestinationField())){
985 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Destination Field");
986 valid = false;
987 }
988 }
989
990 return valid;
991 }
992
993 private boolean validateFieldValuesForConstantsAndDefaultForInvoiceImport(OLEBatchProcessProfileConstantsBo oleBatchProcessProfileConstantsBo) {
994
995 if(OLEConstants.OLEBatchProcess.QUANTITY.equals(oleBatchProcessProfileConstantsBo.getAttributeName())){
996 String quantity = oleBatchProcessProfileConstantsBo.getAttributeValue();
997 if(!getOleOrderRecordService().validateForNumber(quantity)){
998 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.INVALID_QUANTITY);
999 return true;
1000 }
1001 }
1002
1003
1004
1005
1006
1007
1008
1009 else if(OLEConstants.OLEBatchProcess.LIST_PRICE.equals(oleBatchProcessProfileConstantsBo.getAttributeName())){
1010 String listPrice = oleBatchProcessProfileConstantsBo.getAttributeValue();
1011 if(!getOleOrderRecordService().validateDestinationFieldValues(listPrice)){
1012 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.INVALID_INVOICED_PRICE);
1013 return true;
1014 }
1015 }
1016 else if(OLEConstants.OLEBatchProcess.FOREIGN_LIST_PRICE.equals(oleBatchProcessProfileConstantsBo.getAttributeName())){
1017 String foreignListPrice = oleBatchProcessProfileConstantsBo.getAttributeValue();
1018 if(!getOleOrderRecordService().validateDestinationFieldValues(foreignListPrice)){
1019 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.INVALID_INVOICED_FOREIGN_PRICE);
1020 return true;
1021 }
1022 }
1023 else if(OLEConstants.OLEBatchProcess.VENDOR_INVOICE_AMOUNT.equals(oleBatchProcessProfileConstantsBo.getAttributeName())){
1024 String vendorInvoiceAmount = oleBatchProcessProfileConstantsBo.getAttributeValue();
1025 if(!getOleOrderRecordService().validateDestinationFieldValues(vendorInvoiceAmount)){
1026 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.INVALID_VENDOR_INVOICE_AMOUNT);
1027 return true;
1028 }
1029 }
1030 else if(OLEConstants.OLEBatchProcess.INVOICE_DATE.equals(oleBatchProcessProfileConstantsBo.getAttributeName())){
1031 boolean validInvoiceDate = validateInvoiceDate(oleBatchProcessProfileConstantsBo.getAttributeValue());
1032 if(!validInvoiceDate){
1033 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.INVALID_INVOICE_DATE);
1034 return true;
1035 }
1036 }
1037 else if(OLEConstants.OLEBatchProcess.EXCHANGE_RATE.equals(oleBatchProcessProfileConstantsBo.getAttributeName())){
1038 String exchangeRate = oleBatchProcessProfileConstantsBo.getAttributeValue();
1039 if(!getOleOrderRecordService().validateDestinationFieldValues(exchangeRate)){
1040 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.INVALID_EXCHANGE_RATE);
1041 return true;
1042 }
1043 if (exchangeRate.length()>10) {
1044 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.INVALID_EXCHANGE_RATE_NUMBER);
1045 return true;
1046 }
1047 }
1048 return false;
1049 }
1050
1051 private boolean validateInvoiceDate(String invoiceDate){
1052 SimpleDateFormat dateFromRawFile = new SimpleDateFormat("yyyyMMdd");
1053 try {
1054 dateFromRawFile.parse(invoiceDate);
1055 return true;
1056 }
1057 catch (ParseException e) {
1058 return false;
1059 }
1060 }
1061
1062 public boolean validateRecurringPaymentDate(String recurringPaymentDate){
1063 SimpleDateFormat dateFromRawFile = new SimpleDateFormat(org.kuali.ole.OLEConstants.DATE_FORMAT);
1064 dateFromRawFile.setLenient(false);
1065 try {
1066 dateFromRawFile.parse(recurringPaymentDate);
1067 return true;
1068 }
1069 catch (ParseException e) {
1070 return false;
1071 }
1072 }
1073
1074 private String convertEnterDataField(String tag) {
1075 if (StringUtils.isNotEmpty(tag)) {
1076 String[] matchPointArray = tag.split(" ");
1077 if (matchPointArray.length == 3) {
1078 tag = matchPointArray[0] + " " + matchPointArray[2];
1079 }
1080 }
1081 return tag;
1082 }
1083
1084
1085
1086
1087
1088
1089 private boolean validateBibMatchPoint(String bibMatchPoint) {
1090 boolean valid = true;
1091 String pattern = "((001)|(^\\d\\d\\d\\s+([$]([a-z]|\\d))$)|(^\\d\\d\\d\\s+[#|\\d][#|\\d]\\s+([$]([a-z]|\\d))$))";
1092 if (Pattern.matches(pattern, bibMatchPoint) == Boolean.FALSE) {
1093 valid = false;
1094 }
1095 return valid;
1096 }
1097
1098
1099
1100
1101
1102
1103 private boolean validateDataMappingFieldValue(String fieldValue) {
1104 boolean valid = true;
1105 String pattern = "((001)|(^\\d\\d\\d\\s+([$]([a-z]|\\d))+$)|(^\\d\\d\\d\\s+[#|\\d][#|\\d]\\s+([$]([a-z]|\\d))+$))";
1106 if (Pattern.matches(pattern, fieldValue) == Boolean.FALSE) {
1107 valid = false;
1108 }
1109 return valid;
1110 }
1111
1112 private boolean validateFilterCriteriaFieldValue(String fieldValue) {
1113 boolean valid = true;
1114
1115 String pattern = "((^\\d\\d\\d\\s+([$][a-z])+$)|(^\\d\\d\\d\\s+[#|\\d][#|\\d]\\s+([$][a-z])+$))";
1116 if (Pattern.matches(pattern, fieldValue) == Boolean.FALSE) {
1117 valid = false;
1118 }
1119 return valid;
1120 }
1121
1122 @RequestMapping(params = "methodToCall=refreshPageView")
1123 public ModelAndView refreshPageView(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1124 HttpServletRequest request, HttpServletResponse response) throws Exception {
1125
1126
1127
1128
1129
1130
1131 return super.refresh(form,result,request,response);
1132 }
1133 @RequestMapping(params = "methodToCall=refreshBeanId")
1134 public ModelAndView refreshBeanId(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1135 HttpServletRequest request, HttpServletResponse response) throws Exception {
1136 return navigate(form, result, request, response);
1137 }
1138
1139 public ModelAndView refresh(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, HttpServletRequest request, HttpServletResponse response) throws java.lang.Exception {
1140
1141 MaintenanceDocumentForm form1 = (MaintenanceDocumentForm) form;
1142 MaintenanceDocument document = (MaintenanceDocument) form1.getDocument();
1143 OLEBatchProcessProfileBo oleBatchProcessProfileBo = (OLEBatchProcessProfileBo) document.getDocumentDataObject();
1144
1145 if(oleBatchProcessProfileBo != null && oleBatchProcessProfileBo.getBatchProcessProfileType() != null && oleBatchProcessProfileBo.getBatchProcessProfileType().equals(OLEConstants.OLEBatchProcess.GOKB_IMPORT) && oleBatchProcessProfileBo.getOleBatchProcessProfileMappingOptionsList().size() == 0) {
1146 oleBatchProcessProfileBo.getOleBatchProcessProfileDataMappingOptionsBoList().addAll(oleBatchProcessProfileDataMappingOptionsBoList);
1147
1148 OLEBatchProcessProfileMappingOptionsBo oleBatchProcessProfileMappingOptionsBo = new OLEBatchProcessProfileMappingOptionsBo();
1149 oleBatchProcessProfileMappingOptionsBo.getOleBatchProcessProfileDataMappingOptionsBoList().addAll(oleBatchProcessProfileBo.getOleBatchProcessProfileDataMappingOptionsBoList());
1150 oleBatchProcessProfileBo.getOleBatchProcessProfileMappingOptionsList().add(oleBatchProcessProfileMappingOptionsBo);
1151 oleBatchProcessProfileBo.getOleBatchProcessBibDataMappingNewList().addAll(oleBatchProcessBibDataMappingNewList);
1152 oleBatchProcessProfileBo.setDataToImport(DATA_TO_IMPORT_BIB_EINSTANCE);
1153 }
1154
1155 return super.refresh(form,result,request,response);
1156 }
1157
1158 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteBibStatus")
1159 public ModelAndView deleteBibStatus(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1160 HttpServletRequest request, HttpServletResponse response) {
1161 LOG.debug("Initialized addLine method");
1162 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1163 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1164 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1165 OLEBatchProcessProfileBo oleBatchProcessProfileBo=(OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
1166 oleBatchProcessProfileBo.getDeleteBatchProcessProfileBibStatusList().add(oleBatchProcessProfileBo.getOleBatchProcessProfileBibStatusList().get(Integer.parseInt(selectedLineIndex)));
1167
1168 return deleteLine(uifForm, result, request, response);
1169
1170 }
1171 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteDeleteField")
1172 public ModelAndView deleteDeleteField(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1173 HttpServletRequest request, HttpServletResponse response) {
1174 LOG.debug("Initialized addLine method");
1175 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1176 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1177 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1178 OLEBatchProcessProfileBo oleBatchProcessProfileBo=(OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
1179 oleBatchProcessProfileBo.getDeletedBatchProcessProfileDeleteFieldsList().add(oleBatchProcessProfileBo.getOleBatchProcessProfileDeleteFieldsList().get(Integer.parseInt(selectedLineIndex)));
1180
1181 return deleteLine(uifForm, result, request, response);
1182
1183 }
1184 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteRenameField")
1185 public ModelAndView deleteRenameField(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1186 HttpServletRequest request, HttpServletResponse response) {
1187 LOG.debug("Initialized addLine method");
1188 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1189 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1190 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1191 OLEBatchProcessProfileBo oleBatchProcessProfileBo=(OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
1192 oleBatchProcessProfileBo.getDeletedBatchProcessProfileRenameFieldsList().add(oleBatchProcessProfileBo.getOleBatchProcessProfileRenameFieldsList().get(Integer.parseInt(selectedLineIndex)));
1193 return deleteLine(uifForm, result, request, response);
1194 }
1195 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=filterCriteriaDelete")
1196 public ModelAndView filterCriteriaDelete(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1197 HttpServletRequest request, HttpServletResponse response) {
1198 LOG.debug("Initialized addLine method");
1199 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1200 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1201 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1202 OLEBatchProcessProfileBo oleBatchProcessProfileBo=(OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
1203 oleBatchProcessProfileBo.getDeleteBatchProcessProfileFilterCriteriaList().add(oleBatchProcessProfileBo.getOleBatchProcessProfileFilterCriteriaList().get(Integer.parseInt(selectedLineIndex)));
1204 return deleteLine(uifForm, result, request, response);
1205 }
1206
1207 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=dataMappingDelete")
1208 public ModelAndView dataMappingDelete(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1209 HttpServletRequest request, HttpServletResponse response) {
1210 LOG.debug("Initialized addLine method");
1211 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1212 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1213 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1214 OLEBatchProcessProfileBo oleBatchProcessProfileBo=(OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
1215 oleBatchProcessProfileBo.getDeletedBatchProcessProfileMappingOptionsList().add(oleBatchProcessProfileBo.getOleBatchProcessProfileMappingOptionsList().get(Integer.parseInt(selectedLineIndex)));
1216 oleBatchProcessProfileBo.getDeletedBatchProcessProfileDataMappingOptionsList().addAll(oleBatchProcessProfileBo.getOleBatchProcessProfileMappingOptionsList().get(Integer.parseInt(selectedLineIndex)).getOleBatchProcessProfileDataMappingOptionsBoList());
1217 return deleteLine(uifForm, result, request, response);
1218 }
1219
1220 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=bibDataMappingDelete")
1221 public ModelAndView bibDataMappingDelete(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1222 HttpServletRequest request, HttpServletResponse response) {
1223 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1224 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1225 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1226 OLEBatchProcessProfileBo oleBatchProcessProfileBo=(OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
1227 oleBatchProcessProfileBo.getDeleteBatchProcessBibDataMappingNewList().add(oleBatchProcessProfileBo.getOleBatchProcessBibDataMappingNewList().get(Integer.parseInt(selectedLineIndex)));
1228 return deleteLine(uifForm, result, request, response);
1229 }
1230
1231 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=bibDataMappingDeleteOverlay")
1232 public ModelAndView bibDataMappingDeleteOverlay(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1233 HttpServletRequest request, HttpServletResponse response) {
1234 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1235 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1236 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1237 OLEBatchProcessProfileBo oleBatchProcessProfileBo=(OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
1238 oleBatchProcessProfileBo.getDeleteBatchProcessBibDataMappingOverlayList().add(oleBatchProcessProfileBo.getOleBatchProcessBibDataMappingOverlayList().get(Integer.parseInt(selectedLineIndex)));
1239 return deleteLine(uifForm, result, request, response);
1240 }
1241
1242 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=addLineDataMappingDelete")
1243 public ModelAndView addLineDataMappingDelete(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1244 HttpServletRequest request, HttpServletResponse response) {
1245 LOG.debug("Initialized addLine method");
1246 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1247 Map<String,String> actionParameters = form.getActionParameters();
1248 String subCollectionIndex = actionParameters.get(UifParameters.SELECTED_LINE_INDEX);
1249 String mainCollectionIndex= StringUtils.substringBefore(StringUtils.substringAfter(actionParameters.get(UifParameters.SELLECTED_COLLECTION_PATH),"["),"]");
1250 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1251 OLEBatchProcessProfileBo oleBatchProcessProfileBo=(OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
1252 OLEBatchProcessProfileDataMappingOptionsBo oleBatchProcessProfileDataMappingOptionsBo = oleBatchProcessProfileBo.getOleBatchProcessProfileMappingOptionsList().get(Integer.parseInt(mainCollectionIndex)).getOleBatchProcessProfileDataMappingOptionsBoList().get(Integer.parseInt(subCollectionIndex));
1253 if(oleBatchProcessProfileBo.getBatchProcessProfileId()!=null){
1254
1255 oleBatchProcessProfileBo.getDeletedBatchProcessProfileDataMappingOptionsList().add(oleBatchProcessProfileDataMappingOptionsBo);
1256 oleBatchProcessProfileBo.getOleBatchProcessProfileMappingOptionsList().get(Integer.parseInt(mainCollectionIndex)).getOleBatchProcessProfileDataMappingOptionsBoList().remove(Integer.parseInt(subCollectionIndex));
1257 return getUIFModelAndView(uifForm);
1258 }else{
1259 oleBatchProcessProfileBo.getDeletedBatchProcessProfileDataMappingOptionsList().add(oleBatchProcessProfileDataMappingOptionsBo);
1260 return deleteLine(uifForm, result, request, response);
1261 }
1262 }
1263
1264 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteProfileConstant")
1265 public ModelAndView deleteProfileConstant(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1266 HttpServletRequest request, HttpServletResponse response) {
1267 LOG.debug("Initialized addLine method");
1268 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1269 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1270 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1271 OLEBatchProcessProfileBo oleBatchProcessProfileBo=(OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
1272 if(oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.ORDER_RECORD_IMPORT) ||
1273 oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.INVOICE_RECORD_IMPORT)){
1274 String selectedCollectionPath = form.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH);
1275 CollectionGroup collectionGroup = form.getPostedView().getViewIndex().getCollectionGroupByPath(selectedCollectionPath);
1276 String addLinePath = collectionGroup.getAddLineBindingInfo().getBindingPath();
1277 Object eventObject = ObjectPropertyUtils.getPropertyValue(form, addLinePath);
1278 OLEBatchProcessProfileConstantsBo oleBatchProcessProfileConstantsBo = (OLEBatchProcessProfileConstantsBo ) eventObject;
1279 oleBatchProcessProfileConstantsBo.setOldAttributeName(null);
1280 }
1281 oleBatchProcessProfileBo.getDeletedBatchProcessProfileConstantsList().add(oleBatchProcessProfileBo.getOleBatchProcessProfileConstantsList().get(Integer.parseInt(selectedLineIndex)));
1282 return deleteLine(uifForm, result, request, response);
1283 }
1284
1285 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteProfileProtectedField")
1286 public ModelAndView deleteProfileProtectedField(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1287 HttpServletRequest request, HttpServletResponse response) {
1288 LOG.debug("Initialized addLine method");
1289 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1290 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1291 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1292 OLEBatchProcessProfileBo oleBatchProcessProfileBo=(OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
1293 oleBatchProcessProfileBo.getDeletedBatchProcessProfileProtectedFieldList().add(oleBatchProcessProfileBo.getOleBatchProcessProfileProtectedFieldList().get(Integer.parseInt(selectedLineIndex)));
1294 return deleteLine(uifForm, result, request, response);
1295 }
1296
1297 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteBibMatch")
1298 public ModelAndView deleteBibMatch(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1299 HttpServletRequest request, HttpServletResponse response) {
1300 LOG.debug("Initialized deleteLine method");
1301 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1302 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1303 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1304 OLEBatchProcessProfileBo oleBatchProcessProfileBo = (OLEBatchProcessProfileBo) document.getNewMaintainableObject().getDataObject();
1305 oleBatchProcessProfileBo.getDeletedBatchProcessProfileMatchPointList().add(oleBatchProcessProfileBo.getOleBatchProcessProfileBibliographicMatchPointList().get(Integer.parseInt(selectedLineIndex)));
1306 return deleteLine(uifForm, result, request, response);
1307 }
1308
1309 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteHoldingMatch")
1310 public ModelAndView deleteHoldingMatch(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1311 HttpServletRequest request, HttpServletResponse response) {
1312 LOG.debug("Initialized deleteLine method");
1313 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1314 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1315 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1316 OLEBatchProcessProfileBo oleBatchProcessProfileBo = (OLEBatchProcessProfileBo) document.getNewMaintainableObject().getDataObject();
1317 oleBatchProcessProfileBo.getDeletedBatchProcessProfileMatchPointList().add(oleBatchProcessProfileBo.getOleBatchProcessProfileHoldingMatchPointList().get(Integer.parseInt(selectedLineIndex)));
1318 return deleteLine(uifForm, result, request, response);
1319 }
1320
1321 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteItemMatch")
1322 public ModelAndView deleteItemMatch(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1323 HttpServletRequest request, HttpServletResponse response) {
1324 LOG.debug("Initialized deleteLine method");
1325 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1326 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1327 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1328 OLEBatchProcessProfileBo oleBatchProcessProfileBo = (OLEBatchProcessProfileBo) document.getNewMaintainableObject().getDataObject();
1329 oleBatchProcessProfileBo.getDeletedBatchProcessProfileMatchPointList().add(oleBatchProcessProfileBo.getOleBatchProcessProfileItemMatchPointList().get(Integer.parseInt(selectedLineIndex)));
1330 return deleteLine(uifForm, result, request, response);
1331 }
1332 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteEholdingMatch")
1333 public ModelAndView deleteEholdingMatch(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1334 HttpServletRequest request, HttpServletResponse response) {
1335 LOG.debug("Initialized deleteLine method");
1336 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1337 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1338 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1339 OLEBatchProcessProfileBo oleBatchProcessProfileBo = (OLEBatchProcessProfileBo) document.getNewMaintainableObject().getDataObject();
1340 oleBatchProcessProfileBo.getDeletedBatchProcessProfileMatchPointList().add(oleBatchProcessProfileBo.getOleBatchProcessProfileEholdingMatchPointList().get(Integer.parseInt(selectedLineIndex)));
1341 return deleteLine(uifForm, result, request, response);
1342 }
1343
1344 @RequestMapping(params = "methodToCall=populateExchangeRate")
1345 public ModelAndView populateExchangeRate(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1346 HttpServletRequest request, HttpServletResponse response) throws Exception {
1347
1348 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1349 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1350 CollectionGroup collectionGroup = form.getPostedView().getViewIndex().getCollectionGroupByPath("document.newMaintainableObject.dataObject.oleBatchProcessProfileConstantsList");
1351 String addLinePath = collectionGroup.getAddLineBindingInfo().getBindingPath();
1352 Object eventObject = ObjectPropertyUtils.getPropertyValue(form, addLinePath);
1353 OLEBatchProcessProfileConstantsBo oleBatchProcessProfileConstantsBo = (OLEBatchProcessProfileConstantsBo ) eventObject;
1354 OLEBatchProcessProfileBo oleBatchProcessProfileBo=(OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
1355 List<OLEBatchProcessProfileConstantsBo> oleBatchProcessProfileConstantsBoList = oleBatchProcessProfileBo.getOleBatchProcessProfileConstantsList();
1356 for(int recordCount = 0; recordCount < oleBatchProcessProfileConstantsBoList.size();recordCount++) {
1357 if(oleBatchProcessProfileConstantsBoList.get(recordCount).getAttributeName().equalsIgnoreCase(OLEConstants.OLEBatchProcess.CURRENCY_TYPE)){
1358 if(!oleBatchProcessProfileConstantsBoList.get(recordCount).getAttributeValue().equalsIgnoreCase(OleSelectConstant.CURRENCY_TYPE_NAME)){
1359 String currencyTypeId = getOleInvoiceService().getCurrencyTypeIdFromCurrencyType(oleBatchProcessProfileConstantsBoList.get(recordCount).getAttributeValue());
1360 Map exchangeRateMap = new HashMap();
1361 exchangeRateMap.put(OLEConstants.OLEBatchProcess.CURRENCY_TYPE_ID,currencyTypeId);
1362 List<OleExchangeRate> exchangeRateList = (List) getBusinessObjectService().findMatchingOrderBy(
1363 OleExchangeRate.class, exchangeRateMap, OleSelectConstant.EXCHANGE_RATE_DATE, false);
1364 oleBatchProcessProfileConstantsBo.setAttributeValueText(exchangeRateList.get(0).getExchangeRate().toString());
1365 }
1366 else {
1367 oleBatchProcessProfileConstantsBo.setAttributeValueText("0.0");
1368 }
1369 break;
1370 }
1371 oleBatchProcessProfileConstantsBo.setAttributeValueText("0.0");
1372 }
1373 return getUIFModelAndView(form);
1374 }
1375
1376 }