diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/ImplementasiController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/ImplementasiController.java deleted file mode 100644 index c9a5fbb2..00000000 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/ImplementasiController.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.jasamedika.medifirst2000.controller; - -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.orm.jpa.JpaSystemException; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.ImplementasiService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.ImplementasiVO; - -@RestController -@RequestMapping("/implementasi") -public class ImplementasiController extends LocaleController { - - @Autowired - private ImplementasiService service; - - private static final Logger LOGGER = LoggerFactory.getLogger(ImplementasiController.class); - - @RequestMapping(value = "/save-implementasi", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> saveImplementasi(@Valid @RequestBody ImplementasiVO vo,HttpServletRequest request) { - try { - Map result = service.saveImplementasi(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); - - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when saveDiagnosisKeperawatan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when saveDiagnosisKeperawatan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - -} diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IndikatorBIOSController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IndikatorBIOSController.java deleted file mode 100644 index ed497be7..00000000 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IndikatorBIOSController.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.jasamedika.medifirst2000.controller; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.vo.IndikatorBIOSVO; - -@RestController -@RequestMapping("/indikator-bios") -public class IndikatorBIOSController extends LocaleController{ - -} diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IndikatorRensarController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IndikatorRensarController.java index 99e5a3e2..42eb00bc 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IndikatorRensarController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IndikatorRensarController.java @@ -1,123 +1,82 @@ package com.jasamedika.medifirst2000.controller; import java.util.Collection; -import java.util.HashMap; -import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; +import com.jasamedika.medifirst2000.vo.PasienVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specifications; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.jasamedika.medifirst2000.constants.Constants; import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.IBaseRestController; import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; import com.jasamedika.medifirst2000.entities.IndikatorRensar; -import com.jasamedika.medifirst2000.entities.PeriodePelaporan; import com.jasamedika.medifirst2000.exception.ServiceVOException; import com.jasamedika.medifirst2000.service.IndikatorRensarService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; import com.jasamedika.medifirst2000.vo.IndikatorRensarVO; import net.kaczmarzyk.spring.data.jpa.domain.Equal; import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec; +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; +import static org.springframework.web.bind.annotation.RequestMethod.POST; + @RestController @RequestMapping("/indikator-rensar") -public class IndikatorRensarController extends LocaleController implements IBaseRestController{ - +public class IndikatorRensarController extends LocaleController { + @Autowired private IndikatorRensarService indikatorRensarService; - - private static final Logger LOGGER = LoggerFactory - .getLogger(IndikatorRensarController.class); - - - @RequestMapping(value="/find-all/", method= RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> findAll( + + private static final Logger LOGGER = LoggerFactory.getLogger(IndikatorRensarController.class); + + @RequestMapping(value = "/find-all/", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> findAll( @RequestParam(value = "page", required = false, defaultValue = "0") Integer page, @RequestParam(value = "take", required = false, defaultValue = "100") Integer take, @RequestParam(value = "sort", required = false, defaultValue = "id") String sort, @RequestParam(value = "dir", required = false, defaultValue = "asc") String dir, @Spec(path = "id", params = "id", spec = Equal.class) Specification spec1, - @Spec(path = "sasaranStrategisId", params = "sasaranStrategisId", spec = Equal.class) Specification spec2) - { - Specification spec = Specifications.where(spec1).and(spec2); - Map result = new HashMap(); - result = indikatorRensarService.findAll(page, take, sort,dir, spec); - return constructListPageResult(result); + @Spec(path = "sasaranStrategisId", params = "sasaranStrategisId", spec = Equal.class) Specification spec2) { + Specification spec = Specifications.where(spec1).and(spec2); + Map result = indikatorRensarService.findAll(page, take, sort, dir, spec); + return constructListPageResult(result); } - @RequestMapping(value="/save/", method= RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> save(@Valid @RequestBody IndikatorRensarVO vo,HttpServletRequest request){ - try{ + @RequestMapping(value = "/save/", method = POST, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> save(@Valid @RequestBody IndikatorRensarVO vo, + HttpServletRequest request) { + try { Map result = indikatorRensarService.save(vo); - if(null!= result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); - + if (null != result) + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when add/update Indikator Kinerja Utama", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, - mapHeaderMessage); - + LOGGER.error("Got ServiceVOException {} when save", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when add/update Indikator Kinerja Utama", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, - mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when save", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } - - } - - @Override - public ResponseEntity> getAllVOWithQueryString(HttpServletRequest request, - Integer page, Integer limit, String sort, String dir) { - return null; - } - - @Override - public ResponseEntity getVO(Integer id) { - return null; - } - - @Override - public ResponseEntity addVO(IndikatorRensarVO vo) { - return null; - } - - @Override - public ResponseEntity editVO(IndikatorRensarVO vo) { - return null; - } - - @Override - public ResponseEntity deleteVO(Integer id) { - return null; - } - - @Override - public ResponseEntity> getAllVO() { - return null; } } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/InfoTambahanAntrianController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/InfoTambahanAntrianController.java deleted file mode 100644 index e7edcfcc..00000000 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/InfoTambahanAntrianController.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.jasamedika.medifirst2000.controller; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import com.jasamedika.medifirst2000.notification.antrian.InfoTambahanAntrian; -import com.jasamedika.medifirst2000.util.rest.RestUtil; - - -/** - * @author Syamsu -*/ - -@RestController -@RequestMapping({"/test-tanpa-auth/info-tambahan-antrian", "/info-tambahan-antrian"}) -public class InfoTambahanAntrianController { - - @Autowired - InfoTambahanAntrian infoAntrian; - - @RequestMapping(value="/kirim-pesan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity kirimPesankeLayar(@RequestParam("pesan") String pesan, @RequestParam("targetlayar") String targetlayar){ - try{ - infoAntrian.kirimPesan(pesan, targetlayar); - return RestUtil.getJsonResponse("Pesan berhasil terkirim", HttpStatus.OK); - }catch(Exception e){ - return RestUtil.getJsonResponse("Pesan gagal terkirim penyebab " + e.getMessage(), HttpStatus.BAD_REQUEST); - } - } - - @RequestMapping(value="/jenis-total-antrian", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity tambahTotalPerJenisAntrian(@RequestParam("label") String label, - @RequestParam("tipe") String tipe, @RequestParam("total") Integer total, - @RequestParam("hapus") boolean hapus, - @RequestParam("targetlayar") String targetlayar){ - try{ - infoAntrian.kirimJumlahAntrian(label, tipe, String.valueOf(total), hapus, targetlayar); - return RestUtil.getJsonResponse("Total antrian berhasil diinfokan", HttpStatus.OK); - }catch(Exception e){ - return RestUtil.getJsonResponse("Total antrian gagal diinfokan penyebab " + e.getMessage(), HttpStatus.BAD_REQUEST); - } - } - -} diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/InformasiTarifLayananController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/InformasiTarifLayananController.java index 4d753c8a..75c1e7d9 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/InformasiTarifLayananController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/InformasiTarifLayananController.java @@ -1,155 +1,49 @@ package com.jasamedika.medifirst2000.controller; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - import com.jasamedika.medifirst2000.constants.MessageResource; import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; +import com.jasamedika.medifirst2000.exception.ServiceVOException; import com.jasamedika.medifirst2000.service.InformasiTarifLayananService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; import com.jasamedika.medifirst2000.vo.HargaNettoProdukByKelasVO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_ERROR; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.OK; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; @RestController @RequestMapping("/informasi-tarif-layanan") -public class InformasiTarifLayananController extends LocaleController{ - +public class InformasiTarifLayananController extends LocaleController { + @Autowired private InformasiTarifLayananService service; - - private static final Logger LOGGER = LoggerFactory - .getLogger(InformasiTarifLayananController.class); - - @RequestMapping(value = "/get-tarif-layanan-ruangan/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> findTarifLayanan(HttpServletRequest request) { - Map result = null; - try{ - result = service.getInformasiTarifLayananRuangan(); - Boolean dataFound=new Boolean((boolean) result.get("dataFound")); - - if(dataFound){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request )); - } - else{ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,getMessage(MessageResource.LABEL_ERROR,request )); - } - }catch (Exception e){ - e.printStackTrace(); - } - return RestUtil.getJsonResponse(result, HttpStatus.OK); - } - - @RequestMapping(value = "/get-tarif-by-id-produk/{produkId}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> findHargaByIdProduk(@PathVariable("produkId") Integer produkId, HttpServletRequest request) { - Map result = null; - try{ - result = service.getHargaByIdProduk(produkId); - Boolean dataFound=new Boolean((boolean) result.get("dataFound")); - - if(dataFound){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request )); - } - else{ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,getMessage(MessageResource.LABEL_ERROR,request )); - } - }catch (Exception e){ - e.printStackTrace(); - } - return RestUtil.getJsonResponse(result, HttpStatus.OK); - } - - // minimized - @RequestMapping(value = "/get-tarif-layanan-by-id-produk/{produkId}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> findHargaLayananByIdProduk(@PathVariable("produkId") Integer produkId, HttpServletRequest request) { - Map result = null; - try{ - result = service.getHargaProdukByIdProdukMinimized(produkId); - Boolean dataFound=new Boolean((boolean) result.get("dataFound")); - - if(dataFound){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request )); - } - else{ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,getMessage(MessageResource.LABEL_ERROR,request )); - } - }catch (Exception e){ - e.printStackTrace(); - } - return RestUtil.getJsonResponse(result, HttpStatus.OK); - } - - @RequestMapping(value = "/get-all-tarif-produk/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> findAllHarga(HttpServletRequest request) { - Map result = null; - try{ - result = service.getAllHargaProduk(); - Boolean dataFound=new Boolean((boolean) result.get("dataFound")); - - if(dataFound){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request )); - } - else{ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,getMessage(MessageResource.LABEL_ERROR,request )); - } - }catch (Exception e){ - e.printStackTrace(); - } - - return RestUtil.getJsonResponse(result, HttpStatus.OK); - } - - @RequestMapping(value = "/get-harga-netto-by-nama-produk", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-harga-netto-by-nama-produk", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> findHargaNettoByNamaProduk( - @RequestParam(value="namaProduk", required = false, defaultValue = "") String namaProduk, + @RequestParam(value = "namaProduk", required = false, defaultValue = "") String namaProduk, HttpServletRequest request) { - Map result = null; - try{ - result = service.getHargaNettoByNamaProduk(namaProduk); - Boolean dataFound=new Boolean((boolean) result.get("dataFound")); - - if(dataFound){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request )); + try { + Map result = service.getHargaNettoByNamaProduk(namaProduk); + boolean dataFound = (boolean) result.get("dataFound"); + if (dataFound) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + } else { + mapHeaderMessage.put(LABEL_ERROR, getMessage(MessageResource.LABEL_ERROR, request)); } - else{ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,getMessage(MessageResource.LABEL_ERROR,request )); - } - }catch (Exception e){ - e.printStackTrace(); + return getJsonResponse(result, OK); + } catch (Exception e) { + throw new ServiceVOException(e.getMessage()); } - - return RestUtil.getJsonResponse(result, HttpStatus.OK); - } - - @RequestMapping(value = "/get-produk-by-detail-jenis-produk-akomodasi/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> findProdukByDetailJenisProdukAkomodasi(HttpServletRequest request) { - Map result = null; - try{ - result = service.findProdukByDetailJenisProdukAkomodasi(); - Boolean dataFound=new Boolean((boolean) result.get("dataFound")); - - if(dataFound){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request )); - } - else{ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,getMessage(MessageResource.LABEL_ERROR,request )); - } - }catch (Exception e){ - e.printStackTrace(); - } - - return RestUtil.getJsonResponse(result, HttpStatus.OK); } + } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/InseminasiController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/InseminasiController.java deleted file mode 100644 index f287baf9..00000000 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/InseminasiController.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.jasamedika.medifirst2000.controller; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.orm.jpa.JpaSystemException; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.IBaseRestController; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.InseminasiService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.InseminasiVO; - -@RestController -@RequestMapping("/inseminasi") -public class InseminasiController extends LocaleController implements IBaseRestController{ - - @Autowired - private InseminasiService inseminasiService; - - private static final Logger LOGGER = LoggerFactory - .getLogger(InseminasiController.class); - - @Override - public ResponseEntity> getAllVOWithQueryString(HttpServletRequest request, Integer page, - Integer limit, String sort, String dir) { - return null; - } - - @Override - public ResponseEntity getVO(Integer id) { - return null; - } - - @Override - public ResponseEntity addVO(InseminasiVO vo) { - return null; - } - - @Override - public ResponseEntity editVO(InseminasiVO vo) { - return null; - } - - @Override - public ResponseEntity deleteVO(Integer id) { - return null; - } - - @Override - public ResponseEntity> getAllVO() { - return null; - } - - - @RequestMapping(value = "/save-inseminasi/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> addVO(@Valid @RequestBody InseminasiVO vo, HttpServletRequest request) { - - try { - Map result=inseminasiService.saveInseminasi(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request )); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when add Inseminasi", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, - mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when add Inseminasi", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, - mapHeaderMessage); - } - } - -// @RequestMapping(value = "/update-inseminasi/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) -// public ResponseEntity> editVO(@Valid @RequestBody InseminasiVO vo, HttpServletRequest request) { -// -// try { -// Map result=inseminasiService.updateInseminasi(vo); -// if (null != result) -// mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request )); -// return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); -// } catch (ServiceVOException e) { -// LOGGER.error("Got exception {} when update Inseminasi", e.getMessage()); -// addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, -// e.getMessage()); -// return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, -// mapHeaderMessage); -// } catch (JpaSystemException jse) { -// LOGGER.error("Got exception {} when update Inseminasi", jse.getMessage()); -// addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, -// jse.getMessage()); -// return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, -// mapHeaderMessage); -// } -// } -// @SuppressWarnings("unchecked") -// @RequestMapping(value = "/find-by-noCm/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) -// public ResponseEntity> findByNoCm(@RequestParam(value = "noCm", required = false, defaultValue = "000000000000001") String noCm,HttpServletRequest request) { -// Map result = inseminasiService.findByNoCm(noCm); -// Boolean dataFound=new Boolean((boolean) result.get("dataFound")); -// if(dataFound){ -// mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request )); -// }else{ -// mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,getMessage(MessageResource.LABEL_ERROR,request )); -// } -// return RestUtil.getJsonResponse(result, HttpStatus.OK); -// } - -} diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/InstruksiController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/InstruksiController.java index 937f8538..33a9252c 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/InstruksiController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/InstruksiController.java @@ -1,74 +1,72 @@ package com.jasamedika.medifirst2000.controller; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - +import com.jasamedika.medifirst2000.constants.MessageResource; +import com.jasamedika.medifirst2000.controller.base.LocaleController; +import com.jasamedika.medifirst2000.exception.ServiceVOException; +import com.jasamedika.medifirst2000.service.InstruksiService; +import com.jasamedika.medifirst2000.vo.InstruksiCustomVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.InstruksiService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.InstruksiCustomVO; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.List; +import java.util.Map; + +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; +import static org.springframework.web.bind.annotation.RequestMethod.POST; @RestController @RequestMapping("/instruksi") public class InstruksiController extends LocaleController { - - @Autowired - private InstruksiService service; - - private static final Logger LOGGER = LoggerFactory.getLogger(InstruksiController.class); - - @RequestMapping(value = "/save-instruksi", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> saveInstruksi(@Valid @RequestBody InstruksiCustomVO vo,HttpServletRequest request) { - try { - Map result = service.saveInstruksi(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); + @Autowired + private InstruksiService service; + + private static final Logger LOGGER = LoggerFactory.getLogger(InstruksiController.class); + + @RequestMapping(value = "/save-instruksi", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) + public ResponseEntity> saveInstruksi(@Valid @RequestBody InstruksiCustomVO vo, + HttpServletRequest request) { + try { + Map result = service.saveInstruksi(vo); + if (null != result) + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when saveInstruksi", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when saveInstruksi", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when saveInstruksi", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when saveInstruksi", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/get-instruksi/{noCm}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-instruksi/{noCm}", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity>> getTindakanByIdUserAndPeriod(@PathVariable("noCm") String noCm, HttpServletRequest request) { - List> result = null; try { - - result = service.getInstruksi(noCm); - - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); + List> result = service.getInstruksi(noCm); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK); } catch (Exception e) { - e.printStackTrace(); + throw new ServiceVOException(e.getMessage()); } - return RestUtil.getJsonResponse(result, HttpStatus.OK); } + } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IntervensiController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IntervensiController.java deleted file mode 100644 index 58642932..00000000 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IntervensiController.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.jasamedika.medifirst2000.controller; - -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.orm.jpa.JpaSystemException; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.IntervensiService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.DiagnosaKeperawatanVO; -import com.jasamedika.medifirst2000.vo.IntervensiVO; - -@RestController -@RequestMapping("/intervensi") -public class IntervensiController extends LocaleController { - - @Autowired - private IntervensiService service; - - private static final Logger LOGGER = LoggerFactory.getLogger(IntervensiController.class); - - @RequestMapping(value = "/save-intervensi", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> saveIntervensi(@Valid @RequestBody IntervensiVO vo,HttpServletRequest request) { - try { - Map result = service.saveIntervensi(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); - - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when saveDiagnosisKeperawatan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when saveDiagnosisKeperawatan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } -} diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IntraOperasiAnestesiController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IntraOperasiAnestesiController.java index b929cddf..c3e213a9 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IntraOperasiAnestesiController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IntraOperasiAnestesiController.java @@ -1,127 +1,102 @@ package com.jasamedika.medifirst2000.controller; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - +import com.jasamedika.medifirst2000.constants.MessageResource; +import com.jasamedika.medifirst2000.controller.base.LocaleController; +import com.jasamedika.medifirst2000.exception.ServiceVOException; +import com.jasamedika.medifirst2000.service.IntraOperasiAnestesiService; +import com.jasamedika.medifirst2000.vo.AsuhanKeperawatanPeriOperasiHeaderVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.IntraOperasiAnestesiService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.AsuhanKeperawatanPeriOperasiHeaderVO; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.Map; + +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; +import static org.springframework.web.bind.annotation.RequestMethod.POST; @RestController @RequestMapping("/intra-operasi-anestesi") -public class IntraOperasiAnestesiController extends LocaleController { -private static final Logger LOGGER = LoggerFactory.getLogger(IntraOperasiPerawatBedahController.class); - +public class IntraOperasiAnestesiController extends LocaleController { + + private static final Logger LOGGER = LoggerFactory.getLogger(IntraOperasiAnestesiController.class); + @Autowired private IntraOperasiAnestesiService intraOperasiAnestesiService; - - @RequestMapping( - value = "/save-intra-operasi-anestesi", - method = RequestMethod.POST, - produces = MediaType.APPLICATION_JSON_VALUE, - consumes = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/save-intra-operasi-anestesi", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) public ResponseEntity> saveIntraOperasiAnestesi( @Valid @RequestBody AsuhanKeperawatanPeriOperasiHeaderVO vo, HttpServletRequest request) { - try { Map result = this.intraOperasiAnestesiService.saveInteraOperasiAnestesi(vo); - if (result != null) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - - LOGGER.error("Got exception {} when saveIntraOperasiAnestesi", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - + LOGGER.error("Got ServiceVOException {} when saveInteraOperasiAnestesi", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - - LOGGER.error("Got exception {} when saveIntraOperasiAnestesi", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping( - value = "/get-list-intra-operasi-anestesi-by-notrans", - method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getLoadDataByNoTrans( - @RequestParam(value = "notrans", required = true) String notrans, HttpServletRequest request) { - - try { - Map result = this.intraOperasiAnestesiService.getInteraOperasiAnestesi(notrans); - - if (null != result) { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage); - } else { - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage); - } - - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getLoadDataByNoTrans", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getLoadDataByNoTrans", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - + LOGGER.error("Got JpaSystemException {} when saveInteraOperasiAnestesi", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping( - value = "/get-pasien-operasi", - method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getPasienDaftarOperasi( - @RequestParam(value = "noRec", required = true) String noRec, HttpServletRequest request) { + + @RequestMapping(value = "/get-list-intra-operasi-anestesi-by-notrans", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getLoadDataByNoTrans(@RequestParam(value = "notrans") String notrans, + HttpServletRequest request) { + try { + Map result = this.intraOperasiAnestesiService.getInteraOperasiAnestesi(notrans); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); + } + } catch (ServiceVOException e) { + LOGGER.error("Got ServiceVOException {} when getInteraOperasiAnestesi", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + } catch (JpaSystemException jse) { + LOGGER.error("Got JpaSystemException {} when getInteraOperasiAnestesi", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); + } + } + + @RequestMapping(value = "/get-pasien-operasi", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getPasienDaftarOperasi(@RequestParam(value = "noRec") String noRec, + HttpServletRequest request) { try { Map result = this.intraOperasiAnestesiService.getPasienDaftarOperasi(noRec); - if (null != result) { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); } else { - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage); + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getPasienDaftarOperasi", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - + LOGGER.error("Got ServiceVOException {} when getPasienDaftarOperasi", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getPasienDaftarOperasi", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - + LOGGER.error("Got JpaSystemException {} when getPasienDaftarOperasi", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IntraOperasiPerawatBedahController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IntraOperasiPerawatBedahController.java index e51689d1..c02988de 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IntraOperasiPerawatBedahController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IntraOperasiPerawatBedahController.java @@ -1,128 +1,104 @@ package com.jasamedika.medifirst2000.controller; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - +import com.jasamedika.medifirst2000.constants.MessageResource; +import com.jasamedika.medifirst2000.controller.base.LocaleController; +import com.jasamedika.medifirst2000.exception.ServiceVOException; +import com.jasamedika.medifirst2000.service.IntraOperasiPerawatBedahService; +import com.jasamedika.medifirst2000.vo.AsuhanKeperawatanPeriOperasiHeaderVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.IntraOperasiPerawatBedahService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.AsuhanKeperawatanPeriOperasiHeaderVO; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.Map; + +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; +import static org.springframework.web.bind.annotation.RequestMethod.POST; @RestController @RequestMapping("/intra-operasi-perawat-bedah") -public class IntraOperasiPerawatBedahController extends LocaleController { +public class IntraOperasiPerawatBedahController extends LocaleController { + private static final Logger LOGGER = LoggerFactory.getLogger(IntraOperasiPerawatBedahController.class); - + @Autowired private IntraOperasiPerawatBedahService intraOperasiPerawatBedahService; - - @RequestMapping( - value = "/save-intra-operasi-bedah", - method = RequestMethod.POST, - produces = MediaType.APPLICATION_JSON_VALUE, - consumes = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/save-intra-operasi-bedah", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) public ResponseEntity> saveIntraOperasiPerawatBedah( @Valid @RequestBody AsuhanKeperawatanPeriOperasiHeaderVO vo, HttpServletRequest request) { - try { Map result = this.intraOperasiPerawatBedahService.saveInteraOperasiPerawatBedah(vo); - if (result != null) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - - LOGGER.error("Got exception {} when saveIntraOperasiPerawatBedah", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - + LOGGER.error("Got ServiceVOException {} when saveInteraOperasiPerawatBedah", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - - LOGGER.error("Got exception {} when saveIntraOperasiPerawatBedah", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } + LOGGER.error("Got JpaSystemException {} when saveInteraOperasiPerawatBedah", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); + } } - - @RequestMapping( - value = "/get-list-intra-operasi-perawat-bedah-by-notrans", - method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getLoadDataByNoTrans( - @RequestParam(value = "notrans", required = true) String notrans, HttpServletRequest request) { + @RequestMapping(value = "/get-list-intra-operasi-perawat-bedah-by-notrans", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getLoadDataByNoTrans(@RequestParam(value = "notrans") String notrans, + HttpServletRequest request) { try { Map result = this.intraOperasiPerawatBedahService.getInteraOperasiPerwatanBedah(notrans); - if (null != result) { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); } else { - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage); + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getLoadDataByNoTrans", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - + LOGGER.error("Got ServiceVOException {} when getInteraOperasiPerwatanBedah", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getLoadDataByNoTrans", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - + LOGGER.error("Got JpaSystemException {} when getInteraOperasiPerwatanBedah", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping( - value = "get-pasien-operasi", - method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getPasienDaftarOperasi( - @RequestParam(value = "noRec", required = true) String noRec, HttpServletRequest request) { + + @RequestMapping(value = "get-pasien-operasi", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getPasienDaftarOperasi(@RequestParam(value = "noRec") String noRec, + HttpServletRequest request) { try { Map result = this.intraOperasiPerawatBedahService.getPasienDaftarOperasi(noRec); - if (null != result) { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, HttpStatus.OK, mapHeaderMessage); } else { - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage); + return getJsonResponse(null, HttpStatus.NOT_FOUND, mapHeaderMessage); } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getPasienDaftarOperasi", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - + LOGGER.error("Got ServiceVOException {} when getPasienDaftarOperasi", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getPasienDaftarOperasi", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - + LOGGER.error("Got JpaSystemException {} when getPasienDaftarOperasi", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - + } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsDataAlatController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsDataAlatController.java index 84558917..e4eebe58 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsDataAlatController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsDataAlatController.java @@ -1,243 +1,101 @@ package com.jasamedika.medifirst2000.controller; -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import java.io.File; -import java.util.EnumMap; -import java.util.Map; - -import javax.imageio.ImageIO; -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - +import com.jasamedika.medifirst2000.constants.MessageResource; +import com.jasamedika.medifirst2000.controller.base.LocaleController; +import com.jasamedika.medifirst2000.exception.ServiceVOException; +import com.jasamedika.medifirst2000.service.IpsrsDataAlatService; +import com.jasamedika.medifirst2000.vo.RegistrasiAsetVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; -import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.IpsrsDataAlatService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.IpsrsSertifikatKalibrasiVO; -import com.jasamedika.medifirst2000.vo.RegistrasiAsetVO; +import javax.servlet.http.HttpServletRequest; +import java.util.Map; -import com.google.zxing.BarcodeFormat; -import com.google.zxing.EncodeHintType; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.qrcode.QRCodeWriter; -import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; @RestController @RequestMapping("/ipsrs-data-alat") -public class IpsrsDataAlatController extends LocaleController{ +public class IpsrsDataAlatController extends LocaleController { + + private static final Logger LOGGER = LoggerFactory.getLogger(IpsrsDataAlatController.class); @Autowired private IpsrsDataAlatService service; - - private static final Logger LOGGER = LoggerFactory.getLogger(IpsrsDataAlatController.class); - - @RequestMapping(value = "/get-all-registrasi-aset", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-all-registrasi-aset", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getAllRegistrasiAset(HttpServletRequest request) { try { - Map result = service.getAllRegistrasiAset(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getAllRegistrasiAset(); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getAllRegistrasiAset", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getAllRegistrasiAset", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getAllRegistrasiAset", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getAllRegistrasiAset", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/get-one-registrasi-aset", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getOneRegistrasiAset( - @RequestParam(value = "noRec", required = true) String noRec, HttpServletRequest request) { - try { - Map result = service.getOneRegistrasiAset(noRec); - if (null != result){ - //serialQRCode(noRec); - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); - } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getOneRegistrasiAset", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getOneRegistrasiAset", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/get-history-alat", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getHistoryAlat( - @RequestParam(value = "noRec", required = true) String noRec, HttpServletRequest request) { - try { - Map result = service.getHistoryAlat(noRec); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); - } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getHistoryAlat", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getHistoryAlat", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/upload-sertifikat-kalibrasi", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> uploadSertifikatKalibrasi(@Valid @RequestBody IpsrsSertifikatKalibrasiVO vo,HttpServletRequest request) { - try { - Map result = service.uploadSertifikatKalibrasi(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when uploadSertifikatKalibrasi", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when uploadSertifikatKalibrasi", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/get-sertifikat-kalibrasi", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getSertifikatKalibrasi( - @RequestParam(value = "noRec", required = true) String noRec, HttpServletRequest request) { + @RequestMapping(value = "/get-one-registrasi-aset", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getOneRegistrasiAset(@RequestParam(value = "noRec") String noRec, + HttpServletRequest request) { try { - Map result = service.getSertifikatKalibrasi(noRec); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getOneRegistrasiAset(noRec); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getSertifikatKalibrasi", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getOneRegistrasiAset", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getSertifikatKalibrasi", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getOneRegistrasiAset", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/download-sertifikat-kalibrasi", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> downloadSertifikatKalibrasi( - @RequestParam(value = "id", required = true) Integer id, HttpServletRequest request) { - try { - Map result = service.downloadSertifikatKalibrasi(id); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); - } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when downloadSertifikatKalibrasi", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when downloadSertifikatKalibrasi", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - public byte[] serialQRCode(String value){ - byte[] result = null; - try{ - String filePath = "D:/serialQRCode.png"; - int size = 250; - String fileType = "png"; - File myFile = new File(filePath); - - Map hintMap = new EnumMap(EncodeHintType.class); - hintMap.put(EncodeHintType.CHARACTER_SET, "UTF-8"); - - hintMap.put(EncodeHintType.MARGIN, 1); - hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L); - - QRCodeWriter qrCodeWriter = new QRCodeWriter(); - BitMatrix byteMatrix = qrCodeWriter.encode(value, BarcodeFormat.QR_CODE, size, size, hintMap); - int CrunchifyWidth = byteMatrix.getWidth(); - BufferedImage image = new BufferedImage(CrunchifyWidth, CrunchifyWidth, BufferedImage.TYPE_INT_RGB); - image.createGraphics(); - - Graphics2D graphics = (Graphics2D) image.getGraphics(); - graphics.setColor(Color.WHITE); - graphics.fillRect(0, 0, CrunchifyWidth, CrunchifyWidth); - graphics.setColor(Color.BLACK); - - for (int i = 0; i < CrunchifyWidth; i++) { - for (int j = 0; j < CrunchifyWidth; j++) { - if (byteMatrix.get(i, j)) { - graphics.fillRect(i, j, 1, 1); - } - } - } - ImageIO.write(image, fileType, myFile); - }catch(Exception ex){ - ex.printStackTrace(); - } - return result; - } - - @RequestMapping(value = "/get-jenis-produk", - method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-jenis-produk", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getJenisProduk(HttpServletRequest request) { try { - Map result = service.getAllJenisProdukByIpsrs(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getAllJenisProdukByIpsrs(); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getJenisProduk", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getAllJenisProdukByIpsrs", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getJenisProduk", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getAllJenisProdukByIpsrs", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - + } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsMaintenanceController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsMaintenanceController.java index c11f4f31..ddf7023e 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsMaintenanceController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsMaintenanceController.java @@ -1,263 +1,77 @@ package com.jasamedika.medifirst2000.controller; -import java.util.Map; -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; +import com.jasamedika.medifirst2000.constants.MessageResource; +import com.jasamedika.medifirst2000.controller.base.LocaleController; +import com.jasamedika.medifirst2000.exception.ServiceVOException; +import com.jasamedika.medifirst2000.service.IpsrsMaintenanceService; +import com.jasamedika.medifirst2000.vo.IpsrsPemeliharaanVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; -import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.IpsrsMaintenanceService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.IpsrsMaintenanceVO; -import com.jasamedika.medifirst2000.vo.IpsrsPemeliharaanVO; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; @RestController @RequestMapping("/ipsrs-maintenance") -public class IpsrsMaintenanceController extends LocaleController{ +public class IpsrsMaintenanceController extends LocaleController { + + private static final Logger LOGGER = LoggerFactory.getLogger(IpsrsMaintenanceController.class); @Autowired private IpsrsMaintenanceService service; - - private static final Logger LOGGER = LoggerFactory.getLogger(IpsrsMaintenanceController.class); - - @RequestMapping(value = "/get-ruangan-maintenance", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-ruangan-maintenance", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getRuanganMaintenance(HttpServletRequest request) { try { - Map result = service.getRuanganMaintenance(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getRuanganMaintenance(); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getRuanganMaintenance", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getRuanganMaintenance", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getRuanganMaintenance", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getRuanganMaintenance", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - @RequestMapping(value = "/get-aset-maintenance", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getAsetMaintenance(@RequestParam(value = "id", required = true) Integer id, HttpServletRequest request) { - try { - Map result = service.getAsetMaintenance(id); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); - } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getAsetMaintenance", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getAsetMaintenance", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/get-teknisi-maintenace", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getTeknisiMaintenance(HttpServletRequest request) { - try { - Map result = service.getTeknisiMaintenance(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); - } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getTeknisiMaintenance", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getTeknisiMaintenance", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/get-rekanan-maintenance", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/get-rekanan-maintenance", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getRekananMaintenance(HttpServletRequest request) { try { - Map result = service.getRekananMaintenance(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getRekananMaintenance(); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getRekananMaintenance", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getRekananMaintenance", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getRekananMaintenance", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/save-maintenance", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> saveMaintenance(@Valid @RequestBody IpsrsMaintenanceVO vo, HttpServletRequest request) { - try { - Map result = service.saveMaintenance(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); - - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when saveMaintenance", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when saveMaintenance", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/update-maintenance", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> updateMaintenance(@Valid @RequestBody IpsrsMaintenanceVO vo, HttpServletRequest request) { - try { - Map result = service.updateMaintenance(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); - - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when updateMaintenance", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when updateMaintenance", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/get-jadwal-pemeliharaan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getJadwalMaintenance(HttpServletRequest request) { - try { - Map result = service.getJadwalPemeliharaan(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); - } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getJadwalPemeliharaan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getJadwalPemeliharaan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/get-jadwal-kontak-service", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getJadwalKontakService(HttpServletRequest request) { - try { - Map result = service.getJadwalKontakService(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); - } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getJadwalKontakService", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getJadwalKontakService", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/get-jadwal-kalibrasi", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getJadwalKalibrasi(HttpServletRequest request) { - try { - Map result = service.getJadwalKalibrasi(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); - } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getJadwalKalibrasi", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getJadwalKalibrasi", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/get-all-aset-maintenance", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getAllAsetMaintenance(HttpServletRequest request) { - try { - Map result = service.getAllAsetMaintenance(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); - } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getAllAsetMaintenance", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getAllAsetMaintenance", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/get-alert-maintenance", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getAlertPemeliharaan(HttpServletRequest request) { - try { - Map result = service.getAlertMaintenance(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); - } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getAlertPemeliharaan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getAlertPemeliharaan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getRekananMaintenance", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsMonevMaintenanceController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsMonevMaintenanceController.java deleted file mode 100644 index 70b2aa21..00000000 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsMonevMaintenanceController.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.jasamedika.medifirst2000.controller; - -import java.util.Map; -import javax.servlet.http.HttpServletRequest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.orm.jpa.JpaSystemException; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.IpsrsMonevMaintenanceService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.IpsrsMaintenanceVO; - -@RestController -@RequestMapping("/ipsrs-monev-maintenance") -public class IpsrsMonevMaintenanceController extends LocaleController{ - - @Autowired - private IpsrsMonevMaintenanceService service; - - private static final Logger LOGGER = LoggerFactory.getLogger(IpsrsMonevMaintenanceController.class); - - @RequestMapping(value = "/get-rekanan-by-jadwal", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getRekananByJadwal(HttpServletRequest request) { - try { - Map result = service.getRekananByJadwal(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); - } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getRekananByJadwal", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getRekananByJadwal", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/get-kontak-service", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getKontakService( - @RequestParam(value = "rekananId", required = true) Integer rekananId, HttpServletRequest request) { - try { - Map result = service.getKontakService(rekananId); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); - } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getKontakService", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getKontakService", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } -} diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsPemakaianMesinController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsPemakaianMesinController.java index 451431fb..b1ed0837 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsPemakaianMesinController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsPemakaianMesinController.java @@ -1,212 +1,187 @@ package com.jasamedika.medifirst2000.controller; -import java.util.Map; -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; +import com.jasamedika.medifirst2000.constants.MessageResource; +import com.jasamedika.medifirst2000.controller.base.LocaleController; +import com.jasamedika.medifirst2000.exception.ServiceVOException; +import com.jasamedika.medifirst2000.service.IpsrsPemakaianMesinService; +import com.jasamedika.medifirst2000.vo.IpsrsPemakaianMesinVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.IpsrsPemakaianMesinService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.IpsrsPemakaianMesinVO; + +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.Map; + +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; +import static org.springframework.web.bind.annotation.RequestMethod.POST; @RestController @RequestMapping("/ipsrs-pemakaian-mesin") -public class IpsrsPemakaianMesinController extends LocaleController{ +public class IpsrsPemakaianMesinController extends LocaleController { + + private static final Logger LOGGER = LoggerFactory.getLogger(IpsrsPemakaianMesinController.class); @Autowired private IpsrsPemakaianMesinService service; - - private static final Logger LOGGER = LoggerFactory.getLogger(IpsrsPemakaianMesinController.class); - - @RequestMapping(value = "/get-login-user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-login-user/", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getLoginUser(HttpServletRequest request) { try { - Map result = service.getUserLogin(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getUserLogin(); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getPetugasPeminjamanAlat", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getUserLogin", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getPetugasPeminjamanAlat", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getUserLogin", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/get-jenis-mesin", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-jenis-mesin", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getJenisMesin(HttpServletRequest request) { try { Map result = service.getJenisMesin(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getJenisMesin", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getJenisMesin", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getJenisMesin", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getJenisMesin", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/get-data-mesin", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getDataMesin(@RequestParam(value = "id", required = true) Integer id, HttpServletRequest request) { + + @RequestMapping(value = "/get-data-mesin", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getDataMesin(@RequestParam(value = "id") Integer id, + HttpServletRequest request) { try { Map result = service.getDataMesin(id); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getDataMesin", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getDataMesin", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getDataMesin", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getDataMesin", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/get-all-pemakaian-boiler", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-all-pemakaian-boiler", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getAllPemakaianBoiler(HttpServletRequest request) { try { Map result = service.getAllPemakaianBoiler(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getAllPemakaianBoiler", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getAllPemakaianBoiler", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getAllPemakaianBoiler", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getAllPemakaianBoiler", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/get-all-pemakaian-genset", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-all-pemakaian-genset", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getAllPemakaianGenset(HttpServletRequest request) { try { Map result = service.getAllPemakaianGenset(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getAllPemakaianGenset", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getAllPemakaianGenset", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getAllPemakaianGenset", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getAllPemakaianGenset", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/save-pemakaian-mesin", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> savePemakaianMesin(@Valid @RequestBody IpsrsPemakaianMesinVO vo, HttpServletRequest request) { - try { - Map result = service.savePemakaianMesin(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); - - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when savePemakaianMesin", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when savePemakaianMesin", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/delete-pemakaian-mesin", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity deletePemakaianMesin( - @RequestParam(value = "noRec", required = true) String noRec, + + @RequestMapping(value = "/save-pemakaian-mesin", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) + public ResponseEntity> savePemakaianMesin(@Valid @RequestBody IpsrsPemakaianMesinVO vo, HttpServletRequest request) { try { - Boolean status = service.deletePemakaianMesin(noRec); - if (status){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse("noRec : "+noRec, HttpStatus.OK); - } else{ - return RestUtil.getJsonResponse("noRec : null", HttpStatus.BAD_REQUEST); - } + Map result = service.savePemakaianMesin(vo); + if (null != result) + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when deletePemakaianMesin", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when savePemakaianMesin", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when deletePemakaianMesin", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when savePemakaianMesin", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @SuppressWarnings("unchecked") + @RequestMapping(value = "/pemakaian-mesin-boiler") - public Map pemakaianMesinBoiler( + public Map pemakaianMesinBoiler( @RequestParam(value = "page", required = false, defaultValue = "0") Integer page, @RequestParam(value = "take", required = false, defaultValue = "100") Integer limit, @RequestParam(value = "sort", required = false, defaultValue = "noRec") String sort, @RequestParam(value = "dir", required = false, defaultValue = "asc") String dir, @RequestParam(value = "tanggalAwal", required = false) String tanggalAwal, @RequestParam(value = "tanggalAhir", required = false) String tanggalAhir) { - - Map resultPageMap = service.pemakaianBoiler(page, limit, sort, dir, tanggalAwal, tanggalAhir); - - return resultPageMap; + return service.pemakaianBoiler(page, limit, sort, dir, tanggalAwal, tanggalAhir); } - - @SuppressWarnings("unchecked") + @RequestMapping(value = "/pemakaian-mesin-genset") - public Map pemakaianMesinGenset( + public Map pemakaianMesinGenset( @RequestParam(value = "page", required = false, defaultValue = "0") Integer page, @RequestParam(value = "take", required = false, defaultValue = "100") Integer limit, @RequestParam(value = "sort", required = false, defaultValue = "noRec") String sort, @RequestParam(value = "dir", required = false, defaultValue = "asc") String dir, @RequestParam(value = "tanggalAwal", required = false) String tanggalAwal, @RequestParam(value = "tanggalAhir", required = false) String tanggalAhir) { - - Map resultPageMap = service.pemakaianGenset(page, limit, sort, dir, tanggalAwal, tanggalAhir); - - return resultPageMap; + return service.pemakaianGenset(page, limit, sort, dir, tanggalAwal, tanggalAhir); } + } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsPemakaianRuanganController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsPemakaianRuanganController.java index 24b43582..554f9e53 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsPemakaianRuanganController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsPemakaianRuanganController.java @@ -1,192 +1,192 @@ package com.jasamedika.medifirst2000.controller; -import java.util.Map; -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; +import com.jasamedika.medifirst2000.constants.MessageResource; +import com.jasamedika.medifirst2000.controller.base.LocaleController; +import com.jasamedika.medifirst2000.exception.ServiceVOException; +import com.jasamedika.medifirst2000.service.IpsrsPemakaianRuanganService; +import com.jasamedika.medifirst2000.vo.IpsrsPemakaianRuanganVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.IpsrsPemakaianRuanganService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.IpsrsPemakaianRuanganVO; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.Map; + +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; +import static org.springframework.web.bind.annotation.RequestMethod.POST; @RestController @RequestMapping("/ipsrs-pemakaian-ruangan") -public class IpsrsPemakaianRuanganController extends LocaleController{ +public class IpsrsPemakaianRuanganController extends LocaleController { + private static final Logger LOGGER = LoggerFactory.getLogger(IpsrsPemakaianRuanganController.class); @Autowired private IpsrsPemakaianRuanganService service; - - private static final Logger LOGGER = LoggerFactory.getLogger(IpsrsPemakaianRuanganController.class); - - @RequestMapping(value = "/get-ruangan-pemakaian", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-ruangan-pemakaian", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getRuanganPemakaian(HttpServletRequest request) { try { - Map result = service.getRuanganPemakaianRuangan(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getRuanganPemakaianRuangan(); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getRuanganPemakaian", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getRuanganPemakaianRuangan", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getRuanganPemakaian", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getRuanganPemakaianRuangan", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/get-jenis-pemakaian", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-jenis-pemakaian", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getJenisPemakaianRuangan(HttpServletRequest request) { try { - Map result = service.getJenisPemakaianRuangan(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getJenisPemakaianRuangan(); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getJenisPemakaianRuangan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getJenisPemakaianRuangan", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getJenisPemakaianRuangan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getJenisPemakaianRuangan", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/get-kapasitas-jenis-pemakaian", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getKapasitasJenisPemakaianRuangan(@RequestParam(value = "id", required = true) Integer id, HttpServletRequest request) { - try { - Map result = service.getKapasitasJenisPemakaianRuangan(id); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); - } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getKapasitasJenisPemakaianRuangan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getSatuanPgetKapasitasJenisPemakaianRuanganemakaian", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/save-pemakaian-ruangan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> savePemakaianRuangan(@Valid @RequestBody IpsrsPemakaianRuanganVO vo, HttpServletRequest request) { - try { - Map result = service.savePemakaianRuangan(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when savePemakaianRuangan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when savePemakaianRuangan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/get-all-pemakaian-ruangan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getAllPemakaianRuangan(HttpServletRequest request) { - try { - Map result = service.getAllPemakaianRuangan(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); - } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getAllPemakaianRuangan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getAllPemakaianRuangan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/delete-pemakaian-ruangan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity deletePemakaianRuangan( - @RequestParam(value = "noRec", required = true) String noRec, + @RequestMapping(value = "/get-kapasitas-jenis-pemakaian", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getKapasitasJenisPemakaianRuangan(@RequestParam(value = "id") Integer id, HttpServletRequest request) { try { - Boolean status = service.deletePemakaianRuangan(noRec); - if (status){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse("noRec : "+noRec, HttpStatus.OK); - } else{ - return RestUtil.getJsonResponse("noRec : null", HttpStatus.BAD_REQUEST); - } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when deletePemakaianRuangan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when deletePemakaianRuangan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/find-by-periode", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> findDaftarPemakaianRuanganByPeriode( - @RequestParam(value = "periodeAwal", required = true) String periodeAwal, - @RequestParam(value = "periodeAkhir", required = true) String periodeAkhir, - @RequestParam(value = "id", required = true) Integer id, HttpServletRequest request) { - try { - Map result = service.findDaftarPemakaianRuanganByPeriode(periodeAwal, periodeAkhir, id); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getKapasitasJenisPemakaianRuangan(id); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when findDaftarKendaraanDinasByPeriode", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getKapasitasJenisPemakaianRuangan", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when findDaftarKendaraanDinasByPeriode", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getKapasitasJenisPemakaianRuangan", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @SuppressWarnings("unchecked") + + @RequestMapping(value = "/save-pemakaian-ruangan", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) + public ResponseEntity> savePemakaianRuangan(@Valid @RequestBody IpsrsPemakaianRuanganVO vo, + HttpServletRequest request) { + try { + Map result = service.savePemakaianRuangan(vo); + if (null != result) + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); + } catch (ServiceVOException e) { + LOGGER.error("Got ServiceVOException {} when savePemakaianRuangan", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + } catch (JpaSystemException jse) { + LOGGER.error("Got JpaSystemException {} when savePemakaianRuangan", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); + } + } + + @RequestMapping(value = "/get-all-pemakaian-ruangan", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getAllPemakaianRuangan(HttpServletRequest request) { + try { + Map result = service.getAllPemakaianRuangan(); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); + } + } catch (ServiceVOException e) { + LOGGER.error("Got ServiceVOException {} when getAllPemakaianRuangan", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + } catch (JpaSystemException jse) { + LOGGER.error("Got JpaSystemException {} when getAllPemakaianRuangan", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); + } + } + + @RequestMapping(value = "/delete-pemakaian-ruangan", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity deletePemakaianRuangan(@RequestParam(value = "noRec") String noRec, + HttpServletRequest request) { + try { + boolean status = service.deletePemakaianRuangan(noRec); + if (status) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse("noRec : " + noRec, OK); + } else { + return getJsonResponse("noRec : null", HttpStatus.BAD_REQUEST); + } + } catch (ServiceVOException e) { + LOGGER.error("Got ServiceVOException {} when deletePemakaianRuangan", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + } catch (JpaSystemException jse) { + LOGGER.error("Got JpaSystemException {} when deletePemakaianRuangan", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); + } + } + + @RequestMapping(value = "/find-by-periode", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> findDaftarPemakaianRuanganByPeriode( + @RequestParam(value = "periodeAwal") String periodeAwal, + @RequestParam(value = "periodeAkhir") String periodeAkhir, @RequestParam(value = "id") Integer id, + HttpServletRequest request) { + try { + Map result = service.findDaftarPemakaianRuanganByPeriode(periodeAwal, periodeAkhir, id); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); + } + } catch (ServiceVOException e) { + LOGGER.error("Got ServiceVOException {} when findDaftarPemakaianRuanganByPeriode", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + } catch (JpaSystemException jse) { + LOGGER.error("Got JpaSystemException {} when findDaftarPemakaianRuanganByPeriode", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); + } + } + @RequestMapping(value = "/pemakaian-air") - public Map pemakaianMesinGenset( + public Map pemakaianMesinGenset( @RequestParam(value = "page", required = false, defaultValue = "0") Integer page, @RequestParam(value = "take", required = false, defaultValue = "100") Integer limit, @RequestParam(value = "sort", required = false, defaultValue = "noRec") String sort, @@ -194,9 +194,7 @@ public class IpsrsPemakaianRuanganController extends LocaleController resultPageMap = service.pemakaianAir(page, limit, sort, dir, tanggalAwal, tanggalAhir,ruanganId); - - return resultPageMap; + return service.pemakaianAir(page, limit, sort, dir, tanggalAwal, tanggalAhir, ruanganId); } + } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsPeminjamanAlatController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsPeminjamanAlatController.java index 5643df02..b1bd7b50 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsPeminjamanAlatController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsPeminjamanAlatController.java @@ -1,248 +1,205 @@ package com.jasamedika.medifirst2000.controller; -import java.util.Map; -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; +import com.jasamedika.medifirst2000.constants.MessageResource; +import com.jasamedika.medifirst2000.controller.base.LocaleController; +import com.jasamedika.medifirst2000.exception.ServiceVOException; +import com.jasamedika.medifirst2000.service.IpsrsPeminjamanAlatService; +import com.jasamedika.medifirst2000.vo.IpsrsPeminjamanAlatVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.IpsrsPeminjamanAlatService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.IpsrsPeminjamanAlatVO; + +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.Map; + +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; +import static org.springframework.web.bind.annotation.RequestMethod.POST; @RestController @RequestMapping("/ipsrs-peminjaman-alat") -public class IpsrsPeminjamanAlatController extends LocaleController{ +public class IpsrsPeminjamanAlatController extends LocaleController { + + private static final Logger LOGGER = LoggerFactory.getLogger(IpsrsPeminjamanAlatController.class); @Autowired private IpsrsPeminjamanAlatService service; - - private static final Logger LOGGER = LoggerFactory.getLogger(IpsrsPeminjamanAlatController.class); - - @RequestMapping(value = "/get-login-user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-login-user/", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getLoginUser(HttpServletRequest request) { try { - Map result = service.getUserLogin(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getUserLogin(); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getPetugasPeminjamanAlat", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getUserLogin", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getPetugasPeminjamanAlat", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemExceptions {} when getUserLogin", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/get-no-peminjaman-alat", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-no-peminjaman-alat", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getNoOrder(HttpServletRequest request) { try { Map result = service.getNoPeminjamanAlatTable(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getJadwalPemeliharaan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getNoPeminjamanAlatTable", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getJadwalPemeliharaan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getNoPeminjamanAlatTable", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/get-ruangan-peminjaman-alat", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-ruangan-peminjaman-alat", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getRuanganPeminjamanAlat(HttpServletRequest request) { try { Map result = service.getRuanganPeminjamanAlat(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getRuanganPeminjamanAlat", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getRuanganPeminjamanAlat", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getRuanganPeminjamanAlat", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getRuanganPeminjamanAlat", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/get-aset-peminjaman-alat", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getAsetPeminjamanAlat(@RequestParam(value = "id", required = true) Integer id, HttpServletRequest request) { + + @RequestMapping(value = "/get-aset-peminjaman-alat", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getAsetPeminjamanAlat(@RequestParam(value = "id") Integer id, + HttpServletRequest request) { try { - Map result = service.getAsetPeminjamanAlat(id); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getAsetPeminjamanAlat(id); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getAsetPeminjamanAlat", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getAsetPeminjamanAlat", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getAsetPeminjamanAlat", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getAsetPeminjamanAlat", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/get-petugas-peminjaman-alat", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-petugas-peminjaman-alat", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getPetugasPeminjamanAlat(HttpServletRequest request) { try { - Map result = service.getPetugasPeminjamanAlat(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getPetugasPeminjamanAlat(); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getPetugasPeminjamanAlat", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getPetugasPeminjamanAlat", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getPetugasPeminjamanAlat", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getPetugasPeminjamanAlat", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/save-peminjaman-alat", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> savePemeliharaan(@Valid @RequestBody IpsrsPeminjamanAlatVO vo, HttpServletRequest request) { - try { - Map result = service.savePeminjamanAlat(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when savePemeliharaan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when savePemeliharaan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/get-all-peminjaman-alat", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getAllPeminjamanAlat(@RequestParam(value = "status", required = true) String status, + @RequestMapping(value = "/save-peminjaman-alat", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) + public ResponseEntity> savePemeliharaan(@Valid @RequestBody IpsrsPeminjamanAlatVO vo, HttpServletRequest request) { try { - Map result = service.getAllPeminjamanAlat(status); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); - } + Map result = service.savePeminjamanAlat(vo); + if (null != result) + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getAllPeminjamanAlat", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when savePeminjamanAlat", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getAllPeminjamanAlat", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when savePeminjamanAlat", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/delete-pemakaian-ruangan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity deletePeminjamanAlat( - @RequestParam(value = "noRec", required = true) String noRec, + + @RequestMapping(value = "/get-all-peminjaman-alat", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getAllPeminjamanAlat(@RequestParam(value = "status") String status, HttpServletRequest request) { try { - Boolean status = service.deletePeminjamanAlat(noRec); - if (status){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse("noRec : "+noRec, HttpStatus.OK); - } else{ - return RestUtil.getJsonResponse("noRec : null", HttpStatus.BAD_REQUEST); - } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when deletePeminjamanAlat", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when deletePeminjamanAlat", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/find-by-periode", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> findPeminjamanAlatByPeriode( - @RequestParam(value = "periodeAwal", required = true) String periodeAwal, - @RequestParam(value = "periodeAkhir", required = true) String periodeAkhir, - @RequestParam(value = "id", required = true) Integer id, - @RequestParam(value = "status", required = true) String status, HttpServletRequest request) { - try { - Map result = service.findPeminjamanAlatByPeriode(periodeAwal, periodeAkhir, id, status); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getAllPeminjamanAlat(status); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when findPeminjamanAlatByPeriode", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getAllPeminjamanAlat", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when findPeminjamanAlatByPeriode", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getAllPeminjamanAlat", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/update-status-peminjaman", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> updateStatusPeminjaman(@Valid @RequestBody IpsrsPeminjamanAlatVO vo, HttpServletRequest request) { - try { - Map result = service.updateStatusPeminjaman(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); + @RequestMapping(value = "/update-status-peminjaman", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) + public ResponseEntity> updateStatusPeminjaman(@Valid @RequestBody IpsrsPeminjamanAlatVO vo, + HttpServletRequest request) { + try { + Map result = service.updateStatusPeminjaman(vo); + if (null != result) + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when updateStatusPeminjaman", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when updateStatusPeminjaman", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when updateStatusPeminjaman", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when updateStatusPeminjaman", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsPerbaikanController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsPerbaikanController.java index 436596f6..bc388622 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsPerbaikanController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsPerbaikanController.java @@ -9,10 +9,12 @@ import com.jasamedika.medifirst2000.vo.IpsrsPerbaikanVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; @@ -20,7 +22,7 @@ import java.util.Map; import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; -import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttptatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; import static org.springframework.http.HttpStatus.*; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @@ -31,11 +33,11 @@ import static org.springframework.web.bind.annotation.RequestMethod.POST; @RequestMapping("/ipsrs-perbaikan") public class IpsrsPerbaikanController extends LocaleController { + private static final Logger LOGGER = LoggerFactory.getLogger(IpsrsPerbaikanController.class); + @Autowired private IpsrsPerbaikanService service; - private static final Logger LOGGER = LoggerFactory.getLogger(IpsrsPerbaikanController.class); - @RequestMapping(value = "/save-permintaan-perbaikan", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) public ResponseEntity> savePermintaanPerbaikan(@Valid @RequestBody IpsrsPerbaikanVO vo, HttpServletRequest request) { @@ -52,11 +54,11 @@ public class IpsrsPerbaikanController extends LocaleController } catch (ServiceVOException e) { LOGGER.error("Got ServiceVOException {} when savePermintaanPerbaikan", e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage()); - return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { LOGGER.error("Got JpaSystemException {} when savePermintaanPerbaikan", jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); - return getJsonHttptatus(CONFLICT, mapHeaderMessage); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } @@ -73,11 +75,11 @@ public class IpsrsPerbaikanController extends LocaleController } catch (ServiceVOException e) { LOGGER.error("Got ServiceVOException {} when getRuanganPerbaikan", e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage()); - return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { LOGGER.error("Got JpaSystemException {} when getRuanganPerbaikan", jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); - return getJsonHttptatus(CONFLICT, mapHeaderMessage); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } @@ -95,11 +97,11 @@ public class IpsrsPerbaikanController extends LocaleController } catch (ServiceVOException e) { LOGGER.error("Got ServiceVOException {} when getAsetPerbaikan", e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage()); - return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { LOGGER.error("Got JpaSystemException {} when getAsetPerbaikan", jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); - return getJsonHttptatus(CONFLICT, mapHeaderMessage); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } @@ -117,11 +119,11 @@ public class IpsrsPerbaikanController extends LocaleController } catch (ServiceVOException e) { LOGGER.error("Got ServiceVOException {} when getOnePermintaanPerbaikan", e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage()); - return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { LOGGER.error("Got JpaSystemException {} when getOnePermintaanPerbaikan", jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); - return getJsonHttptatus(CONFLICT, mapHeaderMessage); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } @@ -136,11 +138,11 @@ public class IpsrsPerbaikanController extends LocaleController } catch (ServiceVOException e) { LOGGER.error("Got ServiceVOException {} when savePelaksanaanPerbaikan", e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage()); - return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { LOGGER.error("Got JpaSystemException {} when savePelaksanaanPerbaikan", jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); - return getJsonHttptatus(CONFLICT, mapHeaderMessage); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } @@ -156,13 +158,13 @@ public class IpsrsPerbaikanController extends LocaleController } catch (ServiceVOException e) { LOGGER.error("Got ServiceVOException {} when updatePermintaanPerbaikan", e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage()); - return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { LOGGER.error("Got JpaSystemException {} when updatePermintaanPerbaikan", jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); - return getJsonHttptatus(CONFLICT, mapHeaderMessage); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } - return getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE); + return getJsonHttpStatus(NOT_ACCEPTABLE); } } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsPreventiveMaintenanceController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsPreventiveMaintenanceController.java index 32ca6924..4f9bb91b 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsPreventiveMaintenanceController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsPreventiveMaintenanceController.java @@ -1,143 +1,124 @@ package com.jasamedika.medifirst2000.controller; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - +import com.jasamedika.medifirst2000.constants.MessageResource; +import com.jasamedika.medifirst2000.controller.base.LocaleController; +import com.jasamedika.medifirst2000.exception.ServiceVOException; +import com.jasamedika.medifirst2000.service.IpsrsPreventiveMaintenanceService; +import com.jasamedika.medifirst2000.vo.IpsrsPemeliharaanVO; +import com.jasamedika.medifirst2000.vo.IpsrsPreventiveMaintenanceVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.IpsrsPreventiveMaintenanceService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.IpsrsPemeliharaanVO; -import com.jasamedika.medifirst2000.vo.IpsrsPreventiveMaintenanceVO; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.Map; + +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; +import static org.springframework.web.bind.annotation.RequestMethod.POST; @RestController @RequestMapping("/ipsrs-preventive-maintenance") -public class IpsrsPreventiveMaintenanceController extends LocaleController{ +public class IpsrsPreventiveMaintenanceController extends LocaleController { + + private static final Logger LOGGER = LoggerFactory.getLogger(IpsrsPreventiveMaintenanceController.class); - @Autowired private IpsrsPreventiveMaintenanceService service; - - private static final Logger LOGGER = LoggerFactory.getLogger(IpsrsPreventiveMaintenanceController.class); - - @RequestMapping(value = "/get-login-user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getLoginUser(HttpServletRequest request) { - try { - Map result = service.getUserLogin(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); - } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getPetugasPeminjamanAlat", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getPetugasPeminjamanAlat", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/get-aset-preventive-maintenance", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-aset-preventive-maintenance", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getAsetPreventiveMaintenance(HttpServletRequest request) { try { - Map result = service.getAsetPreventiveMaintenance(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getAsetPreventiveMaintenance(); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getAllRegistrasi", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getAsetPreventiveMaintenance", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getAllRegistrasi", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getAsetPreventiveMaintenance", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/get-bagian-alat", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getBagianAlat(@RequestParam(value = "id", required = true) Integer id, HttpServletRequest request) { - try { - Map result = service.getBagianAlat(id); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); - } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getBagianAlat", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getBagianAlat", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/save-preventive-maintenance", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> saveMaintenance(@Valid @RequestBody IpsrsPreventiveMaintenanceVO vo, HttpServletRequest request) { - try { - Map result = service.savePreventiveMaintenance(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); + @RequestMapping(value = "/get-bagian-alat", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getBagianAlat(@RequestParam(value = "id") Integer id, + HttpServletRequest request) { + try { + Map result = service.getBagianAlat(id); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); + } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when saveMaintenance", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getBagianAlat", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when saveMaintenance", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getBagianAlat", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/get-user-verifikasi", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/save-preventive-maintenance", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) + public ResponseEntity> saveMaintenance(@Valid @RequestBody IpsrsPreventiveMaintenanceVO vo, + HttpServletRequest request) { + try { + Map result = service.savePreventiveMaintenance(vo); + if (null != result) + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); + } catch (ServiceVOException e) { + LOGGER.error("Got ServiceVOException {} when savePreventiveMaintenance", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + } catch (JpaSystemException jse) { + LOGGER.error("Got JpaSystemException {} when savePreventiveMaintenance", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); + } + } + + @RequestMapping(value = "/get-user-verifikasi", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getUserVerifikasi(HttpServletRequest request) { try { - Map result = service.getUserVerifikasi(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getUserVerifikasi(); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getUserVerifikasi", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getUserVerifikasi", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getUserVerifikasi", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getUserVerifikasi", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } + } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsTagihanBusinessCenterController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsTagihanBusinessCenterController.java index 4bed5ce9..70ca0e6a 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsTagihanBusinessCenterController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/IpsrsTagihanBusinessCenterController.java @@ -1,185 +1,190 @@ package com.jasamedika.medifirst2000.controller; -import java.util.Map; -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; +import com.jasamedika.medifirst2000.constants.MessageResource; +import com.jasamedika.medifirst2000.controller.base.LocaleController; +import com.jasamedika.medifirst2000.exception.ServiceVOException; +import com.jasamedika.medifirst2000.service.IpsrsTagihanBusinessCenterService; +import com.jasamedika.medifirst2000.vo.IpsrsTagihanBusinessCenterVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.IpsrsTagihanBusinessCenterService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.IpsrsTagihanBusinessCenterVO; + +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.Map; + +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; +import static org.springframework.web.bind.annotation.RequestMethod.POST; @RestController @RequestMapping("/ipsrs-tagihan-business-center") -public class IpsrsTagihanBusinessCenterController extends LocaleController{ +public class IpsrsTagihanBusinessCenterController extends LocaleController { + + private static final Logger LOGGER = LoggerFactory.getLogger(IpsrsTagihanBusinessCenterController.class); @Autowired private IpsrsTagihanBusinessCenterService service; - - private static final Logger LOGGER = LoggerFactory.getLogger(IpsrsTagihanBusinessCenterController.class); - - @RequestMapping(value = "/get-ruangan-business-center", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-ruangan-business-center", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getRuanganTagihanBusinessCenter(HttpServletRequest request) { try { - Map result = service.getRuanganTagihanBusinessCenter(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getRuanganTagihanBusinessCenter(); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getRuanganTagihanBusinessCenter", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getRuanganTagihanBusinessCenter", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getRuanganTagihanBusinessCenter", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getRuanganTagihanBusinessCenter", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/get-jenis-business-center", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-jenis-business-center", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getJenisPemakaianBusinessCenter(HttpServletRequest request) { try { - Map result = service.getJenisPemakaianBusinessCenter(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getJenisPemakaianBusinessCenter(); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getJenisPemakaianBusinessCenter", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getJenisPemakaianBusinessCenter", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getJenisPemakaianBusinessCenter", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getJenisPemakaianBusinessCenter", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/get-kapasitas-jenis-business-center", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getKapasitasJenisPemakaianBusinessCenter(@RequestParam(value = "id", required = true) Integer id, HttpServletRequest request) { - try { - Map result = service.getKapasitasJenisPemakaianBusinessCenter(id); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); - } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getKapasitasJenisPemakaianBusinessCenter", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getKapasitasJenisPemakaianBusinessCenter", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/save-business-center", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> saveBusinessCenter(@Valid @RequestBody IpsrsTagihanBusinessCenterVO vo, HttpServletRequest request) { - try { - Map result = service.saveTagihanBusinessCenter(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when saveBusinessCenter", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when saveBusinessCenter", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/get-all-business-center", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getAllBusinessCenter(HttpServletRequest request) { + @RequestMapping(value = "/get-kapasitas-jenis-business-center", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getKapasitasJenisPemakaianBusinessCenter( + @RequestParam(value = "id") Integer id, HttpServletRequest request) { try { - Map result = service.getAllTagihanBusinessCenter(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getKapasitasJenisPemakaianBusinessCenter(id); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getAllBusinessCenter", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getKapasitasJenisPemakaianBusinessCenter", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getAllBusinessCenter", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getKapasitasJenisPemakaianBusinessCenter", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/delete-business-center", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity deleteBusinessCenter( - @RequestParam(value = "noRec", required = true) String noRec, + + @RequestMapping(value = "/save-business-center", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) + public ResponseEntity> saveBusinessCenter(@Valid @RequestBody IpsrsTagihanBusinessCenterVO vo, HttpServletRequest request) { try { - Boolean status = service.deleteTagihanBusinessCenter(noRec); - if (status){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse("noRec : "+noRec, HttpStatus.OK); - } else{ - return RestUtil.getJsonResponse("noRec : null", HttpStatus.BAD_REQUEST); - } + Map result = service.saveTagihanBusinessCenter(vo); + if (null != result) + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when deleteBusinessCenter", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when saveTagihanBusinessCenter", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when deleteBusinessCenter", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when saveTagihanBusinessCenter", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/find-by-periode", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> findTagihanBusinessCenterByPeriode( - @RequestParam(value = "periodeAwal", required = true) String periodeAwal, - @RequestParam(value = "periodeAkhir", required = true) String periodeAkhir, - @RequestParam(value = "id", required = true) Integer id, HttpServletRequest request) { + + @RequestMapping(value = "/get-all-business-center", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getAllBusinessCenter(HttpServletRequest request) { try { - Map result = service.findTagihanBusinessCenterByPeriode(periodeAwal, periodeAkhir, id); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getAllTagihanBusinessCenter(); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when findTagihanBusinessCenterByPeriode", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getAllTagihanBusinessCenter", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when findTagihanBusinessCenterByPeriode", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getAllTagihanBusinessCenter", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } + + @RequestMapping(value = "/delete-business-center", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity deleteBusinessCenter(@RequestParam(value = "noRec") String noRec, + HttpServletRequest request) { + try { + boolean status = service.deleteTagihanBusinessCenter(noRec); + if (status) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse("noRec : " + noRec, OK); + } else { + return getJsonResponse("noRec : null", BAD_REQUEST); + } + } catch (ServiceVOException e) { + LOGGER.error("Got ServiceVOException {} when deleteTagihanBusinessCenter", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + } catch (JpaSystemException jse) { + LOGGER.error("Got JpaSystemException {} when deleteTagihanBusinessCenter", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); + } + } + + @RequestMapping(value = "/find-by-periode", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> findTagihanBusinessCenterByPeriode( + @RequestParam(value = "periodeAwal") String periodeAwal, + @RequestParam(value = "periodeAkhir") String periodeAkhir, @RequestParam(value = "id") Integer id, + HttpServletRequest request) { + try { + Map result = service.findTagihanBusinessCenterByPeriode(periodeAwal, periodeAkhir, id); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); + } + } catch (ServiceVOException e) { + LOGGER.error("Got ServiceVOException {} when findTagihanBusinessCenterByPeriode", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + } catch (JpaSystemException jse) { + LOGGER.error("Got JpaSystemException {} when findTagihanBusinessCenterByPeriode", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); + } + } + } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/ItJadwalPerawatanController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/ItJadwalPerawatanController.java index 3113e82e..d0760c36 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/ItJadwalPerawatanController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/ItJadwalPerawatanController.java @@ -1,74 +1,57 @@ package com.jasamedika.medifirst2000.controller; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - import com.jasamedika.medifirst2000.constants.MessageResource; import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; import com.jasamedika.medifirst2000.dto.ItJadwalPerawatanDto; -import com.jasamedika.medifirst2000.dto.PenerimaanLinenDto; import com.jasamedika.medifirst2000.service.ItJadwalPerawatanService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; +import static org.springframework.http.HttpStatus.OK; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; +import static org.springframework.web.bind.annotation.RequestMethod.POST; @RestController @RequestMapping("/it-jadwal-perawatan") -public class ItJadwalPerawatanController extends LocaleController{ +public class ItJadwalPerawatanController extends LocaleController { + @Autowired private ItJadwalPerawatanService itJadwalPerawatanService; - - @RequestMapping(value="/save-jadwal", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> saveJadwalPerawatan( - @RequestBody ItJadwalPerawatanDto dto, HttpServletRequest request) { + + @RequestMapping(value = "/save-jadwal", method = POST, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> saveJadwalPerawatan(@RequestBody ItJadwalPerawatanDto dto, + HttpServletRequest request) { Map result = this.itJadwalPerawatanService.saveJadwalPerawatan(dto); if (!result.isEmpty()) { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); } - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } - -// @RequestMapping(value = "/get-jadwal-perawatan", -// method = RequestMethod.GET, -// produces = MediaType.APPLICATION_JSON_VALUE) -// public Map getJadwalPerawatanIt( -// @RequestParam(value = "startDate") String startDate, -// @RequestParam(value = "endDate") String endDate -// ) { -// Map result = this.itJadwalPerawatanService.getJadwalPerawatanAll(startDate, endDate); -// return result; -// } - - @RequestMapping(value = "/get-jadwal-perawatan-by-norec", - method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - public Map getJadwalPerawatanByNoRec( - @RequestParam(value = "noRec") String noRec) { - Map result = this.itJadwalPerawatanService.getJadwalPerawatanbyNoRec(noRec); - return result; + + @RequestMapping(value = "/get-jadwal-perawatan-by-norec", method = GET, produces = APPLICATION_JSON_VALUE) + public Map getJadwalPerawatanByNoRec(@RequestParam(value = "noRec") String noRec) { + return this.itJadwalPerawatanService.getJadwalPerawatanbyNoRec(noRec); } - - @RequestMapping(value="/save-realisasi-jadwal", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> saveRealisasiJadwalPerawatan( - @RequestBody ItJadwalPerawatanDto dto, HttpServletRequest request) { + + @RequestMapping(value = "/save-realisasi-jadwal", method = POST, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> saveRealisasiJadwalPerawatan(@RequestBody ItJadwalPerawatanDto dto, + HttpServletRequest request) { Map result = this.itJadwalPerawatanService.saveRealisasiJadwalPerawatan(dto); if (!result.isEmpty()) { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); } - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/ItPerbaikanController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/ItPerbaikanController.java index 3c298e68..7372cbc7 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/ItPerbaikanController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/ItPerbaikanController.java @@ -23,7 +23,7 @@ import java.util.Map; import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; -import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttptatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; import static org.springframework.http.HttpStatus.*; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @@ -34,11 +34,11 @@ import static org.springframework.web.bind.annotation.RequestMethod.POST; @RequestMapping("/it-perbaikan") public class ItPerbaikanController extends LocaleController { + private static final Logger LOGGER = LoggerFactory.getLogger(ItPerbaikanController.class); + @Autowired private ItPerbaikanService service; - private static final Logger LOGGER = LoggerFactory.getLogger(ItPerbaikanController.class); - @RequestMapping(value = "/get-no-order", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getNoOrder(HttpServletRequest request) { try { @@ -50,13 +50,13 @@ public class ItPerbaikanController extends LocaleController { return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got ServiceVOException {} when get no order", e.getMessage()); + LOGGER.error("Got ServiceVOException {} when getNoOrderTable", e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage()); - return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got JpaSystemException {} when get no order", jse.getMessage()); + LOGGER.error("Got JpaSystemException {} when getNoOrderTable", jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); - return getJsonHttptatus(CONFLICT, mapHeaderMessage); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } @@ -74,13 +74,13 @@ public class ItPerbaikanController extends LocaleController { mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got ServiceVOException {} when save permintaan perbaikan", e.getMessage()); + LOGGER.error("Got ServiceVOException {} when savePermintaanPerbaikan", e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage()); - return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got JpaSystemException {} when save permintaan perbaikan", jse.getMessage()); + LOGGER.error("Got JpaSystemException {} when savePermintaanPerbaikan", jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); - return getJsonHttptatus(CONFLICT, mapHeaderMessage); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } @@ -95,13 +95,13 @@ public class ItPerbaikanController extends LocaleController { return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got ServiceVOException {} when find ruangan asset", e.getMessage()); + LOGGER.error("Got ServiceVOException {} when getRuanganPerbaikan", e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage()); - return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got JpaSystemException {} when find ruangan asset", jse.getMessage()); + LOGGER.error("Got JpaSystemException {} when getRuanganPerbaikan", jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); - return getJsonHttptatus(CONFLICT, mapHeaderMessage); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } @@ -117,13 +117,13 @@ public class ItPerbaikanController extends LocaleController { return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got ServiceVOException {} when find asset by ruangan", e.getMessage()); + LOGGER.error("Got ServiceVOException {} when getAsetPerbaikan", e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage()); - return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got JpaSystemException {} when find asset by ruangan", jse.getMessage()); + LOGGER.error("Got JpaSystemException {} when getAsetPerbaikan", jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); - return getJsonHttptatus(CONFLICT, mapHeaderMessage); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } @@ -136,13 +136,13 @@ public class ItPerbaikanController extends LocaleController { mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got ServiceVOException {} when save pelaksanaan perbaikan", e.getMessage()); + LOGGER.error("Got ServiceVOException {} when savePelaksanaanPerbaikanRev1", e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage()); - return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got JpaSystemException {} when save pelaksanaan perbaikan", jse.getMessage()); + LOGGER.error("Got JpaSystemException {} when savePelaksanaanPerbaikanRev1", jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); - return getJsonHttptatus(CONFLICT, mapHeaderMessage); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } @@ -158,13 +158,13 @@ public class ItPerbaikanController extends LocaleController { return getJsonResponse("noRec : null", HttpStatus.BAD_REQUEST); } } catch (ServiceVOException e) { - LOGGER.error("Got ServiceVOException {} when delete list perbaikan", e.getMessage()); + LOGGER.error("Got ServiceVOException {} when deleteItPerbaikan", e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage()); - return getJsonHttptatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got JpaSystemException {} when delete list perbaikan", jse.getMessage()); + LOGGER.error("Got JpaSystemException {} when deleteItPerbaikan", jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); - return getJsonHttptatus(CONFLICT, mapHeaderMessage); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JabatanController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JabatanController.java index 3108048d..369947bd 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JabatanController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JabatanController.java @@ -1,178 +1,109 @@ package com.jasamedika.medifirst2000.controller; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - +import com.jasamedika.medifirst2000.constants.MessageResource; +import com.jasamedika.medifirst2000.controller.base.LocaleController; +import com.jasamedika.medifirst2000.exception.ServiceVOException; +import com.jasamedika.medifirst2000.service.JabatanService; +import com.jasamedika.medifirst2000.vo.JabatanVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.IBaseRestController; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.JabatanService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.AgamaVO; -import com.jasamedika.medifirst2000.vo.JabatanVO; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.Map; + +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; +import static org.springframework.web.bind.annotation.RequestMethod.POST; @RestController @RequestMapping("/jabatan") -public class JabatanController extends LocaleController implements IBaseRestController { +public class JabatanController extends LocaleController { + + private static final Logger LOGGER = LoggerFactory.getLogger(JabatanController.class); @Autowired private JabatanService jabatanService; - private static final Logger LOGGER = LoggerFactory.getLogger(JabatanController.class); - - @Override - public ResponseEntity> getAllVOWithQueryString(HttpServletRequest request, Integer page, - Integer limit, String sort, String dir) { - return null; - } - - @Override - public ResponseEntity getVO(Integer id) { - return null; - } - - @RequestMapping(value = "/save-jabatan-internal/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/save-jabatan-internal/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) public ResponseEntity addVO(@Valid @RequestBody JabatanVO vo, HttpServletRequest request) { try { - - Map result = jabatanService.saveJabatan(vo);// saveJabatanInternal(vo); - - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result.toString(), HttpStatus.CREATED, mapHeaderMessage); + Map result = jabatanService.saveJabatan(vo); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result.toString(), CREATED, mapHeaderMessage); + } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when add Agama", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when saveJabatan", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when add Agama", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when saveJabatan", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } - + return getJsonHttpStatus(NOT_ACCEPTABLE); } - @RequestMapping(value = "/update-jabatan/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/update-jabatan/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) public ResponseEntity editVO(@Valid @RequestBody JabatanVO vo) { try { - JabatanVO result = (JabatanVO) jabatanService.update(vo); - + JabatanVO result = jabatanService.update(vo); if (null != result) - return RestUtil.getJsonResponse("", HttpStatus.OK); + return getJsonResponse("", OK); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when update Agama", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when update", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when update Agama", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when update", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } - - return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE); + return getJsonHttpStatus(NOT_ACCEPTABLE); } - - @RequestMapping(value = "/update-jabatan-false/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/update-jabatan-false/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) public ResponseEntity editFalseVO(@Valid @RequestBody JabatanVO vo) { try { - JabatanVO result = (JabatanVO) jabatanService.deleteJabatan(vo); - + JabatanVO result = jabatanService.deleteJabatan(vo); if (null != result) - return RestUtil.getJsonResponse("", HttpStatus.OK); + return getJsonResponse("", OK); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when update Agama", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when deleteJabatan", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when update Agama", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when deleteJabatan", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } - - return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE); + return getJsonHttpStatus(NOT_ACCEPTABLE); } - @RequestMapping(value = "/delete-jabatan/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity deleteVO(@RequestParam(value = "id", required = true) Integer id, - HttpServletRequest request) { + @RequestMapping(value = "/delete-jabatan/", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity deleteVO(@RequestParam(value = "id") Integer id, HttpServletRequest request) { try { boolean result = jabatanService.delete(id); - - return RestUtil.getJsonResponse(String.valueOf(result), HttpStatus.CREATED); - + return getJsonResponse(String.valueOf(result), CREATED); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when delete Jabatan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when delete", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when delete Jabatan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when delete", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - @SuppressWarnings("unchecked") - @RequestMapping(value = "/search-jabatan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getAllVOWithQueryString( - @RequestParam(value = "page", required = false, defaultValue = "0") Integer page, - @RequestParam(value = "limit", required = false, defaultValue = "10") Integer limit, - @RequestParam(value = "sort", required = false, defaultValue = "id") String sort, - @RequestParam(value = "dir", required = false, defaultValue = "asc") String dir) { - Map resultPageMap = jabatanService.findAllWithPageAndLimitAndSortByAndDirectionParameter(page, - limit, sort, dir); - - return constructListPageResult(resultPageMap); - } - - @Override - public ResponseEntity addVO(JabatanVO vo) { - return null; - } - - @Override - public ResponseEntity> getAllVO() { - return null; - } - - @RequestMapping(value = "/get-all-jabatan-struktural", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity>> getAllJabatanStruktural(HttpServletRequest request) { - List> result = null; - try { - - result = jabatanService.getJabatanStruktural(); - - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - } catch (Exception e) { - e.printStackTrace(); - } - return RestUtil.getJsonResponse(result, HttpStatus.OK); - } - - @Override - public ResponseEntity deleteVO(Integer id) { - return null; - } - } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JadwalDokterController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JadwalDokterController.java index 577bfae6..58f90d6d 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JadwalDokterController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JadwalDokterController.java @@ -1,450 +1,182 @@ package com.jasamedika.medifirst2000.controller; -import java.io.PrintWriter; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; - +import com.jasamedika.medifirst2000.constants.MessageResource; +import com.jasamedika.medifirst2000.controller.base.LocaleController; +import com.jasamedika.medifirst2000.exception.ServiceVOException; +import com.jasamedika.medifirst2000.service.JadwalDokterService; +import com.jasamedika.medifirst2000.vo.JadwalDokter_VO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.IBaseRestController; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.entities.JadwalDokter; -import com.jasamedika.medifirst2000.entities.Ruangan; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.util.DateUtil; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.service.JadwalDokterService; -import com.jasamedika.medifirst2000.service.PegawaiService; -import com.jasamedika.medifirst2000.service.RuanganService; -import com.jasamedika.medifirst2000.vo.JadwalDokter_VO; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.List; +import java.util.Map; + +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_ERROR; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.DateUtil.toDate; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; +import static org.springframework.web.bind.annotation.RequestMethod.POST; @RestController @RequestMapping("/jadwalDokter") -public class JadwalDokterController extends LocaleController - implements IBaseRestController { +public class JadwalDokterController extends LocaleController { + + private static final Logger LOGGER = LoggerFactory.getLogger(JadwalDokterController.class); @Autowired private JadwalDokterService jadwalDokterService; - @Autowired - private RuanganService ruanganService; - @Autowired - private PegawaiService pegawaiService; - private static final Logger LOGGER = LoggerFactory.getLogger(JadwalDokterController.class); - - @Override - public ResponseEntity> getAllVOWithQueryString(HttpServletRequest request, Integer page, - Integer limit, String sort, String dir) { - return null; - } - - @Override - public ResponseEntity getVO(Integer id) { - return null; - } - - @Override - public ResponseEntity addVO(JadwalDokter_VO vo) { - return null; - } - - @Override - public ResponseEntity editVO(JadwalDokter_VO vo) { - return null; - } - - @Override - public ResponseEntity deleteVO(Integer id) { - return null; - } - - @Override - public ResponseEntity> getAllVO() { - return null; - } - - @RequestMapping(value = "/save-jadwal-dokter/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/save-jadwal-dokter/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) public ResponseEntity> addVO(@Valid @RequestBody JadwalDokter_VO vo, HttpServletRequest request) { - try { Map result = jadwalDokterService.saveJadwalDokter(vo); if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when add Catatan Perkembangan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when saveJadwalDokter", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when add Catatan Perkembangan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when saveJadwalDokter", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - @RequestMapping(value = "/delete-jadwal-dokter/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> deleteVO(@Valid @RequestBody JadwalDokter_VO vo, HttpServletRequest request) { - - try { - Map result=jadwalDokterService.deleteJadwalDokter(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request )); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when add Catatan Perkembangan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, - mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when add Catatan Perkembangan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, - mapHeaderMessage); - } - } - - @RequestMapping(value = "/save-all-jadwal-dokter/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/save-all-jadwal-dokter/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) public ResponseEntity> addAllVO(@Valid @RequestBody List vos, HttpServletRequest request) { - try { Map result = jadwalDokterService.saveListJadwalDokter(vos); if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when add Catatan Perkembangan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when saveListJadwalDokter", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when add Catatan Perkembangan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when saveListJadwalDokter", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - @RequestMapping(value = "/update-all-jadwal-dokter/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/update-all-jadwal-dokter/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) public ResponseEntity> updateAllVo(@Valid @RequestBody List vos, HttpServletRequest request) { - try { Map result = jadwalDokterService.updateListJadwalDokter(vos); if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when add Catatan Perkembangan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when updateListJadwalDokter", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when add Catatan Perkembangan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when updateListJadwalDokter", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - @RequestMapping(value = "/update-jadwal-dokter/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> editVO(@Valid @RequestBody JadwalDokter_VO vo, - HttpServletRequest request) { - - try { - Map result = jadwalDokterService.updateJadwalDokter(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when update Catatan Perkembangan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when update Catatan Perkembangan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/save-list-jadwal-dokter/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> addListVO(@Valid @RequestBody List vos, - HttpServletRequest request) { - - try { - Map result = jadwalDokterService.saveListJadwalDokter(vos); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when add jadwal-dokter", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when add jadwal-dokter", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/save-jadwal-supir/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> addJadwalSupirVO(@Valid @RequestBody JadwalDokter_VO vo, - HttpServletRequest request) { - - try { - Map result = jadwalDokterService.saveJadwalSupirAmbulance(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when add jadwal-dokter", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when add jadwal-dokter", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/find-by-tanggal/{tglJadwal}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> findByTanggal(@PathVariable("tglJadwal") String tanggalJadwal, - HttpServletRequest request) { - Map result = jadwalDokterService.findByTanggal(DateUtil.toDate(tanggalJadwal)); - Boolean dataFound = new Boolean((boolean) result.get("dataFound")); - if (dataFound) { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - } else { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR, - getMessage(MessageResource.LABEL_ERROR, request)); - } - - return RestUtil.getJsonResponse(result, HttpStatus.OK); - } - - @RequestMapping(value = "/find-by-ruangan/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/find-by-ruangan/{id}", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> findByNoCm(@PathVariable("id") Integer id, HttpServletRequest request) { Map result = jadwalDokterService.findByRuangan(id); - Boolean dataFound = new Boolean((boolean) result.get("dataFound")); + boolean dataFound = (boolean) result.get("dataFound"); if (dataFound) { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); } else { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR, - getMessage(MessageResource.LABEL_ERROR, request)); + mapHeaderMessage.put(LABEL_ERROR, getMessage(MessageResource.LABEL_ERROR, request)); } - - return RestUtil.getJsonResponse(result, HttpStatus.OK); + return getJsonResponse(result, OK); } - @RequestMapping(value = "/find-by-ruangan-tanggal/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/find-by-ruangan-tanggal/", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> findByNoCmtglJadwal( @RequestParam(value = "id", required = false) Integer id, @RequestParam(value = "tglJadwal", required = false) String tanggalJadwal, HttpServletRequest request) { - - Map result = jadwalDokterService.findJadwalByTanggalRuangan(DateUtil.toDate(tanggalJadwal), id); - Boolean dataFound = new Boolean((boolean) result.get("dataFound")); + Map result = jadwalDokterService.findJadwalByTanggalRuangan(toDate(tanggalJadwal), id); + boolean dataFound = (boolean) result.get("dataFound"); if (dataFound) { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); } else { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR, - getMessage(MessageResource.LABEL_ERROR, request)); + mapHeaderMessage.put(LABEL_ERROR, getMessage(MessageResource.LABEL_ERROR, request)); } - - return RestUtil.getJsonResponse(result, HttpStatus.OK); + return getJsonResponse(result, OK); } - - @RequestMapping(value = "/find-by-antrian-tanggal/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/find-by-antrian-tanggal/", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> findByNoCmtglJadwal( @RequestParam(value = "noRec", required = false) String noRec, @RequestParam(value = "tglJadwal", required = false) String tanggalJadwal, HttpServletRequest request) { - - Map result = jadwalDokterService.findJadwalByTanggalRuangan(DateUtil.toDate(tanggalJadwal), noRec); - Boolean dataFound = new Boolean((boolean) result.get("dataFound")); + Map result = jadwalDokterService.findJadwalByTanggalRuangan(toDate(tanggalJadwal), noRec); + boolean dataFound = (boolean) result.get("dataFound"); if (dataFound) { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); } else { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR, - getMessage(MessageResource.LABEL_ERROR, request)); + mapHeaderMessage.put(LABEL_ERROR, getMessage(MessageResource.LABEL_ERROR, request)); } + return getJsonResponse(result, OK); + } - return RestUtil.getJsonResponse(result, HttpStatus.OK); - } - /* * create by iwan date : 21.04.2017 */ - @RequestMapping( - value = "/find-by-periode-ruangan-dokter", - method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/find-by-periode-ruangan-dokter", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> findJadwalDokterByPeriodRuangan( @RequestParam(value = "iddok", required = false) final int iddok, - @RequestParam(value = "id", required = false) final int id, + @RequestParam(value = "id", required = false) final int id, @RequestParam(value = "from", required = false) final String from, - @RequestParam(value = "to", required = false) final String to, - final HttpServletRequest request) { - - Map result = this.jadwalDokterService.findJadwalDokterByKisaranTglRuangan(iddok, id, DateUtil.toDate(from), DateUtil.toDate(to)); - - Boolean dataFound = new Boolean((boolean) result.get("dataFound")); - + @RequestParam(value = "to", required = false) final String to, final HttpServletRequest request) { + Map result = this.jadwalDokterService.findJadwalDokterByKisaranTglRuangan(iddok, id, + toDate(from), toDate(to)); + boolean dataFound = (boolean) result.get("dataFound"); if (dataFound) { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + } else { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_ERROR, request)); } - else { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_ERROR, request)); - } - return RestUtil.getJsonResponse(result, HttpStatus.OK); + return getJsonResponse(result, OK); } - - /* - * create by iwan date : 21.04.2017 - */ - @RequestMapping( - value = "/find-by-periode-ruangan-all-dokter", - method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> findJadwalDokterByPeriodRuangan( - @RequestParam(value = "iddok", required = false) final int iddok, - @RequestParam(value = "from", required = false) final String from, - @RequestParam(value = "to", required = false) final String to, - final HttpServletRequest request) { - - Map result = this.jadwalDokterService.findJadwalDokterByKisaranTglRuanganAll(iddok, DateUtil.toDate(from), DateUtil.toDate(to)); - - Boolean dataFound = new Boolean((boolean) result.get("dataFound")); - - if (dataFound) { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - } - else { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_ERROR, request)); - } - return RestUtil.getJsonResponse(result, HttpStatus.OK); - } - - @RequestMapping(value = "/get-jadwal-dokter-by-id", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-jadwal-dokter-by-id", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getJadwalDokterByIdDokter( @RequestParam(value = "id", required = false) Integer id, HttpServletRequest request) { Map result = jadwalDokterService.getJadwalDokterByIdDokter(id); - Boolean dataFound = new Boolean((boolean) result.get("dataFound")); + boolean dataFound = (boolean) result.get("dataFound"); if (dataFound) { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); } else { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR, - getMessage(MessageResource.LABEL_ERROR, request)); + mapHeaderMessage.put(LABEL_ERROR, getMessage(MessageResource.LABEL_ERROR, request)); } - - return RestUtil.getJsonResponse(result, HttpStatus.OK); + return getJsonResponse(result, OK); } - @RequestMapping(value = "/get-jadwal-dokter-mingguan-by-id/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getJadwalDokterMingguanByIdDokter( - @RequestParam(value = "id", required = false) Integer id, HttpServletRequest request) { - Map result = jadwalDokterService.getJadwalDokterMingguanByIdDokter(id); - Boolean dataFound = new Boolean((boolean) result.get("dataFound")); - if (dataFound) { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - } else { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR, - getMessage(MessageResource.LABEL_ERROR, request)); - } - - return RestUtil.getJsonResponse(result, HttpStatus.OK); - } - - @RequestMapping(value = "/get-jadwal-supir-ambulance/{bulan}/{tahun}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/get-jadwal-supir-ambulance/{bulan}/{tahun}", method = GET, produces = APPLICATION_JSON_VALUE) public List> getAllInformasi(@PathVariable("bulan") Integer bulan, @PathVariable("tahun") Integer tahun, HttpServletRequest request) { - List> result = null; - result = jadwalDokterService.getJadwalSupirAmbulanceByPeriode(bulan, tahun); - return result; + return jadwalDokterService.getJadwalSupirAmbulanceByPeriode(bulan, tahun); } - @RequestMapping(value = "/get-jadwal-supir-ambulance/{id}/{bulan}/{tahun}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/get-jadwal-supir-ambulance/{id}/{bulan}/{tahun}", method = GET, produces = APPLICATION_JSON_VALUE) public List> getJadwalByIdAndPeriode(@PathVariable("id") Integer id, @PathVariable("bulan") Integer bulan, @PathVariable("tahun") Integer tahun, HttpServletRequest request) { - List> result = null; - result = jadwalDokterService.getJadwalSupirAmbulanByIdAndPeriode(id, bulan, tahun); - return result; + return jadwalDokterService.getJadwalSupirAmbulanByIdAndPeriode(id, bulan, tahun); } - @RequestMapping(value = "/get-jadwal-by-date/{tanggal}/{bulan}/{tahun}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getJadwalByDate(@PathVariable("tanggal") Integer tanggal, - @PathVariable("bulan") Integer bulan, @PathVariable("tahun") Integer tahun, HttpServletRequest request) { - Map result = null; - try { - result = jadwalDokterService.getJadwalSupirByDate(tanggal, bulan, tahun); - Boolean dataFound = new Boolean((boolean) result.get("dataFound")); - - if (dataFound) { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - } else { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR, - getMessage(MessageResource.LABEL_ERROR, request)); - } - } catch (Exception e) { - e.printStackTrace(); - } - return RestUtil.getJsonResponse(result, HttpStatus.OK); - } - /* Author : Lukman Hakim - * */ - @RequestMapping(value = "/get-pegawai-by-ruangan/{ruangan}/{tahun}/{bulan}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getPegawaiByRuangan(@PathVariable("ruangan") Integer ruangan, - @PathVariable("tahun") Integer tahun, @PathVariable("bulan") Integer bulan, HttpServletRequest request) { - Map result = null; - try { - result = pegawaiService.findPegawaiByRuanganRev(ruangan, tahun, bulan); - - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - - } catch (Exception e) { - e.printStackTrace(); - } - return RestUtil.getJsonResponse(result, HttpStatus.OK); - } } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JadwalDpjpRawatInapController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JadwalDpjpRawatInapController.java index 7d17d34d..c6747a5d 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JadwalDpjpRawatInapController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JadwalDpjpRawatInapController.java @@ -1,71 +1,64 @@ package com.jasamedika.medifirst2000.controller; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - +import com.jasamedika.medifirst2000.constants.MessageResource; +import com.jasamedika.medifirst2000.controller.base.LocaleController; +import com.jasamedika.medifirst2000.exception.ServiceVOException; +import com.jasamedika.medifirst2000.service.JadwalDpjpRawatInapService; +import com.jasamedika.medifirst2000.vo.JadwalDpjpRawatInapVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.JadwalDpjpRawatInapService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.JadwalDpjpRawatInapVO; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.List; +import java.util.Map; + +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.POST; @RestController @RequestMapping("/jadwal-dpjp") -public class JadwalDpjpRawatInapController extends LocaleController{ - - @Autowired - private JadwalDpjpRawatInapService service; - +public class JadwalDpjpRawatInapController extends LocaleController { + private static final Logger LOGGER = LoggerFactory.getLogger(JadwalDpjpRawatInapController.class); - @RequestMapping(value = "/save-jadwal-dpjp", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> save(@Valid @RequestBody JadwalDpjpRawatInapVO vo, HttpServletRequest request) { - try { - Map result = service.save(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); + @Autowired + private JadwalDpjpRawatInapService service; + @RequestMapping(value = "/save-jadwal-dpjp", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) + public ResponseEntity> save(@Valid @RequestBody JadwalDpjpRawatInapVO vo, + HttpServletRequest request) { + try { + Map result = service.save(vo); + if (null != result) + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when save", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when save", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when save", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when save", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - + @RequestMapping(value = "/get-jadwal-dpjp") @ResponseBody - public List> getJadwalDPJP( - @RequestParam(value = "id", required = false) Integer id) { + public List> getJadwalDPJP(@RequestParam(value = "id", required = false) Integer id) { return service.getAll(id); } - - - + @RequestMapping(value = "/get-load-data-dpjp") @ResponseBody public Map getLoadDataDpjp() { diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JadwalRencanaPemeriksaanController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JadwalRencanaPemeriksaanController.java index f785228c..e8adf260 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JadwalRencanaPemeriksaanController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JadwalRencanaPemeriksaanController.java @@ -1,141 +1,78 @@ package com.jasamedika.medifirst2000.controller; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - +import com.jasamedika.medifirst2000.constants.MessageResource; +import com.jasamedika.medifirst2000.controller.base.LocaleController; +import com.jasamedika.medifirst2000.exception.ServiceVOException; +import com.jasamedika.medifirst2000.service.JadwalRencanaPemeriksaanService; +import com.jasamedika.medifirst2000.vo.JadwalRencanaPemeriksaanVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.IBaseRestController; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.JadwalRencanaPemeriksaanService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.JadwalRencanaPemeriksaanVO; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.Map; + +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; +import static org.springframework.web.bind.annotation.RequestMethod.POST; @RestController @RequestMapping("/jadwal-rencana-pemeriksaan") -public class JadwalRencanaPemeriksaanController extends LocaleController implements -IBaseRestController{ +public class JadwalRencanaPemeriksaanController extends LocaleController { + + private static final Logger LOGGER = LoggerFactory.getLogger(JadwalRencanaPemeriksaanController.class); @Autowired private JadwalRencanaPemeriksaanService rencanaPemeriksaanService; - - private static final Logger LOGGER = LoggerFactory - .getLogger(PegawaiController.class); - - - @RequestMapping(value="/find-all/",method= RequestMethod.GET) - public ResponseEntity> findAll(@RequestParam(value="id") Integer id, HttpServletRequest request){ - try{ - Map result = rencanaPemeriksaanService.findAllJadwal(); - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request )); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - }catch (ServiceVOException e) { - LOGGER.error("Got exception {} when get all jadwal", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when get all jadwal", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - @RequestMapping(value="/find-all-by-date-satuan-kerja/{bulan}/{tahun}/{satuanKerjaId}",method= RequestMethod.GET) - public ResponseEntity> findByDateSatuanKerja( - @PathVariable("bulan") Integer bulan, - @PathVariable("tahun") Integer tahun, - @PathVariable("satuanKerjaId") Integer satuanKerjaId, - HttpServletRequest request){ - try{ - Map result = rencanaPemeriksaanService.findByDateSatuanKerjaId(bulan, tahun, satuanKerjaId); - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request )); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - }catch (ServiceVOException e) { - LOGGER.error("Got exception {} when get all jadwal by Date", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when get all jadwal by Date", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value="/save-jadwal/", method= RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> saveJadwal(@Valid @RequestBody JadwalRencanaPemeriksaanVO vo, HttpServletRequest request) - { - try{ - Map result = rencanaPemeriksaanService.saveJadwal(vo); - if(null!= result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); - + @RequestMapping(value = "/find-all-by-date-satuan-kerja/{bulan}/{tahun}/{satuanKerjaId}", method = GET) + public ResponseEntity> findByDateSatuanKerja(@PathVariable("bulan") Integer bulan, + @PathVariable("tahun") Integer tahun, @PathVariable("satuanKerjaId") Integer satuanKerjaId, + HttpServletRequest request) { + try { + Map result = rencanaPemeriksaanService.findByDateSatuanKerjaId(bulan, tahun, satuanKerjaId); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when add jadwal", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, - mapHeaderMessage); - + LOGGER.error("Got ServiceVOException {} when findByDateSatuanKerjaId", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when add jadwal", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, - mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when findByDateSatuanKerjaId", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - @Override - public ResponseEntity> getAllVOWithQueryString(HttpServletRequest request, - Integer page, Integer limit, String sort, String dir) { - return null; + @RequestMapping(value = "/save-jadwal/", method = POST, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> saveJadwal(@Valid @RequestBody JadwalRencanaPemeriksaanVO vo, + HttpServletRequest request) { + try { + Map result = rencanaPemeriksaanService.saveJadwal(vo); + if (null != result) + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); + } catch (ServiceVOException e) { + LOGGER.error("Got ServiceVOException {} when saveJadwal", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + } catch (JpaSystemException jse) { + LOGGER.error("Got JpaSystemException {} when saveJadwal", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); + } } - @Override - public ResponseEntity getVO(Integer id) { - return null; - } - - @Override - public ResponseEntity addVO(JadwalRencanaPemeriksaanVO vo) { - return null; - } - - @Override - public ResponseEntity editVO(JadwalRencanaPemeriksaanVO vo) { - return null; - } - - @Override - public ResponseEntity deleteVO(Integer id) { - return null; - } - - @Override - public ResponseEntity> getAllVO() { - return null; - } - } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JadwalSupirAmbulanceController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JadwalSupirAmbulanceController.java deleted file mode 100644 index e0d06114..00000000 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JadwalSupirAmbulanceController.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.jasamedika.medifirst2000.controller; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.orm.jpa.JpaSystemException; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.IBaseRestController; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.JadwalSupirAmbulanceService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.JadwalSupirAmbulanceVO; -import com.jasamedika.medifirst2000.vo.PegawaiVO; - -@RestController -@RequestMapping("/jadwal-supir-ambulance") -public class JadwalSupirAmbulanceController extends LocaleController - implements IBaseRestController { - - @Autowired - private JadwalSupirAmbulanceService jadwalSupirAmbulanceService; - - private static final Logger LOGGER = LoggerFactory.getLogger(JadwalSupirAmbulanceController.class); - - @RequestMapping(value = "/save-jadwal-supir-ambulance/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> addVO(@Valid @RequestBody JadwalSupirAmbulanceVO vo, - HttpServletRequest request) { - - try { - Map result = jadwalSupirAmbulanceService.addJadwalSupirAmbulance(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} whenaddJadwalSupirAmbulance", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} whenaddJadwalSupirAmbulance", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/save-all-jadwal-supir-ambulance/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> saveAllVO(@Valid @RequestBody List vos, - HttpServletRequest request) { - - try { - Map result = jadwalSupirAmbulanceService.saveAllJadwalSupirAmbulance(vos); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when saveAllJadwalSupirAmbulance", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when saveAllJadwalSupirAmbulance", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/update-jadwal-supir-ambulance/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> updateVO(@Valid @RequestBody JadwalSupirAmbulanceVO vo, - HttpServletRequest request) { - - try { - Map result = jadwalSupirAmbulanceService.updateJadwalSupirAmbulance(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when updateJadwalSupirAmbulance", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when updateJadwalSupirAmbulance", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/find-all-jadwal-supir-ambulance/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> findAllJadwalSupirAmbulance(HttpServletRequest request) { - - try { - Map result = jadwalSupirAmbulanceService.findAllJadwalSupirAmbulance(); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getJadwalSupirAmbulance", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getJadwalSupirAmbulance", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/get-supir-ambulance/", method = RequestMethod.GET) - public ResponseEntity> getSupirAmbulance(HttpServletRequest request) { - try { - List listSupirVO = jadwalSupirAmbulanceService.getSupirAmbulance(); - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(listSupirVO, HttpStatus.OK, mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getAllSupir Ambulance", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getAllSupirAmbulance", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - - } - - @RequestMapping(value = "/get-jadwal-by-date/{bulan}/{tahun}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getJadwalByDate(@PathVariable("bulan") Integer bulan, - @PathVariable("tahun") Integer tahun, HttpServletRequest request) { - Map result = null; - try { - result = jadwalSupirAmbulanceService.findJadwalByTanggal(bulan, tahun); - Boolean dataFound = new Boolean((boolean) result.get("dataFound")); - - if (dataFound) { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - } else { - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR, - getMessage(MessageResource.LABEL_ERROR, request)); - } - } catch (Exception e) { - e.printStackTrace(); - } - return RestUtil.getJsonResponse(result, HttpStatus.OK); - } - - @Override - public ResponseEntity> getAllVOWithQueryString(HttpServletRequest request, - Integer page, Integer limit, String sort, String dir) { - return null; - } - - @Override - public ResponseEntity getVO(Integer id) { - return null; - } - - @Override - public ResponseEntity addVO(JadwalSupirAmbulanceVO vo) { - return null; - } - - @Override - public ResponseEntity editVO(JadwalSupirAmbulanceVO vo) { - return null; - } - - @Override - public ResponseEntity deleteVO(Integer id) { - return null; - } - - @Override - public ResponseEntity> getAllVO() { - return null; - } -} diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisBahanController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisBahanController.java index c29f0e92..45077ec2 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisBahanController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisBahanController.java @@ -1,139 +1,63 @@ package com.jasamedika.medifirst2000.controller; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - +import com.jasamedika.medifirst2000.constants.MessageResource; +import com.jasamedika.medifirst2000.controller.base.LocaleController; +import com.jasamedika.medifirst2000.exception.ServiceVOException; +import com.jasamedika.medifirst2000.service.JenisBahanService; +import com.jasamedika.medifirst2000.vo.JenisBahanVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.JenisBahanService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.JenisBahanVO; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.Map; + +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; +import static org.springframework.web.bind.annotation.RequestMethod.POST; @RestController @RequestMapping("/jenis-bahan/") -public class JenisBahanController extends LocaleController{ +public class JenisBahanController extends LocaleController { + private static final Logger LOGGER = LoggerFactory.getLogger(JenisBahanController.class); - + @Autowired private JenisBahanService jenisBahanService; - - @RequestMapping(value = "/save-jenis-bahan/", - method = RequestMethod.POST, - produces = MediaType.APPLICATION_JSON_VALUE, - consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> saveJenisBahan(@Valid @RequestBody JenisBahanVO vo,HttpServletRequest request) { - - try{ + + @RequestMapping(value = "/save-jenis-bahan/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) + public ResponseEntity> saveJenisBahan(@Valid @RequestBody JenisBahanVO vo, + HttpServletRequest request) { + try { Map result = this.jenisBahanService.saveJenisBahan(vo); if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when save Jenis Bahan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, - mapHeaderMessage); - + LOGGER.error("Got ServiceVOException {} when saveJenisBahan", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when save Jenis Bahan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, - mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when saveJenisBahan", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - /* - @RequestMapping(value = "/get-jenis-bahan/", - method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE, - consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getAll(HttpServletRequest request) { - - try{ - Map result = this.jenisBahanService.getJenisBahan(); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when GET Jenis Bahan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, - mapHeaderMessage); - - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when GET Jenis Bahan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, - mapHeaderMessage); - } - } - */ - - @RequestMapping(value="/get-jenis-bahan/", - method=RequestMethod.GET, - produces=MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-jenis-bahan/", method = GET, produces = APPLICATION_JSON_VALUE) public Map getAll(HttpServletRequest request) { - Map result = this.jenisBahanService.getJenisBahan(); - return result; - } - - /* - @RequestMapping(value = "/get-jenis-bahan-by-id/", - method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE, - consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getJenisBahanById(@RequestParam(value="id", required=true)Integer id, HttpServletRequest request) { - - try{ - Map result = this.jenisBahanService.getJenisBahanById(id); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when GET Jenis Bahan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, - mapHeaderMessage); - - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when GET Jenis Bahan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, - mapHeaderMessage); - } - } - */ - - @RequestMapping(value="/get-jenis-bahan-by-id/", - method=RequestMethod.GET, - produces=MediaType.APPLICATION_JSON_VALUE) - public Map getJenisBahanById(@RequestParam("id")Integer id, HttpServletRequest request) { - Map result = this.jenisBahanService.getJenisBahanById(id); - return result; + return this.jenisBahanService.getJenisBahan(); } } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisBelanjaController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisBelanjaController.java deleted file mode 100644 index ecf445a4..00000000 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisBelanjaController.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.jasamedika.medifirst2000.controller; - -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.orm.jpa.JpaSystemException; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.JenisBelanjaService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.JenisBelanjaVO; - -@RestController -@RequestMapping("/jenis-belanja") -public class JenisBelanjaController extends LocaleController { - - @Autowired - private JenisBelanjaService jenisBelanjaService; - - private static final Logger LOGGER = LoggerFactory.getLogger(JenisBelanjaController.class); - - @RequestMapping(value = "/save-jenis-belanja", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> saveJenisBelanja(@Valid @RequestBody JenisBelanjaVO vo, - HttpServletRequest request) { - try { - Map result = jenisBelanjaService.saveJenisBelanja(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when save Jenis Belanja", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when save Jenis Belanja", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - - } - - @RequestMapping(value = "/update-jenis-belanja", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> updateJenisBelanja(@Valid @RequestBody JenisBelanjaVO vo, - HttpServletRequest request) { - try { - Map result = jenisBelanjaService.updateJenisBelanja(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when update Jenis Belanja", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when update Jenis Belanja", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - - } - -} diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisDietController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisDietController.java index bfe48739..2adfa154 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisDietController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisDietController.java @@ -1,139 +1,92 @@ package com.jasamedika.medifirst2000.controller; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - +import com.jasamedika.medifirst2000.constants.MessageResource; +import com.jasamedika.medifirst2000.controller.base.LocaleController; +import com.jasamedika.medifirst2000.entities.JenisDiet; +import com.jasamedika.medifirst2000.exception.ServiceVOException; +import com.jasamedika.medifirst2000.service.JenisDietService; +import com.jasamedika.medifirst2000.vo.JenisDietVO; +import com.jasamedika.medifirst2000.vo.PasienVO; +import net.kaczmarzyk.spring.data.jpa.domain.Equal; +import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.jpa.domain.Specification; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.IBaseRestController; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.entities.JenisDiet; -import com.jasamedika.medifirst2000.entities.SatuanIndikator; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.JenisDietService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.JenisDietVO; -import com.jasamedika.medifirst2000.vo.SatuanIndikatorVO; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.Collection; +import java.util.Map; -import net.kaczmarzyk.spring.data.jpa.domain.Equal; -import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec; +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; +import static org.springframework.web.bind.annotation.RequestMethod.POST; @RestController -@RequestMapping(value="/jenis-diet") -public class JenisDietController extends LocaleController -implements IBaseRestController{ +@RequestMapping(value = "/jenis-diet") +public class JenisDietController extends LocaleController { + + private static final Logger LOGGER = LoggerFactory.getLogger(JenisDietController.class); @Autowired private JenisDietService jenisDietService; - - private static final Logger LOGGER = LoggerFactory - .getLogger(PegawaiController.class); - @Override - public ResponseEntity> getAllVOWithQueryString(HttpServletRequest request, Integer page, - Integer limit, String sort, String dir) { - return null; - } - @Override - public ResponseEntity getVO(Integer id) { - return null; - } - - @Override - public ResponseEntity addVO(JenisDietVO vo) { - return null; - } - - @Override - public ResponseEntity editVO(JenisDietVO vo) { - return null; - } - - @Override - public ResponseEntity deleteVO(Integer id) { - return null; - } - - @Override - public ResponseEntity> getAllVO() { - return null; - } - - @RequestMapping(value="/generate/",method= RequestMethod.GET) - public ResponseEntity> getGenerateNoUsulan( - HttpServletRequest request) - { - try{ - Map result = jenisDietService.generate(); - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request )); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - }catch (ServiceVOException e) { - LOGGER.error("Got exception {} when generate no usulan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + @RequestMapping(value = "/generate/", method = GET) + public ResponseEntity> getGenerateNoUsulan(HttpServletRequest request) { + try { + Map result = jenisDietService.generate(); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } catch (ServiceVOException e) { + LOGGER.error("Got ServiceVOException {} when generate", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when generate no usulan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when generate", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value="/find-all/", method= RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> findAll( + + @RequestMapping(value = "/find-all/", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> findAll( @RequestParam(value = "page", required = false, defaultValue = "0") Integer page, @RequestParam(value = "take", required = false, defaultValue = "100") Integer take, @RequestParam(value = "sort", required = false, defaultValue = "id") String sort, @RequestParam(value = "dir", required = false, defaultValue = "asc") String dir, - @Spec(path = "id", params = "id", spec = Equal.class) Specification spec) - { - Map result = new HashMap(); - result = jenisDietService.findAll(page, take, sort,dir, spec); - return constructListPageResult(result); + @Spec(path = "id", params = "id", spec = Equal.class) Specification spec) { + Map result = jenisDietService.findAll(page, take, sort, dir, spec); + return constructListPageResult(result); } - @RequestMapping(value="/save/", method= RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> save(@Valid @RequestBody JenisDietVO vo,HttpServletRequest request){ - try{ + @RequestMapping(value = "/save/", method = POST, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> save(@Valid @RequestBody JenisDietVO vo, HttpServletRequest request) { + try { Map result = jenisDietService.save(vo); - if(null!= result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); - + if (null != result) + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when add/update Jenis Diet", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, - mapHeaderMessage); - + LOGGER.error("Got ServiceVOException {} when save", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when add/update Jenis Diet", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, - mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when save", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } - } + } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisIndikatorController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisIndikatorController.java deleted file mode 100644 index e923f0c3..00000000 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisIndikatorController.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.jasamedika.medifirst2000.controller; - -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.jpa.domain.Specification; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.orm.jpa.JpaSystemException; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.IBaseRestController; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.entities.JenisIndikator; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.JenisIndikatorService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.JenisIndikatorVO; - -import net.kaczmarzyk.spring.data.jpa.domain.Equal; -import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec; - -@RestController -@RequestMapping("/jenis-indikator") -public class JenisIndikatorController extends LocaleController -implements IBaseRestController{ - - @Autowired - private JenisIndikatorService jenisIndikatorService; - - private static final Logger LOGGER = LoggerFactory - .getLogger(PegawaiController.class); - - @Override - public ResponseEntity> getAllVOWithQueryString(HttpServletRequest request, - Integer page, Integer limit, String sort, String dir) { - return null; - } - - @Override - public ResponseEntity getVO(Integer id) { - return null; - } - - @Override - public ResponseEntity addVO(JenisIndikatorVO vo) { - return null; - } - - @Override - public ResponseEntity editVO(JenisIndikatorVO vo) { - return null; - } - - @Override - public ResponseEntity deleteVO(Integer id) { - return null; - } - - @Override - public ResponseEntity> getAllVO() { - return null; - } - - @RequestMapping(value="/find-all/", method= RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> findAll( - @RequestParam(value = "page", required = false, defaultValue = "0") Integer page, - @RequestParam(value = "take", required = false, defaultValue = "100") Integer take, - @RequestParam(value = "sort", required = false, defaultValue = "id") String sort, - @RequestParam(value = "dir", required = false, defaultValue = "asc") String dir, - @Spec(path = "id", params = "id", spec = Equal.class) Specification spec) - { - Map result = new HashMap(); - result = jenisIndikatorService.findAll(page, take, sort,dir, spec); - return constructListPageResult(result); - } - - @RequestMapping(value="/save/", method= RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> save(@Valid @RequestBody JenisIndikatorVO vo,HttpServletRequest request){ - try{ - Map result = jenisIndikatorService.save(vo); - if(null!= result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); - - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when add/update Jenis Indikator", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, - mapHeaderMessage); - - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when add/update Jenis Indikator", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, - mapHeaderMessage); - } - - } -} diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisLimbahB3MasukController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisLimbahB3MasukController.java index 59991c05..02d0fa5c 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisLimbahB3MasukController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisLimbahB3MasukController.java @@ -1,156 +1,96 @@ package com.jasamedika.medifirst2000.controller; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - +import com.jasamedika.medifirst2000.constants.MessageResource; +import com.jasamedika.medifirst2000.controller.base.LocaleController; +import com.jasamedika.medifirst2000.entities.JenisLimbahB3Masuk; +import com.jasamedika.medifirst2000.exception.ServiceVOException; +import com.jasamedika.medifirst2000.service.JenisLimbahB3MasukService; +import com.jasamedika.medifirst2000.vo.JenisLimbahB3MasukVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.entities.Pengendali; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.JenisLimbahB3MasukService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.JenisLimbahB3MasukVO; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.Map; + +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; +import static org.springframework.web.bind.annotation.RequestMethod.POST; @RestController @RequestMapping("/jenis-limbah-b3-masuk") -public class JenisLimbahB3MasukController extends LocaleController{ - +public class JenisLimbahB3MasukController extends LocaleController { + + private static final Logger LOGGER = LoggerFactory.getLogger(JenisLimbahB3MasukController.class); @Autowired - private JenisLimbahB3MasukService jenisLimbahB3MasukService; - - private static final Logger LOGGER = LoggerFactory - .getLogger(JenisLimbahB3MasukController.class); - - @RequestMapping(value = "/save-jenis-limbah-b3-masuk/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> addVO(@Valid @RequestBody JenisLimbahB3MasukVO vo,HttpServletRequest request) { - - try{ + private JenisLimbahB3MasukService jenisLimbahB3MasukService; + + @RequestMapping(value = "/save-jenis-limbah-b3-masuk/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) + public ResponseEntity> addVO(@Valid @RequestBody JenisLimbahB3MasukVO vo, + HttpServletRequest request) { + try { Map result = jenisLimbahB3MasukService.addJenisLimbahB3(vo); if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when add jenisLimbahB3Masuk", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, - mapHeaderMessage); - + LOGGER.error("Got ServiceVOException {} when add addJenisLimbahB3", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when add jenisLimbahB3Masuk", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, - mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when add addJenisLimbahB3", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/update-jenis-limbah-b3-masuk/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> updateVO(@Valid @RequestBody JenisLimbahB3MasukVO vo,HttpServletRequest request) { - - try{ - Map result = jenisLimbahB3MasukService.addJenisLimbahB3(vo); + + @RequestMapping(value = "/find-all-jenis-limbah-b3-masuk/", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getAllVO(HttpServletRequest request) { + try { + Map result = jenisLimbahB3MasukService.findAllAlat(); if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when update jenisLimbahB3Masuk", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, - mapHeaderMessage); - + LOGGER.error("Got ServiceVOException {} when findAllAlat", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when update jenisLimbahB3Masuk", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, - mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when findAllAlat", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/find-all-jenis-limbah-b3-masuk/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getAllVO(HttpServletRequest request) { - - try { - Map result=jenisLimbahB3MasukService.findAllAlat(); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request )); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when get all jenisLimbahB3Masuk", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, - mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when get all jenisLimbahB3Masuk", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, - mapHeaderMessage); - } - } - - @RequestMapping(value = "/delete-jenis-limbah-b3-masuk", method = RequestMethod.GET) - public ResponseEntity deleteNamaBahan(@RequestParam(value = "id", required = true) Integer id) { - + + @RequestMapping(value = "/get-jenis-limbah-b3-masuk", method = GET) + public ResponseEntity> getJenisLimbahB3Masuk(HttpServletRequest request, + @RequestParam(value = "kategori") String kategori) { try { - if (jenisLimbahB3MasukService.deleteJenisLimbahB3(id) == true) - return RestUtil.getJsonResponse(id +" Dihapus", HttpStatus.CREATED); - + Map result = jenisLimbahB3MasukService.getJenisLimbahB3Masuk(kategori); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when delete jenisLimbahB3Masuk", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, - mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getJenisLimbahB3Masuk", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when delete jenisLimbahB3Masuk", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, - mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getJenisLimbahB3Masuk", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } - - return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE); } - - @RequestMapping(value = "/get-jenis-limbah-b3-masuk", method = RequestMethod.GET) - public ResponseEntity> getJenisLimbahB3Masuk(HttpServletRequest request,@RequestParam(value = "kategori", required = true) String kategori) { - try { - Map result = jenisLimbahB3MasukService.getJenisLimbahB3Masuk(kategori); - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when get all pengendali", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when get all dokter", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - - } } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisLinenController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisLinenController.java index 99258983..6ab07adf 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisLinenController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisLinenController.java @@ -1,122 +1,94 @@ package com.jasamedika.medifirst2000.controller; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - +import com.jasamedika.medifirst2000.constants.MessageResource; +import com.jasamedika.medifirst2000.controller.base.LocaleController; +import com.jasamedika.medifirst2000.exception.ServiceVOException; +import com.jasamedika.medifirst2000.service.JenisLinenService; +import com.jasamedika.medifirst2000.vo.JenisLinenVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.JenisLinenService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.JenisLinenVO; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.Map; + +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; +import static org.springframework.web.bind.annotation.RequestMethod.POST; @RestController @RequestMapping("/jenis-linen") public class JenisLinenController extends LocaleController { + private static final Logger LOGGER = LoggerFactory.getLogger(JenisLinenController.class); + @Autowired private JenisLinenService jenisLinenService; - private static final Logger LOGGER = LoggerFactory.getLogger(JenisLinenController.class); - - @RequestMapping(value = "/save-jenis-linen/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/save-jenis-linen/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) public ResponseEntity> saveJenisLinen(@Valid @RequestBody JenisLinenVO vo, HttpServletRequest request) { try { Map result = jenisLinenService.saveJenisLinen(vo); if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when save Jenis Linen", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when saveJenisLinen", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when save Jenis Linen", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when saveJenisLinen", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } - } - @RequestMapping(value = "/update-jenis-linen/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> updateJenisLinen(@Valid @RequestBody JenisLinenVO vo, - HttpServletRequest request) { - try { - Map result = jenisLinenService.updateJenisLinen(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when update Jenis Linen", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when update Jenis Linen", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - - } - - @RequestMapping(value = "/find-all-jenis-linen/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/find-all-jenis-linen/", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> findAllJenisLinen(HttpServletRequest request) { - try { Map result = jenisLinenService.findAllJenisLinen(); if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when get All Jenis Linen", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when findAllJenisLinen", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when get All Jenis Linen", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when findAllJenisLinen", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } - } - @RequestMapping(value = "/delete-jenis-linen/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity deleteJenisLinen(@RequestParam(value = "id", required = true) Integer id) { - + @RequestMapping(value = "/delete-jenis-linen/", method = GET, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) + public ResponseEntity deleteJenisLinen(@RequestParam(value = "id") Integer id) { try { - if (jenisLinenService.deleteJenisLinen(id) == true) - return RestUtil.getJsonResponse(id + " Dihapus", HttpStatus.CREATED); - + if (jenisLinenService.deleteJenisLinen(id)) + return getJsonResponse(id + " Dihapus", CREATED); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when delete Jenis Linen", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when deleteJenisLinen", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when delete Jenis Linen", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when deleteJenisLinen", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } - - return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE); + return getJsonHttpStatus(NOT_ACCEPTABLE); } } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisLogController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisLogController.java deleted file mode 100644 index bede85d7..00000000 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisLogController.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.jasamedika.medifirst2000.controller; - -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.JenisLogService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.JenisLogVO; -import org.slf4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; -import java.util.List; - -import static org.slf4j.LoggerFactory.getLogger; -import static org.springframework.http.HttpStatus.CREATED; -import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; -import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; -import static org.springframework.web.bind.annotation.RequestMethod.POST; - -/** - * @author Salman - * @version 1.0.0 - * @since 02/02/2024 - */ -@RestController -@RequestMapping("/log/jenis") -public class JenisLogController { - private static final Logger LOGGER = getLogger(JenisLogController.class); - - @Autowired - private JenisLogService jenisLogService; - - @RequestMapping(method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) - public ResponseEntity addVO(@Valid @RequestBody List vos, HttpServletRequest request) { - try { - jenisLogService.save(vos); - return RestUtil.getJsonResponse(CREATED.getReasonPhrase(), CREATED); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when add jenis log", e.getMessage()); - return RestUtil.getJsonHttptatus(INTERNAL_SERVER_ERROR); - } - } -} diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisPengadaanController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisPengadaanController.java deleted file mode 100644 index 1bbef597..00000000 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisPengadaanController.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.jasamedika.medifirst2000.controller; - -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.orm.jpa.JpaSystemException; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.JenisPengadaanService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.JenisPengadaanVO; - -@RestController -@RequestMapping("/jenis-pengadaan") -public class JenisPengadaanController extends LocaleController { - - @Autowired - private JenisPengadaanService jenisPengadaanService; - - private static final Logger LOGGER = LoggerFactory.getLogger(JenisPengadaanService.class); - - @RequestMapping(value = "/save-jenis-pengadaan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> saveJenisPengadaan(@Valid @RequestBody JenisPengadaanVO vo, - HttpServletRequest request) { - try { - Map result = jenisPengadaanService.saveJenisPengadaan(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when save Jenis Pengadaan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when save Jenis Pengadaan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - - } - - @RequestMapping(value = "/update-jenis-pengadaan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> updateJenisPengadaan(@Valid @RequestBody JenisPengadaanVO vo, - HttpServletRequest request) { - try { - Map result = jenisPengadaanService.updateJenisPengadaan(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, - getMessage(MessageResource.LABEL_SUCCESS, request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when update Jenis Pengadaan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when update Jenis Pengadaan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - - } - -} diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisResponController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisResponController.java index a55f396f..c2565751 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisResponController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisResponController.java @@ -1,58 +1,57 @@ package com.jasamedika.medifirst2000.controller; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - +import com.jasamedika.medifirst2000.constants.MessageResource; +import com.jasamedika.medifirst2000.controller.base.LocaleController; +import com.jasamedika.medifirst2000.exception.ServiceVOException; +import com.jasamedika.medifirst2000.service.JenisResponService; +import com.jasamedika.medifirst2000.vo.JenisResponVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.JenisResponService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.JenisResponVO; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.Map; + +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.POST; @RestController @RequestMapping("/jenisRespon") public class JenisResponController extends LocaleController { - - @Autowired - private JenisResponService service; - - private static final Logger LOGGER = LoggerFactory.getLogger(JenisResponController.class); - - @RequestMapping(value = "/save-jenis-respon", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> saveJenisRespon(@Valid @RequestBody JenisResponVO vo,HttpServletRequest request) { - try { - Map result = service.saveJenisRespon(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); + private static final Logger LOGGER = LoggerFactory.getLogger(JenisResponController.class); + + @Autowired + private JenisResponService service; + + @RequestMapping(value = "/save-jenis-respon", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) + public ResponseEntity> saveJenisRespon(@Valid @RequestBody JenisResponVO vo, + HttpServletRequest request) { + try { + Map result = service.saveJenisRespon(vo); + if (null != result) + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when saveJenisRespon", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when saveJenisRespon", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when saveJenisRespon", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when saveJenisRespon", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisWaktuController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisWaktuController.java index a0ad145e..0de1ef53 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisWaktuController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JenisWaktuController.java @@ -1,126 +1,80 @@ package com.jasamedika.medifirst2000.controller; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - +import com.jasamedika.medifirst2000.constants.MessageResource; +import com.jasamedika.medifirst2000.controller.base.LocaleController; +import com.jasamedika.medifirst2000.entities.JenisWaktu; +import com.jasamedika.medifirst2000.exception.ServiceVOException; +import com.jasamedika.medifirst2000.service.JenisWaktuService; +import com.jasamedika.medifirst2000.vo.JenisWaktuVO; +import com.jasamedika.medifirst2000.vo.PasienVO; +import net.kaczmarzyk.spring.data.jpa.domain.Equal; +import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.jpa.domain.Specification; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.IBaseRestController; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.entities.JenisWaktu; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.JenisWaktuService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.JenisWaktuVO; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.Collection; +import java.util.Map; -import net.kaczmarzyk.spring.data.jpa.domain.Equal; -import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec; +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; +import static org.springframework.web.bind.annotation.RequestMethod.POST; @RestController -@RequestMapping(value="/jenis-waktu") -public class JenisWaktuController extends LocaleController -implements IBaseRestController{ +@RequestMapping(value = "/jenis-waktu") +public class JenisWaktuController extends LocaleController { + + private static final Logger LOGGER = LoggerFactory.getLogger(JenisWaktuController.class); @Autowired private JenisWaktuService jenisWaktuService; - - private static final Logger LOGGER = LoggerFactory - .getLogger(IndikatorRensarController.class); - - @Override - public ResponseEntity> getAllVOWithQueryString(HttpServletRequest request, Integer page, - Integer limit, String sort, String dir) { - return null; - } - @Override - public ResponseEntity getVO(Integer id) { - return null; - } - - @Override - public ResponseEntity addVO(JenisWaktuVO vo) { - return null; - } - - @Override - public ResponseEntity editVO(JenisWaktuVO vo) { - return null; - } - - @Override - public ResponseEntity deleteVO(Integer id) { - return null; - } - - @Override - public ResponseEntity> getAllVO() { - return null; - } - - @RequestMapping(value="/find-all/", method= RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> findAll( + @RequestMapping(value = "/find-all/", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> findAll( @RequestParam(value = "page", required = false, defaultValue = "0") Integer page, @RequestParam(value = "take", required = false, defaultValue = "100") Integer take, @RequestParam(value = "sort", required = false, defaultValue = "id") String sort, @RequestParam(value = "dir", required = false, defaultValue = "asc") String dir, - @Spec(path = "id", params = "id", spec = Equal.class) Specification spec) - { - Map result = new HashMap(); - result = jenisWaktuService.findAll(page, take, sort,dir, spec); - return constructListPageResult(result); + @Spec(path = "id", params = "id", spec = Equal.class) Specification spec) { + Map result = jenisWaktuService.findAll(page, take, sort, dir, spec); + return constructListPageResult(result); } - @RequestMapping(value="/save/", method= RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> save(@Valid @RequestBody JenisWaktuVO vo,HttpServletRequest request){ - try{ + @RequestMapping(value = "/save/", method = POST, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> save(@Valid @RequestBody JenisWaktuVO vo, HttpServletRequest request) { + try { Map result = jenisWaktuService.save(vo); - if(null!= result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage); - + if (null != result) + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when add/update Jenis Waktu", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, - mapHeaderMessage); - + LOGGER.error("Got ServiceVOException {} when save", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when add/update Jenis Waktu", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, - jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, - mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when save", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } - } - @RequestMapping(value="/get-jenis-waktu/", - method=RequestMethod.GET, - produces=MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/get-jenis-waktu/", method = GET, produces = APPLICATION_JSON_VALUE) public Map getJenisWaktu(HttpServletRequest request) { - Map result = this.jenisWaktuService.getJenisWaktu(); - return result; + return this.jenisWaktuService.getJenisWaktu(); } + } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JumlahDiskonDokterController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JumlahDiskonDokterController.java deleted file mode 100644 index 758d1825..00000000 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/JumlahDiskonDokterController.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.jasamedika.medifirst2000.controller; - -import com.jasamedika.medifirst2000.dto.JumlahDiskonDokterDto; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.JumlahDiskonDokterService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import org.apache.commons.collections4.map.SingletonMap; -import org.slf4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; -import java.util.List; - -import static org.slf4j.LoggerFactory.getLogger; -import static org.springframework.http.HttpStatus.CREATED; -import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; -import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; -import static org.springframework.web.bind.annotation.RequestMethod.POST; - -/** - * @author salmanoe - * @version 1.0.0 - * @since 07/02/2024 - */ -@RestController -@RequestMapping("/master/dokter/jumlah-diskon") -public class JumlahDiskonDokterController { - private static final Logger LOGGER = getLogger(JumlahDiskonDokterController.class); - - @Autowired - private JumlahDiskonDokterService jumlahDiskonDokterService; - - @RequestMapping(method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) - public ResponseEntity> save(HttpServletRequest request, - @Valid @RequestBody List dtos) { - try { - jumlahDiskonDokterService.save(dtos); - return RestUtil.getJsonResponse(dtos, CREATED, new SingletonMap<>("status", CREATED.getReasonPhrase())); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when add jumlah diskon dokter", e.getMessage()); - return RestUtil.getJsonHttptatus(INTERNAL_SERVER_ERROR); - } - } -} diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/K3CheckListFacillitySefetyController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/K3CheckListFacillitySefetyController.java index 82806a7c..eb95af2a 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/K3CheckListFacillitySefetyController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/K3CheckListFacillitySefetyController.java @@ -1,170 +1,146 @@ package com.jasamedika.medifirst2000.controller; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - +import com.jasamedika.medifirst2000.constants.MessageResource; +import com.jasamedika.medifirst2000.controller.base.LocaleController; +import com.jasamedika.medifirst2000.exception.ServiceVOException; +import com.jasamedika.medifirst2000.service.K3CheckListFacillitySefetyService; +import com.jasamedika.medifirst2000.vo.K3CheckListFacillitySefetyVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.orm.jpa.JpaSystemException; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.jasamedika.medifirst2000.constants.Constants; -import com.jasamedika.medifirst2000.constants.MessageResource; -import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; -import com.jasamedika.medifirst2000.exception.ServiceVOException; -import com.jasamedika.medifirst2000.service.K3CheckListFacillitySefetyService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; -import com.jasamedika.medifirst2000.vo.K3CheckListFacillitySefetyVO; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.Map; + +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; +import static org.springframework.web.bind.annotation.RequestMethod.POST; @RestController @RequestMapping("/k3-checklist-facillity-sefety") -public class K3CheckListFacillitySefetyController extends LocaleController{ - +public class K3CheckListFacillitySefetyController extends LocaleController { + + private static final Logger LOGGER = LoggerFactory.getLogger(K3CheckListFacillitySefetyController.class); + @Autowired private K3CheckListFacillitySefetyService service; - - private static final Logger LOGGER = LoggerFactory.getLogger(K3CheckListFacillitySefetyController.class); - - @RequestMapping(value = "/get-k3-ruangan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-k3-ruangan", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getK3Ruangan(HttpServletRequest request) { try { - Map result = service.getK3Ruangan(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getK3Ruangan(); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getK3Ruangan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getK3Ruangan", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getK3Ruangan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getK3Ruangan", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - @RequestMapping(value = "/get-k3-facillity-check", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getK3FacillityCheck(HttpServletRequest request) { - try { - Map result = service.getK3FacillityCheck(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); - } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getK3FacillityCheck", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getK3FacillityCheck", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/get-k3-kelompokLpj-gedung", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/get-k3-kelompokLpj-gedung", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getK3KelompokLpjGedung( - @RequestParam(value = "k3FacillityCheckId", required = true) Integer k3FacillityCheckId, - HttpServletRequest request) { + @RequestParam(value = "k3FacillityCheckId") Integer k3FacillityCheckId, HttpServletRequest request) { try { - Map result = service.getK3KelompokLpjGedung(k3FacillityCheckId); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getK3KelompokLpjGedung(k3FacillityCheckId); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getK3KelompokLpjGedung", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getK3KelompokLpjGedung", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getK3KelompokLpjGedung", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getK3KelompokLpjGedung", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/save-k3-checklist-facillity-sefety", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> saveK3CheckListFacillitySefety(@Valid @RequestBody K3CheckListFacillitySefetyVO vo, HttpServletRequest request) { - try { - Map result = service.saveK3CheckListFacillitySefety(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); + @RequestMapping(value = "/save-k3-checklist-facillity-sefety", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) + public ResponseEntity> saveK3CheckListFacillitySefety( + @Valid @RequestBody K3CheckListFacillitySefetyVO vo, HttpServletRequest request) { + try { + Map result = service.saveK3CheckListFacillitySefety(vo); + if (null != result) + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when saveK3CheckListFacillitySefety", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when saveK3CheckListFacillitySefety", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when saveK3CheckListFacillitySefety", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when saveK3CheckListFacillitySefety", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/get-k3-check-list-fasilitas-dan-keamanan", - method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-k3-check-list-fasilitas-dan-keamanan", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getCheckListFasilitasdanKeamanan(HttpServletRequest request) { try { - Map result = service.getCheckListFasilitasdanKeamanan(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getCheckListFasilitasdanKeamanan(); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getCheckListFasilitasdanKeamanan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getCheckListFasilitasdanKeamanan", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getCheckListFasilitasdanKeamanan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getCheckListFasilitasdanKeamanan", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/get-k3-check-list-fasilitas-dan-keamanan-detail", - method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-k3-check-list-fasilitas-dan-keamanan-detail", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getCheckListFasilitasdanKeamananDetail( - @RequestParam(value = "k3FacillityCheckId", required = true) Integer k3FacillityCheckId, - @RequestParam(value = "noRec", required = true) String noRec, - HttpServletRequest request) { + @RequestParam(value = "k3FacillityCheckId") Integer k3FacillityCheckId, + @RequestParam(value = "noRec") String noRec, HttpServletRequest request) { try { - Map result = service.getCheckListFasilitasdanKeamananHeader(k3FacillityCheckId, noRec); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getCheckListFasilitasdanKeamananHeader(k3FacillityCheckId, noRec); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getCheckListFasilitasdanKeamanan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getCheckListFasilitasdanKeamananHeader", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getCheckListFasilitasdanKeamanan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getCheckListFasilitasdanKeamananHeader", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - + } diff --git a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/K3LaporanKecelakaanKerjaController.java b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/K3LaporanKecelakaanKerjaController.java index f5ba3ba4..2368bb01 100644 --- a/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/K3LaporanKecelakaanKerjaController.java +++ b/jasamedika-web/src/main/java/com/jasamedika/medifirst2000/controller/K3LaporanKecelakaanKerjaController.java @@ -1,282 +1,280 @@ package com.jasamedika.medifirst2000.controller; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.orm.jpa.JpaSystemException; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import com.jasamedika.medifirst2000.constants.Constants; import com.jasamedika.medifirst2000.constants.MessageResource; import com.jasamedika.medifirst2000.controller.base.LocaleController; -import com.jasamedika.medifirst2000.core.web.WebConstants; import com.jasamedika.medifirst2000.exception.ServiceVOException; import com.jasamedika.medifirst2000.service.K3LaporanKecelakaanKerjaService; -import com.jasamedika.medifirst2000.util.rest.RestUtil; import com.jasamedika.medifirst2000.vo.K3LaporanKecelakaanKerjaVO; import com.jasamedika.medifirst2000.vo.LkkIdentifikasiKejadianVO; import com.jasamedika.medifirst2000.vo.LkkIdentifikasiKorbanVO; import com.jasamedika.medifirst2000.vo.LkkSaksiKejadianVO; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.orm.jpa.JpaSystemException; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.Map; + +import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE; +import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus; +import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse; +import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.web.bind.annotation.RequestMethod.GET; +import static org.springframework.web.bind.annotation.RequestMethod.POST; @RestController @RequestMapping("/k3-laporan-kecelakaan-kerja") -public class K3LaporanKecelakaanKerjaController extends LocaleController{ +public class K3LaporanKecelakaanKerjaController extends LocaleController { + + private static final Logger LOGGER = LoggerFactory.getLogger(K3LaporanKecelakaanKerjaController.class); @Autowired private K3LaporanKecelakaanKerjaService service; - - private static final Logger LOGGER = LoggerFactory.getLogger(K3LaporanKecelakaanKerjaController.class); - - @RequestMapping(value = "/get-login-pelapor", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-login-pelapor", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getLoginUser(HttpServletRequest request) { try { - Map result = service.getUserLogin(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getUserLogin(); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getLoginUser", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getUserLogin", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getLoginUser", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getUserLogin", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/get-unit-ruangan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + + @RequestMapping(value = "/get-unit-ruangan", method = GET, produces = APPLICATION_JSON_VALUE) public ResponseEntity> getUnitRuangan(HttpServletRequest request) { try { - Map result = service.getUnitRuangan(); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); + Map result = service.getUnitRuangan(); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); } } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getUnitRuangan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when getUnitRuangan", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getUnitRuangan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when getUnitRuangan", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/save-data-lkk", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> saveDataLkk(@Valid @RequestBody K3LaporanKecelakaanKerjaVO vo, HttpServletRequest request) { - try { - Map result = service.saveDataLkk(vo); - if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when saveDataLkk", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when saveDataLkk", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/get-identifikasi-kejadian", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getIdentifikasiKejadian( - @RequestParam(value = "idPegawai", required = true) Integer idPegawai, HttpServletRequest request) { - try { - Map result = service.getIdentifikasiKejadian(idPegawai); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); - } - } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getIdentifikasiKejadian", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); - } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getIdentifikasiKejadian", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); - } - } - - @RequestMapping(value = "/get-lkk-by-norec", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> getDataLkkByNoRec(@RequestParam(value = "noRec", required = true) String noRec, + @RequestMapping(value = "/save-data-lkk", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) + public ResponseEntity> saveDataLkk(@Valid @RequestBody K3LaporanKecelakaanKerjaVO vo, HttpServletRequest request) { try { - Map result = service.getDataLkkByNoRec(noRec); - if (null != result){ - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - } else{ - return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); - } + Map result = service.saveDataLkk(vo); + if (null != result) + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, CREATED, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when getDataLkkByNoRec", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when saveDataLkk", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when getDataLkkByNoRec", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when saveDataLkk", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/update-identifikasi-kejadian", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity updateIdentifikasiKejadian(@Valid @RequestBody LkkIdentifikasiKejadianVO vo, HttpServletRequest request) { + + @RequestMapping(value = "/get-identifikasi-kejadian", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getIdentifikasiKejadian( + @RequestParam(value = "idPegawai") Integer idPegawai, HttpServletRequest request) { + try { + Map result = service.getIdentifikasiKejadian(idPegawai); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); + } + } catch (ServiceVOException e) { + LOGGER.error("Got ServiceVOException {} when getIdentifikasiKejadian", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + } catch (JpaSystemException jse) { + LOGGER.error("Got JpaSystemException {} when getIdentifikasiKejadian", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); + } + } + + @RequestMapping(value = "/get-lkk-by-norec", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity> getDataLkkByNoRec(@RequestParam(value = "noRec") String noRec, + HttpServletRequest request) { + try { + Map result = service.getDataLkkByNoRec(noRec); + if (null != result) { + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); + } else { + return getJsonResponse(null, NOT_FOUND, mapHeaderMessage); + } + } catch (ServiceVOException e) { + LOGGER.error("Got ServiceVOException {} when getDataLkkByNoRec", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); + } catch (JpaSystemException jse) { + LOGGER.error("Got JpaSystemException {} when getDataLkkByNoRec", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); + } + } + + @RequestMapping(value = "/update-identifikasi-kejadian", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) + public ResponseEntity updateIdentifikasiKejadian(@Valid @RequestBody LkkIdentifikasiKejadianVO vo, + HttpServletRequest request) { try { Integer result = service.updateIdentifikasiKejadian(vo); if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(vo.getNoRec(), HttpStatus.OK,mapHeaderMessage); - + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(vo.getNoRec(), OK, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when updateIdentifikasiKejadian", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when updateIdentifikasiKejadian", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when updateIdentifikasiKejadian", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when updateIdentifikasiKejadian", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/update-identifikasi-korban", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity updateIdentifikasiKorban(@Valid @RequestBody LkkIdentifikasiKorbanVO vo, HttpServletRequest request) { + + @RequestMapping(value = "/update-identifikasi-korban", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) + public ResponseEntity updateIdentifikasiKorban(@Valid @RequestBody LkkIdentifikasiKorbanVO vo, + HttpServletRequest request) { try { Integer result = service.updateIdentifikasiKorban(vo); if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(vo.getNoRec(), HttpStatus.OK,mapHeaderMessage); - + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(vo.getNoRec(), OK, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when updateIdentifikasiKorban", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when updateIdentifikasiKorban", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when updateIdentifikasiKorban", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when updateIdentifikasiKorban", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/update-saksi-kejadian", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity updateSaksiKejadian(@Valid @RequestBody LkkSaksiKejadianVO vo, HttpServletRequest request) { + + @RequestMapping(value = "/update-saksi-kejadian", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) + public ResponseEntity updateSaksiKejadian(@Valid @RequestBody LkkSaksiKejadianVO vo, + HttpServletRequest request) { try { Integer result = service.updateSaksiKejadian(vo); if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(vo.getNoRec(), HttpStatus.OK,mapHeaderMessage); - + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(vo.getNoRec(), OK, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when updateSaksiKejadian", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when updateSaksiKejadian", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when updateSaksiKejadian", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when updateSaksiKejadian", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/delete-identifikasi-kejadian", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity deleteIdentifikasiKejadian( - @RequestParam(value = "noRec", required = true) String noRec, HttpServletRequest request) { + + @RequestMapping(value = "/delete-identifikasi-kejadian", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity deleteIdentifikasiKejadian(@RequestParam(value = "noRec") String noRec, + HttpServletRequest request) { try { Boolean result = service.deleteIdentifikasiKejadian(noRec); if (result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when deleteIdentifikasiKejadian", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when deleteIdentifikasiKejadian", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when deleteIdentifikasiKejadian", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when deleteIdentifikasiKejadian", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/delete-identifikasi-korban", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity deleteIdentifikasiKorban( - @RequestParam(value = "noRec", required = true) String noRec, HttpServletRequest request) { + + @RequestMapping(value = "/delete-identifikasi-korban", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity deleteIdentifikasiKorban(@RequestParam(value = "noRec") String noRec, + HttpServletRequest request) { try { Boolean result = service.deleteIdentifikasiKorban(noRec); if (result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when deleteIdentifikasiKorban", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when deleteIdentifikasiKorban", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when deleteIdentifikasiKorban", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when deleteIdentifikasiKorban", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/delete-saksi-kejadian", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity deleteSaksiKejadian( - @RequestParam(value = "noRec", required = true) String noRec, HttpServletRequest request) { + + @RequestMapping(value = "/delete-saksi-kejadian", method = GET, produces = APPLICATION_JSON_VALUE) + public ResponseEntity deleteSaksiKejadian(@RequestParam(value = "noRec") String noRec, + HttpServletRequest request) { try { Boolean result = service.deleteSaksiKejadian(noRec); if (result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); - + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(result, OK, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when deleteSaksiKejadian", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when deleteSaksiKejadian", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when deleteSaksiKejadian", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when deleteSaksiKejadian", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } } - - @RequestMapping(value = "/verifikasi-lkk", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity verifLaporanKecelakaan(@Valid @RequestBody K3LaporanKecelakaanKerjaVO vo, HttpServletRequest request) { + + @RequestMapping(value = "/verifikasi-lkk", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) + public ResponseEntity verifLaporanKecelakaan(@Valid @RequestBody K3LaporanKecelakaanKerjaVO vo, + HttpServletRequest request) { try { Integer result = service.verifLaporanKecelakaan(vo); if (null != result) - mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); - return RestUtil.getJsonResponse(vo.getNoRec(), HttpStatus.OK,mapHeaderMessage); - + mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request)); + return getJsonResponse(vo.getNoRec(), OK, mapHeaderMessage); } catch (ServiceVOException e) { - LOGGER.error("Got exception {} when verifLaporanKecelakaan", e.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); + LOGGER.error("Got ServiceVOException {} when verifLaporanKecelakaan", e.getMessage()); + addHeaderMessage(ERROR_MESSAGE, e.getMessage()); + return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage); } catch (JpaSystemException jse) { - LOGGER.error("Got exception {} when verifLaporanKecelakaan", jse.getMessage()); - addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); - return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage); + LOGGER.error("Got JpaSystemException {} when verifLaporanKecelakaan", jse.getMessage()); + addHeaderMessage(ERROR_MESSAGE, jse.getMessage()); + return getJsonHttpStatus(CONFLICT, mapHeaderMessage); } }