Package org.apache.oodt.cas.filemgr.structs

Examples of org.apache.oodt.cas.filemgr.structs.Product


    public void testAddMetadata() {
        Metadata met = new Metadata();
        met.addMetadata("ProductStructure", Product.STRUCTURE_FLAT);

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

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


    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();
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
                .addCriterion(SqlParser
                        .parseSqlWhereClause("CAS.ProductName != 'TestFile3' AND (Filename == 'test-file-1.txt' OR Filename == 'test-file-2.txt') AND CAS.ProductName != 'TestFile2'"));
        System.out.println(query);
        List<String> productIds = myCat.query(query, testProduct
                .getProductType());
        System.out.println(productIds);
        assertEquals("[23]", productIds.toString());

        // perform second query
        query = new Query();
        query
                .addCriterion(SqlParser
                        .parseSqlWhereClause("Filename == 'test-file-1.txt' OR (Filename == 'test-file-2.txt' AND CAS.ProductName != 'TestFile2')"));
        System.out.println(query);
        productIds = myCat.query(query, testProduct.getProductType());
        System.out.println(productIds);
        assertEquals("[25, 23]", productIds.toString());

        // perform second query
        query = new Query();
        query
                .addCriterion(SqlParser
                        .parseSqlWhereClause("NominalDate == '2008-01-20' AND DataVersion >= '3.6' AND DataVersion <= '4.0'"));
        System.out.println(query);
        productIds = myCat.query(query, testProduct.getProductType());
        System.out.println(productIds);
        assertEquals("[24, 23]", productIds.toString());
    }
View Full Code Here

        }

    }

    private static Product getTestProduct() {
        Product testProduct = Product.getDefaultFlatProduct("test",
                "urn:oodt:GenericFile");
        testProduct.getProductType().setName("GenericFile");
        return testProduct;
    }
View Full Code Here

            public ProductPage getFirstPage(ProductType pt) {
               ProductPage pp = new ProductPage();
               pp.setPageNum(PAGE_NUM);
               pp.setTotalPages(TOTAL_PAGES);
               pp.setPageSize(PAGE_SIZE);
               Product p = new Product();
               p.setProductId(PRODUCT_ID);
               p.setProductName(PRODUCT_NAME);
               p.setProductType(pt);
               p.setProductStructure(PRODUCT_STRUCTURE);
               p.setTransferStatus(PRODUCT_STATUS);
               pp.setPageProducts(Lists.newArrayList(p));
               return pp;
            }
         };
      }
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());
View Full Code Here

    }

  }

  private static Product getTestProduct() {
    Product testProduct = Product.getDefaultFlatProduct("test",
        "urn:oodt:GenericFile");
    testProduct.getProductType().setName("GenericFile");
    return testProduct;
  }
View Full Code Here

            ConnectionException {
         return new XmlRpcFileManagerClient(new URL("http://localhost:9000"),
               false) {
            @Override
            public Product getProductById(String productId) {
               Product p = new Product();
               p.setProductId(productId);
               p.setProductName(PRODUCT_NAME);
               return p;
            }
            @Override
            public List<Reference> getProductReferences(Product product) {
               product.setProductReferences(Lists.newArrayList(new Reference(
View Full Code Here

            ConnectionException {
         return new XmlRpcFileManagerClient(new URL("http://localhost:9000"),
               false) {
            @Override
            public Product getProductById(String productId) {
               Product p = new Product();
               p.setProductId(productId);
               p.setProductName(PRODUCT_NAME);
               return p;
            }
            @Override
            public List<Reference> getProductReferences(Product product) {
               return null;
View Full Code Here

            fail(e.getMessage());
        }
    }

    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);
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.filemgr.structs.Product

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.