Project

General

Profile

Revision 75e3aef5

ID75e3aef5f2a567e2833c03f13194b062a5d58947
Parent 5915e0b2
Child 046b8cfb

Added by Katja Luther 10 months ago

ref #8815: add UuidAndTitleCache methods again in taxonnodeservice

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImpl.java
156 156
         return result.get(0).intValue ();
157 157
    }
158 158

  
159
    @Override
160
    public List<TaxonNodeDto> listChildNodesAsUuidAndTitleCache(TaxonNodeDto parent) {
161
        String queryString =
162
                  " SELECT tn.uuid, tn.id, t.titleCache "
163
                + " FROM TaxonNode tn "
164
                + "    INNER JOIN tn.taxon AS t "
165
                + " WHERE tn.parent.uuid = :parentId";
166

  
167
        Query query =  getSession().createQuery(queryString);
168
        query.setParameter("parentId", parent.getUuid());
169

  
170
        @SuppressWarnings("unchecked")
171
        List<Object[]> result = query.list();
172

  
173
        List<TaxonNodeDto> list = new ArrayList<>();
174
        for(Object[] object : result){
175
            list.add(new TaxonNodeDto((UUID) object[0],(Integer) object[1], (String) object[2]));
176
        }
177
        return list;
178
    }
159
//    @Override
160
//    public List<TaxonNodeDto> listChildNodesAsTaxonNodeDto(TaxonNodeDto parent) {
161
//        String queryString =
162
//                  " SELECT tn.uuid, tn.id, t.titleCache "
163
//                + " FROM TaxonNode tn "
164
//                + "    INNER JOIN tn.taxon AS t "
165
//                + " WHERE tn.parent.uuid = :parentId";
166
//
167
//        Query query =  getSession().createQuery(queryString);
168
//        query.setParameter("parentId", parent.getUuid());
169
//
170
//        @SuppressWarnings("unchecked")
171
//        List<Object[]> result = query.list();
172
//
173
//        List<TaxonNodeDto> list = new ArrayList<>();
174
//        for(Object[] object : result){
175
//            list.add(new TaxonNodeDto((UUID) object[0],(Integer) object[1], (String) object[2]));
176
//        }
177
//        return list;
178
//    }
179 179

  
180 180
    @Override
181 181
    public List<TaxonNodeDto> listChildNodesAsTaxonNodeDto(TaxonNodeDto parent) {
......
1014 1014
             return list;
1015 1015
         }
1016 1016
    }
1017
    @Override
1018
    public List<TaxonNodeDto> getTaxonNodeDto(Integer limit, String pattern, UUID classificationUuid) {
1019
        String queryString = "SELECT tn.uuid, tn.id, t.titleCache, t.name.rank "
1020
                + " FROM TaxonNode tn "
1021
                + "   INNER JOIN tn.taxon AS t "
1022
                + "   INNER JOIN tn.classification AS cls "
1023
                + "WHERE t.titleCache LIKE :pattern ";
1024
        if(classificationUuid != null){
1025
            queryString += "AND cls.uuid = :classificationUuid";
1026
        }
1027
        Query query =  getSession().createQuery(queryString);
1028

  
1029
        query.setParameter("pattern", pattern.toLowerCase()+"%");
1030
        query.setParameter("classificationUuid", classificationUuid);
1031

  
1032

  
1033
        @SuppressWarnings("unchecked")
1034
        List<Object[]> result = query.list();
1035
        Collections.sort(result, new UuidAndTitleCacheTaxonComparator());
1036

  
1037
        List<TaxonNodeDto> list = new ArrayList<>();
1038
        for(Object[] object : result){
1039
            list.add(new TaxonNodeDto((UUID) object[0],(Integer) object[1], (String) object[2]));
1040
        }
1041
        return list;
1042
    }
1043
    @Override
1044
    public List<UuidAndTitleCache<TaxonNode>> listChildNodesAsUuidAndTitleCache(UuidAndTitleCache<TaxonNode> parent) {
1045
        String queryString =
1046
                " SELECT tn.uuid, tn.id, t.titleCache "
1047
              + " FROM TaxonNode tn "
1048
              + "    INNER JOIN tn.taxon AS t "
1049
              + " WHERE tn.parent.uuid = :parentId";
1050

  
1051
      Query query =  getSession().createQuery(queryString);
1052
      query.setParameter("parentId", parent.getUuid());
1053

  
1054
      @SuppressWarnings("unchecked")
1055
      List<Object[]> result = query.list();
1056

  
1057
      List<UuidAndTitleCache<TaxonNode>> list = new ArrayList<>();
1058
      for(Object[] object : result){
1059
          list.add(new UuidAndTitleCache<>((UUID) object[0],(Integer) object[1], (String) object[2]));
1060
      }
1061
      return list;
1062
    }
1017 1063

  
1018 1064

  
1019 1065
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/taxon/ITaxonNodeDao.java
57 57
     * @return a list of UuidAndTitleCache objects that represent children of the
58 58
     * parent
59 59
     */
60
    public List<TaxonNodeDto> listChildNodesAsUuidAndTitleCache(TaxonNodeDto parent);
60
    //public List<TaxonNodeDto> listChildNodesAsUuidAndTitleCache(TaxonNodeDto parent);
61 61

  
62 62
    /**
63 63
     * Retrieves the parent node of the {@link TaxonNode} represented by the given {@link UuidAndTitleCache}.
......
232 232
     * @return
233 233
     */
234 234
    long count(Class<? extends TaxonNode> type, List<Restriction<?>> restrictions, boolean includePublished);
235
    /**
236
     * get taxonNodeDto of parent with given rank
237
     * @param classification
238
     * @param rank
239
     * @return
240
     */
235

  
241 236
	public TaxonNodeDto getParentTaxonNodeDtoForRank( Classification classification, Rank rank, TaxonName name);
242 237

  
238

  
239
    public List<TaxonNodeDto> getTaxonNodeDto(Integer limit, String pattern, UUID classificationUuid);
240

  
241

  
242
    public List<UuidAndTitleCache<TaxonNode>> listChildNodesAsUuidAndTitleCache(UuidAndTitleCache<TaxonNode> parent);
243

  
243 244
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ITaxonNodeService.java
74 74
     * @param classificationUuid if specified only nodes of this classification are retrieved
75 75
     * @return a list of matches
76 76
     */
77
	public List<TaxonNodeDto> getUuidAndTitleCache(Integer limit, String pattern, UUID classificationUuid);
77
	public List<TaxonNodeDto> getTaxonNodeDto(Integer limit, String pattern, UUID classificationUuid);
78 78

  
79 79
    /**
80 80
     * Retrieves the parent node of the child {@link TaxonNode}
......
273 273
            List<OrderHint> orderHints, List<String> propertyPaths, boolean includeUnpublished);
274 274

  
275 275
	public TaxonNodeDto taxonNodeDtoParentRank(Classification classification, Rank rank, TaxonName name);
276

  
277
    /**
278
     * Lists all direct child nodes of the given {@link ITaxonTreeNode}
279
     * @param parent the parent ITaxonTreeNode
280
     * @return a list of UuidAndTitleCache objects that represent children of the
281
     * parent
282
     */
283
	 public List<UuidAndTitleCache<TaxonNode>> listChildNodesAsUuidAndTitleCache(ITaxonTreeNode parent);
284
	 public List<TaxonNodeDto> getUuidAndTitleCache(Integer limit, String pattern, UUID classificationUuid);
285
	 public List<UuidAndTitleCache<TaxonNode>> listChildNodesAsUuidAndTitleCache(UuidAndTitleCache<TaxonNode> parent);
286

  
276 287
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonNodeServiceImpl.java
77 77
import eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonNodeDao;
78 78
import eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonNodeFilterDao;
79 79
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
80
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
80 81
import eu.etaxonomy.cdm.persistence.hibernate.permission.ICdmPermissionEvaluator;
81 82
import eu.etaxonomy.cdm.persistence.query.OrderHint;
82 83

  
......
1199 1200
        return getTaxonDistributionDTOForSubtree(parentNodeUuid, propertyPaths, null);
1200 1201
    }
1201 1202

  
1203
    @Override
1204
    public List<TaxonNodeDto> getTaxonNodeDto(Integer limit, String pattern, UUID classificationUuid) {
1205
        return dao.getTaxonNodeDto(limit, pattern, classificationUuid);
1206
    }
1207

  
1208
    @Override
1209
    public List<UuidAndTitleCache<TaxonNode>> listChildNodesAsUuidAndTitleCache(ITaxonTreeNode parent) {
1210
        UUID uuid = parent.getUuid();
1211
        int id = parent.getId();
1212
        UuidAndTitleCache<TaxonNode> uuidAndTitleCache = new UuidAndTitleCache<>(uuid, id, null);
1213
        return listChildNodesAsUuidAndTitleCache(uuidAndTitleCache);
1214
    }
1215

  
1216
    @Override
1217
    public List<UuidAndTitleCache<TaxonNode>> listChildNodesAsUuidAndTitleCache(UuidAndTitleCache<TaxonNode> parent) {
1218
        return dao.listChildNodesAsUuidAndTitleCache(parent);
1219
    }
1220

  
1202 1221

  
1203 1222
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)