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 || attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_PLATFORM)) {
920 oleBatchProcessProfileConstantsBo.setAttributeValue(oleBatchProcessProfileConstantsBo.getAttributeValueText());
921 }
922 }
923
924 private boolean validateRequiredForMapping(OLEBatchProcessProfileDataMappingOptionsBo dataMappingOptionsBo, OLEBatchProcessProfileBo profileBo , MaintenanceDocumentForm form) {
925 boolean valid = true;
926 if ((profileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_BIB_IMPORT))) {
927 if (StringUtils.isBlank(dataMappingOptionsBo.getDataType())){
928 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Data Type");
929 valid = false;
930 }
931 if(StringUtils.isBlank(dataMappingOptionsBo.getSourceFieldText())){
932 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Source Field");
933 valid = false;
934 }
935 if(StringUtils.isBlank(dataMappingOptionsBo.getDataTypeDestinationField())){
936 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Destination Data Type");
937 valid = false;
938 }
939 if(StringUtils.isBlank(dataMappingOptionsBo.getDestinationField())){
940 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Destination Field");
941 valid = false;
942 }
943 }
944 if ((profileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_EXPORT))) {
945 if(StringUtils.isBlank(dataMappingOptionsBo.getDataType())){
946 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Data Type");
947 valid = false;
948 }
949 if(StringUtils.isBlank(dataMappingOptionsBo.getSourceField())){
950 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Source Field");
951 valid = false;
952 }
953 if(StringUtils.isBlank(dataMappingOptionsBo.getDataTypeDestinationField())){
954 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Destination Field");
955 valid = false;
956 }
957 if(StringUtils.isBlank(dataMappingOptionsBo.getDestinationFieldText())){
958 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Destination Field Value");
959 valid = false;
960 }
961 }
962 if ((profileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.ORDER_RECORD_IMPORT))) {
963 if(StringUtils.isBlank(dataMappingOptionsBo.getSourceField())){
964 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Source Field");
965 valid = false;
966 }
967 if(StringUtils.isBlank(dataMappingOptionsBo.getDataTypeDestinationField())){
968 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Destination Data Type");
969 valid = false;
970 }
971 if(StringUtils.isBlank(dataMappingOptionsBo.getDestinationField())){
972 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Destination Field");
973 valid = false;
974 }
975 }
976 if ((profileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.INVOICE_RECORD_IMPORT))) {
977 if(StringUtils.isBlank(dataMappingOptionsBo.getSourceField())){
978 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Source Field");
979 valid = false;
980 }
981 if(StringUtils.isBlank(dataMappingOptionsBo.getDataTypeDestinationField())){
982 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Destination Data Type");
983 valid = false;
984 }
985 if(StringUtils.isBlank(dataMappingOptionsBo.getDestinationField())){
986 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_DATA_MAPPING_SECTION_ID, OLEConstants.OLEBatchProcess.OLE_BATCH_REQUIRED , "Destination Field");
987 valid = false;
988 }
989 }
990
991 return valid;
992 }
993
994 private boolean validateFieldValuesForConstantsAndDefaultForInvoiceImport(OLEBatchProcessProfileConstantsBo oleBatchProcessProfileConstantsBo) {
995
996 if(OLEConstants.OLEBatchProcess.QUANTITY.equals(oleBatchProcessProfileConstantsBo.getAttributeName())){
997 String quantity = oleBatchProcessProfileConstantsBo.getAttributeValue();
998 if(!getOleOrderRecordService().validateForNumber(quantity)){
999 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.INVALID_QUANTITY);
1000 return true;
1001 }
1002 }
1003
1004
1005
1006
1007
1008
1009
1010 else if(OLEConstants.OLEBatchProcess.LIST_PRICE.equals(oleBatchProcessProfileConstantsBo.getAttributeName())){
1011 String listPrice = oleBatchProcessProfileConstantsBo.getAttributeValue();
1012 if(!getOleOrderRecordService().validateDestinationFieldValues(listPrice)){
1013 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.INVALID_INVOICED_PRICE);
1014 return true;
1015 }
1016 }
1017 else if(OLEConstants.OLEBatchProcess.FOREIGN_LIST_PRICE.equals(oleBatchProcessProfileConstantsBo.getAttributeName())){
1018 String foreignListPrice = oleBatchProcessProfileConstantsBo.getAttributeValue();
1019 if(!getOleOrderRecordService().validateDestinationFieldValues(foreignListPrice)){
1020 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.INVALID_INVOICED_FOREIGN_PRICE);
1021 return true;
1022 }
1023 }
1024 else if(OLEConstants.OLEBatchProcess.VENDOR_INVOICE_AMOUNT.equals(oleBatchProcessProfileConstantsBo.getAttributeName())){
1025 String vendorInvoiceAmount = oleBatchProcessProfileConstantsBo.getAttributeValue();
1026 if(!getOleOrderRecordService().validateDestinationFieldValues(vendorInvoiceAmount)){
1027 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.INVALID_VENDOR_INVOICE_AMOUNT);
1028 return true;
1029 }
1030 }
1031 else if(OLEConstants.OLEBatchProcess.INVOICE_DATE.equals(oleBatchProcessProfileConstantsBo.getAttributeName())){
1032 boolean validInvoiceDate = validateInvoiceDate(oleBatchProcessProfileConstantsBo.getAttributeValue());
1033 if(!validInvoiceDate){
1034 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.INVALID_INVOICE_DATE);
1035 return true;
1036 }
1037 }
1038 else if(OLEConstants.OLEBatchProcess.EXCHANGE_RATE.equals(oleBatchProcessProfileConstantsBo.getAttributeName())){
1039 String exchangeRate = oleBatchProcessProfileConstantsBo.getAttributeValue();
1040 if(!getOleOrderRecordService().validateDestinationFieldValues(exchangeRate)){
1041 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.INVALID_EXCHANGE_RATE);
1042 return true;
1043 }
1044 if (exchangeRate.length()>10) {
1045 GlobalVariables.getMessageMap().putErrorForSectionId(OLEConstants.OLEBatchProcess.OLE_BATCH_PROFILE_CONSTANT_SECTION_ID, OLEConstants.OLEBatchProcess.INVALID_EXCHANGE_RATE_NUMBER);
1046 return true;
1047 }
1048 }
1049 return false;
1050 }
1051
1052 private boolean validateInvoiceDate(String invoiceDate){
1053 SimpleDateFormat dateFromRawFile = new SimpleDateFormat("yyyyMMdd");
1054 try {
1055 dateFromRawFile.parse(invoiceDate);
1056 return true;
1057 }
1058 catch (ParseException e) {
1059 return false;
1060 }
1061 }
1062
1063 public boolean validateRecurringPaymentDate(String recurringPaymentDate){
1064 SimpleDateFormat dateFromRawFile = new SimpleDateFormat(org.kuali.ole.OLEConstants.DATE_FORMAT);
1065 dateFromRawFile.setLenient(false);
1066 try {
1067 dateFromRawFile.parse(recurringPaymentDate);
1068 return true;
1069 }
1070 catch (ParseException e) {
1071 return false;
1072 }
1073 }
1074
1075 private String convertEnterDataField(String tag) {
1076 if (StringUtils.isNotEmpty(tag)) {
1077 String[] matchPointArray = tag.split(" ");
1078 if (matchPointArray.length == 3) {
1079 tag = matchPointArray[0] + " " + matchPointArray[2];
1080 }
1081 }
1082 return tag;
1083 }
1084
1085
1086
1087
1088
1089
1090 private boolean validateBibMatchPoint(String bibMatchPoint) {
1091 boolean valid = true;
1092 String pattern = "((001)|(^\\d\\d\\d\\s+([$]([a-z]|\\d))$)|(^\\d\\d\\d\\s+[#|\\d][#|\\d]\\s+([$]([a-z]|\\d))$))";
1093 if (Pattern.matches(pattern, bibMatchPoint) == Boolean.FALSE) {
1094 valid = false;
1095 }
1096 return valid;
1097 }
1098
1099
1100
1101
1102
1103
1104 private boolean validateDataMappingFieldValue(String fieldValue) {
1105 boolean valid = true;
1106 String pattern = "((001)|(^\\d\\d\\d\\s+([$]([a-z]|\\d))+$)|(^\\d\\d\\d\\s+[#|\\d][#|\\d]\\s+([$]([a-z]|\\d))+$))";
1107 if (Pattern.matches(pattern, fieldValue) == Boolean.FALSE) {
1108 valid = false;
1109 }
1110 return valid;
1111 }
1112
1113 private boolean validateFilterCriteriaFieldValue(String fieldValue) {
1114 boolean valid = true;
1115
1116 String pattern = "((^\\d\\d\\d\\s+([$][a-z])+$)|(^\\d\\d\\d\\s+[#|\\d][#|\\d]\\s+([$][a-z])+$))";
1117 if (Pattern.matches(pattern, fieldValue) == Boolean.FALSE) {
1118 valid = false;
1119 }
1120 return valid;
1121 }
1122
1123 @RequestMapping(params = "methodToCall=refreshPageView")
1124 public ModelAndView refreshPageView(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1125 HttpServletRequest request, HttpServletResponse response) throws Exception {
1126
1127
1128
1129
1130
1131
1132 return super.refresh(form,result,request,response);
1133 }
1134 @RequestMapping(params = "methodToCall=refreshBeanId")
1135 public ModelAndView refreshBeanId(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1136 HttpServletRequest request, HttpServletResponse response) throws Exception {
1137 return navigate(form, result, request, response);
1138 }
1139
1140 public ModelAndView refresh(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, HttpServletRequest request, HttpServletResponse response) throws java.lang.Exception {
1141
1142 MaintenanceDocumentForm form1 = (MaintenanceDocumentForm) form;
1143 MaintenanceDocument document = (MaintenanceDocument) form1.getDocument();
1144 OLEBatchProcessProfileBo oleBatchProcessProfileBo = (OLEBatchProcessProfileBo) document.getDocumentDataObject();
1145
1146 if(oleBatchProcessProfileBo != null && oleBatchProcessProfileBo.getBatchProcessProfileType() != null && oleBatchProcessProfileBo.getBatchProcessProfileType().equals(OLEConstants.OLEBatchProcess.GOKB_IMPORT) && oleBatchProcessProfileBo.getOleBatchProcessProfileMappingOptionsList().size() == 0) {
1147 oleBatchProcessProfileBo.getOleBatchProcessProfileDataMappingOptionsBoList().addAll(oleBatchProcessProfileDataMappingOptionsBoList);
1148
1149 OLEBatchProcessProfileMappingOptionsBo oleBatchProcessProfileMappingOptionsBo = new OLEBatchProcessProfileMappingOptionsBo();
1150 oleBatchProcessProfileMappingOptionsBo.getOleBatchProcessProfileDataMappingOptionsBoList().addAll(oleBatchProcessProfileBo.getOleBatchProcessProfileDataMappingOptionsBoList());
1151 oleBatchProcessProfileBo.getOleBatchProcessProfileMappingOptionsList().add(oleBatchProcessProfileMappingOptionsBo);
1152 oleBatchProcessProfileBo.getOleBatchProcessBibDataMappingNewList().addAll(oleBatchProcessBibDataMappingNewList);
1153 oleBatchProcessProfileBo.setDataToImport(DATA_TO_IMPORT_BIB_EINSTANCE);
1154 }
1155
1156 return super.refresh(form,result,request,response);
1157 }
1158
1159 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteBibStatus")
1160 public ModelAndView deleteBibStatus(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1161 HttpServletRequest request, HttpServletResponse response) {
1162 LOG.debug("Initialized addLine method");
1163 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1164 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1165 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1166 OLEBatchProcessProfileBo oleBatchProcessProfileBo=(OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
1167 oleBatchProcessProfileBo.getDeleteBatchProcessProfileBibStatusList().add(oleBatchProcessProfileBo.getOleBatchProcessProfileBibStatusList().get(Integer.parseInt(selectedLineIndex)));
1168
1169 return deleteLine(uifForm, result, request, response);
1170
1171 }
1172 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteDeleteField")
1173 public ModelAndView deleteDeleteField(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1174 HttpServletRequest request, HttpServletResponse response) {
1175 LOG.debug("Initialized addLine method");
1176 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1177 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1178 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1179 OLEBatchProcessProfileBo oleBatchProcessProfileBo=(OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
1180 oleBatchProcessProfileBo.getDeletedBatchProcessProfileDeleteFieldsList().add(oleBatchProcessProfileBo.getOleBatchProcessProfileDeleteFieldsList().get(Integer.parseInt(selectedLineIndex)));
1181
1182 return deleteLine(uifForm, result, request, response);
1183
1184 }
1185 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteRenameField")
1186 public ModelAndView deleteRenameField(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1187 HttpServletRequest request, HttpServletResponse response) {
1188 LOG.debug("Initialized addLine method");
1189 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1190 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1191 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1192 OLEBatchProcessProfileBo oleBatchProcessProfileBo=(OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
1193 oleBatchProcessProfileBo.getDeletedBatchProcessProfileRenameFieldsList().add(oleBatchProcessProfileBo.getOleBatchProcessProfileRenameFieldsList().get(Integer.parseInt(selectedLineIndex)));
1194 return deleteLine(uifForm, result, request, response);
1195 }
1196 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=filterCriteriaDelete")
1197 public ModelAndView filterCriteriaDelete(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1198 HttpServletRequest request, HttpServletResponse response) {
1199 LOG.debug("Initialized addLine method");
1200 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1201 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1202 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1203 OLEBatchProcessProfileBo oleBatchProcessProfileBo=(OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
1204 oleBatchProcessProfileBo.getDeleteBatchProcessProfileFilterCriteriaList().add(oleBatchProcessProfileBo.getOleBatchProcessProfileFilterCriteriaList().get(Integer.parseInt(selectedLineIndex)));
1205 return deleteLine(uifForm, result, request, response);
1206 }
1207
1208 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=dataMappingDelete")
1209 public ModelAndView dataMappingDelete(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1210 HttpServletRequest request, HttpServletResponse response) {
1211 LOG.debug("Initialized addLine method");
1212 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1213 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1214 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1215 OLEBatchProcessProfileBo oleBatchProcessProfileBo=(OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
1216 oleBatchProcessProfileBo.getDeletedBatchProcessProfileMappingOptionsList().add(oleBatchProcessProfileBo.getOleBatchProcessProfileMappingOptionsList().get(Integer.parseInt(selectedLineIndex)));
1217 oleBatchProcessProfileBo.getDeletedBatchProcessProfileDataMappingOptionsList().addAll(oleBatchProcessProfileBo.getOleBatchProcessProfileMappingOptionsList().get(Integer.parseInt(selectedLineIndex)).getOleBatchProcessProfileDataMappingOptionsBoList());
1218 return deleteLine(uifForm, result, request, response);
1219 }
1220
1221 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=bibDataMappingDelete")
1222 public ModelAndView bibDataMappingDelete(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1223 HttpServletRequest request, HttpServletResponse response) {
1224 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1225 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1226 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1227 OLEBatchProcessProfileBo oleBatchProcessProfileBo=(OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
1228 oleBatchProcessProfileBo.getDeleteBatchProcessBibDataMappingNewList().add(oleBatchProcessProfileBo.getOleBatchProcessBibDataMappingNewList().get(Integer.parseInt(selectedLineIndex)));
1229 return deleteLine(uifForm, result, request, response);
1230 }
1231
1232 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=bibDataMappingDeleteOverlay")
1233 public ModelAndView bibDataMappingDeleteOverlay(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1234 HttpServletRequest request, HttpServletResponse response) {
1235 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1236 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1237 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1238 OLEBatchProcessProfileBo oleBatchProcessProfileBo=(OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
1239 oleBatchProcessProfileBo.getDeleteBatchProcessBibDataMappingOverlayList().add(oleBatchProcessProfileBo.getOleBatchProcessBibDataMappingOverlayList().get(Integer.parseInt(selectedLineIndex)));
1240 return deleteLine(uifForm, result, request, response);
1241 }
1242
1243 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=addLineDataMappingDelete")
1244 public ModelAndView addLineDataMappingDelete(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1245 HttpServletRequest request, HttpServletResponse response) {
1246 LOG.debug("Initialized addLine method");
1247 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1248 Map<String,String> actionParameters = form.getActionParameters();
1249 String subCollectionIndex = actionParameters.get(UifParameters.SELECTED_LINE_INDEX);
1250 String mainCollectionIndex= StringUtils.substringBefore(StringUtils.substringAfter(actionParameters.get(UifParameters.SELLECTED_COLLECTION_PATH),"["),"]");
1251 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1252 OLEBatchProcessProfileBo oleBatchProcessProfileBo=(OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
1253 OLEBatchProcessProfileDataMappingOptionsBo oleBatchProcessProfileDataMappingOptionsBo = oleBatchProcessProfileBo.getOleBatchProcessProfileMappingOptionsList().get(Integer.parseInt(mainCollectionIndex)).getOleBatchProcessProfileDataMappingOptionsBoList().get(Integer.parseInt(subCollectionIndex));
1254 if(oleBatchProcessProfileBo.getBatchProcessProfileId()!=null){
1255
1256 oleBatchProcessProfileBo.getDeletedBatchProcessProfileDataMappingOptionsList().add(oleBatchProcessProfileDataMappingOptionsBo);
1257 oleBatchProcessProfileBo.getOleBatchProcessProfileMappingOptionsList().get(Integer.parseInt(mainCollectionIndex)).getOleBatchProcessProfileDataMappingOptionsBoList().remove(Integer.parseInt(subCollectionIndex));
1258 return getUIFModelAndView(uifForm);
1259 }else{
1260 oleBatchProcessProfileBo.getDeletedBatchProcessProfileDataMappingOptionsList().add(oleBatchProcessProfileDataMappingOptionsBo);
1261 return deleteLine(uifForm, result, request, response);
1262 }
1263 }
1264
1265 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteProfileConstant")
1266 public ModelAndView deleteProfileConstant(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1267 HttpServletRequest request, HttpServletResponse response) {
1268 LOG.debug("Initialized addLine method");
1269 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1270 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1271 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1272 OLEBatchProcessProfileBo oleBatchProcessProfileBo=(OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
1273 if(oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.ORDER_RECORD_IMPORT) ||
1274 oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.INVOICE_RECORD_IMPORT)){
1275 String selectedCollectionPath = form.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH);
1276 CollectionGroup collectionGroup = form.getPostedView().getViewIndex().getCollectionGroupByPath(selectedCollectionPath);
1277 String addLinePath = collectionGroup.getAddLineBindingInfo().getBindingPath();
1278 Object eventObject = ObjectPropertyUtils.getPropertyValue(form, addLinePath);
1279 OLEBatchProcessProfileConstantsBo oleBatchProcessProfileConstantsBo = (OLEBatchProcessProfileConstantsBo ) eventObject;
1280 oleBatchProcessProfileConstantsBo.setOldAttributeName(null);
1281 }
1282 oleBatchProcessProfileBo.getDeletedBatchProcessProfileConstantsList().add(oleBatchProcessProfileBo.getOleBatchProcessProfileConstantsList().get(Integer.parseInt(selectedLineIndex)));
1283 return deleteLine(uifForm, result, request, response);
1284 }
1285
1286 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteProfileProtectedField")
1287 public ModelAndView deleteProfileProtectedField(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1288 HttpServletRequest request, HttpServletResponse response) {
1289 LOG.debug("Initialized addLine method");
1290 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1291 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1292 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1293 OLEBatchProcessProfileBo oleBatchProcessProfileBo=(OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
1294 oleBatchProcessProfileBo.getDeletedBatchProcessProfileProtectedFieldList().add(oleBatchProcessProfileBo.getOleBatchProcessProfileProtectedFieldList().get(Integer.parseInt(selectedLineIndex)));
1295 return deleteLine(uifForm, result, request, response);
1296 }
1297
1298 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteBibMatch")
1299 public ModelAndView deleteBibMatch(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1300 HttpServletRequest request, HttpServletResponse response) {
1301 LOG.debug("Initialized deleteLine method");
1302 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1303 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1304 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1305 OLEBatchProcessProfileBo oleBatchProcessProfileBo = (OLEBatchProcessProfileBo) document.getNewMaintainableObject().getDataObject();
1306 oleBatchProcessProfileBo.getDeletedBatchProcessProfileMatchPointList().add(oleBatchProcessProfileBo.getOleBatchProcessProfileBibliographicMatchPointList().get(Integer.parseInt(selectedLineIndex)));
1307 return deleteLine(uifForm, result, request, response);
1308 }
1309
1310 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteHoldingMatch")
1311 public ModelAndView deleteHoldingMatch(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1312 HttpServletRequest request, HttpServletResponse response) {
1313 LOG.debug("Initialized deleteLine method");
1314 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1315 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1316 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1317 OLEBatchProcessProfileBo oleBatchProcessProfileBo = (OLEBatchProcessProfileBo) document.getNewMaintainableObject().getDataObject();
1318 oleBatchProcessProfileBo.getDeletedBatchProcessProfileMatchPointList().add(oleBatchProcessProfileBo.getOleBatchProcessProfileHoldingMatchPointList().get(Integer.parseInt(selectedLineIndex)));
1319 return deleteLine(uifForm, result, request, response);
1320 }
1321
1322 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteItemMatch")
1323 public ModelAndView deleteItemMatch(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1324 HttpServletRequest request, HttpServletResponse response) {
1325 LOG.debug("Initialized deleteLine method");
1326 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1327 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1328 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1329 OLEBatchProcessProfileBo oleBatchProcessProfileBo = (OLEBatchProcessProfileBo) document.getNewMaintainableObject().getDataObject();
1330 oleBatchProcessProfileBo.getDeletedBatchProcessProfileMatchPointList().add(oleBatchProcessProfileBo.getOleBatchProcessProfileItemMatchPointList().get(Integer.parseInt(selectedLineIndex)));
1331 return deleteLine(uifForm, result, request, response);
1332 }
1333 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteEholdingMatch")
1334 public ModelAndView deleteEholdingMatch(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1335 HttpServletRequest request, HttpServletResponse response) {
1336 LOG.debug("Initialized deleteLine method");
1337 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1338 String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
1339 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1340 OLEBatchProcessProfileBo oleBatchProcessProfileBo = (OLEBatchProcessProfileBo) document.getNewMaintainableObject().getDataObject();
1341 oleBatchProcessProfileBo.getDeletedBatchProcessProfileMatchPointList().add(oleBatchProcessProfileBo.getOleBatchProcessProfileEholdingMatchPointList().get(Integer.parseInt(selectedLineIndex)));
1342 return deleteLine(uifForm, result, request, response);
1343 }
1344
1345 @RequestMapping(params = "methodToCall=populateExchangeRate")
1346 public ModelAndView populateExchangeRate(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
1347 HttpServletRequest request, HttpServletResponse response) throws Exception {
1348
1349 MaintenanceDocumentForm form = (MaintenanceDocumentForm) uifForm;
1350 MaintenanceDocument document = (MaintenanceDocument) form.getDocument();
1351 CollectionGroup collectionGroup = form.getPostedView().getViewIndex().getCollectionGroupByPath("document.newMaintainableObject.dataObject.oleBatchProcessProfileConstantsList");
1352 String addLinePath = collectionGroup.getAddLineBindingInfo().getBindingPath();
1353 Object eventObject = ObjectPropertyUtils.getPropertyValue(form, addLinePath);
1354 OLEBatchProcessProfileConstantsBo oleBatchProcessProfileConstantsBo = (OLEBatchProcessProfileConstantsBo ) eventObject;
1355 OLEBatchProcessProfileBo oleBatchProcessProfileBo=(OLEBatchProcessProfileBo)document.getNewMaintainableObject().getDataObject();
1356 List<OLEBatchProcessProfileConstantsBo> oleBatchProcessProfileConstantsBoList = oleBatchProcessProfileBo.getOleBatchProcessProfileConstantsList();
1357 for(int recordCount = 0; recordCount < oleBatchProcessProfileConstantsBoList.size();recordCount++) {
1358 if(oleBatchProcessProfileConstantsBoList.get(recordCount).getAttributeName().equalsIgnoreCase(OLEConstants.OLEBatchProcess.CURRENCY_TYPE)){
1359 if(!oleBatchProcessProfileConstantsBoList.get(recordCount).getAttributeValue().equalsIgnoreCase(OleSelectConstant.CURRENCY_TYPE_NAME)){
1360 String currencyTypeId = getOleInvoiceService().getCurrencyTypeIdFromCurrencyType(oleBatchProcessProfileConstantsBoList.get(recordCount).getAttributeValue());
1361 Map exchangeRateMap = new HashMap();
1362 exchangeRateMap.put(OLEConstants.OLEBatchProcess.CURRENCY_TYPE_ID,currencyTypeId);
1363 List<OleExchangeRate> exchangeRateList = (List) getBusinessObjectService().findMatchingOrderBy(
1364 OleExchangeRate.class, exchangeRateMap, OleSelectConstant.EXCHANGE_RATE_DATE, false);
1365 oleBatchProcessProfileConstantsBo.setAttributeValueText(exchangeRateList.get(0).getExchangeRate().toString());
1366 }
1367 else {
1368 oleBatchProcessProfileConstantsBo.setAttributeValueText("0.0");
1369 }
1370 break;
1371 }
1372 oleBatchProcessProfileConstantsBo.setAttributeValueText("0.0");
1373 }
1374 return getUIFModelAndView(form);
1375 }
1376
1377 }