@Test public void getProductByDownloadableFilename () { fr.gael.dhus.database.object.Collection validCollection; fr.gael.dhus.database.object.Collection invalidCollection; Product product; validCollection = new Collection (); validCollection.setUUID ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa3"); validCollection.setName ("Japan"); invalidCollection = new Collection (); invalidCollection.setUUID ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4"); invalidCollection.setName ("China"); product = dao.getProductByDownloadableFilename("prod0",validCollection); Assert.assertNotNull(product); Assert.assertEquals(product.getId ().intValue(), 0); product = dao.getProductByDownloadableFilename("prod6",validCollection); Assert.assertNull(product); product = dao.getProductByDownloadableFilename("prod0",invalidCollection); Assert.assertNull (product); product = dao.getProductByDownloadableFilename("prod6",null); Assert.assertNotNull(product); Assert.assertEquals(product.getId ().intValue (), 6); product = dao.getProductByDownloadableFilename (null, null); Assert.assertNull (product); }
@SuppressWarnings ("unchecked") public Product getProductByDownloadableFilename (final String filename, final Collection collection) { List<Product>products=null; if (collection == null) { products = (List<Product>)find( "from Product where download.path LIKE '%" + filename + "' AND processed = true"); } else { products = (List<Product>)getHibernateTemplate ().find ( "select p from Collection c left outer join c.products p " + "where c=? AND" + " p.download.path LIKE ? AND" + " processed=true", collection, "%"+filename +"%"); } if ((products!=null) && (products.size ()>0)) return products.iterator ().next (); return null; }
ProductDao extends HibernateDao<Product, Long> { @SuppressWarnings ("unchecked") public Product getProductByDownloadableFilename (final String filename, final Collection collection) { List<Product>products=null; if (collection == null) { products = (List<Product>)find( "from Product where download.path LIKE '%" + filename + "' AND processed = true"); } else { products = (List<Product>)getHibernateTemplate ().find ( "select p from Collection c left outer join c.products p " + "where c=? AND" + " p.download.path LIKE ? AND" + " processed=true", collection, "%"+filename +"%"); } if ((products!=null) && (products.size ()>0)) return products.iterator ().next (); return null; } }
ProductDao extends HibernateDao<Product, Long> { @SuppressWarnings ("unchecked") public Product getProductByDownloadableFilename (final String filename, final Collection collection) { List<Product>products=null; if (collection == null) { products = (List<Product>)find( "from Product where download.path LIKE '%" + filename + "' AND processed = true"); } else { products = (List<Product>)getHibernateTemplate ().find ( "select p from Collection c left outer join c.products p " + "where c=? AND" + " p.download.path LIKE ? AND" + " processed=true", collection, "%"+filename +"%"); } if ((products!=null) && (products.size ()>0)) return products.iterator ().next (); return null; }  }
ProductDao extends HibernateDao<Product, Long> { @SuppressWarnings ("unchecked") public Product getProductByDownloadableFilename (final String filename, final Collection collection) { List<Product>products=null; if (collection == null) { products = (List<Product>)find( "from Product where download.path LIKE '%" + filename + "' AND processed = true"); } else { products = (List<Product>)getHibernateTemplate ().find ( "select p from Collection c left outer join c.products p " + "where c=? AND" + " p.download.path LIKE ? AND" + " processed=true", collection, "%"+filename +"%"); } if ((products!=null) && (products.size ()>0)) return products.iterator ().next (); return null; }  static int getMaxPageSize(); Product getProductByPath(final URL path); @Override List<Product> listCriteria(DetachedCriteria detached, int skip,
         int top); @SuppressWarnings ("unchecked") List<Product> read(List<Long>ids); boolean exists(URL url); @Override List<Product> scroll(String clauses, int skip, int n); Iterator<Product> scrollFiltered(String filter, final Long collection_id, int skip); int count(String filter, final String collection_uuid); @Override void deleteAll(); @Override void delete(Product product); void setIndexes(Product product, List<MetadataIndex>indexes); void setIndexes(Long id, List<MetadataIndex>indexes); Iterator<Product> getProductsByIngestionDate(Date max_date); Iterator<Product> getProductsLowerAccess(Date max_date); static String getPathFromProduct(Product product); static String getPathFromURL(URL product); @SuppressWarnings ("unchecked") List<Long> getAuthorizedProducts(String user_uuid); @SuppressWarnings ("unchecked") Product getProductByDownloadableFilename(final String filename,
         final Collection collection); Product getProductByUuid(String uuid); List<Product> getNoCollectionProducts(User user); List<Product> scrollUploadedProducts(final User user, final int skip,
      final int top); @SuppressWarnings ("unchecked") List<Product> getUploadedProducts(final User user); User getOwnerOfProduct(final Product product); boolean isAuthorized(final String user_uuid, final long product_id); Iterator<Product> getUnprocessedProducts(); Iterator<Product> getAllProducts(); Product getProductByIdentifier(String identifier); }
ProductDao extends HibernateDao<Product, Long> { @SuppressWarnings ("unchecked") public Product getProductByDownloadableFilename (final String filename, final Collection collection) { List<Product>products=null; if (collection == null) { products = (List<Product>)find( "from Product where download.path LIKE '%" + filename + "' AND processed = true"); } else { products = (List<Product>)getHibernateTemplate ().find ( "select p from Collection c left outer join c.products p " + "where c=? AND" + " p.download.path LIKE ? AND" + " processed=true", collection, "%"+filename +"%"); } if ((products!=null) && (products.size ()>0)) return products.iterator ().next (); return null; }  static int getMaxPageSize(); Product getProductByPath(final URL path); @Override List<Product> listCriteria(DetachedCriteria detached, int skip,
         int top); @SuppressWarnings ("unchecked") List<Product> read(List<Long>ids); boolean exists(URL url); @Override List<Product> scroll(String clauses, int skip, int n); Iterator<Product> scrollFiltered(String filter, final Long collection_id, int skip); int count(String filter, final String collection_uuid); @Override void deleteAll(); @Override void delete(Product product); void setIndexes(Product product, List<MetadataIndex>indexes); void setIndexes(Long id, List<MetadataIndex>indexes); Iterator<Product> getProductsByIngestionDate(Date max_date); Iterator<Product> getProductsLowerAccess(Date max_date); static String getPathFromProduct(Product product); static String getPathFromURL(URL product); @SuppressWarnings ("unchecked") List<Long> getAuthorizedProducts(String user_uuid); @SuppressWarnings ("unchecked") Product getProductByDownloadableFilename(final String filename,
         final Collection collection); Product getProductByUuid(String uuid); List<Product> getNoCollectionProducts(User user); List<Product> scrollUploadedProducts(final User user, final int skip,
      final int top); @SuppressWarnings ("unchecked") List<Product> getUploadedProducts(final User user); User getOwnerOfProduct(final Product product); boolean isAuthorized(final String user_uuid, final long product_id); Iterator<Product> getUnprocessedProducts(); Iterator<Product> getAllProducts(); Product getProductByIdentifier(String identifier);  }