Project

General

Profile

« Previous | Next » 

Revision 71559ffe

Added by Katja Luther over 2 years ago

ref #9710: switch to dtos for descriptive data set and descriptions for character matrix

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/filter/TaxonNodeFilter.java
100 100
        return new TaxonNodeFilter().setRankMin(rankMin).setRankMax(rankMax);
101 101
    }
102 102

  
103
    public static TaxonNodeFilter NewRankInstance(UUID rankMinUuid, UUID rankMaxUuid){
104
        return new TaxonNodeFilter().setRankMin(rankMinUuid).setRankMax(rankMaxUuid);
105
    }
106

  
103 107
    public static TaxonNodeFilter NewAreaInstance(NamedArea area){
104 108
        return new TaxonNodeFilter().orArea(area);
105 109
    }
......
152 156
// ********************** reset *****************************/
153 157

  
154 158
    public void reset(){
155
        subtrees = new ArrayList<>();
159
        resetSubtrees();
156 160
        resetAreas();
157 161
        resetRanks();
158 162
        resetDistributionStatus();
......
186 190
        rankMax = null;
187 191
    }
188 192

  
193
    private void resetSubtrees() {
194
        subtrees = new ArrayList<>();
195
    }
196

  
189 197
//*************************************
190 198

  
191 199
    public List<LogicFilter<TaxonNode>>getSubtreeFilter(){
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/term/TermNode.java
37 37

  
38 38
import org.apache.commons.lang3.StringUtils;
39 39
import org.apache.log4j.Logger;
40
import org.hibernate.LazyInitializationException;
40 41
import org.hibernate.annotations.Cascade;
41 42
import org.hibernate.annotations.CascadeType;
42 43
import org.hibernate.envers.Audited;
......
708 709

  
709 710
	void updateSortIndex(){
710 711
	 // TODO workaround (see sortIndex doc)
711
        for (int i = 0; i < children.size(); i++) {
712
            children.get(i).setSortIndex(i);
712
	    try{
713
	        for (int i = 0; i < children.size(); i++) {
714
	            children.get(i).setSortIndex(i);
715
	        }
716
	    } catch (LazyInitializationException e) {
717
            logger.info("Cannot clean up uninitialized children without a session, skipping.");
713 718
        }
719

  
714 720
	}
715 721

  
716 722
	public void removeNullValueFromChildren(){
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/description/IDescriptiveDataSetDao.java
12 12
import eu.etaxonomy.cdm.model.description.Feature;
13 13
import eu.etaxonomy.cdm.persistence.dao.common.IIdentifiableDao;
14 14
import eu.etaxonomy.cdm.persistence.dao.hibernate.common.IdentifiableDaoBase;
15
import eu.etaxonomy.cdm.persistence.dto.DescriptiveDataSetBaseDto;
15 16
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
16 17

  
17 18
public interface IDescriptiveDataSetDao extends IIdentifiableDao<DescriptiveDataSet> {
......
30 31
	@Deprecated
31 32
    public List<UuidAndTitleCache<DescriptiveDataSet>> getDescriptiveDataSetUuidAndTitleCache(Integer limitOfInitialElements,
32 33
            String pattern);
34

  
35
    /**
36
     * @param uuid
37
     * @return
38
     */
39
    DescriptiveDataSetBaseDto getDescriptiveDataSetDtoByUuid(UUID uuid);
33 40
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/DescriptionDaoImpl.java
915 915
        return dtoList;
916 916
    }
917 917

  
918

  
919

  
918 920
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/DescriptiveDataSetDao.java
13 13
import org.hibernate.Query;
14 14
import org.hibernate.Session;
15 15
import org.hibernate.criterion.Restrictions;
16
import org.springframework.beans.factory.annotation.Autowired;
16 17
import org.springframework.beans.factory.annotation.Qualifier;
17 18
import org.springframework.stereotype.Repository;
18 19

  
......
25 26
import eu.etaxonomy.cdm.model.description.QuantitativeData;
26 27
import eu.etaxonomy.cdm.persistence.dao.description.IDescriptiveDataSetDao;
27 28
import eu.etaxonomy.cdm.persistence.dao.hibernate.common.IdentifiableDaoBase;
29
import eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonNodeDao;
30
import eu.etaxonomy.cdm.persistence.dao.term.IDefinedTermDao;
31
import eu.etaxonomy.cdm.persistence.dao.term.ITermTreeDao;
32
import eu.etaxonomy.cdm.persistence.dto.DescriptiveDataSetBaseDto;
33
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
34
import eu.etaxonomy.cdm.persistence.dto.TermDto;
35
import eu.etaxonomy.cdm.persistence.dto.TermTreeDto;
28 36
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
29 37

  
30 38
@Repository
......
34 42
        implements IDescriptiveDataSetDao {
35 43
	private static final Logger logger = Logger.getLogger(DescriptiveDataSetDao.class);
36 44

  
45
	 @Autowired
46
	 private ITermTreeDao termTreeDao;
47

  
48
	 @Autowired
49
     private IDefinedTermDao termDao;
50

  
51
	 @Autowired
52
     private ITaxonNodeDao nodeDao;
53

  
37 54
	public DescriptiveDataSetDao() {
38 55
		super(DescriptiveDataSet.class);
39 56
	}
......
201 218

  
202 219
        return list;
203 220
    }
221

  
222
    private List<UUID> getNodeUuidsForDescriptiveDataSet(UUID uuid) {
223
        Session session = getSession();
224

  
225
        String queryString = "SELECT t.uuid  FROM DescriptiveDataSet a JOIN a.taxonSubtreeFilter as t WHERE a.uuid = :uuid";
226

  
227

  
228
        Query query;
229
        query = session.createQuery(queryString);
230
        query.setParameter("uuid", uuid);
231

  
232

  
233
        @SuppressWarnings("unchecked")
234
        List<UUID> result = query.list();
235
        List<UUID> list = new ArrayList<>();
236
        for(UUID object : result){
237
            list.add(object);
238
        }
239

  
240
        return list;
241
    }
242

  
243

  
244

  
245
    @Override
246
    public DescriptiveDataSetBaseDto getDescriptiveDataSetDtoByUuid(UUID uuid) {
247
        String queryString = DescriptiveDataSetBaseDto.getDescriptiveDataSetDtoSelect()
248
                + " WHERE a.uuid = :uuid"
249
                + " ORDER BY a.titleCache";
250
        Query query =  getSession().createQuery(queryString);
251
        query.setParameter("uuid", uuid);
252

  
253
        @SuppressWarnings("unchecked")
254
        List<Object[]> result = query.list();
255

  
256
        List<DescriptiveDataSetBaseDto> list = DescriptiveDataSetBaseDto.descriptiveDataSetBaseDtoListFrom(result);
257
        UUID descriptiveSystemUuid = null;
258
        UUID minRankUuid = null;
259
        UUID maxRankUuid = null;
260
        if (result != null && !result.isEmpty()){
261
            Object[] descriptiveDataSetResult = result.get(0);
262
            descriptiveSystemUuid = (UUID)descriptiveDataSetResult[4];
263
            minRankUuid = (UUID)descriptiveDataSetResult[5];
264
            maxRankUuid = (UUID)descriptiveDataSetResult[6];
265
        }else{
266
            return null;
267
        }
268
        //get descriptiveSystem
269
        DescriptiveDataSetBaseDto dto = list.get(0);
270
        if (descriptiveSystemUuid != null){
271
            TermTreeDto treeDto = termTreeDao.getTermTreeDtosByUuid(descriptiveSystemUuid);
272
            dto.setDescriptiveSystem(treeDto);
273
        }
274
        //get taxon nodes
275
        List<UUID> nodeUuids = getNodeUuidsForDescriptiveDataSet(uuid);
276
        List<TaxonNodeDto> nodeDtos = nodeDao.getTaxonNodeDtos(nodeUuids);
277
        Set<TaxonNodeDto> nodeSet = new HashSet<>(nodeDtos);
278
        dto.setSubTreeFilter(nodeSet);
279

  
280
        TermDto minRank = termDao.getTermDto(minRankUuid);
281
        TermDto maxRank = termDao.getTermDto(maxRankUuid);
282
        dto.setMaxRank(maxRank);
283
        dto.setMinRank(minRank);
284
        return dto;
285
    }
204 286
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImpl.java
1180 1180
        return list;
1181 1181
    }
1182 1182

  
1183
    @Override
1184
    public TaxonNodeDto getTaxonNodeDto(UUID nodeUuid) {
1185
        String queryString = "SELECT new " + SortableTaxonNodeQueryResult.class.getName() + "("
1186
                + "tn.uuid, tn.id, t.titleCache, rank "
1187
                + ") "
1188
                + " FROM TaxonNode tn "
1189
                + "   INNER JOIN tn.taxon AS t "
1190
                + "   INNER JOIN t.name AS name "
1191
                + "   LEFT OUTER JOIN name.rank AS rank "
1192
                + " WHERE t.uuid LIKE :uuid ";
1193

  
1194

  
1195
        Query query =  getSession().createQuery(queryString);
1196

  
1197
        query.setParameter("uuid", nodeUuid.toString());
1198

  
1199

  
1200
        @SuppressWarnings("unchecked")
1201
        List<SortableTaxonNodeQueryResult> result = query.list();
1202
        Collections.sort(result, new SortableTaxonNodeQueryResultComparator());
1203

  
1204
        List<TaxonNodeDto> list = new ArrayList<>();
1205
        for(SortableTaxonNodeQueryResult queryDTO : result){
1206
            list.add(new TaxonNodeDto(queryDTO.getTaxonNodeUuid(), queryDTO.getTaxonNodeId(), queryDTO.getTaxonTitleCache()));
1207
        }
1208
        return list.get(0);
1209
    }
1210

  
1211
    @Override
1212
    public List<TaxonNodeDto> getTaxonNodeDtos(List<UUID> nodeUuids) {
1213
        String queryString = "SELECT new " + SortableTaxonNodeQueryResult.class.getName() + "("
1214
                + "tn.uuid, tn.id, t.titleCache, rank "
1215
                + ") "
1216
                + " FROM TaxonNode tn "
1217
                + "   INNER JOIN tn.taxon AS t "
1218
                + "   INNER JOIN t.name AS name "
1219
                + "   LEFT OUTER JOIN name.rank AS rank "
1220
                + " WHERE t.uuid IN (:uuid) ";
1221

  
1222

  
1223
        Query query =  getSession().createQuery(queryString);
1224
//        List<String> uuidStrings = nodeUuids.stream().map(e -> e.toString()).collect(Collectors.toList());
1225

  
1226
        query.setParameterList("uuid", nodeUuids);
1227

  
1228

  
1229
        @SuppressWarnings("unchecked")
1230
        List<SortableTaxonNodeQueryResult> result = query.list();
1231
        Collections.sort(result, new SortableTaxonNodeQueryResultComparator());
1232

  
1233
        List<TaxonNodeDto> list = new ArrayList<>();
1234
        for(SortableTaxonNodeQueryResult queryDTO : result){
1235
            TaxonNodeDto nodeDto = new TaxonNodeDto(queryDTO.getTaxonNodeUuid(), queryDTO.getTaxonNodeId(), queryDTO.getTaxonTitleCache(), queryDTO.getNameRank().getOrderIndex());
1236

  
1237
            list.add(nodeDto);
1238
        }
1239
        return list;
1240
    }
1241

  
1242
    @Override
1243
    public List<TaxonNodeDto> getTaxonNodeForTaxonInClassificationDto(UUID taxonUUID, UUID classificationUuid) {
1244
        String queryString = "SELECT new " + SortableTaxonNodeQueryResult.class.getName() + "("
1245
                + "tn.uuid, tn.id, t.titleCache, rank "
1246
                + ") "
1247
                + " FROM TaxonNode tn "
1248
                + "   INNER JOIN tn.taxon AS t "
1249
                + "   INNER JOIN tn.classification AS cls "
1250
                + "   INNER JOIN tn.taxon AS t "
1251
                + "   INNER JOIN t.name AS name "
1252
                + "   LEFT OUTER JOIN name.rank AS rank "
1253
//                + "   LEFT OUTER JOIN tn.taxon.name.rank AS rank "
1254
                + " WHERE t.uuid = :uuid ";
1255
        if(classificationUuid != null){
1256
            queryString += "AND cls.uuid = :classificationUuid";
1257
        }
1258

  
1259
        Query query =  getSession().createQuery(queryString);
1260

  
1261
        query.setParameter("uuid", taxonUUID);
1262
        if(classificationUuid != null){
1263
            query.setParameter("classificationUuid", classificationUuid);
1264
        }
1265

  
1266
        @SuppressWarnings("unchecked")
1267
        List<SortableTaxonNodeQueryResult> result = query.list();
1268
        Collections.sort(result, new SortableTaxonNodeQueryResultComparator());
1269

  
1270
        List<TaxonNodeDto> list = new ArrayList<>();
1271
        for(SortableTaxonNodeQueryResult queryDTO : result){
1272
            list.add(new TaxonNodeDto(queryDTO.getTaxonNodeUuid(), queryDTO.getTaxonNodeId(), queryDTO.getTaxonTitleCache(), queryDTO.getNameRank().getOrderIndex()));
1273
        }
1274
        return list;
1275
    }
1276

  
1277

  
1183 1278
    @Override
1184 1279
    public List<TaxonNodeDto> getUuidAndTitleCache(Integer limit, String pattern, UUID classificationUuid) {
1185 1280
        return getUuidAndTitleCache(limit, pattern, classificationUuid, false);
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/term/DefinedTermDaoImpl.java
11 11
import java.util.ArrayList;
12 12
import java.util.Collection;
13 13
import java.util.Enumeration;
14
import java.util.HashMap;
14 15
import java.util.Iterator;
15 16
import java.util.List;
16 17
import java.util.Locale;
18
import java.util.Map;
17 19
import java.util.Set;
18 20
import java.util.UUID;
19 21

  
......
792 794
        return list;
793 795
    }
794 796

  
797
    @Override
798
    public TermDto findByUUIDAsDto(UUID uuid) {
799
        String queryString = TermDto.getTermDtoSelect()
800
                + " where a.uuid like :uuid ";
801

  
802

  
803
        Query query =  getSession().createQuery(queryString);
804
        query.setParameter("uuid", uuid);
805

  
806

  
807
        @SuppressWarnings("unchecked")
808
        List<Object[]> result = query.list();
809

  
810
        List<TermDto> list = TermDto.termDtoListFrom(result);
811
        if (list.size()== 1){
812
            return list.get(0);
813
        }else{
814
            return null;
815
        }
816

  
817
    }
818

  
819

  
795 820
    @Override
796 821
    public Collection<TermDto> findByTypeAsDto(TermType termType) {
797 822
        if (termType == null){
......
834 859
    }
835 860

  
836 861
    @Override
837
    public List<TermDto> getSupportedStatesForFeature(UUID featureUuid){
838
        List<TermDto> list = new ArrayList<>();
839
        String supportedCategoriesQueryString = "SELECT cat.uuid "
840
                + "from DefinedTermBase t "
841
                + "join t.supportedCategoricalEnumerations as cat "
842
                + "where t.uuid = :featureUuid";
843
        Query supportedCategoriesQuery =  getSession().createQuery(supportedCategoriesQueryString);
844
        supportedCategoriesQuery.setParameter("featureUuid", featureUuid);
845
        @SuppressWarnings("unchecked")
846
		List<UUID> supportedCategories = supportedCategoriesQuery.list();
847
        if(supportedCategories.isEmpty()){
848
            return list;
849
        }
862
    public  Map<UUID, List<TermDto>> getSupportedStatesForFeature(Set<UUID> featureUuids){
863
        Map<UUID, List<TermDto>> map = new HashMap<>();
864
        for (UUID featureUuid: featureUuids){
865
            List<TermDto> list = new ArrayList<>();
866
            String supportedCategoriesQueryString = "SELECT cat.uuid "
867
                    + "from DefinedTermBase t "
868
                    + "join t.supportedCategoricalEnumerations as cat "
869
                    + "where t.uuid = :featureUuid";
870
            Query supportedCategoriesQuery =  getSession().createQuery(supportedCategoriesQueryString);
871
            supportedCategoriesQuery.setParameter("featureUuid", featureUuid);
872
            @SuppressWarnings("unchecked")
873
    		List<UUID> supportedCategories = supportedCategoriesQuery.list();
874
            if(supportedCategories.isEmpty()){
875
                map.put(featureUuid, list);
876
                continue;
877
            }
850 878

  
851
        String queryString = TermDto.getTermDtoSelect()
852
                + "where v.uuid in (:supportedCategories) "
853
                + "order by a.titleCache";
854
        Query query =  getSession().createQuery(queryString);
855
        query.setParameterList("supportedCategories", supportedCategories);
879
            String queryString = TermDto.getTermDtoSelect()
880
                    + "where v.uuid in (:supportedCategories) "
881
                    + "order by a.titleCache";
882
            Query query =  getSession().createQuery(queryString);
883
            query.setParameterList("supportedCategories", supportedCategories);
856 884

  
857
        @SuppressWarnings("unchecked")
858
        List<Object[]> result = query.list();
885
            @SuppressWarnings("unchecked")
886
            List<Object[]> result = query.list();
859 887

  
860
        list = TermDto.termDtoListFrom(result);
861
        return list;
888
            list = TermDto.termDtoListFrom(result);
889
            map.put(featureUuid, list);
890
        }
891
        return map;
862 892
    }
863 893

  
864 894
    @Override
......
919 949
        List<TermDto> list = FeatureDto.termDtoListFrom(result);
920 950
        return list;
921 951
    }
952

  
953
    @Override
954
    public TermDto getTermDto(UUID uuid) {
955
        String queryString = TermDto.getTermDtoSelect()
956
                + " where a.uuid = :uuid ";
957

  
958

  
959
        Query query =  getSession().createQuery(queryString);
960
        query.setParameter("uuid", uuid);
961

  
962

  
963

  
964
        @SuppressWarnings("unchecked")
965
        List<Object[]> result = query.list();
966
        TermDto dto = null;
967
        List<TermDto> dtoList = TermDto.termDtoListFrom(result);
968
        if (dtoList != null && !dtoList.isEmpty()){
969
            dto = dtoList.get(0);
970
        }
971
        return dto;
972
    }
922 973
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/term/TermNodeDaoImpl.java
6 6

  
7 7
package eu.etaxonomy.cdm.persistence.dao.hibernate.term;
8 8

  
9
import java.util.ArrayList;
9 10
import java.util.List;
10 11
import java.util.Set;
12
import java.util.UUID;
11 13

  
12 14
import org.hibernate.Criteria;
15
import org.hibernate.Query;
16
import org.hibernate.Session;
13 17
import org.hibernate.criterion.Restrictions;
14 18
import org.springframework.stereotype.Repository;
15 19

  
......
17 21
import eu.etaxonomy.cdm.model.term.TermType;
18 22
import eu.etaxonomy.cdm.persistence.dao.hibernate.common.VersionableDaoBase;
19 23
import eu.etaxonomy.cdm.persistence.dao.term.ITermNodeDao;
24
import eu.etaxonomy.cdm.persistence.dto.SortableTaxonNodeQueryResult;
25
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
20 26
import eu.etaxonomy.cdm.persistence.query.OrderHint;
21 27

  
22 28
/**
......
63 69
        return results;
64 70
	}
65 71

  
66

  
72
	@Override
73
	public List<UuidAndTitleCache<TermNode>> getUuidAndTitleCache(Integer limit, String pattern){
74
	    Session session = getSession();
75
        Query query = session.createQuery(
76

  
77
                "SELECT new " + SortableTaxonNodeQueryResult.class.getName() + "("
78
                + " uuid, id, titleCache "
79
                + ") "
80
                + " FROM TermNode node "
81
                + " JOIN DefinedTerm term ON node.term = term "
82
                + (pattern!=null?" WHERE term.titleCache LIKE :pattern":""));
83
        if(pattern!=null){
84
            pattern = pattern.replace("*", "%");
85
            pattern = pattern.replace("?", "_");
86
            pattern = pattern + "%";
87
            query.setParameter("pattern", pattern);
88
        }
89
        if (limit != null){
90
           query.setMaxResults(limit);
91
        }
92
        return getUuidAndTitleCache(query);
93
	}
94
	 protected List<UuidAndTitleCache<TermNode>> getUuidAndTitleCache(Query query){
95
	        List<UuidAndTitleCache<TermNode>> list = new ArrayList<>();
96
	        List<Object> result = query.list();
97

  
98
	        for(Object obj : result){
99
	            if (obj instanceof SortableTaxonNodeQueryResult) {
100
	                SortableTaxonNodeQueryResult stnqr = (SortableTaxonNodeQueryResult) obj;
101
	                list.add(new UuidAndTitleCache<>(stnqr.getTaxonNodeUuid(),stnqr.getTaxonNodeId(), stnqr.getTaxonTitleCache()));
102
	            }else{
103
	                Object[] object = (Object[])obj;
104
	                list.add(new UuidAndTitleCache<>((UUID) object[0],(Integer) object[1], (String) object[2]));
105
	            }
106
	        }
107
	        return list;
108
	    }
67 109

  
68 110
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/term/TermVocabularyDaoImpl.java
34 34
import eu.etaxonomy.cdm.model.view.AuditEvent;
35 35
import eu.etaxonomy.cdm.persistence.dao.hibernate.common.IdentifiableDaoBase;
36 36
import eu.etaxonomy.cdm.persistence.dao.term.ITermVocabularyDao;
37
import eu.etaxonomy.cdm.persistence.dto.CharacterDto;
37 38
import eu.etaxonomy.cdm.persistence.dto.FeatureDto;
38 39
import eu.etaxonomy.cdm.persistence.dto.TermCollectionDto;
39 40
import eu.etaxonomy.cdm.persistence.dto.TermDto;
......
307 308
    }
308 309

  
309 310
    @Override
310
    public Collection<TermDto> getTopLevelTerms(UUID vocabularyUuid, TermType type) {
311
    public List<TermDto> getTopLevelTerms(UUID vocabularyUuid, TermType type) {
311 312
        String queryString;
312 313
        if (type.equals(TermType.NamedArea)){
313 314
            queryString = TermDto.getTermDtoSelectNamedArea();
314 315
        }else if (type.equals(TermType.Feature) || type.isKindOf(TermType.Feature)){
315
            queryString = FeatureDto.getTermDtoSelect();
316
            if (type.equals(TermType.Character)){
317
                queryString = CharacterDto.getTermDtoSelect();
318
            }else{
319
                queryString = FeatureDto.getTermDtoSelect();
320
            }
316 321
        }else{
317 322
            queryString = TermDto.getTermDtoSelect();
318 323
        }
319 324
        queryString = queryString
320
                + "where v.uuid = :vocabularyUuid "
321
                + "and a.partOf is null "
322
                + "and a.kindOf is null";
325
                + " where v.uuid = :vocabularyUuid ";
326
//                + "and a.partOf is null "
327
//                + "and a.kindOf is null";
323 328
        Query query =  getSession().createQuery(queryString);
324 329
        query.setParameter("vocabularyUuid", vocabularyUuid);
325 330

  
......
327 332
        List<Object[]> result = query.list();
328 333
        List<TermDto> list = null;
329 334
        if (type.equals(TermType.Feature)|| type.isKindOf(TermType.Feature)){
330
            list = FeatureDto.termDtoListFrom(result);
335
            if (type.equals(TermType.Character)){
336
                list = CharacterDto.termDtoListFrom(result);
337
            }else{
338
                list = FeatureDto.termDtoListFrom(result);
339
            }
331 340
        }else{
332 341
            list = TermDto.termDtoListFrom(result);
333 342
        }
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/taxon/ITaxonNodeDao.java
185 185
    public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(
186 186
            Classification classification, Integer limit, String pattern, boolean searchForClassifications,
187 187
            boolean includeDoubtful);
188

  
189
    /**
190
     * @param taxonUUID
191
     * @param classificationUuid
192
     * @return
193
     */
194
    List<TaxonNodeDto> getTaxonNodeForTaxonInClassificationDto(UUID taxonUUID, UUID classificationUuid);
195

  
196
    /**
197
     * @param nodeUuid
198
     * @return
199
     */
200
    TaxonNodeDto getTaxonNodeDto(UUID nodeUuid);
201

  
202
    /**
203
     * @param nodeUuid
204
     * @return
205
     */
206
    List<TaxonNodeDto> getTaxonNodeDtos(List<UUID> nodeUuid);
188 207
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/term/IDefinedTermDao.java
12 12
import java.util.Enumeration;
13 13
import java.util.List;
14 14
import java.util.Locale;
15
import java.util.Map;
15 16
import java.util.Set;
16 17
import java.util.UUID;
17 18

  
......
220 221
     */
221 222
    public Collection<TermDto> getKindOfsAsDto(TermDto parentTerm);
222 223

  
224
    public TermDto getTermDto(UUID uuid);
225

  
223 226

  
224 227
    /**
225 228
     * Returns a collection of {@link TermDto}s that match the given search parameters.
......
239 242
    public Collection<TermDto> findByUriAsDto(URI uri, String termLabel, TermType termType);
240 243

  
241 244
    /**
242
     * Returns all states for all supportedCategoricalEnumeration of this categorical feature
243
     * @param featureUuid the feature which has to support categorical data
244
     * @return list of all supported states
245
     * Returns all states for all supportedCategoricalEnumeration of the categorical features
246
     * @param set of featureUuids the feature which has to support categorical data
247
     * @return map of lists of all supported states
245 248
     */
246
    public List<TermDto> getSupportedStatesForFeature(UUID featureUuid);
249
    public Map<UUID, List<TermDto>> getSupportedStatesForFeature(Set<UUID> featureUuids);
247 250

  
248 251
    public Collection<TermDto> findByUUIDsAsDto(List<UUID> uuidList);
249 252

  
......
253 256

  
254 257
    public Collection<TermDto> findFeatureByTitleAsDto(String pattern);
255 258

  
259
    public TermDto findByUUIDAsDto(UUID uuid);
260

  
256 261
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/term/ITermNodeDao.java
11 11
import eu.etaxonomy.cdm.model.term.TermNode;
12 12
import eu.etaxonomy.cdm.model.term.TermType;
13 13
import eu.etaxonomy.cdm.persistence.dao.common.IVersionableDao;
14
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
14 15
import eu.etaxonomy.cdm.persistence.query.OrderHint;
15 16

  
16 17
/**
......
29 30
    public List<TermNode> list(TermType termType, Integer limit, Integer start, List<OrderHint> orderHints,
30 31
            List<String> propertyPaths);
31 32

  
33
    /**
34
     * @param limit
35
     * @param pattern
36
     * @return
37
     */
38
    List<UuidAndTitleCache<TermNode>> getUuidAndTitleCache(Integer limit, String pattern);
39

  
32 40

  
33 41
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/term/ITermVocabularyDao.java
120 120
     * @param vocabularyUuid the id of the vocabulary
121 121
     * @return a collection of top level terms
122 122
     */
123
    public Collection<TermDto> getTopLevelTerms(UUID vocabularyUuid, TermType type);
123
    public List<TermDto> getTopLevelTerms(UUID vocabularyUuid, TermType type);
124 124

  
125 125
    /**
126 126
     * Loads all terms for the given vocabulary
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/CharacterDto.java
45 45
    private TermNodeDto ratioTo;
46 46

  
47 47
    public CharacterDto(UUID uuid, Set<Representation> representations, UUID partOfUuid, UUID kindOfUuid,
48
            UUID vocabularyUuid, Integer orderIndex, String idInVocabulary, Set<Representation> vocRepresentations,
48
            UUID vocabularyUuid, Integer orderIndex, String idInVocabulary, //Set<Representation> vocRepresentations,
49 49
            boolean isAvailableForTaxon, boolean isAvailableForTaxonName, boolean isAvailableForOccurrence,
50 50
            String titleCache, TermNodeDto structure, TermDto structureModifier, TermNodeDto property,
51 51
            TermDto propertyModifier, TermNodeDto ratioTo, boolean isSupportCategoricalData, boolean isSupportsQuantitativeData, Set<TermVocabularyDto> supportedCategoricalEnumerations, Set<TermVocabularyDto> recommendedModifierEnumeration,  Set<TermDto> recommendedMeasurementUnits,  Set<TermDto> recommendedStatisticalMeasures) {
52 52
        super(uuid, representations, partOfUuid, kindOfUuid, vocabularyUuid, orderIndex, idInVocabulary,
53
                vocRepresentations, isAvailableForTaxon, isAvailableForTaxonName, isAvailableForOccurrence, titleCache, isSupportCategoricalData, isSupportsQuantitativeData, supportedCategoricalEnumerations, recommendedModifierEnumeration, recommendedMeasurementUnits, recommendedStatisticalMeasures);
53
                isAvailableForTaxon, isAvailableForTaxonName, isAvailableForOccurrence, titleCache, isSupportCategoricalData, isSupportsQuantitativeData, supportedCategoricalEnumerations, recommendedModifierEnumeration, recommendedMeasurementUnits, recommendedStatisticalMeasures);
54 54
        this.structure = structure;
55 55
        this.structureModifier = structureModifier;
56 56
        this.property = property;
......
82 82
           recommendedMeasurementUnitsDtos.add(TermDto.fromTerm(term));
83 83
       }
84 84
       CharacterDto dto = new CharacterDto(character.getUuid(), character.getRepresentations(), character.getPartOf() != null? character.getPartOf().getUuid(): null, character.getKindOf() != null? character.getKindOf().getUuid(): null,
85
               voc != null? voc.getUuid(): null, null, character.getIdInVocabulary(), voc != null? voc.getRepresentations(): null, character.isAvailableForTaxon(), character.isAvailableForTaxonName(), character.isAvailableForOccurrence(), character.getTitleCache(),
85
               voc != null? voc.getUuid(): null, null, character.getIdInVocabulary(), character.isAvailableForTaxon(), character.isAvailableForTaxonName(), character.isAvailableForOccurrence(), character.getTitleCache(),
86 86
                       character.getStructure() !=null? TermNodeDto.fromNode(character.getStructure(), null): null, character.getStructureModifier() != null? TermDto.fromTerm(character.getStructureModifier()): null,
87 87
                                       character.getProperty() != null? TermNodeDto.fromNode(character.getProperty(), null): null, character.getPropertyModifier() != null? TermDto.fromTerm(character.getPropertyModifier()): null, character.getRatioToStructure() != null? TermNodeDto.fromNode(character.getRatioToStructure(), null): null,
88 88
                                               character.isSupportsCategoricalData(), character.isSupportsQuantitativeData(),supportedCategoricalDtos, recommendedModifierDtos, recommendedMeasurementUnitsDtos, recommendedStatisticalMeasuresDtos);
......
142 142
                + "v.uuid, "
143 143
//                + "a.orderIndex, "
144 144
                + "a.idInVocabulary, "
145
                + "voc_rep,  "
145
//                + "voc_rep,  "
146 146
                + "a.termType,  "
147 147
                + "a.uri,  "
148 148
                + "m,  "
......
192 192
                if(elements[1]!=null){
193 193
                    dtoMap.get(uuid).addRepresentation((Representation)elements[1]);
194 194
                }
195
                if(elements[6]!=null){
196
                    dtoMap.get(uuid).addVocRepresentation((Representation)elements[6]);
197
                }
198
                if(elements[9]!=null){
199
                    dtoMap.get(uuid).addMedia(((Media) elements[9]).getUuid());
195
//                if(elements[6]!=null){
196
//                    dtoMap.get(uuid).addVocRepresentation((Representation)elements[6]);
197
//                }
198
                if(elements[8]!=null){
199
                    dtoMap.get(uuid).addMedia(((Media) elements[8]).getUuid());
200 200
                }
201 201
            } else {
202 202
                // term representation
......
207 207
                }
208 208
                // term media
209 209
                Set<UUID> mediaUuids = new HashSet<>();
210
                if(elements[9] instanceof Media) {
211
                    mediaUuids.add(((Media) elements[9]).getUuid());
210
                if(elements[8] instanceof Media) {
211
                    mediaUuids.add(((Media) elements[8]).getUuid());
212 212
                }
213 213
                // voc representation
214
                Set<Representation> vocRepresentations = new HashSet<>();
215
                if(elements[6] instanceof Representation) {
216
                    vocRepresentations = new HashSet<Representation>(7);
217
                    vocRepresentations.add((Representation)elements[6]);
218
                }
214
//                Set<Representation> vocRepresentations = new HashSet<>();
215
//                if(elements[6] instanceof Representation) {
216
//                    vocRepresentations = new HashSet<Representation>(7);
217
//                    vocRepresentations.add((Representation)elements[6]);
218
//                }
219 219
                boolean isAvailableForTaxon = false;
220 220
                boolean isAvailableForTaxonName = false;
221 221
                boolean isAvailableForOccurrence = false;
222 222

  
223
                EnumSet<CdmClass> availableForString = (EnumSet<CdmClass>)elements[10];
223
                EnumSet<CdmClass> availableForString = (EnumSet<CdmClass>)elements[9];
224 224

  
225 225
                if (availableForString.contains(CdmClass.TAXON)){
226 226
                    isAvailableForTaxon = true;
......
234 234
                boolean isSupportsCategoricalData = false;
235 235
                boolean isSupportsQuantitativeData = false;
236 236

  
237
                EnumSet<CdmClass> supportsString = (EnumSet<CdmClass>)elements[12];
237
                EnumSet<CdmClass> supportsString = (EnumSet<CdmClass>)elements[11];
238 238

  
239 239
                if (supportsString.contains(CdmClass.CATEGORICAL_DATA)){
240 240
                    isSupportsCategoricalData = true;
......
243 243
                    isSupportsQuantitativeData = true;
244 244
                }
245 245

  
246
                Object o = elements[13];
246
                Object o = elements[12];
247 247
                Set<TermVocabularyDto> recommendedModifierDtos = new HashSet<>();
248 248
                if (o instanceof TermVocabulary){
249 249
                    recommendedModifierDtos.add(TermVocabularyDto.fromVocabulary((TermVocabulary)o));
......
258 258

  
259 259

  
260 260

  
261
                o = elements[14];
261
                o = elements[13];
262 262
                Set<TermDto> recommendedStatisticalMeasuresDtos = new HashSet<>();
263 263
                if (o instanceof StatisticalMeasure){
264 264
                    recommendedStatisticalMeasuresDtos.add(TermDto.fromTerm((StatisticalMeasure)o));
......
270 270
                        }
271 271
                    }
272 272
                }
273
                o =  elements[15];
273
                o =  elements[14];
274 274
                Set<TermVocabularyDto> supportedCategoricalDtos = new HashSet<>();
275 275
                if (o instanceof TermVocabulary){
276 276
                    supportedCategoricalDtos.add(TermVocabularyDto.fromVocabulary((TermVocabulary)o));
......
282 282
                }
283 283

  
284 284

  
285
                o = elements[16];
285
                o = elements[15];
286 286
                Set<TermDto> recommendedMeasurementUnitsDtos = new HashSet<>();
287 287
                if (o instanceof MeasurementUnit){
288 288
                    recommendedMeasurementUnitsDtos.add(TermDto.fromTerm((MeasurementUnit)o));
289 289
                }else if (o instanceof Set){
290
                    Set<MeasurementUnit> recommendedMeasurementUnits = (Set<MeasurementUnit>) elements[17];
290
                    Set<MeasurementUnit> recommendedMeasurementUnits = (Set<MeasurementUnit>) elements[15];
291 291
                    for (MeasurementUnit term: recommendedMeasurementUnits){
292 292
                        recommendedMeasurementUnitsDtos.add(TermDto.fromTerm(term));
293 293
                    }
294 294
                }
295 295

  
296
                o = elements[17];
296
                o = elements[16];
297 297
                TermNodeDto prop = null;
298 298
                if (o instanceof TermNode){
299 299
                    prop = TermNodeDto.fromNode((TermNode) o, TermTreeDto.fromTree((TermTree) ((TermNode)o).getGraph()));
300 300
                }
301 301

  
302
                o = elements[18];
302
                o = elements[17];
303 303
                TermNodeDto structure = null;
304 304
                if (o instanceof TermNode){
305 305
                    structure = TermNodeDto.fromNode((TermNode) o, TermTreeDto.fromTree((TermTree) ((TermNode)o).getGraph()));
306 306
                }
307 307

  
308
                o = elements[10];
308
                o = elements[9];
309 309
                TermNodeDto ratioTo = null;
310 310
                if (o instanceof TermNode){
311 311
                    ratioTo = TermNodeDto.fromNode((TermNode) o, TermTreeDto.fromTree((TermTree) ((TermNode)o).getGraph()));
......
320 320
                        (UUID)elements[4],
321 321
                        null,
322 322
                        (String)elements[5],
323
                        vocRepresentations,
323
//                        vocRepresentations,
324 324
                        isAvailableForTaxon,
325 325
                        isAvailableForTaxonName,
326 326
                        isAvailableForOccurrence,
327
                        (String)elements[11],structure, null, prop, null, ratioTo, isSupportsCategoricalData,
327
                        (String)elements[10],structure, null, prop, null, ratioTo, isSupportsCategoricalData,
328 328
//                        structure, structureModifier, prop, null, isSupportsCategoricalData,
329 329
                        isSupportsQuantitativeData,
330 330
                        supportedCategoricalDtos,
......
332 332
                        recommendedMeasurementUnitsDtos,
333 333
                        recommendedStatisticalMeasuresDtos)
334 334
                        ;
335
                termDto.setUri((URI)elements[8]);
335
                termDto.setUri((URI)elements[7]);
336 336
                termDto.setMedia(mediaUuids);
337 337

  
338 338

  
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/DescriptiveDataSetBaseDto.java
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.persistence.dto;
10

  
11
import java.io.Serializable;
12
import java.util.ArrayList;
13
import java.util.HashMap;
14
import java.util.HashSet;
15
import java.util.List;
16
import java.util.Map;
17
import java.util.Set;
18
import java.util.UUID;
19

  
20
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
21
import eu.etaxonomy.cdm.model.term.Representation;
22

  
23
/**
24
 * @author k.luther
25
 * @since Aug 31, 2021
26
 */
27
public class DescriptiveDataSetBaseDto implements Serializable{
28

  
29
    private static final long serialVersionUID = 7310069387512600745L;
30

  
31
    private UUID uuid;
32
    private Integer id;
33
    private String titleCache;
34
    private TermTreeDto descriptiveSystem;
35
    private Set<TaxonNodeDto> subTreeFilter;
36
    private Set<TermDto> geoFilter;
37

  
38
    private Set<Representation> representations = new HashSet<>();
39
    private String representation_L10n = null;
40
    private String representation_L10n_abbreviatedLabel = null;
41
    private String representation_L10n_text = null;
42

  
43
    private TermDto maxRank;
44
    private TermDto minRank;
45

  
46

  
47

  
48
    public DescriptiveDataSetBaseDto(UUID uuid, Integer id, String titleCache){
49
        this.uuid = uuid;
50
        this.id = id;
51
        this.titleCache = titleCache;
52
    }
53

  
54
    public UUID getUuid() {
55
        return uuid;
56
    }
57

  
58

  
59
    public void setUuid(UUID uuid) {
60
        this.uuid = uuid;
61
    }
62

  
63
    public Integer getId() {
64
        return id;
65
    }
66

  
67
    public void setId(Integer id) {
68
        this.id = id;
69
    }
70

  
71
    public String getTitleCache() {
72
        return titleCache;
73
    }
74

  
75
    public void setTitleCache(String titleCache) {
76
        this.titleCache = titleCache;
77
    }
78

  
79
    public TermTreeDto getDescriptiveSystem() {
80
        return descriptiveSystem;
81
    }
82

  
83
    public void setDescriptiveSystem(TermTreeDto descriptiveSystem) {
84
        this.descriptiveSystem = descriptiveSystem;
85
    }
86

  
87

  
88
    private void addRepresentation(Representation representation) {
89
        if (this.representations == null){
90
            this.representations = new HashSet<>();
91
        }
92
        this.representations.add(representation);
93

  
94
    }
95
    public TermDto getMaxRank() {
96
        return maxRank;
97
    }
98

  
99
    public void setMaxRank(TermDto minRank) {
100
        this.maxRank = minRank;
101
    }
102

  
103
    public TermDto getMinRank() {
104
        return minRank;
105
    }
106

  
107
    public void setMinRank(TermDto minRank) {
108
        this.minRank = minRank;
109
    }
110

  
111

  
112
    /** sql queries to get descriptive data set dto*/
113

  
114
    public static String getDescriptiveDataSetDtoSelect(){
115
        String[] result = createSqlParts();
116

  
117
        return result[0]+result[1]+result[2];
118
    }
119

  
120
    private static String[] createSqlParts() {
121
        String sqlSelectString = ""
122
                + "select a.uuid, "
123
                + "a.id, "
124
                + "a.titleCache, "
125
                + "r, "
126
                + "d.uuid, "
127
                + "minRank.uuid, "
128
//                + "minRank.representations, "
129
//                + "minRank.termType, "
130
//                + "minRank.orderIndex, "
131
//                + "minRank.idInVocabulary, "
132
//                + "minRank.titleCache, "
133
                + "maxRank.uuid ";
134
//                + "maxRank.representations, "
135
//                + "maxRank.termType, "
136
//                + "maxRank.orderIndex, "
137
//                + "maxRank.idInVocabulary, "
138
//                + "maxRank.titleCache ";
139
        //UUID uuid, Set<Representation> representations, TermType termType, UUID partOfUuid, UUID kindOfUuid,
140
       // UUID vocabularyUuid, Integer orderIndex, String idInVocabulary, String titleCache
141
        String sqlFromString =   " FROM DescriptiveDataSet as a ";
142

  
143
        String sqlJoinString =  " LEFT JOIN a.descriptiveSystem as d "
144
                + " LEFT JOIN a.representations AS r "
145
                + " LEFT JOIN a.minRank as minRank "
146
                + " LEFT JOIN a.maxRank as maxRank ";
147

  
148
        String[] result = new String[3];
149
        result[0] = sqlSelectString;
150
        result[1] = sqlFromString;
151
        result[2] = sqlJoinString;
152
        return result;
153
    }
154

  
155
    /**
156
     * @param result
157
     * @return
158
     */
159
    public static List<DescriptiveDataSetBaseDto> descriptiveDataSetBaseDtoListFrom(List<Object[]> results) {
160

  
161
            List<DescriptiveDataSetBaseDto> dtos = new ArrayList<>(); // list to ensure order
162
            // map to handle multiple representations/media/vocRepresentation because of LEFT JOIN
163
            Map<UUID, DescriptiveDataSetBaseDto> dtoMap = new HashMap<>(results.size());
164
            for (Object[] elements : results) {
165
                UUID uuid = (UUID)elements[0];
166
                Integer id = (Integer)elements[1];
167

  
168
                if(dtoMap.containsKey(uuid)){
169
                    // multiple results for one dataset -> multiple (voc) representation/media
170
                    if(elements[1]!=null){
171
                        dtoMap.get(uuid).addRepresentation((Representation)elements[1]);
172
                    }
173
                } else {
174
                    // dataset representation
175
                    Set<Representation> representations = new HashSet<>();
176
                    if(elements[1] instanceof Representation) {
177
                        representations = new HashSet<>(1);
178
                        representations.add((Representation)elements[1]);
179
                    }
180

  
181
                    DescriptiveDataSetBaseDto datasetDto = new DescriptiveDataSetBaseDto(
182
                            uuid,
183
                            id,
184
                            (String)elements[2]);
185

  
186
//                    TermDto minRank = new TermDto((UUID)elements[5], (Set<Representation>)elements[6], (TermType)elements[7], null, null, null, (Integer)elements[8], (String)elements[9], (String)elements[10]);
187
//                    TermDto maxRank = new TermDto((UUID)elements[11], (Set<Representation>)elements[12], (TermType)elements[13], null, null, null, (Integer)elements[14], (String)elements[15], (String)elements[16]);
188
//                    datasetDto.setMinRank(minRank);
189
//                    datasetDto.setMaxRank(maxRank);
190

  
191
                    dtoMap.put(uuid, datasetDto);
192
                    dtos.add(datasetDto);
193
                }
194
            }
195
            return dtos;
196
        }
197

  
198
    public static DescriptiveDataSetBaseDto fromDescriptiveDataSet(DescriptiveDataSet dataSet){
199
        DescriptiveDataSetBaseDto dto = new DescriptiveDataSetBaseDto(dataSet.getUuid(), dataSet.getId(), dataSet.getTitleCache());
200
        if (dataSet.getDescriptiveSystem() != null){
201
            dto.setDescriptiveSystem(TermTreeDto.fromTree(dataSet.getDescriptiveSystem()));
202
        }
203
        return dto;
204
    }
205

  
206
    public Set<TaxonNodeDto> getSubTreeFilter() {
207
        return subTreeFilter;
208
    }
209

  
210
    public void setSubTreeFilter(Set<TaxonNodeDto> subTreeFilter) {
211
        this.subTreeFilter = subTreeFilter;
212
    }
213

  
214
    public Set<TermDto> getGeoFilter() {
215
        return geoFilter;
216
    }
217

  
218
    public void setGeoFilter(Set<TermDto> geoFilter) {
219
        this.geoFilter = geoFilter;
220
    }
221

  
222

  
223
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/FeatureDto.java
49 49
    Set<TermVocabularyDto> recommendedModifierEnumeration = new HashSet<>();
50 50

  
51 51
    public FeatureDto(UUID uuid, Set<Representation> representations, UUID partOfUuid, UUID kindOfUuid,
52
            UUID vocabularyUuid, Integer orderIndex, String idInVocabulary, Set<Representation> vocRepresentations, boolean isAvailableForTaxon,
53
            boolean isAvailableForTaxonName, boolean isAvailableForOccurrence, String titleCache, boolean isSupportsCategoricalData, boolean isSupportsQuantitativeData,
52
            UUID vocabularyUuid, Integer orderIndex, String idInVocabulary, //Set<Representation> vocRepresentations,
53
            boolean isAvailableForTaxon, boolean isAvailableForTaxonName, boolean isAvailableForOccurrence, String titleCache, boolean isSupportsCategoricalData, boolean isSupportsQuantitativeData,
54 54
            Set<TermVocabularyDto> supportedCategoricalEnumerations, Set<TermVocabularyDto> recommendedModifierEnumeration,  Set<TermDto> recommendedMeasurementUnits,  Set<TermDto> recommendedStatisticalMeasures){
55 55
        super(uuid, representations, TermType.Feature, partOfUuid, kindOfUuid,
56
                vocabularyUuid, orderIndex, idInVocabulary, vocRepresentations, titleCache);
56
                vocabularyUuid, orderIndex, idInVocabulary, titleCache);
57 57
        this.isAvailableForOccurrence = isAvailableForOccurrence;
58 58
        this.isAvailableForTaxon = isAvailableForTaxon;
59 59
        this.isAvailableForTaxonName = isAvailableForTaxonName;
......
67 67
        this.recommendedModifierEnumeration = recommendedModifierEnumeration;
68 68
    }
69 69

  
70
    static public FeatureDto fromTerm(Feature term) {
71
        FeatureDto result = (FeatureDto) fromTerm(term, null, false);
70

  
71

  
72
    static public FeatureDto fromFeature(Feature term) {
73
        UUID partOfUuid = term.getPartOf() != null? term.getPartOf().getUuid(): null;
74
        UUID kindOfUuid = term.getKindOf() != null? term.getKindOf().getUuid(): null;
75
        UUID vocUuid =  term.getVocabulary() != null? term.getVocabulary().getUuid(): null;
76
        Set<TermVocabularyDto> supportedCategoricalEnumerations = new HashSet<>();
77
        for (TermVocabulary<State> stateVoc:term.getSupportedCategoricalEnumerations()){
78
            supportedCategoricalEnumerations.add(TermVocabularyDto.fromVocabulary(stateVoc));
79
        }
80

  
81
        Set<TermVocabularyDto> recommendedModifiers = new HashSet<>();
82
        for (TermVocabulary<DefinedTerm> modifier:term.getRecommendedModifierEnumeration()){
83
            recommendedModifiers.add(TermVocabularyDto.fromVocabulary(modifier));
84
        }
85

  
86
        Set<TermDto> recommendedMeasurementUnits= new HashSet<>();
87
        for (MeasurementUnit measurementUnit:term.getRecommendedMeasurementUnits()){
88
            recommendedMeasurementUnits.add(TermDto.fromTerm(measurementUnit));
89
        }
90

  
91
        Set<TermDto> recommendedStatisticalMeasures = new HashSet<>();
92
        for (StatisticalMeasure statMeasure:term.getRecommendedStatisticalMeasures()){
93
            recommendedStatisticalMeasures.add(TermDto.fromTerm(statMeasure));
94
        }
95

  
96
        FeatureDto result =  new FeatureDto(term.getUuid(), term.getRepresentations(), partOfUuid, kindOfUuid, vocUuid, null, term.getIdInVocabulary(), term.isAvailableForTaxon(), term.isAvailableForTaxonName(), term.isAvailableForOccurrence(),
97
                term.getTitleCache(),term.isSupportsCategoricalData(), term.isSupportsQuantitativeData(), supportedCategoricalEnumerations, recommendedModifiers, recommendedMeasurementUnits, recommendedStatisticalMeasures);
72 98
        result.isAvailableForOccurrence = term.isAvailableForOccurrence();
73 99
        result.isAvailableForTaxon = term.isAvailableForTaxon();
74 100
        result.isAvailableForTaxonName = term.isAvailableForTaxonName();
......
245 271
                + "v.uuid, "
246 272
                + "a.orderIndex, "
247 273
                + "a.idInVocabulary, "
248
                + "voc_rep,  "
274
//                + "voc_rep,  "
249 275
                + "a.termType,  "
250 276
                + "a.uri,  "
251 277
                + "m,  "
......
264 290
                + "LEFT JOIN a.media as m "
265 291
                + "LEFT JOIN a.representations AS r "
266 292
                + "LEFT JOIN a.vocabulary as v "
267
                + "LEFT JOIN v.representations as voc_rep "
293
//                + "LEFT JOIN v.representations as voc_rep "
268 294
                + "LEFT JOIN a.recommendedModifierEnumeration as recommendedModifierEnumeration "
269 295
                + "LEFT JOIN a.recommendedStatisticalMeasures as recommendedStatisticalMeasures "
270 296
                + "LEFT JOIN a.supportedCategoricalEnumerations as supportedCategoricalEnumerations "
......
290 316
                if(elements[1]!=null){
291 317
                    dtoMap.get(uuid).addRepresentation((Representation)elements[1]);
292 318
                }
293
                if(elements[7]!=null){
294
                    dtoMap.get(uuid).addVocRepresentation((Representation)elements[7]);
295
                }
296
                if(elements[10]!=null){
297
                    dtoMap.get(uuid).addMedia(((Media) elements[10]).getUuid());
319
//                if(elements[7]!=null){
320
//                    dtoMap.get(uuid).addVocRepresentation((Representation)elements[7]);
321
//                }
322
                if(elements[9]!=null){
323
                    dtoMap.get(uuid).addMedia(((Media) elements[9]).getUuid());
298 324
                }
299 325
            } else {
300 326
                // term representation
......
305 331
                }
306 332
                // term media
307 333
                Set<UUID> mediaUuids = new HashSet<>();
308
                if(elements[10] instanceof Media) {
309
                    mediaUuids.add(((Media) elements[10]).getUuid());
334
                if(elements[9] instanceof Media) {
335
                    mediaUuids.add(((Media) elements[9]).getUuid());
310 336
                }
311 337
                // voc representation
312
                Set<Representation> vocRepresentations = new HashSet<>();
313
                if(elements[7] instanceof Representation) {
314
                    vocRepresentations = new HashSet<Representation>(7);
315
                    vocRepresentations.add((Representation)elements[7]);
316
                }
338
//                Set<Representation> vocRepresentations = new HashSet<>();
339
//                if(elements[7] instanceof Representation) {
340
//                    vocRepresentations = new HashSet<Representation>(7);
341
//                    vocRepresentations.add((Representation)elements[7]);
342
//                }
317 343
                boolean isAvailableForTaxon = false;
318 344
                boolean isAvailableForTaxonName = false;
319 345
                boolean isAvailableForOccurrence = false;
320 346

  
321
                EnumSet<CdmClass> availableForString = (EnumSet<CdmClass>)elements[11];
347
                EnumSet<CdmClass> availableForString = (EnumSet<CdmClass>)elements[10];
322 348

  
323 349
                if (availableForString.contains(CdmClass.TAXON)){
324 350
                    isAvailableForTaxon = true;
......
332 358
                boolean isSupportsCategoricalData = false;
333 359
                boolean isSupportsQuantitativeData = false;
334 360

  
335
                EnumSet<CdmClass> supportsString = (EnumSet<CdmClass>)elements[13];
361
                EnumSet<CdmClass> supportsString = (EnumSet<CdmClass>)elements[12];
336 362

  
337 363
                if (supportsString.contains(CdmClass.CATEGORICAL_DATA)){
338 364
                    isSupportsCategoricalData = true;
......
341 367
                    isSupportsQuantitativeData = true;
342 368
                }
343 369

  
344
                Object o = elements[14];
370
                Object o = elements[13];
345 371
                Set<TermVocabularyDto> recommendedModifierDtos = new HashSet<>();
346 372
                if (o instanceof TermVocabulary){
347 373
                    recommendedModifierDtos.add(TermVocabularyDto.fromVocabulary((TermVocabulary)o));
......
356 382

  
357 383

  
358 384

  
359
                o = elements[15];
385
                o = elements[14];
360 386
                Set<TermDto> recommendedStatisticalMeasuresDtos = new HashSet<>();
361 387
                if (o instanceof StatisticalMeasure){
362 388
                    recommendedStatisticalMeasuresDtos.add(TermDto.fromTerm((StatisticalMeasure)o));
......
368 394
                        }
369 395
                    }
370 396
                }
371
                o =  elements[16];
397
                o =  elements[15];
372 398
                Set<TermVocabularyDto> supportedCategoricalDtos = new HashSet<>();
373 399
                if (o instanceof TermVocabulary){
374 400
                    supportedCategoricalDtos.add(TermVocabularyDto.fromVocabulary((TermVocabulary)o));
......
384 410
//                        supportedCategoricalDtos.add(TermVocabularyDto.fromVocabulary(voc));
385 411
//                    }
386 412
//                }
387
                o = elements[17];
413
                o = elements[16];
388 414
                Set<TermDto> recommendedMeasurementUnitsDtos = new HashSet<>();
389 415
                if (o instanceof MeasurementUnit){
390 416
                    recommendedMeasurementUnitsDtos.add(TermDto.fromTerm((MeasurementUnit)o));
391 417
                }else if (o instanceof Set){
392
                    Set<MeasurementUnit> recommendedMeasurementUnits = (Set<MeasurementUnit>) elements[17];
418
                    Set<MeasurementUnit> recommendedMeasurementUnits = (Set<MeasurementUnit>) elements[16];
393 419
                    for (MeasurementUnit term: recommendedMeasurementUnits){
394 420
                        recommendedMeasurementUnitsDtos.add(TermDto.fromTerm(term));
395 421
                    }
......
409 435
                        (UUID)elements[4],
410 436
                        (Integer)elements[5],
411 437
                        (String)elements[6],
412
                        vocRepresentations,
438
//                        vocRepresentations,
413 439
                        isAvailableForTaxon,
414 440
                        isAvailableForTaxonName,
415 441
                        isAvailableForOccurrence,
416
                        (String)elements[12],
442
                        (String)elements[11],
417 443
                        isSupportsCategoricalData,
418 444
                        isSupportsQuantitativeData,
419 445
                        supportedCategoricalDtos,
......
421 447
                        recommendedMeasurementUnitsDtos,
422 448
                        recommendedStatisticalMeasuresDtos)
423 449
                        ;
424
                termDto.setUri((URI)elements[9]);
450
                termDto.setUri((URI)elements[8]);
425 451
                termDto.setMedia(mediaUuids);
426 452

  
427 453

  
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/TaxonNodeDto.java
87 87
        super(uuid, id, titleCache);
88 88
    }
89 89

  
90
    public TaxonNodeDto(UUID uuid, Integer id, String titleCache, Integer rankOrderIndex) {
91
        super(uuid, id, titleCache);
92
        this.rankOrderIndex = rankOrderIndex;
93
    }
94

  
90 95
    public TaxonNodeDto(Class type, ITaxonTreeNode taxonTreeNode) {
91 96
        super(type, taxonTreeNode.getUuid(), taxonTreeNode.getId(), null);
92 97
        Taxon taxon = null;
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/TermCollectionDto.java
33 33
    private boolean containsDuplicates = false;
34 34
    private boolean isOrderRelevant;
35 35
    private boolean isFlat;
36
    private boolean isAllowModifications = true;
36 37

  
37 38
    public TermCollectionDto(UUID uuid, Set<Representation> representations, TermType termType, String titleCache, boolean isAllowDuplicate, boolean isOrderRelevant, boolean isFlat) {
38 39
        super(uuid, representations, titleCache);
......
138 139
                + "a.orderRelevant,"
139 140
                + "a.isFlat "
140 141

  
142

  
141 143
                + "FROM "+fromTable+" as a "
142 144
                + "LEFT JOIN a.representations AS r ";
145

  
143 146
    }
144 147

  
145 148

  
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/TermDto.java
45 45
    private String idInVocabulary = null;
46 46
    private Collection<TermDto> includes;
47 47
    private Collection<TermDto> generalizationOf;
48
    private Set<Representation> vocRepresentations = null;
49
    private String vocRepresentation_L10n = null;
50
    private String vocRepresentation_L10n_abbreviatedLabel = null;
48
//    this should be handled in vocabularyDto
49
//    private Set<Representation> vocRepresentations = null;
50
//    private String vocRepresentation_L10n = null;
51
//    private String vocRepresentation_L10n_abbreviatedLabel = null;
51 52
    private Collection<UUID> media = null;
52 53
    private NamedAreaLevel level = null;
53 54

  
54
    private TermDto(UUID uuid, Set<Representation> representations, TermType termType, UUID partOfUuid, UUID kindOfUuid,
55
            UUID vocabularyUuid, Integer orderIndex, String idInVocabulary, String titleCache) {
56
        this(uuid, representations, termType, partOfUuid, kindOfUuid, vocabularyUuid, orderIndex, idInVocabulary, null, titleCache);
57
    }
55
//    private TermDto(UUID uuid, Set<Representation> representations, TermType termType, UUID partOfUuid, UUID kindOfUuid,
56
//            UUID vocabularyUuid, Integer orderIndex, String idInVocabulary, String titleCache) {
57
//        this(uuid, representations, termType, partOfUuid, kindOfUuid, vocabularyUuid, orderIndex, idInVocabulary, titleCache);
58
//    }
58 59

  
59 60
    protected TermDto(UUID uuid, Set<Representation> representations, TermType termType, UUID partOfUuid, UUID kindOfUuid,
60
            UUID vocabularyUuid, Integer orderIndex, String idInVocabulary, Set<Representation> vocRepresentations, String titleCache) {
61
            UUID vocabularyUuid, Integer orderIndex, String idInVocabulary, String titleCache) {
61 62
        super(uuid, representations, titleCache);
62 63
        this.partOfUuid = partOfUuid;
63 64
        this.kindOfUuid = kindOfUuid;
64 65
        this.vocabularyUuid = vocabularyUuid;
65 66
        this.orderIndex = orderIndex;
66 67
        this.idInVocabulary = idInVocabulary;
67
        this.vocRepresentations = vocRepresentations;
68
//        this.vocRepresentations = vocRepresentations;
68 69
        setTermType(termType);
69 70
    }
70 71

  
......
122 123

  
123 124
    @Override
124 125
    public void localize(ITermRepresentation_L10n representation_L10n) {
125
        if(vocRepresentations!=null){
126
            representation_L10n.localize(vocRepresentations);
127
            if (representation_L10n.getLabel() != null) {
128
                setVocRepresentation_L10n(representation_L10n.getLabel());
129
            }
130
            if (representation_L10n.getAbbreviatedLabel() != null) {
131
                setVocRepresentation_L10n_abbreviatedLabel(representation_L10n.getAbbreviatedLabel());
132
            }
133
        }
126
//        if(vocRepresentations!=null){
127
//            representation_L10n.localize(vocRepresentations);
128
//            if (representation_L10n.getLabel() != null) {
129
//                setVocRepresentation_L10n(representation_L10n.getLabel());
130
//            }
131
//            if (representation_L10n.getAbbreviatedLabel() != null) {
132
//                setVocRepresentation_L10n_abbreviatedLabel(representation_L10n.getAbbreviatedLabel());
133
//            }
134
//        }
134 135
        super.localize(representation_L10n);
135 136
    }
136 137

  
137
    public void setVocRepresentation_L10n(String vocRepresentation_L10n) {
138
        this.vocRepresentation_L10n = vocRepresentation_L10n;
139
    }
140

  
138
//    public void setVocRepresentation_L10n(String vocRepresentation_L10n) {
139
//        this.vocRepresentation_L10n = vocRepresentation_L10n;
140
//    }
141
//
141 142
    public String getVocRepresentation_L10n() {
142
        return vocRepresentation_L10n;
143
        return vocabularyDto.getRepresentation_L10n();
143 144
    }
144

  
145
    public void setVocRepresentation_L10n_abbreviatedLabel(String vocRepresentation_L10n_abbreviatedLabel) {
146
        this.vocRepresentation_L10n_abbreviatedLabel = vocRepresentation_L10n_abbreviatedLabel;
147
    }
148

  
145
//
146
//    public void setVocRepresentation_L10n_abbreviatedLabel(String vocRepresentation_L10n_abbreviatedLabel) {
147
//        this.vocRepresentation_L10n_abbreviatedLabel = vocRepresentation_L10n_abbreviatedLabel;
148
//    }
149
//
149 150
    public String getVocRepresentation_L10n_abbreviatedLabel() {
150
        return vocRepresentation_L10n_abbreviatedLabel;
151
    }
152

  
153
    protected void addVocRepresentation(Representation vocRepresentation){
154
        this.vocRepresentations.add(vocRepresentation);
151
        return vocabularyDto.getRepresentation_L10n_abbreviatedLabel();
155 152
    }
153
//
154
//    protected void addVocRepresentation(Representation vocRepresentation){
155
//        this.vocRepresentations.add(vocRepresentation);
156
//    }
156 157

  
157 158
    public void setPartOfDto(TermDto partOfDto) {
158 159
        this.partOfDto = partOfDto;
......
266 267
                + "v.uuid, "
267 268
                + "a.orderIndex, "
268 269
                + "a.idInVocabulary, "
269
                + "voc_rep,  "
270
//                + "voc_rep,  "
270 271
                + "a.termType,  "
271 272
                + "a.uri,  "
272 273
                + "m,  "
......
278 279
                + "LEFT JOIN a.media as m "
279 280
                + "LEFT JOIN a.representations AS r "
280 281
                + "LEFT JOIN a.vocabulary as v "
281
                + "LEFT JOIN v.representations as voc_rep "
282
//                + "LEFT JOIN v.representations as voc_rep "
282 283
                ;
283 284

  
284 285
        String[] result = new String[3];
......
304 305
                if(elements[1]!=null){
305 306
                    dtoMap.get(uuid).addRepresentation((Representation)elements[1]);
306 307
                }
307
                if(elements[7]!=null){
308
                    dtoMap.get(uuid).addVocRepresentation((Representation)elements[7]);
309
                }
310
                if(elements[10]!=null){
311
                    dtoMap.get(uuid).addMedia(((Media) elements[10]).getUuid());
308
//                if(elements[7]!=null){
309
//                    dtoMap.get(uuid).addVocRepresentation((Representation)elements[7]);
310
//                }
311
                if(elements[9]!=null){
312
                    dtoMap.get(uuid).addMedia(((Media) elements[9]).getUuid());
312 313
                }
313 314
            } else {
314 315
                // term representation
......
319 320
                }
320 321
                // term media
321 322
                Set<UUID> mediaUuids = new HashSet<>();
322
                if(elements[10] instanceof Media) {
323
                    mediaUuids.add(((Media) elements[10]).getUuid());
323
                if(elements[9] instanceof Media) {
324
                    mediaUuids.add(((Media) elements[9]).getUuid());
324 325
                }
325 326
                // voc representation
326
                Set<Representation> vocRepresentations = new HashSet<>();
327
                if(elements[7] instanceof Representation) {
328
                    vocRepresentations = new HashSet<>(7);
329
                    vocRepresentations.add((Representation)elements[7]);
330
                }
327
//                Set<Representation> vocRepresentations = new HashSet<>();
328
//                if(elements[7] instanceof Representation) {
329
//                    vocRepresentations = new HashSet<>(7);
330
//                    vocRepresentations.add((Representation)elements[7]);
331
//                }
331 332
                TermDto termDto = new TermDto(
332 333
                        uuid,
333 334
                        representations,
334
                        (TermType)elements[8],
335
                        (TermType)elements[7],
335 336
                        (UUID)elements[2],
336 337
                        (UUID)elements[3],
337 338
                        (UUID)elements[4],
338 339
                        (Integer)elements[5],
339 340
                        (String)elements[6],
340
                        vocRepresentations,
341
                        (String)elements[11]);
342
                termDto.setUri((URI)elements[9]);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff