Package org.apache.oodt.cas.catalog.page

Examples of org.apache.oodt.cas.catalog.page.TransactionReceipt


 
  public void testDataSourceCatalogIngestQueryAndDelete() throws CatalogServiceException, ParseException, TokenMgrError {
    //test ingest
    Metadata m = new Metadata();
    m.addMetadata("testkey1", "testval1");
    TransactionReceipt tr = cs.ingest(m);
    Vector<TransactionReceipt> receipts = new Vector<TransactionReceipt>();
    receipts.add(tr);
    List<TransactionalMetadata> metadatas = cs.getMetadata(receipts);
    assertEquals(metadatas.size(), 1);
    Metadata ingestedMetadata = metadatas.get(0).getMetadata();
    assertEquals(ingestedMetadata.getMetadata("testkey1"), "testval1");
    assertEquals(ingestedMetadata.getAllMetadata("testkey1").size(), 2);

    //test ingest update
    m.replaceMetadata(CatalogServiceLocal.CATALOG_SERVICE_TRANSACTION_ID_MET_KEY.toString(), tr.getTransactionId().toString());
    m.replaceMetadata(CatalogServiceLocal.ENABLE_UPDATE_MET_KEY, "true");
    tr = cs.ingest(m);
    receipts = new Vector<TransactionReceipt>();
    receipts.add(tr);
    metadatas = cs.getMetadata(receipts);
    assertEquals(metadatas.size(), 1);
    ingestedMetadata = metadatas.get(0).getMetadata();
    assertEquals(ingestedMetadata.getMetadata("testkey1"), "testval1");
    assertEquals(ingestedMetadata.getAllMetadata("testkey1").size(), 2);

    //test query using querypager
    QueryExpression qe = QueryParser.parseQueryExpression("testkey1 == 'testval1'");
    QueryPager pager = cs.query(qe);
    metadatas = cs.getNextPage(pager);
    assertEquals(metadatas.size(), 1);
    ingestedMetadata = metadatas.get(0).getMetadata();
    assertEquals(ingestedMetadata.getMetadata("testkey1"), "testval1");
    assertEquals(ingestedMetadata.getAllMetadata("testkey1").size(), 2);

    //test query using std paging
    qe = QueryParser.parseQueryExpression("testkey1 == 'testval1'");
    Page page = cs.getPage(new PageInfo(20, PageInfo.FIRST_PAGE), qe);
    metadatas = cs.getMetadata(page);
    assertEquals(metadatas.size(), 1);
    ingestedMetadata = metadatas.get(0).getMetadata();
    assertEquals(ingestedMetadata.getMetadata("testkey1"), "testval1");
    assertEquals(ingestedMetadata.getAllMetadata("testkey1").size(), 2);

    //test query using std paging with catalog restriction
    qe = QueryParser.parseQueryExpression("testkey1 == 'testval1'");
    page = cs.getPage(new PageInfo(20, PageInfo.FIRST_PAGE), qe, Collections.singleton("TestCatalog1"));
    metadatas = cs.getMetadata(page);
    assertEquals(metadatas.size(), 1);
    ingestedMetadata = metadatas.get(0).getMetadata();
    assertEquals(ingestedMetadata.getMetadata("testkey1"), "testval1");
    assertEquals(ingestedMetadata.getAllMetadata("testkey1").size(), 1);

    //test delete
    m = new Metadata();
    m.addMetadata(CatalogServiceLocal.CATALOG_SERVICE_TRANSACTION_ID_MET_KEY.toString(), tr.getTransactionId().toString());
    cs.delete(m);
    assertEquals(cs.getMetadata(Collections.singletonList(tr)).size(), 0);
  }
View Full Code Here


          }
        }else {
          LOG.log(Level.WARNING, "Ingest not permitted to catalog '" + catalog + "' -- skipping over catalog");
        }
      }
      return (catalogReceipts.size() > 0) ? new TransactionReceipt(catalogServiceTransactionId, catalogReceipts) : null;
    }catch (Exception e) {
      throw new CatalogServiceException("Error occured during Metadata ingest attempt : " + e.getMessage(), e);
    }
  }
View Full Code Here

           if (found == null)
             found = new Vector<CatalogReceipt>();
           found.add(catalogReceipt)
           existing.put(catalogServiceTransactionId, found);
         }else {
           returnList.add(new TransactionReceipt(null, Collections.singletonList(catalogReceipt)));
         }
       }
       for (TransactionId<?> transactionId : existing.keySet())
         returnList.add(new TransactionReceipt(transactionId, existing.get(transactionId)));
       return returnList;
    }catch (Exception e) {
      throw new CatalogServiceException(e.getMessage(), e);
    }
  }
View Full Code Here

    List<TransactionReceipt> indexedReceipts = new Vector<TransactionReceipt>();
    for (TransactionReceipt transactionReceipt : transactionReceipts) {
      try {
//        for (CatalogReceipt catalogReceipt : transactionReceipt.getCatalogReceipts()) {
          if (transactionReceipt.getTransactionId() == null)
            transactionReceipt = new TransactionReceipt(this.getCatalogServiceTransactionId(transactionReceipt.getCatalogReceipts().get(0), true), transactionReceipt.getCatalogReceipts());
//        }
        indexedReceipts.add(transactionReceipt);
      }catch(Exception e) {
        throw new CatalogServiceException(e.getMessage(), e);
      }
View Full Code Here

          else
            LOG.log(Level.WARNING, "Failed to get metadata for transaction ids for catalog '" + catalogReceipt.getCatalogId() + "' : " + e.getMessage(), e);
        }
      }
      if (metadata.getHashtable().keySet().size() > 0)
        metadataSet.add(new TransactionalMetadata(new TransactionReceipt(transactionReceipt.getTransactionId(), successfulCatalogReceipts), metadata));
    }
    return new Vector<TransactionalMetadata>(metadataSet);
  }
View Full Code Here

          else
            LOG.log(Level.WARNING, "Failed to get metadata for transaction ids for catalog '" + catalog.getId() + "' : " + e.getMessage(), e);
        }
      }
      if (metadata.getHashtable().keySet().size() > 0)
        metadataSet.add(new TransactionalMetadata(new TransactionReceipt(catalogServiceTransactionId, catalogReceipts), metadata));
    }
    return new Vector<TransactionalMetadata>(metadataSet);
  }
View Full Code Here

  public void testDataSourceCatalogIngestQueryAndDelete()
      throws CatalogServiceException, ParseException, TokenMgrError {
    // test ingest
    Metadata m = new Metadata();
    m.addMetadata("testkey1", "testval1");
    TransactionReceipt tr = cs.ingest(m);
    Vector<TransactionReceipt> receipts = new Vector<TransactionReceipt>();
    receipts.add(tr);
    List<TransactionalMetadata> metadatas = cs.getMetadata(receipts);
    assertEquals(metadatas.size(), 1);
    Metadata ingestedMetadata = metadatas.get(0).getMetadata();
    assertEquals(ingestedMetadata.getMetadata("testkey1"), "testval1");
    assertEquals(ingestedMetadata.getAllMetadata("testkey1").size(), 2);

    // test ingest update
    m.replaceMetadata(
        CatalogServiceLocal.CATALOG_SERVICE_TRANSACTION_ID_MET_KEY
            .toString(), tr.getTransactionId().toString());
    m.replaceMetadata(CatalogServiceLocal.ENABLE_UPDATE_MET_KEY, "true");
    tr = cs.ingest(m);
    receipts = new Vector<TransactionReceipt>();
    receipts.add(tr);
    metadatas = cs.getMetadata(receipts);
    assertEquals(metadatas.size(), 1);
    ingestedMetadata = metadatas.get(0).getMetadata();
    assertEquals(ingestedMetadata.getMetadata("testkey1"), "testval1");
    assertEquals(ingestedMetadata.getAllMetadata("testkey1").size(), 2);

    // test query using querypager
    QueryExpression qe = QueryParser
        .parseQueryExpression("testkey1 == 'testval1'");
    QueryPager pager = cs.query(qe);
    metadatas = cs.getNextPage(pager);
    assertEquals(metadatas.size(), 1);
    ingestedMetadata = metadatas.get(0).getMetadata();
    assertEquals(ingestedMetadata.getMetadata("testkey1"), "testval1");
    assertEquals(ingestedMetadata.getAllMetadata("testkey1").size(), 2);

    // test query using std paging
    qe = QueryParser.parseQueryExpression("testkey1 == 'testval1'");
    Page page = cs.getPage(new PageInfo(20, PageInfo.FIRST_PAGE), qe);
    metadatas = cs.getMetadata(page);
    assertEquals(metadatas.size(), 1);
    ingestedMetadata = metadatas.get(0).getMetadata();
    assertEquals(ingestedMetadata.getMetadata("testkey1"), "testval1");
    assertEquals(ingestedMetadata.getAllMetadata("testkey1").size(), 2);

    // test query using std paging with catalog restriction
    qe = QueryParser.parseQueryExpression("testkey1 == 'testval1'");
    page = cs.getPage(new PageInfo(20, PageInfo.FIRST_PAGE), qe,
        Collections.singleton("TestCatalog1"));
    metadatas = cs.getMetadata(page);
    assertEquals(metadatas.size(), 1);
    ingestedMetadata = metadatas.get(0).getMetadata();
    assertEquals(ingestedMetadata.getMetadata("testkey1"), "testval1");
    assertEquals(ingestedMetadata.getAllMetadata("testkey1").size(), 1);

    // test delete
    m = new Metadata();
    m.addMetadata(
        CatalogServiceLocal.CATALOG_SERVICE_TRANSACTION_ID_MET_KEY
            .toString(), tr.getTransactionId().toString());
    cs.delete(m);
    assertEquals(cs.getMetadata(Collections.singletonList(tr)).size(), 0);
  }
View Full Code Here

          }
        }else {
          LOG.log(Level.WARNING, "Ingest not permitted to catalog '" + catalog + "' -- skipping over catalog");
        }
      }
      return (catalogReceipts.size() > 0) ? new TransactionReceipt(catalogServiceTransactionId, catalogReceipts) : null;
    }catch (Exception e) {
      throw new CatalogServiceException("Error occured during Metadata ingest attempt : " + e.getMessage(), e);
    }
  }
View Full Code Here

           if (found == null)
             found = new Vector<CatalogReceipt>();
           found.add(catalogReceipt)
           existing.put(catalogServiceTransactionId, found);
         }else {
           returnList.add(new TransactionReceipt(null, Collections.singletonList(catalogReceipt)));
         }
       }
       for (TransactionId<?> transactionId : existing.keySet())
         returnList.add(new TransactionReceipt(transactionId, existing.get(transactionId)));
       return returnList;
    }catch (Exception e) {
      throw new CatalogServiceException(e.getMessage(), e);
    }
  }
View Full Code Here

    List<TransactionReceipt> indexedReceipts = new Vector<TransactionReceipt>();
    for (TransactionReceipt transactionReceipt : transactionReceipts) {
      try {
//        for (CatalogReceipt catalogReceipt : transactionReceipt.getCatalogReceipts()) {
          if (transactionReceipt.getTransactionId() == null)
            transactionReceipt = new TransactionReceipt(this.getCatalogServiceTransactionId(transactionReceipt.getCatalogReceipts().get(0), true), transactionReceipt.getCatalogReceipts());
//        }
        indexedReceipts.add(transactionReceipt);
      }catch(Exception e) {
        throw new CatalogServiceException(e.getMessage(), e);
      }
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.catalog.page.TransactionReceipt

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.