Update controller

Clean code
This commit is contained in:
Salman Manoe 2025-01-06 14:48:46 +07:00
parent 444f9eab94
commit 776ffe55a3
14 changed files with 272 additions and 1627 deletions

View File

@ -1,112 +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.RestController;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
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.RiwayatKelahiranYangLaluService;
import com.jasamedika.medifirst2000.service.ThtService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.RiwayatKelahiranYangLaluVO;
/**
* Controller class for Pengakjian Awal RiwayatKelahiranYangLaluController
*
* @author Askur
*/
@RestController
@RequestMapping("/riwayat-kelahiran-yang-lalu")
@JsonIgnoreProperties(ignoreUnknown = true)
public class RiwayatKelahiranYangLaluController extends LocaleController<RiwayatKelahiranYangLaluVO> implements
IBaseRestController<RiwayatKelahiranYangLaluVO> {
private static final Logger LOGGER = LoggerFactory.getLogger(RiwayatKelahiranYangLaluController.class);
@Autowired
private RiwayatKelahiranYangLaluService riwayatKelahiranYangLaluService;
@Autowired
private ThtService thtService;
@RequestMapping(value = "/save-riwayat-kelahiran-yang-lalu", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> save(@Valid @RequestBody RiwayatKelahiranYangLaluVO vo,HttpServletRequest request) {
try {
Map<String,Object> result = riwayatKelahiranYangLaluService.addRiwayatKelahiranYangLalu(vo);
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
result.put("message", "Berhasil");
}else{
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,getMessage(MessageResource.LABEL_ERROR,request ));
result.put("message", "Gagal");
}
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add Pasien", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Pasien", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@Override
public ResponseEntity<Collection<RiwayatKelahiranYangLaluVO>> getAllVOWithQueryString(HttpServletRequest request,
Integer page, Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<RiwayatKelahiranYangLaluVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(RiwayatKelahiranYangLaluVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(RiwayatKelahiranYangLaluVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<RiwayatKelahiranYangLaluVO>> getAllVO() {
return null;
}
}

View File

@ -1,33 +1,31 @@
package com.jasamedika.medifirst2000.controller; package com.jasamedika.medifirst2000.controller;
import java.text.ParseException; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.Map; import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import javax.servlet.http.HttpServletRequest; import com.jasamedika.medifirst2000.exception.ServiceVOException;
import javax.validation.Valid; import com.jasamedika.medifirst2000.service.RiwayatKesehatanService;
import com.jasamedika.medifirst2000.vo.RiwayatKesehatanVO;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; 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.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException; import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import javax.servlet.http.HttpServletRequest;
import com.jasamedika.medifirst2000.constants.Constants; import javax.validation.Valid;
import com.jasamedika.medifirst2000.constants.MessageResource; import java.util.Map;
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.RiwayatKesehatanService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.RiwayatKesehatanVO;
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.slf4j.LoggerFactory.getLogger;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
/****************** /******************
* @author Shakato * @author Shakato
@ -37,33 +35,30 @@ import com.jasamedika.medifirst2000.vo.RiwayatKesehatanVO;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class RiwayatKesehatanController extends LocaleController<RiwayatKesehatanVO> { public class RiwayatKesehatanController extends LocaleController<RiwayatKesehatanVO> {
private static final Logger LOGGER = getLogger(RiwayatKesehatanController.class);
@Autowired @Autowired
private RiwayatKesehatanService riwayatKesehatanService; private RiwayatKesehatanService riwayatKesehatanService;
private static final Logger LOGGER = LoggerFactory.getLogger(RiwayatKesehatanController.class); @RequestMapping(value = "/save-riwayat-kesehatan", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<String> saveRiwayatKesehatan(@Valid @RequestBody RiwayatKesehatanVO vo,
@RequestMapping(value = "/save-riwayat-kesehatan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) HttpServletRequest request) {
public ResponseEntity<String> saveRiwayatKesehatan(@Valid @RequestBody RiwayatKesehatanVO vo, HttpServletRequest request) throws ParseException {
try { try {
// SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss.SSS");
// vo.setTglRegistrasi(format.parse(vo.getTanggalPendaftaran()));
Map<String, Object> result = riwayatKesehatanService.saveRiwayatKesehatanService(vo); Map<String, Object> result = riwayatKesehatanService.saveRiwayatKesehatanService(vo);
if (null != result) if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request )); mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
RestUtil.getJsonHttpStatus(HttpStatus.CREATED); getJsonHttpStatus(CREATED);
SaveLog("Riwayat Kesehatan", "Pemeriksaan", request); SaveLog("Riwayat Kesehatan", "Pemeriksaan", request);
return RestUtil.getJsonResponse("Status Sukses", HttpStatus.CREATED,mapHeaderMessage); return getJsonResponse("Status Sukses", CREATED, mapHeaderMessage);
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when save Riwayat Kesehatan", e.getMessage()); LOGGER.error("Got ServiceVOException {} when saveRiwayatKesehatanService", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when save Riwayat Kesehatan", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when saveRiwayatKesehatanService", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} }
} }
} }

View File

@ -1,120 +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.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.RiwayatMasaKehamilanService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.RiwayatMasaKehamilanVO;
@RestController
@RequestMapping("/riwayat-masa-kehamilan")
public class RiwayatMasaKehamilanController extends LocaleController<RiwayatMasaKehamilanVO> implements
IBaseRestController<RiwayatMasaKehamilanVO> {
@Autowired
private RiwayatMasaKehamilanService riwayatMasaKehamilanService;
private static final Logger LOGGER = LoggerFactory
.getLogger(RiwayatMasaKehamilanController.class);
@RequestMapping(value = "/save-riwayat-masa-kehamilan/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> addVO(@Valid @RequestBody RiwayatMasaKehamilanVO vo, HttpServletRequest request) {
try {
Map<String,Object> result=riwayatMasaKehamilanService.addRiwayatMasaKehamilan(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 Riwayat Masa Kehamilan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Riwayat Masa Kehamilan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value = "/update-riwayat-masa-kehamilan/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> updateVO(@Valid @RequestBody RiwayatMasaKehamilanVO vo, HttpServletRequest request) {
try {
Map<String,Object> result=riwayatMasaKehamilanService.updateRiwayatMasaKehamilan(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 Riwayat Masa Kehamilan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when update Riwayat Masa Kehamilan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@Override
public ResponseEntity<Collection<RiwayatMasaKehamilanVO>> getAllVOWithQueryString(HttpServletRequest request,
Integer page, Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<RiwayatMasaKehamilanVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(RiwayatMasaKehamilanVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(RiwayatMasaKehamilanVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<RiwayatMasaKehamilanVO>> getAllVO() {
return null;
}
}

View File

@ -1,122 +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.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.RiwayatPascaLahirService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.RiwayatPascaLahirVO;
@RestController
@RequestMapping("/riwayat-pasca-lahir")
public class RiwayatPascaLahirController extends LocaleController<RiwayatPascaLahirVO> implements
IBaseRestController<RiwayatPascaLahirVO> {
@Autowired
private RiwayatPascaLahirService riwayatPascaLahirService;
private static final Logger LOGGER = LoggerFactory
.getLogger(RiwayatPascaLahirController.class);
@RequestMapping(value = "/save-riwayat-pasca-lahir/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> addVO(@Valid @RequestBody RiwayatPascaLahirVO vo, HttpServletRequest request) {
try {
Map<String,Object> result=riwayatPascaLahirService.addRiwayatPascaLahir(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 Riwayat Pasca Lahir", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Riwayat Pasca Lahir", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value = "/update-riwayat-pasca-lahir/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> updateVO(@Valid @RequestBody RiwayatPascaLahirVO vo, HttpServletRequest request) {
try {
Map<String,Object> result=riwayatPascaLahirService.updateRiwayatPascaLahir(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 Riwayat Pasca Lahir", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Riwayat Pasca Lahir", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@Override
public ResponseEntity<Collection<RiwayatPascaLahirVO>> getAllVOWithQueryString(HttpServletRequest request,
Integer page, Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<RiwayatPascaLahirVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(RiwayatPascaLahirVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(RiwayatPascaLahirVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<RiwayatPascaLahirVO>> getAllVO() {
return null;
}
}

View File

@ -1,102 +0,0 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Collection;
import java.util.List;
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.fasterxml.jackson.annotation.JsonIgnoreProperties;
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.RiwayatPekerjaanService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.RiwayatPekerjaanVO;
/**
*
*
* @author Roberto
*/
@RestController
@RequestMapping("/riwayat-pekerjaan")
@JsonIgnoreProperties(ignoreUnknown = true)
public class RiwayatPekerjaanController extends LocaleController<RiwayatPekerjaanVO> implements IBaseRestController<RiwayatPekerjaanVO> {
@Autowired
private RiwayatPekerjaanService riwayatPekerjaanService;
private static final Logger LOGGER = LoggerFactory.getLogger(RiwayatPekerjaanController.class);
@RequestMapping(value = "/save-riwayat-pekerjaan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> saveRiwayatPekerjaan(@Valid @RequestBody RiwayatPekerjaanVO vo,HttpServletRequest request) {
try {
RiwayatPekerjaanVO result = riwayatPekerjaanService.add(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
RestUtil.getJsonHttpStatus(HttpStatus.CREATED);
return RestUtil.getJsonResponse("Status Sukses", HttpStatus.CREATED,mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add Status Keluarga", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Status Keluarga", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@Override
public ResponseEntity<Collection<RiwayatPekerjaanVO>> getAllVOWithQueryString(HttpServletRequest request, Integer page,
Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<RiwayatPekerjaanVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(RiwayatPekerjaanVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(RiwayatPekerjaanVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<RiwayatPekerjaanVO>> getAllVO() {
return null;
}
}

View File

@ -1,102 +0,0 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Collection;
import java.util.List;
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.fasterxml.jackson.annotation.JsonIgnoreProperties;
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.RiwayatPelatihanService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.RiwayatPelatihanVO;
/******************
* @author Shakato
******************/
@RestController
@RequestMapping("/riwayat-pelatihan")
@JsonIgnoreProperties(ignoreUnknown = true)
public class RiwayatPelatihanController extends LocaleController<RiwayatPelatihanVO> implements IBaseRestController<RiwayatPelatihanVO> {
@Autowired
private RiwayatPelatihanService riwayatPelatihanService;
private static final Logger LOGGER = LoggerFactory.getLogger(RiwayatPelatihanController.class);
@RequestMapping(value = "/save-riwayat-pelatihan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> saveRiwayatPelatihan(@Valid @RequestBody RiwayatPelatihanVO vo,HttpServletRequest request) {
try {
RiwayatPelatihanVO result = riwayatPelatihanService.add(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
RestUtil.getJsonHttpStatus(HttpStatus.CREATED);
return RestUtil.getJsonResponse("Status Sukses", HttpStatus.CREATED,mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add Status Keluarga", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Status Keluarga", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@Override
public ResponseEntity<Collection<RiwayatPelatihanVO>> getAllVOWithQueryString(HttpServletRequest request, Integer page,
Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<RiwayatPelatihanVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(RiwayatPelatihanVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(RiwayatPelatihanVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<RiwayatPelatihanVO>> getAllVO() {
return null;
}
}

View File

@ -1,34 +1,30 @@
package com.jasamedika.medifirst2000.controller; package com.jasamedika.medifirst2000.controller;
import java.util.Collection; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.List; import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import javax.servlet.http.HttpServletRequest; import com.jasamedika.medifirst2000.exception.ServiceVOException;
import javax.validation.Valid; import com.jasamedika.medifirst2000.service.RiwayatPendidikanService;
import com.jasamedika.medifirst2000.vo.RiwayatPendidikanVO;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; 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.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException; import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import javax.servlet.http.HttpServletRequest;
import com.jasamedika.medifirst2000.constants.Constants; import javax.validation.Valid;
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.RiwayatPendidikanService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.RiwayatPendidikanVO;
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.slf4j.LoggerFactory.getLogger;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
/****************** /******************
* @author Shakato * @author Shakato
@ -36,66 +32,30 @@ import com.jasamedika.medifirst2000.vo.RiwayatPendidikanVO;
@RestController @RestController
@RequestMapping("/riwayat-pendidikan") @RequestMapping("/riwayat-pendidikan")
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class RiwayatPendidikanController extends LocaleController<RiwayatPendidikanVO> implements IBaseRestController<RiwayatPendidikanVO> { public class RiwayatPendidikanController extends LocaleController<RiwayatPendidikanVO> {
private static final Logger LOGGER = getLogger(RiwayatPendidikanController.class);
@Autowired @Autowired
private RiwayatPendidikanService riwayatPendidikanService; private RiwayatPendidikanService riwayatPendidikanService;
private static final Logger LOGGER = LoggerFactory.getLogger(RiwayatPendidikanController.class); @RequestMapping(value = "/save-riwayat-pendidikan", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<String> saveRiwayatPendidikan(@Valid @RequestBody RiwayatPendidikanVO vo,
@RequestMapping(value = "/save-riwayat-pendidikan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) HttpServletRequest request) {
public ResponseEntity<String> saveRiwayatPendidikan(@Valid @RequestBody RiwayatPendidikanVO vo,HttpServletRequest request) {
try { try {
RiwayatPendidikanVO result = riwayatPendidikanService.add(vo); RiwayatPendidikanVO result = riwayatPendidikanService.add(vo);
if (null != result) if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request )); mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
RestUtil.getJsonHttpStatus(HttpStatus.CREATED); return getJsonResponse("Status Sukses", CREATED, mapHeaderMessage);
return RestUtil.getJsonResponse("Status Sukses", HttpStatus.CREATED,mapHeaderMessage);
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add Status Keluarga", e.getMessage()); LOGGER.error("Got ServiceVOException {} when riwayatPendidikanService.add", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Status Keluarga", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when riwayatPendidikanService.add", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
} }
}
@Override
public ResponseEntity<Collection<RiwayatPendidikanVO>> getAllVOWithQueryString(HttpServletRequest request, Integer page,
Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<RiwayatPendidikanVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(RiwayatPendidikanVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(RiwayatPendidikanVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<RiwayatPendidikanVO>> getAllVO() {
return null;
}
} }

View File

@ -1,106 +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 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.RestController;
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.service.RiwayatPenghargaanService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.RiwayatPenghargaanVO;
@RestController
@RequestMapping("/riwayat-penghargaan")
public class RiwayatPenghargaanController extends LocaleController<RiwayatPenghargaanVO> implements IBaseRestController<RiwayatPenghargaanVO> {
@Autowired
private RiwayatPenghargaanService riwayatPenghargaanService;
private static final Logger LOGGER = LoggerFactory
.getLogger(RiwayatPenghargaanController.class);
@Override
public ResponseEntity<Collection<RiwayatPenghargaanVO>> getAllVOWithQueryString(HttpServletRequest request,
Integer page, Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<RiwayatPenghargaanVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(RiwayatPenghargaanVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(RiwayatPenghargaanVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<RiwayatPenghargaanVO>> getAllVO() {
return null;
}
@RequestMapping(value = "/get-riwayat-penghargaan-by-dokter/{dokterId}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> findPenghargaanByIdDokter(@PathVariable("dokterId") Integer dokterId, HttpServletRequest request) {
Map<String, Object> result = null;
try{
result = riwayatPenghargaanService.findPenghargaanByIdDokter(dokterId);
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-nama-riwayat-penghargaan-by-dokter/{dokterId}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> findNamaPenghargaanByIdDokter(@PathVariable("dokterId") Integer dokterId, HttpServletRequest request) {
Map<String, Object> result = null;
try{
result = riwayatPenghargaanService.findNamaPenghargaanByIdDokter(dokterId);
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);
}
}

View File

@ -1,76 +1,72 @@
package com.jasamedika.medifirst2000.controller; package com.jasamedika.medifirst2000.controller;
import java.util.List; import com.jasamedika.medifirst2000.constants.MessageResource;
import java.util.Map; import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import javax.servlet.http.HttpServletRequest; import com.jasamedika.medifirst2000.service.RiwayatPenyakitPengobatanService;
import javax.validation.Valid; import com.jasamedika.medifirst2000.vo.RiwayatPenyakitPengobatanVO;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; 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.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException; import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants; import javax.servlet.http.HttpServletRequest;
import com.jasamedika.medifirst2000.constants.MessageResource; import javax.validation.Valid;
import com.jasamedika.medifirst2000.controller.base.LocaleController; import java.util.List;
import com.jasamedika.medifirst2000.core.web.WebConstants; import java.util.Map;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.RiwayatPenyakitPengobatanService; import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import com.jasamedika.medifirst2000.util.rest.RestUtil; import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import com.jasamedika.medifirst2000.vo.RiwayatPenyakitPengobatanVO; import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.slf4j.LoggerFactory.getLogger;
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 @RestController
@RequestMapping("/riwayat-penyakit-pengobatan") @RequestMapping("/riwayat-penyakit-pengobatan")
public class RiwayatPenyakitPengobatanController extends LocaleController<RiwayatPenyakitPengobatanVO> { public class RiwayatPenyakitPengobatanController extends LocaleController<RiwayatPenyakitPengobatanVO> {
private static final Logger LOGGER = getLogger(RiwayatPenyakitPengobatanController.class);
@Autowired @Autowired
private RiwayatPenyakitPengobatanService service; private RiwayatPenyakitPengobatanService service;
private static final Logger LOGGER = LoggerFactory.getLogger(RiwayatPenyakitPengobatanController.class); @RequestMapping(value = "/save-riwayat-penyakit-pengobatan", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveRiwayatPenyakitPengobatan(
@RequestMapping(value = "/save-riwayat-penyakit-pengobatan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @Valid @RequestBody List<RiwayatPenyakitPengobatanVO> vo, HttpServletRequest request) {
public ResponseEntity<Map<String,Object>> saveRiwayatPenyakitPengobatan(@Valid @RequestBody List<RiwayatPenyakitPengobatanVO> vo,HttpServletRequest request) {
try { try {
Map<String, Object> result = service.saveRiwayatPenyakitPengobatan(vo); Map<String, Object> result = service.saveRiwayatPenyakitPengobatan(vo);
if (null != result) if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when saveRiwayatPenyakitPengobatan", e.getMessage()); LOGGER.error("Got ServiceVOException {} when saveRiwayatPenyakitPengobatan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when saveRiwayatPenyakitPengobatan", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when saveRiwayatPenyakitPengobatan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} }
} }
@RequestMapping(value = "/get-riwayat-penyakit-pengobatan/{noCm}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/get-riwayat-penyakit-pengobatan/{noCm}", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getTindakanByIdUserAndPeriod(@PathVariable("noCm") String noCm, public ResponseEntity<List<Map<String, Object>>> getTindakanByIdUserAndPeriod(@PathVariable("noCm") String noCm,
HttpServletRequest request) { HttpServletRequest request) {
List<Map<String, Object>> result = null;
try { try {
List<Map<String, Object>> result = service.getRiwayatPenyakitPengobatan(noCm);
result = service.getRiwayatPenyakitPengobatan(noCm); mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK);
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); throw new ServiceVOException(e.getMessage());
} }
return RestUtil.getJsonResponse(result, HttpStatus.OK);
} }
} }

View File

@ -1,93 +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.RiwayatPerkembanganPsikomotorService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.KelahiranVO;
import com.jasamedika.medifirst2000.vo.RiwayatPerkembanganPsikomotorVO;
/**
* @author Teguh
*/
@RestController
@RequestMapping("/riwayat-perkembangan-psikomotor")
public class RiwayatPerkembanganPsikomotorController extends LocaleController<KelahiranVO> {
@Autowired
private RiwayatPerkembanganPsikomotorService riwayatPerkembanganPsikomotorService;
private static final Logger LOGGER = LoggerFactory
.getLogger(RiwayatPerkembanganPsikomotorController.class);
@RequestMapping(value = "/save-riwayat-perkembangan-psikomotor/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> addVO(@Valid @RequestBody RiwayatPerkembanganPsikomotorVO vo,HttpServletRequest request) {
try{
Map<String, Object> result = riwayatPerkembanganPsikomotorService.addRiwayatPerkembanganPskomotor(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 riwayat perkembangan psikomotor", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add riwayat perkembangan psikomotor", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value = "/update-riwayat-perkembangan-psikomotor/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> updateVO(@Valid @RequestBody RiwayatPerkembanganPsikomotorVO vo,HttpServletRequest request) {
try{
Map<String, Object> result = riwayatPerkembanganPsikomotorService.addRiwayatPerkembanganPskomotor(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 riwayat perkembangan psikomotor", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when update riwayat perkembangan psikomotor", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
}

View File

@ -1,189 +1,107 @@
package com.jasamedika.medifirst2000.controller; 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.dao.DataIntegrityViolationException;
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.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 com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource; import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.IBaseRestController;
import com.jasamedika.medifirst2000.controller.base.LocaleController; import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.dao.RuanganDao;
import com.jasamedika.medifirst2000.entities.Ruangan; import com.jasamedika.medifirst2000.entities.Ruangan;
import com.jasamedika.medifirst2000.exception.ServiceVOException; import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.RuanganService; import com.jasamedika.medifirst2000.service.RuanganService;
import com.jasamedika.medifirst2000.util.rest.RestUtil; import com.jasamedika.medifirst2000.vo.PasienVO;
import com.jasamedika.medifirst2000.vo.RuanganVO; import com.jasamedika.medifirst2000.vo.RuanganVO;
import org.slf4j.Logger;
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 net.kaczmarzyk.spring.data.jpa.domain.DateBetween; import javax.servlet.http.HttpServletRequest;
import net.kaczmarzyk.spring.data.jpa.domain.GreaterThanOrEqual; import javax.validation.Valid;
import net.kaczmarzyk.spring.data.jpa.domain.In; import java.util.Collection;
import net.kaczmarzyk.spring.data.jpa.domain.LessThanOrEqual; import java.util.Map;
import net.kaczmarzyk.spring.data.jpa.domain.Like;
import net.kaczmarzyk.spring.data.jpa.web.annotation.And; import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import net.kaczmarzyk.spring.data.jpa.web.annotation.JoinFetch; import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import net.kaczmarzyk.spring.data.jpa.web.annotation.Or; import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec; import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.slf4j.LoggerFactory.getLogger;
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 @RestController
@RequestMapping("/ruangan") @RequestMapping("/ruangan")
public class RuanganController extends LocaleController<RuanganVO> implements IBaseRestController<RuanganVO> { public class RuanganController extends LocaleController<RuanganVO> {
private static final Logger LOGGER = getLogger(RuanganController.class);
@Autowired @Autowired
private RuanganService ruanganService; private RuanganService<Ruangan> ruanganService;
@Autowired @RequestMapping(value = "/save-ruangan/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
private RuanganDao ruanganDao;
private static final Logger LOGGER = LoggerFactory.getLogger(RuanganController.class);
public ResponseEntity<Collection<RuanganVO>> getAllVOWithQueryString(HttpServletRequest request, Integer page,
Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<RuanganVO> getVO(@PathVariable("id") Integer id) {
return null;
}
@RequestMapping(value = "/save-ruangan/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> addVO(@Valid @RequestBody RuanganVO vo, HttpServletRequest request) { public ResponseEntity<String> addVO(@Valid @RequestBody RuanganVO vo, HttpServletRequest request) {
try { try {
RuanganVO result = (RuanganVO) ruanganService.add(vo); RuanganVO result = ruanganService.add(vo);
if (null != result) if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
getMessage(MessageResource.LABEL_SUCCESS, request)); return getJsonResponse("", CREATED, mapHeaderMessage);
return RestUtil.getJsonResponse("", HttpStatus.CREATED, mapHeaderMessage);
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add Ruangan", e.getMessage()); LOGGER.error("Got ServiceVOException {} when ruanganService.add", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Ruangan", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when ruanganService.add", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
} }
} @RequestMapping(value = "/update-ruangan/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
@RequestMapping(value = "/update-ruangan/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> editVO(@Valid @RequestBody RuanganVO vo) { public ResponseEntity<String> editVO(@Valid @RequestBody RuanganVO vo) {
try { try {
RuanganVO result = (RuanganVO) ruanganService.update(vo); RuanganVO result = ruanganService.update(vo);
if (null != result) if (null != result)
return RestUtil.getJsonResponse("", HttpStatus.OK); return getJsonResponse("", OK);
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when update Ruangan", e.getMessage()); LOGGER.error("Got ServiceVOException {} when ruanganService.update", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when update Ruangan", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when ruanganService.update", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
return getJsonHttpStatus(NOT_ACCEPTABLE);
} }
return RestUtil.getJsonHttpStatus(HttpStatus.NOT_ACCEPTABLE); @RequestMapping(value = "/get-all-ruangan-rawat-inap", method = GET)
}
@RequestMapping(value = "/delete-ruangan/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> deleteVO(Integer id) {
try {
if (ruanganService.delete(id) == true)
return RestUtil.getJsonResponse("", HttpStatus.OK);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when delete Ruangan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when delete Ruangan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
} catch (DataIntegrityViolationException ex) {
LOGGER.error("Got exception {} when delete Ruangan", ex.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, ex.getMessage());
}
return RestUtil.getJsonHttpStatus(HttpStatus.NOT_ACCEPTABLE);
}
@Override
public ResponseEntity<List<RuanganVO>> getAllVO() {
return null;
}
@Override
public ResponseEntity<String> addVO(RuanganVO vo) {
return null;
}
@SuppressWarnings("unchecked")
@RequestMapping(value = "/get-all-ruangan-laboratorium", method = RequestMethod.GET)
public ResponseEntity<Collection<RuanganVO>> getAllRuanganLaboratorium(HttpServletRequest request) {
Collection<RuanganVO> resultPageMap = ruanganService.findRuanganLaboratorium();
return RestUtil.getJsonResponse(resultPageMap, HttpStatus.OK);
}
@SuppressWarnings("unchecked")
@RequestMapping(value = "/get-all-ruangan-rawat-inap", method = RequestMethod.GET)
public ResponseEntity<Collection<RuanganVO>> getAllRuanganRawatInap(HttpServletRequest request) { public ResponseEntity<Collection<RuanganVO>> getAllRuanganRawatInap(HttpServletRequest request) {
Collection<RuanganVO> resultPageMap = ruanganService.findRuanganRanap(); Collection<RuanganVO> resultPageMap = ruanganService.findRuanganRanap();
return getJsonResponse(resultPageMap, OK);
return RestUtil.getJsonResponse(resultPageMap, HttpStatus.OK);
} }
@RequestMapping(value = "/get-all-ruangan-rawat-jalan", method = RequestMethod.GET) @RequestMapping(value = "/get-all-ruangan-rawat-jalan", method = GET)
public ResponseEntity<Collection<RuanganVO>> getAllRuanganRawatJalan(HttpServletRequest request) { public ResponseEntity<Collection<RuanganVO>> getAllRuanganRawatJalan(HttpServletRequest request) {
Collection<RuanganVO> resultPageMap = ruanganService.findRuanganJalan(); Collection<RuanganVO> resultPageMap = ruanganService.findRuanganJalan();
return getJsonResponse(resultPageMap, OK);
return RestUtil.getJsonResponse(resultPageMap, HttpStatus.OK);
} }
@RequestMapping(value = "/get-all-ruangan-penunjang", method = RequestMethod.GET) @RequestMapping(value = "/get-all-ruangan-penunjang", method = GET)
public ResponseEntity<Collection<RuanganVO>> getAllRuanganPenunjang(HttpServletRequest request) { public ResponseEntity<Collection<RuanganVO>> getAllRuanganPenunjang(HttpServletRequest request) {
Collection<RuanganVO> resultPageMap = ruanganService.findRuanganJalan(); Collection<RuanganVO> resultPageMap = ruanganService.findRuanganJalan();
return getJsonResponse(resultPageMap, OK);
return RestUtil.getJsonResponse(resultPageMap, HttpStatus.OK);
} }
@RequestMapping(value = "/get-all-ruangan-operator", method = RequestMethod.GET) @RequestMapping(value = "/get-all-ruangan-operator", method = GET)
public ResponseEntity<Collection<RuanganVO>> getAllRuanganOperator(HttpServletRequest request) { public ResponseEntity<Collection<RuanganVO>> getAllRuanganOperator(HttpServletRequest request) {
Collection<RuanganVO> resultPageMap = ruanganService.findRuanganOperator(); Collection<RuanganVO> resultPageMap = ruanganService.findRuanganOperator();
return getJsonResponse(resultPageMap, OK);
return RestUtil.getJsonResponse(resultPageMap, HttpStatus.OK);
} }
@SuppressWarnings("unchecked") @RequestMapping(value = "/search-ruangan-by-name", method = GET, produces = APPLICATION_JSON_VALUE)
@RequestMapping(value = "/search-ruangan-by-name", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Collection<PasienVO>> getAllVOWithQueryString(
public ResponseEntity<Collection<RuanganVO>> getAllVOWithQueryString(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page, @RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "limit", required = false, defaultValue = "10") Integer limit, @RequestParam(value = "limit", required = false, defaultValue = "10") Integer limit,
@RequestParam(value = "sort", required = false, defaultValue = "id") String sort, @RequestParam(value = "sort", required = false, defaultValue = "id") String sort,
@ -191,288 +109,32 @@ public class RuanganController extends LocaleController<RuanganVO> implements IB
@RequestParam(value = "nama", required = false) String nama, @RequestParam(value = "nama", required = false) String nama,
@RequestParam(value = "kdRuangan", required = false) String kdRuangan) { @RequestParam(value = "kdRuangan", required = false) String kdRuangan) {
Map<String, Object> resultPageMap = ruanganService.findByName(page, limit, sort, dir, nama, kdRuangan); Map<String, Object> resultPageMap = ruanganService.findByName(page, limit, sort, dir, nama, kdRuangan);
return constructListPageResult(resultPageMap); return constructListPageResult(resultPageMap);
} }
@RequestMapping(value = "/get-all-ruangan-by-id-dept", method = GET, produces = APPLICATION_JSON_VALUE)
@SuppressWarnings("unchecked")
@RequestMapping(value = "/multipleCondition")
@ResponseBody
public ResponseEntity<List<Object>> multipleCondition(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "take", required = false, defaultValue = "10") Integer limit,
@RequestParam(value = "sort", required = false, defaultValue = "id") String sort,
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
@Spec(path = "qRuangan", params = "qRuangan", spec = In.class) Specification<Ruangan> noRuangan,
@Or({ @Spec(params = "namaRuangan", path = "namaRuangan", spec = Like.class),
@Spec(params = "kdRuangan", path = "kdRuangan", spec = Like.class) }) Specification<Ruangan> nameSpec) {
Specification<Ruangan> spec = Specifications.where(noRuangan).and(nameSpec);
Map<String, Object> resultPageMap = ruanganService.ruanganPaging(page,limit,sort,dir,spec);
return constructListPageResult(resultPageMap);
}
@SuppressWarnings("unchecked")
@RequestMapping(value = "/orCondition")
@ResponseBody
public ResponseEntity<List<Object>> orCondition(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "take", required = false, defaultValue = "10") Integer limit,
@RequestParam(value = "sort", required = false, defaultValue = "id") String sort,
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
@Or({ @Spec(path = "namaRuangan", spec = Like.class),
@Spec(path = "kdRuangan", spec = Like.class) }) Specification<Ruangan> spec) {
Map<String, Object> resultPageMap = ruanganService.ruanganPaging(page,limit,sort,dir,spec);
return constructListPageResult(resultPageMap);
}
@SuppressWarnings("unchecked")
@RequestMapping(value = "/andCondition")
@ResponseBody
public ResponseEntity<List<Object>> andCondition(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "take", required = false, defaultValue = "10") Integer limit,
@RequestParam(value = "sort", required = false, defaultValue = "id") String sort,
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
@And({ @Spec(path = "namaRuangan", spec = Like.class),
@Spec(path = "kdRuangan", spec = Like.class) }) Specification<Ruangan> spec) {
Map<String, Object> resultPageMap = ruanganService.ruanganPaging(page,limit,sort,dir,spec);
return constructListPageResult(resultPageMap);
}
@SuppressWarnings("unchecked")
@RequestMapping(value = "/joinCondition")
public ResponseEntity<List<Object>> joinCondition(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "take", required = false, defaultValue = "10") Integer limit,
@RequestParam(value = "sort", required = false, defaultValue = "id") String sort,
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
@JoinFetch(paths = { "departemen" })
@Spec(path="departemen.namaDepartemen", params="namaDepartemen", spec=Like.class) Specification<Ruangan> spec) {
Map<String, Object> resultPageMap = ruanganService.ruanganPaging(page,limit,sort,dir,spec);
return constructListPageResult(resultPageMap);
}
@SuppressWarnings("unchecked")
@RequestMapping(value = "/dateBetweenCondition")
@ResponseBody
public ResponseEntity<List<Object>> findRuangansByRegistrationDate(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "take", required = false, defaultValue = "10") Integer limit,
@RequestParam(value = "sort", required = false, defaultValue = "id") String sort,
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
@Spec(path = "tanggal", params = {"dateStart", "dateEnd"}, config = "yyyy-MM-dd", spec = DateBetween.class) Specification<Ruangan> spec) {
Map<String, Object> resultPageMap = ruanganService.ruanganPaging(page,limit,sort,dir,spec);
return constructListPageResult(resultPageMap);
}
@SuppressWarnings("unchecked")
@RequestMapping(value = "/dateBefore")
@ResponseBody
public ResponseEntity<List<Object>> dateBefore(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "take", required = false, defaultValue = "10") Integer limit,
@RequestParam(value = "sort", required = false, defaultValue = "id") String sort,
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
@Spec(path = "tanggal", params = "tanggal", config = "yyyy-MM-dd", spec = LessThanOrEqual.class) Specification<Ruangan> spec) {
Map<String, Object> resultPageMap = ruanganService.ruanganPaging(page,limit,sort,dir,spec);
return constructListPageResult(resultPageMap);
}
@SuppressWarnings("unchecked")
@RequestMapping(value = "/dateAfter")
@ResponseBody
public ResponseEntity<List<Object>> dateAfter(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "take", required = false, defaultValue = "10") Integer limit,
@RequestParam(value = "sort", required = false, defaultValue = "id") String sort,
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
@Spec(path = "tanggal", params = "tanggal", config = "yyyy-MM-dd", spec = GreaterThanOrEqual.class) Specification<Ruangan> spec) {
Map<String, Object> resultPageMap = ruanganService.ruanganPaging(page,limit,sort,dir,spec);
return constructListPageResult(resultPageMap);
}
@SuppressWarnings("unchecked")
@RequestMapping(value = "/greaterThan")
@ResponseBody
public ResponseEntity<List<Object>> greaterThan(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "take", required = false, defaultValue = "10") Integer limit,
@RequestParam(value = "sort", required = false, defaultValue = "id") String sort,
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
@Spec(path = "noCounter", params = "noCounter", spec = GreaterThanOrEqual.class) Specification<Ruangan> spec) {
Map<String, Object> resultPageMap = ruanganService.ruanganPaging(page,limit,sort,dir,spec);
return constructListPageResult(resultPageMap);
}
@SuppressWarnings("unchecked")
@RequestMapping(value = "/lessThan")
@ResponseBody
public ResponseEntity<List<Object>> lessThan(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "take", required = false, defaultValue = "10") Integer limit,
@RequestParam(value = "sort", required = false, defaultValue = "id") String sort,
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
@Spec(path = "noCounter", params = "noCounter", spec = LessThanOrEqual.class) Specification<Ruangan> spec) {
Map<String, Object> resultPageMap = ruanganService.ruanganPaging(page,limit,sort,dir,spec);
return constructListPageResult(resultPageMap);
}
@RequestMapping(value = "/get-list-ruangan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getJadwalKerja(
HttpServletRequest request) {
List<Map<String, Object>> result = null;
try {
result = ruanganService.findRuangan();
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
} catch (Exception e) {
e.printStackTrace();
}
return RestUtil.getJsonResponse(result, HttpStatus.OK);
}
@RequestMapping(value = "/get-all-ruangan-for-tagihan", method = RequestMethod.GET)
public ResponseEntity< Map<String,Object>> findAllDepartemenById5And6(
@RequestParam(value = "instalasiId", required = false) Integer instalasiId,
HttpServletRequest request) {
try {
Map<String,Object> listPegawaiVo = ruanganService.findAllRuanganForTagihan( instalasiId);
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(listPegawaiVo, HttpStatus.OK,mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when get all dokter", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(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.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-all-unit-kerja", method = RequestMethod.GET)
public ResponseEntity<List<Map<String,Object>>> findAllUnitKerja(
HttpServletRequest request) {
try {
List<Map<String,Object>> listUnitKerja = ruanganService.findRuanganUnitKerja();
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(listUnitKerja, HttpStatus.OK,mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when get all unit kerja", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when get all unit kerja", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
/*
* Author Iwan Kasan
*/
@RequestMapping(
value = "/get-all-ruangan-by-id-dept",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getRuanganByIdDep(final HttpServletRequest request) { public ResponseEntity<Map<String, Object>> getRuanganByIdDep(final HttpServletRequest request) {
Map<String, Object> result = this.ruanganService.getRuanganByIdDep(); Map<String, Object> result = this.ruanganService.getRuanganByIdDep();
boolean dataFound = (boolean) result.get("dataFound");
Boolean dataFound = new Boolean((boolean) result.get("dataFound"));
if (dataFound) { if (dataFound) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
getMessage(MessageResource.LABEL_SUCCESS, request)); } else {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_ERROR, request));
} }
else { return getJsonResponse(result, OK);
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_ERROR, request));
}
return RestUtil.getJsonResponse(result, HttpStatus.OK);
} }
/* @RequestMapping(value = "/get-jml-tempattidur-byruangan", method = GET, produces = APPLICATION_JSON_VALUE)
* Author Iwan Kasan
*/
@RequestMapping(
value = "/get-jml-tempattidur-ruangan",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getJmlTempatTidur(final HttpServletRequest request) {
Map<String, Object> result = this.ruanganService.getJmlTempatTidur();
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);
}
/*
* Author Iwan Kasan
*/
@RequestMapping(
value = "/get-jml-tempattidur-byruangan",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getJmlTempatTidurByIdRuangan( public ResponseEntity<Map<String, Object>> getJmlTempatTidurByIdRuangan(
@RequestParam(value = "idRuangan", required = false) Integer idRuangan, final HttpServletRequest request) { @RequestParam(value = "idRuangan", required = false) Integer idRuangan, final HttpServletRequest request) {
Map<String, Object> result = this.ruanganService.getJmlTempatTidurByIdRuangan(idRuangan); Map<String, Object> result = this.ruanganService.getJmlTempatTidurByIdRuangan(idRuangan);
boolean dataFound = (boolean) result.get("dataFound");
Boolean dataFound = new Boolean((boolean) result.get("dataFound"));
if (dataFound) { if (dataFound) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
getMessage(MessageResource.LABEL_SUCCESS, request)); } else {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_ERROR, request));
} }
else { return getJsonResponse(result, OK);
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_ERROR, request));
}
return RestUtil.getJsonResponse(result, HttpStatus.OK);
} }
} }

View File

@ -1,135 +0,0 @@
/*package com.jasamedika.medifirst2000.controller;
import java.awt.Rectangle;
import java.util.Collection;
import java.util.List;
import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
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 org.springframework.web.util.UriComponentsBuilder;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.controller.base.IBaseRestController;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.entities.AgamaM;
import com.jasamedika.medifirst2000.entities.KelasM;
import com.jasamedika.medifirst2000.entities.PurchasedTest;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.ModelService;
import com.jasamedika.medifirst2000.service.RuanganMService;
import com.jasamedika.medifirst2000.service.KelasMService;
import com.jasamedika.medifirst2000.service.TestService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.ModelVO;
import com.jasamedika.medifirst2000.vo.PasienVO;
import com.jasamedika.medifirst2000.vo.RuanganMVO;
import com.jasamedika.medifirst2000.vo.ModelVO;
import com.jasamedika.medifirst2000.vo.KelasMVO;
*//**
* Controller class for KelasM Business
*
* @author Roberto
*//*
@RestController
@RequestMapping("/ruanganM")
public class RuanganMController extends LocaleController<RuanganMVO> implements IBaseRestController<KelasMVO> {
@Autowired
private TestService testService;
@Autowired
private RuanganMService ruanganMService;
private static final Logger LOGGER = LoggerFactory
.getLogger(KelasMController.class);
@Override
public ResponseEntity<Collection<KelasMVO>> getAllVOWithQueryString(Integer page, Integer limit, String sort,
String dir) {
return null;
}
@Override
public ResponseEntity<KelasMVO> getVO(String id) {
return null;
}
@RequestMapping(value = "/save-ruangan/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> addVO(@Valid @RequestBody RuanganMVO vo) {
try {
RuanganMVO result = ruanganMService.add(vo);
if (null != result)
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,"");
RestUtil.getJsonHttptatus(HttpStatus.CREATED);
return RestUtil.getJsonResponse(vo.getId().toString(), HttpStatus.CREATED);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add RuanganM", 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 RuanganM", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value = "/list-ruangan", method = RequestMethod.GET)
public ResponseEntity<List<RuanganMVO>> listRuangan() {
List<RuanganMVO> listRuanganMVO = ruanganMService.findAll();
return RestUtil.getJsonResponse(listRuanganMVO, HttpStatus.OK,mapHeaderMessage);
}
@Override
public ResponseEntity<String> editVO(KelasMVO vo) {
return null;
}
@Override
protected List<RuanganMVO> getAllVOFromService() {
return null;
}
@Override
public ResponseEntity<String> addVO(KelasMVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<Collection<KelasMVO>> getAllVO() {
return null;
}
}
*/

View File

@ -1,57 +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.RunningNumberService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
@RestController
@RequestMapping("/pasien-daftar-setting")
public class RunningNumberController extends LocaleController{
@Autowired
private RunningNumberService service;
private static final Logger LOGGER = LoggerFactory.getLogger(IpsrsDataAlatController.class);
@RequestMapping(value = "/update-nocm", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getOneRegistrasiAset(
@RequestParam(value = "noCm", required = true) String noCm, HttpServletRequest request) {
try {
Map<String,Object> result = service.saveNoCmPasien(noCm);
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 getOneRegistrasiAset", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(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.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
}

View File

@ -1,142 +1,123 @@
package com.jasamedika.medifirst2000.controller; package com.jasamedika.medifirst2000.controller;
import java.util.Map; import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import javax.servlet.http.HttpServletRequest; import com.jasamedika.medifirst2000.exception.ServiceVOException;
import javax.validation.Valid; import com.jasamedika.medifirst2000.service.SanitasiKesehatanLingkunganService;
import com.jasamedika.medifirst2000.vo.SanitasiKesehatanLingkunganVO;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; 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.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException; import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; 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.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants; import javax.servlet.http.HttpServletRequest;
import com.jasamedika.medifirst2000.constants.MessageResource; import javax.validation.Valid;
import com.jasamedika.medifirst2000.controller.base.LocaleController; import java.util.Map;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException; import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import com.jasamedika.medifirst2000.service.SanitasiKesehatanLingkunganService; import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import com.jasamedika.medifirst2000.util.rest.RestUtil; import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import com.jasamedika.medifirst2000.vo.SanitasiKesehatanLingkunganVO; import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.slf4j.LoggerFactory.getLogger;
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 @RestController
@RequestMapping("/sanitasi-kesehatan-lingkungan") @RequestMapping("/sanitasi-kesehatan-lingkungan")
public class SanitasiKesehatanLingkunganController extends LocaleController<SanitasiKesehatanLingkunganVO> { public class SanitasiKesehatanLingkunganController extends LocaleController<SanitasiKesehatanLingkunganVO> {
private static final Logger LOGGER = getLogger(SanitasiKesehatanLingkunganController.class);
@Autowired @Autowired
private SanitasiKesehatanLingkunganService service; private SanitasiKesehatanLingkunganService service;
private static final Logger LOGGER = LoggerFactory.getLogger(SanitasiKesehatanLingkunganController.class); @RequestMapping(value = "/get-user-login", method = GET, produces = APPLICATION_JSON_VALUE)
@RequestMapping(value = "/get-unit-ruangan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getUnitRuangan(HttpServletRequest request) {
try {
Map<String,Object> 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);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getUnitRuangan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getUnitRuangan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-user-login", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getUserLogin(HttpServletRequest request) { public ResponseEntity<Map<String, Object>> getUserLogin(HttpServletRequest request) {
try { try {
Map<String, Object> result = service.getUserLogin(); Map<String, Object> result = service.getUserLogin();
if (null != result) { if (null != result) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); return getJsonResponse(result, OK, mapHeaderMessage);
} else { } else {
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
} }
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getUserLogin", e.getMessage()); LOGGER.error("Got ServiceVOException {} when getUserLogin", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getUserLogin", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when getUserLogin", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} }
} }
@RequestMapping(value = "/get-parameter-sanitasi", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/get-parameter-sanitasi", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getParameterSanitasi(HttpServletRequest request) { public ResponseEntity<Map<String, Object>> getParameterSanitasi(HttpServletRequest request) {
try { try {
Map<String, Object> result = service.getParameterSanitasi(); Map<String, Object> result = service.getParameterSanitasi();
if (null != result) { if (null != result) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); return getJsonResponse(result, OK, mapHeaderMessage);
} else { } else {
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
} }
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getParameterSanitasi", e.getMessage()); LOGGER.error("Got ServiceVOException {} when getParameterSanitasi", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getParameterSanitasi", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when getParameterSanitasi", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} }
} }
@RequestMapping(value = "/get-petugas-ruangan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/get-petugas-ruangan", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getPjRuangan( public ResponseEntity<Map<String, Object>> getPjRuangan(
@RequestParam(value = "ruanganId", required = true) Integer ruanganId, HttpServletRequest request) { @RequestParam(value = "ruanganId") Integer ruanganId, HttpServletRequest request) {
try { try {
Map<String, Object> result = service.getPjRuangan(ruanganId); Map<String, Object> result = service.getPjRuangan(ruanganId);
if (null != result) { if (null != result) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage); return getJsonResponse(result, OK, mapHeaderMessage);
} else { } else {
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage); return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
} }
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getPjRuangan", e.getMessage()); LOGGER.error("Got ServiceVOException {} when getPjRuangan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getPjRuangan", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when getPjRuangan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} }
} }
@RequestMapping(value = "/save-sanitasi-kesehatan-lingkungan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/save-sanitasi-kesehatan-lingkungan", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveSanitasiKesehatanLingkungan(@Valid @RequestBody SanitasiKesehatanLingkunganVO vo, HttpServletRequest request) { public ResponseEntity<Map<String, Object>> saveSanitasiKesehatanLingkungan(
@Valid @RequestBody SanitasiKesehatanLingkunganVO vo, HttpServletRequest request) {
try { try {
Map<String, Object> result = service.saveSanitasiKesehatanLingkungan(vo); Map<String, Object> result = service.saveSanitasiKesehatanLingkungan(vo);
if (null != result) if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request)); mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage); return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) { } catch (ServiceVOException e) {
LOGGER.error("Got exception {} when saveSanitasiKesehatanLingkungan", e.getMessage()); LOGGER.error("Got ServiceVOException {} when saveSanitasiKesehatanLingkungan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage()); addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage); return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) { } catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when saveSanitasiKesehatanLingkungan", jse.getMessage()); LOGGER.error("Got JpaSystemException {} when saveSanitasiKesehatanLingkungan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage()); addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage); return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} }
} }
} }