You are viewing a plain text version of this content. The canonical link for it is here.
Posted to graffito-commits@incubator.apache.org by cl...@apache.org on 2005/09/24 08:00:34 UTC
svn commit: r291263 - in /incubator/graffito/trunk/jcr-mapping/src:
java/org/apache/portals/graffito/jcr/query/
java/org/apache/portals/graffito/jcr/query/impl/
test/org/apache/portals/graffito/jcr/
test/org/apache/portals/graffito/jcr/persistence/coll...
Author: clombart
Date: Sat Sep 24 01:00:20 2005
New Revision: 291263
URL: http://svn.apache.org/viewcvs?rev=291263&view=rev
Log:
Start the QueryManager Service.
* It is still a prototype. I'm just start it. Please, don't blame me, it is not yet finish :-)
* After make some experience, I will made a proposal to the team
Added:
incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/
incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/Filter.java
incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/Query.java
incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/QueryManager.java
incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/
incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/FilterImpl.java
incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/QueryImpl.java
incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/QueryManagerImpl.java
incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/query/
incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/query/impl/
incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/query/impl/QueryManagerTest.java
Modified:
incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java
incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImplTest.java
incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImplTest.java
Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/Filter.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/Filter.java?rev=291263&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/Filter.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/Filter.java Sat Sep 24 01:00:20 2005
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ * as applicable.
+ *
+ * Licensed 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.portals.graffito.jcr.query;
+
+import java.util.Collection;
+
+/**
+ *
+ * Graffito JCR Filter interface.
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ *
+ */
+public interface Filter
+{
+
+ public Class getFilterClass();
+
+ /**
+ * Set the filter scope. The scope is an Node path specifying where to search in the content tree.
+ * For example, if the scope is '/myserver1/myfolder', the search engine will search all objects
+ * which are located below '/myserver1/myfolder'.
+ *
+ * @param scope The filter scope
+ *
+ */
+ public void setScope(String scope);
+
+ /**
+ * Get the filter scope.
+ *
+ * @return The filter scope
+ */
+ public String getScope();
+
+ /**
+ * Search content based on a fullTextSearch.
+ * Depending on the full text search engine, you can also filter on properties.
+ *
+ * @param fullTextSearch The full text search string
+ */
+ public void addContains(String fullTextSearch);
+
+
+ public void addBetween(String arg0, Object arg1, Object arg2);
+
+ public void addEqualTo(String arg0, Object arg1);
+
+ public void addGreaterOrEqualThan(String arg0, Object arg1);
+
+ public void addGreaterThan(String arg0, Object arg1);
+
+ public void addIn(String attribute, Collection values);
+
+ public void addLessOrEqualThan(String arg0, Object arg1);
+
+ public void addLike(String arg0, Object arg1);
+
+ public abstract void addNotBetween(String arg0, Object arg1, Object arg2);
+
+ public void addNotEqualTo(String arg0, Object arg1);
+
+ public void addNotLike(String arg0, Object arg1);
+
+ public void addNotNull(String arg0);
+
+ public void addIsNull(String arg0);
+
+ public void addOrFilter(Filter arg0);
+
+ public void addJCRExpression(String jcrExpression);
+
+
+
+
+
+
+}
Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/Query.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/Query.java?rev=291263&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/Query.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/Query.java Sat Sep 24 01:00:20 2005
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ * as applicable.
+ *
+ * Licensed 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.portals.graffito.jcr.query;
+
+/**
+ * Graffito JCR Query interface
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ *
+ */
+public interface Query
+{
+
+
+ public void setFilter(Filter filter);
+
+ public Filter getFilter();
+
+}
Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/QueryManager.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/QueryManager.java?rev=291263&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/QueryManager.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/QueryManager.java Sat Sep 24 01:00:20 2005
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ * as applicable.
+ *
+ * Licensed 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.portals.graffito.jcr.query;
+
+import org.apache.portals.graffito.jcr.exception.JcrMappingException;
+
+/**
+ * The query manager is used to instantiate query objects and execute query based on the object model.
+ * Internally, this service used the JCR QueryManager
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ *
+ */
+public interface QueryManager
+{
+ public Filter createFilter(Class classQuery) throws JcrMappingException;
+
+ public Query createQuery(Filter filter);
+
+ public String buildJCRExpression(Query query) throws JcrMappingException;
+
+
+}
Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/FilterImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/FilterImpl.java?rev=291263&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/FilterImpl.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/FilterImpl.java Sat Sep 24 01:00:20 2005
@@ -0,0 +1,215 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ * as applicable.
+ *
+ * Licensed 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.portals.graffito.jcr.query.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.portals.graffito.jcr.exception.JcrMappingException;
+import org.apache.portals.graffito.jcr.mapper.Mapper;
+import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
+import org.apache.portals.graffito.jcr.query.Filter;
+
+/**
+ * {@link org.apache.portals.graffito.jcr.query.Filter}
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ *
+ */
+public class FilterImpl implements Filter
+{
+
+ private Class claszz;
+ private String scope = "";
+ private ArrayList jcrExpressions = new ArrayList();
+
+ private Mapper mapper;
+ private ClassDescriptor classDescriptor;
+
+
+ public FilterImpl(Mapper mapper, Class clazz) throws JcrMappingException
+ {
+ this.mapper = mapper;
+ this.claszz = clazz;
+
+ classDescriptor = mapper.getClassDescriptor(clazz);
+ }
+
+
+
+ public Class getFilterClass()
+ {
+
+ return claszz;
+ }
+
+
+
+ /**
+ * @see org.apache.portals.graffito.jcr.query.Filter#setScope(java.lang.String)
+ */
+ public void setScope(String scope)
+ {
+ this.scope = scope;
+ }
+
+ /**
+ * @see org.apache.portals.graffito.jcr.query.Filter#getScope()
+ */
+ public String getScope()
+ {
+
+ return this.scope;
+ }
+
+ /**
+ * @see org.apache.portals.graffito.jcr.query.Filter#addContains(java.lang.String)
+ */
+ public void addContains(String fullTextSearch)
+ {
+ }
+
+ /**
+ * @see org.apache.portals.graffito.jcr.query.Filter#addBetween(java.lang.String, java.lang.Object, java.lang.Object)
+ */
+ public void addBetween(String fieldAttributeName, Object value1, Object value2)
+ {
+ }
+
+ /**
+ * @see org.apache.portals.graffito.jcr.query.Filter#addEqualTo(java.lang.String, java.lang.Object)
+ */
+ public void addEqualTo(String fieldAttributeName, Object value)
+ {
+ String jcrExpression = "@" + this.getJcrFieldName(fieldAttributeName) + " = " + this.getStringValue(value);
+ jcrExpressions.add(jcrExpression);
+ }
+
+ /**
+ * @see org.apache.portals.graffito.jcr.query.Filter#addGreaterOrEqualThan(java.lang.String, java.lang.Object)
+ */
+ public void addGreaterOrEqualThan(String fieldAttributeName, Object value)
+ {
+
+ String jcrExpression = "@" + this.getJcrFieldName(fieldAttributeName) + " >= " + this.getStringValue(value);
+ jcrExpressions.add(jcrExpression);
+
+ }
+
+ /**
+ * @see org.apache.portals.graffito.jcr.query.Filter#addGreaterThan(java.lang.String, java.lang.Object)
+ */
+ public void addGreaterThan(String fieldAttributeName, Object value)
+ {
+ }
+
+ /**
+ * @see org.apache.portals.graffito.jcr.query.Filter#addIn(java.lang.String, java.util.Collection)
+ */
+ public void addIn(String fieldAttributeName, Collection values)
+ {
+ }
+
+ /**
+ * @see org.apache.portals.graffito.jcr.query.Filter#addLessOrEqualThan(java.lang.String, java.lang.Object)
+ */
+ public void addLessOrEqualThan(String fieldAttributeName, Object arg1)
+ {
+ }
+
+ /**
+ * @see org.apache.portals.graffito.jcr.query.Filter#addLike(java.lang.Object, java.lang.Object)
+ */
+ public void addLike(String fieldAttributeName, Object arg1)
+ {
+ }
+
+ /**
+ * @see org.apache.portals.graffito.jcr.query.Filter#addNotBetween(java.lang.String, java.lang.Object, java.lang.Object)
+ */
+ public void addNotBetween(String fieldAttributeName, Object value1, Object value2)
+ {
+ }
+
+ /**
+ * @see org.apache.portals.graffito.jcr.query.Filter#addNotEqualTo(java.lang.String, java.lang.Object)
+ */
+ public void addNotEqualTo(String fieldAttributeName, Object value)
+ {
+ }
+
+ /**
+ * @see org.apache.portals.graffito.jcr.query.Filter#addNotLike(java.lang.String, java.lang.Object)
+ */
+ public void addNotLike(String fieldAttributeName, Object value)
+ {
+ }
+
+ /**
+ * @see org.apache.portals.graffito.jcr.query.Filter#addNotNull(java.lang.String)
+ */
+ public void addNotNull(String arg0)
+ {
+ }
+
+ /**
+ * @see org.apache.portals.graffito.jcr.query.Filter#addIsNull(java.lang.String)
+ */
+ public void addIsNull(String fieldAttributeName)
+ {
+ }
+
+ /**
+ * @see org.apache.portals.graffito.jcr.query.Filter#addOrFilter(org.apache.portals.graffito.jcr.query.Filter)
+ */
+ public void addOrFilter(Filter filter)
+ {
+ }
+
+ public void addJCRExpression(String jcrExpression)
+ {
+ jcrExpressions.add(jcrExpression);
+ }
+
+
+ private String getJcrFieldName(String fieldAttribute)
+ {
+ return classDescriptor.getJcrName(fieldAttribute);
+
+ }
+
+ private String getStringValue (Object value)
+ {
+ if (value instanceof String)
+ {
+ return "'" + value + "'";
+ }
+ else
+ {
+ return value.toString();
+ }
+ }
+
+ public Collection getJcrExpressions()
+ {
+ return jcrExpressions;
+ }
+
+
+
+}
Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/QueryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/QueryImpl.java?rev=291263&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/QueryImpl.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/QueryImpl.java Sat Sep 24 01:00:20 2005
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ * as applicable.
+ *
+ * Licensed 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.portals.graffito.jcr.query.impl;
+
+import org.apache.portals.graffito.jcr.query.Filter;
+import org.apache.portals.graffito.jcr.query.Query;
+
+/**
+ * Default Query implementation
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ *
+ */
+public class QueryImpl implements Query
+{
+
+ private Filter filter;
+
+
+ public QueryImpl(Filter filter)
+ {
+ this.filter = filter;
+ }
+
+ /**
+ * @see org.apache.portals.graffito.jcr.query.Query#setFilter(org.apache.portals.graffito.jcr.query.Filter)
+ */
+ public void setFilter(Filter filter)
+ {
+ this.filter = filter;
+ }
+
+ /**
+ * @see org.apache.portals.graffito.jcr.query.Query#getFilter()
+ */
+ public Filter getFilter()
+ {
+ return this.filter;
+ }
+
+}
Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/QueryManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/QueryManagerImpl.java?rev=291263&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/QueryManagerImpl.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/QueryManagerImpl.java Sat Sep 24 01:00:20 2005
@@ -0,0 +1,82 @@
+package org.apache.portals.graffito.jcr.query.impl;
+
+import java.util.Iterator;
+
+import org.apache.portals.graffito.jcr.exception.JcrMappingException;
+import org.apache.portals.graffito.jcr.mapper.Mapper;
+import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
+import org.apache.portals.graffito.jcr.query.Filter;
+import org.apache.portals.graffito.jcr.query.Query;
+import org.apache.portals.graffito.jcr.query.QueryManager;
+
+public class QueryManagerImpl implements QueryManager
+{
+
+ private Mapper mapper;
+
+ public QueryManagerImpl(Mapper mapper)
+ {
+ this.mapper = mapper;
+ }
+
+ public Filter createFilter(Class classQuery) throws JcrMappingException
+ {
+
+ return new FilterImpl(mapper, classQuery);
+ }
+
+ public Query createQuery(Filter filter)
+ {
+
+ return new QueryImpl(filter);
+ }
+
+ public String buildJCRExpression(Query query) throws JcrMappingException
+ {
+
+ Filter filter = query.getFilter();
+
+ String jcrExp = "";
+
+ // Add scope
+ if ((filter.getScope() != null && ( ! filter.getScope().equals(""))))
+ {
+ jcrExp += "/jcr:root" + filter.getScope();
+ }
+
+ // Add node type
+ jcrExp += "//element(*, " + this.getNodeType(filter) + ")";
+
+ // Add filter criteria
+ if (((FilterImpl)filter).getJcrExpressions().size() > 0)
+ {
+ int count = 1;
+
+ jcrExp += "[";
+ Iterator criteriaIterator = ((FilterImpl)filter).getJcrExpressions().iterator();
+ while (criteriaIterator.hasNext())
+ {
+ if (count > 1)
+ {
+ jcrExp += " and ";
+ }
+ jcrExp += (String) criteriaIterator.next();
+ count++;
+
+ }
+ jcrExp += "]";
+ }
+
+
+ return jcrExp;
+
+ }
+
+ private String getNodeType(Filter filter) throws JcrMappingException
+ {
+ ClassDescriptor classDescriptor = mapper.getClassDescriptor(filter.getFilterClass());
+ return classDescriptor.getJcrNodeType();
+
+ }
+
+}
Modified: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java?rev=291263&r1=291262&r2=291263&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java Sat Sep 24 01:00:20 2005
@@ -17,23 +17,21 @@
package org.apache.portals.graffito.jcr;
import java.io.BufferedOutputStream;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
-import java.io.IOException;
-import javax.jcr.PathNotFoundException;
import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
import javax.jcr.Session;
+
import junit.framework.TestCase;
import org.apache.portals.graffito.jcr.mapper.impl.DigesterMapperImpl;
import org.apache.portals.graffito.jcr.persistence.PersistenceManager;
import org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerImpl;
+import org.apache.portals.graffito.jcr.query.QueryManager;
+import org.apache.portals.graffito.jcr.query.impl.QueryManagerImpl;
import org.apache.portals.graffito.jcr.repository.RepositoryUtil;
import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
/**
* Base class for testcases. Provides priviledged access to the jcr test
@@ -51,6 +49,7 @@
private PersistenceManager persistenceManager;
+ private QueryManager queryManager;
private static boolean isInit = false;
@@ -79,6 +78,8 @@
session = RepositoryUtil.login(repository, "superuser", "superuser");
persistenceManager = new PersistenceManagerImpl(mapper, repository, session);
+ queryManager = new QueryManagerImpl(mapper);
+
}
@@ -119,6 +120,16 @@
System.out.println("Impossible to export the content from : " + nodePath);
e.printStackTrace();
}
+ }
+
+ protected Session getSession()
+ {
+ return this.session;
+ }
+
+ public QueryManager getQueryManager()
+ {
+ return this.queryManager;
}
}
Modified: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImplTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImplTest.java?rev=291263&r1=291262&r2=291263&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImplTest.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImplTest.java Sat Sep 24 01:00:20 2005
@@ -123,6 +123,11 @@
assertTrue("Incorrect collection size", a.getCollection().size() == 2);
assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("new first"));
+ // --------------------------------------------------------------------------------
+ // Export to check the content
+ // --------------------------------------------------------------------------------
+ this.exportDocument("target/DefaultCollectionConverterExport.xml", "/test", true, false);
+
}
catch (Exception e)
{
Modified: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImplTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImplTest.java?rev=291263&r1=291262&r2=291263&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImplTest.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImplTest.java Sat Sep 24 01:00:20 2005
@@ -126,93 +126,5 @@
}
-// public void testAddElement()
-// {
-// try
-// {
-//
-// if (getPersistenceManager().itemExists("/test"))
-// {
-// getPersistenceManager().remove("/test");
-// }
-//
-// // --------------------------------------------------------------------------------
-// // Create and store an object graph in the repository
-// // --------------------------------------------------------------------------------
-// A a = new A();
-//
-// C c1 = new C();
-// c1.setId("first");
-// c1.setName("First Element");
-// C c2 = new C();
-// c2.setId("second");
-// c2.setName("Second Element");
-//
-// C c3 = new C();
-// c3.setId("third");
-// c3.setName("Third Element");
-//
-//
-// Collection collection = new ArrayList();
-// collection.add(c1);
-// collection.add(c2);
-// collection.add(c3);
-//
-// a.setCollection(collection);
-//
-// getPersistenceManager().insert("/test", a);
-//
-// // --------------------------------------------------------------------------------
-// // Get the object
-// // --------------------------------------------------------------------------------
-// a = (A) getPersistenceManager().getObject(A.class, "/test");
-// assertNotNull("a.collection is null", a.getCollection());
-// assertTrue("Incorrect a.collection size", a.getCollection().size() == 3);
-// assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));
-//
-// // --------------------------------------------------------------------------------
-// // Update the object
-// // --------------------------------------------------------------------------------
-// c1 = new C();
-// c1.setId("first");
-// c1.setName("First Element");
-// c2 = new C();
-// c2.setId("second");
-// c2.setName("Second Element");
-//
-// c3 = new C();
-// c3.setId("third");
-// c3.setName("Third Element");
-//
-// C c4 = new C();
-// c4.setId("Fourth");
-// c4.setName("Fourth Element");
-//
-// collection = new ArrayList();
-// collection.add(c1);
-// collection.add(c2);
-// collection.add(c3);
-// collection.add(c4);
-// a.setCollection(collection);
-//
-// getPersistenceManager().update("/test", a);
-//
-// // --------------------------------------------------------------------------------
-// // Get the object
-// // --------------------------------------------------------------------------------
-// a = (A) getPersistenceManager().getObject(A.class, "/test");
-// assertNotNull("a is null", a);
-// assertNotNull("a.collection is null", a.getCollection());
-// assertTrue("Incorrect collection size", a.getCollection().size() == 4);
-// assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));
-//
-// }
-// catch (Exception e)
-// {
-// e.printStackTrace();
-// fail("Exception occurs during the unit test : " + e);
-// }
-//
-// }
}
Added: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/query/impl/QueryManagerTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/query/impl/QueryManagerTest.java?rev=291263&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/query/impl/QueryManagerTest.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/query/impl/QueryManagerTest.java Sat Sep 24 01:00:20 2005
@@ -0,0 +1,83 @@
+/* ========================================================================
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed 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.portals.graffito.jcr.query.impl;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.portals.graffito.jcr.TestBase;
+import org.apache.portals.graffito.jcr.query.Filter;
+import org.apache.portals.graffito.jcr.query.Query;
+import org.apache.portals.graffito.jcr.query.QueryManager;
+import org.apache.portals.graffito.jcr.testmodel.C;
+
+
+/**
+ * Test QueryManagerImpl methods
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class QueryManagerTest extends TestBase
+{
+ private final static Log log = LogFactory.getLog(QueryManagerTest.class);
+
+ /**
+ * <p>Defines the test case name for junit.</p>
+ * @param testName The test case name.
+ */
+ public QueryManagerTest(String testName) throws Exception
+ {
+ super(testName);
+ }
+
+ public static Test suite()
+ {
+ // All methods starting with "test" will be executed in the test suite.
+ return new TestSuite(QueryManagerTest.class);
+ }
+
+ public void testClassA()
+ {
+
+ try
+ {
+ QueryManager queryManager = this.getQueryManager();
+ Filter filter = queryManager.createFilter(C.class);
+ filter.addEqualTo("name", "a test value");
+ filter.addEqualTo("id", new Integer(1));
+ filter.setScope("/test");
+
+ Query query = queryManager.createQuery(filter);
+ String jcrExpression = queryManager.buildJCRExpression(query);
+ assertNotNull("jcrExpression is null", jcrExpression);
+ assertTrue("Invalid JcrExpression", jcrExpression.equals("/jcr:root/test//element(*, graffito:C)[@graffito:name = 'a test value' and @graffito:id = 1]"));
+
+
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("Exception occurs during the unit test : " + e);
+ }
+
+ }
+
+
+}
\ No newline at end of file