You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by bf...@apache.org on 2010/09/29 19:19:15 UTC
svn commit: r1002752 [2/9] - in /incubator/oodt/trunk/catalog: ./
.externalToolBuilders/ .settings/ src/ src/main/ src/main/assembly/
src/main/bin/ src/main/java/ src/main/java/gov/ src/main/java/gov/nasa/
src/main/java/gov/nasa/jpl/ src/main/java/gov/...
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/mapping/LuceneIngestMapper.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/mapping/LuceneIngestMapper.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/mapping/LuceneIngestMapper.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/mapping/LuceneIngestMapper.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.mapping;
+
+//JDK imports
+import java.util.Set;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.exception.CatalogRepositoryException;
+import org.apache.oodt.cas.catalog.page.CatalogReceipt;
+import org.apache.oodt.cas.catalog.page.IndexPager;
+import org.apache.oodt.cas.catalog.struct.TransactionId;
+import org.apache.oodt.cas.catalog.struct.TransactionIdFactory;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A Ingest Mapper that indexes to a Lucene index
+ * <p>
+ */
+public class LuceneIngestMapper implements IngestMapper {
+
+ public void deleteAllMappingsForCatalog(String catalogId)
+ throws CatalogRepositoryException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void deleteAllMappingsForCatalogServiceTransactionId(
+ TransactionId<?> catalogServiceTransactionId)
+ throws CatalogRepositoryException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void deleteTransactionIdMapping(
+ TransactionId<?> catalogTransactionId, String catalogId)
+ throws CatalogRepositoryException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public CatalogReceipt getCatalogReceipt(
+ TransactionId<?> catalogServiceTransactionId, String catalogId)
+ throws CatalogRepositoryException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public TransactionId<?> getCatalogServiceTransactionId(
+ TransactionId<?> catalogTransactionId, String catalogId)
+ throws CatalogRepositoryException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public TransactionId<?> getCatalogTransactionId(
+ TransactionId<?> catalogServiceTransactionId, String catalogId)
+ throws CatalogRepositoryException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Set<String> getCatalogIds(
+ TransactionId<?> catalogServiceTransactionId)
+ throws CatalogRepositoryException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Set<TransactionId<?>> getPageOfCatalogTransactionIds(
+ IndexPager indexPager, String catalogId)
+ throws CatalogRepositoryException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean hasCatalogServiceTransactionId(
+ TransactionId<?> catalogServiceTransactionId)
+ throws CatalogRepositoryException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void storeTransactionIdMapping(
+ TransactionId<?> catalogServiceTransactionId,
+ TransactionIdFactory catalogServiceTransactionIdFactory,
+ CatalogReceipt catalogReceipt,
+ TransactionIdFactory catalogTransactionIdFactory)
+ throws CatalogRepositoryException {
+ // TODO Auto-generated method stub
+
+ }
+
+
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/mapping/LuceneIngestMapperFactory.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/mapping/LuceneIngestMapperFactory.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/mapping/LuceneIngestMapperFactory.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/mapping/LuceneIngestMapperFactory.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.mapping;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A Factory for creating LuceneIngestMapper
+ * <p>
+ */
+public class LuceneIngestMapperFactory implements
+ IngestMapperFactory {
+
+ public IngestMapper createMapper() {
+ return new LuceneIngestMapper();
+ }
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/mapping/MemoryBasedIngestMapper.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/mapping/MemoryBasedIngestMapper.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/mapping/MemoryBasedIngestMapper.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/mapping/MemoryBasedIngestMapper.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,291 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.mapping;
+
+//JDK imports
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.exception.CatalogRepositoryException;
+import org.apache.oodt.cas.catalog.page.CatalogReceipt;
+import org.apache.oodt.cas.catalog.page.IndexPager;
+import org.apache.oodt.cas.catalog.struct.TransactionId;
+import org.apache.oodt.cas.catalog.struct.TransactionIdFactory;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A Ingest Mapper that indexes to local memory
+ * <p>
+ */
+public class MemoryBasedIngestMapper implements IngestMapper {
+
+ private static Logger LOG = Logger.getLogger(MemoryBasedIngestMapper.class.getName());
+
+ protected HashMap<String, TransactionIdMapping> catalogServiceTransactionIdKeyMapping;
+ protected HashMap<String, TransactionIdMapping> catalogInfoKeyMapping;
+ protected HashMap<String, List<CatalogReceipt>> catalogIdToCatalogReceiptMapping;
+
+ public MemoryBasedIngestMapper() {
+ this.catalogServiceTransactionIdKeyMapping = new HashMap<String, TransactionIdMapping>();
+ this.catalogInfoKeyMapping = new HashMap<String, TransactionIdMapping>();
+ this.catalogIdToCatalogReceiptMapping = new HashMap<String, List<CatalogReceipt>>();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.apache.oodt.cas.catalog.repository.CatalogRepository#
+ * getCatalogServiceTransactionId
+ * (org.apache.oodt.cas.catalog.struct.TransactionId, java.lang.String)
+ */
+ public synchronized TransactionId<?> getCatalogServiceTransactionId(
+ TransactionId<?> catalogTransactionId, String catalogId)
+ throws CatalogRepositoryException {
+ LOG.log(Level.INFO, "Looking up CatalogService TransactionId for Catalog TransactionId '" + catalogTransactionId + "' and catalog '" + catalogId + "'");
+ String key = generateKey(catalogTransactionId.toString(), catalogId);
+// System.out.println("LOOKING UP: " + key);
+ TransactionIdMapping mapping = this.catalogInfoKeyMapping.get(key);
+ if (mapping != null) {
+ return mapping.catalogServiceTransactionId;
+ }else {
+ return null;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.apache.oodt.cas.catalog.repository.CatalogRepository#
+ * getCatalogTransactionId
+ * (org.apache.oodt.cas.catalog.struct.TransactionId, java.lang.String)
+ */
+ public synchronized TransactionId<?> getCatalogTransactionId(
+ TransactionId<?> catalogServiceTransactionId, String catalogId)
+ throws CatalogRepositoryException {
+ TransactionIdMapping mapping = this.catalogServiceTransactionIdKeyMapping
+ .get(catalogServiceTransactionId.toString());
+ if (mapping != null)
+ for (CatalogReceipt receipt : mapping.getCatalogReceipts())
+ if (receipt.getCatalogId().equals(catalogId))
+ return receipt.getTransactionId();
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.oodt.cas.catalog.mapping.IngestMapper#getPage(org.apache
+ * .oodt.cas.catalog.page.IndexPager, java.lang.String)
+ */
+ public synchronized Set<TransactionId<?>> getPageOfCatalogTransactionIds(IndexPager indexPager,
+ String catalogId) throws CatalogRepositoryException {
+ Set<TransactionId<?>> catalogTransactionIds = new HashSet<TransactionId<?>>();
+ List<CatalogReceipt> catalogReceipts = this.catalogIdToCatalogReceiptMapping.get(catalogId);
+ if (catalogReceipts != null)
+ for (int i = indexPager.getPageNum() * indexPager.getPageSize(); i < catalogReceipts.size() && i < (indexPager.getPageNum() + 1) * indexPager.getPageSize(); i++)
+ catalogTransactionIds.add(catalogReceipts.get(i).getTransactionId());
+ return catalogTransactionIds;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.oodt.cas.catalog.mapping.IngestMapper#deleteAllMappingsForCatalog(java.lang.String)
+ */
+ public synchronized void deleteAllMappingsForCatalog(String catalogId)
+ throws CatalogRepositoryException {
+ List<CatalogReceipt> catalogReceipts = this.catalogIdToCatalogReceiptMapping.remove(catalogId);
+ if (catalogReceipts != null) {
+ for (CatalogReceipt catalogReceipt : catalogReceipts) {
+ TransactionIdMapping mapping = this.catalogInfoKeyMapping.remove(generateKey(catalogReceipt.getTransactionId().toString(), catalogReceipt.getCatalogId()));
+ if (mapping != null)
+ mapping.getCatalogReceipts().remove(catalogReceipt);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.oodt.cas.catalog.repository.CatalogRepository#deleteAllMappingsForCatalogServiceTransactionId(org.apache.oodt.cas.catalog.struct.TransactionId)
+ */
+ public synchronized void deleteAllMappingsForCatalogServiceTransactionId(
+ TransactionId<?> catalogServiceTransactionId)
+ throws CatalogRepositoryException {
+ TransactionIdMapping mapping = this.catalogServiceTransactionIdKeyMapping.remove(catalogServiceTransactionId.toString());
+ if (mapping != null)
+ for (CatalogReceipt catalogReceipt : mapping.getCatalogReceipts()) {
+ this.catalogIdToCatalogReceiptMapping.get(catalogReceipt.getCatalogId()).remove(catalogReceipt);
+ this.catalogInfoKeyMapping.remove(generateKey(catalogReceipt.getTransactionId().toString(), catalogReceipt.getCatalogId()));
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.oodt.cas.catalog.repository.CatalogRepository#deleteTransactionIdMapping(org.apache.oodt.cas.catalog.struct.TransactionId, org.apache.oodt.cas.catalog.struct.TransactionId, java.lang.String)
+ */
+ public synchronized void deleteTransactionIdMapping(
+ TransactionId<?> catalogTransactionId, String catalogId)
+ throws CatalogRepositoryException {
+ List<CatalogReceipt> catalogReceipts = this.catalogIdToCatalogReceiptMapping.get(catalogId);
+ for (int i = 0; i < catalogReceipts.size(); i++) {
+ if (catalogReceipts.get(i).getCatalogId().equals(catalogId) && catalogReceipts.get(i).getTransactionId().equals(catalogTransactionId)) {
+ catalogReceipts.remove(i);
+ break;
+ }
+ }
+ TransactionIdMapping mapping = this.catalogInfoKeyMapping.remove(generateKey(catalogTransactionId.toString(), catalogId));
+ this.catalogServiceTransactionIdKeyMapping.remove(mapping.getCatalogServiceTransactionId().toString());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.oodt.cas.catalog.repository.CatalogRepository#hasCatalogServiceTransactionId(org.apache.oodt.cas.catalog.struct.TransactionId)
+ */
+ public synchronized boolean hasCatalogServiceTransactionId(
+ TransactionId<?> catalogServiceTransactionId)
+ throws CatalogRepositoryException {
+ return this.catalogServiceTransactionIdKeyMapping.containsKey(catalogServiceTransactionId.toString());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.apache.oodt.cas.catalog.repository.CatalogRepository#
+ * storeTransactionIdMapping(java.lang.String,
+ * org.apache.oodt.cas.catalog.struct.TransactionId,
+ * org.apache.oodt.cas.catalog.struct.TransactionId)
+ */
+ public synchronized void storeTransactionIdMapping(
+ TransactionId<?> catalogServiceTransactionId,
+ TransactionIdFactory catalogServiceTransactionIdFactory,
+ CatalogReceipt catalogReceipt,
+ TransactionIdFactory catalogTransactionIdFactory)
+ throws CatalogRepositoryException {
+ TransactionIdMapping mapping = this.catalogServiceTransactionIdKeyMapping
+ .get(catalogServiceTransactionId.toString());
+ if (mapping == null)
+ mapping = new TransactionIdMapping(catalogServiceTransactionId);
+ mapping.addCatalogReceipt(catalogReceipt);
+ this.catalogServiceTransactionIdKeyMapping.put(
+ catalogServiceTransactionId.toString(), mapping);
+ this.catalogInfoKeyMapping.put(generateKey(catalogReceipt.getTransactionId().toString(), catalogReceipt.getCatalogId()), mapping);
+ List<CatalogReceipt> catalogReceipts = this.catalogIdToCatalogReceiptMapping.get(catalogReceipt.getCatalogId());
+ if (catalogReceipts == null)
+ catalogReceipts = new Vector<CatalogReceipt>();
+ catalogReceipts.add(catalogReceipt);
+ this.catalogIdToCatalogReceiptMapping.put(catalogReceipt.getCatalogId(), catalogReceipts);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.oodt.cas.catalog.repository.CatalogRepository#getCatalogs
+ * (org.apache.oodt.cas.catalog.struct.TransactionId)
+ */
+ public synchronized Set<String> getCatalogIds(
+ TransactionId<?> catalogServiceTransactionId)
+ throws CatalogRepositoryException {
+ HashSet<String> catalogs = new HashSet<String>();
+ TransactionIdMapping mapping = this.catalogServiceTransactionIdKeyMapping
+ .get(catalogServiceTransactionId.toString());
+ for (CatalogReceipt catalogReceipt : mapping.getCatalogReceipts())
+ catalogs.add(catalogReceipt.getCatalogId());
+ return catalogs;
+ }
+
+ public CatalogReceipt getCatalogReceipt(
+ TransactionId<?> catalogServiceTransactionId, String catalogId)
+ throws CatalogRepositoryException {
+ TransactionIdMapping mapping = this.catalogServiceTransactionIdKeyMapping.get(catalogServiceTransactionId);
+ for (CatalogReceipt catalogReceipt : mapping.getCatalogReceipts())
+ if (catalogReceipt.getCatalogId().equals(catalogId))
+ return catalogReceipt;
+ return null;
+ }
+
+ private static String generateKey(String catalogTransactionId, String catalogId) {
+ return catalogTransactionId + ":" + catalogId;
+ }
+
+ private class TransactionIdMapping {
+
+ private TransactionId<?> catalogServiceTransactionId;
+ List<CatalogReceipt> catalogReceipts;
+
+ public TransactionIdMapping(TransactionId<?> catalogServiceTransactionId) {
+ this.catalogServiceTransactionId = catalogServiceTransactionId;
+ this.catalogReceipts = new Vector<CatalogReceipt>();
+ }
+
+ public void addCatalogReceipt(CatalogReceipt catalogReceipt) {
+ this.catalogReceipts.add(catalogReceipt);
+ }
+
+ public List<CatalogReceipt> getCatalogReceipts() {
+ return this.catalogReceipts;
+ }
+
+ public TransactionId<?> getCatalogServiceTransactionId() {
+ return catalogServiceTransactionId;
+ }
+
+ }
+
+// private class CatalogInfo {
+//
+// private String catalogId;
+// private TransactionId<?> catalogTransactionId;
+//
+// public CatalogInfo(String catalogId,
+// TransactionId<?> catalogTransactionId) {
+// this.catalogId = catalogId;
+// this.catalogTransactionId = catalogTransactionId;
+// }
+//
+// public String getCatalogUrn() {
+// return this.catalogId;
+// }
+//
+// public TransactionId<?> getCatalogTransactionId() {
+// return this.catalogTransactionId;
+// }
+//
+// public boolean equals(Object obj) {
+// if (obj instanceof CatalogInfo) {
+// return this.toString().equals(obj.toString());
+// }else {
+// return false;
+// }
+// }
+//
+// public String toString() {
+// return this.catalogId + ":" + this.catalogTransactionId;
+// }
+//
+// }
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/mapping/MemoryBasedIngestMapperFactory.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/mapping/MemoryBasedIngestMapperFactory.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/mapping/MemoryBasedIngestMapperFactory.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/mapping/MemoryBasedIngestMapperFactory.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.mapping;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A Factory for creating MemoryBasedIngestMapper
+ * <p>
+ */
+public class MemoryBasedIngestMapperFactory implements IngestMapperFactory {
+
+ public IngestMapper createMapper() {
+ return new MemoryBasedIngestMapper();
+ }
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/metadata/TransactionalMetadata.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/metadata/TransactionalMetadata.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/metadata/TransactionalMetadata.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/metadata/TransactionalMetadata.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.metadata;
+
+//JDK imports
+import java.util.Date;
+import java.util.Set;
+
+//APACHE imports
+import org.apache.commons.lang.StringUtils;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.page.TransactionReceipt;
+import org.apache.oodt.cas.catalog.struct.TransactionId;
+import org.apache.oodt.cas.catalog.system.CatalogService;
+import org.apache.oodt.cas.metadata.Metadata;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * Metadata tied to a Transaction
+ * <p>
+ */
+public class TransactionalMetadata {
+
+ protected TransactionReceipt receipt;
+ protected Metadata metadata;
+
+ public TransactionalMetadata(TransactionReceipt receipt, Metadata metadata) {
+ this.receipt = receipt;
+ this.metadata = metadata;
+ this.metadata.replaceMetadata(CatalogService.CATALOG_SERVICE_TRANSACTION_ID_MET_KEY, this.receipt.getTransactionId().toString());
+ this.metadata.replaceMetadata(CatalogService.CATALOG_IDS_MET_KEY, StringUtils.join(this.receipt.getCatalogIds().iterator(), ","));
+ }
+
+ public TransactionId<?> getTransactionId() {
+ return receipt.getTransactionId();
+ }
+
+ public Set<String> getCatalogIds() {
+ return receipt.getCatalogIds();
+ }
+
+ public Date getTransactionDate() {
+ return receipt.getTransactionDate();
+ }
+
+ public Metadata getMetadata() {
+ return metadata;
+ }
+
+ @Override
+ public int hashCode() {
+ return this.getTransactionId().hashCode();
+ }
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/CatalogReceipt.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/CatalogReceipt.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/CatalogReceipt.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/CatalogReceipt.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.page;
+
+//JDK imports
+import java.util.Date;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.struct.TransactionId;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ */
+public class CatalogReceipt {
+
+ protected TransactionId<?> transactionId;
+ protected Date transactionDate;
+ protected String catalogId;
+
+ public CatalogReceipt(IngestReceipt ingestReceipt, String catalogId) {
+ this.transactionId = ingestReceipt.getCatalogTransactionId();
+ this.transactionDate = ingestReceipt.getTransactionDate();
+ this.catalogId = catalogId;
+ }
+
+ public TransactionId<?> getTransactionId() {
+ return this.transactionId;
+ }
+
+ public Date getTransactionDate() {
+ return this.transactionDate;
+ }
+
+ public String getCatalogId() {
+ return this.catalogId;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof CatalogReceipt) {
+ CatalogReceipt compareTo = (CatalogReceipt) obj;
+ return this.transactionId.equals(compareTo.transactionId) && this.transactionDate.equals(compareTo.transactionDate) && this.catalogId.equals(compareTo.catalogId);
+ }else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ return this.toString().hashCode();
+ }
+
+ public String toString() {
+ return ("{CatalogReceipt(tID=" + this.transactionId + ",tDate=" + this.transactionDate + ",catID=" + this.catalogId + ")}");
+ }
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/IndexPager.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/IndexPager.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/IndexPager.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/IndexPager.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.page;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A pager for paging through a index
+ * <p>
+ */
+public class IndexPager {
+
+ protected int pageSize;
+ protected int pageNum;
+ protected int totalPages;
+ protected int numOfHits;
+
+ public IndexPager() {
+ this.pageSize = 20;
+ this.pageNum = 1;
+ this.totalPages = 0;
+ }
+
+ public IndexPager(ProcessedPageInfo processedPageInfo) {
+ this.pageSize = processedPageInfo.getPageSize();
+ this.pageNum = processedPageInfo.getPageNum();
+ this.totalPages = processedPageInfo.getTotalPages();
+ this.numOfHits = processedPageInfo.getNumOfHits();
+ }
+
+ public ProcessedPageInfo getProcessedPageInfo() {
+ return new ProcessedPageInfo(this.pageSize, this.pageNum, this.numOfHits);
+ }
+
+ public int getPageSize() {
+ return this.pageSize;
+ }
+
+ public int getPageNum() {
+ return this.pageNum;
+ }
+
+ public int getTotalPages() {
+ return this.totalPages;
+ }
+
+ public int getNumOfHits() {
+ return this.numOfHits;
+ }
+
+ public void incrementPageNumber() {
+ if (this.pageNum + 1 <= this.totalPages)
+ this.pageNum++;
+ }
+
+ public boolean isLastPage() {
+ return this.getProcessedPageInfo().isLastPage();
+ }
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/IngestReceipt.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/IngestReceipt.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/IngestReceipt.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/IngestReceipt.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.page;
+
+//JDK imports
+import java.util.Date;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.struct.TransactionId;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ */
+public class IngestReceipt {
+
+ protected TransactionId<?> catalogTransactionId;
+ protected Date transactionDate;
+
+ public IngestReceipt(TransactionId<?> catalogTransactionId, Date transactionDate) {
+ this.catalogTransactionId = catalogTransactionId;
+ this.transactionDate = transactionDate;
+ }
+
+ public TransactionId<?> getCatalogTransactionId() {
+ return this.catalogTransactionId;
+ }
+
+ public Date getTransactionDate() {
+ return this.transactionDate;
+ }
+
+ public int hashCode() {
+ return this.catalogTransactionId.hashCode();
+ }
+
+ public String toString() {
+ return this.catalogTransactionId.toString() + " : " + this.transactionDate.toString();
+ }
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/Page.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/Page.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/Page.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/Page.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.page;
+
+//JDK imports
+import java.util.List;
+import java.util.Set;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.query.QueryExpression;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ */
+public class Page {
+
+ protected List<TransactionReceipt> receipts;
+ protected ProcessedPageInfo processedPageInfo;
+ protected QueryExpression queryExpression;
+ protected Set<String> restrictToCatalogIds;
+
+ public Page(ProcessedPageInfo pageInfo, QueryExpression queryExpression, Set<String> restrictToCatalogIds, List<TransactionReceipt> receipts) {
+ this.processedPageInfo = pageInfo;
+ this.queryExpression = queryExpression;
+ this.restrictToCatalogIds = restrictToCatalogIds;
+ this.receipts = receipts;
+ }
+
+ public List<TransactionReceipt> getReceipts() {
+ return this.receipts;
+ }
+
+ public int getPageSize() {
+ return this.processedPageInfo.getPageSize();
+ }
+
+ public int getPageNum() {
+ return this.processedPageInfo.getPageNum();
+ }
+
+ public int getTotalPages() {
+ return this.processedPageInfo.getTotalPages();
+ }
+
+ public int getNumOfHits() {
+ return this.processedPageInfo.getNumOfHits();
+ }
+
+ public QueryExpression getQueryExpression() {
+ return queryExpression;
+ }
+
+ public Set<String> getRestrictToCatalogIds() {
+ return restrictToCatalogIds;
+ }
+
+ public boolean isLastPage() {
+ return this.processedPageInfo.isLastPage();
+ }
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/PageInfo.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/PageInfo.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/PageInfo.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/PageInfo.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.page;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ */
+public class PageInfo {
+
+ protected int pageSize;
+ protected int pageNum;
+
+ public static final int LAST_PAGE = Integer.MAX_VALUE;
+ public static final int FIRST_PAGE = 1;
+
+ public PageInfo(int pageSize, int pageNum) {
+ this.pageSize = pageSize;
+ if (pageNum < 1)
+ this.pageNum = 1;
+ else
+ this.pageNum = pageNum;
+ }
+
+ public int getPageSize() {
+ return pageSize;
+ }
+
+ public int getPageNum() {
+ return pageNum;
+ }
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/ProcessedPageInfo.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/ProcessedPageInfo.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/ProcessedPageInfo.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/ProcessedPageInfo.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.page;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ */
+public class ProcessedPageInfo extends PageInfo {
+
+ protected int totalPages;
+ protected int numOfHits;
+
+ public ProcessedPageInfo(int pageSize, int pageNum, int numOfHits) {
+ super(pageSize, pageNum > ((int) Math.ceil((double) numOfHits / (double) pageSize)) ? ((int) Math.ceil((double) numOfHits / (double) pageSize)) : pageNum);
+ this.totalPages = ((int) Math.ceil((double) numOfHits / (double) pageSize));
+ this.numOfHits = numOfHits;
+ }
+
+ public int getTotalPages() {
+ return this.totalPages;
+ }
+
+ public int getNumOfHits() {
+ return this.numOfHits;
+ }
+
+ public boolean isLastPage() {
+ return this.pageNum == this.totalPages;
+ }
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/QueryPager.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/QueryPager.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/QueryPager.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/QueryPager.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.page;
+
+//JDK imports
+import java.util.Collections;
+import java.util.List;
+import java.util.Vector;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A pager for paging through query results
+ * <p>
+ */
+public class QueryPager extends IndexPager {
+
+ protected List<TransactionReceipt> receipts;
+
+ public QueryPager(List<TransactionReceipt> receipts) {
+ super();
+ this.receipts = new Vector<TransactionReceipt>(receipts);
+ this.totalPages = this.caculateTotalPages();
+ this.numOfHits = receipts.size();
+ }
+
+ protected int caculateTotalPages() {
+ return (int) Math.ceil((double) receipts.size() / (double) this.getPageSize());
+ }
+
+ public void setPageInfo(PageInfo pageInfo) {
+ this.pageSize = Math.max(pageInfo.getPageSize(), 0);
+ this.totalPages = this.caculateTotalPages();
+ if (this.totalPages == 0)
+ this.pageNum = 0;
+ else
+ this.pageNum = (pageInfo.getPageNum() == PageInfo.LAST_PAGE || pageInfo.getPageNum() >= this.totalPages) ? this.totalPages : pageInfo.getPageNum();
+ }
+
+ public List<TransactionReceipt> getTransactionReceipts() {
+ return Collections.unmodifiableList(this.receipts);
+ }
+
+ public List<TransactionReceipt> getCurrentPage() {
+ List<TransactionReceipt> currentPage = new Vector<TransactionReceipt>();
+ if (this.pageNum > 0)
+ for (int i = (this.getPageNum() - 1) * this.getPageSize(); i < receipts.size() && i < this.getPageNum() * this.getPageSize(); i++)
+ currentPage.add(receipts.get(i));
+ return currentPage;
+ }
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/TransactionReceipt.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/TransactionReceipt.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/TransactionReceipt.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/page/TransactionReceipt.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.page;
+
+//JDK imports
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.Vector;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.struct.TransactionId;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A Reciept created by performing a transaction with a CatalogService
+ * <p>
+ */
+public class TransactionReceipt {
+
+ protected TransactionId<?> transactionId;
+ protected Set<String> catalogIds;
+ protected Date transactionDate;
+ protected Vector<CatalogReceipt> catalogReceipts;
+
+ public TransactionReceipt(TransactionId<?> transactionId, List<CatalogReceipt> catalogReceipts) {
+ this.transactionId = transactionId;
+ this.catalogIds = new HashSet<String>();
+ this.catalogReceipts = new Vector<CatalogReceipt>(catalogReceipts);
+ for (CatalogReceipt catalogReceipt : catalogReceipts) {
+ this.catalogIds.add(catalogReceipt.getCatalogId());
+ if (this.transactionDate == null)
+ this.transactionDate = catalogReceipt.getTransactionDate();
+ else if (this.transactionDate.before(catalogReceipt.getTransactionDate()))
+ this.transactionDate = catalogReceipt.getTransactionDate();
+ }
+ }
+
+ public TransactionId<?> getTransactionId() {
+ return this.transactionId;
+ }
+
+ public Set<String> getCatalogIds() {
+ return this.catalogIds;
+ }
+
+ public Date getTransactionDate() {
+ return this.transactionDate;
+ }
+
+ public List<CatalogReceipt> getCatalogReceipts() {
+ return Collections.unmodifiableList(this.catalogReceipts);
+ }
+
+ public int hashCode() {
+ return this.transactionId.hashCode();
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof TransactionReceipt) {
+ return this.transactionId.equals(((TransactionReceipt) obj).transactionId);
+ }else {
+ return false;
+ }
+ }
+
+ public String toString() {
+ return this.transactionId + ":" + this.catalogIds;
+ }
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/ComparisonQueryExpression.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/ComparisonQueryExpression.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/ComparisonQueryExpression.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/ComparisonQueryExpression.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.query;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A TermQueryExpression which allows Term comparison
+ * <p>
+ */
+public class ComparisonQueryExpression extends TermQueryExpression {
+
+ public static enum Operator { EQUAL_TO("=="), LESS_THAN_EQUAL_TO("<="), GREATER_THAN_EQUAL_TO(">="), LESS_THAN("<"), GREATER_THAN(">"), LIKE("LIKE");
+
+ private String value;
+
+ Operator(String value) {
+ this.value = value;
+ }
+
+ public static Operator getOperatorBySign(String sign) {
+ if (EQUAL_TO.value.equals(sign))
+ return EQUAL_TO;
+ else if (LESS_THAN_EQUAL_TO.value.equals(sign))
+ return LESS_THAN_EQUAL_TO;
+ else if (GREATER_THAN_EQUAL_TO.value.equals(sign))
+ return GREATER_THAN_EQUAL_TO;
+ else if (LESS_THAN.value.equals(sign))
+ return LESS_THAN;
+ else if (GREATER_THAN.value.equals(sign))
+ return GREATER_THAN;
+ else if (LIKE.value.equals(sign))
+ return LIKE;
+ else
+ throw new IllegalArgumentException("Not matching operator for '" + sign + "'");
+ }
+
+ public String toString() {
+ return this.value;
+ }
+
+ }
+ protected Operator operator;
+
+ public void setOperator(Operator operator) {
+ this.operator = operator;
+ }
+
+ public Operator getOperator() {
+ return this.operator;
+ }
+
+ @Override
+ public String toString() {
+ return "({" + this.bucketNames + "} " + this.getTerm().getName() + " " + this.operator + " " + this.getTerm().getValues() + ")";
+ }
+
+ @Override
+ public ComparisonQueryExpression clone() {
+ ComparisonQueryExpression newQE = new ComparisonQueryExpression();
+ newQE.operator = this.operator;
+ newQE.setTerm(this.term.clone());
+ newQE.setBucketNames(this.getBucketNames());
+ return newQE;
+ }
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/CustomQueryExpression.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/CustomQueryExpression.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/CustomQueryExpression.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/CustomQueryExpression.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.query;
+
+//JDK imports
+import java.util.Properties;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A Configurable QueryExpression
+ * <p>
+ */
+public class CustomQueryExpression extends QueryExpression {
+
+ protected Properties properties;
+ protected String name;
+
+ public CustomQueryExpression(String name) {
+ this(name, new Properties());
+ }
+
+ public CustomQueryExpression(String name, Properties properties) {
+ super();
+ this.name = name;
+ if (properties != null)
+ this.properties = properties;
+ else
+ this.properties = new Properties();
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setProperty(String key, String value) {
+ this.properties.put(key, value);
+ }
+
+ public String getProperty(String key) {
+ return this.properties.getProperty(key);
+ }
+
+ @Override
+ public CustomQueryExpression clone() {
+ CustomQueryExpression cqe = new CustomQueryExpression(this.name, (Properties) this.properties.clone());
+ cqe.setBucketNames(this.getBucketNames());
+ return cqe;
+ }
+
+ @Override
+ public String toString() {
+ return "({" + this.bucketNames + "} " + this.name + " : " + this.properties.toString() + ")";
+ }
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/CustomWrapperQueryExpression.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/CustomWrapperQueryExpression.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/CustomWrapperQueryExpression.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/CustomWrapperQueryExpression.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.query;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ */
+public class CustomWrapperQueryExpression extends WrapperQueryExpression {
+
+ protected String meaning;
+
+ public CustomWrapperQueryExpression(String meaning) {
+ this.meaning = meaning;
+ }
+
+ public CustomWrapperQueryExpression(String meaning, QueryExpression queryExpression) {
+ super(queryExpression);
+ this.meaning = meaning;
+ }
+
+ public String getMeaning() {
+ return this.meaning;
+ }
+
+ @Override
+ public CustomWrapperQueryExpression clone() {
+ CustomWrapperQueryExpression cwqe = new CustomWrapperQueryExpression(this.meaning, this.queryExpression.clone());
+ cwqe.setBucketNames(this.bucketNames);
+ return cwqe;
+ }
+
+ @Override
+ public String toString() {
+ return "({" + this.bucketNames + "} " + this.meaning + "(" + this.queryExpression + "))";
+ }
+
+ @Override
+ public boolean isValidWithNoSubExpression() {
+ return false;
+ }
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/FreeTextQueryExpression.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/FreeTextQueryExpression.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/FreeTextQueryExpression.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/FreeTextQueryExpression.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.query;
+
+//JDK imports
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+/**
+ * @author woollard
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A Free Text TermQueryExpression
+ * </p>
+ *
+ */
+public class FreeTextQueryExpression extends TermQueryExpression {
+
+ private HashSet<String> noiseWordHash = new HashSet<String>(
+ Arrays.asList(new String[] { "a", "all", "am", "an", "and",
+ "any", "are", "as", "at", "be", "but", "can", "did", "do", "does",
+ "for", "from", "had", "has", "have", "here", "how", "i", "if",
+ "in", "is", "it", "no", "not", "of", "on", "or", "so", "that",
+ "the", "then", "there", "this", "to", "too", "up", "use", "what",
+ "when", "where", "who", "why", "you" }));
+
+ /**
+ * A method for adding unparsed free text to the FreeTextCriteria. Free text
+ * entered as a string is tokenized and punctuation and common words are
+ * dropped before the values are added to the query. In order to query for
+ * pre-parsed keywords, see the setValues method of this class.
+ *
+ * @param text
+ * The free text to be parsed and searched on.
+ */
+ public void addFreeText(String text) {
+ // remove punctuation from the text
+ text = text.replaceAll("\\p{Punct}+", "");
+
+ // tokenize string using default delimiters
+ StringTokenizer tok = new StringTokenizer(text);
+ String token = null;
+
+ // filter noise words and add to values vector
+ List<String> values = new Vector<String>();
+ while (tok.hasMoreElements()) {
+ token = tok.nextToken();
+ if (!noiseWordHash.contains(token))
+ values.add(token);
+ }
+ if (values.size() > 0) {
+ values.addAll(this.term.getValues());
+ this.term.setValues(values);
+ }
+ }
+
+ /**
+ * Implementation of the abstract method inherited from QueryCriteria for
+ * generating a human-parsable string version of the query criteria. Note
+ * that the returned String follows the Lucene query language.
+ *
+ * @return The query as a String.
+ */
+ public String toString() {
+ String serial = "({" + this.bucketNames + "} " + this.term.getName() + " :|";
+ for (String value : this.term.getValues())
+ serial += "+" + value;
+ serial += "|: )";
+ return serial;
+ }
+
+ @Override
+ public FreeTextQueryExpression clone() {
+ FreeTextQueryExpression ftQE = new FreeTextQueryExpression();
+ ftQE.noiseWordHash = new HashSet<String>(this.noiseWordHash);
+ ftQE.setTerm(this.term.clone());
+ ftQE.setBucketNames(this.bucketNames);
+ return ftQE;
+ }
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/NotQueryExpression.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/NotQueryExpression.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/NotQueryExpression.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/NotQueryExpression.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.query;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A WrapperQueryExpression which signifies negation of wrapped QueryExpression
+ * <p>
+ */
+public class NotQueryExpression extends WrapperQueryExpression {
+
+ public NotQueryExpression() {
+ super();
+ }
+
+ public NotQueryExpression(QueryExpression queryExpression) {
+ super(queryExpression);
+ }
+
+ @Override
+ public NotQueryExpression clone() {
+ NotQueryExpression nqe = new NotQueryExpression(this.queryExpression.clone());
+ nqe.setBucketNames(this.getBucketNames());
+ return nqe;
+ }
+
+ @Override
+ public String toString() {
+ return "(NOT (" + this.queryExpression + "))";
+ }
+
+ @Override
+ public boolean isValidWithNoSubExpression() {
+ return false;
+ }
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/QueryExpression.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/QueryExpression.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/QueryExpression.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/QueryExpression.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.query;
+
+//JDK imports
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A Expression for querying against a CatalogServices Metadata
+ * <p>
+ */
+public abstract class QueryExpression implements Cloneable {
+
+ protected Set<String> bucketNames;
+
+ public QueryExpression() {}
+
+ public QueryExpression(Set<String> bucketNames) {
+ this.bucketNames = new HashSet<String>(bucketNames);
+ }
+
+ public Set<String> getBucketNames() {
+ return (this.bucketNames != null) ? new HashSet<String>(this.bucketNames) : null;
+ }
+
+ public void setBucketNames(Set<String> bucketNames) {
+ this.bucketNames = bucketNames;
+ }
+
+ public abstract String toString();
+
+ public abstract QueryExpression clone();
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/QueryLogicalGroup.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/QueryLogicalGroup.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/QueryLogicalGroup.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/QueryLogicalGroup.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.query;
+
+//JDK imports
+import java.util.Collections;
+import java.util.List;
+import java.util.Vector;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A QueryExpression which groups other QueryExpressions
+ * <p>
+ */
+public class QueryLogicalGroup extends QueryExpression {
+
+ public enum Operator { AND, OR }
+
+ protected Operator operator;
+
+ protected List<QueryExpression> queryExpressions;
+
+ public QueryLogicalGroup() {
+ this(new Vector<QueryExpression>(), Operator.AND);
+ }
+
+ public QueryLogicalGroup(List<QueryExpression> queryExpressions) {
+ this(queryExpressions, Operator.AND);
+ }
+
+ public QueryLogicalGroup(List<QueryExpression> queryExpressions, Operator operator) {
+ this.setExpressions(queryExpressions);
+ this.setOperator(operator);
+ }
+
+ public void setExpressions(List<QueryExpression> queryExpressions) {
+ this.queryExpressions = new Vector<QueryExpression>(queryExpressions);
+ }
+
+ /**
+ *
+ * @param queryCriteria
+ */
+ public void addExpression(QueryExpression queryExpression) {
+ this.queryExpressions.add(queryExpression);
+ }
+
+ /**
+ *
+ * @param queryCriterias
+ */
+ public void addExpressions(List<QueryExpression> queryExpressions) {
+ this.queryExpressions.addAll(queryExpressions);
+ }
+
+ /**
+ *
+ * @return
+ */
+ public List<QueryExpression> getExpressions() {
+ return Collections.unmodifiableList(this.queryExpressions);
+ }
+
+ /**
+ *
+ * @param operator
+ */
+ public void setOperator(Operator operator) {
+ this.operator = operator;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Operator getOperator() {
+ return this.operator;
+ }
+
+ @Override
+ public String toString() {
+ String query = "({" + this.bucketNames + "} " + this.operator + " : ";
+ for (QueryExpression queryExpression : this.queryExpressions)
+ query += queryExpression.toString() + ",";
+ return query.substring(0, query.length() - 1) + ")";
+ }
+
+ public QueryLogicalGroup clone() {
+ QueryLogicalGroup qlGroup = new QueryLogicalGroup();
+ qlGroup.setBucketNames(this.getBucketNames());
+ qlGroup.setOperator(this.operator);
+ for (QueryExpression qe : this.queryExpressions)
+ qlGroup.addExpression(qe.clone());
+ return qlGroup;
+ }
+
+}
\ No newline at end of file
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/StdQueryExpression.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/StdQueryExpression.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/StdQueryExpression.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/StdQueryExpression.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.query;
+
+//JDK imports
+import java.util.Set;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A Standard QueryExpression
+ * <p>
+ */
+public class StdQueryExpression extends QueryExpression {
+
+ public StdQueryExpression() {
+ super();
+ }
+
+ public StdQueryExpression(Set<String> bucketNames) {
+ super(bucketNames);
+ }
+
+ @Override
+ public StdQueryExpression clone() {
+ return new StdQueryExpression(this.getBucketNames());
+ }
+
+ @Override
+ public String toString() {
+ return "({" + this.bucketNames + "})";
+ }
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/TermQueryExpression.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/TermQueryExpression.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/TermQueryExpression.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/TermQueryExpression.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.query;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.term.Term;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A QueryExpression which wrappers a Term
+ * <p>
+ */
+public abstract class TermQueryExpression extends QueryExpression implements Cloneable {
+
+ protected Term term;
+
+ public Term getTerm() {
+ return this.term;
+ }
+
+ public void setTerm(Term term) {
+ this.term = term;
+ }
+
+ public abstract TermQueryExpression clone();
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/WrapperQueryExpression.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/WrapperQueryExpression.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/WrapperQueryExpression.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/WrapperQueryExpression.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.query;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A QueryExpression which wrappers another QueryExpression
+ * <p>
+ */
+public abstract class WrapperQueryExpression extends QueryExpression {
+
+ protected QueryExpression queryExpression;
+
+ public WrapperQueryExpression() {
+ super();
+ }
+
+ public WrapperQueryExpression(QueryExpression queryExpression) {
+ this();
+ this.queryExpression = queryExpression;
+ }
+
+ public QueryExpression getQueryExpression() {
+ return queryExpression;
+ }
+
+ public void setQueryExpression(QueryExpression queryExpression) {
+ this.queryExpression = queryExpression;
+ }
+
+ @Override
+ public String toString() {
+ return "(" + this.queryExpression + ")";
+ }
+
+ public abstract boolean isValidWithNoSubExpression();
+
+ public abstract WrapperQueryExpression clone();
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/FilterAlgorithm.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/FilterAlgorithm.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/FilterAlgorithm.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/FilterAlgorithm.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.query.filter;
+
+//JDK imports
+import java.util.List;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * An algorithm interface for defining how QueryFilter filters query results
+ * <p>
+ */
+public abstract class FilterAlgorithm<FilterType> {
+
+ public abstract List<FilterType> filter(List<FilterType> events);
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/QueryFilter.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/QueryFilter.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/QueryFilter.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/QueryFilter.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.query.filter;
+
+//JDK imports
+import java.util.List;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.metadata.TransactionalMetadata;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A Filter interface for filtering queries
+ * <p>
+ */
+public abstract class QueryFilter<FilterType> {
+
+ protected FilterAlgorithm<FilterType> filterAlgorithm;
+
+ public QueryFilter() {}
+
+ public QueryFilter(FilterAlgorithm<FilterType> filterAlgorithm) {
+ super();
+ this.filterAlgorithm = filterAlgorithm;
+ }
+
+ public void setFilterAlgorithm(FilterAlgorithm<FilterType> filterAlgorithm) {
+ this.filterAlgorithm = filterAlgorithm;
+ }
+
+ public FilterAlgorithm<FilterType> getFilterAlgorithm() {
+ return this.filterAlgorithm;
+ }
+
+ public List<TransactionalMetadata> filterMetadataList(List<TransactionalMetadata> metadataToFilter) {
+ return this.filterTypeToMetadata(this.filterAlgorithm.filter(this.metadataToFilterType(metadataToFilter)));
+ }
+
+ protected abstract List<FilterType> metadataToFilterType(List<TransactionalMetadata> metadataList);
+
+ protected abstract List<TransactionalMetadata> filterTypeToMetadata(List<FilterType> filterObjects);
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/time/MetadataTimeEvent.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/time/MetadataTimeEvent.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/time/MetadataTimeEvent.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/time/MetadataTimeEvent.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.query.filter.time;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.metadata.TransactionalMetadata;
+import org.apache.oodt.commons.filter.ObjectTimeEvent;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A ObjectTimeEvent that holds TermBuckets
+ * <p>
+ */
+public class MetadataTimeEvent extends ObjectTimeEvent<TransactionalMetadata> {
+
+ public MetadataTimeEvent(long startTime, long endTime, TransactionalMetadata timeObj) {
+ super(startTime, endTime, timeObj);
+ }
+
+ public MetadataTimeEvent(long startTime, long endTime, double priority, TransactionalMetadata timeObj) {
+ super(startTime, endTime, priority, timeObj);
+ }
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/time/MetadataTimeEventFilterAlgorithm.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/time/MetadataTimeEventFilterAlgorithm.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/time/MetadataTimeEventFilterAlgorithm.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/time/MetadataTimeEventFilterAlgorithm.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.query.filter.time;
+
+//JDK imports
+import java.util.Collections;
+import java.util.List;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.query.filter.FilterAlgorithm;
+import org.apache.oodt.commons.filter.TimeEventWeightedHash;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ */
+public class MetadataTimeEventFilterAlgorithm extends FilterAlgorithm<MetadataTimeEvent> {
+
+ protected long epsilon;
+
+ public MetadataTimeEventFilterAlgorithm() {
+ this.epsilon = 0;
+ }
+
+ public MetadataTimeEventFilterAlgorithm(long epsilon) {
+ this.epsilon = epsilon;
+ }
+
+ public void setEpsilon(long epsilon) {
+ this.epsilon = epsilon;
+ }
+
+ public long getEpsilon() {
+ return this.epsilon;
+ }
+
+ @Override
+ public List<MetadataTimeEvent> filter(List<MetadataTimeEvent> events) {
+ TimeEventWeightedHash timeEventHash = TimeEventWeightedHash.buildHash(events, this.epsilon);
+ return Collections.unmodifiableList((List<MetadataTimeEvent>) timeEventHash.getGreatestWeightedPathAsOrderedList());
+ }
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/time/MetadataTimeEventQueryFilter.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/time/MetadataTimeEventQueryFilter.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/time/MetadataTimeEventQueryFilter.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/time/MetadataTimeEventQueryFilter.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.query.filter.time;
+
+//JDK imports
+import java.util.Collections;
+import java.util.List;
+import java.util.Vector;
+
+//OODT imports
+import org.apache.oodt.cas.catalog.metadata.TransactionalMetadata;
+import org.apache.oodt.cas.catalog.query.filter.QueryFilter;
+import org.apache.oodt.cas.catalog.query.filter.time.conv.AsciiSortableVersionConverter;
+import org.apache.oodt.cas.catalog.query.filter.time.conv.VersionConverter;
+
+//OODT imports
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A query filter that allows user to filter results in a complex query
+ * <p>
+ */
+public class MetadataTimeEventQueryFilter extends QueryFilter<MetadataTimeEvent> {
+
+ private String startDateTimeMetKey, endDateTimeMetKey, priorityMetKey;
+ private VersionConverter converter;
+
+ public MetadataTimeEventQueryFilter() {
+ super();
+ this.converter = new AsciiSortableVersionConverter();
+ }
+
+ public String getStartDateTimeMetKey() {
+ return startDateTimeMetKey;
+ }
+
+ public void setStartDateTimeMetKey(String startDateTimeMetKey) {
+ this.startDateTimeMetKey = startDateTimeMetKey;
+ }
+
+ public String getEndDateTimeMetKey() {
+ return endDateTimeMetKey;
+ }
+
+ public void setEndDateTimeMetKey(String endDateTimeMetKey) {
+ this.endDateTimeMetKey = endDateTimeMetKey;
+ }
+
+ public String getPriorityMetKey() {
+ return priorityMetKey;
+ }
+
+ public void setPriorityMetKey(String priorityMetKey) {
+ this.priorityMetKey = priorityMetKey;
+ }
+
+ public VersionConverter getConverter() {
+ return converter;
+ }
+
+ public void setConverter(VersionConverter converter) {
+ if (converter != null)
+ this.converter = converter;
+ }
+
+ @Override
+ protected List<MetadataTimeEvent> metadataToFilterType(List<TransactionalMetadata> metadataList) {
+ List<MetadataTimeEvent> timeEvents = new Vector<MetadataTimeEvent>();
+ for (TransactionalMetadata transactionalMetadata : metadataList) {
+ double priority = 0;
+ if (this.getPriorityMetKey() != null)
+ priority = Double.parseDouble(transactionalMetadata.getMetadata().getMetadata(this.priorityMetKey));
+ long startTime = Long.parseLong(transactionalMetadata.getMetadata().getMetadata(this.startDateTimeMetKey));
+ String endTimeString = transactionalMetadata.getMetadata().getMetadata(this.endDateTimeMetKey);
+ long endTime = startTime;
+ if (endTimeString != null)
+ endTime = Long.parseLong(endTimeString);
+ timeEvents.add(new MetadataTimeEvent(startTime, endTime, priority, transactionalMetadata));
+ }
+ return Collections.unmodifiableList(timeEvents);
+ }
+
+ @Override
+ protected List<TransactionalMetadata> filterTypeToMetadata(List<MetadataTimeEvent> filterObjects) {
+ List<TransactionalMetadata> metadataList = new Vector<TransactionalMetadata>();
+ for (MetadataTimeEvent timeEvent : filterObjects)
+ metadataList.add(timeEvent.getTimeObject());
+ return Collections.unmodifiableList(metadataList);
+ }
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/time/conv/AsciiSortableVersionConverter.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/time/conv/AsciiSortableVersionConverter.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/time/conv/AsciiSortableVersionConverter.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/time/conv/AsciiSortableVersionConverter.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.query.filter.time.conv;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * Converts a ascii sortable String version into a priority number
+ * <p>
+ */
+public class AsciiSortableVersionConverter implements VersionConverter {
+
+ public double convertToPriority(String version) throws Exception {
+ double priority = 0;
+ char[] versionCharArray = version.toCharArray();
+ for (int i = 0, j = versionCharArray.length - 1; i < versionCharArray.length; i++, j--)
+ priority += (((int) versionCharArray[i]) * Math.pow(10, j));
+ return priority;
+ }
+
+}
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/time/conv/VersionConverter.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/time/conv/VersionConverter.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/time/conv/VersionConverter.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/filter/time/conv/VersionConverter.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.catalog.query.filter.time.conv;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * An interface for converting a String version into a priority number
+ * <p>
+ */
+public interface VersionConverter {
+
+ public double convertToPriority(String version) throws Exception;
+
+}