Beispiel #1
0
 @SuppressWarnings("unchecked")
 @Override
 public List<GeoObject> listByLayerIdWithTags(Long layerId) {
   List<GeoObject> objs =
       (List<GeoObject>)
           getCurrentSession()
               .createQuery(
                   ("Select o from GeoLayer l inner join l.geoObjects o left join fetch o.geoObjectProperties p left join fetch o.createdBy cb left join fetch o.changedBy chb where l.id = :layerId"))
               .setLong("layerId", layerId)
               .list();
   if (objs.size() == 0) return objs;
   List<GeoObjectTag> tags =
       getCurrentSession()
           .createQuery(
               "SELECT t from GeoObjectTag t join t.geoObject o join o.geoLayers l where l.id = :layerId")
           .setLong("layerId", layerId)
           .list();
   for (GeoObject obj : objs) {
     HashSet<GeoObjectTag> fetchedTags = new HashSet<GeoObjectTag>();
     for (GeoObjectTag tag : tags) {
       if (tag.getGeoObject().getId() == obj.getId()) {
         fetchedTags.add(tag);
       }
     }
     obj.setTags(fetchedTags);
   }
   return objs;
 }
Beispiel #2
0
  @SuppressWarnings("unchecked")
  @Override
  public List<GeoObject> listByLayerIdFromRevision(Long layerId, Long revId) {
    List<GeoObject> objs =
        (List<GeoObject>)
            getCurrentSession()
                .createSQLQuery(getResourceSQL("GeoObjectDao.listByLayerIdFromRevision"))
                .addEntity(GeoObject.class)
                .setLong("layerId", layerId)
                .setLong("revId", revId)
                .list();
    if (objs.size() == 0) return objs;

    List<GeoObjectTag> tags =
        getCurrentSession()
            .createQuery("from GeoObjectTag t where t.geoObject in :objs")
            .setParameterList("objs", objs)
            .list();
    for (GeoObject obj : objs) {
      HashSet<GeoObjectTag> fetchedTags = new HashSet<GeoObjectTag>();
      for (GeoObjectTag tag : tags) {
        if (tag.getGeoObject().getId() == obj.getId()) {
          fetchedTags.add(tag);
        }
      }
      obj.setTags(fetchedTags);
    }
    return objs;

    /*
    for(GeoObject obj : objs){
    	 List<GeoObjectTag> tags = getCurrentSession().createQuery("from GeoObjectTag t where t.geoObject = :obj").setEntity("obj", obj).list();
    	 obj.setTags(new HashSet<GeoObjectTag>(tags));
    }
    return objs;
    */
  }