View Javadoc
1   package net.sumaris.core.service;
2   
3   /*-
4    * #%L
5    * SUMARiS:: Core
6    * %%
7    * Copyright (C) 2018 SUMARiS Consortium
8    * %%
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU General Public License as
11   * published by the Free Software Foundation, either version 3 of the
12   * License, or (at your option) any later version.
13   * 
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   * 
19   * You should have received a copy of the GNU General Public
20   * License along with this program.  If not, see
21   * <http://www.gnu.org/licenses/gpl-3.0.html>.
22   * #L%
23   */
24  
25  import net.sumaris.core.dao.administration.user.PersonDao;
26  import net.sumaris.core.dao.data.LandingRepository;
27  import net.sumaris.core.dao.data.ObservedLocationDao;
28  import net.sumaris.core.dao.data.OperationDao;
29  import net.sumaris.core.dao.data.TripDao;
30  import net.sumaris.core.model.administration.user.Person;
31  import net.sumaris.core.model.data.Landing;
32  import net.sumaris.core.model.data.ObservedLocation;
33  import net.sumaris.core.model.data.Operation;
34  import net.sumaris.core.model.data.Trip;
35  import net.sumaris.core.vo.administration.user.PersonVO;
36  import net.sumaris.core.vo.data.LandingVO;
37  import net.sumaris.core.vo.data.ObservedLocationVO;
38  import net.sumaris.core.vo.data.OperationVO;
39  import net.sumaris.core.vo.data.TripVO;
40  import org.springframework.beans.factory.annotation.Autowired;
41  import org.springframework.core.convert.support.GenericConversionService;
42  import org.springframework.stereotype.Component;
43  
44  import javax.annotation.PostConstruct;
45  
46  @Component("conversionService")
47  public class ConversionServiceImpl extends GenericConversionService {
48  
49      @Autowired
50      private TripDao tripDao;
51  
52      @Autowired
53      private ObservedLocationDao observedLocationDao;
54  
55      @Autowired
56      private OperationDao operationDao;
57  
58      @Autowired
59      private LandingRepository landingRepository;
60  
61      @Autowired
62      private PersonDao personDao;
63  
64      @PostConstruct
65      private void initConverters() {
66  
67          // Entity->VO converters
68          addConverter(Trip.class, TripVO.class, tripDao::toVO);
69          addConverter(ObservedLocation.class, ObservedLocationVO.class, observedLocationDao::toVO);
70          addConverter(Operation.class, OperationVO.class, operationDao::toVO);
71          addConverter(Landing.class, LandingVO.class, landingRepository::toVO);
72          addConverter(Person.class, PersonVO.class, personDao::toPersonVO);
73      }
74  }