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

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


        }
    }
   
    public void testPagedQuery(){
      // Add a couple of Products and associated Metadata
      Product testProduct = null;
      for(int i = 0; i < catPageSize + 1; i++){
        testProduct = Product.getDefaultFlatProduct("test" + i,
          "urn:oodt:GenericFile");
        testProduct.getProductType().setName("GenericFile");
        Reference ref = new Reference("file:///foo.txt", "file:///bar.txt", 100);
            Vector<Reference> references = new Vector<Reference>();
            references.add(ref);
            testProduct.setProductReferences(references);
        Metadata met = new Metadata();
        met.addMetadata("Filename", "tempProduct" + i);
        met.addMetadata("ProductStructure", "Flat");
        try {
                myCat.addProduct(testProduct);
                myCat.addMetadata(met, testProduct);
            } catch (Exception e) {
                e.printStackTrace();
                fail(e.getMessage());
            }
      }
     
      // Formulate a test query
      Query query = new Query();
      BooleanQueryCriteria bqc = new BooleanQueryCriteria();
      try{
        bqc.setOperator(BooleanQueryCriteria.AND);
      }catch (Exception e){
        e.printStackTrace();
            fail(e.getMessage());
      }
      TermQueryCriteria tqc = new TermQueryCriteria();
      tqc.setElementName("ProductStructure");
      tqc.setValue("Flat");
      try{
        bqc.addTerm(tqc);
      }catch (Exception e){
        e.printStackTrace();
            fail(e.getMessage());
      }
      tqc = new TermQueryCriteria();
      tqc.setElementName("Filename");
      tqc.setValue("tempProduct1");
      try{
        bqc.addTerm(tqc);
      }catch (Exception e){
        e.printStackTrace();
            fail(e.getMessage());
      }
      query.addCriterion(bqc);
     
      // Perform the query and validate results
      ProductPage page = null;
      try{
        page = myCat.pagedQuery(query, testProduct.getProductType(), 1);
      }catch (Exception e){
        e.printStackTrace();
            fail(e.getMessage());
      }
      assertEquals(page.getPageProducts().size(), 1);
View Full Code Here


      assertEquals(page.getPageNum(), 1);
      assertEquals(page.getTotalPages(), 1);
    }
 
    private static Product getTestProduct() {
        Product testProduct = Product.getDefaultFlatProduct("test",
                "urn:oodt:GenericFile");
        testProduct.getProductType().setName("GenericFile");

        // set references
        Reference ref = new Reference("file:///foo.txt", "file:///bar.txt", 100);
        Vector references = new Vector();
        references.add(ref);
        testProduct.setProductReferences(references);

        return testProduct;
    }
View Full Code Here

         return new XmlRpcFileManagerClient(new URL("http://localhost:9000"),
               false) {
            @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 ProductPage getLastPage(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

               false) {
            public FileTransferStatus getCurrentFileTransfer() {
               status = new FileTransferStatus();
               status.setFileRef(new Reference(ORIG_REF, DS_REF, FILE_SIZE));
               status.setBytesTransferred(BYTE_TRANS);
               Product parentProduct = new Product();
               parentProduct.setProductName(PRODUCT_NAME);
               status.setParentProduct(parentProduct);
               return status;
            }
         };
      }
View Full Code Here

        }

        assertNotNull(cache);
        assertEquals(1, cache.size());

        Product prod = null;
        try {
            prod = XmlRpcStructFactory.getProductFromXmlRpc(fm
                    .getProductByName("test.txt"));
        } catch (CatalogException e) {
            fail(e.getMessage());
        }
        assertTrue(cache.contains(prod.getProductId()));
    }
View Full Code Here

        // now make sure that the file is ingested
        try {
            XmlRpcFileManagerClient fmClient = new XmlRpcFileManagerClient(
                    new URL("http://localhost:" + FM_PORT));
            Product p = fmClient.getProductByName("test.txt");
            assertNotNull(p);
            assertEquals(Product.STATUS_RECEIVED, p.getTransferStatus());
            assertTrue(fmClient.hasProduct("test.txt"));
            fmClient = null;
        } catch (Exception e) {
            fail(e.getMessage());
        }
View Full Code Here

    System.setProperties(initialProperties);
  }

  public void testVersioner() {
    DirectoryProductVersioner versioner = new DirectoryProductVersioner();
    Product p = Product.getDefaultFlatProduct("test", "urn:oodt:GenericFile");
    p.setProductStructure(Product.STRUCTURE_HIERARCHICAL);
    p.getProductType().setProductRepositoryPath("file:///home/files");
    Reference r = new Reference("file:///tmp/dir1", null, 4L);
    Reference r2 = new Reference("file:///tmp/dir1/file1.txt", null, 20L);
    p.getProductReferences().add(r);
    p.getProductReferences().add(r2);
    Metadata met = new Metadata();
    met.addMetadata(CoreMetKeys.FILENAME, "dir1");
    try {
      versioner.createDataStoreReferences(p, met);
    } catch (Exception e) {
      e.printStackTrace();
      fail(e.getMessage());
    }

    assertNotNull(p.getProductReferences());
    assertEquals(2, p.getProductReferences().size());
    assertEquals("file:/home/files/dir1/", p.getProductReferences().get(0)
        .getDataStoreReference());
    assertEquals("file:/home/files/dir1/file1.txt", p.getProductReferences()
        .get(1).getDataStoreReference());

  }
View Full Code Here

   @Override
   public Product getProductById(String productId) {
      lastMethodCallDetails = new MethodCallDetails("getProductById",
            Lists.newArrayList((Object) productId));
      Product p = new Product();
      p.setProductId(productId);
      p.setProductName("TestProductName");
      p.setProductReferences(Lists.newArrayList(
            new Reference("file:/orig/file", "file:/ds/file", 3)));
      p.setProductStructure(Product.STRUCTURE_FLAT);
      p.setTransferStatus(Product.STATUS_RECEIVED);
      ProductType pt = new ProductType();
      pt.setName("TestProductType");
      p.setProductType(pt);
      return p;
   }
View Full Code Here

  public void tearDown() throws Exception {
    System.setProperties(initialProperties);
  }
 
  public void testVersioning(){
    Product product = new Product();
    ProductType type = new ProductType();
    type.setProductRepositoryPath(productRepoPath);
    product.setProductStructure(Product.STRUCTURE_FLAT);
    product.setProductType(type);
   
    Metadata metadata = new Metadata();
    metadata.addMetadata(SingleFileBasicVersioner.FILENAME_FIELD, "testfile.txt");
   
    Reference r = new Reference();
    r.setOrigReference(origFileRef);
   
    product.getProductReferences().add(r);
   
    SingleFileBasicVersioner versioner = new SingleFileBasicVersioner();
    try{
      versioner.createDataStoreReferences(product, metadata);
    }
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.