Update controller

Clean code
This commit is contained in:
Salman Manoe 2024-12-31 14:14:44 +07:00
parent 1dbc607a88
commit 72e5251785
13 changed files with 591 additions and 1184 deletions

View File

@ -1,143 +1,140 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PengukuranKebisinganService;
import com.jasamedika.medifirst2000.vo.PengukuranKebisinganVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
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.PengukuranKebisinganService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.PengukuranKebisinganVO;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.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
@RequestMapping("/pengukuran-kebisingan")
public class PengukuranKebisinganController extends LocaleController<PengukuranKebisinganVO>{
public class PengukuranKebisinganController extends LocaleController<PengukuranKebisinganVO> {
private static final Logger LOGGER = getLogger(PengukuranKebisinganController.class);
@Autowired
private PengukuranKebisinganService service;
private static final Logger LOGGER = LoggerFactory.getLogger(PengukuranKebisinganController.class);
@RequestMapping(value = "/get-unit-ruangan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/get-unit-ruangan", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<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);
Map<String, Object> result = service.getUnitRuangan();
if (null != result) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getUnitRuangan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getUnitRuangan", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getUnitRuangan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getUnitRuangan", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-baku-mutu", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/get-baku-mutu", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getBakuMutu(HttpServletRequest request) {
try {
Map<String,Object> result = service.getBakuMutu();
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
} else{
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
Map<String, Object> result = service.getBakuMutu();
if (null != result) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getBakuMutu", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getBakuMutu", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getBakuMutu", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getBakuMutu", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/save-pengukuran-kebisingan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> savePengukuranKebisingan(@Valid @RequestBody PengukuranKebisinganVO vo, HttpServletRequest request) {
@RequestMapping(value = "/save-pengukuran-kebisingan", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> savePengukuranKebisingan(@Valid @RequestBody PengukuranKebisinganVO vo,
HttpServletRequest request) {
try {
vo.setMenutype("kebisingan");
Map<String,Object> result = service.savePengukuranKebisingan(vo);
Map<String, Object> result = service.savePengukuranKebisingan(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when savePengukuranKebisingan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when savePengukuranKebisingan", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when savePengukuranKebisingan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when savePengukuranKebisingan", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-pengukuran-kebisingan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/get-pengukuran-kebisingan", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getPengukuranKebisingan(HttpServletRequest request) {
try {
Map<String,Object> result = service.getPengukuranKebisingan();
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
} else{
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
Map<String, Object> result = service.getPengukuranKebisingan();
if (null != result) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getPengukuranKebisingan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getPengukuranKebisingan", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getPengukuranKebisingan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getPengukuranKebisingan", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping("/lapPengukuranKebisingan")
public ModelAndView generateLapHasilPemeriksaanSWAPantauLimbahCair(ModelAndView m,
@RequestParam(value = "format", required = false) String format,
@RequestParam(value = "startDate", required = true) String startDate,
@RequestParam(value = "endDate", required = true) String endDate) {
@RequestParam(value = "startDate") String startDate, @RequestParam(value = "endDate") String endDate) {
Map<String, Object> result = this.service.getRepotingPengukurangKebisingan(startDate, endDate);
Map<String, Object> header = (Map<String, Object>) result.get("header");
String periode = header.get("startDate") == null ? "" : (String) header.get("startDate");
periode = periode + (header.get("endDate") == null ? "" : " sd " + (String) header.get("endDate"));
periode = periode + (header.get("endDate") == null ? "" : " sd " + header.get("endDate"));
m.addObject("dataSource", result.get("listData"));
m.addObject("periode", periode);
m.addObject("format", "pdf");
if (format != null && !format.isEmpty()) {
if (format != null && !format.isEmpty())
m.addObject("format", format);
}
return m;
}
}

View File

@ -1,143 +1,98 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PengukuranKelembabanService;
import com.jasamedika.medifirst2000.vo.PengukuranKebisinganVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
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.PengukuranKelembabanService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.PengukuranKebisinganVO;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.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
@RequestMapping("/pengukuran-kelembaban")
public class PengukuranKelembabanController extends LocaleController<PengukuranKebisinganVO>{
public class PengukuranKelembabanController extends LocaleController<PengukuranKebisinganVO> {
private static final Logger LOGGER = getLogger(PengukuranKelembabanController.class);
@Autowired
private PengukuranKelembabanService service;
private static final Logger LOGGER = LoggerFactory.getLogger(PengukuranKelembabanController.class);
@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-baku-mutu", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getBakuMutu(HttpServletRequest request) {
try {
Map<String,Object> result = service.getBakuMutu();
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 getBakuMutu", 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 getBakuMutu", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/save-pengukuran-kelembaban", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> savePengukuranKelembaban(@Valid @RequestBody PengukuranKebisinganVO vo, HttpServletRequest request) {
@RequestMapping(value = "/save-pengukuran-kelembaban", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> savePengukuranKelembaban(@Valid @RequestBody PengukuranKebisinganVO vo,
HttpServletRequest request) {
try {
vo.setMenutype("kelembaban");
Map<String,Object> result = service.savePengukuranKelembaban(vo);
Map<String, Object> result = service.savePengukuranKelembaban(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when savePengukuranKelembaban", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when savePengukuranKelembaban", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when savePengukuranKelembaban", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when savePengukuranKelembaban", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-pengukuran-kelembaban", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/get-pengukuran-kelembaban", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getPengukuranKelembaban(HttpServletRequest request) {
try {
Map<String,Object> result = service.getPengukuranKelembaban();
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
} else{
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
Map<String, Object> result = service.getPengukuranKelembaban();
if (null != result) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getPengukuranKebisingan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getPengukuranKelembaban", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getPengukuranKebisingan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getPengukuranKelembaban", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping("/lapPengukuranKelembaban")
public ModelAndView lapPengukuranKelembaban(ModelAndView m,
@RequestParam(value = "format", required = false) String format,
@RequestParam(value = "startDate", required = true) String startDate,
@RequestParam(value = "endDate", required = true) String endDate) {
@RequestParam(value = "startDate") String startDate, @RequestParam(value = "endDate") String endDate) {
Map<String, Object> result = this.service.getRepotingPengukurangKelembaban(startDate, endDate);
Map<String, Object> header = (Map<String, Object>) result.get("header");
String periode = header.get("startDate") == null ? "" : (String) header.get("startDate");
periode = periode + (header.get("endDate") == null ? "" : " sd " + (String) header.get("endDate"));
periode = periode + (header.get("endDate") == null ? "" : " sd " + header.get("endDate"));
m.addObject("dataSource", result.get("listData"));
m.addObject("periode", periode);
m.addObject("format", "pdf");
if (format != null && !format.isEmpty()) {
if (format != null && !format.isEmpty())
m.addObject("format", format);
}
return m;
}
}

View File

@ -1,111 +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.PengukuranKinerjaKegiatanService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.PengukuranKinerjaKegiatanVO;
@RestController
@RequestMapping("/pengukuran-kinerja-kegiatan")
public class PengukuranKinerjaKegiatanController extends LocaleController<PengukuranKinerjaKegiatanVO> {
@Autowired
private PengukuranKinerjaKegiatanService pengukuranKinerjaKegiatanService;
private static final Logger LOGGER = LoggerFactory
.getLogger(PengukuranKinerjaKegiatanController.class);
@RequestMapping(value = "/save-pengukuran-kinerja-kegiatan/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> addVO(@Valid @RequestBody PengukuranKinerjaKegiatanVO vo,HttpServletRequest request) {
try{
Map<String, Object> result = pengukuranKinerjaKegiatanService.addPengukuranKinerjaKegiatan(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 pengukuran kinerja kegiatan", 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 pengukuran kinerja kegiatan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value = "/update-pengukuran-kinerja-kegiatan/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> updateVO(@Valid @RequestBody PengukuranKinerjaKegiatanVO vo,HttpServletRequest request) {
try{
Map<String, Object> result = pengukuranKinerjaKegiatanService.addPengukuranKinerjaKegiatan(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 pengukuran kinerja kegiatan", 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 pengukuran kinerja kegiatan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value = "/find-all-pengukuran-kinerja-kegiatan/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> getAllVO(HttpServletRequest request) {
try {
Map<String,Object> result=pengukuranKinerjaKegiatanService.findAllPengukuranKinerjaKegiatan();
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when get all pengukuran kinerja kegiatan", 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 pengukuran kinerja kegiatan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
}

View File

@ -1,145 +1,98 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PengukuranPencahayaanService;
import com.jasamedika.medifirst2000.vo.PengukuranKebisinganVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
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.PengukuranPencahayaanService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.PengukuranKebisinganVO;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.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
@RequestMapping("/pengukuran-pencahayaan")
public class PengukuranPencahayaanController extends LocaleController<PengukuranKebisinganVO>{
public class PengukuranPencahayaanController extends LocaleController<PengukuranKebisinganVO> {
private static final Logger LOGGER = getLogger(PengukuranPencahayaanController.class);
@Autowired
private PengukuranPencahayaanService service;
private static final Logger LOGGER = LoggerFactory.getLogger(PengukuranPencahayaanController.class);
@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-baku-mutu", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getBakuMutu(HttpServletRequest request) {
try {
Map<String,Object> result = service.getBakuMutu();
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 getBakuMutu", 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 getBakuMutu", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/save-pengukuran-pencahayaan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> savePengukuranPencahayaan(@Valid @RequestBody PengukuranKebisinganVO vo, HttpServletRequest request) {
@RequestMapping(value = "/save-pengukuran-pencahayaan", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> savePengukuranPencahayaan(@Valid @RequestBody PengukuranKebisinganVO vo,
HttpServletRequest request) {
try {
vo.setMenutype("pencahayaan");
Map<String,Object> result = service.savePengukuranPencahayaan(vo);
Map<String, Object> result = service.savePengukuranPencahayaan(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when savePengukuranPencahayaan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when savePengukuranPencahayaan", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when savePengukuranPencahayaan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when savePengukuranPencahayaan", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-pengukuran-pencahayaan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/get-pengukuran-pencahayaan", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getPengukuranPencahayaan(HttpServletRequest request) {
try {
Map<String,Object> result = service.getPengukuranPencahayaan();
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
} else{
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
Map<String, Object> result = service.getPengukuranPencahayaan();
if (null != result) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getPengukuranKebisingan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getPengukuranPencahayaan", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getPengukuranKebisingan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getPengukuranPencahayaan", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
}
@RequestMapping("/lapPengukuranPencahayaan")
public ModelAndView lapPengukuranPencahayaan(ModelAndView m,
@RequestParam(value = "format", required = false) String format,
@RequestParam(value = "startDate", required = true) String startDate,
@RequestParam(value = "endDate", required = true) String endDate) {
@RequestParam(value = "startDate") String startDate, @RequestParam(value = "endDate") String endDate) {
Map<String, Object> result = this.service.getRepotingPengukurangPencahayaan(startDate, endDate);
Map<String, Object> header = (Map<String, Object>) result.get("header");
String periode = header.get("startDate") == null ? "" : (String) header.get("startDate");
periode = periode + (header.get("endDate") == null ? "" : " sd " + (String) header.get("endDate"));
periode = periode + (header.get("endDate") == null ? "" : " sd " + header.get("endDate"));
m.addObject("dataSource", result.get("listData"));
m.addObject("periode", periode);
m.addObject("format", "pdf");
if (format != null && !format.isEmpty()) {
if (format != null && !format.isEmpty())
m.addObject("format", format);
}
return m;
}
}

View File

@ -1,24 +1,5 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
@ -27,66 +8,41 @@ import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PengukuranSuhuService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.PengukuranKebisinganVO;
import org.slf4j.Logger;
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.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController
@RequestMapping("/pengukuran-suhu")
public class PengukuranSuhuController extends LocaleController<PengukuranKebisinganVO>{
public class PengukuranSuhuController extends LocaleController<PengukuranKebisinganVO> {
private static final Logger LOGGER = getLogger(PengukuranSuhuController.class);
@Autowired
private PengukuranSuhuService service;
private static final Logger LOGGER = LoggerFactory.getLogger(PengukuranSuhuController.class);
@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-baku-mutu", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getBakuMutu(HttpServletRequest request) {
try {
Map<String,Object> result = service.getBakuMutu();
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 getBakuMutu", 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 getBakuMutu", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/save-pengukuran-suhu", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> savePengukuranPencahayaan(@Valid @RequestBody PengukuranKebisinganVO vo, HttpServletRequest request) {
@RequestMapping(value = "/save-pengukuran-suhu", method = POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> savePengukuranPencahayaan(@Valid @RequestBody PengukuranKebisinganVO vo,
HttpServletRequest request) {
try {
vo.setMenutype("suhu");
Map<String,Object> result = service.savePengukuranSuhu(vo);
Map<String, Object> result = service.savePengukuranSuhu(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
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 savePengukuranPencahayaan", e.getMessage());
@ -98,16 +54,17 @@ public class PengukuranSuhuController extends LocaleController<PengukuranKebisin
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-pengukuran-suhu", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getPengukuranKelembaban(HttpServletRequest request) {
try {
Map<String,Object> result = service.getPengukuranSuhu();
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
} else{
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
Map<String, Object> result = service.getPengukuranSuhu();
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 getPengukuranKebisingan", e.getMessage());
@ -119,7 +76,7 @@ public class PengukuranSuhuController extends LocaleController<PengukuranKebisin
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping("/lapPengukuranSuhu")
public ModelAndView lapPengukuranSuhu(ModelAndView m,
@RequestParam(value = "format", required = false) String format,
@ -127,7 +84,7 @@ public class PengukuranSuhuController extends LocaleController<PengukuranKebisin
@RequestParam(value = "endDate", required = true) String endDate) {
Map<String, Object> result = this.service.getRepotingPengukurangSuhu(startDate, endDate);
Map<String, Object> header = (Map<String, Object>) result.get("header");
String periode = header.get("startDate") == null ? "" : (String) header.get("startDate");
periode = periode + (header.get("endDate") == null ? "" : " sd " + (String) header.get("endDate"));

View File

@ -1,59 +1,57 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PenilaianKinerjaSatpamService;
import com.jasamedika.medifirst2000.vo.PenilaianKinerjaSatpamVO;
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.PenilaianKinerjaSatpamService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.PenilaianKinerjaSatpamVO;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.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;
@RestController
@RequestMapping("/penilaian-kinerja-satpam")
public class PenilaianKinerjaSatpamController extends LocaleController<PenilaianKinerjaSatpamVO> {
private static final Logger LOGGER = getLogger(PenilaianKinerjaSatpamController.class);
@Autowired
private PenilaianKinerjaSatpamService penilaianKinerjaSatpamService;
private static final Logger LOGGER = LoggerFactory.getLogger(PenilaianKinerjaSatpamController.class);
@RequestMapping(value = "/save-penilaian-kinerja-satpam/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/save-penilaian-kinerja-satpam/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> savePenilaianKinerjaSatpam(
@Valid @RequestBody PenilaianKinerjaSatpamVO vo, HttpServletRequest request) {
try {
Map<String, Object> result = penilaianKinerjaSatpamService.savePenilaianKinerjaSatpam(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when save Penilaian Kinerja Satpam", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when savePenilaianKinerjaSatpam", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when save Penilaian Kinerja Satpam", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when savePenilaianKinerjaSatpam", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
}

View File

@ -1,352 +1,267 @@
package com.jasamedika.medifirst2000.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PenyuluhanService;
import com.jasamedika.medifirst2000.vo.PlanningDiklatHumasMarketVO;
import com.jasamedika.medifirst2000.vo.RencanaDiseminasiVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PenyuluhanService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.PlanningDiklatHumasMarketVO;
import com.jasamedika.medifirst2000.vo.RencanaDiseminasiVO;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.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
@RequestMapping("/penyuluhan")
public class PenyuluhanController extends LocaleController{
private static final Logger LOGGER = LoggerFactory.getLogger(PenyuluhanController.class);
public class PenyuluhanController extends LocaleController<RencanaDiseminasiVO> {
private static final Logger LOGGER = getLogger(PenyuluhanController.class);
@Autowired
private PenyuluhanService penyuluhanService;
@RequestMapping(value = "/save-rencana-penyuluhan", method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE,consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveRencanaPenyuluhan(
@RequestBody RencanaDiseminasiVO vo, HttpServletRequest request) {
@RequestMapping(value = "/save-rencana-penyuluhan", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveRencanaPenyuluhan(@RequestBody RencanaDiseminasiVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = this.penyuluhanService.saveStrukPlanning(vo);
if (result != null)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when savePlanningDHM", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when saveStrukPlanning", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when savePlanningDHM", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-struk-planning-by-noplanning",method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getLoadDataByNoPlanning(
@RequestParam(value = "noPlanning", required = true) String noPlanning, HttpServletRequest request) {
try {
Map<String, Object> result = penyuluhanService.getPlanningByNoPlanning(noPlanning);
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 getLoadDataByNoPlanning", 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 getLoadDataByNoPlanning", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when saveStrukPlanning", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-planning-humas-by-noplanning",method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getPlanningHumasDiklatByNoPlanning(
@RequestParam(value = "noPlanning", required = true) String noPlanning, HttpServletRequest request) {
@RequestMapping(value = "/get-planning-humas-by-noplanning", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getPlanningHumasDiklatByNoPlanning(
@RequestParam(value = "noPlanning") String noPlanning, HttpServletRequest request) {
try {
Map<String, Object> result = penyuluhanService.getListPlanningDHM(noPlanning);
if (null != result) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage);
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getLoadDataByNoPlanning", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getListPlanningDHM", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getLoadDataByNoPlanning", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getListPlanningDHM", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-list-planning",method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/get-list-planning", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getLoadDataNoPlanning(
@RequestParam(value = "noPlanning", required = false) String noPlanning,
@RequestParam(value = "dateStart", required = true) String dateStart,
@RequestParam(value = "dateEnd", required = true) String dateEnd,
@RequestParam(value = "dateStart") String dateStart, @RequestParam(value = "dateEnd") String dateEnd,
HttpServletRequest request) {
try {
List<Map<String, Object>> result = penyuluhanService.getInformasiRencanaPenyuluhan(noPlanning,dateEnd,dateStart);
List<Map<String, Object>> result = penyuluhanService.getInformasiRencanaPenyuluhan(noPlanning, dateEnd,
dateStart);
if (null != result) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage);
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getLoadDataNoPlanning", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getInformasiRencanaPenyuluhan", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getLoadDataNoPlanning", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getInformasiRencanaPenyuluhan", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-no-planning/", method = RequestMethod.GET)
public ResponseEntity<Map<String,Object>> getNoPlanning(HttpServletRequest request) {
@RequestMapping(value = "/get-no-planning/", method = GET)
public ResponseEntity<Map<String, Object>> getNoPlanning(HttpServletRequest request) {
try {
String noSurat= penyuluhanService.noPlanning();
Map<String,Object> result=new HashMap<String,Object>();
String noSurat = penyuluhanService.noPlanning();
Map<String, Object> result = new HashMap<>();
result.put("noSurat", noSurat);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add nota-dinas", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when noPlanning", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add nota-dinas", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when noPlanning", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/save-peserta-penyuluhan", method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE,consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> savePesertaPenyuluhan(
@RequestBody RencanaDiseminasiVO vo, HttpServletRequest request) {
@RequestMapping(value = "/save-peserta-penyuluhan", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> savePesertaPenyuluhan(@RequestBody RencanaDiseminasiVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = this.penyuluhanService.savePesertaPenyuluhan(vo);
if (result != null)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when savePlanningDHM", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when savePesertaPenyuluhan", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when savePlanningDHM", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-peserta-penyuluhan-by-noplanning/", method = RequestMethod.GET)
public ResponseEntity<List<Map<String,Object>>> getPesertaPenyuluhanByNoPlanning(
@RequestParam(value = "noPlanning", required = true) String noPlanning,
HttpServletRequest request) {
try {
List<Map<String,Object>> result= penyuluhanService.getPesertaPenyuluhanByNoPlanning(noPlanning);
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add nota-dinas", 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 nota-dinas", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when savePesertaPenyuluhan", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping( value = "/save-pelaksanaan-penyuluhan",method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE,consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> savePelaksanaanPenyuluhan(
@RequestBody PlanningDiklatHumasMarketVO vo, HttpServletRequest request) {
@RequestMapping(value = "/get-peserta-penyuluhan-by-noplanning/", method = GET)
public ResponseEntity<List<Map<String, Object>>> getPesertaPenyuluhanByNoPlanning(
@RequestParam(value = "noPlanning") String noPlanning, HttpServletRequest request) {
try {
List<Map<String, Object>> result = penyuluhanService.getPesertaPenyuluhanByNoPlanning(noPlanning);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got ServiceVOException {} when getPesertaPenyuluhanByNoPlanning", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got JpaSystemException {} when getPesertaPenyuluhanByNoPlanning", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/save-pelaksanaan-penyuluhan", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<String> savePelaksanaanPenyuluhan(@RequestBody PlanningDiklatHumasMarketVO vo,
HttpServletRequest request) {
try {
String result = this.penyuluhanService.savePelaksanaanPenyuluhan(vo);
if (result != null)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when savePlanningDHM", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when savePelaksanaanPenyuluhan", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when savePlanningDHM", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
LOGGER.error("Got JpaSystemException {} when savePelaksanaanPenyuluhan", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-daftar-pelaksanaan-diseminasi",method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/get-daftar-pelaksanaan-diseminasi", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<List<Map<String, Object>>> getListPlannDHMHukorByNoPlanningAndDate(
@RequestParam(value = "noPlanning", required = false) String noPlanning,
@RequestParam(value = "dateStart", required = true) String dateStart,
@RequestParam(value = "dateEnd", required = true) String dateEnd,
@RequestParam(value = "dateStart") String dateStart, @RequestParam(value = "dateEnd") String dateEnd,
HttpServletRequest request) {
try {
List<Map<String, Object>> result = penyuluhanService.getListPlannDHMHukorByNoPlanningAndDate(noPlanning,dateStart,dateEnd);
List<Map<String, Object>> result = penyuluhanService.getListPlannDHMHukorByNoPlanningAndDate(noPlanning,
dateStart, dateEnd);
if (null != result) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage);
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getLoadDataNoPlanning", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getListPlannDHMHukorByNoPlanningAndDate", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getLoadDataNoPlanning", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getListPlannDHMHukorByNoPlanningAndDate", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-daftar-pelaksanaan-by-noplanning",method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getPlanningDHMHukorByNoPlanning(
@RequestParam(value = "noPlanning", required = true) String noPlanning,
HttpServletRequest request) {
@RequestMapping(value = "/get-daftar-pelaksanaan-by-noplanning", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getPlanningDHMHukorByNoPlanning(
@RequestParam(value = "noPlanning") String noPlanning, HttpServletRequest request) {
try {
Map<String, Object> result = penyuluhanService.getPlanningDHMHukorByNoPlanning(noPlanning);
if (null != result) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} else {
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND, mapHeaderMessage);
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
}
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when getLoadDataNoPlanning", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getPlanningDHMHukorByNoPlanning", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getLoadDataNoPlanning", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getPlanningDHMHukorByNoPlanning", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-peserta-registrasi-by-noplanning/", method = RequestMethod.GET)
public ResponseEntity<List<Map<String,Object>>> getPesertaRegistrasiByNoPlanning(
@RequestParam(value = "noPlanning", required = true) String noPlanning,
HttpServletRequest request) {
@RequestMapping(value = "/get-peserta-registrasi-by-noplanning/", method = GET)
public ResponseEntity<List<Map<String, Object>>> getPesertaRegistrasiByNoPlanning(
@RequestParam(value = "noPlanning") String noPlanning, HttpServletRequest request) {
try {
List<Map<String,Object>> result= penyuluhanService.getPesertaRegistrasiByNoPlanning(noPlanning);
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
List<Map<String, Object>> result = penyuluhanService.getPesertaRegistrasiByNoPlanning(noPlanning);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, OK, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add nota-dinas", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getPesertaRegistrasiByNoPlanning", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add nota-dinas", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getPesertaRegistrasiByNoPlanning", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/save-registrasi-peserta-penyuluhan", method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE,consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveRegistrasiPesertaPenyuluhan(
@RequestBody RencanaDiseminasiVO vo, HttpServletRequest request) {
@RequestMapping(value = "/save-registrasi-peserta-penyuluhan", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveRegistrasiPesertaPenyuluhan(@RequestBody RencanaDiseminasiVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = this.penyuluhanService.saveRegistrasiPesertaPenyuluhan(vo);
if (result != null)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when savePlanningDHM", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when saveRegistrasiPesertaPenyuluhan", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when savePlanningDHM", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
LOGGER.error("Got JpaSystemException {} when saveRegistrasiPesertaPenyuluhan", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
}

View File

@ -1,32 +1,17 @@
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 com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.service.PenyusunanEPlanningService;
import com.jasamedika.medifirst2000.vo.DetailSpekAnggaranVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PenyusunanEPlanningService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.DetailSpekAnggaranVO;
import com.jasamedika.medifirst2000.vo.PenyusunanEPlanningVO;
import java.util.Map;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
@RestController
@RequestMapping("/penyusunan-eplanning")
@ -35,47 +20,14 @@ public class PenyusunanEPlanningController extends LocaleController<DetailSpekAn
@Autowired
private PenyusunanEPlanningService service;
private static final Logger LOGGER = LoggerFactory.getLogger(PenyusunanEPlanningController.class);
@RequestMapping(value = "/get-penyusunan-eplanning", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/get-penyusunan-eplanning", method = GET, produces = APPLICATION_JSON_VALUE)
public Map<String, Object> getPenyusunanTRPNBP(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "limit", required = false, defaultValue = "50") Integer limit,
@RequestParam(value = "sort", required = false, defaultValue = "namaProduk") String sort,
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
@RequestParam(value = "isVerifikasi", required = false) String isVerifikasi) {
Map<String, Object> resultPageMap = service.getPenyusunanEPlanning(page, limit, sort, dir, isVerifikasi);
return resultPageMap;
return service.getPenyusunanEPlanning(page, limit, sort, dir, isVerifikasi);
}
@RequestMapping(value = "/get-mata-anggaran", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> getMataAnggaran(@RequestParam(value = "id", required = false) Integer id) {
Map<String, Object> resultPageMap = service.getMataAnggaran(id);
return resultPageMap;
}
@RequestMapping(value = "/save-penyusunan-eplanning", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> savePenyusunanEPlanning(@Valid @RequestBody PenyusunanEPlanningVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = service.savePenyusunanEPlanning(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 savePenyusunanEPlanning", 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 savePenyusunanEPlanning", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
}

View File

@ -1,43 +1,43 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PenyusunanTRPNBPService;
import com.jasamedika.medifirst2000.vo.PenyusunanTRPNPBVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PenyusunanTRPNBPService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.PenyusunanTRPNPBVO;
import com.jasamedika.medifirst2000.vo.StrukPelayananDetailVO;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.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
@RequestMapping("/penyusunan-trpnbp")
public class PenyusunanTRPNBPController extends LocaleController<StrukPelayananDetailVO> {
public class PenyusunanTRPNBPController extends LocaleController<PenyusunanTRPNPBVO> {
private static final Logger LOGGER = getLogger(PenyusunanTRPNBPController.class);
@Autowired
private PenyusunanTRPNBPService service;
private static final Logger LOGGER = LoggerFactory.getLogger(PenyusunanTRPNBPController.class);
@RequestMapping(value = "/get-penyusunan-trpnbp", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/get-penyusunan-trpnbp", method = GET, produces = APPLICATION_JSON_VALUE)
public Map<String, Object> getPenyusunanTRPNBP(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "limit", required = false, defaultValue = "50") Integer limit,
@ -45,41 +45,34 @@ public class PenyusunanTRPNBPController extends LocaleController<StrukPelayananD
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
@RequestParam(value = "dateStart", required = false) String dateStart,
@RequestParam(value = "dateEnd", required = false) String dateEnd) {
Map<String, Object> resultPageMap = service.getPenyusunanTRPNBP(page, limit, sort, dir, dateStart, dateEnd);
return resultPageMap;
return service.getPenyusunanTRPNBP(page, limit, sort, dir, dateStart, dateEnd);
}
@RequestMapping(value = "/save-penyusunan-trpnbp", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/save-penyusunan-trpnbp", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> savePenyusunanTRPNBP(@Valid @RequestBody PenyusunanTRPNPBVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = service.savePenyusunanTRPNBP(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when savePenyusunanTRPNBP", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when savePenyusunanTRPNBP", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when savePenyusunanTRPNBP", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when savePenyusunanTRPNBP", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-daftar-penyusunan-trpnbp", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/get-daftar-penyusunan-trpnbp", method = GET, produces = APPLICATION_JSON_VALUE)
public Map<String, Object> getDaftarPenyusunanTRPNBP(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "limit", required = false, defaultValue = "50") Integer limit,
@RequestParam(value = "tahun", required = false) Integer tahun) {
Map<String, Object> resultPageMap = service.getDaftarPenyusunanTRPNBP(page, limit, tahun);
return resultPageMap;
return service.getDaftarPenyusunanTRPNBP(page, limit, tahun);
}
}

View File

@ -1,77 +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.PeralatanDetailService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.ObservasiIGDVOCustom;
import com.jasamedika.medifirst2000.vo.PeralatanDetailCustomVO;
import com.jasamedika.medifirst2000.vo.PeralatanDetailVO;
@RestController
@RequestMapping("/peralatan")
public class PeralatanDetailController extends LocaleController<PeralatanDetailVO> implements IBaseRestController<PeralatanDetailVO>{
@Autowired
private PeralatanDetailService peralatanDetailService;
private static final Logger LOGGER = LoggerFactory
.getLogger(PeralatanDetailController.class);
@Override
public ResponseEntity<Collection<PeralatanDetailVO>> getAllVOWithQueryString(HttpServletRequest request,
Integer page, Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<PeralatanDetailVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(PeralatanDetailVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(PeralatanDetailVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<PeralatanDetailVO>> getAllVO() {
return null;
}
}

View File

@ -1,118 +1,71 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.IBaseRestController;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.entities.Peran;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PeranService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.PasienVO;
import com.jasamedika.medifirst2000.vo.PeranVO;
import net.kaczmarzyk.spring.data.jpa.domain.Equal;
import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Collection;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.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;
@RestController
@RequestMapping("/peran")
public class PeranController extends LocaleController<PeranVO>
implements IBaseRestController<PeranVO>{
public class PeranController extends LocaleController<PeranVO> {
private static final Logger LOGGER = getLogger(PeranController.class);
@Autowired
private PeranService peranService;
private static final Logger LOGGER = LoggerFactory
.getLogger(IndikatorRensarController.class);
@Override
public ResponseEntity<Collection<PeranVO>> getAllVOWithQueryString(HttpServletRequest request, Integer page,
Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<PeranVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(PeranVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(PeranVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<PeranVO>> getAllVO() {
return null;
}
@RequestMapping(value="/find-all/", method= RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Collection<Peran>> findAll(
@RequestMapping(value = "/find-all/", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Collection<PasienVO>> findAll(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "take", required = false, defaultValue = "100") Integer take,
@RequestParam(value = "sort", required = false, defaultValue = "id") String sort,
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
@Spec(path = "id", params = "id", spec = Equal.class) Specification<Peran> spec)
{
Map<String, Object> result = new HashMap<String, Object>();
result = peranService.findAll(page, take, sort,dir, spec);
return constructListPageResult(result);
@Spec(path = "id", params = "id", spec = Equal.class) Specification<Peran> spec) {
Map<String, Object> result = peranService.findAll(page, take, sort, dir, spec);
return constructListPageResult(result);
}
@RequestMapping(value="/save/", method= RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> save(@Valid @RequestBody PeranVO vo,HttpServletRequest request){
try{
@RequestMapping(value = "/save/", method = RequestMethod.POST, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> save(@Valid @RequestBody PeranVO vo, HttpServletRequest request) {
try {
Map<String, Object> result = peranService.save(vo);
if(null!= result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
if (null != result)
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add/update Peran", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when peranService.save", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add/update Peran", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when peranService.save", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
}

View File

@ -1,34 +1,33 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.entities.PeranHubungan;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PeranHubunganService;
import com.jasamedika.medifirst2000.vo.PeranHubunganVO;
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.PeranHubunganService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.PeranHubunganVO;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_ERROR;
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;
/**
* Controller class for PeranHubunganController
@ -37,70 +36,35 @@ import com.jasamedika.medifirst2000.vo.PeranHubunganVO;
*/
@RestController
@RequestMapping("/peran-hubungan")
@JsonIgnoreProperties(ignoreUnknown = true)
public class PeranHubunganController extends LocaleController<PeranHubunganVO> implements
IBaseRestController<PeranHubunganVO> {
private static final Logger LOGGER = LoggerFactory.getLogger(PeranHubunganController.class);
@JsonIgnoreProperties(ignoreUnknown = true)
public class PeranHubunganController extends LocaleController<PeranHubunganVO> {
private static final Logger LOGGER = getLogger(PeranHubunganController.class);
@Autowired
private PeranHubunganService peranHubunganService;
private PeranHubunganService<PeranHubungan> peranHubunganService;
@RequestMapping(value = "/save-peran-hubungan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> save(@Valid @RequestBody PeranHubunganVO vo,HttpServletRequest request) {
@RequestMapping(value = "/save-peran-hubungan", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> save(@Valid @RequestBody PeranHubunganVO vo,
HttpServletRequest request) {
try {
Map<String,Object> result = peranHubunganService.addPeranHubungan(vo);
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
}else{
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,getMessage(MessageResource.LABEL_ERROR,request ));
Map<String, Object> result = peranHubunganService.addPeranHubungan(vo);
if (null != result) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
} else {
mapHeaderMessage.put(LABEL_ERROR, getMessage(MessageResource.LABEL_ERROR, request));
}
SaveLog("Peran Hubungan", "Pemeriksaan",request);
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
SaveLog("Peran Hubungan", "Pemeriksaan", request);
return getJsonResponse(result, 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);
LOGGER.error("Got ServiceVOException {} when addPeranHubungan", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(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);
LOGGER.error("Got JpaSystemException {} when addPeranHubungan", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@Override
public ResponseEntity<Collection<PeranHubunganVO>> getAllVOWithQueryString(HttpServletRequest request,
Integer page, Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<PeranHubunganVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(PeranHubunganVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(PeranHubunganVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<PeranHubunganVO>> getAllVO() {
return null;
}
}

View File

@ -1,118 +1,76 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.entities.PeriodePelaporan;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PeriodePelaporanService;
import com.jasamedika.medifirst2000.vo.PasienVO;
import com.jasamedika.medifirst2000.vo.PeriodePelaporanVO;
import net.kaczmarzyk.spring.data.jpa.domain.Equal;
import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.IBaseRestController;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.entities.PeriodePelaporan;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PeriodePelaporanService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.PeriodePelaporanVO;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Collection;
import java.util.Map;
import net.kaczmarzyk.spring.data.jpa.domain.Equal;
import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.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
@RequestMapping("/periode-pelaporan")
public class PeriodePelaporanController extends LocaleController<PeriodePelaporanVO>
implements IBaseRestController<PeriodePelaporanVO>{
public class PeriodePelaporanController extends LocaleController<PeriodePelaporanVO> {
private static final Logger LOGGER = getLogger(PeriodePelaporanController.class);
@Autowired
private PeriodePelaporanService pelaporanService;
private static final Logger LOGGER = LoggerFactory
.getLogger(PegawaiController.class);
@Override
public ResponseEntity<Collection<PeriodePelaporanVO>> getAllVOWithQueryString(HttpServletRequest request,
Integer page, Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<PeriodePelaporanVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(PeriodePelaporanVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(PeriodePelaporanVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<PeriodePelaporanVO>> getAllVO() {
return null;
}
@RequestMapping(value="/find-all/", method= RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Collection<PeriodePelaporan>> findAll(
@RequestMapping(value = "/find-all/", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Collection<PasienVO>> findAll(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "take", required = false, defaultValue = "100") Integer take,
@RequestParam(value = "sort", required = false, defaultValue = "id") String sort,
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
@Spec(path = "id", params = "id", spec = Equal.class) Specification<PeriodePelaporan> spec)
{
Map<String, Object> result = new HashMap<String, Object>();
result = pelaporanService.findAll(page, take, sort,dir, spec);
return constructListPageResult(result);
@Spec(path = "id", params = "id", spec = Equal.class) Specification<PeriodePelaporan> spec) {
Map<String, Object> result = pelaporanService.findAll(page, take, sort, dir, spec);
return constructListPageResult(result);
}
@RequestMapping(value="/save/", method= RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> save(@Valid @RequestBody PeriodePelaporanVO vo,HttpServletRequest request){
try{
@RequestMapping(value = "/save/", method = POST, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> save(@Valid @RequestBody PeriodePelaporanVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = pelaporanService.save(vo);
if(null!= result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
if (null != result)
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add/update Periode Pelaporan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when pelaporanService.save", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add/update Periode Pelaporan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttpStatus(HttpStatus.CONFLICT,
mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when pelaporanService.save", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
}