Revision 37d1c24f
Added by Patrick Plitzner over 5 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/TermDto.java | ||
---|---|---|
20 | 20 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
21 | 21 |
import eu.etaxonomy.cdm.model.common.OrderedTermBase; |
22 | 22 |
import eu.etaxonomy.cdm.model.common.Representation; |
23 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
|
23 | 24 |
|
24 | 25 |
/** |
25 | 26 |
* @author andreas |
... | ... | |
33 | 34 |
private UUID kindOfUuid = null; |
34 | 35 |
private UUID partOfUuid = null; |
35 | 36 |
private UUID vocabularyUuid = null; |
37 |
private TermDto kindOfDto = null; |
|
38 |
private TermDto partOfDto = null; |
|
39 |
private TermVocabularyDto vocabularyDto = null; |
|
36 | 40 |
private Integer orderIndex = null; |
37 | 41 |
private String idInVocabulary = null; |
38 | 42 |
private Collection<TermDto> includes; |
... | ... | |
48 | 52 |
} |
49 | 53 |
|
50 | 54 |
static public TermDto fromTerm(DefinedTermBase term) { |
51 |
return fromTerm(term, null); |
|
55 |
return fromTerm(term, null, false); |
|
56 |
} |
|
57 |
|
|
58 |
static public TermDto fromTerm(DefinedTermBase term, boolean initializeToTop) { |
|
59 |
return fromTerm(term, null, initializeToTop); |
|
52 | 60 |
} |
53 | 61 |
|
54 | 62 |
static public TermDto fromTerm(DefinedTermBase term, Set<Representation> representations) { |
63 |
return fromTerm(term, representations, false); |
|
64 |
} |
|
65 |
|
|
66 |
static public TermDto fromTerm(DefinedTermBase term, Set<Representation> representations, boolean initializeToTop) { |
|
67 |
DefinedTermBase partOf = term.getPartOf(); |
|
68 |
DefinedTermBase kindOf = term.getKindOf(); |
|
69 |
TermVocabulary vocabulary = term.getVocabulary(); |
|
55 | 70 |
TermDto dto = new TermDto( |
56 | 71 |
term.getUuid(), |
57 | 72 |
representations!=null?representations:term.getRepresentations(), |
58 |
(term.getPartOf()!=null?term.getPartOf().getUuid():null),
|
|
59 |
(term.getKindOf()!=null?term.getKindOf().getUuid():null),
|
|
60 |
term.getVocabulary().getUuid(),
|
|
73 |
(partOf!=null?partOf.getUuid():null),
|
|
74 |
(kindOf!=null?kindOf.getUuid():null),
|
|
75 |
vocabulary.getUuid(),
|
|
61 | 76 |
(term instanceof OrderedTermBase)?((OrderedTermBase) term).getOrderIndex():null, |
62 | 77 |
term.getIdInVocabulary()); |
78 |
if(initializeToTop){ |
|
79 |
if(partOf!=null){ |
|
80 |
dto.setPartOfDto(fromTerm(partOf, initializeToTop)); |
|
81 |
} |
|
82 |
if(kindOf!=null){ |
|
83 |
dto.setKindOfDto(fromTerm(kindOf, initializeToTop)); |
|
84 |
} |
|
85 |
dto.setVocabularyDto(new TermVocabularyDto(vocabulary.getUuid(), vocabulary.getRepresentations())); |
|
86 |
} |
|
63 | 87 |
return dto; |
64 | 88 |
} |
65 | 89 |
|
90 |
public void setPartOfDto(TermDto partOfDto) { |
|
91 |
this.partOfDto = partOfDto; |
|
92 |
} |
|
93 |
|
|
94 |
public TermDto getPartOfDto() { |
|
95 |
return partOfDto; |
|
96 |
} |
|
97 |
|
|
98 |
public void setKindOfDto(TermDto kindOfDto) { |
|
99 |
this.kindOfDto = kindOfDto; |
|
100 |
} |
|
101 |
|
|
102 |
public TermDto getKindOfDto() { |
|
103 |
return kindOfDto; |
|
104 |
} |
|
105 |
|
|
106 |
public void setVocabularyDto(TermVocabularyDto vocabularyDto) { |
|
107 |
this.vocabularyDto = vocabularyDto; |
|
108 |
} |
|
109 |
|
|
110 |
public TermVocabularyDto getVocabularyDto() { |
|
111 |
return vocabularyDto; |
|
112 |
} |
|
113 |
|
|
66 | 114 |
public UUID getVocabularyUuid() { |
67 | 115 |
return vocabularyUuid; |
68 | 116 |
} |
Also available in: Unified diff
ref #7887 Add "parent" DTOs to TermDto