Package org.apache.oodt.cas.metadata

Examples of org.apache.oodt.cas.metadata.Metadata


        }

    }

    public void testRemoveMetadata() {
        Metadata met = new Metadata();
        met.addMetadata("Filename", "tempProduct");

        Product testProduct = getTestProduct();
        testProduct.setProductId("1"); // need to link metadata to prod

        try {
            myCat.addMetadata(met, testProduct);
        } catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
        }

        try {
            myCat.removeMetadata(met, testProduct);
        } catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
        }

        try {
            Metadata retMet = myCat.getMetadata(testProduct);
            String retValue = retMet.getMetadata("Filename");
            assertNull(retValue);
        } catch (CatalogException e) {
            fail(e.getMessage());
        }
    }
View Full Code Here


    public void testQuery() throws Exception {
        // ingest first file
        Product testProduct = getTestProduct();
        testProduct.setProductId("23");
        Metadata prodMet = new Metadata();
        URL ingestUrl = this.getClass().getResource(
            "/ingest");
        prodMet.addMetadata(CoreMetKeys.FILE_LOCATION, new File(
            ingestUrl.getFile()).getCanonicalPath());
        prodMet.addMetadata(CoreMetKeys.FILENAME, "test-file-1.txt");
        prodMet.addMetadata("CAS.ProductName", "TestFile1");
        prodMet.addMetadata(CoreMetKeys.PRODUCT_TYPE, "GenericFile");
        prodMet.addMetadata("NominalDate", "2008-01-20");
        prodMet.addMetadata("DataVersion", "3.6");
        myCat.addMetadata(prodMet, testProduct);

        // ingest second file
        testProduct.setProductId("24");
        prodMet.replaceMetadata(CoreMetKeys.FILENAME, "test-file-2.txt");
        prodMet.replaceMetadata("CAS.ProductName", "TestFile2");
        myCat.addMetadata(prodMet, testProduct);

        // ingest thrid file
        testProduct.setProductId("25");
        prodMet.replaceMetadata(CoreMetKeys.FILENAME, "test-file-2.txt");
        prodMet.replaceMetadata("CAS.ProductName", "TestFile3");
        prodMet.replaceMetadata("DataVersion", "4.6");
        myCat.addMetadata(prodMet, testProduct);

        // perform first query
        Query query = new Query();
        query
View Full Code Here

        testProduct.getProductType().setName("GenericFile");
        return testProduct;
    }

    private static Metadata getTestMetadata(String prodName) {
        Metadata met = new Metadata();
        met.addMetadata("CAS.ProductName", prodName);
        return met;
    }
View Full Code Here

      return new File(url.getFile()).getAbsolutePath();
  }

  public void testOrdering() {
    Product testProduct = getTestProduct();
    Metadata testMet = getTestMetadata("test");

    try {
      myCat.addProduct(testProduct);
      myCat.addMetadata(testMet, testProduct);
    } catch (Exception e) {
      e.printStackTrace();
      fail(e.getMessage());
    }

    Product retProduct;
    try {
      Metadata retMet = myCat.getMetadata(testProduct);
      assertNotNull(retMet);
      assertNotNull(retMet.getAllMetadata("CAS.ProductName"));
      assertEquals(3, retMet.getAllMetadata("CAS.ProductName").size());
      assertEquals("test", retMet.getAllMetadata("CAS.ProductName").get(0));
      assertEquals("test2", retMet.getAllMetadata("CAS.ProductName").get(1));
      assertEquals("test3", retMet.getAllMetadata("CAS.ProductName").get(2));
    } catch (Exception e) {
      fail(e.getMessage());
    }

  }
View Full Code Here

    testProduct.getProductType().setName("GenericFile");
    return testProduct;
  }

  private static Metadata getTestMetadata(String prodName) {
    Metadata met = new Metadata();
    met.addMetadata("CAS.ProductName", prodName);
    met.addMetadata("CAS.ProductName", prodName + "2");
    met.addMetadata("CAS.ProductName", prodName + "3");
    return met;
  }
View Full Code Here

            @Override
            public List<QueryResult> complexQuery(ComplexQuery complexQuery) {
               clientSetQuery = complexQuery;
               Product p = new Product();
               p.setProductId("TestProductId");
               Metadata m = new Metadata();
               m.addMetadata("Filename", TEST_FILENAME);
               QueryResult qr = new QueryResult(p, m);
               qr.setToStringFormat(complexQuery.getToStringResultFormat());
               return Lists.newArrayList(qr);
            }
         };
View Full Code Here

    public void testGetMetadata() throws CatalogException {
       Product product = getTestProduct();
       myCat.addProduct(product);
       myCat.addProductReferences(product);
       Metadata m = new Metadata();
       m.addMetadata(CoreMetKeys.FILE_LOCATION, Lists.newArrayList("/loc/1", "/loc/2"));
       myCat.addMetadata(m, product);
       Metadata rndTripMet = myCat.getMetadata(product);

       assertNotNull(rndTripMet);
       assertEquals(2, rndTripMet.getAllMetadata(CoreMetKeys.FILE_LOCATION).size());
       assertTrue(rndTripMet.getAllMetadata(CoreMetKeys.FILE_LOCATION).contains("/loc/1"));
       assertTrue(rndTripMet.getAllMetadata(CoreMetKeys.FILE_LOCATION).contains("/loc/2"));
    }
View Full Code Here

   
    public void testGetReducedMetadata() throws CatalogException {
       Product product = getTestProduct();
       myCat.addProduct(product);
       myCat.addProductReferences(product);
       Metadata m = new Metadata();
       m.addMetadata(CoreMetKeys.FILE_LOCATION, Lists.newArrayList("/loc/1", "/loc/2"));
       myCat.addMetadata(m, product);
       Metadata rndTripMet = myCat.getReducedMetadata(product,
             Lists.newArrayList(CoreMetKeys.FILE_LOCATION));

       assertNotNull(rndTripMet);
       assertEquals(2, rndTripMet.getAllMetadata(CoreMetKeys.FILE_LOCATION).size());
       assertTrue(rndTripMet.getAllMetadata(CoreMetKeys.FILE_LOCATION).contains("/loc/1"));
       assertTrue(rndTripMet.getAllMetadata(CoreMetKeys.FILE_LOCATION).contains("/loc/2"));
    }
View Full Code Here

    public void testGetReducedMetadataNull() throws CatalogException {
        Product p = getTestProduct();
        myCat.addProduct(p);
        myCat.addProductReferences(p);
        myCat.addMetadata(new Metadata(), p);

        // should not throw NPE here
        Metadata rndTripMet = myCat.getReducedMetadata(p, Lists.newArrayList(CoreMetKeys.FILENAME));

        assertNotNull(rndTripMet);
        // should return null if met key has no value
        assertNull(rndTripMet.getAllMetadata(CoreMetKeys.FILENAME));
    }
View Full Code Here

        // add catPageSize of the test Product
        // then add a product called "ShouldBeFirstForPage.txt"
        // make sure it's the first one on the 2nd page

        Product testProd = getTestProduct();
        Metadata met = getTestMetadata("test");

        for (int i = 0; i < this.catPageSize; i++) {
            try {
                myCat.addProduct(testProd);
                myCat.addMetadata(met, testProd);
            } catch (Exception e) {
                fail(e.getMessage());
            }
        }

        testProd.setProductName("ShouldBeFirstForPage.txt");
        met.replaceMetadata("CAS.ProdutName", "ShouldBeFirstForPage.txt");

        try {
            myCat.addProduct(testProd);
            myCat.addMetadata(met, testProd);
        } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.metadata.Metadata

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.