manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1029455 - /incubator/lcf/trunk/modules/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceDerby.java
Date Sun, 31 Oct 2010 19:06:08 GMT
Author: kwright
Date: Sun Oct 31 19:06:08 2010
New Revision: 1029455

URL: http://svn.apache.org/viewvc?rev=1029455&view=rev
Log:
More work on CONNECTORS-109.  Hook up regular expression methods into Derby. 

Modified:
    incubator/lcf/trunk/modules/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceDerby.java

Modified: incubator/lcf/trunk/modules/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceDerby.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceDerby.java?rev=1029455&r1=1029454&r2=1029455&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceDerby.java
(original)
+++ incubator/lcf/trunk/modules/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceDerby.java
Sun Oct 31 19:06:08 2010
@@ -538,16 +538,29 @@ public class DBInterfaceDerby extends Da
     {
       rootDatabase.executeQuery("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.user."+userName+"',
'"+password+"')",null,invalidateKeys,null,null,false,0,null,null);
       rootDatabase.executeQuery("CREATE SCHEMA "+userName+" AUTHORIZATION "+userName,null,invalidateKeys,null,null,false,0,null,null);
-      // Create user-defined functions
-      rootDatabase.executeQuery("CREATE FUNCTION caseInsensitiveRegularExpressionCompare
(value varchar(255), regexp varchar(255)) returns varchar(255) "+
-        "language java parameter style java no sql external name 'org.apache.manifoldcf.core.database.DBInterfaceDerby.caseInsensitiveRegularExpressionCompare",null,invalidateKeys,null,null,false,0,null,null);
-      rootDatabase.executeQuery("CREATE FUNCTION caseSensitiveRegularExpressionCompare (value
varchar(255), regexp varchar(255)) returns varchar(255) "+
-        "language java parameter style java no sql external name 'org.apache.manifoldcf.core.database.DBInterfaceDerby.caseSensitiveRegularExpressionCompare",null,invalidateKeys,null,null,false,0,null,null);
-      rootDatabase.executeQuery("CREATE FUNCTION caseInsensitiveSubstring (value varchar(255),
regexp varchar(255)) returns varchar(255) "+
-        "language java parameter style java no sql external name 'org.apache.manifoldcf.core.database.DBInterfaceDerby.caseInsensitiveSubstring",null,invalidateKeys,null,null,false,0,null,null);
-      rootDatabase.executeQuery("CREATE FUNCTION caseSensitiveSubstring (value varchar(255),
regexp varchar(255)) returns varchar(255) "+
-        "language java parameter style java no sql external name 'org.apache.manifoldcf.core.database.DBInterfaceDerby.caseSensitiveSubstring",null,invalidateKeys,null,null,false,0,null,null);
     }
+    try
+    {
+      rootDatabase.executeQuery("DROP FUNCTION CASEINSENSITIVEREGULAREXPRESSIONCOMPARE",null,invalidateKeys,null,null,false,0,null,null);
+      rootDatabase.executeQuery("DROP FUNCTION CASESENSITIVEREGULAREXPRESSIONCOMPARE",null,invalidateKeys,null,null,false,0,null,null);
+      rootDatabase.executeQuery("DROP FUNCTION CASEINSENSITIVESUBSTRING",null,invalidateKeys,null,null,false,0,null,null);
+      rootDatabase.executeQuery("DROP FUNCTION CASESENSITIVESUBSTRING",null,invalidateKeys,null,null,false,0,null,null);
+    }
+    catch (ManifoldCFException e)
+    {
+      if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
+        throw e;
+      // Otherwise, eat it.
+    }
+    // Create user-defined functions
+    rootDatabase.executeQuery("CREATE FUNCTION CASEINSENSITIVEREGULAREXPRESSIONCOMPARE (value
varchar(255), regexp varchar(255)) returns varchar(255) "+
+      "language java parameter style java no sql external name 'org.apache.manifoldcf.core.database.DBInterfaceDerby.caseInsensitiveRegularExpressionCompare'",null,invalidateKeys,null,null,false,0,null,null);
+    rootDatabase.executeQuery("CREATE FUNCTION CASESENSITIVEREGULAREXPRESSIONCOMPARE (value
varchar(255), regexp varchar(255)) returns varchar(255) "+
+      "language java parameter style java no sql external name 'org.apache.manifoldcf.core.database.DBInterfaceDerby.caseSensitiveRegularExpressionCompare'",null,invalidateKeys,null,null,false,0,null,null);
+    rootDatabase.executeQuery("CREATE FUNCTION CASEINSENSITIVESUBSTRING (value varchar(255),
regexp varchar(255)) returns varchar(255) "+
+      "language java parameter style java no sql external name 'org.apache.manifoldcf.core.database.DBInterfaceDerby.caseInsensitiveSubstring'",null,invalidateKeys,null,null,false,0,null,null);
+    rootDatabase.executeQuery("CREATE FUNCTION CASESENSITIVESUBSTRING (value varchar(255),
regexp varchar(255)) returns varchar(255) "+
+      "language java parameter style java no sql external name 'org.apache.manifoldcf.core.database.DBInterfaceDerby.caseSensitiveSubstring'",null,invalidateKeys,null,null,false,0,null,null);
   }
 
   /** Drop user and database.
@@ -835,12 +848,17 @@ public class DBInterfaceDerby extends Da
   */
   public String constructRegexpClause(String column, String regularExpression, boolean caseInsensitive)
   {
-    return column + " LIKE " + regularExpression;
+    //return column + " LIKE " + regularExpression;
     // Waiting for DERBY-4066 to be resolved in a release for the following:
     //if (caseInsensitive)
     //  return "caseInsensitiveRegularExpressionCompare("+column+","+regularExpression+")='true'";
     //else
     //  return "caseSensitiveRegularExpressionCompare("+column+","+regularExpression+")='true'";
+    if (caseInsensitive)
+      return "CASEINSENSITIVEREGULAREXPRESSIONCOMPARE(CAST("+column+" AS VARCHAR(255)),"+regularExpression+")='true'";
+    else
+      return "CASESENSITIVEREGULAREXPRESSIONCOMPARE(CAST("+column+" AS VARCHAR(255)),"+regularExpression+")='true'";
+
   }
 
   /** Construct a regular-expression substring clause.
@@ -853,12 +871,16 @@ public class DBInterfaceDerby extends Da
   */
   public String constructSubstringClause(String column, String regularExpression, boolean
caseInsensitive)
   {
-    return "''";
+    //return "''";
     // Waiting for DERBY-4066 to be resolved in a release for the following:
     //if (caseInsensitive)
     //  return "caseInsensitiveSubstring("+column+","+regularExpression+")";
     //else
     //  return "caseSensitiveSubstring("+column+","+regularExpression+")";
+    if (caseInsensitive)
+      return "CASEINSENSITIVESUBSTRING(CAST("+column+" AS VARCHAR(255)),"+regularExpression+")";
+    else
+      return "CASESENSITIVESUBSTRING(CAST("+column+" AS VARCHAR(255)),"+regularExpression+")";
   }
 
   /** Construct an offset/limit clause.



Mime
View raw message