use of org.modelmapper.ModelMapper in project pinot by linkedin.
the class GenericResultSetMapper method main.
public static void main(String[] args) throws Exception {
ModelMapper mapper = new ModelMapper();
Map<String, Object> result = new HashMap<>();
//[{jobName=Test_Anomaly_Task, jobId=1, workerId=1, taskType=MONITOR, id=1, taskInfo=clob2: '{"jobExecutionId":1,"monitorType":"UPDATE","expireDaysAgo":0}', lastModified=2016-08-24 17:25:53.258, version=0, taskStartTime=1470356753227, status=RUNNING, taskEndTime=1471220753227}]
result.put("jobName", "Test_Anomaly_Task");
result.put("jobId", 1L);
result.put("taskType", "MONITOR");
result.put("id", 1L);
result.put("taskInfo", "clob2: '{\"jobExecutionId\":1,\"monitorType\":\"UPDATE\",\"expireDaysAgo\":0}'");
result.put("taskType", "MONITOR");
result.put("lastModified", "2016-08-24 17:25:53.258");
result.put("status", "RUNNING");
result.put("lastModified", "2016-08-24 17:25:53.258");
TaskDTO taskSpec1 = mapper.map(result, TaskDTO.class);
System.out.println(taskSpec1);
//INPUT 2
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(new File("/tmp/map.out.1472093046128")));
Map<String, Object> inputMap = (Map<String, Object>) ois.readObject();
TaskDTO taskSpec2 = mapper.map(inputMap, TaskDTO.class);
System.out.println(taskSpec2);
}
use of org.modelmapper.ModelMapper in project useful-java-links by Vedenin.
the class ModelMapperHelloWorld method main.
public static void main(String[] args) {
// init mapper
PropertyMap<Source, Destination> orderMap = new PropertyMap<Source, Destination>() {
protected void configure() {
map().setText(source.getMessage());
}
};
ModelMapper modelMapper = new ModelMapper();
modelMapper.addMappings(orderMap);
// convert
Source source = new Source("Hello World!");
Destination destObject = modelMapper.map(source, Destination.class);
// print Hello World!
destObject.print();
}
use of org.modelmapper.ModelMapper in project Settler by EmhyrVarEmreis.
the class CategoryService method getCategoriesWithValue.
public ResponseEntity<List<CategoryWithValueDTO>> getCategoriesWithValue(Long userId) {
if (Objects.isNull(userId) || userId < 0) {
userId = Security.currentUser().getId();
}
QCategory category = QCategory.category;
QTransaction transaction = QTransaction.transaction;
List<Tuple> fetch = new JPAQuery<>(entityManager).from(category, transaction).select(category, transaction.value.sum()).where(transaction.creator.id.eq(userId)).where(transaction.categories.contains(category)).groupBy(category.code, category.description).orderBy(transaction.value.sum().desc()).fetch();
ModelMapper preparedModelMapper = getModelMapper();
List<CategoryWithValueDTO> categoryWithValueDTOList = new ArrayList<>(fetch.size());
for (Tuple tuple : fetch) {
Category c = tuple.get(category);
Double d = tuple.get(transaction.value.sum());
if (Objects.nonNull(c)) {
categoryWithValueDTOList.add(new CategoryWithValueDTO(userId, preparedModelMapper.map(c, CategoryDTO.class), d));
}
}
return new ResponseEntity<>(categoryWithValueDTOList, HttpStatus.OK);
}
use of org.modelmapper.ModelMapper in project Internet-Software-Architectures by zivko11.
the class ActorPerformancesManager method Create.
public boolean Create(ActorPerformancesDTO dto) {
ModelMapper mapper = new ModelMapper();
Actorperformances actorPerformances;
try {
actorPerformances = mapper.map(dto, Actorperformances.class);
} catch (Exception exc) {
exc.printStackTrace();
return false;
}
actorPerformancesRepository.save(actorPerformances);
return true;
}
use of org.modelmapper.ModelMapper in project Internet-Software-Architectures by zivko11.
the class CinemaTheatreManager method ReadAll.
public ArrayList<CinemaTheatreDTO> ReadAll() {
ModelMapper mapper = new ModelMapper();
ArrayList<CinemaTheatre> listEntities = (ArrayList<CinemaTheatre>) cinemaTheatreRepository.findAll();
ArrayList<CinemaTheatreDTO> listDTO = new ArrayList<CinemaTheatreDTO>();
for (CinemaTheatre tmp : listEntities) {
try {
CinemaTheatreDTO dto = mapper.map(tmp, CinemaTheatreDTO.class);
listDTO.add(dto);
} catch (Exception exc) {
exc.printStackTrace();
return null;
}
}
return listDTO;
}
Aggregations