Project

General

Profile

Download (2.61 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2021 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.dto;
10

    
11
import java.io.Serializable;
12
import java.util.UUID;
13

    
14
import eu.etaxonomy.cdm.model.description.State;
15
import eu.etaxonomy.cdm.persistence.dto.TermDto;
16

    
17
/**
18
 * @author k.luther
19
 * @since Aug 19, 2021
20
 */
21
public class StateDataDto implements Serializable {
22

    
23
    private TermDto state;
24
    private Integer count;
25
    private UUID uuid;
26

    
27
    public StateDataDto(TermDto state, Integer count, UUID uuid){
28
        this.state = state;
29
        this.count = count;
30
        setUuid(uuid);
31
    }
32

    
33
    public StateDataDto(State state){
34
        this.state = TermDto.fromTerm(state);
35
        //new StateData
36
        setUuid(null);
37
    }
38

    
39

    
40

    
41
    public StateDataDto(TermDto state){
42
        this.state = state;
43
        //new StateData
44
        setUuid(null);
45
    }
46

    
47
    public Integer getCount() {
48
        return count;
49
    }
50
    public void setCount(int count) {
51
        this.count = count;
52
    }
53
    public TermDto getState() {
54
        return state;
55
    }
56
    public void setState(TermDto state) {
57
        this.state = state;
58
    }
59
    public UUID getUuid() {
60
        return uuid;
61
    }
62
    public void setUuid(UUID uuid) {
63
        this.uuid = uuid;
64
    }
65

    
66
    public static String getStateDataDtoSelect(String fromTable){
67
        String[] result = createSqlParts(fromTable);
68

    
69
        return result[0]+result[1]+result[2];
70
    }
71

    
72
    private static String[] createSqlParts(String fromTable) {
73
        String sqlSelectString = ""
74
                + "select a.uuid, "
75
                + "r, "
76
                + "p.uuid, "
77
                + "k.uuid, "
78
                + "v.uuid, "
79
                + "a.orderIndex, "
80
                + "a.idInVocabulary, "
81
//                + "voc_rep,  "
82
                + "a.termType,  "
83
                + "a.uri,  "
84
                + "m,  "
85
                + "a.titleCache ";
86
        String sqlFromString =   " FROM "+fromTable+" as a ";
87

    
88
        String sqlJoinString =  "LEFT JOIN a.partOf as p "
89
                + "LEFT JOIN a.kindOf as k "
90
                + "LEFT JOIN a.media as m "
91
                + "LEFT JOIN a.representations AS r "
92
                + "LEFT JOIN a.vocabulary as v "
93
//                + "LEFT JOIN v.representations as voc_rep "
94
                ;
95

    
96
        String[] result = new String[3];
97
        result[0] = sqlSelectString;
98
        result[1] = sqlFromString;
99
        result[2] = sqlJoinString;
100
        return result;
101
    }
102

    
103
}
(40-40/47)