You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2013/07/11 13:22:38 UTC
svn commit: r1502187 - in /syncope/branches/1_1_X/core/src/main:
java/org/apache/syncope/core/persistence/dao/impl/AttributableSearchDAOImpl.java
resources/views.xml
Author: ilgrosso
Date: Thu Jul 11 11:22:38 2013
New Revision: 1502187
URL: http://svn.apache.org/r1502187
Log:
[SYNCOPE-400] Changing search views and code to work without UNION ALL
Modified:
syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AttributableSearchDAOImpl.java
syncope/branches/1_1_X/core/src/main/resources/views.xml
Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AttributableSearchDAOImpl.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AttributableSearchDAOImpl.java?rev=1502187&r1=1502186&r2=1502187&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AttributableSearchDAOImpl.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AttributableSearchDAOImpl.java Thu Jul 11 11:22:38 2013
@@ -363,10 +363,15 @@ public class AttributableSearchDAOImpl e
query.append("subject_id IN (");
}
- query.append("SELECT DISTINCT subject_id ").append("FROM ").
- append(attrUtil.searchView()).append("_resource WHERE ");
-
- query.append("resource_name=?").append(setParameter(parameters, cond.getResourceName()));
+ query.append("SELECT DISTINCT subject_id ").append("FROM ").append(attrUtil.searchView()).
+ append("_resource WHERE resource_name=?").
+ append(setParameter(parameters, cond.getResourceName()));
+
+ if (attrUtil.getType() == AttributableType.USER) {
+ query.append(" UNION SELECT DISTINCT subject_id ").append("FROM ").append(attrUtil.searchView()).
+ append("_role_resource WHERE resource_name=?").
+ append(setParameter(parameters, cond.getResourceName()));
+ }
query.append(')');
@@ -528,9 +533,25 @@ public class AttributableSearchDAOImpl e
return EMPTY_ATTR_QUERY;
}
- StringBuilder query = new StringBuilder("SELECT DISTINCT subject_id FROM ").
- append(attrUtil.searchView()).append("_attr WHERE ").append("schema_name='").append(schema.getName());
- fillAttributeQuery(query, attrValue, schema, cond, not, parameters);
+ StringBuilder query = new StringBuilder("SELECT DISTINCT subject_id FROM ").append(attrUtil.searchView());
+ if (cond.getType() == AttributeCond.Type.ISNOTNULL) {
+ query.append(" WHERE subject_id NOT IN (SELECT subject_id FROM ").
+ append(attrUtil.searchView()).append("_null_attr WHERE schema_name='").
+ append(schema.getName()).append("')");
+ } else {
+ if (cond.getType() == AttributeCond.Type.ISNULL) {
+ query.append("_null_attr WHERE schema_name='").append(schema.getName()).append("'");
+ } else {
+ if (schema.isUniqueConstraint()) {
+ query.append("_unique_attr ");
+ } else {
+ query.append("_attr ");
+ }
+ query.append("WHERE schema_name='").append(schema.getName());
+
+ fillAttributeQuery(query, attrValue, schema, cond, not, parameters);
+ }
+ }
return query.toString();
}
Modified: syncope/branches/1_1_X/core/src/main/resources/views.xml
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/resources/views.xml?rev=1502187&r1=1502186&r2=1502187&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/resources/views.xml (original)
+++ syncope/branches/1_1_X/core/src/main/resources/views.xml Thu Jul 11 11:22:38 2013
@@ -16,7 +16,6 @@ software distributed under the License i
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-
-->
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
@@ -26,8 +25,8 @@ under the License.
SELECT u.id as subject_id, u.* FROM SyncopeUser u
</entry>
- <entry key="user_search_attr">
- CREATE VIEW user_search_attr AS
+ <entry key="user_search_unique_attr">
+ CREATE VIEW user_search_unique_attr AS
SELECT ua.owner_id AS subject_id,
ua.schema_name AS schema_name,
@@ -38,8 +37,9 @@ under the License.
uav.stringvalue AS stringvalue
FROM UAttrUniqueValue uav, UAttr ua
WHERE uav.attribute_id = ua.id
-
- UNION ALL
+ </entry>
+ <entry key="user_search_attr">
+ CREATE VIEW user_search_attr AS
SELECT ua.owner_id AS subject_id,
ua.schema_name AS schema_name,
@@ -50,8 +50,9 @@ under the License.
uav.stringvalue AS stringvalue
FROM UAttrValue uav, UAttr ua
WHERE uav.attribute_id = ua.id
-
- UNION ALL
+ </entry>
+ <entry key="user_search_null_attr">
+ CREATE VIEW user_search_null_attr AS
SELECT u.id AS subject_id,
USchema.name AS schema_name,
@@ -76,8 +77,9 @@ under the License.
SELECT st.user_id AS subject_id, st.resource_name AS resource_name
FROM SyncopeUser_ExternalResource st
-
- UNION ALL
+ </entry>
+ <entry key="user_search_role_resource">
+ CREATE VIEW user_search_role_resource AS
SELECT m.syncopeuser_id AS subject_id, st.resource_name AS resource_name
FROM Membership m, SyncopeRole r, SyncopeRole_ExternalResource st
@@ -88,8 +90,8 @@ under the License.
SELECT r.id as subject_id, r.* FROM SyncopeRole r
</entry>
- <entry key="role_search_attr">
- CREATE VIEW role_search_attr AS
+ <entry key="role_search_unique_attr">
+ CREATE VIEW role_search_unique_attr AS
SELECT ra.owner_id AS subject_id,
ra.schema_name AS schema_name,
@@ -100,8 +102,9 @@ under the License.
rav.stringvalue AS stringvalue
FROM RAttrUniqueValue rav, RAttr ra
WHERE rav.attribute_id = ra.id
-
- UNION ALL
+ </entry>
+ <entry key="role_search_attr">
+ CREATE VIEW role_search_attr AS
SELECT ra.owner_id AS subject_id,
ra.schema_name AS schema_name,
@@ -112,8 +115,9 @@ under the License.
rav.stringvalue AS stringvalue
FROM RAttrValue rav, RAttr ra
WHERE rav.attribute_id = ra.id
-
- UNION ALL
+ </entry>
+ <entry key="role_search_null_attr">
+ CREATE VIEW role_search_null_attr AS
SELECT r.id AS subject_id,
RSchema.name AS schema_name,