本文整理汇总了Java中org.apache.oodt.cas.filemgr.structs.Product.setProductReferences方法的典型用法代码示例。如果您正苦于以下问题:Java Product.setProductReferences方法的具体用法?Java Product.setProductReferences怎么用?Java Product.setProductReferences使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.oodt.cas.filemgr.structs.Product
的用法示例。
在下文中一共展示了Product.setProductReferences方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProductFromXmlRpc
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static Product getProductFromXmlRpc(Map<?, ?> productHash) {
Product product = new Product();
product.setProductId((String) productHash.get("id"));
product.setProductName((String) productHash.get("name"));
if (productHash.get("type") != null) {
product.setProductType(getProductTypeFromXmlRpc(
(Map<String, Object>) productHash.get("type")));
}
product.setProductStructure((String) productHash.get("structure"));
product.setTransferStatus((String) productHash.get("transferStatus"));
if (productHash.get("references") != null) {
product.setProductReferences(getReferencesFromXmlRpc(
(Vector<Map<String, Object>>) productHash
.get("references")));
}
if (productHash.get("rootReference") != null) {
product.setRootRef(getReferenceFromXmlRpc(
(Map<String, Object>) productHash.get("rootReference")));
}
return product;
}
示例2: execute
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
@Override
public void execute(ActionMessagePrinter printer)
throws CmdLineActionException {
try {
FileManagerClient fmClient = getClient();
dt.setFileManagerUrl(fmClient.getFileManagerUrl());
Product product;
if (productId != null) {
product = fmClient.getProductById(productId);
} else if (productName != null) {
product = fmClient.getProductByName(productName);
} else {
throw new Exception("Must specify either productId or productName");
}
if (product != null) {
product.setProductReferences(fmClient.getProductReferences(product));
dt.retrieveProduct(product, destination);
} else {
throw new Exception("Product was not found");
}
} catch (Exception e) {
throw new CmdLineActionException("Failed to retrieve files for product : " + e.getMessage(), e);
}
}
示例3: setUp
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
@Before
public void setUp() {
properties = new Properties();
properties.setProperty("org.apache.oodt.cas.filemgr.versioning.configuration.test_type",
"/[Year]/[Month]/[Day]/[Filename]");
versioner = new ConfigurableMetadataBasedFileVersioner(properties);
metadata = new Metadata();
metadata.addMetadata("Year", "2013");
metadata.addMetadata("Month", "03");
metadata.addMetadata("Day", "23");
metadata.addMetadata("Filename", "test.dat");
product = new Product();
product.setProductStructure(Product.STRUCTURE_FLAT);
ProductType pt = new ProductType();
pt.setProductRepositoryPath("file:/base/path");
pt.setName("TEST_TYPE");
product.setProductType(pt);
Reference ref = new Reference();
ref.setOrigReference("/path/to/file");
product.setProductReferences(Lists.newArrayList(ref));
}
示例4: getFilePath
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
public String getFilePath(Product prod) {
if (!isConnected())
return "N/A";
if (prod.getProductReferences() == null) {
prod.setProductReferences(safeGetProductReferences(prod));
}
if (prod.getProductReferences() == null
|| (prod.getProductReferences() != null
&& prod.getProductReferences().size() == 0)) {
return "N/A";
}
// get the first ref
Reference r = (Reference) prod.getProductReferences().get(0);
return safeGetFileFromUri(r.getDataStoreReference()).getAbsolutePath();
}
示例5: getClient
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
public FileManagerClient getClient() throws MalformedURLException,
ConnectionException {
return new DummyFileManagerClient(new URL("http://localhost:9000"),
false) {
public Product getProductByName(String name) {
Product p = new Product();
p.setProductId(PRODUCT_ID);
p.setProductName(name);
ProductType pt = new ProductType();
pt.setName(PRODUCT_TYPE_NAME);
p.setProductType(pt);
p.setProductStructure(PRODUCT_STRUCTURE);
p.setTransferStatus(PRODUCT_STATUS);
p.setRootRef(new Reference("file:/dummy/path", ROOT_REF, 2));
p.setProductReferences(Lists.newArrayList(new Reference(
ORIG_REF_1, DS_REF_1, FILE_SIZE_REF_1), new Reference(
ORIG_REF_2, DS_REF_2, FILE_SIZE_REF_2)));
return p;
}
};
}
示例6: getClient
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
public FileManagerClient getClient() throws MalformedURLException,
ConnectionException {
return new DummyFileManagerClient(new URL("http://localhost:9000"),
false) {
public Product getProductById(String productId) {
Product p = new Product();
p.setProductId(productId);
p.setProductName(PRODUCT_NAME);
ProductType pt = new ProductType();
pt.setName(PRODUCT_TYPE_NAME);
p.setProductType(pt);
p.setProductStructure(PRODUCT_STRUCTURE);
p.setTransferStatus(PRODUCT_STATUS);
p.setRootRef(new Reference("file:/dummy/path", ROOT_REF, 2));
p.setProductReferences(Lists.newArrayList(new Reference(
ORIG_REF_1, DS_REF_1, FILE_SIZE_REF_1), new Reference(
ORIG_REF_2, DS_REF_2, FILE_SIZE_REF_2)));
return p;
}
};
}
示例7: getProductById
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
@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;
}
示例8: getProductByName
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
@Override
public Product getProductByName(String productName) {
lastMethodCallDetails = new MethodCallDetails("getProductByName",
Lists.newArrayList((Object) productName));
Product p = new Product();
p.setProductId("TestProductId");
p.setProductName(productName);
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;
}
示例9: quickPrintProductHealth
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
private void quickPrintProductHealth() {
if (getFmUp()) {
System.out.println("Latest " + TOP_N_PRODUCTS + " products ingested:");
List prods = this.fm.safeGetTopNProducts(TOP_N_PRODUCTS);
if (prods != null && prods.size() > 0) {
for (Object prod : prods) {
Product p = (Product) prod;
p.setProductType(fm.safeGetProductTypeById(p.getProductType()
.getProductTypeId()));
p.setProductReferences(fm.safeGetProductReferences(p));
Metadata prodMet = fm.safeGetMetadata(p);
System.out.println(fm.getFilePath(p) + " at: "
+ prodMet.getMetadata("CAS." + PRODUCT_RECEVIED_TIME));
}
}
}
}
示例10: getProduct
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
/**
* Gets an HTTP response that represents a {@link Product} from the file
* manager.
* @param productId the ID of the product
* @return an HTTP response that represents a {@link Product} from the file
* manager
*/
@GET
@Path("product")
@Produces({"application/xml", "application/json", "application/atom+xml",
"application/rdf+xml", "application/rss+xml", "application/zip"})
public ProductResource getProduct(@QueryParam("productId") String productId)
{
if (productId == null || productId.trim().equals(""))
{
throw new BadRequestException("This URL requires a productId query "
+ "parameter with a product ID value, "
+ "e.g. /product?productId=1787a257-df87-11e2-8a2d-e3f6264e86c5");
}
try
{
FileManagerClient client = getContextClient();
// Find the product.
Product product = client.getProductById(productId);
product.setProductReferences(client.getProductReferences(product));
// Create the product resource, add the product data and return the
// resource as the HTTP response.
return new ProductResource(product, client.getMetadata(product),
product.getProductReferences(), getContextWorkingDir());
}
catch (Exception e)
{
String message = "Unable to find the requested resource.";
LOGGER.log(Level.FINE, message, e);
throw new NotFoundException(message + " " + e.getMessage());
}
}
示例11: testCreateProductZipFileFromHierarchicalProduct
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
public void testCreateProductZipFileFromHierarchicalProduct(){
//Data store reference needs absolute path to test data
String cwd=System.getProperty("user.dir");
Product product = new Product();
product.setProductId("TestProductId");
product.setProductName("TestProductName");
product.setProductReferences(Lists.newArrayList(
new Reference("file:///orig/data/", "file://" + cwd + "/src/test/resources/", 4096),
new Reference("file:///orig/data/test-file-1.txt", "file://" + cwd + "/src/test/resources/test-file-1.txt", 20),
new Reference("file:///orig/data/test-file-2.txt", "file://" + cwd + "/src/test/resources/test-file-2.txt", 20),
new Reference("file:///orig/data/test-file-3.txt", "file://" + cwd + "/src/test/resources/test-file-3.txt", 20)));
product.setProductStructure(Product.STRUCTURE_HIERARCHICAL);
product.setTransferStatus(Product.STATUS_RECEIVED);
ProductType pt = new ProductType();
pt.setName("TestProductType");
Metadata metadata = new Metadata();
String workingDirPath;
workingDir = Files.createTempDir();
workingDirPath = workingDir.getAbsolutePath();
workingDir.deleteOnExit();
String productZipFilePath = null;
try {
productZipFilePath = DataUtils.createProductZipFile(product, metadata, workingDirPath);
} catch (Exception e) {
fail(e.getMessage());
}
String zipFileName = product.getProductName() + ".zip";
assertEquals(productZipFilePath, workingDirPath + "/" + zipFileName);
}
示例12: moveProducts
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
public void moveProducts(ProductType type) throws CatalogException, URISyntaxException, DataTransferException {
// paginate through the product list
ProductPage page = fmgrClient.getFirstPage(type);
for (int i = 0; i < page.getTotalPages(); i++) {
if (page.getPageProducts() != null
&& page.getPageProducts().size() > 0) {
for (Product p : page.getPageProducts()) {
p.setProductReferences(fmgrClient.getProductReferences(p));
Metadata met = fmgrClient.getMetadata(p);
Reference r = ((Reference) p.getProductReferences().get(0));
String newLocPath = PathUtils.replaceEnvVariables(
this.pathSpec, met);
if (locationsMatch(r.getDataStoreReference(), newLocPath)) {
LOG.log(Level.INFO,
"Current and New locations match. " + p.getProductName() + " was not moved.");
continue;
}
LOG.log(Level.INFO, "Moving product: ["
+ p.getProductName() + "] from: ["
+ new File(new URI(r.getDataStoreReference()))
+ "] to: [" + newLocPath + "]");
long timeBefore = System.currentTimeMillis();
fmgrClient.moveProduct(p, newLocPath);
long timeAfter = System.currentTimeMillis();
double seconds = ((timeAfter - timeBefore) * 1.0) / DOUBLE;
LOG.log(Level.INFO, "Product: [" + p.getProductName()
+ "] move successful: took: [" + seconds
+ "] seconds");
}
if (!page.isLastPage()) {
page = fmgrClient.getNextPage(type, page);
}
}
}
}
示例13: removeFile
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
public boolean removeFile(String filePath) throws DataTransferException, IOException {
// TODO(bfoster): Clean this up so that it deletes by product not file.
Product product = new Product();
Reference r = new Reference();
r.setDataStoreReference(filePath);
product.setProductReferences(Lists.newArrayList(r));
dataTransfer.deleteProduct(product);
return true;
}
示例14: addProductReferences
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
@Override
public void addProductReferences(Product product) throws CatalogException {
Product ingestedProduct = products.get(product.getProductId());
List<Reference> references = ingestedProduct.getProductReferences();
if (references == null) {
references = Lists.newArrayList();
}
references.addAll(product.getProductReferences());
ingestedProduct.setProductReferences(references);
}
示例15: getTestProduct
import org.apache.oodt.cas.filemgr.structs.Product; //导入方法依赖的package包/类
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;
}