Search in sources :

Example 1 with CatalogTool

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;
}
Also used : CatalogTool(it.istat.mec.catalog.domain.CatalogTool) ArrayList(java.util.ArrayList)

Example 2 with CatalogTool

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);
}
Also used : CatalogTool(it.istat.mec.catalog.domain.CatalogTool) NoDataException(it.istat.mec.catalog.exceptions.NoDataException)

Example 3 with CatalogTool

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);
}
Also used : Agent(it.istat.mec.catalog.domain.Agent) Documentation(it.istat.mec.catalog.domain.Documentation) GsbpmProcess(it.istat.mec.catalog.domain.GsbpmProcess) ArrayList(java.util.ArrayList) LinkAgentTool(it.istat.mec.catalog.domain.LinkAgentTool) Date(java.util.Date) CatalogTool(it.istat.mec.catalog.domain.CatalogTool) StatisticalMethod(it.istat.mec.catalog.domain.StatisticalMethod) NoDataException(it.istat.mec.catalog.exceptions.NoDataException)

Example 4 with CatalogTool

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;
}
Also used : CatalogTool(it.istat.mec.catalog.domain.CatalogTool) DesktopApplication(it.istat.mec.catalog.domain.DesktopApplication) CatalogToolDTO(it.istat.mec.catalog.dto.CatalogToolDTO) StatisticalServiceDto(it.istat.mec.catalog.dto.StatisticalServiceDto) SoftwareProcedureDto(it.istat.mec.catalog.dto.SoftwareProcedureDto) DesktopApplicationDto(it.istat.mec.catalog.dto.DesktopApplicationDto) StatisticalService(it.istat.mec.catalog.domain.StatisticalService) SoftwareProcedure(it.istat.mec.catalog.domain.SoftwareProcedure) ModelMapper(org.modelmapper.ModelMapper)

Example 5 with CatalogTool

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);
}
Also used : Agent(it.istat.mec.catalog.domain.Agent) Documentation(it.istat.mec.catalog.domain.Documentation) GsbpmProcess(it.istat.mec.catalog.domain.GsbpmProcess) ArrayList(java.util.ArrayList) LinkAgentTool(it.istat.mec.catalog.domain.LinkAgentTool) Date(java.util.Date) CatalogTool(it.istat.mec.catalog.domain.CatalogTool) StatisticalMethod(it.istat.mec.catalog.domain.StatisticalMethod)

Aggregations

CatalogTool (it.istat.mec.catalog.domain.CatalogTool)8 ArrayList (java.util.ArrayList)4 ModelMapper (org.modelmapper.ModelMapper)3 Agent (it.istat.mec.catalog.domain.Agent)2 DesktopApplication (it.istat.mec.catalog.domain.DesktopApplication)2 Documentation (it.istat.mec.catalog.domain.Documentation)2 GsbpmProcess (it.istat.mec.catalog.domain.GsbpmProcess)2 LinkAgentTool (it.istat.mec.catalog.domain.LinkAgentTool)2 SoftwareProcedure (it.istat.mec.catalog.domain.SoftwareProcedure)2 StatisticalMethod (it.istat.mec.catalog.domain.StatisticalMethod)2 StatisticalService (it.istat.mec.catalog.domain.StatisticalService)2 CatalogToolDTO (it.istat.mec.catalog.dto.CatalogToolDTO)2 DesktopApplicationDto (it.istat.mec.catalog.dto.DesktopApplicationDto)2 SoftwareProcedureDto (it.istat.mec.catalog.dto.SoftwareProcedureDto)2 StatisticalServiceDto (it.istat.mec.catalog.dto.StatisticalServiceDto)2 NoDataException (it.istat.mec.catalog.exceptions.NoDataException)2 Date (java.util.Date)2 ToolType (it.istat.mec.catalog.domain.ToolType)1