Project

General

Profile

Revision 0962e21b

ID0962e21b7f776d17f4d4a6cb43cd492fcd275ccb
Parent 38588c66
Child 5e403d42

Added by Andreas Kohlbecker over 2 years ago

ref #7791 TaxonGraphService and TaxonGraphController implemented

View differences:

cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/TaxonGraphController.java
1
/**
2
* Copyright (C) 2018 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.remote.controller;
10

  
11
import java.util.List;
12
import java.util.UUID;
13

  
14
import javax.servlet.http.HttpServletRequest;
15

  
16
import org.apache.log4j.Logger;
17
import org.springframework.beans.factory.annotation.Autowired;
18
import org.springframework.stereotype.Controller;
19
import org.springframework.web.bind.WebDataBinder;
20
import org.springframework.web.bind.annotation.InitBinder;
21
import org.springframework.web.bind.annotation.RequestMapping;
22
import org.springframework.web.bind.annotation.RequestMethod;
23
import org.springframework.web.bind.annotation.RequestParam;
24

  
25
import eu.etaxonomy.cdm.api.service.ITaxonGraphService;
26
import eu.etaxonomy.cdm.persistence.dao.taxonGraph.TaxonGraphException;
27
import eu.etaxonomy.cdm.persistence.dto.TaxonGraphEdgeDTO;
28
import eu.etaxonomy.cdm.remote.editor.UUIDPropertyEditor;
29
import io.swagger.annotations.Api;
30

  
31
/**
32
 * @author a.kohlbecker
33
 * @since Oct 2, 2018
34
 *
35
 */
36
@Controller
37
@Api("taxonGraph")
38
@RequestMapping(value = {"/taxonGraph"})
39
public class TaxonGraphController {
40

  
41

  
42
    public static final Logger logger = Logger.getLogger(TaxonGraphController.class);
43

  
44
    @Autowired
45
    private ITaxonGraphService service;
46

  
47
    @InitBinder
48
    public void initBinder(WebDataBinder binder) {
49
        binder.registerCustomEditor(UUID.class, new UUIDPropertyEditor());
50
    }
51

  
52
    @RequestMapping(method = RequestMethod.GET, value="edges")
53
    public List<TaxonGraphEdgeDTO> doEdges(
54
            @RequestParam(value = "fromTaxonUuid", required = false) UUID fromTaxonUuid,
55
            @RequestParam(value = "toTaxonUuid", required = false) UUID toTaxonUuid,
56
            HttpServletRequest request) throws TaxonGraphException{
57

  
58
        logger.info("doEdges() " + request.getRequestURL());
59
        return service.edges(fromTaxonUuid, toTaxonUuid, false);
60
    }
61

  
62
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ITaxonGraphService.java
1
/**
2
* Copyright (C) 2018 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.api.service;
10

  
11
import java.util.List;
12
import java.util.UUID;
13

  
14
import eu.etaxonomy.cdm.persistence.dao.taxonGraph.TaxonGraphException;
15
import eu.etaxonomy.cdm.persistence.dto.TaxonGraphEdgeDTO;
16

  
17
/**
18
 * @author a.kohlbecker
19
 * @since Oct 2, 2018
20
 *
21
 */
22
public interface ITaxonGraphService {
23

  
24
    List<TaxonGraphEdgeDTO> edges(UUID fromtaxonUuid, UUID toTaxonUuid, boolean includeUnpublished) throws TaxonGraphException;
25

  
26
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonGraphServiceImpl.java
1
/**
2
* Copyright (C) 2018 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.api.service;
10

  
11
import java.util.List;
12
import java.util.UUID;
13

  
14
import org.springframework.beans.factory.annotation.Autowired;
15
import org.springframework.stereotype.Service;
16
import org.springframework.transaction.annotation.Transactional;
17

  
18
import eu.etaxonomy.cdm.persistence.dao.taxonGraph.ITaxonGraphDao;
19
import eu.etaxonomy.cdm.persistence.dao.taxonGraph.TaxonGraphException;
20
import eu.etaxonomy.cdm.persistence.dto.TaxonGraphEdgeDTO;
21

  
22
/**
23
 * @author a.kohlbecker
24
 * @since Oct 2, 2018
25
 *
26
 */
27
@Service
28
@Transactional(readOnly = true)
29
public class TaxonGraphServiceImpl implements ITaxonGraphService {
30

  
31
    @Autowired
32
    private ITaxonGraphDao taxonGraphDao;
33

  
34

  
35
    @Override
36
    public List<TaxonGraphEdgeDTO> edges(UUID fromtaxonUuid, UUID toTaxonUuid, boolean includeUnpublished) throws TaxonGraphException{
37
        return taxonGraphDao.edges(fromtaxonUuid, toTaxonUuid, includeUnpublished);
38
    }
39
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)