示例#1
0
 public void testGetImagesAttachedToNodeOrAncestor() {
   Hashtable hash = new Hashtable();
   hash.put(ImageDAO.GROUP, "life");
   // hash.put(ImageDAO.SEARCH_ANCESTORS, new Boolean(true));
   List list = dao.getImagesMatchingCriteria(hash);
   System.out.println("number of images attached to life: " + list.size());
 }
示例#2
0
  public void testQuerying() {
    Hashtable hash = new Hashtable();
    hash.put(ImageDAO.IMAGE_ID, new Integer(1));
    testVampStellateResult(dao.getImagesMatchingCriteria(hash));
    hash.clear();
    hash.put(ImageDAO.FILENAME, "VampStellate17.jpg");
    testVampStellateResult(dao.getImagesMatchingCriteria(hash));
    hash.put(ImageDAO.IMAGE_ID, new Integer(1));
    testVampStellateResult(dao.getImagesMatchingCriteria(hash));
    // -- not sure what I was thinking here.  the way this used to work, it would return the image
    // regardless of the node name.
    // hash.remove(ImageDAO.IMAGE_ID);
    // hash.put(ImageDAO.GROUP, "XXXXXXXX");
    // testVampStellateResult(dao.getImagesMatchingCriteria(hash));
    hash.clear();
    hash.put(ImageDAO.GROUP, "Eukaryotes");
    testEukaryotesResult(dao.getImagesMatchingCriteria(hash));
    hash.put(ImageDAO.GROUP, "Eukarya");
    testEukaryotesResult(dao.getImagesMatchingCriteria(hash));
    hash.put(ImageDAO.GROUP, "eUKarya");
    testEukaryotesResult(dao.getImagesMatchingCriteria(hash));

    hash.clear();
    hash.put(ImageDAO.SCIENTIFIC_NAME, "Crinoidea");
    List list = dao.getImagesMatchingCriteria(hash);
    NodeImage img = (NodeImage) list.get(0);
    assertEquals(img.getId(), 8);
    // This image is set to use 0, so we shouldn't get any results
    hash.put(ImageDAO.IMAGE_USE, new Byte((byte) 0));
    list = dao.getImagesMatchingCriteria(hash);
    assertEquals(list.size(), 0);

    hash.clear();
    hash.put(ImageDAO.CONTRIBUTOR, david);
    list = dao.getImagesMatchingCriteria(hash);
    assertEquals(list.size(), 4);
    hash.put(ImageDAO.SCIENTIFIC_NAME, "Bembidion umbratum");
    list = dao.getImagesMatchingCriteria(hash);
    assertEquals(list.size(), 1);
    // This image is set to use 2, so we should get the same result
    hash.put(ImageDAO.IMAGE_USE, new Byte((byte) 0));
    list = dao.getImagesMatchingCriteria(hash);
    assertEquals(list.size(), 1);
    hash.clear();
    hash.put(ImageDAO.COPYOWNER_CONTRIBUTOR, david);
    list = dao.getImagesMatchingCriteria(hash);
    Iterator it = list.iterator();
    while (it.hasNext()) {
      img = (NodeImage) it.next();
      assertEquals(img.getCopyrightOwnerContributor().getId(), david.getId());
    }

    hash.clear();
    hash.put(ImageDAO.COPYOWNER, "David Maddison");
    list = dao.getImagesMatchingCriteria(hash);
    // This should match 10 imgs.  David is the copy owner contributor on 9, and his name is in the
    // copyright
    // owner field for 1 img.
    assertEquals(list.size(), 10);

    hash.clear();
    hash.put(ImageDAO.ANY_DATA, "arizona");
    list = dao.getImagesMatchingCriteria(hash);
    assertEquals(list.size(), 4);

    hash.clear();
    hash.put(ImageDAO.ANY_DATA, "ari");
    list = dao.getImagesMatchingCriteria(hash);
    assertEquals(list.size(), 8);
  }