Author: bfoster
Date: Fri Apr 1 15:23:24 2011
New Revision: 1087751
URL: http://svn.apache.org/viewvc?rev=1087751&view=rev
Log:
- updates to cas-catalog connection
--------------------------
Modified:
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/AbstractCatalog.java
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/Catalog.java
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/ColumnBasedDataSourceCatalog.java
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/ColumnBasedDataSourceCatalogFactory.java
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/catalogservice/CatalogServiceUtils.java
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/catalogservice/FilemgrCatalogIndex.java
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Product.java
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/ProductType.java
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java
Modified:
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/AbstractCatalog.java
URL:
http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/AbstractCatalog.java?rev=1087751&r1=1087750&r2=1087751&view=diff
==============================================================================
---
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/AbstractCatalog.java
(original)
+++
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/AbstractCatalog.java
Fri Apr 1 15:23:24 2011
@@ -40,11 +40,11 @@ public abstract class AbstractCatalog im
return productIds;
}
- public List<Metadata> getReducedMetadata(Query query, List<ProductType>
types, List<String> elements) throws CatalogException {
- List<Metadata> metadatas = new Vector<Metadata>();
- for (ProductType type : types)
- metadatas.addAll(this.getReducedMetadata(query, type,
elements));
- return metadatas;
- }
+// public List<Metadata> getReducedMetadata(Query query, List<ProductType>
types, List<String> elements) throws CatalogException {
+// List<Metadata> metadatas = new Vector<Metadata>();
+// for (ProductType type : types)
+// metadatas.addAll(this.getReducedMetadata(query, type,
elements));
+// return metadatas;
+// }
}
Modified:
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/Catalog.java
URL:
http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/Catalog.java?rev=1087751&r1=1087750&r2=1087751&view=diff
==============================================================================
---
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/Catalog.java
(original)
+++
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/Catalog.java
Fri Apr 1 15:23:24 2011
@@ -250,11 +250,11 @@ public interface Catalog extends Paginat
public Metadata getReducedMetadata(Product product, List<String> elements)
throws CatalogException;
- public List<Metadata> getReducedMetadata(Query query, ProductType type,
List<String> elements)
- throws CatalogException;
-
- public List<Metadata> getReducedMetadata(Query query, List<ProductType>
types, List<String> elements) throws CatalogException;
-
+// public List<Metadata> getReducedMetadata(Query query, ProductType type,
List<String> elements)
+// throws CatalogException;
+//
+// public List<Metadata> getReducedMetadata(Query query, List<ProductType>
types, List<String> elements) throws CatalogException;
+//
/**
* <p>
* Queries the Catalog with the specified {@link Query}
Modified:
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/ColumnBasedDataSourceCatalog.java
URL:
http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/ColumnBasedDataSourceCatalog.java?rev=1087751&r1=1087750&r2=1087751&view=diff
==============================================================================
---
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/ColumnBasedDataSourceCatalog.java
(original)
+++
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/ColumnBasedDataSourceCatalog.java
Fri Apr 1 15:23:24 2011
@@ -17,6 +17,7 @@
package org.apache.oodt.cas.filemgr.catalog;
//OODT imports
+import org.apache.oodt.cas.filemgr.repository.RepositoryManager;
import org.apache.oodt.cas.filemgr.structs.Element;
import org.apache.oodt.cas.filemgr.structs.Product;
import org.apache.oodt.cas.filemgr.structs.ProductPage;
@@ -28,6 +29,7 @@ import org.apache.oodt.cas.filemgr.util.
import org.apache.oodt.cas.filemgr.validation.ValidationLayer;
import org.apache.oodt.cas.metadata.Metadata;
import org.apache.oodt.commons.date.DateUtils;
+import org.apache.oodt.commons.util.DateConvert;
//JDK imports
import java.sql.Connection;
@@ -65,6 +67,7 @@ public class ColumnBasedDataSourceCatalo
/* our validation layer */
private ValidationLayer validationLayer = null;
+ RepositoryManager repositoryManager = null;
/* size of pages of products within the catalog */
protected int pageSize = -1;
@@ -82,9 +85,10 @@ public class ColumnBasedDataSourceCatalo
* </p>.
* @throws
*/
- public ColumnBasedDataSourceCatalog(DataSource ds, ValidationLayer
valLayer, int pageSize) {
+ public ColumnBasedDataSourceCatalog(DataSource ds, ValidationLayer
valLayer, RepositoryManager repositoryManager, int pageSize) {
this.dataSource = ds;
this.validationLayer = valLayer;
+ this.repositoryManager = repositoryManager;
this.pageSize = pageSize;
}
@@ -214,7 +218,8 @@ public class ColumnBasedDataSourceCatalo
try {
conn = dataSource.getConnection();
conn.setAutoCommit(false);
- statement = this.setDateFormats(conn.createStatement());
+// statement = this.setDateFormats(conn.createStatement());
+ statement = conn.createStatement();
Vector<String> queryTables = new Vector<String>();
queryTables.add(product.getProductType().getName() + "_METADATA");
@@ -328,7 +333,8 @@ public class ColumnBasedDataSourceCatalo
try {
conn = dataSource.getConnection();
conn.setAutoCommit(false);
- statement = this.setDateFormats(conn.createStatement());
+// statement = this.setDateFormats(conn.createStatement());
+ statement = conn.createStatement();
String modifyProductSql = "UPDATE products SET "
+ "ProductName = '" + product.getProductName()
@@ -373,7 +379,8 @@ public class ColumnBasedDataSourceCatalo
try {
conn = dataSource.getConnection();
conn.setAutoCommit(false);
- statement = this.setDateFormats(conn.createStatement());
+// statement = this.setDateFormats(conn.createStatement());
+ statement = conn.createStatement();
// first remove the refs
String deleteProductSql = "DELETE FROM "
@@ -441,7 +448,8 @@ public class ColumnBasedDataSourceCatalo
try {
conn = dataSource.getConnection();
conn.setAutoCommit(false);
- statement = this.setDateFormats(conn.createStatement());
+// statement = this.setDateFormats(conn.createStatement());
+ statement = conn.createStatement();
String deleteProductSql = "DELETE FROM products WHERE ProductId = "
+ product.getProductId();
@@ -494,7 +502,8 @@ public class ColumnBasedDataSourceCatalo
try {
conn = dataSource.getConnection();
conn.setAutoCommit(false);
- statement = this.setDateFormats(conn.createStatement());
+// statement = this.setDateFormats(conn.createStatement());
+ statement = conn.createStatement();
String modifyProductSql = "UPDATE products SET
ProductTransferStatus = '"
+ product.getTransferStatus()
@@ -537,7 +546,8 @@ public class ColumnBasedDataSourceCatalo
try {
conn = dataSource.getConnection();
conn.setAutoCommit(false);
- statement = this.setDateFormats(conn.createStatement());
+// statement = this.setDateFormats(conn.createStatement());
+ statement = conn.createStatement();
for (Reference reference : product.getProductReferences()) {
@@ -594,9 +604,10 @@ public class ColumnBasedDataSourceCatalo
try {
conn = dataSource.getConnection();
- statement = this.setDateFormats(conn.createStatement());
+// statement = this.setDateFormats(conn.createStatement());
+ statement = conn.createStatement();
- String getProductSql = "SELECT * " + "FROM products "
+ String getProductSql = "SELECT ProductId, ProductName,
ProductStructure, ProductType, ProductTransferStatus,
to_char(ProductReceivedTime, 'YYYY-MM-DD\"T\"HH24:MI:SS.FF3TZH:TZM') as
ProductReceivedTime FROM products "
+ "WHERE ProductId = " + productId;
LOG.log(Level.FINE, "getProductById: Executing: " + getProductSql);
@@ -610,6 +621,7 @@ public class ColumnBasedDataSourceCatalo
ProductType productType = new ProductType();
productType.setName(rs.getString("ProductType"));
product.setProductType(productType);
+
product.setProductReceivedTime(DateConvert.isoParse(rs.getString("ProductReceivedTime")));
product.setTransferStatus(rs.getString("ProductTransferStatus"));
return product;
}else {
@@ -647,9 +659,10 @@ public class ColumnBasedDataSourceCatalo
try {
conn = dataSource.getConnection();
- statement = this.setDateFormats(conn.createStatement());
+// statement = this.setDateFormats(conn.createStatement());
+ statement = conn.createStatement();
- String getProductSql = "SELECT * " + "FROM products "
+ String getProductSql = "SELECT ProductId, ProductName,
ProductStructure, ProductType, ProductTransferStatus,
to_char(ProductReceivedTime, 'YYYY-MM-DD\"T\"HH24:MI:SS.FF3TZH:TZM') as
ProductReceivedTime FROM products "
+ "WHERE ProductName = '" + productName + "'";
LOG.log(Level.FINE, "getProductByName: Executing: "
@@ -664,6 +677,7 @@ public class ColumnBasedDataSourceCatalo
ProductType productType = new ProductType();
productType.setName(rs.getString("ProductType"));
product.setProductType(productType);
+
product.setProductReceivedTime(DateConvert.isoParse(rs.getString("ProductReceivedTime")));
product.setTransferStatus(rs.getString("TransferStatus"));
return product;
}else {
@@ -700,7 +714,8 @@ public class ColumnBasedDataSourceCatalo
try {
conn = dataSource.getConnection();
- statement = this.setDateFormats(conn.createStatement());
+// statement = this.setDateFormats(conn.createStatement());
+ statement = conn.createStatement();
String getProductRefSql = "SELECT * FROM "
+ product.getProductType().getName() + "_reference"
@@ -753,9 +768,10 @@ public class ColumnBasedDataSourceCatalo
try {
conn = dataSource.getConnection();
- statement = this.setDateFormats(conn.createStatement());
+// statement = this.setDateFormats(conn.createStatement());
+ statement = conn.createStatement();
- String getProductSql = "SELECT * FROM products ORDER BY ProductId
DESC";
+ String getProductSql = "SELECT ProductId, ProductName,
ProductStructure, ProductType, ProductTransferStatus,
to_char(ProductReceivedTime, 'YYYY-MM-DD\"T\"HH24:MI:SS.FF3TZH:TZM') as
ProductReceivedTime FROM products ORDER BY ProductId DESC";
LOG.log(Level.FINE, "getProducts: Executing: " + getProductSql);
rs = statement.executeQuery(getProductSql);
@@ -769,7 +785,8 @@ public class ColumnBasedDataSourceCatalo
ProductType productType = new ProductType();
productType.setName(rs.getString("ProductType"));
product.setProductType(productType);
- product.setTransferStatus(rs.getString("TransferStatus"));
+
product.setProductReceivedTime(DateConvert.isoParse(rs.getString("ProductReceivedTime")));
+
product.setTransferStatus(rs.getString("ProductTransferStatus"));
products.add(product);
}
@@ -805,9 +822,10 @@ public class ColumnBasedDataSourceCatalo
try {
conn = dataSource.getConnection();
- statement = this.setDateFormats(conn.createStatement());
+// statement = this.setDateFormats(conn.createStatement());
+ statement = conn.createStatement();
- String getProductSql = "SELECT * FROM products WHERE ProductType =
'" + type.getName() + "'";
+ String getProductSql = "SELECT ProductId, ProductName,
ProductStructure, ProductType, ProductTransferStatus,
to_char(ProductReceivedTime, 'YYYY-MM-DD\"T\"HH24:MI:SS.FF3TZH:TZM') as
ProductReceivedTime FROM products WHERE ProductType = '" + type.getName() + "'";
LOG.log(Level.FINE, "getProductsByProductType: Executing: "
+ getProductSql);
@@ -822,7 +840,8 @@ public class ColumnBasedDataSourceCatalo
ProductType productType = new ProductType();
productType.setName(rs.getString("ProductType"));
product.setProductType(productType);
- product.setTransferStatus(rs.getString("TransferStatus"));
+
product.setProductReceivedTime(DateConvert.isoParse(rs.getString("ProductReceivedTime")));
+
product.setTransferStatus(rs.getString("ProductTransferStatus"));
products.add(product);
}
@@ -852,16 +871,18 @@ public class ColumnBasedDataSourceCatalo
try {
conn = dataSource.getConnection();
- statement = this.setDateFormats(conn.createStatement());
+// statement = this.setDateFormats(conn.createStatement());
+ statement = conn.createStatement();
- Metadata metadata = new Metadata();
-
+ Metadata metadata = new Metadata();
List<String> scalarElementNames = new Vector<String>();
-
+ List<String> scalarElementSelectValues = new Vector<String>();
+
List<Element> elements =
this.validationLayer.getElements(product.getProductType());
for (Element element : elements) {
if (!this.isVector(element)) {
-
scalarElementNames.add(this.isDate(this.getType(element))
+ scalarElementNames.add(element.getElementName());
+
scalarElementSelectValues.add(this.isDate(this.getType(element))
? "to_char(" +
element.getElementName()
+ ", '" +
this.getDateFormat(this.getType(element))
+ "') as " +
element.getElementName()
@@ -891,7 +912,7 @@ public class ColumnBasedDataSourceCatalo
}
}
- String metadataSql = "SELECT " +
StringUtils.join(scalarElementNames, ",") + " FROM "
+ String metadataSql = "SELECT " +
StringUtils.join(scalarElementSelectValues, ",") + " FROM "
+ product.getProductType().getName() + "_METADATA"
+ " WHERE ProductId = " + product.getProductId();
@@ -929,7 +950,8 @@ public class ColumnBasedDataSourceCatalo
try {
conn = dataSource.getConnection();
- statement = this.setDateFormats(conn.createStatement());
+// statement = this.setDateFormats(conn.createStatement());
+ statement = conn.createStatement();
Metadata metadata = new Metadata();
@@ -1036,7 +1058,7 @@ public class ColumnBasedDataSourceCatalo
String getMetadataSql = "SELECT DISTINCT(ProductId) AS
ProductId,ProductType FROM " + productType.getName() + "_VW";
// String getMetadataSql = "SELECT " +
StringUtils.join(selectElements, ",") + " FROM " +
StringUtils.join(queryTables, ",");
- if (query.getCriteria() != null)
+ if (query != null && query.getCriteria() != null &&
query.getCriteria().size() > 0)
getMetadataSql += " WHERE " +
SqlParser.getInfixCriteriaString(query.getCriteria()).replaceAll("==", "=");;
getMetadataSql += " ORDER BY ProductId DESC";
@@ -1046,9 +1068,7 @@ public class ColumnBasedDataSourceCatalo
while (rs.next()) {
Product p = new Product();
p.setProductId(rs.getString("ProductId"));
- ProductType pt = new ProductType();
- pt.setName(rs.getString("ProductType"));
- p.setProductType(pt);
+
p.setProductType(this.repositoryManager.getProductTypeByName(rs.getString("ProductType")));
metadatas.add(this.getMetadata(p));
}
@@ -1087,7 +1107,7 @@ public class ColumnBasedDataSourceCatalo
ResultSet.CONCUR_READ_ONLY));
String getProductSql = "SELECT DISTINCT(ProductId) AS ProductId
FROM " + type.getName() + "_VW";
- if (query.getCriteria() != null && query.getCriteria().size() >
0)
+ if (query != null && query.getCriteria() != null &&
query.getCriteria().size() > 0)
getProductSql += " WHERE " +
SqlParser.getInfixCriteriaString(query.getCriteria()).replaceAll("==", "=");
getProductSql += " ORDER BY ProductId DESC";
@@ -1144,7 +1164,7 @@ public class ColumnBasedDataSourceCatalo
statement = this.setDateFormats(conn.createStatement());
statement.setMaxRows(n);
- String getProductSql = "SELECT * FROM products WHERE ProductType =
'" + type.getName() + "' ORDER BY ProductReceivedTime DESC";
+ String getProductSql = "SELECT ProductId, ProductName,
ProductStructure, ProductType, ProductTransferStatus,
to_char(ProductReceivedTime, 'YYYY-MM-DD\"T\"HH24:MI:SS.FF3TZH:TZM') as
ProductReceivedTime FROM products WHERE ProductType = '" + type.getName() + "'
ORDER BY ProductId DESC";
LOG.log(Level.FINE, "getTopNProducts: executing: " +
getProductSql);
rs = statement.executeQuery(getProductSql);
@@ -1155,10 +1175,11 @@ public class ColumnBasedDataSourceCatalo
product.setProductId(rs.getString("ProductId"));
product.setProductName(rs.getString("ProductName"));
product.setProductStructure(rs.getString("ProductStructure"));
+
product.setProductReceivedTime(DateConvert.isoParse(rs.getString("ProductReceivedTime")));
ProductType productType = new ProductType();
productType.setName(rs.getString("ProductType"));
product.setProductType(productType);
- product.setTransferStatus(rs.getString("TransferStatus"));
+
product.setTransferStatus(rs.getString("ProductTransferStatus"));
products.add(product);
}
@@ -1331,8 +1352,9 @@ public class ColumnBasedDataSourceCatalo
ResultSet.CONCUR_READ_ONLY));
String getProductSql = "SELECT DISTINCT(ProductId) AS ProductId
FROM " + type.getName() + "_VW"
- + (query.getCriteria() != null ? " WHERE " +
SqlParser.getInfixCriteriaString(query.getCriteria()) : "")
+ + ((query != null && query.getCriteria() != null &&
query.getCriteria().size() > 0) ? " WHERE " +
SqlParser.getInfixCriteriaString(query.getCriteria()) : "")
+ " ORDER BY ProductId DESC";
+ LOG.log(Level.FINE, "executing pagedQuery: " + getProductSql);
rs = statement.executeQuery(getProductSql);
int rsSize = -1;
Modified:
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/ColumnBasedDataSourceCatalogFactory.java
URL:
http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/ColumnBasedDataSourceCatalogFactory.java?rev=1087751&r1=1087750&r2=1087751&view=diff
==============================================================================
---
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/ColumnBasedDataSourceCatalogFactory.java
(original)
+++
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/ColumnBasedDataSourceCatalogFactory.java
Fri Apr 1 15:23:24 2011
@@ -17,10 +17,7 @@
package org.apache.oodt.cas.filemgr.catalog;
//OODT imports
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
+import org.apache.oodt.cas.filemgr.repository.RepositoryManager;
import org.apache.oodt.cas.filemgr.util.GenericFileManagerObjectFactory;
import org.apache.oodt.cas.filemgr.validation.ValidationLayer;
import org.apache.oodt.cas.metadata.util.PathUtils;
@@ -44,7 +41,8 @@ public class ColumnBasedDataSourceCatalo
/* our validation layer */
protected ValidationLayer validationLayer = null;
-
+ protected RepositoryManager repositoryManager = null;
+
/*
* page size: size of the pages used by the catalog to paginate products
* back to the user
@@ -57,6 +55,7 @@ public class ColumnBasedDataSourceCatalo
protected String driver;
protected String validationLayerFactoryClass;
+ protected String repositoryManagerFactoryClass;
/**
*
@@ -78,13 +77,13 @@ public class ColumnBasedDataSourceCatalo
.replaceEnvVariables(System
.getProperty("org.apache.oodt.cas.filemgr.catalog.column.based.datasource.jdbc.driver",
"some_driver_class"));
- String dbIntTypes = PathUtils
- .replaceEnvVariables(System
-
.getProperty("org.apache.oodt.cas.filemgr.catalog.column.based.datasource.db.int.types"));
-
validationLayerFactoryClass = System
.getProperty("filemgr.validationLayer.factory",
"org.apache.oodt.cas.filemgr.validation.DataSourceValidationLayerFactory");
+
+ repositoryManagerFactoryClass = System
+ .getProperty("filemgr.repository.factory",
+
"org.apache.oodt.cas.filemgr.repository.DataSourceRepositoryManagerFactory");
pageSize = Integer
.getInteger(
@@ -151,6 +150,10 @@ public class ColumnBasedDataSourceCatalo
this.validationLayer = validationLayer;
}
+ public void setRepositoryManager(RepositoryManager repositoryManager) {
+ this.repositoryManager = repositoryManager;
+ }
+
/*
* (non-Javadoc)
*
@@ -159,9 +162,11 @@ public class ColumnBasedDataSourceCatalo
public Catalog createCatalog() {
if (this.validationLayer == null)
this.validationLayer =
GenericFileManagerObjectFactory.getValidationLayerFromFactory(validationLayerFactoryClass);
+ if (this.repositoryManager == null)
+ this.repositoryManager =
GenericFileManagerObjectFactory.getRepositoryManagerServiceFromFactory(repositoryManagerFactoryClass);
if (this.ds == null)
this.ds =
DatabaseConnectionBuilder.buildDataSource(user, pass,driver, jdbcUrl);
- return new ColumnBasedDataSourceCatalog(this.ds, validationLayer,
pageSize);
+ return new ColumnBasedDataSourceCatalog(this.ds, validationLayer,
this.repositoryManager, pageSize);
}
}
Modified:
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/catalogservice/CatalogServiceUtils.java
URL:
http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/catalogservice/CatalogServiceUtils.java?rev=1087751&r1=1087750&r2=1087751&view=diff
==============================================================================
---
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/catalogservice/CatalogServiceUtils.java
(original)
+++
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/catalogservice/CatalogServiceUtils.java
Fri Apr 1 15:23:24 2011
@@ -44,8 +44,10 @@ import org.apache.oodt.cas.filemgr.struc
import org.apache.oodt.cas.filemgr.structs.mime.MimeType;
import org.apache.oodt.cas.filemgr.structs.mime.MimeTypeException;
import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.commons.util.DateConvert;
//JDK imports
+import java.text.ParseException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
@@ -88,14 +90,14 @@ public class CatalogServiceUtils {
return comparisonQueryExpression;
}
- public static List<Product> asProducts(List<TransactionalMetadata>
transactionalMetadataList, List<ProductType> supportedProductTypes) throws
NumberFormatException, MimeTypeException {
+ public static List<Product> asProducts(List<TransactionalMetadata>
transactionalMetadataList, List<ProductType> supportedProductTypes) throws
NumberFormatException, MimeTypeException, ParseException {
List<Product> products = new Vector<Product>();
for (TransactionalMetadata transactionalMetadata :
transactionalMetadataList)
products.add(asProduct(transactionalMetadata,
supportedProductTypes));
return products;
}
- public static Product asProduct(TransactionalMetadata
transactionalMetadata, List<ProductType> supportedProductTypes) throws
NumberFormatException, MimeTypeException {
+ public static Product asProduct(TransactionalMetadata
transactionalMetadata, List<ProductType> supportedProductTypes) throws
NumberFormatException, MimeTypeException, ParseException {
HashSet<Term> terms =
getProductTerms(transactionalMetadata.getMetadata());
terms.add(new
Term(CatalogService.CATALOG_SERVICE_TRANSACTION_ID_MET_KEY,
Collections.singletonList(transactionalMetadata.getTransactionId().toString())));
TermBucket termBucket = new
TermBucket(transactionalMetadata.getMetadata().getMetadata(CoreMetKeys.PRODUCT_TYPE));
@@ -103,11 +105,12 @@ public class CatalogServiceUtils {
return asProduct(termBucket, supportedProductTypes);
}
- public static Product asProduct(TermBucket termBucket,
List<ProductType> supportedProductTypes) throws NumberFormatException,
MimeTypeException {
+ public static Product asProduct(TermBucket termBucket,
List<ProductType> supportedProductTypes) throws NumberFormatException,
MimeTypeException, ParseException {
String productId = safeReadTermValue(termBucket,
CatalogService.CATALOG_SERVICE_TRANSACTION_ID_MET_KEY);
String productName = safeReadTermValue(termBucket,
CoreMetKeys.PRODUCT_NAME);
String status = safeReadTermValue(termBucket,
CoreMetKeys.PRODUCT_STATUS);
String structure = safeReadTermValue(termBucket,
CoreMetKeys.PRODUCT_STRUCTURE);
+ String receivedTime = safeReadTermValue(termBucket,
CoreMetKeys.PRODUCT_RECEVIED_TIME);
ProductType productType = null;
for (ProductType type : supportedProductTypes)
if (type.getName().equals(termBucket.getName()))
@@ -140,6 +143,8 @@ public class CatalogServiceUtils {
product.setProductId(productId);
product.setProductReferences(refs);
product.setTransferStatus(status);
+ if (receivedTime != null)
+
product.setProductReceivedTime(DateConvert.isoParse(receivedTime));
if (structure != null)
product.setProductStructure(structure);
return product;
@@ -177,7 +182,7 @@ public class CatalogServiceUtils {
// return ProductPage.blankPage();
// }
- public static ProductPage getProductPage(Page page, CatalogService
catalogService, List<ProductType> supportedProductTypes) throws
CatalogServiceException, NumberFormatException, MimeTypeException {
+ public static ProductPage getProductPage(Page page, CatalogService
catalogService, List<ProductType> supportedProductTypes) throws
CatalogServiceException, NumberFormatException, MimeTypeException,
ParseException {
List<TransactionalMetadata> metadatas = null;
if (page.getPageNum() >= 1) {
metadatas = catalogService.getMetadata(page);
@@ -196,6 +201,8 @@ public class CatalogServiceUtils {
metadata.replaceMetadata(CoreMetKeys.PRODUCT_STRUCTURE,
product.getProductStructure());
if (product.getTransferStatus() != null)
metadata.replaceMetadata(CoreMetKeys.PRODUCT_STATUS,
product.getTransferStatus());
+ if (product.getProductReceivedTime() != null)
+
metadata.replaceMetadata(CoreMetKeys.PRODUCT_RECEVIED_TIME,
DateConvert.isoFormat(product.getProductReceivedTime()));
metadata.replaceMetadata(CoreMetKeys.PRODUCT_TYPE,
product.getProductType().getName());
if (product.getRootRef() != null) {
metadata.replaceMetadata(CoreMetKeys.PRODUCT_ROOT_REF_ORIG,
product.getRootRef().getOrigReference());
Modified:
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/catalogservice/FilemgrCatalogIndex.java
URL:
http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/catalogservice/FilemgrCatalogIndex.java?rev=1087751&r1=1087750&r2=1087751&view=diff
==============================================================================
---
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/catalogservice/FilemgrCatalogIndex.java
(original)
+++
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/catalogservice/FilemgrCatalogIndex.java
Fri Apr 1 15:23:24 2011
@@ -17,10 +17,8 @@
package org.apache.oodt.cas.filemgr.catalog.catalogservice;
//JDK imports
-import java.text.ParseException;
import java.util.Collections;
import java.util.Date;
-import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
@@ -38,7 +36,6 @@ import org.apache.oodt.cas.catalog.excep
import org.apache.oodt.cas.catalog.exception.QueryServiceException;
import org.apache.oodt.cas.catalog.page.IndexPager;
import org.apache.oodt.cas.catalog.page.IngestReceipt;
-import org.apache.oodt.cas.catalog.page.TransactionReceipt;
import org.apache.oodt.cas.catalog.query.CustomQueryExpression;
import org.apache.oodt.cas.catalog.query.CustomWrapperQueryExpression;
import org.apache.oodt.cas.catalog.query.QueryExpression;
@@ -56,9 +53,7 @@ import org.apache.oodt.cas.filemgr.struc
import org.apache.oodt.cas.filemgr.structs.ProductType;
import org.apache.oodt.cas.filemgr.structs.Query;
import org.apache.oodt.cas.filemgr.structs.QueryCriteria;
-import org.apache.oodt.cas.filemgr.structs.query.QueryResult;
import org.apache.oodt.cas.metadata.Metadata;
-import org.apache.oodt.commons.util.DateConvert;
/**
* @author bfoster
@@ -264,7 +259,7 @@ public class FilemgrCatalogIndex impleme
public boolean hasTransactionId(TransactionId<?> catalogTransactionId)
throws CatalogIndexException {
try {
Product product =
this.fmCatalog.getProductById(catalogTransactionId.toString());
- return product != null &&
this.isSupportedProductTypeId(product.getProductType().getProductTypeId());
+ return product != null &&
this.isSupportedProductType(product.getProductType());
}catch(Exception e) {
throw new CatalogIndexException("", e);
}
@@ -273,7 +268,7 @@ public class FilemgrCatalogIndex impleme
public boolean delete(TransactionId<?> transactionId) throws
IngestServiceException {
try {
Product product =
this.fmCatalog.getProductById(transactionId.toString());
-
product.setProductType(this.getProductTypeById(product.getProductType().getProductTypeId()));
+
product.setProductType(this.getCompleteProductType(product.getProductType()));
if (product != null) {
LOG.log(Level.INFO, "Deleting Product for
TransactionId: " + transactionId);
this.fmCatalog.removeProduct(product);
@@ -292,7 +287,7 @@ public class FilemgrCatalogIndex impleme
try {
transactionId =
this.getTransactionIdFactory().createNewTransactionId();
Product product =
CatalogServiceUtils.asProduct(termBuckets.get(0), new
Vector<ProductType>(this.supportedProductTypes));
-
product.setProductType(this.getProductTypeById(product.getProductType().getProductTypeId()));
+
product.setProductType(this.getCompleteProductType(product.getProductType()));
Metadata metadata =
CatalogServiceUtils.asMetadata(termBuckets.get(0));
String catalogAction =
metadata.getMetadata(CatalogActions.CATALOG_ACTION_KEY);
if
(catalogAction.equals(CatalogActions.INGEST_PRODUCT)) {
@@ -304,8 +299,8 @@ public class FilemgrCatalogIndex impleme
// String productReceivedTime =
metadata.getMetadata(CoreMetKeys.PRODUCT_RECEVIED_TIME);
// if (productReceivedTime == null)
//
metadata.replaceMetadata(CoreMetKeys.PRODUCT_RECEVIED_TIME,
DateConvert.isoFormat(new Date()));
- metadata.replaceMetadata(CoreMetKeys.PRODUCT_ID,
product.getProductId());
- return this.generateReceipt(metadata);
+// metadata.replaceMetadata(CoreMetKeys.PRODUCT_ID,
product.getProductId());
+ return new
IngestReceipt(this.generateTransactionId(product.getProductId()),
product.getProductReceivedTime());
}catch (Exception e) {
throw new IngestServiceException("Failed to Ingest
Product for TransactionId: " + transactionId, e);
}
@@ -315,7 +310,7 @@ public class FilemgrCatalogIndex impleme
List<TermBucket> termBuckets) throws
IngestServiceException {
try {
Product product =
this.fmCatalog.getProductById(transactionId.toString());
-
product.setProductType(this.getProductTypeById(product.getProductType().getProductTypeId()));
+
product.setProductType(this.getCompleteProductType(product.getProductType()));
Metadata metadata =
CatalogServiceUtils.asMetadata(termBuckets.get(0));
String catalogAction =
metadata.getMetadata(CatalogActions.CATALOG_ACTION_KEY);
if
(catalogAction.equals(CatalogActions.REMOVE_PRODUCT)) {
@@ -336,7 +331,7 @@ public class FilemgrCatalogIndex impleme
try {
Product product =
CatalogServiceUtils.asProduct(termBuckets.get(0), new
Vector<ProductType>(this.supportedProductTypes));
product.setProductId(transactionId.toString());
-
product.setProductType(this.getProductTypeById(product.getProductType().getProductTypeId()));
+
product.setProductType(this.getCompleteProductType(product.getProductType()));
Metadata metadata =
CatalogServiceUtils.asMetadata(termBuckets.get(0));
metadata.replaceMetadata(CoreMetKeys.PRODUCT_ID,
product.getProductId());
String catalogAction =
metadata.getMetadata(CatalogActions.CATALOG_ACTION_KEY);
@@ -363,7 +358,7 @@ public class FilemgrCatalogIndex impleme
try {
Product product =
this.fmCatalog.getProductById(transactionId.toString());
if (product != null) {
-
product.setProductType(this.getProductTypeById(product.getProductType().getProductTypeId()));
+
product.setProductType(this.getCompleteProductType(product.getProductType()));
product.setProductReferences(this.fmCatalog.getProductReferences(product));
return
Collections.singletonList(CatalogServiceUtils.asTermBucket(product,
this.fmCatalog.getMetadata(product),
this.fmCatalog.getValidationLayer().getElements(product.getProductType())));
}else {
@@ -385,10 +380,10 @@ public class FilemgrCatalogIndex impleme
public List<IngestReceipt> query(QueryExpression queryExpression)
throws QueryServiceException {
try {
- List<String> elements = new Vector<String>();
- Collections.addAll(elements,
CoreMetKeys.PRODUCT_ID,CoreMetKeys.PRODUCT_RECEVIED_TIME);
+// List<String> elements = new Vector<String>();
+// Collections.addAll(elements,
CoreMetKeys.PRODUCT_ID,CoreMetKeys.PRODUCT_RECEVIED_TIME);
- List<Metadata> metadatas = new Vector<Metadata>();
+ List<Product> products = new Vector<Product>();
if (queryExpression instanceof
CustomWrapperQueryExpression) {
CustomWrapperQueryExpression cwqe =
(CustomWrapperQueryExpression) queryExpression;
@@ -402,21 +397,24 @@ public class FilemgrCatalogIndex impleme
CustomQueryExpression customQE =
(CustomQueryExpression) queryExpression;
if
(customQE.getName().equals(CatalogServiceMetKeys.PRODUCT_NAME_QUERY_EXPRESSION))
{
Product product =
this.fmCatalog.getProductByName(customQE.getProperty(CatalogServiceMetKeys.PRODUCT_NAME_CUSTOM_KEY));
- if (product != null &&
product.getProductType() != null &&
this.isSupportedProductTypeId(product.getProductType().getProductTypeId())) {
-
product.setProductType(this.getProductTypeById(product.getProductType().getProductTypeId()));
- metadatas =
Collections.singletonList(this.fmCatalog.getReducedMetadata(product, elements));
- }else {
- metadatas =
Collections.emptyList();
- }
+ if (product != null &&
product.getProductType() != null &&
this.isSupportedProductType(product.getProductType()))
+ products.add(product);
+// if (product != null &&
product.getProductType() != null &&
this.isSupportedProductType(product.getProductType())) {
+//
product.setProductType(this.getCompleteProductType(product.getProductType()));
+// metadatas =
Collections.singletonList(this.fmCatalog.getReducedMetadata(product, elements));
+// }else {
+// metadatas =
Collections.emptyList();
+// }
}else if
(customQE.getName().equals(CatalogServiceMetKeys.TOP_N_QUERY_EXPRESSION)) {
List<Product> topNProducts =
this.fmCatalog.getTopNProducts(Integer.parseInt(customQE.getProperty(CatalogServiceMetKeys.N_CUSTOM_KEY)));
if (topNProducts != null) {
for (Product product :
topNProducts) {
- if (product != null &&
product.getProductType() != null &&
this.isSupportedProductTypeId(product.getProductType().getProductTypeId())) {
-
product.setProductType(this.getProductTypeById(product.getProductType().getProductTypeId()));
- Metadata m =
this.fmCatalog.getMetadata(product);
-
m.replaceMetadata(CoreMetKeys.PRODUCT_ID, product.getProductId());
-
metadatas.add(m);
+ if (product != null &&
product.getProductType() != null &&
this.isSupportedProductType(product.getProductType())) {
+
product.setProductType(this.getCompleteProductType(product.getProductType()));
+
products.add(product);
+// Metadata m =
this.fmCatalog.getMetadata(product);
+//
m.replaceMetadata(CoreMetKeys.PRODUCT_ID, product.getProductId());
+//
metadatas.add(m);
}
}
}
@@ -438,12 +436,17 @@ public class FilemgrCatalogIndex impleme
if (type != null)
supportedSubsetOfTypes.add(type);
}
- metadatas =
this.fmCatalog.getReducedMetadata(fmQuery, supportedSubsetOfTypes, elements);
+ List<String> productIds =
this.fmCatalog.query(fmQuery, supportedSubsetOfTypes);
+ for (String productId : productIds)
+
products.add(this.fmCatalog.getProductById(productId));
+// metadatas =
this.fmCatalog.getReducedMetadata(fmQuery, supportedSubsetOfTypes, elements);
}
List<IngestReceipt> ingestReceipts = new
Vector<IngestReceipt>();
- for (Metadata metadata : metadatas)
- ingestReceipts.add(generateReceipt(metadata));
+// for (Metadata metadata : metadatas)
+// ingestReceipts.add(generateReceipt(metadata));
+ for (Product product : products)
+ ingestReceipts.add(new
IngestReceipt(this.generateTransactionId(product.getProductId()),
product.getProductReceivedTime()));
return ingestReceipts;
}catch (Exception e) {
throw new QueryServiceException("Failed to perform
CatalogQuery '" + queryExpression + "' : " + e.getMessage(), e);
@@ -453,10 +456,10 @@ public class FilemgrCatalogIndex impleme
public List<IngestReceipt> query(QueryExpression queryExpression, int
startIndex, int endIndex)
throws QueryServiceException {
try {
- List<String> elements = new Vector<String>();
- Collections.addAll(elements,
CoreMetKeys.PRODUCT_ID,CoreMetKeys.PRODUCT_RECEVIED_TIME);
+// List<String> elements = new Vector<String>();
+// Collections.addAll(elements,
CoreMetKeys.PRODUCT_ID,CoreMetKeys.PRODUCT_RECEVIED_TIME);
- List<Metadata> metadatas = new Vector<Metadata>();
+ List<Product> products = new Vector<Product>();
if (queryExpression instanceof
CustomWrapperQueryExpression) {
CustomWrapperQueryExpression cwqe =
(CustomWrapperQueryExpression) queryExpression;
@@ -470,21 +473,24 @@ public class FilemgrCatalogIndex impleme
CustomQueryExpression customQE =
(CustomQueryExpression) queryExpression;
if
(customQE.getName().equals(CatalogServiceMetKeys.PRODUCT_NAME_QUERY_EXPRESSION))
{
Product product =
this.fmCatalog.getProductByName(customQE.getProperty(CatalogServiceMetKeys.PRODUCT_NAME_CUSTOM_KEY));
- if (product != null &&
product.getProductType() != null &&
this.isSupportedProductTypeId(product.getProductType().getProductTypeId())) {
-
product.setProductType(this.getProductTypeById(product.getProductType().getProductTypeId()));
- metadatas =
Collections.singletonList(this.fmCatalog.getReducedMetadata(product, elements));
- }else {
- metadatas =
Collections.emptyList();
- }
+ if (product != null &&
product.getProductType() != null &&
this.isSupportedProductType(product.getProductType()))
+ products.add(product);
+// if (product != null &&
product.getProductType() != null &&
this.isSupportedProductType(product.getProductType())) {
+//
product.setProductType(this.getCompleteProductType(product.getProductType()));
+// metadatas =
Collections.singletonList(this.fmCatalog.getReducedMetadata(product, elements));
+// }else {
+// metadatas =
Collections.emptyList();
+// }
}else if
(customQE.getName().equals(CatalogServiceMetKeys.TOP_N_QUERY_EXPRESSION)) {
List<Product> topNProducts =
this.fmCatalog.getTopNProducts(Integer.parseInt(customQE.getProperty(CatalogServiceMetKeys.N_CUSTOM_KEY)));
if (topNProducts != null) {
for (Product product :
topNProducts) {
- if (product != null &&
product.getProductType() != null &&
this.isSupportedProductTypeId(product.getProductType().getProductTypeId())) {
-
product.setProductType(this.getProductTypeById(product.getProductType().getProductTypeId()));
- Metadata m =
this.fmCatalog.getMetadata(product);
-
m.replaceMetadata(CoreMetKeys.PRODUCT_ID, product.getProductId());
-
metadatas.add(m);
+ if (product != null &&
product.getProductType() != null &&
this.isSupportedProductType(product.getProductType())) {
+
products.add(product);
+//
product.setProductType(this.getCompleteProductType(product.getProductType()));
+// Metadata m =
this.fmCatalog.getMetadata(product);
+//
m.replaceMetadata(CoreMetKeys.PRODUCT_ID, product.getProductId());
+//
metadatas.add(m);
}
}
}
@@ -506,31 +512,35 @@ public class FilemgrCatalogIndex impleme
if (type != null)
supportedSubsetOfTypes.add(type);
}
- int currentIndex = 0;
+// int currentIndex = 0;
for (ProductType type : supportedSubsetOfTypes)
{
- ProductPage page =
this.fmCatalog.pagedQuery(fmQuery, type, 1);
+// ProductPage page =
this.fmCatalog.pagedQuery(fmQuery, type, 1);
+ int currentIndex = products.size();
if (endIndex <= currentIndex)
break;
- if (startIndex >= currentIndex &&
startIndex <= currentIndex + page.getNumOfHits()) {
+// if (startIndex >= currentIndex &&
startIndex <= currentIndex + page.getNumOfHits()) {
int localIndex = startIndex -
currentIndex;
int pageNum = (int)
Math.ceil((double) localIndex / (double) this.fmCatalog.getPageSize());
int numOfPages = (int)
Math.ceil((double) (endIndex - startIndex) / (double)
this.fmCatalog.getPageSize());
for (int i = 0; i < numOfPages;
i++, pageNum++) {
- page =
this.fmCatalog.pagedQuery(fmQuery, type, pageNum);
+ ProductPage page =
this.fmCatalog.pagedQuery(fmQuery, type, pageNum);
for (int k = 0, j =
localIndex; k < page.getPageProducts().size() && j < (localIndex +
this.fmCatalog.getPageSize()) && j < endIndex - currentIndex; k++, j++) {
Product product
= page.getPageProducts().get(k);
product.setProductType(type);
-
metadatas.add(this.fmCatalog.getReducedMetadata(product, elements));
+
products.add(product);
+//
metadatas.add(this.fmCatalog.getReducedMetadata(product, elements));
}
}
- }
- currentIndex += page.getNumOfHits();
+// }
+// currentIndex += page.getNumOfHits();
}
}
List<IngestReceipt> ingestReceipts = new
Vector<IngestReceipt>();
- for (Metadata metadata : metadatas)
- ingestReceipts.add(generateReceipt(metadata));
+// for (Metadata metadata : metadatas)
+// ingestReceipts.add(generateReceipt(metadata));
+ for (Product product : products)
+ ingestReceipts.add(new
IngestReceipt(this.generateTransactionId(product.getProductId()),
product.getProductReceivedTime()));
return ingestReceipts;
}catch (Exception e) {
throw new QueryServiceException("Failed to perform
CatalogQuery '" + queryExpression + "' : " + e.getMessage(), e);
@@ -551,7 +561,7 @@ public class FilemgrCatalogIndex impleme
CustomQueryExpression customQE =
(CustomQueryExpression) queryExpression;
if
(customQE.getName().equals(CatalogServiceMetKeys.PRODUCT_NAME_QUERY_EXPRESSION))
{
Product product =
this.fmCatalog.getProductByName(customQE.getProperty(CatalogServiceMetKeys.PRODUCT_NAME_CUSTOM_KEY));
- if (product != null &&
product.getProductType() != null &&
this.isSupportedProductTypeId(product.getProductType().getProductTypeId())) {
+ if (product != null &&
product.getProductType() != null &&
this.isSupportedProductType(product.getProductType())) {
return 1;
}else {
return 0;
@@ -608,14 +618,14 @@ public class FilemgrCatalogIndex impleme
}
}
- protected IngestReceipt generateReceipt(Metadata metadata) throws
ParseException {
- String reveivedTimeString =
metadata.getMetadata(CoreMetKeys.PRODUCT_RECEVIED_TIME);
- Date receivedDate = new GregorianCalendar(2000, 01,
01).getTime();
- if (reveivedTimeString != null)
- receivedDate = DateConvert.isoParse(reveivedTimeString);
-// System.out.println("generating receipt for product_id : " +
metadata.getMetadata(CoreMetKeys.PRODUCT_ID));
- return new
IngestReceipt(this.generateTransactionId(metadata.getMetadata(CoreMetKeys.PRODUCT_ID)),
receivedDate);
- }
+// protected IngestReceipt generateReceipt(Metadata metadata) throws
ParseException {
+// String reveivedTimeString =
metadata.getMetadata(CoreMetKeys.PRODUCT_RECEVIED_TIME);
+// Date receivedDate = new GregorianCalendar(2000, 01,
01).getTime();
+// if (reveivedTimeString != null)
+// receivedDate = DateConvert.isoParse(reveivedTimeString);
+//// System.out.println("generating receipt for product_id : " +
metadata.getMetadata(CoreMetKeys.PRODUCT_ID));
+// return new
IngestReceipt(this.generateTransactionId(metadata.getMetadata(CoreMetKeys.PRODUCT_ID)),
receivedDate);
+// }
// private void writeObject(java.io.ObjectOutputStream out) throws
IOException {
// try {
@@ -642,13 +652,13 @@ public class FilemgrCatalogIndex impleme
// }
// }
- protected boolean isSupportedProductTypeName(String name) {
- return this.getProductTypeByName(name) != null;
- }
-
- protected boolean isSupportedProductTypeId(String id) {
- return this.getProductTypeById(id) != null;
- }
+// protected boolean isSupportedProductTypeName(String name) {
+// return this.getProductTypeByName(name) != null;
+// }
+//
+// protected boolean isSupportedProductTypeId(String id) {
+// return this.getProductTypeById(id) != null;
+// }
protected ProductType getProductTypeByName(String name) {
for (ProductType type : this.supportedProductTypes)
@@ -656,13 +666,27 @@ public class FilemgrCatalogIndex impleme
return type;
return null;
}
+//
+// protected ProductType getProductTypeById(String id) {
+// for (ProductType type : this.supportedProductTypes)
+// if (type.getProductTypeId().equals(id))
+// return type;
+// return null;
+// }
- protected ProductType getProductTypeById(String id) {
+ protected boolean isSupportedProductType(ProductType productType) {
for (ProductType type : this.supportedProductTypes)
- if (type.getProductTypeId().equals(id))
+ if (type.equals(productType))
+ return true;
+ return false;
+ }
+
+ protected ProductType getCompleteProductType(ProductType productType)
throws Exception {
+ for (ProductType type : this.supportedProductTypes)
+ if (type.equals(productType))
return type;
return null;
- }
+ }
protected Set<String> getSupportedProductTypeNames() {
Set<String> productTypeNames = new HashSet<String>();
Modified:
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Product.java
URL:
http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Product.java?rev=1087751&r1=1087750&r2=1087751&view=diff
==============================================================================
---
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Product.java
(original)
+++
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Product.java
Fri Apr 1 15:23:24 2011
@@ -21,6 +21,7 @@ import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
+import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
@@ -63,6 +64,8 @@ public class Product {
/* our product structure: can be Heirarchical, or Flat */
private String productStructure = null;
+ private Date productReceivedTime = null;
+
/* a set of {@link References} to the items that make up this product */
private List<Reference> references = null;
@@ -139,11 +142,12 @@ public class Product {
* A {@link List} of {@link Reference}s pointing to the items
* that make up this product.
*/
- public Product(String name, ProductType pType, String structure,
+ public Product(String name, ProductType pType, String structure, Date
productReceivedTime,
String transferStatus, List<Reference> refs) {
productName = name;
productType = pType;
productStructure = structure;
+ this.productReceivedTime = productReceivedTime;
references = refs;
}
@@ -177,7 +181,15 @@ public class Product {
this.productStructure = productStructure;
}
- /**
+ public Date getProductReceivedTime() {
+ return productReceivedTime;
+ }
+
+ public void setProductReceivedTime(Date productReceivedTime) {
+ this.productReceivedTime = productReceivedTime;
+ }
+
+ /**
* @return Returns the references.
*/
public List<Reference> getProductReferences() {
Modified:
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/ProductType.java
URL:
http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/ProductType.java?rev=1087751&r1=1087750&r2=1087751&view=diff
==============================================================================
---
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/ProductType.java
(original)
+++
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/ProductType.java
Fri Apr 1 15:23:24 2011
@@ -192,6 +192,17 @@ public class ProductType {
public void setHandlers(List<TypeHandler> handlers) {
this.handlers = handlers;
}
+
+ public boolean equals(Object obj) {
+ if (obj instanceof ProductType) {
+ ProductType type = (ProductType) obj;
+ if (type.getProductTypeId() != null && this.getProductTypeId()
!= null)
+ return
type.getProductTypeId().equals(this.getProductTypeId());
+ else if (type.getName() != null && this.getName() != null)
+ return type.getName().equals(this.getName());
+ }
+ return false;
+ }
/* (non-Javadoc)
* @see java.lang.Object#toString()
Modified:
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java
URL:
http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java?rev=1087751&r1=1087750&r2=1087751&view=diff
==============================================================================
---
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java
(original)
+++
oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java
Fri Apr 1 15:23:24 2011
@@ -499,16 +499,14 @@ public class XmlRpcFileManager {
// set the ProductType
// to obey the contract of the File Manager, we need to make
// sure its set here
- product.setProductType(this.repositoryManager
- .getProductTypeById(product.getProductType()
- .getProductTypeId()));
+ this.setProductType(product);
return XmlRpcStructFactory.getXmlRpcProduct(product);
} catch (CatalogException e) {
e.printStackTrace();
LOG.log(Level.SEVERE, "Unable to obtain product by name: ["
+ productName + "]: Message: " + e.getMessage(), e);
throw new CatalogException(e.getMessage(), e);
- } catch (RepositoryManagerException e) {
+ } catch (Exception e) {
e.printStackTrace();
LOG.log(Level.SEVERE, "Unable to obtain product type by id: ["
+ product.getProductType().getProductTypeId()