incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r293029 - in /incubator/graffito/trunk/jcr-mapping/src: java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/ java/org/apache/portals/graffito/jcr/query/ java/org/apache/portals/graffito/jcr/query/impl/ test/org/apache/porta...
Date Sat, 01 Oct 2005 21:15:42 GMT
Author: clombart
Date: Sat Oct  1 14:15:28 2005
New Revision: 293029

URL: http://svn.apache.org/viewcvs?rev=293029&view=rev
Log:
Still working on the query service

Modified:
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/AtomicTypeConverterFactory.java
    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/impl/FilterImpl.java
    incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerAtomicQueryTest.java

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/AtomicTypeConverterFactory.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/AtomicTypeConverterFactory.java?rev=293029&r1=293028&r2=293029&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/AtomicTypeConverterFactory.java
(original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/AtomicTypeConverterFactory.java
Sat Oct  1 14:15:28 2005
@@ -240,6 +240,7 @@
             if (propValue == null)
                 return null;
             return this.getValueFactory().createValue((Calendar) propValue);
+            
         }
 
         public Object getJavaObjectFromJcr(Node node, String jcrPropName) throws ValueFormatException,
PathNotFoundException,

Modified: 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=293029&r1=293028&r2=293029&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/Filter.java
(original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/Filter.java
Sat Oct  1 14:15:28 2005
@@ -65,6 +65,8 @@
 	public void addGreaterThan(String arg0, Object arg1);
 
 	public void addLessOrEqualThan(String arg0, Object arg1);
+	
+	public void addLessThan(String arg0, Object arg1);
 
 	public void addLike(String arg0, Object arg1);
 

Modified: 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=293029&r1=293028&r2=293029&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/FilterImpl.java
(original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/FilterImpl.java
Sat Oct  1 14:15:28 2005
@@ -148,6 +148,16 @@
 		jcrExpressions.add(jcrExpression);	
 		
 	}
+	
+	/**
+	 * @see org.apache.portals.graffito.jcr.query.Filter#addLessOrEqualThan(java.lang.String,
java.lang.Object)
+	 */
+	public void addLessThan(String fieldAttributeName, Object value)
+	{
+		String jcrExpression =  "@" + this.getJcrFieldName(fieldAttributeName) + " < " + this.getStringValue(value);
+		jcrExpressions.add(jcrExpression);	
+		
+	}	
 
 	/**
 	 * @see org.apache.portals.graffito.jcr.query.Filter#addLike(java.lang.Object, java.lang.Object)
@@ -233,18 +243,29 @@
 			else 
 			{
 			    if ((value instanceof Calendar))
-			    {
-			    	//||(value instanceof Date)
+			    {			    	
 			    	Calendar calendar = (Calendar) value;			        
 			        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T00:00:00.000+01:00'");
-			        //'1976-01-01T00:00:00.000+01:00'
 			        formatter.setCalendar(calendar);
 			         
-			         String formattedString = " TIMESTAMP '" + formatter.format(calendar.getTime())
+ "'";
+			         String formattedString = "'" + formatter.format(calendar.getTime()) + "'";
 			         return formattedString;
 			    }
 			    else
 			    {
+			    	if (value instanceof Date)
+			    	{
+			    		Date date = (Date) value;		        
+				        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T00:00:00.000+01:00'");
+				        Calendar calendar = Calendar.getInstance();
+				        calendar.setTime(date);
+				        formatter.setCalendar(calendar);
+				         
+				         String formattedString = "'" + formatter.format(calendar.getTime()) + "'";
+				         return formattedString;			    		
+			    		
+			    	}
+			    	
 			    	return value.toString();			    	
 			    }
 			}

Modified: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerAtomicQueryTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerAtomicQueryTest.java?rev=293029&r1=293028&r2=293029&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerAtomicQueryTest.java
(original)
+++ incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerAtomicQueryTest.java
Sat Oct  1 14:15:28 2005
@@ -117,15 +117,40 @@
 			
 			result = persistenceManager.getObjects(query);			
 			assertTrue("Invalid number of objects - should be = 36", result.size() == 36);
+
+			// Test double value
+//			filter = queryManager.createFilter(Atomic.class);
+//			filter.addEqualTo("doubleObject", new Double (202.12));
+//			query = queryManager.createQuery(filter);
+//			
+//			result = persistenceManager.getObjects(query);			
+//			assertTrue("Invalid number of objects - should be = 3", result.size() == 1);
+		
+//			filter = queryManager.createFilter(Atomic.class);
+//			filter.addLessOrEqualThan("doublePrimitive", new Double(602.12));
+//			query = queryManager.createQuery(filter);
+//			
+//			result = persistenceManager.getObjects(query);			
+//			assertTrue("Invalid number of objects - should be = 5", result.size() == 6);
 			
 			//Test Date & Calendar
 //			filter = queryManager.createFilter(Atomic.class);
-//			filter.addLessOrEqualThan("calendar", Calendar.getInstance());
+//			Calendar calendar = Calendar.getInstance();
+//			calendar.set(2012, 12, 01);
+//			filter.addLessThan("myCalendar", calendar);
 //			query = queryManager.createQuery(filter);
 //			
 //			result = persistenceManager.getObjects(query);			
 //			assertTrue("Invalid number of objects - should be = 100 ", result.size() == 100);
-			
+
+//			filter = queryManager.createFilter(Atomic.class);
+//			Calendar calendar = Calendar.getInstance();
+//			calendar.set(2012, 12, 01);
+//			filter.addLessThan("date", calendar);
+//			query = queryManager.createQuery(filter);
+//			
+//			result = persistenceManager.getObjects(query);			
+//			assertTrue("Invalid number of objects - should be = 100 ", result.size() == 100);		

 			
 		}
 		catch (Exception e)
@@ -156,7 +181,9 @@
 				a.setIntPrimitive(200 + i);
 				a.setString("Test String " + i);
 				a.setDate(new Date());
-				a.setCalendar(Calendar.getInstance());
+				Calendar calendar = Calendar.getInstance();
+				calendar.set(1976, 4, 20, 15, 40);
+				a.setCalendar(calendar);
 				a.setDoubleObject(new Double(2.12 + i));
 				a.setDoublePrimitive(1.23 + i);
 				long now = System.currentTimeMillis();



Mime
View raw message