Package org.apache.oodt.cas.metadata

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


        }

    }

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

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

        try {
            Metadata retMet = myCat.getMetadata(testProduct);
            assertNotNull(retMet);
            assertTrue(retMet.containsKey(CoreMetKeys.PRODUCT_STRUCTURE));
            assertEquals(Product.STRUCTURE_FLAT, retMet
                    .getMetadata(CoreMetKeys.PRODUCT_STRUCTURE));
        } catch (CatalogException e) {
            fail(e.getMessage());
        }
View Full Code Here


        }

    }

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

        Product testProduct = getTestProduct();
        try {
            myCat.addProduct(testProduct);
            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) {
            e.printStackTrace();
            fail(e.getMessage());
        }
View Full Code Here

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

        return testProduct;
    }

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

        // Reset the System properties to initial values.
        System.setProperties(initialProperties);
    }

    private void doIngest() {
        Metadata prodMet = null;

        try {
            URL ingestUrl = this.getClass().getResource("/ingest");
            URL refUrl = this.getClass().getResource("/ingest/test.txt");
            URL metUrl = this.getClass().getResource("/ingest/test.txt.met");

            prodMet = new SerializableMetadata(new FileInputStream(
                new File(metUrl.getFile())));

            // now add the right file location
            prodMet.addMetadata(CoreMetKeys.FILE_LOCATION, new File(
                ingestUrl.getFile()).getCanonicalPath());
            ingester.ingest(new URL("http://localhost:" + FM_PORT), new File(
                refUrl.getFile()), prodMet);
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

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

    private RemoteSiteFile pFile;

    public RemoteFile(RemoteSiteFile pFile) {
        this.pFile = pFile;
        this.metadata = new Metadata();
        this.metadata.addMetadata(RETRIEVED_FROM_LOC, pFile.getPath());
        this.metadata.addMetadata(FILENAME, pFile.getName());
        this.metadata.addMetadata(DATA_PROVIDER, pFile.getSite().getURL().getHost());
    }
View Full Code Here

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

   @Override
   public Metadata getMetadata(Product p) {
      lastMethodCallDetails = new MethodCallDetails("getMetadata",
            Lists.newArrayList((Object) p));
      return new Metadata();
   }
View Full Code Here

      fmc = new XmlRpcFileManagerClient(new URL("http://localhost:" + FM_PORT));
    } catch (Exception e) {
      fail(e.getMessage());
    }

    Metadata met = null;
    try {
      met = fmc.getMetadata(fmc.getProductByName("test.txt"));
    } catch (CatalogException e) {
      e.printStackTrace();
      fail(e.getMessage());
    }

    assertNotNull(met);
    assertTrue(met.containsKey(ProductMetKeys.PRODUCT_ID));
    assertNotNull(met.getMetadata(ProductMetKeys.PRODUCT_ID));
    assertTrue(met.containsKey(ProductMetKeys.PRODUCT_NAME));
    assertNotNull(met.getMetadata(ProductMetKeys.PRODUCT_NAME));
    assertTrue(met.containsKey(ProductMetKeys.PRODUCT_STRUCTURE));
    assertEquals("Flat", met.getMetadata(ProductMetKeys.PRODUCT_STRUCTURE));
    assertTrue(met.containsKey(ProductMetKeys.PRODUCT_TRANSFER_STATUS));
    assertEquals(Product.STATUS_RECEIVED, met
        .getMetadata(ProductMetKeys.PRODUCT_TRANSFER_STATUS));

    assertTrue(met.containsKey(ProductMetKeys.PRODUCT_ORIG_REFS));
    assertTrue(met.containsKey(ProductMetKeys.PRODUCT_DATASTORE_REFS));
    assertTrue(met.containsKey(ProductMetKeys.PRODUCT_FILE_SIZES));
    assertTrue(met.containsKey(ProductMetKeys.PRODUCT_MIME_TYPES));

    assertEquals(1, met.getAllMetadata(ProductMetKeys.PRODUCT_ORIG_REFS).size());
    assertEquals(1, met.getAllMetadata(ProductMetKeys.PRODUCT_DATASTORE_REFS)
        .size());
    assertEquals(1, met.getAllMetadata(ProductMetKeys.PRODUCT_FILE_SIZES)
        .size());
    assertEquals(1, met.getAllMetadata(ProductMetKeys.PRODUCT_MIME_TYPES)
        .size());

    URL refUrl = this.getClass().getResource("/ingest/test.txt");

    String origPath = null;
    try {
      origPath = new File(refUrl.getFile()).getCanonicalPath();
    } catch (IOException e) {
      fail(e.getMessage());
    }
    assertEquals(origPath, met.getMetadata(ProductMetKeys.PRODUCT_ORIG_REFS));
    assertEquals("/tmp/test.txt/test.txt", met
        .getMetadata(ProductMetKeys.PRODUCT_DATASTORE_REFS));

    assertNotNull(met.getMetadata(ProductMetKeys.PRODUCT_FILE_SIZES));
    assertEquals("text/plain", met
        .getMetadata(ProductMetKeys.PRODUCT_MIME_TYPES));

    try {
      met = fmc.getReducedMetadata(fmc.getProductByName("test.txt"),
          Collections.EMPTY_LIST);
    } catch (CatalogException e) {
      e.printStackTrace();
      fail(e.getMessage());
    }

    assertNotNull(met);
    assertTrue(met.containsKey(ProductMetKeys.PRODUCT_ID));
    assertNotNull(met.getMetadata(ProductMetKeys.PRODUCT_ID));
    assertTrue(met.containsKey(ProductMetKeys.PRODUCT_NAME));
    assertNotNull(met.getMetadata(ProductMetKeys.PRODUCT_NAME));
    assertTrue(met.containsKey(ProductMetKeys.PRODUCT_STRUCTURE));
    assertEquals("Flat", met.getMetadata(ProductMetKeys.PRODUCT_STRUCTURE));
    assertTrue(met.containsKey(ProductMetKeys.PRODUCT_TRANSFER_STATUS));
    assertEquals(Product.STATUS_RECEIVED, met
        .getMetadata(ProductMetKeys.PRODUCT_TRANSFER_STATUS));

    assertTrue(met.containsKey(ProductMetKeys.PRODUCT_ORIG_REFS));
    assertTrue(met.containsKey(ProductMetKeys.PRODUCT_DATASTORE_REFS));
    assertTrue(met.containsKey(ProductMetKeys.PRODUCT_FILE_SIZES));
    assertTrue(met.containsKey(ProductMetKeys.PRODUCT_MIME_TYPES));

    assertEquals(1, met.getAllMetadata(ProductMetKeys.PRODUCT_ORIG_REFS).size());
    assertEquals(1, met.getAllMetadata(ProductMetKeys.PRODUCT_DATASTORE_REFS)
        .size());
    assertEquals(1, met.getAllMetadata(ProductMetKeys.PRODUCT_FILE_SIZES)
        .size());
    assertEquals(1, met.getAllMetadata(ProductMetKeys.PRODUCT_MIME_TYPES)
        .size());

    origPath = null;
    try {
      origPath = new File(refUrl.getFile()).getCanonicalPath();
    } catch (IOException e) {
      fail(e.getMessage());
    }
    assertEquals(origPath, met.getMetadata(ProductMetKeys.PRODUCT_ORIG_REFS));
    assertEquals("/tmp/test.txt/test.txt", met
        .getMetadata(ProductMetKeys.PRODUCT_DATASTORE_REFS));

    assertNotNull(met.getMetadata(ProductMetKeys.PRODUCT_FILE_SIZES));
    assertEquals("text/plain", met
        .getMetadata(ProductMetKeys.PRODUCT_MIME_TYPES));

  }
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.