1 package org.kuali.asr.service.impl;
2
3 import org.apache.log4j.Logger;
4 import org.kuali.asr.ASRConstants;
5 import org.kuali.asr.bo.*;
6 import org.kuali.asr.service.ASRHelperServiceImpl;
7 import org.kuali.asr.service.ASRService;
8 import org.kuali.ole.OLEConstants;
9 import org.kuali.ole.deliver.bo.ASRTypeRequest;
10 import org.kuali.ole.deliver.bo.OleDeliverRequestBo;
11 import org.kuali.ole.deliver.processor.LoanProcessor;
12 import org.kuali.ole.deliver.service.OleDeliverRequestDocumentHelperServiceImpl;
13 import org.kuali.ole.ncip.bo.OLEPlaceRequest;
14 import org.kuali.ole.ncip.converter.OLEPlaceRequestConverter;
15 import org.kuali.ole.ncip.service.impl.OLECirculationServiceImpl;
16 import org.kuali.rice.core.api.config.property.ConfigContext;
17 import org.kuali.rice.krad.service.BusinessObjectService;
18 import org.kuali.rice.krad.service.KRADServiceLocator;
19
20 import java.util.ArrayList;
21 import java.util.HashMap;
22 import java.util.List;
23 import java.util.Map;
24
25
26
27
28
29
30
31
32
33
34
35
36 public class ASRServiceImpl implements ASRService {
37 private static final Logger LOG = Logger.getLogger(ASRServiceImpl.class);
38 private ASRHelperServiceImpl asrHelperService = getAsrHelperService();
39 private BusinessObjectService businessObjectService=getBusinessObjectService();
40 private OLECirculationServiceImpl oleCirculationService=getOleCirculationService();
41 private OLEASRPlaceRequestHelperServiceImpl oleasrPlaceRequestHelperService=new OLEASRPlaceRequestHelperServiceImpl();
42 private OleDeliverRequestDocumentHelperServiceImpl oleDeliverRequestDocumentHelperService;
43 private LoanProcessor loanProcessor = new LoanProcessor();
44
45 public OleDeliverRequestDocumentHelperServiceImpl getOleDeliverRequestDocumentHelperService() {
46 if(oleDeliverRequestDocumentHelperService==null){
47 oleDeliverRequestDocumentHelperService = new OleDeliverRequestDocumentHelperServiceImpl();
48 }
49 return oleDeliverRequestDocumentHelperService ;
50 }
51
52 public void setOleDeliverRequestDocumentHelperService(OleDeliverRequestDocumentHelperServiceImpl oleDeliverRequestDocumentHelperService) {
53 this.oleDeliverRequestDocumentHelperService = oleDeliverRequestDocumentHelperService;
54 }
55
56
57
58
59 public ASRHelperServiceImpl getAsrHelperService(){
60 if(asrHelperService==null){
61 asrHelperService = new ASRHelperServiceImpl();
62 }
63 return asrHelperService;
64 }
65
66 public BusinessObjectService getBusinessObjectService(){
67 if(businessObjectService == null){
68 businessObjectService = KRADServiceLocator.getBusinessObjectService();
69 }
70 return businessObjectService;
71 }
72
73 public OLECirculationServiceImpl getOleCirculationService(){
74 if(oleCirculationService == null){
75 oleCirculationService = new OLECirculationServiceImpl();
76 }
77 return oleCirculationService;
78 }
79
80
81
82
83
84
85
86
87 @Override
88 public Object lookupNewASRItems(String operatorId) {
89 LOG.info("Inside the lookupNewASRItems method . OperatorId : "+operatorId);
90
91 if(!asrHelperService.isAuthorized(operatorId)){
92 return asrHelperService.generateResponse(ASRConstants.OPERATOR_NOT_FOUND_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.OPERATOR_NOT_FOUND), ASRConstants.SUCCESS_STATUS);
93 }
94
95 ASRItems asrItems = asrHelperService.getNewASRItems();
96 if(asrItems.getAsrItems().size()>0){
97 return asrItems;
98 }else{
99 return asrHelperService.generateResponse(ASRConstants.ITEM_NOT_FOUND_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.ITEM_NOT_FOUND), ASRConstants.SUCCESS_STATUS);
100 }
101 }
102
103
104
105
106
107
108 @Override
109 public ASRResponseBo removeASRItem(String barcode) {
110 LOG.info("Inside the removeASRItem method . Item Barcode : "+barcode);
111
112 Map<String,String> itemMap = new HashMap<String,String>();
113 itemMap.put("itemBarcode",barcode);
114 List<org.kuali.ole.deliver.bo.ASRItem> asrItems = (List<org.kuali.ole.deliver.bo.ASRItem>)businessObjectService.findMatching(org.kuali.ole.deliver.bo.ASRItem.class,itemMap);
115 if(asrItems.size() == 0){
116 return asrHelperService.generateResponse(ASRConstants.ITEM_NOT_FOUND_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.ITEM_NOT_FOUND), ASRConstants.SUCCESS_STATUS);
117 }
118 businessObjectService.delete(asrItems);
119
120 return asrHelperService.generateResponse(ASRConstants.ITEM_DELETED_CODE,ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.ITEM_DELETED) , ASRConstants.SUCCESS_STATUS);
121 }
122
123
124
125
126
127
128 @Override
129 public Object updateASRItemStatusToAvailable(UpdateASRItemRequestBo updateASRItemRequestBo) {
130 LOG.info("Inside the updateASRItemStatusToAvailable method . Item Barcode : " + updateASRItemRequestBo.getItemBarcode());
131
132 if(!asrHelperService.isAuthorized(updateASRItemRequestBo.getOperatorId())){
133 return asrHelperService.generateResponse(ASRConstants.OPERATOR_NOT_FOUND_CODE,ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.OPERATOR_NOT_FOUND) , ASRConstants.SUCCESS_STATUS);
134 }
135 if(!(updateASRItemRequestBo.getItemStatus().equals(asrHelperService.getParameter(ASRConstants.ASR_ITEM_AVAILABLE)))){
136 return asrHelperService.generateResponse(ASRConstants.STATUS_NOT_MATCH_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.STATUS_NOT_MATCH), ASRConstants.SUCCESS_STATUS);
137 }
138 List<String> resultList = new ArrayList<String>();
139 resultList.add(ASRConstants.LOCATION_LEVEL_DISPLAY);
140 String itemLocation = asrHelperService.getLocation(updateASRItemRequestBo.getItemBarcode());
141 if(itemLocation == null){
142 return asrHelperService.generateResponse(ASRConstants.ITEM_NOT_FOUND_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.ITEM_NOT_FOUND), ASRConstants.SUCCESS_STATUS);
143 }
144 if(itemLocation!=null &&!asrHelperService.isAnASRItem(itemLocation)){
145 return asrHelperService.generateResponse(ASRConstants.NOT_ASR_ITEM_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.NOT_ASR_ITEM), ASRConstants.SUCCESS_STATUS);
146 }
147
148 if(!asrHelperService.updateItemStatus(updateASRItemRequestBo.getItemBarcode(),updateASRItemRequestBo.getItemStatus())) {
149 return asrHelperService.generateResponse(ASRConstants.ITEM_STATUS_NOT_UPDATED_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.ITEM_STATUS_NOT_UPDATED), ASRConstants.SUCCESS_STATUS);
150 }else{
151 removeASRItem(updateASRItemRequestBo.getItemBarcode());
152 }
153 return null;
154 }
155
156
157
158
159
160
161 @Override
162 public ASRResponseBo placeRequestOnASRItem(PlaceASRItemRequestBo placeRequestASRItemBo) {
163 LOG.info("Inside the placeRequestOnASRItem method . Item Barcode : "+placeRequestASRItemBo.getItemBarcode() );
164
165 if(!asrHelperService.isAuthorized(placeRequestASRItemBo.getOperatorId())){
166 return asrHelperService.generateResponse(ASRConstants.OPERATOR_NOT_FOUND_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.OPERATOR_NOT_FOUND), ASRConstants.SUCCESS_STATUS);
167 }
168
169 String itemLocation = asrHelperService.getLocation(placeRequestASRItemBo.getItemBarcode());
170 if(itemLocation == null){
171 return asrHelperService.generateResponse(ASRConstants.ITEM_NOT_FOUND_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.ITEM_NOT_FOUND), ASRConstants.SUCCESS_STATUS);
172 }
173 if(itemLocation!=null &&!asrHelperService.isAnASRItem(itemLocation)){
174 return asrHelperService.generateResponse(ASRConstants.NOT_ASR_ITEM_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.NOT_ASR_ITEM), ASRConstants.SUCCESS_STATUS);
175 }
176 if(!asrHelperService.validatePickupLocation(placeRequestASRItemBo.getPickUpLocation())){
177 return asrHelperService.generateResponse(ASRConstants.INVALID_PKUP_LOCN_CD, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.INVALID_PKUP_LOCN), ASRConstants.SUCCESS_STATUS);
178 }
179
180 String requestType = loanProcessor.getParameter(ASRConstants.ASR_TYP_RQST);
181
182 String message = getOleDeliverRequestDocumentHelperService().placeRequest(placeRequestASRItemBo.getPatronId(),placeRequestASRItemBo.getOperatorId(),placeRequestASRItemBo.getItemBarcode(),requestType,placeRequestASRItemBo.getPickUpLocation(),null,null,null,null,null,null,false,null,null,null);
183
184 OLEPlaceRequestConverter olePlaceRequestConverter = new OLEPlaceRequestConverter();
185 OLEPlaceRequest olePlaceRequest = (OLEPlaceRequest)olePlaceRequestConverter.generatePlaceRequestObject(message);
186 message = olePlaceRequest.getMessage();
187 if(message.contains(OLEConstants.RQST_SUCCESS)){
188 return asrHelperService.generateResponse(ASRConstants.HOLD_PLACED_CODE, message, ASRConstants.SUCCESS_STATUS);
189 }
190 return asrHelperService.generateResponse("106",message,ASRConstants.SUCCESS_STATUS);
191 }
192
193
194
195
196
197
198
199 @Override
200 public ASRResponseBo cancelASRRequest(String holdId, String operatorId) {
201 LOG.info("Inside the ASRResponseBo method . Hold Id : "+holdId + ". OperatorId : " +operatorId);
202
203 if(!asrHelperService.isAuthorized(operatorId)){
204 return asrHelperService.generateResponse(ASRConstants.OPERATOR_NOT_FOUND_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.OPERATOR_NOT_FOUND), ASRConstants.SUCCESS_STATUS);
205 }
206
207
208 Map<String,String> requestMap = new HashMap<String,String>();
209 requestMap.put("requestId",holdId);
210 requestMap.put("requestStatus","1");
211 OleDeliverRequestBo oleDeliverRequestBo=null;
212 List<OleDeliverRequestBo> oleDeliverRequestBos = asrHelperService.getDeliverRequest(requestMap);
213 if(oleDeliverRequestBos == null ||(oleDeliverRequestBos!=null && oleDeliverRequestBos.size()==0)){
214 return asrHelperService.generateResponse(ASRConstants.REQUEST_NOT_FOUND_FOR_HOLD_ID_CODE,ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.REQUEST_NOT_FOUND_FOR_HOLD_ID) +" "+holdId, ASRConstants.SUCCESS_STATUS);
215 }else if((oleDeliverRequestBos!=null && oleDeliverRequestBos.size()>0) && businessObjectService.findMatching(ASRTypeRequest.class,requestMap).size()>0){
216
217 getOleDeliverRequestDocumentHelperService().cancelDocument(oleDeliverRequestBos.get(0));
218 return asrHelperService.generateResponse(ASRConstants.REQUEST_CANCELED_CODE,ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.REQUEST_CANCELED) , ASRConstants.SUCCESS_STATUS);
219 } else{
220 return asrHelperService.generateResponse("109","Hold is processed",404);
221 }
222 }
223
224
225
226
227
228
229
230 @Override
231 public Object lookupASRTypeRequest(String operatorId, String asrLocation) {
232 LOG.info("Inside the lookupASRTypeRequest method . OperatorId : "+operatorId +". ASRLocation :" +asrLocation);
233
234 if(!asrHelperService.isAuthorized(operatorId)){
235 return asrHelperService.generateResponse(ASRConstants.OPERATOR_NOT_FOUND_CODE,ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.OPERATOR_NOT_FOUND) , ASRConstants.SUCCESS_STATUS);
236 }
237
238 ASRRequests asrRequests= asrHelperService.getASRTypeRequest("1");
239 if(asrRequests!=null)
240 asrRequests=asrHelperService.getASRRequestBasedOnLocation(asrRequests,asrLocation);
241 if(asrRequests!=null && asrRequests.getAsrRequests()!=null && asrRequests.getAsrRequests().size()>0){
242 return asrRequests;
243 }else{
244 return asrHelperService.generateResponse(ASRConstants.REQUEST_NOT_FOUND_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.REQUEST_NOT_FOUND), ASRConstants.SUCCESS_STATUS);
245 }
246
247 }
248
249
250
251
252
253
254 @Override
255 public Object updateASRRequestStatus(UpdateASRRequestStatusBo updateASRRequestStatusBo) {
256 LOG.info("Inside the updateASRItemStatusToMissing method . Request Id : "+updateASRRequestStatusBo.getHoldId() + ". OperatorId : "+updateASRRequestStatusBo.getOperatorId() );
257 ASRTypeRequest asrTypeRequest;
258
259 if(!asrHelperService.isAuthorized(updateASRRequestStatusBo.getOperatorId())){
260 return asrHelperService.generateResponse(ASRConstants.OPERATOR_NOT_FOUND_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.OPERATOR_NOT_FOUND), ASRConstants.SUCCESS_STATUS);
261 }
262 if((updateASRRequestStatusBo.getStatus().equals(ASRConstants.ASR_REQUEST_IN_PROCESS)) || updateASRRequestStatusBo.getStatus().equals(ASRConstants.ASR_REQUEST_FAILURE)){
263
264 } else{
265 return asrHelperService.generateResponse(ASRConstants.STATUS_NOT_MATCH_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.STATUS_NOT_MATCH), ASRConstants.SUCCESS_STATUS);
266 }
267
268 List<ASRTypeRequest> asrTypeRequests = getAsrHelperService().getASRRequest("requestId",updateASRRequestStatusBo.getHoldId());
269 if(asrTypeRequests==null || (asrTypeRequests!=null && asrTypeRequests.size()==0)){
270 return asrHelperService.generateResponse(ASRConstants.REQUEST_NOT_FOUND_FOR_HOLD_ID_CODE,ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.REQUEST_NOT_FOUND_FOR_HOLD_ID) +" "+updateASRRequestStatusBo.getHoldId(), ASRConstants.SUCCESS_STATUS);
271 }else {
272 asrTypeRequest = asrTypeRequests.get(0);
273 }
274
275 if(!asrHelperService.updateRequestStatus(asrTypeRequest,updateASRRequestStatusBo.getHoldId(),updateASRRequestStatusBo.getStatus())){
276 return asrHelperService.generateResponse(ASRConstants.ITEM_STATUS_NOT_UPDATED_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.ITEM_STATUS_NOT_UPDATED), ASRConstants.SUCCESS_STATUS);
277 }
278
279 return null;
280 }
281
282
283
284
285
286
287 @Override
288 public Object updateASRItemStatusToBeingRetrieved(UpdateASRItemStatusBo updateASRItemStatusBo) {
289 LOG.info("Inside the updateASRItemStatusToMissing method . Item Barcode : "+updateASRItemStatusBo.getItemBarcode() + ". OperatorId : "+updateASRItemStatusBo.getOperatorId() );
290
291 if(!asrHelperService.isAuthorized(updateASRItemStatusBo.getOperatorId())){
292 return asrHelperService.generateResponse(ASRConstants.OPERATOR_NOT_FOUND_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.OPERATOR_NOT_FOUND), ASRConstants.SUCCESS_STATUS);
293 }
294 if(!(updateASRItemStatusBo.getItemStatus().equals(asrHelperService.getParameter(ASRConstants.ASR_ITEM_RETRIVED)))){
295 return asrHelperService.generateResponse(ASRConstants.STATUS_NOT_MATCH_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.STATUS_NOT_MATCH), ASRConstants.SUCCESS_STATUS);
296 }
297
298 String itemLocation = asrHelperService.getLocation(updateASRItemStatusBo.getItemBarcode());
299 if(itemLocation == null){
300 return asrHelperService.generateResponse(ASRConstants.ITEM_NOT_FOUND_CODE,ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.ITEM_NOT_FOUND) , ASRConstants.SUCCESS_STATUS);
301 }
302
303 if(itemLocation!=null &&!asrHelperService.isAnASRItem(itemLocation)){
304 return asrHelperService.generateResponse(ASRConstants.NOT_ASR_ITEM_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.NOT_ASR_ITEM), ASRConstants.SUCCESS_STATUS);
305 }
306
307 if(!asrHelperService.updateItemStatus(updateASRItemStatusBo.getItemBarcode(),updateASRItemStatusBo.getItemStatus())) {
308 return asrHelperService.generateResponse(ASRConstants.ITEM_STATUS_NOT_UPDATED_CODE,ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.ITEM_STATUS_NOT_UPDATED) , ASRConstants.SUCCESS_STATUS);
309 }
310 return null;
311 }
312
313
314
315
316
317
318 @Override
319 public Object updateASRItemStatusToMissing(UpdateASRItemStatusBo updateASRItemStatusBo) {
320 LOG.info("Inside the updateASRItemStatusToMissing method . Item Barcode : "+updateASRItemStatusBo.getItemBarcode() + ". OperatorId : "+updateASRItemStatusBo.getOperatorId() );
321
322 if(!asrHelperService.isAuthorized(updateASRItemStatusBo.getOperatorId())){
323 return asrHelperService.generateResponse(ASRConstants.OPERATOR_NOT_FOUND_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.OPERATOR_NOT_FOUND), ASRConstants.SUCCESS_STATUS);
324 }
325 if(!(updateASRItemStatusBo.getItemStatus().equals(asrHelperService.getParameter(ASRConstants.ASR_ITEM_MISSING)))){
326 return asrHelperService.generateResponse(ASRConstants.STATUS_NOT_MATCH_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.STATUS_NOT_MATCH), ASRConstants.SUCCESS_STATUS);
327 }
328 String itemLocation = asrHelperService.getLocation(updateASRItemStatusBo.getItemBarcode());
329 if(itemLocation == null){
330 return asrHelperService.generateResponse(ASRConstants.ITEM_NOT_FOUND_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.ITEM_NOT_FOUND), ASRConstants.SUCCESS_STATUS);
331 }
332
333 if(itemLocation!=null &&!asrHelperService.isAnASRItem(itemLocation)){
334 return asrHelperService.generateResponse(ASRConstants.NOT_ASR_ITEM_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.NOT_ASR_ITEM), ASRConstants.SUCCESS_STATUS);
335 }
336
337 if(!asrHelperService.updateItemStatus(updateASRItemStatusBo.getItemBarcode(),updateASRItemStatusBo.getItemStatus())) {
338 return asrHelperService.generateResponse(ASRConstants.ITEM_STATUS_NOT_UPDATED_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.ITEM_STATUS_NOT_UPDATED), ASRConstants.SUCCESS_STATUS);
339 }
340
341 asrHelperService.deleteASRRequest(updateASRItemStatusBo.getItemBarcode());
342 return null;
343 }
344
345
346
347
348
349
350 @Override
351 public ASRResponseBo addNewASRItem(ASRItem asrItem) {
352 LOG.info("Inside the addNewASRItem method . Item Barcode : "+asrItem.getItemBarcode());
353
354
355 String itemLocation = asrHelperService.getLocation(asrItem.getItemBarcode());
356 if(itemLocation == null){
357 return asrHelperService.generateResponse(ASRConstants.ITEM_NOT_FOUND_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.ITEM_NOT_FOUND), ASRConstants.SUCCESS_STATUS);
358 }
359
360 if(itemLocation!=null &&!asrHelperService.isAnASRItem(itemLocation)){
361 return asrHelperService.generateResponse(ASRConstants.NOT_ASR_ITEM_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.NOT_ASR_ITEM), ASRConstants.SUCCESS_STATUS);
362 }
363 if(asrHelperService.saveASRItem(asrItem)){
364 return asrHelperService.generateResponse(ASRConstants.SUCESS_REQUEST_CD,ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.SUCESS_ITEM_MESG),ASRConstants.SUCCESS_STATUS);
365 }
366
367
368 return null;
369 }
370
371
372
373
374
375
376 @Override
377 public ASRResponseBo sendASRRequest(ASRRequestBo asrRequestBo) {
378 LOG.info("Inside the sendASRRequest method . Item Barcode : "+asrRequestBo.getItemBarcode());
379
380 String itemLocation = asrHelperService.getLocation(asrRequestBo.getItemBarcode());
381 if(itemLocation == null){
382 return asrHelperService.generateResponse(ASRConstants.ITEM_NOT_FOUND_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.ITEM_NOT_FOUND), ASRConstants.SUCCESS_STATUS);
383 }
384
385 if(itemLocation!=null &&!asrHelperService.isAnASRItem(itemLocation)){
386 return asrHelperService.generateResponse(ASRConstants.NOT_ASR_ITEM_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.NOT_ASR_ITEM), ASRConstants.SUCCESS_STATUS);
387 }
388
389 if(!asrHelperService.validatePatron(asrRequestBo.getPatronBarcode())){
390 return asrHelperService.generateResponse(ASRConstants.PATRON_NOT_FOUND_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.PATRON_NOT_FOUND), ASRConstants.SUCCESS_STATUS);
391 }
392
393
394 if(!asrHelperService.validatePickupLocation(asrRequestBo.getPickupLocation())){
395 return asrHelperService.generateResponse(ASRConstants.INVALID_PKUP_LOCN_CD, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.INVALID_PKUP_LOCN), ASRConstants.SUCCESS_STATUS);
396 }
397
398 if(asrHelperService.saveASRRequest(asrRequestBo)){
399 return asrHelperService.generateResponse(ASRConstants.SUCESS_REQUEST_CD,ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.SUCESS_REQUEST_MESG),ASRConstants.SUCCESS_STATUS);
400 }else{
401 return asrHelperService.generateResponse("",ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.FAILURE_REQUEST_MESG),ASRConstants.FAILURE_STATUS);
402 }
403 }
404
405
406
407
408
409
410
411 @Override
412 public Object lookupAsrRequest(String operatorId,String itemBarcode) {
413 LOG.info("Inside the lookupAsrRequest method . Operator Id : "+operatorId +". Item Barcode : "+itemBarcode);
414 LookupASRRequestResponseBO lookupASRRequestResponseBO = new LookupASRRequestResponseBO();
415
416
417 if(!asrHelperService.isAuthorized(operatorId)){
418 return asrHelperService.generateResponse(ASRConstants.OPERATOR_NOT_FOUND_CODE,ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.OPERATOR_NOT_FOUND) , ASRConstants.SUCCESS_STATUS);
419 }
420
421 String itemLocation = asrHelperService.getLocation(itemBarcode);
422 if(itemLocation == null){
423 return asrHelperService.generateResponse(ASRConstants.ITEM_NOT_FOUND_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.ITEM_NOT_FOUND), ASRConstants.SUCCESS_STATUS);
424 }
425
426 if(itemLocation!=null &&!asrHelperService.isAnASRItem(itemLocation)){
427 return asrHelperService.generateResponse(ASRConstants.NOT_ASR_ITEM_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.NOT_ASR_ITEM), ASRConstants.SUCCESS_STATUS);
428 }
429 ASRRequestDetailsBo asrRequestDetailsBo = asrHelperService.getRequests(itemBarcode);
430 if(asrRequestDetailsBo==null){
431
432
433
434 lookupASRRequestResponseBO.setCode(ASRConstants.REQUEST_NOT_FOUND_CODE);
435 lookupASRRequestResponseBO.setMessage(ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.REQUEST_NOT_FOUND));
436 lookupASRRequestResponseBO.setStatusCode(ASRConstants.SUCCESS_STATUS);
437 } else if(asrRequestDetailsBo!=null && asrRequestDetailsBo.getAsrRequestDetailBos()!=null && asrRequestDetailsBo.getAsrRequestDetailBos().size()>0){
438 lookupASRRequestResponseBO.setCode("000");
439 lookupASRRequestResponseBO.setMessage("Successful query, holds found");
440 lookupASRRequestResponseBO.setStatusCode(ASRConstants.SUCCESS_STATUS);
441 lookupASRRequestResponseBO.setAsrRequestDetailsBo(asrRequestDetailsBo);
442 return lookupASRRequestResponseBO;
443 }
444 return lookupASRRequestResponseBO;
445 }
446
447
448
449
450
451
452 @Override
453 public ASRResponseBo receiveASRItemTransit(ReceiveTransitRequestBo receiveTransitRequestBo) {
454 LOG.info("Inside the receiveASRItemTransit method . Barcode : "+receiveTransitRequestBo.getBarcode() + " Operator Id : "+receiveTransitRequestBo.getOperatorId());
455
456 if(!asrHelperService.isAuthorized(receiveTransitRequestBo.getOperatorId())){
457 return asrHelperService.generateResponse(ASRConstants.OPERATOR_NOT_FOUND_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.OPERATOR_NOT_FOUND), ASRConstants.SUCCESS_STATUS);
458 }
459
460 String itemLocation = asrHelperService.getLocation(receiveTransitRequestBo.getBarcode());
461 if(itemLocation == null){
462 return asrHelperService.generateResponse(ASRConstants.ITEM_NOT_FOUND_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.ITEM_NOT_FOUND), ASRConstants.SUCCESS_STATUS);
463 }
464
465 if(itemLocation!=null &&!asrHelperService.isAnASRItem(itemLocation)){
466 return asrHelperService.generateResponse(ASRConstants.NOT_ASR_ITEM_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.NOT_ASR_ITEM), ASRConstants.SUCCESS_STATUS);
467 }
468 if(!asrHelperService.isAuthorized(receiveTransitRequestBo.getOperatorId())){
469 return asrHelperService.generateResponse(ASRConstants.OPERATOR_NOT_FOUND_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.OPERATOR_NOT_FOUND), ASRConstants.SUCCESS_STATUS);
470 }
471
472 boolean validLocation = asrHelperService.validateLocation(receiveTransitRequestBo.getOperatorId(),itemLocation);
473 if(validLocation){
474 if(asrHelperService.updateItemStatusForInTransit(receiveTransitRequestBo.getBarcode(),ASRConstants.AVAILABLE))
475 return asrHelperService.generateResponse(ASRConstants.ITEM_STATUS_UPDATED_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.ITEM_STATUS_UPDATED), ASRConstants.SUCCESS_STATUS);
476 else
477 return asrHelperService.generateResponse(ASRConstants.ITEM_NOT_IN_TRANSIT_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.ITEM_NOT_IN_TRANSIT), ASRConstants.SUCCESS_STATUS);
478 }else{
479 return asrHelperService.generateResponse(ASRConstants.LOCATION_MISMATCH_CODE,ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.LOCATION_MISMATCH),ASRConstants.SUCCESS_STATUS);
480 }
481 }
482
483
484
485
486
487
488 @Override
489 public ASRResponseBo checkInASRItem(ASRCheckInBo asrCheckInBo) {
490 LOG.info("Inside the checkInASRItem method : Item Barcode : "+asrCheckInBo.getItemBarcode());
491
492 String itemLocation = asrHelperService.getLocation(asrCheckInBo.getItemBarcode());
493 if(itemLocation == null){
494 return asrHelperService.generateResponse(ASRConstants.ITEM_NOT_FOUND_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.ITEM_NOT_FOUND), ASRConstants.SUCCESS_STATUS);
495 }
496
497 if(itemLocation!=null &&!asrHelperService.isAnASRItem(itemLocation)){
498 return asrHelperService.generateResponse(ASRConstants.NOT_ASR_ITEM_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.NOT_ASR_ITEM), ASRConstants.SUCCESS_STATUS);
499 }
500
501 OleDeliverRequestBo oleDeliverRequestBo = asrHelperService.getPrioritizedRequest(asrCheckInBo.getItemBarcode());
502
503 if(oleDeliverRequestBo!=null){
504 boolean validLocation=asrHelperService.isCirculationDesksLocation(itemLocation,oleDeliverRequestBo.getPickUpLocationId());
505 if(validLocation){
506 asrHelperService.updateItemStatus(asrCheckInBo.getItemBarcode(), ASRConstants.ON_HOLD);
507 return asrHelperService.generateResponse("200",ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.ITEM_STATUS_UPDATED_HOLD)+asrCheckInBo.getItemBarcode(),ASRConstants.SUCCESS_STATUS);
508 }else if(!validLocation){
509 asrHelperService.updateItemStatus(asrCheckInBo.getItemBarcode(), ASRConstants.INTRANSIT_FOR_HOLD);
510 return asrHelperService.generateResponse(ASRConstants.ITEM_STATUS_UPDATED_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.ITEM_STATUS_UPDATED)+" "+asrCheckInBo.getItemBarcode(), ASRConstants.SUCCESS_STATUS);
511
512 }
513 }else{
514 return asrHelperService.generateResponse(ASRConstants.REQUEST_NOT_FOUND_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.REQUEST_NOT_FOUND), ASRConstants.SUCCESS_STATUS);
515 }
516
517
518 return asrHelperService.generateResponse(ASRConstants.REQUEST_NOT_FOUND_CODE, ConfigContext.getCurrentContextConfig().getProperty(ASRConstants.REQUEST_NOT_FOUND), ASRConstants.SUCCESS_STATUS);
519 }
520
521
522 }