You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2009/07/07 14:15:26 UTC
svn commit: r791808 - in /lenya/branches/BRANCH_2_0_X: ./
src/impl/java/org/apache/lenya/cms/metadata/
src/impl/test/org/apache/lenya/cms/metadata/
src/java/org/apache/lenya/cms/metadata/
src/modules/lucene/java/src/org/apache/cocoon/components/search/...
Author: andreas
Date: Tue Jul 7 12:15:26 2009
New Revision: 791808
URL: http://svn.apache.org/viewvc?rev=791808&view=rev
Log:
Reverting change: Added support for meta data index types. Requires Java 1.5, will be postponed.
Modified:
lenya/branches/BRANCH_2_0_X/build.properties
lenya/branches/BRANCH_2_0_X/src/impl/java/org/apache/lenya/cms/metadata/ConfigurableElementSet.java
lenya/branches/BRANCH_2_0_X/src/impl/java/org/apache/lenya/cms/metadata/ElementImpl.java
lenya/branches/BRANCH_2_0_X/src/impl/test/org/apache/lenya/cms/metadata/MetaDataTest.java
lenya/branches/BRANCH_2_0_X/src/java/org/apache/lenya/cms/metadata/Element.java
lenya/branches/BRANCH_2_0_X/src/modules/lucene/java/src/org/apache/cocoon/components/search/components/impl/IndexManagerImpl.java
lenya/branches/BRANCH_2_0_X/src/modules/lucene/java/src/org/apache/lenya/modules/lucene/MetaDataFieldRegistry.java
lenya/branches/BRANCH_2_0_X/src/modules/lucene/java/src/org/apache/lenya/modules/lucene/impl/MetaDataFieldRegistryImpl.java
Modified: lenya/branches/BRANCH_2_0_X/build.properties
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_0_X/build.properties?rev=791808&r1=791807&r2=791808&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_0_X/build.properties (original)
+++ lenya/branches/BRANCH_2_0_X/build.properties Tue Jul 7 12:15:26 2009
@@ -161,7 +161,7 @@
#------------------------------------------------------------------------------------
# The Java version.
-src.java.version=1.5
+src.java.version=1.4
#------------------------------------------------------------------------------------
Modified: lenya/branches/BRANCH_2_0_X/src/impl/java/org/apache/lenya/cms/metadata/ConfigurableElementSet.java
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_0_X/src/impl/java/org/apache/lenya/cms/metadata/ConfigurableElementSet.java?rev=791808&r1=791807&r2=791808&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_0_X/src/impl/java/org/apache/lenya/cms/metadata/ConfigurableElementSet.java (original)
+++ lenya/branches/BRANCH_2_0_X/src/impl/java/org/apache/lenya/cms/metadata/ConfigurableElementSet.java Tue Jul 7 12:15:26 2009
@@ -30,7 +30,6 @@
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.lenya.cms.metadata.Element.IndexType;
/**
* Avalon-based element set.
@@ -39,23 +38,20 @@
ThreadSafe, Initializable, Serviceable {
private String namespaceUri;
- private Map<String, Element> elements = new HashMap<String, Element>();
+ private Map elements = new HashMap();
public void configure(Configuration config) throws ConfigurationException {
this.namespaceUri = config.getAttribute("name");
- for (Configuration elemConfig : config.getChildren("element")) {
- String name = elemConfig.getAttribute("name");
- boolean isMultiple = elemConfig.getAttributeAsBoolean("multiple", false);
- boolean isEditable = elemConfig.getAttributeAsBoolean("editable", false);
- boolean isSearchable = elemConfig.getAttributeAsBoolean("searchable", false);
- String actionOnCopy = elemConfig.getAttribute("onCopy", "copy");
+ Configuration[] attributeConfigs = config.getChildren("element");
+ for (int i = 0; i < attributeConfigs.length; i++) {
+ String name = attributeConfigs[i].getAttribute("name");
+ boolean isMultiple = attributeConfigs[i].getAttributeAsBoolean("multiple", false);
+ boolean isEditable = attributeConfigs[i].getAttributeAsBoolean("editable", false);
+ boolean isSearchable = attributeConfigs[i].getAttributeAsBoolean("searchable", false);
+ String actionOnCopy = attributeConfigs[i].getAttribute("onCopy", "copy");
ElementImpl element = new ElementImpl(name, isMultiple, isEditable, isSearchable);
-
- String indexTypeString = elemConfig.getAttribute("indexType", "text");
- element.setIndexType(getIndexType(indexTypeString));
-
int action;
if (actionOnCopy.equalsIgnoreCase("copy")) {
action = Element.ONCOPY_COPY;
@@ -79,23 +75,8 @@
}
- protected IndexType getIndexType(String indexTypeString) throws ConfigurationException {
- if (indexTypeString.equals("text")) {
- return IndexType.TEXT;
- }
- else if (indexTypeString.equals("keyword")) {
- return IndexType.KEYWORD;
- }
- else if (indexTypeString.equals("date")) {
- return IndexType.DATE;
- }
- else {
- throw new ConfigurationException("Unsupported index type: '" + indexTypeString + "'");
- }
- }
-
public Element[] getElements() {
- Collection<Element> values = this.elements.values();
+ Collection values = this.elements.values();
return (Element[]) values.toArray(new Element[values.size()]);
}
Modified: lenya/branches/BRANCH_2_0_X/src/impl/java/org/apache/lenya/cms/metadata/ElementImpl.java
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_0_X/src/impl/java/org/apache/lenya/cms/metadata/ElementImpl.java?rev=791808&r1=791807&r2=791808&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_0_X/src/impl/java/org/apache/lenya/cms/metadata/ElementImpl.java (original)
+++ lenya/branches/BRANCH_2_0_X/src/impl/java/org/apache/lenya/cms/metadata/ElementImpl.java Tue Jul 7 12:15:26 2009
@@ -17,8 +17,6 @@
*/
package org.apache.lenya.cms.metadata;
-import org.apache.lenya.util.Assert;
-
/**
* Element implementation.
*/
@@ -30,7 +28,6 @@
private boolean editable;
private int actionOnCopy;
private boolean searchable;
- private IndexType indexType;
/**
* Ctor.
@@ -90,14 +87,5 @@
public boolean isSearchable() {
return this.searchable;
}
-
- public void setIndexType(IndexType indexType) {
- Assert.notNull("index type", indexType);
- this.indexType = indexType;
- }
-
- public IndexType getIndexType() {
- return this.indexType;
- }
}
Modified: lenya/branches/BRANCH_2_0_X/src/impl/test/org/apache/lenya/cms/metadata/MetaDataTest.java
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_0_X/src/impl/test/org/apache/lenya/cms/metadata/MetaDataTest.java?rev=791808&r1=791807&r2=791808&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_0_X/src/impl/test/org/apache/lenya/cms/metadata/MetaDataTest.java (original)
+++ lenya/branches/BRANCH_2_0_X/src/impl/test/org/apache/lenya/cms/metadata/MetaDataTest.java Tue Jul 7 12:15:26 2009
@@ -155,10 +155,6 @@
return false;
}
- public IndexType getIndexType() {
- return IndexType.TEXT;
- }
-
}
protected class TestElementSet implements ElementSet {
Modified: lenya/branches/BRANCH_2_0_X/src/java/org/apache/lenya/cms/metadata/Element.java
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_0_X/src/java/org/apache/lenya/cms/metadata/Element.java?rev=791808&r1=791807&r2=791808&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_0_X/src/java/org/apache/lenya/cms/metadata/Element.java (original)
+++ lenya/branches/BRANCH_2_0_X/src/java/org/apache/lenya/cms/metadata/Element.java Tue Jul 7 12:15:26 2009
@@ -22,10 +22,6 @@
*/
public interface Element {
- enum IndexType {
- KEYWORD, TEXT, DATE
- }
-
/**
* @return the name of the element.
*/
@@ -50,7 +46,7 @@
* Copy all values if the meta data are copied.
*/
int ONCOPY_COPY = 0;
-
+
/**
* Don't copy the values of this element if the meta data are copied.
*/
@@ -65,12 +61,10 @@
* @return The action to be taken when meta data are copied from one owner to another.
*/
int getActionOnCopy();
-
+
/**
* @return If this element shall be included in search queries.
*/
boolean isSearchable();
-
- IndexType getIndexType();
}
Modified: lenya/branches/BRANCH_2_0_X/src/modules/lucene/java/src/org/apache/cocoon/components/search/components/impl/IndexManagerImpl.java
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_0_X/src/modules/lucene/java/src/org/apache/cocoon/components/search/components/impl/IndexManagerImpl.java?rev=791808&r1=791807&r2=791808&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_0_X/src/modules/lucene/java/src/org/apache/cocoon/components/search/components/impl/IndexManagerImpl.java (original)
+++ lenya/branches/BRANCH_2_0_X/src/modules/lucene/java/src/org/apache/cocoon/components/search/components/impl/IndexManagerImpl.java Tue Jul 7 12:15:26 2009
@@ -43,10 +43,14 @@
import org.apache.excalibur.source.SourceResolver;
import org.apache.excalibur.source.SourceUtil;
import org.apache.lenya.cms.cocoon.components.context.ContextUtility;
+import org.apache.lenya.cms.metadata.Element;
+import org.apache.lenya.cms.metadata.ElementSet;
import org.apache.lenya.cms.metadata.MetaDataException;
+import org.apache.lenya.cms.metadata.MetaDataRegistry;
import org.apache.lenya.cms.publication.DocumentFactory;
import org.apache.lenya.cms.publication.DocumentUtil;
import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.PublicationException;
import org.apache.lenya.cms.publication.PublicationManager;
import org.apache.lenya.modules.lucene.MetaDataFieldRegistry;
@@ -107,7 +111,8 @@
/**
* type of the field: "text, "keyword", "date" (see
*
- * @see org.apache.cocoon.components.search.fieldmodel.FieldDefinition class)
+ * @see org.apache.cocoon.components.search.fieldmodel.FieldDefinition
+ * class)
*/
public static final String TYPE_ATTRIBUTE = "type";
@@ -127,8 +132,8 @@
public static final String INDEX_CONF_FILE = "search/lucene_index.xml";
/**
- * check the config file each time the getIndex is called to update if necessary the
- * configuration
+ * check the config file each time the getIndex is called to update if
+ * necessary the configuration
*/
// public static final String CHECK_ATTRIBUTE = "check";
/**
@@ -136,7 +141,8 @@
*/
// public static final String CONFIG_ATTRIBUTE = "config";
/**
- * Check or not the configuration file (automatic update if the file is changed)
+ * Check or not the configuration file (automatic update if the file is
+ * changed)
*/
// private boolean check;
/**
@@ -192,9 +198,7 @@
/*
* (non-Javadoc)
*
- * @see
- * org.apache.cocoon.components.search.components.IndexManager#addIndex(org.apache.cocoon.components
- * .search.Index)
+ * @see org.apache.cocoon.components.search.components.IndexManager#addIndex(org.apache.cocoon.components.search.Index)
*/
public void addIndex(Index base) {
this.indexes().put(base.getID(), base);
@@ -259,9 +263,7 @@
/*
* (non-Javadoc)
*
- * @see
- * org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework
- * .configuration.Configuration)
+ * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
*/
public void configure(Configuration configuration) throws ConfigurationException {
this.indexerRole = configuration.getChild(INDEXER_ELEMENT).getAttribute(
@@ -315,13 +317,12 @@
IndexStructure docdecl = new IndexStructure();
addMetaDataFieldDefinitions(registry, docdecl);
-
+
FieldDefinition uuidDef = FieldDefinition.create("uuid", FieldDefinition.KEYWORD);
uuidDef.setStore(true);
docdecl.addFieldDef(uuidDef);
- FieldDefinition langDef = FieldDefinition.create("language",
- FieldDefinition.KEYWORD);
+ FieldDefinition langDef = FieldDefinition.create("language", FieldDefinition.KEYWORD);
langDef.setStore(true);
docdecl.addFieldDef(langDef);
@@ -399,8 +400,11 @@
protected void addMetaDataFieldDefinitions(MetaDataFieldRegistry registry,
IndexStructure indexStructure) throws MetaDataException {
- for (FieldDefinition def : registry.getFieldDefinitions()) {
- indexStructure.addFieldDef(def);
+ String[] fieldNames = registry.getFieldNames();
+ for (int i = 0; i < fieldNames.length; i++) {
+ FieldDefinition fieldDef = FieldDefinition.create(fieldNames[i], FieldDefinition.TEXT);
+ fieldDef.setStore(false);
+ indexStructure.addFieldDef(fieldDef);
}
}
@@ -431,7 +435,6 @@
/*
* (non-Javadoc)
- *
* @see org.apache.cocoon.components.search.components.IndexManager#getIndex()
*/
public Index[] getIndex() {
@@ -440,10 +443,7 @@
/*
* (non-Javadoc)
- *
- * @see
- * org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service
- * .ServiceManager)
+ * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
*/
public void service(ServiceManager manager) throws ServiceException {
this.manager = manager;
Modified: lenya/branches/BRANCH_2_0_X/src/modules/lucene/java/src/org/apache/lenya/modules/lucene/MetaDataFieldRegistry.java
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_0_X/src/modules/lucene/java/src/org/apache/lenya/modules/lucene/MetaDataFieldRegistry.java?rev=791808&r1=791807&r2=791808&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_0_X/src/modules/lucene/java/src/org/apache/lenya/modules/lucene/MetaDataFieldRegistry.java (original)
+++ lenya/branches/BRANCH_2_0_X/src/modules/lucene/java/src/org/apache/lenya/modules/lucene/MetaDataFieldRegistry.java Tue Jul 7 12:15:26 2009
@@ -16,10 +16,6 @@
*/
package org.apache.lenya.modules.lucene;
-import java.util.Set;
-
-import org.apache.cocoon.components.search.fieldmodel.FieldDefinition;
-
/**
* Map meta data elements to Lucene index fields.
*/
@@ -41,7 +37,5 @@
* @return All field names.
*/
String[] getFieldNames();
-
- Set<FieldDefinition> getFieldDefinitions();
}
Modified: lenya/branches/BRANCH_2_0_X/src/modules/lucene/java/src/org/apache/lenya/modules/lucene/impl/MetaDataFieldRegistryImpl.java
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_0_X/src/modules/lucene/java/src/org/apache/lenya/modules/lucene/impl/MetaDataFieldRegistryImpl.java?rev=791808&r1=791807&r2=791808&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_0_X/src/modules/lucene/java/src/org/apache/lenya/modules/lucene/impl/MetaDataFieldRegistryImpl.java (original)
+++ lenya/branches/BRANCH_2_0_X/src/modules/lucene/java/src/org/apache/lenya/modules/lucene/impl/MetaDataFieldRegistryImpl.java Tue Jul 7 12:15:26 2009
@@ -16,7 +16,6 @@
*/
package org.apache.lenya.modules.lucene.impl;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -27,7 +26,6 @@
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.cocoon.components.search.fieldmodel.FieldDefinition;
import org.apache.lenya.cms.metadata.Element;
import org.apache.lenya.cms.metadata.ElementSet;
import org.apache.lenya.cms.metadata.MetaDataRegistry;
@@ -101,39 +99,4 @@
return (String[]) fieldNames.toArray(new String[fieldNames.size()]);
}
- public Set<FieldDefinition> getFieldDefinitions() {
- final MetaDataRegistry registry = getRegistry();
- final Set<FieldDefinition> fieldDefs = new HashSet<FieldDefinition>();
- try {
- final String[] namespaces = registry.getNamespaceUris();
- for (int n = 0; n < namespaces.length; n++) {
- final ElementSet elementSet = registry.getElementSet(namespaces[n]);
- final Element[] elements = elementSet.getElements();
- for (int e = 0; e < elements.length; e++) {
- final String fieldName = getFieldName(namespaces[n], elements[e].getName());
- final FieldDefinition fieldDef = FieldDefinition.create(fieldName,
- getFieldType(elements[e].getIndexType()));
- fieldDef.setStore(false);
- fieldDefs.add(fieldDef);
- }
- }
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- return Collections.unmodifiableSet(fieldDefs);
- }
-
- protected int getFieldType(Element.IndexType indexType) {
- switch (indexType) {
- case TEXT:
- return FieldDefinition.TEXT;
- case KEYWORD:
- return FieldDefinition.KEYWORD;
- case DATE:
- return FieldDefinition.DATE;
- default:
- throw new IllegalArgumentException("Unsupported index type: " + indexType);
- }
- }
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org