Commit 54b42741 authored by Miguel Rodriguez's avatar Miguel Rodriguez

Merge branch 'issue1' into 'master'

Fix buggy ms & oracle queries

See merge request premier-emea/alfresco-db-queries!5
parents cb6054c5 b903a63c
......@@ -50,7 +50,6 @@ public class SqlMapperController {
} else if (dbType.equalsIgnoreCase("oracle")){
return dbSizeMapper.findTablesInfoOracle();
}
return null;
}
......@@ -60,7 +59,6 @@ public class SqlMapperController {
} else if (dbType.equalsIgnoreCase("mysql")){
return dbSizeMapper.findDbSizeMysql();
}
return null;
}
......@@ -74,7 +72,6 @@ public class SqlMapperController {
} else if (dbType.equalsIgnoreCase("microsoft")){
return nodeListMapper.findNodesSizeMSSql();
}
return null;
}
......@@ -92,7 +89,6 @@ public class SqlMapperController {
} else if (dbType.equalsIgnoreCase("microsoft")){
return nodeListMapper.findNodesByStoreMSSql();
}
return null;
}
......@@ -106,7 +102,6 @@ public class SqlMapperController {
} else if (dbType.equalsIgnoreCase("microsoft")){
return largeFolderMapper.findBySizeMSSql(largeFolderSize);
}
return null;
}
......@@ -120,7 +115,6 @@ public class SqlMapperController {
} else if (dbType.equalsIgnoreCase("microsoft")){
return nodeListMapper.findNodesByContentTypeMSSql();
}
return null;
}
......@@ -134,7 +128,6 @@ public class SqlMapperController {
} else if (dbType.equalsIgnoreCase("microsoft")){
return nodeListMapper.findNodesByContentTypeAndMonthMSSql();
}
return null;
}
......@@ -147,11 +140,19 @@ public class SqlMapperController {
}
public List findACLNodeRepartition() {
return accessControlListMapper.findACLNodeRepartition();
if (dbType.equalsIgnoreCase("oracle")){
return accessControlListMapper.findACLNodeRepartitionOracle();
} else if (dbType.equalsIgnoreCase("microsoft")){
return accessControlListMapper.findACLNodeRepartitionMSSql();
} else return accessControlListMapper.findACLNodeRepartition();
}
public List findACEAuthorities() {
return accessControlListMapper.findACEAuthorities();
if (dbType.equalsIgnoreCase("oracle")){
return accessControlListMapper.findACEAuthoritiesOracle();
} else if (dbType.equalsIgnoreCase("microsoft")){
return accessControlListMapper.findACEAuthoritiesMSSql();
} else return accessControlListMapper.findACEAuthorities();
}
public String findOrphanedAcls() {
......@@ -180,7 +181,6 @@ public class SqlMapperController {
} else if (dbType.equalsIgnoreCase("microsoft")){
return activitiesFeedMapper.findActivitiesByActivityTypeMSSql();
}
return null;
}
......@@ -194,7 +194,6 @@ public class SqlMapperController {
} else if (dbType.equalsIgnoreCase("microsoft")){
return activitiesFeedMapper.findActivitiesByUserMSSql();
}
return null;
}
......@@ -208,7 +207,6 @@ public class SqlMapperController {
} else if (dbType.equalsIgnoreCase("microsoft")){
return activitiesFeedMapper.findActivitiesByApplicationInterfaceMSSql();
}
return null;
}
......@@ -226,7 +224,6 @@ public class SqlMapperController {
} else if (dbType.equalsIgnoreCase("microsoft")){
return authorityMapper.findAuthorizedUsersMSSql();
}
return null;
}
......
......@@ -24,12 +24,35 @@ public interface AccessControlListMapper {
"GROUP BY acl_id ORDER BY numNodes DESC LIMIT 10"})
List<AccessControlList> findACLNodeRepartition();
@Select({"SELECT * FROM (SELECT acl_id aclid, count(*) numNodes " +
"FROM alf_node " +
"GROUP BY acl_id ORDER BY numNodes DESC) " +
"WHERE ROWNUM <= 10"})
List<AccessControlList> findACLNodeRepartitionOracle();
@Select({"SELECT TOP 10 acl_id aclid, count(*) numNodes " +
"FROM alf_node " +
"GROUP BY acl_id ORDER BY numNodes DESC"})
List<AccessControlList> findACLNodeRepartitionMSSql();
@Select({"SELECT md5(aa.authority) AS authorityHash, count(*) AS numAces " +
"FROM alf_access_control_entry ace " +
"JOIN alf_authority aa ON aa.id=ace.authority_id " +
"GROUP BY authorityHash HAVING count(*) > 0"})
List<AccessControlList> findACEAuthorities();
@Select({"SELECT 'xxx' AS authorityHash, count(*) AS numAces " +
"FROM alf_access_control_entry ace " +
"JOIN alf_authority aa ON aa.id=ace.authority_id " +
"GROUP BY aa.authority HAVING count(*) > 0"})
List<AccessControlList> findACEAuthoritiesOracle();
@Select({"SELECT CONVERT(VARCHAR(32), HashBytes('MD5', aa.authority), 2) AS authorityHash, count(*) AS numAces " +
"FROM alf_access_control_entry ace " +
"JOIN alf_authority aa ON aa.id=ace.authority_id " +
"GROUP BY aa.authority HAVING count(*) > 0"})
List<AccessControlList> findACEAuthoritiesMSSql();
@Select({"SELECT count(*) occurrences from alf_access_control_list aacl " +
"LEFT OUTER JOIN alf_node an ON an.acl_id=aacl.id " +
"WHERE aacl.id IS NULL"})
......
......@@ -51,47 +51,47 @@ public interface ActivitiesFeedMapper {
List<ActivitiesFeed> findActivitiesByApplicationInterfaceMySQL();
@Select("select count(*) as occurrences, substr(post_date, 1, 10) as postDate, site_network as siteNetwork, activity_type as activityType " +
"from alf_activity_feed" +
"where feed_user_id != '@@NULL@@'" +
"and feed_user_id = post_user_id" +
"from alf_activity_feed " +
"where feed_user_id != '@@NULL@@' " +
"and feed_user_id = post_user_id " +
"group by post_date, site_network, activity_type")
List<ActivitiesFeed> findActivitiesByActivityTypeOracle();
@Select("select count(*) as occurrences, substr(post_date, 1, 10) as postDate, site_network as siteNetwork, feed_user_id as feedUserId " +
"from alf_activity_feed" +
"where feed_user_id != '@@NULL@@'" +
"and feed_user_id = post_user_id" +
"from alf_activity_feed " +
"where feed_user_id != '@@NULL@@' " +
"and feed_user_id = post_user_id " +
"group by post_date, site_network, feed_user_id")
List<ActivitiesFeed> findActivitiesByUserOracle();
@Select("select count(*) as occurrences, substr(post_date, 1, 10) as postDate, site_network as siteNetwork, app_tool as appTool " +
"from alf_activity_feed" +
"where feed_user_id != '@@NULL@@'" +
"and feed_user_id = post_user_id" +
"from alf_activity_feed " +
"where feed_user_id != '@@NULL@@' " +
"and feed_user_id = post_user_id " +
"group by post_date, site_network, app_tool")
List<ActivitiesFeed> findActivitiesByApplicationInterfaceOracle();
@Select("select count(*) as occurrences, substring(CONVERT(VARCHAR(11), post_date), 1, 11) as postDate, " +
"site_network as siteNetwork, activity_type as activityType" +
"from alf_activity_feed" +
"where feed_user_id != '@@NULL@@'" +
"and feed_user_id = post_user_id" +
"site_network as siteNetwork, activity_type as activityType " +
"from alf_activity_feed " +
"where feed_user_id != '@@NULL@@' " +
"and feed_user_id = post_user_id " +
"group by post_date, site_network, activity_type")
List<ActivitiesFeed> findActivitiesByActivityTypeMSSql();
@Select("select count(*) as occurrences, substring(CONVERT(VARCHAR(11), post_date), 1, 11) as postDate, " +
"site_network as siteNetwork, feed_user_id as feedUserId" +
"from alf_activity_feed" +
"where feed_user_id != '@@NULL@@'" +
"and feed_user_id = post_user_id" +
"site_network as siteNetwork, feed_user_id as feedUserId " +
"from alf_activity_feed " +
"where feed_user_id != '@@NULL@@' " +
"and feed_user_id = post_user_id " +
"group by post_date, site_network, feed_user_id")
List<ActivitiesFeed> findActivitiesByUserMSSql();
@Select("select count(*) as occurrences, substring(CONVERT(VARCHAR(11), post_date), 1, 11) as postDate, " +
"site_network as siteNetwork, app_tool as appTool" +
"from alf_activity_feed" +
"where feed_user_id != '@@NULL@@'" +
"and feed_user_id = post_user_id" +
"site_network as siteNetwork, app_tool as appTool " +
"from alf_activity_feed " +
"where feed_user_id != '@@NULL@@' " +
"and feed_user_id = post_user_id " +
"group by post_date, site_network, app_tool")
List<ActivitiesFeed> findActivitiesByApplicationInterfaceMSSql();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment