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