76 lines
2.1 KiB
Java
76 lines
2.1 KiB
Java
package com.jasamedika.medifirst2000.converter;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import com.google.gson.Gson;
|
|
import com.jasamedika.medifirst2000.converter.base.BaseVoConverter;
|
|
import com.jasamedika.medifirst2000.dao.custom.base.impl.FindConverterDao;
|
|
import com.jasamedika.medifirst2000.entities.PapStatusKemandirian;
|
|
import com.jasamedika.medifirst2000.vo.PapStatusKemandirianVO;
|
|
|
|
/**
|
|
* Converter class PapStatusKemandirian
|
|
*
|
|
* @author Askur
|
|
*/
|
|
@Component
|
|
public class PapStatusKemandirianConverter extends FindConverterDao implements
|
|
BaseVoConverter<PapStatusKemandirianVO, PapStatusKemandirian> {
|
|
|
|
public PapStatusKemandirian transferVOToModel(PapStatusKemandirianVO vo, PapStatusKemandirian model) {
|
|
if (null == model)
|
|
model = new PapStatusKemandirian();
|
|
|
|
try {
|
|
String[] fieldsToInclude = null;
|
|
Map<String, Object> serialized = vo.serialize(fieldsToInclude,vo.getClass().getName());
|
|
Gson gson = new Gson();
|
|
String json = gson.toJson(serialized);
|
|
model = gson.fromJson(json, PapStatusKemandirian.class);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
return model;
|
|
|
|
}
|
|
|
|
public List<PapStatusKemandirianVO> transferListOfModelToListOfVO(List<PapStatusKemandirian> models,
|
|
List<PapStatusKemandirianVO> vos) {
|
|
if (null == vos)
|
|
vos = new ArrayList<PapStatusKemandirianVO>();
|
|
|
|
if (null == models)
|
|
return vos;
|
|
|
|
for (PapStatusKemandirian model : models) {
|
|
PapStatusKemandirianVO vo = new PapStatusKemandirianVO();
|
|
transferModelToVO(model, vo);
|
|
vos.add(vo);
|
|
}
|
|
|
|
return vos;
|
|
}
|
|
|
|
public PapStatusKemandirianVO transferModelToVO(PapStatusKemandirian model, PapStatusKemandirianVO vo) {
|
|
if (null == vo)
|
|
vo = new PapStatusKemandirianVO();
|
|
|
|
try {
|
|
String[] fieldsToInclude = null;
|
|
Map<String, Object> serialized = model.serialize(fieldsToInclude,model.getClass().getSimpleName());
|
|
Gson gson = new Gson();
|
|
String json = gson.toJson(serialized);
|
|
vo = gson.fromJson(json, PapStatusKemandirianVO.class);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
return vo;
|
|
}
|
|
|
|
}
|