001package org.kuali.asr.processor; 002 003import org.apache.log4j.Logger; 004import org.kuali.asr.bo.*; 005import org.kuali.asr.service.ASRService; 006import org.kuali.asr.service.impl.ASRServiceImpl; 007 008import javax.ws.rs.*; 009import javax.ws.rs.core.MediaType; 010import javax.ws.rs.core.Response; 011 012/** 013 * Created with IntelliJ IDEA. 014 * User: maheswarang 015 * Date: 12/24/13 016 * Time: 7:53 PM 017 * To change this template use File | Settings | File Templates. 018 */ 019 020/** 021 * This class act as controller for processing the request made to the exposed ASr Webservice 022 */ 023@Path("/asr") 024public class ASRRequestProcessor { 025 private static final Logger LOG = Logger.getLogger(ASRRequestProcessor.class); 026 private ASRService asrService ; 027 028 public ASRService getAsrService() { 029 if(asrService==null){ 030 asrService = new ASRServiceImpl(); 031 } 032 return asrService; 033 } 034 035 public ASRRequestProcessor(){ 036 getAsrService(); 037 } 038 039 040 041 @GET 042 @Path("/lookupNewAsrItems/{operatorId}") 043 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) 044 public Response lookUpNewASRItems(@PathParam("operatorId") String operatorId){ 045 Object object = asrService.lookupNewASRItems(operatorId); 046 if(object instanceof ASRItems){ 047 return Response.status(200).entity(object).build(); 048 } else { 049 ASRResponseBo asrResponseBo = (ASRResponseBo)object; 050 return Response.status(asrResponseBo.getStatusCode()).entity(object).build(); 051 } 052 } 053 054 @GET 055 @Path("/lookupAsrRequests/{operatorId},{asrLocation}") 056 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) 057 public Response lookUpNewASRTypeRequests(@PathParam("operatorId") String operatorId,@PathParam("asrLocation") String asrLocation){ 058 Object object = asrService.lookupASRTypeRequest(operatorId, asrLocation); 059 if(object instanceof ASRRequests){ 060 return Response.status(200).entity(object).build(); 061 } else { 062 ASRResponseBo asrResponseBo = (ASRResponseBo)object; 063 return Response.status(asrResponseBo.getStatusCode()).entity(object).build(); 064 } 065 } 066 067 068 @GET 069 @Path("/lookupAsrItemHolds/{operatorId},{itemBarcode}") 070 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) 071 public Response lookUpASRRequests(@PathParam("operatorId") String operatorId,@PathParam("itemBarcode") String itemBarcode){ 072 Object object =asrService.lookupAsrRequest(operatorId,itemBarcode); 073 if(object instanceof LookupASRRequestResponseBO){ 074 LookupASRRequestResponseBO lookupASRRequestResponseBO = (LookupASRRequestResponseBO)object; 075 return Response.status(lookupASRRequestResponseBO.getStatusCode()).entity(lookupASRRequestResponseBO).build(); 076 }else{ 077 ASRResponseBo asrResponseBo = (ASRResponseBo)object; 078 return Response.status(asrResponseBo.getStatusCode()).entity(object).build(); 079 } 080 } 081 082 083 @DELETE 084 @Path("/cancelHold/{holdId},{operatorId}") 085 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) 086 public Response cancelHold(@PathParam("holdId") String holdId,@PathParam("operatorId") String operatorId){ 087 ASRResponseBo asrResponseBo = asrService.cancelASRRequest(holdId,operatorId); 088 return Response.status(asrResponseBo.getStatusCode()).entity(asrResponseBo).build(); 089 090 } 091 092 @DELETE 093 @Path("/removeASRItem/{itemBarcode}") 094 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) 095 public Response removeASRItem(@PathParam("itemBarcode") String itemBarcode){ 096 ASRResponseBo asrResponseBo = asrService.removeASRItem(itemBarcode); 097 return Response.status(asrResponseBo.getStatusCode()).entity(asrResponseBo).build(); 098 } 099 100 @POST 101 @Path("/updateASRItemStatusAvailable") 102 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) 103 public Response updateASRItemStatusToAvailable(UpdateASRItemRequestBo updateASRItemRequestBo){ 104 Object object = asrService.updateASRItemStatusToAvailable(updateASRItemRequestBo); 105 if(object==null){ 106 return Response.status(200).entity(object).build(); 107 } else if(object instanceof ASRResponseBo) { 108 ASRResponseBo asrResponseBo = (ASRResponseBo)object; 109 return Response.status(asrResponseBo.getStatusCode()).entity(asrResponseBo).build(); 110 } 111 return Response.status(200).entity("").build(); 112 } 113 114 115 @POST 116 @Path("/updateASRItemStatusMissing") 117 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) 118 public Response updateASRItemStatusToMissing(UpdateASRItemStatusBo updateASRItemStatusBo){ 119 Object object = asrService.updateASRItemStatusToMissing(updateASRItemStatusBo); 120 if(object==null){ 121 return Response.status(200).entity(object).build(); 122 } else if(object instanceof ASRResponseBo) { 123 ASRResponseBo asrResponseBo = (ASRResponseBo)object; 124 return Response.status(asrResponseBo.getStatusCode()).entity(asrResponseBo).build(); 125 } 126 return Response.status(200).entity("").build(); 127 } 128 129 @POST 130 @Path("/updateASRItemStatusBeingRetrieved") 131 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) 132 public Response updateASRItemStatus(UpdateASRItemStatusBo updateASRItemStatusBo){ 133 Object object= asrService.updateASRItemStatusToBeingRetrieved(updateASRItemStatusBo); 134 if(object==null){ 135 return Response.status(200).entity(object).build(); 136 } else if(object instanceof ASRResponseBo) { 137 ASRResponseBo asrResponseBo = (ASRResponseBo)object; 138 return Response.status(asrResponseBo.getStatusCode()).entity(asrResponseBo).build(); 139 } 140 return Response.status(200).entity("").build(); 141 } 142 143 @POST 144 @Path("/placeASRRequest") 145 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) 146 public Response placeRequestOnASRItem(PlaceASRItemRequestBo placeASRItemRequestBo){ 147 ASRResponseBo asrResponseBo = asrService.placeRequestOnASRItem(placeASRItemRequestBo); 148 return Response.status(asrResponseBo.getStatusCode()).entity(asrResponseBo).build(); 149 } 150 151 152 @POST 153 @Path("/updateASRRequest") 154 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) 155 public Response updateASRRequestStatus(UpdateASRRequestStatusBo updateASRRequestStatusBo){ 156 Object object= asrService.updateASRRequestStatus(updateASRRequestStatusBo); 157 if(object==null){ 158 return Response.status(200).entity(object).build(); 159 } else if(object instanceof ASRResponseBo) { 160 ASRResponseBo asrResponseBo = (ASRResponseBo)object; 161 return Response.status(asrResponseBo.getStatusCode()).entity(asrResponseBo).build(); 162 } 163 return Response.status(200).entity("").build(); 164 } 165 166 167 @POST 168 @Path("/addNewASRItem") 169 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) 170 public Response addNewASRItem(ASRItem asrItem){ 171 ASRResponseBo asrResponseBo = asrService.addNewASRItem(asrItem); 172 return Response.status(asrResponseBo.getStatusCode()).entity(asrResponseBo).build(); 173 } 174 175 @POST 176 @Path("/sendASRRequest") 177 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) 178 public Response sendASRRequest(ASRRequestBo asrRequestBo){ 179 ASRResponseBo asrResponseBo = asrService.sendASRRequest(asrRequestBo); 180 return Response.status(asrResponseBo.getStatusCode()).entity(asrResponseBo).build(); 181 } 182 183 @POST 184 @Path("/receiveTransitOfASRItem") 185 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) 186 public Response receiveASRItemTransit(ReceiveTransitRequestBo receiveTransitRequestBo){ 187 ASRResponseBo asrResponseBo = asrService.receiveASRItemTransit(receiveTransitRequestBo); 188 return Response.status(asrResponseBo.getStatusCode()).entity(asrResponseBo).build(); 189 } 190 191 @POST 192 @Path("/checkInASRItem") 193 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) 194 public Response checkInASRItem(ASRCheckInBo asrCheckInBo){ 195 ASRResponseBo asrResponseBo = asrService.checkInASRItem(asrCheckInBo); 196 return Response.status(asrResponseBo.getStatusCode()).entity(asrResponseBo).build(); 197 } 198 199 200}