Update controller

Clean code
This commit is contained in:
Salman Manoe 2024-12-23 14:29:40 +07:00
parent 9d2466eaca
commit f2cbdb411a
17 changed files with 630 additions and 1926 deletions

View File

@ -1,186 +1,142 @@
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.data.jpa.domain.Specifications;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.IBaseRestController;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.entities.DetailKajianEvaluasi;
import com.jasamedika.medifirst2000.entities.KajianEvaluasi;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.DetailKajianEvaluasiService;
import com.jasamedika.medifirst2000.service.KajianEvaluasiService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.DetailKajianEvaluasiVO;
import com.jasamedika.medifirst2000.vo.KajianEvaluasiVO;
import com.jasamedika.medifirst2000.vo.PasienVO;
import net.kaczmarzyk.spring.data.jpa.domain.DateBetween;
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.data.jpa.domain.Specifications;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController
@RequestMapping("/kajian-evaluasi")
public class KajianEvaluasiController extends LocaleController<KajianEvaluasiVO>
{
public class KajianEvaluasiController extends LocaleController<KajianEvaluasiVO> {
private static final Logger LOGGER = LoggerFactory.getLogger(KajianEvaluasiController.class);
@Autowired
private KajianEvaluasiService evaluasiService;
@Autowired
private DetailKajianEvaluasiService detailService;
private static final Logger LOGGER = LoggerFactory
.getLogger(PegawaiController.class);
@RequestMapping(value="/find-all/",method= RequestMethod.GET)
public ResponseEntity<List<Object>> findAll(
@RequestMapping(value = "/find-all/", method = GET)
public ResponseEntity<Collection<PasienVO>> findAll(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "take", required = false, defaultValue = "20") Integer take,
@RequestParam(value = "sort", required = false, defaultValue = "id") String sort,
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
@Spec(path = "tglUsulan", params = {"dateStart", "dateEnd"}, config = "yyyy-MM-dd", spec = DateBetween.class) Specification<KajianEvaluasi> tglUsulan,
@Spec(path = "noUsulan", params = "noUsulan" , spec = Equal.class) Specification<KajianEvaluasi> noUsulan,
@Spec(path = "id", params = "id" , spec = Equal.class) Specification<KajianEvaluasi> id) {
Map<String,Object> result = new HashMap<String, Object>();
Specification<KajianEvaluasi> spec = Specifications.where(tglUsulan).and(noUsulan).and(id);
result = evaluasiService.findAll(page, take, sort, dir, spec);
return constructListPageResult(result);
@Spec(path = "tglUsulan", params = { "dateStart",
"dateEnd" }, config = "yyyy-MM-dd", spec = DateBetween.class) Specification<KajianEvaluasi> tglUsulan,
@Spec(path = "noUsulan", params = "noUsulan", spec = Equal.class) Specification<KajianEvaluasi> noUsulan,
@Spec(path = "id", params = "id", spec = Equal.class) Specification<KajianEvaluasi> id) {
Specification<KajianEvaluasi> spec = Specifications.where(tglUsulan).and(noUsulan).and(id);
Map<String, Object> result = evaluasiService.findAll(page, take, sort, dir, spec);
return constructListPageResult(result);
}
@RequestMapping(value="/find-all-by-jabatan/",method= RequestMethod.GET)
public ResponseEntity<List<Object>> findAllByJabatan(
@RequestMapping(value = "/find-all-by-jabatan/", method = GET)
public ResponseEntity<Collection<PasienVO>> findAllByJabatan(
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
@RequestParam(value = "take", required = false, defaultValue = "20") Integer take,
@RequestParam(value = "sort", required = false, defaultValue = "id") String sort,
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
@Spec(path = "kajianEvaluasi.tglUsulan", params = {"dateStart", "dateEnd"}, config = "yyyy-MM-dd", spec = DateBetween.class) Specification<DetailKajianEvaluasi> tglUsulan,
@Spec(path = "kajianEvaluasi.noUsulan", params = "noUsulan" , spec = Equal.class) Specification<DetailKajianEvaluasi> noUsulan,
@Spec(path = "tujuan.id",params="jabatanId",spec=Equal.class)Specification<DetailKajianEvaluasi> tujuanId,
@Spec(path = "id", params = "id" , spec = Equal.class) Specification<DetailKajianEvaluasi> id) {
Map<String,Object> result = new HashMap<String, Object>();
Specification<DetailKajianEvaluasi> spec = Specifications.where(tglUsulan).and(tujuanId).and(noUsulan).and(id);
result = detailService.findAll(page, take, sort, dir, spec);
return constructListPageResult(result);
@Spec(path = "kajianEvaluasi.tglUsulan", params = { "dateStart",
"dateEnd" }, config = "yyyy-MM-dd", spec = DateBetween.class) Specification<DetailKajianEvaluasi> tglUsulan,
@Spec(path = "kajianEvaluasi.noUsulan", params = "noUsulan", spec = Equal.class) Specification<DetailKajianEvaluasi> noUsulan,
@Spec(path = "tujuan.id", params = "jabatanId", spec = Equal.class) Specification<DetailKajianEvaluasi> tujuanId,
@Spec(path = "id", params = "id", spec = Equal.class) Specification<DetailKajianEvaluasi> id) {
Specification<DetailKajianEvaluasi> spec = Specifications.where(tglUsulan).and(tujuanId).and(noUsulan).and(id);
Map<String, Object> result = detailService.findAll(page, take, sort, dir, spec);
return constructListPageResult(result);
}
@RequestMapping(value="/save/",method= RequestMethod.POST)
public ResponseEntity<Map<String,Object>> saveKajian(@Valid @RequestBody KajianEvaluasiVO vo,HttpServletRequest request){
try{
@RequestMapping(value = "/save/", method = POST)
public ResponseEntity<Map<String, Object>> saveKajian(@Valid @RequestBody KajianEvaluasiVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = evaluasiService.saveKajian(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 kajian", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when saveKajian", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add kajian", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when saveKajian", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value="/update-kajian/",method= RequestMethod.POST)
public ResponseEntity<Map<String,Object>> updateKajian(@Valid @RequestBody List<DetailKajianEvaluasiVO> vos,HttpServletRequest request){
try{
@RequestMapping(value = "/update-kajian/", method = POST)
public ResponseEntity<Map<String, Object>> updateKajian(@Valid @RequestBody List<DetailKajianEvaluasiVO> vos,
HttpServletRequest request) {
try {
Map<String, Object> result = detailService.updateKajian(vos);
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 update kajian", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when updateKajian", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when update kajian", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when updateKajian", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value="/delete/",method= RequestMethod.POST)
public ResponseEntity<Map<String,Object>> deleteKajian(@Valid @RequestBody List<KajianEvaluasiVO> vos,HttpServletRequest request){
try{
@RequestMapping(value = "/delete/", method = POST)
public ResponseEntity<Map<String, Object>> deleteKajian(@Valid @RequestBody List<KajianEvaluasiVO> vos,
HttpServletRequest request) {
try {
Map<String, Object> result = evaluasiService.deleteKajian(vos);
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 delete kajian", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when deleteKajian", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when delete kajian", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when deleteKajian", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value="/generate-no-usulan/{bulan}/{tahun}",method= RequestMethod.GET)
public ResponseEntity<Map<String,Object>> getGenerateNoUsulan(
@PathVariable("bulan") Integer bulan,
@PathVariable("tahun") Integer tahun,
HttpServletRequest request)
{
try{
Map<String,Object> result = evaluasiService.generateNoUsulan(bulan, tahun);
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
}catch (ServiceVOException e) {
LOGGER.error("Got exception {} when generate no usulan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when generate no usulan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
}

View File

@ -1,137 +1,91 @@
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.KamusIndikator;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.KamusIndikatorService;
import com.jasamedika.medifirst2000.vo.KamusIndikatorVO;
import com.jasamedika.medifirst2000.vo.PasienVO;
import net.kaczmarzyk.spring.data.jpa.domain.Equal;
import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.domain.Specifications;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.IBaseRestController;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.dto.DetailKamusIndikatorDTO;
import com.jasamedika.medifirst2000.entities.DampakResiko;
import com.jasamedika.medifirst2000.entities.KamusIndikator;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.KamusIndikatorService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.DampakResikoVO;
import com.jasamedika.medifirst2000.vo.KamusIndikatorVO;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Collection;
import java.util.Map;
import net.kaczmarzyk.spring.data.jpa.domain.Equal;
import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController
@RequestMapping("/kamus-indikator")
public class KamusIndikatorController extends LocaleController<KamusIndikatorVO>
implements IBaseRestController<KamusIndikatorVO>{
public class KamusIndikatorController extends LocaleController<KamusIndikatorVO> {
private static final Logger LOGGER = LoggerFactory.getLogger(KamusIndikatorController.class);
@Autowired
private KamusIndikatorService kamusIndikatorService;
private static final Logger LOGGER = LoggerFactory
.getLogger(PegawaiController.class);
@Override
public ResponseEntity<Collection<KamusIndikatorVO>> getAllVOWithQueryString(HttpServletRequest request, Integer page,
Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<KamusIndikatorVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(KamusIndikatorVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(KamusIndikatorVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<KamusIndikatorVO>> getAllVO() {
return null;
}
@RequestMapping(value="/find-all/", method= RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Collection<KamusIndikator>> 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<KamusIndikator> id,
@Spec(path = "indikator.sasaranStrategis.id", params = "sasaranStrategisId", spec = Equal.class) Specification<KamusIndikator> sasaran)
{
Specification spec = Specifications.where(id).and(sasaran);
Map<String, Object> result = new HashMap<String, Object>();
result = kamusIndikatorService.findAll(page, take, sort,dir, spec);
return constructListPageResult(result);
@Spec(path = "indikator.sasaranStrategis.id", params = "sasaranStrategisId", spec = Equal.class) Specification<KamusIndikator> sasaran) {
Specification<KamusIndikator> spec = Specifications.where(id).and(sasaran);
Map<String, Object> result = kamusIndikatorService.findAll(page, take, sort, dir, spec);
return constructListPageResult(result);
}
@RequestMapping(value="/detail-indikator/", method= RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Collection<DetailKamusIndikatorDTO>> findAll(
@RequestMapping(value = "/detail-indikator/", 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<KamusIndikator> spec)
{
Map<String, Object> result = new HashMap<String, Object>();
result = kamusIndikatorService.findDetail(page, take, sort,dir, spec);
return constructListPageResult(result);
@Spec(path = "id", params = "id", spec = Equal.class) Specification<KamusIndikator> spec) {
Map<String, Object> result = kamusIndikatorService.findDetail(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 KamusIndikatorVO vo,HttpServletRequest request){
try{
@RequestMapping(value = "/save/", method = POST, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> save(@Valid @RequestBody KamusIndikatorVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = kamusIndikatorService.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 kamus IKU", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when save", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add/update kamus IKU", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when save", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
}

View File

@ -1,97 +1,70 @@
package com.jasamedika.medifirst2000.controller;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.DetailAnggaranService;
import com.jasamedika.medifirst2000.service.KartuPengendaliService;
import com.jasamedika.medifirst2000.vo.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.entities.KartuPengendaliDetail;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.BaseAnggaranService;
import com.jasamedika.medifirst2000.service.DetailAnggaranService;
import com.jasamedika.medifirst2000.service.KartuPengendaliService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.DetailAnggaranVO;
import com.jasamedika.medifirst2000.vo.KartuPengendaliCustomVO;
import com.jasamedika.medifirst2000.vo.KartuPengendaliDetailVO;
import com.jasamedika.medifirst2000.vo.PenawaranHargaVO;
import com.jasamedika.medifirst2000.vo.RegistrasiPelayananVO;
import com.jasamedika.medifirst2000.vo.RekapPemenangUlpVO;
import com.jasamedika.medifirst2000.vo.UpdateJadwalVO;
import com.jasamedika.medifirst2000.vo.UploadVO;
import com.jasamedika.medifirst2000.vo.UploadExcelVO;
import com.jasamedika.medifirst2000.vo.VerifikasiKartuPengendaliDetailVO;
import com.jasamedika.medifirst2000.vo.VerifikasiKartuPengendaliHeaderVO;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController
@RequestMapping("/kartu-pengendali")
public class KartuPengendaliController extends LocaleController<RegistrasiPelayananVO> {
public class KartuPengendaliController extends LocaleController<KartuPengendaliVO> {
private static final Logger LOGGER = LoggerFactory.getLogger(KartuPengendaliController.class);
@Autowired
private KartuPengendaliService service;
@Autowired
private DetailAnggaranService detailAnggaranService;
private static final Logger LOGGER = LoggerFactory.getLogger(KartuPengendaliController.class);
// save kartu Pengendali
@RequestMapping(value = "/save-kartu-pengendali", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@Autowired
private DetailAnggaranService detailAnggaranService;
@RequestMapping(value = "/save-kartu-pengendali", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveKartuPengendali(@Valid @RequestBody KartuPengendaliCustomVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = service.saveKartuPengendali(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 saveKartuPengendali", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when saveKartuPengendali", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when saveKartuPengendali", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when saveKartuPengendali", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
// Kartu Pengendai Paging
// Jika ANggaran maka kelompok User/isPpk null
// Jika Ppk Maka kelompok User / is Ppk=true
// Jika Ulp Maka is Ulp = true
@SuppressWarnings("unchecked")
@RequestMapping(value = "/kartu-pengendali-list")
@ResponseBody
public Map<String, Object> multipleCondition(
@ -105,14 +78,10 @@ public class KartuPengendaliController extends LocaleController<RegistrasiPelaya
@RequestParam(value = "kelompokUser", required = false) Boolean isPpk,
@RequestParam(value = "isUlp", required = false) Boolean isUlp,
@RequestParam(value = "isPp", required = false) Boolean isPp) {
Map<String, Object> resultPageMap = service.kartuPengenDaliPAging(page, limit, sort, dir, dateStart, dateEnd,
pengendaliId, isPpk, isUlp,isPp);
return resultPageMap;
return service.kartuPengenDaliPAging(page, limit, sort, dir, dateStart, dateEnd, pengendaliId, isPpk, isUlp,
isPp);
}
@SuppressWarnings("unchecked")
@RequestMapping(value = "/kartu-pengendali-header-list")
@ResponseBody
public Map<String, Object> kartuPengendaliHeader(
@ -129,15 +98,10 @@ public class KartuPengendaliController extends LocaleController<RegistrasiPelaya
@RequestParam(value = "isAnggaran", required = false) Boolean isAnggaran,
@RequestParam(value = "isPengendali", required = false) Boolean isPengendali,
@RequestParam(value = "isDirekturTerkait", required = false) Boolean isDirekturTerkait) {
Map<String, Object> resultPageMap = service.kartuPengenDaliPagingHeader(page, limit, sort, dir, dateStart,
dateEnd, pengendaliId, isPpk, isUlp,isPp, isAnggaran, isPengendali, isDirekturTerkait);
return resultPageMap;
return service.kartuPengenDaliPagingHeader(page, limit, sort, dir, dateStart, dateEnd, pengendaliId, isPpk,
isUlp, isPp, isAnggaran, isPengendali, isDirekturTerkait);
}
@SuppressWarnings("unchecked")
@RequestMapping(value = "/pre-add-penerimaan")
@ResponseBody
public Map<String, Object> preAddPenerimaan(
@ -148,37 +112,18 @@ public class KartuPengendaliController extends LocaleController<RegistrasiPelaya
@RequestParam(value = "dateStart", required = false) String dateStart,
@RequestParam(value = "dateEnd", required = false) String dateEnd,
@RequestParam(value = "supplierId", required = false) Integer supplierId) {
Map<String, Object> resultPageMap = service.preAddPenerimaan(page, limit, sort, dir, dateStart,dateEnd, supplierId);
return resultPageMap;
return service.preAddPenerimaan(page, limit, sort, dir, dateStart, dateEnd, supplierId);
}
// Generate Template Excel
@SuppressWarnings("unchecked")
@RequestMapping(value = "/generate-template-exel")
@ResponseBody
public Map<String, Object> generateTemplateExcel(@RequestParam(value = "noRec", required = false) String noRec,HttpServletResponse response) throws IOException {
public void generateTemplateExcel(@RequestParam(value = "noRec", required = false) String noRec,
HttpServletResponse response) throws IOException {
String fileName = service.generateTemplateExcel(noRec);
String fileType = "application/vnd.ms-excel";
// Find this file id in database to get file name, and file type
// You must tell the browser the file type you are going to send
// for example application/pdf, text/plain, text/html, image/jpg
response.setContentType(fileType);
// Make sure to show the download dialog
response.setHeader("Content-disposition", "attachment; filename="+fileName);
// Assume file name is retrieved from database
// For example D:\\file\\test.pdf
response.setHeader("Content-disposition", "attachment; filename=" + fileName);
File my_file = new File(fileName);
// This should send the file to browser
OutputStream out = response.getOutputStream();
FileInputStream in = new FileInputStream(my_file);
byte[] buffer = new byte[4096];
@ -188,304 +133,247 @@ public class KartuPengendaliController extends LocaleController<RegistrasiPelaya
}
in.close();
out.flush();
return null;
}
// verifikasi PPK
@RequestMapping(value = "/save-verifikasi-spek-anggaran", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/save-verifikasi-spek-anggaran", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveVerifikasiKartuPengendaliDetail(
@Valid @RequestBody VerifikasiKartuPengendaliDetailVO vo, HttpServletRequest request) {
try {
Map<String, Object> result = service.verifikasiPpk(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 Kartu Pengendali Detail", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when verifikasiPpk", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when Kartu Pengendali Detail", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when verifikasiPpk", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
// Rekap Pemenang from Ppk
@RequestMapping(value = "/rekap-pemenang", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> rekapPemenang(
@Valid @RequestBody VerifikasiKartuPengendaliDetailVO vo, HttpServletRequest request) {
@RequestMapping(value = "/rekap-pemenang", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> rekapPemenang(@Valid @RequestBody VerifikasiKartuPengendaliDetailVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = service.rekapPemenang(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 Kartu Pengendali Detail", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when rekapPemenang", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when Kartu Pengendali Detail", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when rekapPemenang", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
// Rekap Pemenang from Ulp
@RequestMapping(value = "/rekap-pemenang-from-ulp", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> rekapPemenangFromUlp(@Valid @RequestBody RekapPemenangUlpVO vo, HttpServletRequest request) {
@RequestMapping(value = "/rekap-pemenang-from-ulp", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> rekapPemenangFromUlp(@Valid @RequestBody RekapPemenangUlpVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = service.rekapPemenangFromUlp(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 Kartu Pengendali Detail", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when rekapPemenangFromUlp", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when Kartu Pengendali Detail", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when rekapPemenangFromUlp", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
// Verifikasi by Anggaran By etail
@RequestMapping(value = "/verifikasi-kartu-pengendali-by-anggaran", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/verifikasi-kartu-pengendali-by-anggaran", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> verifikasiKartuPengendaliByAnggaran(
@Valid @RequestBody VerifikasiKartuPengendaliDetailVO vo, HttpServletRequest request) {
try {
Map<String, Object> result = service.verifikasiKartuPengendaliDetailByAnggaran(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 saveKartuPengendali", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when verifikasiKartuPengendaliDetailByAnggaran", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when saveKartuPengendali", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when verifikasiKartuPengendaliDetailByAnggaran", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
// Verifikasi by Anggaran By Header
@RequestMapping(value = "/verifikasi-kartu-pengendali-by-header", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/verifikasi-kartu-pengendali-by-header", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> verifikasiKartuPengendaliHeadByAnggaran(
@Valid @RequestBody VerifikasiKartuPengendaliHeaderVO vo, HttpServletRequest request) {
try {
Map<String, Object> result = service.verifikasiAnggaran(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 Verif Kartu Pengendali", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when verifikasiAnggaran", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when Verif Kartu Pengendali", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when verifikasiAnggaran", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
// Verifikasi by Direktur By Header
@RequestMapping(value = "/verifikasi-kartu-pengendali-by-direktur", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/verifikasi-kartu-pengendali-by-direktur", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> verifikasiKartuPengendaliByDirektur(
@Valid @RequestBody VerifikasiKartuPengendaliHeaderVO vo, HttpServletRequest request) {
try {
Map<String, Object> result = service.verfikasiDirekturTerkait(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 Verif Kartu Pengendali", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when verfikasiDirekturTerkait", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when Verif Kartu Pengendali", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when verfikasiDirekturTerkait", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
// Verifikasi by pp
@RequestMapping(value = "/verifikasi-kartu-pengendali-by-pp", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/verifikasi-kartu-pengendali-by-pp", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> verifikasiKartuPengendaliByPp(
@Valid @RequestBody VerifikasiKartuPengendaliHeaderVO vo, HttpServletRequest request) {
try {
Map<String, Object> result = service.verfikasiPp(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 Verif Kartu Pengendali", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when verfikasiPp", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when Verif Kartu Pengendali", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when verfikasiPp", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
// Verifikasi by pp
@RequestMapping(value = "/verifikasi-kartu-pengendali-by-ulp", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/verifikasi-kartu-pengendali-by-ulp", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> verifikasiKartuPengendaliByUlp(
@Valid @RequestBody VerifikasiKartuPengendaliHeaderVO vo, HttpServletRequest request) {
try {
Map<String, Object> result = service.verfikasiULP(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 Verif Kartu Pengendali", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when verfikasiULP", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when Verif Kartu Pengendali", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when verfikasiULP", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
// Update Jadwal
@RequestMapping(value = "/update-jadwal", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> updateJadwal(@Valid @RequestBody UpdateJadwalVO vo, HttpServletRequest request) {
@RequestMapping(value = "/update-jadwal", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> updateJadwal(@Valid @RequestBody UpdateJadwalVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = service.updateJadwal(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 update jadwal", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when updateJadwal", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when update jadwal", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when updateJadwal", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
// Menampilkan Kartu Pengendali Berdasarkan Norec (array)
@RequestMapping(value = "/get-detail-kartu-pengendali-list/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public List<Map<String, Object>> kartuPengendliDetailList(
@RequestParam(value = "noRec", required = true) String noRec) {
List<Map<String, Object>> kartuPengendliDetailList = service.kartuPengendliDetailList(noRec);
return kartuPengendliDetailList;
@RequestMapping(value = "/get-detail-kartu-pengendali-list/", method = GET, produces = APPLICATION_JSON_VALUE)
public List<Map<String, Object>> kartuPengendliDetailList(@RequestParam(value = "noRec") String noRec) {
return service.kartuPengendliDetailList(noRec);
}
@RequestMapping(value = "/get-kartu-pengendali-header-by-norec/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> getKartuPengendaliHeaderByNoRec(
@RequestParam(value = "noRec", required = true) String noRec) {
Map<String, Object> kartuPengendliDetailList = service.getKartuPengendaliHeaderByNoRec(noRec);
return kartuPengendliDetailList;
}
@RequestMapping(value = "/pre-rekap-pemenang/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> preRekapPemenang(
@RequestParam(value = "noRec", required = true) String noRec) {
Map<String, Object> kartuPengendliDetailList = service.preRekapPemenang(noRec);
return kartuPengendliDetailList;
}
//getStrukRekap
@RequestMapping(value = "/get-get-struk-rekap", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> getStrukRekap(
@RequestParam(value = "noRec", required = true) String noRec) {
Map<String, Object> strukRekap = service.getStrukRekap(noRec);
return strukRekap;
}
@RequestMapping(value = "/pre-add-jadwal", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> preAddJadwal(
@RequestParam(value = "noRec", required = true) String noRec) {
Map<String, Object> data = service.getPreAddJadwal(noRec);
return data;
@RequestMapping(value = "/get-kartu-pengendali-header-by-norec/", method = GET, produces = APPLICATION_JSON_VALUE)
public Map<String, Object> getKartuPengendaliHeaderByNoRec(@RequestParam(value = "noRec") String noRec) {
return service.getKartuPengendaliHeaderByNoRec(noRec);
}
// Menampilkan Kartu Pengendali Berdasarkan Norec (array)
@RequestMapping(value = "/get-metode-pengadaan-detail", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> getMetodePengadaanDetail(
@RequestParam(value = "id", required = true) Integer id) {
Map<String, Object> kartuPengendliDetailList = service.metodePengadaanDetail(id);
return kartuPengendliDetailList;
@RequestMapping(value = "/pre-rekap-pemenang/", method = GET, produces = APPLICATION_JSON_VALUE)
public Map<String, Object> preRekapPemenang(@RequestParam(value = "noRec") String noRec) {
return service.preRekapPemenang(noRec);
}
@RequestMapping(value = "/upload-exel/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> upload(@Valid @RequestBody UploadExcelVO vo,HttpServletRequest request) throws IOException {
@RequestMapping(value = "/get-get-struk-rekap", method = GET, produces = APPLICATION_JSON_VALUE)
public Map<String, Object> getStrukRekap(@RequestParam(value = "noRec") String noRec) {
return service.getStrukRekap(noRec);
}
@RequestMapping(value = "/pre-add-jadwal", method = GET, produces = APPLICATION_JSON_VALUE)
public Map<String, Object> preAddJadwal(@RequestParam(value = "noRec") String noRec) {
return service.getPreAddJadwal(noRec);
}
@RequestMapping(value = "/get-metode-pengadaan-detail", method = GET, produces = APPLICATION_JSON_VALUE)
public Map<String, Object> getMetodePengadaanDetail(@RequestParam(value = "id") Integer id) {
return service.metodePengadaanDetail(id);
}
@RequestMapping(value = "/upload-exel/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> upload(@Valid @RequestBody UploadExcelVO vo, HttpServletRequest request)
throws IOException {
try {
Map<String,Object> result = service.uploadExel(vo) ;
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
Map<String, Object> result = service.uploadExel(vo);
if (null != result)
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add Agama", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when uploadExel", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Agama", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when uploadExel", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/save-penawaran-harga-supplier/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> savePenawaranHargaSupplier(@Valid @RequestBody PenawaranHargaVO vo,HttpServletRequest request) throws IOException {
@RequestMapping(value = "/save-penawaran-harga-supplier/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> savePenawaranHargaSupplier(@Valid @RequestBody PenawaranHargaVO vo,
HttpServletRequest request) throws IOException {
try {
Map<String,Object> result = service.savePenawaranHargaSupplier(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
Map<String, Object> result = service.savePenawaranHargaSupplier(vo);
if (null != result)
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add Penawaran Harga", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when savePenawaranHargaSupplier", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Penawaran Harga", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when savePenawaranHargaSupplier", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@SuppressWarnings("unchecked")
@RequestMapping(value = "/list-kontrak-grid")
@ResponseBody
public Map<String, Object> listKontrakGrid(
@ -497,43 +385,14 @@ public class KartuPengendaliController extends LocaleController<RegistrasiPelaya
@RequestParam(value = "dateEnd", required = false) String dateEnd,
@RequestParam(value = "supplierId", required = false) Integer supplierId,
@RequestParam(value = "tahun", required = false) Integer tahun) {
Map<String, Object> resultPageMap = service.listKontrakGrid(page, limit, sort, dir, dateStart, dateEnd, supplierId, tahun);
return resultPageMap;
return service.listKontrakGrid(page, limit, sort, dir, dateStart, dateEnd, supplierId, tahun);
}
@RequestMapping(value = "/get-kelompok-user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/get-kelompok-user/", method = GET, produces = APPLICATION_JSON_VALUE)
public Map<String, Object> getKelompokUser() {
Map<String, Object> result = new HashMap<String, Object>();
Map<String, Object> result = new HashMap<>();
result.put("kelompokUser", detailAnggaranService.getKelompokUserLogin());
return result;
}
/*
* @RequestMapping(value = "/verifikasi-kartu-pengendali", method =
* RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes
* = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Map<String,
* Object>> verifikasiKartuPengendali(@Valid @RequestBody
* KartuPengendaliDetailVO vo, HttpServletRequest request) { try {
* Map<String,Object> result = service.verifikasiKartuPengendaliDetail(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 verifikasi kartu Pengendali", e.getMessage());
* addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
* return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
* mapHeaderMessage); } catch (JpaSystemException jse) { LOGGER.error(
* "Got exception {} when verifikasi kartu Pengendali", jse.getMessage());
* addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
* return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
* }
*
* }
*/
}

View File

@ -1,39 +1,28 @@
package com.jasamedika.medifirst2000.controller;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.jasamedika.medifirst2000.service.KartuStokService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.service.KartuStokService;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/kartu-stok")
public class KartuStokController {
@Autowired
private KartuStokService kartuStokService;
private static final Logger LOGGER = LoggerFactory.getLogger(KartuStokController.class);
@SuppressWarnings("unchecked")
@RequestMapping(value = "/get-kartu-stok")
@ResponseBody
public List<Map<String, Object>> preAddPenerimaan(
@RequestParam(value = "dateStart", required = true) String dateStart,
@RequestParam(value = "dateEnd", required = true) String dateEnd,
@RequestParam(value = "ruanganId", required = true) Integer ruanganId,
@RequestParam(value = "produkId", required = true) Integer produkId) {
List<Map<String, Object>> resultPageMap = kartuStokService.getKartuStok( ruanganId,produkId,dateStart,dateEnd);
return resultPageMap;
public List<Map<String, Object>> preAddPenerimaan(@RequestParam(value = "dateStart") String dateStart,
@RequestParam(value = "dateEnd") String dateEnd, @RequestParam(value = "ruanganId") Integer ruanganId,
@RequestParam(value = "produkId") Integer produkId) {
return kartuStokService.getKartuStok(ruanganId, produkId, dateStart, dateEnd);
}
}

View File

@ -1,97 +1,54 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Collection;
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.KategoryProdukService;
import com.jasamedika.medifirst2000.vo.KategoryProdukVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.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.KategoryProdukService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.KategoryProdukVO;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
@RestController
@RequestMapping(value="/kategory-produk")
public class KategoryProdukController extends LocaleController<KategoryProdukVO>
implements IBaseRestController<KategoryProdukVO>{
@RequestMapping(value = "/kategory-produk")
public class KategoryProdukController extends LocaleController<KategoryProdukVO> {
private static final Logger LOGGER = LoggerFactory.getLogger(KategoryProdukController.class);
@Autowired
private KategoryProdukService kategoryProdukService;
private static final Logger LOGGER = LoggerFactory
.getLogger(IndikatorRensarController.class);
@Override
public ResponseEntity<Collection<KategoryProdukVO>> getAllVOWithQueryString(HttpServletRequest request,
Integer page, Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<KategoryProdukVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(KategoryProdukVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(KategoryProdukVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<KategoryProdukVO>> getAllVO() {
return null;
}
@RequestMapping(value="/get-kategory-produk-gizi/", method= RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> getBentukGizi(
HttpServletRequest request){
try{
@RequestMapping(value = "/get-kategory-produk-gizi/", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getBentukGizi(HttpServletRequest request) {
try {
Map<String, Object> result = kategoryProdukService.getKategoryProdukGizi();
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 get Kategory Produk Gizi", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getKategoryProdukGizi", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when get Kategory Produk Gizi", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getKategoryProdukGizi", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
}

View File

@ -1,37 +1,35 @@
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.KebutuhanDasar;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.KebutuhanDasarService;
import com.jasamedika.medifirst2000.vo.KebutuhanDasarVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.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.KebutuhanDasarService;
import com.jasamedika.medifirst2000.util.DateUtil;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.KebutuhanDasarVO;
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.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;
/**
* Controller class for KebutuhanDasarController
@ -40,88 +38,50 @@ import com.jasamedika.medifirst2000.vo.KebutuhanDasarVO;
*/
@RestController
@RequestMapping("/kebutuhan-dasar")
@JsonIgnoreProperties(ignoreUnknown = true)
public class KebutuhanDasarController extends LocaleController<KebutuhanDasarVO> implements
IBaseRestController<KebutuhanDasarVO> {
@JsonIgnoreProperties(ignoreUnknown = true)
public class KebutuhanDasarController extends LocaleController<KebutuhanDasarVO> {
private static final Logger LOGGER = LoggerFactory.getLogger(KebutuhanDasarController.class);
@Autowired
private KebutuhanDasarService kebutuhanDasarService;
private KebutuhanDasarService<KebutuhanDasar> kebutuhanDasarService;
@RequestMapping(value = "/save-kebutuhan-dasar", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> save(@Valid @RequestBody KebutuhanDasarVO vo,HttpServletRequest request) {
@RequestMapping(value = "/save-kebutuhan-dasar", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> save(@Valid @RequestBody KebutuhanDasarVO vo,
HttpServletRequest request) {
try {
Map<String,Object> result = kebutuhanDasarService.addKebutuhanDasar(vo);
if (null != result){
mapHeaderMessage.clear();
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
}else{
mapHeaderMessage.clear();
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,getMessage(MessageResource.LABEL_ERROR,request ));
Map<String, Object> result = kebutuhanDasarService.addKebutuhanDasar(vo);
mapHeaderMessage.clear();
if (null != result) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
} else {
mapHeaderMessage.put(LABEL_ERROR, getMessage(MessageResource.LABEL_ERROR, request));
}
SaveLog("Kebutuhan Dasar Perawat", "Perawat",request);
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
SaveLog("Kebutuhan Dasar Perawat", "Perawat", request);
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add kebutuhan dasar", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when addKebutuhanDasar", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add kebutuhan dasar", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when addKebutuhanDasar", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/find-kebutuhan-dasar", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> findByNoRec(@RequestParam("noRec") String noRec,HttpServletRequest request) {
Map<String,Object> result = kebutuhanDasarService.findKebutuhanDasarByNoRec(noRec);
Boolean dataFound=new Boolean((boolean) result.get("dataFound"));
if(dataFound){
mapHeaderMessage.clear();
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
}else{
mapHeaderMessage.clear();
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,getMessage(MessageResource.LABEL_ERROR,request ));
@RequestMapping(value = "/find-kebutuhan-dasar", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> findByNoRec(@RequestParam("noRec") String noRec,
HttpServletRequest request) {
Map<String, Object> result = kebutuhanDasarService.findKebutuhanDasarByNoRec(noRec);
boolean dataFound = (boolean) result.get("dataFound");
mapHeaderMessage.clear();
if (dataFound) {
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
} else {
mapHeaderMessage.put(LABEL_ERROR, getMessage(MessageResource.LABEL_ERROR, request));
}
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
}
@Override
public ResponseEntity<Collection<KebutuhanDasarVO>> getAllVOWithQueryString(HttpServletRequest request,
Integer page, Integer limit, String sort, String dir) {
return null;
return getJsonResponse(result, OK, mapHeaderMessage);
}
@Override
public ResponseEntity<KebutuhanDasarVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(KebutuhanDasarVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(KebutuhanDasarVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<KebutuhanDasarVO>> getAllVO() {
return null;
}
}

View File

@ -1,59 +0,0 @@
package com.jasamedika.medifirst2000.controller;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
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.controller.base.LocaleController;
import com.jasamedika.medifirst2000.entities.Kecamatan;
import com.jasamedika.medifirst2000.service.KecamatanService;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
@RestController
@RequestMapping("/kecamatan")
public class KecamatanController extends LocaleController {
@Autowired
private KecamatanService kecamatanService;
private static final Logger LOGGER = LoggerFactory
.getLogger(KecamatanController.class);
@RequestMapping("/kecamatanReport")
public ModelAndView generateReportMateri(ModelAndView m,@RequestParam(value = "format", required = false) String format){
Iterable<Kecamatan> data = kecamatanService.findAllKecamatan();
m.addObject("dataSource", data);
m.addObject("tanggalReport", new Date());
m.addObject("title", "Report Kecamatan");
m.addObject("format", "pdf");
if(format != null && !format.isEmpty()){
m.addObject("format", format);
}
return m;
}
}

View File

@ -1,98 +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.KegiatanService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.KegiatanVO;
@RestController
@RequestMapping("/kegiatan")
public class KegiatanController extends LocaleController<KegiatanVO> {
@Autowired
private KegiatanService kegiatanService;
private static final Logger LOGGER = LoggerFactory.getLogger(KegiatanController.class);
@RequestMapping(value = "/save-kegiatan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveKegiatan(@Valid @RequestBody KegiatanVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = kegiatanService.saveKegiatan(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when save Kegiatan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when save Kegiatan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/update-kegiatan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> updateKegiatan(@Valid @RequestBody KegiatanVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = kegiatanService.updateKegiatan(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 Kegiatan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when update Kegiatan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/find-all-kegiatan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> findAllKegiatan(HttpServletRequest request) {
Map<String, Object> result=null;
try {
result = kegiatanService.findAllKgiatan();
Boolean dataFound = new Boolean((boolean) result.get("dataFound"));
if (dataFound) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
} else {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR, getMessage(MessageResource.LABEL_ERROR, request));
}
}catch(Exception ex){
ex.printStackTrace();
}
return RestUtil.getJsonResponse(result, HttpStatus.OK);
}
}

View File

@ -1,99 +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.KegiatanDetailService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.KegiatanDetailVO;
import com.jasamedika.medifirst2000.vo.KegiatanVO;
@RestController
@RequestMapping("/kegiatan-detail")
public class KegiatanDetailController extends LocaleController<KegiatanVO> {
@Autowired
private KegiatanDetailService kegiatanDetailService;
private static final Logger LOGGER = LoggerFactory.getLogger(KegiatanDetailController.class);
@RequestMapping(value = "/save-kegiatan-detail", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveKegiatanDetail(@Valid @RequestBody KegiatanDetailVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = kegiatanDetailService.saveKegiatanDetail(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when save Kegiatan Detail", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when save Kegiatan Detail", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/update-kegiatan-detail", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> updateKegiatanDetail(@Valid @RequestBody KegiatanDetailVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = kegiatanDetailService.updateKegiatanDetail(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 Kegiatan Detail", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when update Kegiatan Detail", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/find-all-kegiatan-detail", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> findAllKegiatanDetail(HttpServletRequest request) {
Map<String, Object> result=null;
try {
result = kegiatanDetailService.findAllKgiatanDetail();
Boolean dataFound = new Boolean((boolean) result.get("dataFound"));
if (dataFound) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
} else {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR, getMessage(MessageResource.LABEL_ERROR, request));
}
}catch(Exception ex){
ex.printStackTrace();
}
return RestUtil.getJsonResponse(result, HttpStatus.OK);
}
}

View File

@ -1,112 +0,0 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.IBaseRestController;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.KehamilanSekarangService;
import com.jasamedika.medifirst2000.service.ThtService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.KehamilanSekarangVO;
/**
* Controller class for Pengakjian Awal KehamilanSekarangController
*
* @author Askur
*/
@RestController
@RequestMapping("/kehamilan-sekarang")
@JsonIgnoreProperties(ignoreUnknown = true)
public class KehamilanSekarangController extends LocaleController<KehamilanSekarangVO> implements
IBaseRestController<KehamilanSekarangVO> {
private static final Logger LOGGER = LoggerFactory.getLogger(KehamilanSekarangController.class);
@Autowired
private KehamilanSekarangService riwayatKelahiranYangLaluService;
@Autowired
private ThtService thtService;
@RequestMapping(value = "/save-kehamilan-sekarang", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> save(@Valid @RequestBody KehamilanSekarangVO vo,HttpServletRequest request) {
try {
Map<String,Object> result = riwayatKelahiranYangLaluService.addKehamilanSekarang(vo);
if (null != result){
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
result.put("message", "Berhasil");
}else{
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,getMessage(MessageResource.LABEL_ERROR,request ));
result.put("message", "Gagal");
}
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add Pasien", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Pasien", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@Override
public ResponseEntity<Collection<KehamilanSekarangVO>> getAllVOWithQueryString(HttpServletRequest request,
Integer page, Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<KehamilanSekarangVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(KehamilanSekarangVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(KehamilanSekarangVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<KehamilanSekarangVO>> getAllVO() {
return null;
}
}

View File

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

View File

@ -1,192 +1,118 @@
package com.jasamedika.medifirst2000.controller;
import java.text.ParseException;
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.Kelas;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.KelasService;
import com.jasamedika.medifirst2000.vo.KelasVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
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.dao.KelasDao;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.KelasService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.KelasVO;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController
@RequestMapping("/kelas")
public class KelasController extends LocaleController<KelasVO> implements
IBaseRestController<KelasVO> {
public class KelasController extends LocaleController<KelasVO> {
private static final Logger LOGGER = LoggerFactory.getLogger(KelasController.class);
@Autowired
private KelasService kelasService;
private static final Logger LOGGER = LoggerFactory
.getLogger(KelasController.class);
private KelasService<Kelas> kelasService;
@Override
public ResponseEntity<KelasVO> getVO(Integer id) {
return null;
}
@RequestMapping(value = "/save-kelas/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> addVO(@Valid @RequestBody KelasVO vo,HttpServletRequest request) {
@RequestMapping(value = "/save-kelas/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<String> addVO(@Valid @RequestBody KelasVO vo, HttpServletRequest request) {
try {
KelasVO result = (KelasVO) kelasService.add(vo);
KelasVO result = kelasService.add(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse("", HttpStatus.CREATED,mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse("", CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add Kelas", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when add", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Kelas", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when add", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/update-kelas/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/update-kelas/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<String> editVO(@Valid @RequestBody KelasVO vo) {
try {
KelasVO result = (KelasVO) kelasService.update(vo);
KelasVO result = kelasService.update(vo);
if (null != result)
return RestUtil.getJsonResponse("", HttpStatus.CREATED);
return getJsonResponse("", CREATED);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add Kelas", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when update", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Kelas", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when update", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE);
return getJsonHttpStatus(NOT_ACCEPTABLE);
}
@RequestMapping(value = "/delete-kelas/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> deleteVO( @RequestParam(value = "id", required = false) Integer id) {
@RequestMapping(value = "/delete-kelas/", method = GET, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<String> deleteVO(@RequestParam(value = "id", required = false) Integer id) {
try {
if (kelasService.delete(id) == true)
return RestUtil.getJsonResponse("", HttpStatus.CREATED);
if (kelasService.delete(id))
return getJsonResponse("", CREATED);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when delete Kelas", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when delete", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when delete Kelas", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}catch(DataIntegrityViolationException ex){
LOGGER.error("Got exception {} when delete Ruangan", ex.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
ex.getMessage());
}
return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE);
LOGGER.error("Got JpaSystemException {} when delete", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
} catch (DataIntegrityViolationException ex) {
LOGGER.error("Got DataIntegrityViolationException {} when delete", ex.getMessage());
addHeaderMessage(ERROR_MESSAGE, ex.getMessage());
}
return getJsonHttpStatus(NOT_ACCEPTABLE);
}
@Override
public ResponseEntity<List<KelasVO>> getAllVO() {
return null;
}
@Override
public ResponseEntity<Collection<KelasVO>> getAllVOWithQueryString(HttpServletRequest request, Integer page,
Integer limit, String sort, String dir) {
return null;
}
@SuppressWarnings("unchecked")
@RequestMapping(value = "/search-kelas", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Collection<KelasVO>> getAllVOWithQueryString(
@RequestParam(value = "page", required = false ,defaultValue = "0") Integer page,
@RequestParam(value = "limit", required = false ,defaultValue = "10") Integer limit,
@RequestParam(value = "sort", required = false, defaultValue = "id") String sort,
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir){
Map<String, Object> resultPageMap = kelasService.findAllWithPageAndLimitAndSortByAndDirectionParameter(page,
limit, sort, dir);
return constructListPageResult(resultPageMap);
}
@Override
public ResponseEntity<String> addVO(KelasVO vo) {
return null;
}
@RequestMapping(value = "/get-kelas-by-ruangan/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getKomposisiMakanan(@RequestParam(value = "ruanganId", required = false) Integer ruanganId,
HttpServletRequest request) throws ParseException {
@RequestMapping(value = "/get-kelas-by-ruangan/", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getKomposisiMakanan(
@RequestParam(value = "ruanganId", required = false) Integer ruanganId, HttpServletRequest request) {
try {
Map<String, Object> result = kelasService.findKelasByRuangan(ruanganId);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
SaveLog("Order Farmasi", "Permintaan", request);
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
SaveLog("Get kelas by ruangan", "Permintaan", 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.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when findKelasByRuangan", 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.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when findKelasByRuangan", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
}

View File

@ -1,134 +0,0 @@
package com.jasamedika.medifirst2000.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.entities.KelompokEvaluasi;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.KelompokEvaluasiService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.KelompokEvaluasiVO;
import com.jasamedika.medifirst2000.vo.KomponenEvaluasiVO;
@RestController
@RequestMapping("/kelompok-evaluasi")
public class KelompokEvaluasiController extends LocaleController<KelompokEvaluasiVO> {
@Autowired
private KelompokEvaluasiService kelompokEvaluasiService;
private static final Logger LOGGER = LoggerFactory
.getLogger(KelompokEvaluasiController.class);
@RequestMapping(value = "/save/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> addVO(@RequestBody KelompokEvaluasiVO vo,HttpServletRequest request) {
try {
KelompokEvaluasiVO result = kelompokEvaluasiService.add(vo);
if (null != result)
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
return RestUtil.getJsonResponse("", HttpStatus.CREATED,mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add KomponenEvaluasi", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add KomponenEvaluasi", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value = "/update/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> editVO(@Valid @RequestBody KelompokEvaluasiVO vo) {
try {
KelompokEvaluasiVO result = kelompokEvaluasiService.update(vo);
if (null != result)
return RestUtil.getJsonResponse("", HttpStatus.OK);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when update KomponenEvaluasi", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when update KomponenEvaluasi",
jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE);
}
@RequestMapping(value = "/delete/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> deleteVO(Integer id) {
try {
if (kelompokEvaluasiService.delete(id) == true)
return RestUtil.getJsonResponse("", HttpStatus.CREATED);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when delete KomponenEvaluasi", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when delete KomponenEvaluasi", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE);
}
@RequestMapping(value = "/get-all", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<KelompokEvaluasi>> getAllVO() {
List<KelompokEvaluasi> result = kelompokEvaluasiService.findAll();
return RestUtil.getJsonResponse(result, HttpStatus.OK);
}
@SuppressWarnings("unchecked")
@RequestMapping(value = "/find-by-id", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<KelompokEvaluasi> getAllVOWithQueryString(@RequestParam(value = "id", required = true) Integer id){
KelompokEvaluasi result=kelompokEvaluasiService.findById(id);
return RestUtil.getJsonResponse(result, HttpStatus.OK);
}
}

View File

@ -1,36 +1,28 @@
package com.jasamedika.medifirst2000.controller;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.KeluargaPegawaiService;
import com.jasamedika.medifirst2000.vo.KeluargaPegawaiVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.IBaseRestController;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.KeluargaPegawaiService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.KeluargaPegawaiVO;
import com.jasamedika.medifirst2000.vo.PosisiLamaranVO;
import javax.validation.Valid;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
/**
* Controller class for KeluargaPegawaiController
@ -41,89 +33,35 @@ import com.jasamedika.medifirst2000.vo.PosisiLamaranVO;
*/
@RestController
@RequestMapping("/keluarga-pegawai")
public class KeluargaPegawaiController extends
LocaleController<KeluargaPegawaiVO> implements
IBaseRestController<KeluargaPegawaiVO> {
public class KeluargaPegawaiController extends LocaleController<KeluargaPegawaiVO> {
private static final Logger LOGGER = LoggerFactory.getLogger(KeluargaPegawaiController.class);
@Autowired
private KeluargaPegawaiService keluargaPegawaiService;
private static final Logger LOGGER = LoggerFactory
.getLogger(KeluargaPegawaiController.class);
@RequestMapping(value = "/cari-alamat-id/{id}", method = RequestMethod.GET)
public ResponseEntity<KeluargaPegawaiVO> getVO(
@PathVariable("id") Integer id) {
KeluargaPegawaiVO keluargaPegawaiVO = keluargaPegawaiService
.findById(id);
return RestUtil.getJsonResponse(keluargaPegawaiVO, HttpStatus.OK);
}
@RequestMapping(value = "/get-all/", method = RequestMethod.GET)
public ResponseEntity<List> getAllKeluaraPegawai(
@PathVariable("id") Integer id) {
List keluargaPegawaiVO = keluargaPegawaiService
.findAll();
return RestUtil.getJsonResponse(keluargaPegawaiVO, HttpStatus.OK);
@RequestMapping(value = "/cari-alamat-id/{id}", method = GET)
public ResponseEntity<KeluargaPegawaiVO> getVO(@PathVariable("id") Integer id) {
KeluargaPegawaiVO keluargaPegawaiVO = keluargaPegawaiService.findById(id);
return getJsonResponse(keluargaPegawaiVO, OK);
}
@RequestMapping(value = "/cari-alamat-by-pasien-id/{id}", method = RequestMethod.GET)
public ResponseEntity<KeluargaPegawaiVO> getByPasienVO(
@PathVariable("id") Integer id) {
KeluargaPegawaiVO keluargaPegawaiVO = keluargaPegawaiService
.findById(id);
return RestUtil.getJsonResponse(keluargaPegawaiVO, HttpStatus.OK);
}
@Override
public ResponseEntity<Collection<KeluargaPegawaiVO>> getAllVOWithQueryString(
HttpServletRequest request, Integer page, Integer limit,
String sort, String dir) {
return null;
}
@RequestMapping(value = "/save-keluarga-pegawai", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/save-keluarga-pegawai", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<String> addVO(@Valid @RequestBody KeluargaPegawaiVO vo) {
try {
KeluargaPegawaiVO result = keluargaPegawaiService.add(vo);
if (null != result)
return RestUtil.getJsonResponse("Success", HttpStatus.CREATED);
return getJsonResponse("Success", CREATED);
} catch (ServiceVOException e) {
LOGGER.error("Got exception {} when add pegawai", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when add", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Pegawai", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when add", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE);
return getJsonHttpStatus(NOT_ACCEPTABLE);
}
@Override
public ResponseEntity<String> editVO(KeluargaPegawaiVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<KeluargaPegawaiVO>> getAllVO() {
return null;
}
}

View File

@ -1,185 +1,81 @@
package com.jasamedika.medifirst2000.controller;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.KeluhanPelangganService;
import com.jasamedika.medifirst2000.vo.KeluhanPelangganVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.IBaseRestController;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.KeluhanPelangganService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.KeluhanPelangganVO;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
import static org.springframework.http.HttpStatus.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController
@RequestMapping("/keluhan-pelanggan")
public class KeluhanPelangganController extends LocaleController<KeluhanPelangganVO> implements IBaseRestController<KeluhanPelangganVO> {
public class KeluhanPelangganController extends LocaleController<KeluhanPelangganVO> {
private static final Logger LOGGER = LoggerFactory.getLogger(KeluhanPelangganController.class);
@Autowired
private KeluhanPelangganService keluhanPelangganService;
private static final Logger LOGGER = LoggerFactory
.getLogger(KeluhanPelangganController.class);
@RequestMapping(value = "/save-keluhan-pelanggan/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> addVO(@Valid @RequestBody KeluhanPelangganVO vo, HttpServletRequest request) {
try {
Map<String,Object> result=keluhanPelangganService.addKeluhanPelanggan(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 Keluhan Pelanggan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when add Keluhan Pelanggan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value = "/update-keluhan-pelanggan/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> updateVO(@Valid @RequestBody KeluhanPelangganVO vo, HttpServletRequest request) {
try {
Map<String,Object> result=keluhanPelangganService.addKeluhanPelanggan(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 Keluhan Pelanggan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when update Keluhan Pelanggan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(value = "/find-all-keluhan-pelanggan/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String,Object>> getAllVO(HttpServletRequest request) {
try {
Map<String,Object> result=keluhanPelangganService.findAllKeluhanPelanggan();
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 Keluhan Pelanggan", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when get all Keluhan Pelanggan", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
mapHeaderMessage);
}
}
@RequestMapping(
value = "/get-keluhanpelanggan-by-period",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getKeluhanPelangganByPeriod(
@RequestParam(value = "bulan", required = true) Integer bulan,
@RequestParam(value = "tahun", required = true) Integer tahun,
HttpServletRequest request) {
@RequestMapping(value = "/save-keluhan-pelanggan/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> addVO(@Valid @RequestBody KeluhanPelangganVO vo,
HttpServletRequest request) {
try {
Map<String, Object> result = keluhanPelangganService.addKeluhanPelanggan(vo);
if (null != result)
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
return getJsonResponse(result, CREATED, mapHeaderMessage);
} catch (ServiceVOException e) {
LOGGER.error("Got ServiceVOException {} when addKeluhanPelanggan", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got JpaSystemException {} when addKeluhanPelanggan", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/get-keluhanpelanggan-by-period", method = GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getKeluhanPelangganByPeriod(@RequestParam(value = "bulan") Integer bulan,
@RequestParam(value = "tahun") Integer tahun, HttpServletRequest request) {
try {
Map<String, Object> result = this.keluhanPelangganService.getKeluhanPelangganByPeriod(bulan, tahun);
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 getKeluhanPelangganByPeriod", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
LOGGER.error("Got ServiceVOException {} when getKeluhanPelangganByPeriod", e.getMessage());
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when getKeluhanPelangganByPeriod", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
LOGGER.error("Got JpaSystemException {} when getKeluhanPelangganByPeriod", jse.getMessage());
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value="/get-pekerjaan",
method=RequestMethod.GET,
produces=MediaType.APPLICATION_JSON_VALUE)
public Map<String, Object> getPekerjaan(
@RequestParam("noRec")String noRec, HttpServletRequest request) {
Map<String, Object> result = this.keluhanPelangganService.getPekerjaan();
return result;
}
@Override
public ResponseEntity<Collection<KeluhanPelangganVO>> getAllVOWithQueryString(HttpServletRequest request,
Integer page, Integer limit, String sort, String dir) {
return null;
}
@Override
public ResponseEntity<KeluhanPelangganVO> getVO(Integer id) {
return null;
}
@Override
public ResponseEntity<String> addVO(KeluhanPelangganVO vo) {
return null;
}
@Override
public ResponseEntity<String> editVO(KeluhanPelangganVO vo) {
return null;
}
@Override
public ResponseEntity<String> deleteVO(Integer id) {
return null;
}
@Override
public ResponseEntity<List<KeluhanPelangganVO>> getAllVO() {
return null;
}
}

View File

@ -1,95 +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.KemenLembService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.KemenLembVO;
@RestController
@RequestMapping("/kemen-lemb")
public class KemenLembController extends LocaleController<KemenLembVO>{
@Autowired
private KemenLembService kemenLembService;
private static final Logger LOGGER = LoggerFactory
.getLogger(KemenLembController.class);
@RequestMapping(value = "/save-kemen-lemb",
method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> saveKemenLemb(@Valid @RequestBody KemenLembVO vo, HttpServletRequest request) {
try {
Map<String,Object> result = kemenLembService.saveKemenLemb(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 saveKemenLemb", e.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when saveKemenLemb", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/find-all-kemen-lemb", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> findAllKemenLemb(HttpServletRequest request) {
Map<String, Object> result=null;
try {
result = kemenLembService.findAllKemenLemb();
Boolean dataFound = new Boolean((boolean) result.get("dataFound"));
if (dataFound) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
} else {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR, getMessage(MessageResource.LABEL_ERROR, request));
}
}catch(Exception ex){
ex.printStackTrace();
}
return RestUtil.getJsonResponse(result, HttpStatus.OK);
}
@RequestMapping(value = "/find-one-kemen-lemb", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> findOneKemenLemb(HttpServletRequest request) {
Map<String, Object> result=null;
try {
result = kemenLembService.findOneKemenLemb();
Boolean dataFound = new Boolean((boolean) result.get("dataFound"));
if (dataFound) {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
} else {
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR, getMessage(MessageResource.LABEL_ERROR, request));
}
}catch(Exception ex){
ex.printStackTrace();
}
return RestUtil.getJsonResponse(result, HttpStatus.OK);
}
}

View File

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