use of it.istat.mec.catalog.domain.CatalogTool in project catalogo-strumenti by istat-methodology.
the class StatisticalServiceService method findByCataloTools.
public List<StatisticalServiceDto> findByCataloTools(Long id) {
List<CatalogTool> catalogTools = new ArrayList<CatalogTool>();
catalogTools.add(new CatalogTool(id));
// return Translators.translateSM(statisticalMethodDao.findByCatalogTools(catalogTools));
return null;
}
use of it.istat.mec.catalog.domain.CatalogTool in project catalogo-strumenti by istat-methodology.
the class ToolService method deleteTool.
public CatalogToolDTO deleteTool(Long id) {
if (!toolDao.findById(id).isPresent())
throw new NoDataException("Tool not present");
CatalogTool tool = toolDao.findById(id).get();
toolDao.delete(tool);
return Translators.translate(tool);
}
use of it.istat.mec.catalog.domain.CatalogTool in project catalogo-strumenti by istat-methodology.
the class ToolService method updateTool.
public CatalogToolDTO updateTool(CreateToolRequest request) {
if (!toolDao.findById(request.getId()).isPresent())
throw new NoDataException("Tool not present");
CatalogTool tool = toolDao.findById(request.getId()).get();
List<GsbpmProcess> gsbpmProcesses = new ArrayList<GsbpmProcess>();
List<LinkAgentTool> linkAgentsTools = new ArrayList<LinkAgentTool>();
List<StatisticalMethod> statisticalMethods = new ArrayList<StatisticalMethod>();
List<Documentation> documentations = new ArrayList<Documentation>();
tool = Translators.translate(request);
if (request.getGsbpmProcesses() != null) {
for (int i = 0; i < request.getGsbpmProcesses().length; i++) gsbpmProcesses.add(new GsbpmProcess(request.getGsbpmProcesses()[i]));
}
if (request.getLinkAgents() != null) {
for (int i = 0; i < request.getLinkAgents().length; i++) {
LinkAgentTool linkAgentTool = new LinkAgentTool();
Agent agent = agentDao.findById(request.getLinkAgents()[i].getAgent()).get();
linkAgentTool.setId(request.getLinkAgents()[i].getId());
linkAgentTool.setAgent(agent);
linkAgentTool.setTool(tool);
linkAgentTool.setNotes(request.getLinkAgents()[i].getNotes());
linkAgentTool.setReferenceDate(request.getLinkAgents()[i].getReferenceDate());
linkAgentTool.setRole(request.getLinkAgents()[i].getRole());
linkAgentsTools.add(linkAgentTool);
}
}
if (request.getStatisticalMethods() != null) {
for (int i = 0; i < request.getStatisticalMethods().length; i++) statisticalMethods.add(new StatisticalMethod(request.getStatisticalMethods()[i]));
}
if (request.getDocumentations() != null) {
for (int i = 0; i < request.getDocumentations().length; i++) {
Documentation doc = documentationDao.findById(request.getDocumentations()[i]).get();
doc.setTool(tool);
documentations.add(doc);
}
}
tool.setGsbpmProcesses(gsbpmProcesses);
tool.setLinkAgentsTools(linkAgentsTools);
tool.setStatisticalMethods(statisticalMethods);
tool.setDocumentations(documentations);
Date date = new Date(System.currentTimeMillis());
tool.setLastUpdate(date);
toolDao.save(tool);
return Translators.translate(tool);
}
use of it.istat.mec.catalog.domain.CatalogTool in project catalogo-strumenti by istat-methodology.
the class Translators method translate.
public static CatalogToolDTO translate(CatalogTool x) {
final ModelMapper modelMapper = new ModelMapper();
TypeMap<CatalogTool, CatalogToolDTO> typeMap = modelMapper.createTypeMap(CatalogTool.class, CatalogToolDTO.class);
typeMap.include(DesktopApplication.class, CatalogToolDTO.class).include(StatisticalService.class, CatalogToolDTO.class).include(SoftwareProcedure.class, CatalogToolDTO.class);
modelMapper.typeMap(DesktopApplication.class, CatalogToolDTO.class).setProvider(new Provider<CatalogToolDTO>() {
public CatalogToolDTO get(ProvisionRequest<CatalogToolDTO> request) {
return new DesktopApplicationDto();
}
});
modelMapper.typeMap(StatisticalService.class, CatalogToolDTO.class).setProvider(new Provider<CatalogToolDTO>() {
public CatalogToolDTO get(ProvisionRequest<CatalogToolDTO> request) {
return new StatisticalServiceDto();
}
});
modelMapper.typeMap(SoftwareProcedure.class, CatalogToolDTO.class).setProvider(new Provider<CatalogToolDTO>() {
public CatalogToolDTO get(ProvisionRequest<CatalogToolDTO> request) {
return new SoftwareProcedureDto();
}
});
CatalogToolDTO dTO = null;
if (x instanceof StatisticalService)
dTO = modelMapper.map(x, StatisticalServiceDto.class);
if (x instanceof DesktopApplication)
dTO = modelMapper.map(x, DesktopApplicationDto.class);
if (x instanceof SoftwareProcedure)
dTO = modelMapper.map(x, SoftwareProcedureDto.class);
return dTO;
}
use of it.istat.mec.catalog.domain.CatalogTool in project catalogo-strumenti by istat-methodology.
the class ToolService method newTool.
public CatalogToolDTO newTool(CreateToolRequest request) {
CatalogTool tool = new CatalogTool();
List<GsbpmProcess> gsbpmProcesses = new ArrayList<GsbpmProcess>();
List<LinkAgentTool> linkAgentsTools = new ArrayList<LinkAgentTool>();
List<StatisticalMethod> statisticalMethods = new ArrayList<StatisticalMethod>();
List<Documentation> documentations = new ArrayList<Documentation>();
tool = Translators.translate(request);
if (request.getGsbpmProcesses() != null) {
for (int i = 0; i < request.getGsbpmProcesses().length; i++) gsbpmProcesses.add(new GsbpmProcess(request.getGsbpmProcesses()[i]));
}
if (request.getLinkAgents() != null) {
for (int i = 0; i < request.getLinkAgents().length; i++) {
LinkAgentTool linkAgentTool = new LinkAgentTool();
Agent agent = agentDao.findById(request.getLinkAgents()[i].getAgent()).get();
linkAgentTool.setId(request.getLinkAgents()[i].getId());
linkAgentTool.setAgent(agent);
linkAgentTool.setTool(tool);
linkAgentTool.setNotes(request.getLinkAgents()[i].getNotes());
linkAgentTool.setReferenceDate(request.getLinkAgents()[i].getReferenceDate());
linkAgentTool.setRole(request.getLinkAgents()[i].getRole());
linkAgentsTools.add(linkAgentTool);
}
}
if (request.getStatisticalMethods() != null) {
for (int i = 0; i < request.getStatisticalMethods().length; i++) statisticalMethods.add(new StatisticalMethod(request.getStatisticalMethods()[i]));
}
if (request.getDocumentations() != null) {
for (int i = 0; i < request.getDocumentations().length; i++) {
Documentation doc = documentationDao.findById(request.getDocumentations()[i]).get();
doc.setTool(tool);
documentations.add(doc);
}
}
tool.setGsbpmProcesses(gsbpmProcesses);
tool.setLinkAgentsTools(linkAgentsTools);
tool.setStatisticalMethods(statisticalMethods);
tool.setDocumentations(documentations);
Date date = new Date(System.currentTimeMillis());
tool.setLastUpdate(date);
toolDao.save(tool);
return Translators.translate(tool);
}
Aggregations