Revision 440ea14c
Added by Andreas Müller over 2 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/TermVocabularyDto.java | ||
---|---|---|
42 | 42 |
return dto; |
43 | 43 |
} |
44 | 44 |
|
45 |
public static List<TermVocabularyDto> termVocabularyDtoListFrom(List<Object[]> results) {
|
|
45 |
public static List<TermVocabularyDto> termVocabularyDtoListFrom(List<Object[]> queryResult) {
|
|
46 | 46 |
List<TermVocabularyDto> dtos = new ArrayList<>(); // list to ensure order |
47 | 47 |
// map to handle multiple representations because of LEFT JOIN |
48 |
Map<UUID, TermCollectionDto> dtoMap = new HashMap<>(results.size());
|
|
49 |
for (Object[] elements : results) {
|
|
48 |
Map<UUID, TermCollectionDto> dtoMap = new HashMap<>(queryResult.size());
|
|
49 |
for (Object[] elements : queryResult) {
|
|
50 | 50 |
UUID uuid = (UUID)elements[0]; |
51 | 51 |
if(dtoMap.containsKey(uuid)){ |
52 | 52 |
// multiple results for one voc -> multiple (voc) representation |
... | ... | |
58 | 58 |
// voc representation |
59 | 59 |
Set<Representation> representations = new HashSet<>(); |
60 | 60 |
if(elements[1] instanceof Representation) { |
61 |
representations = new HashSet<Representation>(1);
|
|
61 |
representations = new HashSet<>(1); |
|
62 | 62 |
representations.add((Representation)elements[1]); |
63 | 63 |
} |
64 | 64 |
|
65 |
|
|
66 | 65 |
TermVocabularyDto termVocDto = new TermVocabularyDto( |
67 | 66 |
uuid, |
68 | 67 |
representations, |
... | ... | |
72 | 71 |
(boolean)elements[5], |
73 | 72 |
(boolean)elements[6]); |
74 | 73 |
|
75 |
|
|
76 | 74 |
dtoMap.put(uuid, termVocDto); |
77 | 75 |
dtos.add(termVocDto); |
78 | 76 |
} |
79 | 77 |
} |
80 | 78 |
return dtos; |
81 | 79 |
} |
82 |
|
|
83 |
} |
|
80 |
} |
Also available in: Unified diff
cleanup