Scarab commit: svn commit: r10468 - trunk/src/java/org/tigris/scarab/util/word/IssueSearch.java

[email protected]
Newsgroups gmane.comp.java.scarab.cvs
Message-ID <[email protected]>
Author: ronvoe122
Date: 2007-10-26 02:45:27-0700
New Revision: 10468

Modified:
   trunk/src/java/org/tigris/scarab/util/word/IssueSearch.java

Log:
[SCB2416] 
-text search: don't strip non-latin characters from search string
-search by creation date: fixed wrong method call (date between minDate and minDate)
-relative Dates: fixed wrong data type in call to Date.setTime()
-relative Dates: added the ability to express future dates
Patch by Andrey Larionov (tweaked by me)

Modified: trunk/src/java/org/tigris/scarab/util/word/IssueSearch.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/util/word/IssueSearch.java?view=diff&rev=10468&p1=trunk/src/java/org/tigris/scarab/util/word/IssueSearch.java&p2=trunk/src/java/org/tigris/scarab/util/word/IssueSearch.java&r1=10467&r2=10468
==============================================================================
--- trunk/src/java/org/tigris/scarab/util/word/IssueSearch.java	(original)
+++ trunk/src/java/org/tigris/scarab/util/word/IssueSearch.java	2007-10-26 02:45:27-0700
@@ -139,7 +139,7 @@
     private static final char DOT_REPLACEMENT_IN_JOIN_CONDITION = '#';
 
 	private static final Pattern RELATIVE_DATE_PATTERN = Pattern.compile(
-        "\\s*now\\s*(-\\s*(\\d+)|)\\s*",
+        "\\s*now\\s*(([+-])\\s*(\\d+)|)\\s*",
 		Pattern.CASE_INSENSITIVE
     );
 	
@@ -289,7 +289,7 @@
             String s = av.getValue();
             if (s!=null) 
             {
-                av.setValue( s.replaceAll("[^\\w]+", " ").toLowerCase());       
+                av.setValue( s.replaceAll("[\\+\\-\\&{2}\\|\\|\\!\\(\\)\\{\\}\\[\\]\\^\\\"\\~\\*\\?\\:\\\\]+", " ").toLowerCase());       
             }
         }
     }
@@ -907,16 +907,19 @@
         if (dateString != null) 
         {
             Matcher m = RELATIVE_DATE_PATTERN.matcher(dateString);
-        	if(m.matches())
-        	{
+        	   if(m.matches())
+        	   {
                 date = new Date();
-        		String dateDifference = m.group(2);
-        		if(dateDifference!=null)
-        		{
-      				int hours = Integer.parseInt(dateDifference);
-       				date.setTime(date.getTime() - hours * 3600000 );
-        		}
-        	}
+
+        		    String dateDifference = m.group(3);
+        		    String sign = m.group(2);
+        		    if(dateDifference!=null)
+        	       {
+                    long hours = Long.parseLong(dateDifference);  
+                    if (sign.equals("-")) hours = hours * -1;
+                    date.setTime(date.getTime() + hours * 3600000 );
+                }
+        	   }
             else if (dateString.indexOf(':') == -1)
             {
                 String[] patterns = {
@@ -1429,7 +1432,7 @@
         addTransDateRange(crit, "CHANGE_DATE_TABLE", IssuePeer.LAST_TRANS_ID,
                           getMinChangeDate(), getMaxChangeDate());
         addTransDateRange(crit, "CREATE_DATE_TABLE", IssuePeer.CREATED_TRANS_ID,
-                          getMinCreationDate(), getMinCreationDate());
+                          getMinCreationDate(), getMaxCreationDate());
     }
         
     private void addUserCriteria(Criteria crit)
@@ -1816,4 +1819,4 @@
             }
         }
     }
-}
+}
\ No newline at end of file
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.