Topia-commits
Threads by month
- ----- 2026 -----
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
September 2012
- 2 participants
- 16 discussions
r2670 - in branches/topia-2.6.x: . topia-persistence topia-service-migration topia-service-replication topia-service-security
by maven-release@users.nuiton.org Sept. 14, 2012
by maven-release@users.nuiton.org Sept. 14, 2012
Sept. 14, 2012
Author: maven-release
Date: 2012-09-14 17:56:07 +0200 (Fri, 14 Sep 2012)
New Revision: 2670
Url: http://nuiton.org/repositories/revision/topia/2670
Log:
[maven-release-plugin] prepare for next development iteration
Modified:
branches/topia-2.6.x/pom.xml
branches/topia-2.6.x/topia-persistence/pom.xml
branches/topia-2.6.x/topia-service-migration/pom.xml
branches/topia-2.6.x/topia-service-replication/pom.xml
branches/topia-2.6.x/topia-service-security/pom.xml
Modified: branches/topia-2.6.x/pom.xml
===================================================================
--- branches/topia-2.6.x/pom.xml 2012-09-14 15:56:05 UTC (rev 2669)
+++ branches/topia-2.6.x/pom.xml 2012-09-14 15:56:07 UTC (rev 2670)
@@ -37,7 +37,7 @@
</parent>
<artifactId>topia</artifactId>
- <version>2.7</version>
+ <version>2.7.1-SNAPSHOT</version>
<modules>
<module>topia-persistence</module>
@@ -452,9 +452,9 @@
<!-- Source control management. -->
<scm>
- <connection>scm:svn:http://svn.nuiton.org/svn/topia/tags/topia-2.7</connection>
- <developerConnection>scm:svn:http://svn.nuiton.org/svn/topia/tags/topia-2.7</developerConnection>
- <url>http://www.nuiton.org/repositories/browse/topia/tags/topia-2.7</url>
+ <connection>scm:svn:http://svn.nuiton.org/svn/topia/branches/topia-2.6.x</connection>
+ <developerConnection>scm:svn:http://svn.nuiton.org/svn/topia/branches/topia-2.6.x</developerConnection>
+ <url>http://www.nuiton.org/repositories/browse/topia/branches/topia-2.6.x</url>
</scm>
<distributionManagement>
Modified: branches/topia-2.6.x/topia-persistence/pom.xml
===================================================================
--- branches/topia-2.6.x/topia-persistence/pom.xml 2012-09-14 15:56:05 UTC (rev 2669)
+++ branches/topia-2.6.x/topia-persistence/pom.xml 2012-09-14 15:56:07 UTC (rev 2670)
@@ -35,7 +35,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.7</version>
+ <version>2.7.1-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.topia</groupId>
Modified: branches/topia-2.6.x/topia-service-migration/pom.xml
===================================================================
--- branches/topia-2.6.x/topia-service-migration/pom.xml 2012-09-14 15:56:05 UTC (rev 2669)
+++ branches/topia-2.6.x/topia-service-migration/pom.xml 2012-09-14 15:56:07 UTC (rev 2670)
@@ -35,7 +35,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.7</version>
+ <version>2.7.1-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.topia</groupId>
Modified: branches/topia-2.6.x/topia-service-replication/pom.xml
===================================================================
--- branches/topia-2.6.x/topia-service-replication/pom.xml 2012-09-14 15:56:05 UTC (rev 2669)
+++ branches/topia-2.6.x/topia-service-replication/pom.xml 2012-09-14 15:56:07 UTC (rev 2670)
@@ -35,7 +35,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.7</version>
+ <version>2.7.1-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.topia</groupId>
Modified: branches/topia-2.6.x/topia-service-security/pom.xml
===================================================================
--- branches/topia-2.6.x/topia-service-security/pom.xml 2012-09-14 15:56:05 UTC (rev 2669)
+++ branches/topia-2.6.x/topia-service-security/pom.xml 2012-09-14 15:56:07 UTC (rev 2670)
@@ -35,7 +35,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.7</version>
+ <version>2.7.1-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.topia</groupId>
1
0
Author: maven-release
Date: 2012-09-14 17:56:05 +0200 (Fri, 14 Sep 2012)
New Revision: 2669
Url: http://nuiton.org/repositories/revision/topia/2669
Log:
[maven-release-plugin] copy for tag topia-2.7
Added:
tags/topia-2.7/
Property changes on: tags/topia-2.7
___________________________________________________________________
Added: svn:ignore
+ *.ipr
*.iws
.classpath
*.iml
.project
target
.settings
.idea
Added: svn:mergeinfo
+ /branches/from2.2.2-eugene2-beta:1662-1714
/branches/topia-2.6.x:2293-2300
1
0
r2668 - in branches/topia-2.6.x: . topia-persistence topia-service-migration topia-service-replication topia-service-security
by maven-release@users.nuiton.org Sept. 14, 2012
by maven-release@users.nuiton.org Sept. 14, 2012
Sept. 14, 2012
Author: maven-release
Date: 2012-09-14 17:56:03 +0200 (Fri, 14 Sep 2012)
New Revision: 2668
Url: http://nuiton.org/repositories/revision/topia/2668
Log:
[maven-release-plugin] prepare release topia-2.7
Modified:
branches/topia-2.6.x/pom.xml
branches/topia-2.6.x/topia-persistence/pom.xml
branches/topia-2.6.x/topia-service-migration/pom.xml
branches/topia-2.6.x/topia-service-replication/pom.xml
branches/topia-2.6.x/topia-service-security/pom.xml
Modified: branches/topia-2.6.x/pom.xml
===================================================================
--- branches/topia-2.6.x/pom.xml 2012-09-14 15:33:14 UTC (rev 2667)
+++ branches/topia-2.6.x/pom.xml 2012-09-14 15:56:03 UTC (rev 2668)
@@ -37,7 +37,7 @@
</parent>
<artifactId>topia</artifactId>
- <version>2.7-SNAPSHOT</version>
+ <version>2.7</version>
<modules>
<module>topia-persistence</module>
@@ -452,9 +452,9 @@
<!-- Source control management. -->
<scm>
- <connection>scm:svn:http://svn.nuiton.org/svn/topia/branches/topia-2.6.x</connection>
- <developerConnection>scm:svn:http://svn.nuiton.org/svn/topia/branches/topia-2.6.x</developerConnection>
- <url>http://www.nuiton.org/repositories/browse/topia/branches/topia-2.6.x</url>
+ <connection>scm:svn:http://svn.nuiton.org/svn/topia/tags/topia-2.7</connection>
+ <developerConnection>scm:svn:http://svn.nuiton.org/svn/topia/tags/topia-2.7</developerConnection>
+ <url>http://www.nuiton.org/repositories/browse/topia/tags/topia-2.7</url>
</scm>
<distributionManagement>
Modified: branches/topia-2.6.x/topia-persistence/pom.xml
===================================================================
--- branches/topia-2.6.x/topia-persistence/pom.xml 2012-09-14 15:33:14 UTC (rev 2667)
+++ branches/topia-2.6.x/topia-persistence/pom.xml 2012-09-14 15:56:03 UTC (rev 2668)
@@ -35,7 +35,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.7-SNAPSHOT</version>
+ <version>2.7</version>
</parent>
<groupId>org.nuiton.topia</groupId>
Modified: branches/topia-2.6.x/topia-service-migration/pom.xml
===================================================================
--- branches/topia-2.6.x/topia-service-migration/pom.xml 2012-09-14 15:33:14 UTC (rev 2667)
+++ branches/topia-2.6.x/topia-service-migration/pom.xml 2012-09-14 15:56:03 UTC (rev 2668)
@@ -35,7 +35,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.7-SNAPSHOT</version>
+ <version>2.7</version>
</parent>
<groupId>org.nuiton.topia</groupId>
Modified: branches/topia-2.6.x/topia-service-replication/pom.xml
===================================================================
--- branches/topia-2.6.x/topia-service-replication/pom.xml 2012-09-14 15:33:14 UTC (rev 2667)
+++ branches/topia-2.6.x/topia-service-replication/pom.xml 2012-09-14 15:56:03 UTC (rev 2668)
@@ -35,7 +35,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.7-SNAPSHOT</version>
+ <version>2.7</version>
</parent>
<groupId>org.nuiton.topia</groupId>
Modified: branches/topia-2.6.x/topia-service-security/pom.xml
===================================================================
--- branches/topia-2.6.x/topia-service-security/pom.xml 2012-09-14 15:33:14 UTC (rev 2667)
+++ branches/topia-2.6.x/topia-service-security/pom.xml 2012-09-14 15:56:03 UTC (rev 2668)
@@ -35,7 +35,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.7-SNAPSHOT</version>
+ <version>2.7</version>
</parent>
<groupId>org.nuiton.topia</groupId>
1
0
Author: tchemit
Date: 2012-09-14 17:33:14 +0200 (Fri, 14 Sep 2012)
New Revision: 2667
Url: http://nuiton.org/repositories/revision/topia/2667
Log:
fixes #2314: Updates to nuiton-utils 2.6.2
Modified:
branches/topia-2.6.x/pom.xml
Modified: branches/topia-2.6.x/pom.xml
===================================================================
--- branches/topia-2.6.x/pom.xml 2012-09-14 15:31:35 UTC (rev 2666)
+++ branches/topia-2.6.x/pom.xml 2012-09-14 15:33:14 UTC (rev 2667)
@@ -60,7 +60,7 @@
<!-- libs version -->
<eugeneVersion>2.5</eugeneVersion>
- <nuitonUtilsVersion>2.6.2-SNAPSHOT</nuitonUtilsVersion>
+ <nuitonUtilsVersion>2.6.2</nuitonUtilsVersion>
<processorPluginVersion>1.2.2</processorPluginVersion>
<nuitonI18nVersion>2.4.1</nuitonI18nVersion>
<xmlrpcVersion>3.1.2</xmlrpcVersion>
1
0
r2666 - in branches/topia-2.6.x: . topia-persistence topia-service-migration topia-service-replication topia-service-security
by tchemit@users.nuiton.org Sept. 14, 2012
by tchemit@users.nuiton.org Sept. 14, 2012
Sept. 14, 2012
Author: tchemit
Date: 2012-09-14 17:31:35 +0200 (Fri, 14 Sep 2012)
New Revision: 2666
Url: http://nuiton.org/repositories/revision/topia/2666
Log:
move to version 2.7-SNAPSHOT
Modified:
branches/topia-2.6.x/pom.xml
branches/topia-2.6.x/topia-persistence/pom.xml
branches/topia-2.6.x/topia-service-migration/pom.xml
branches/topia-2.6.x/topia-service-replication/pom.xml
branches/topia-2.6.x/topia-service-security/pom.xml
Modified: branches/topia-2.6.x/pom.xml
===================================================================
--- branches/topia-2.6.x/pom.xml 2012-09-14 10:02:42 UTC (rev 2665)
+++ branches/topia-2.6.x/pom.xml 2012-09-14 15:31:35 UTC (rev 2666)
@@ -37,7 +37,7 @@
</parent>
<artifactId>topia</artifactId>
- <version>2.6.14-SNAPSHOT</version>
+ <version>2.7-SNAPSHOT</version>
<modules>
<module>topia-persistence</module>
Modified: branches/topia-2.6.x/topia-persistence/pom.xml
===================================================================
--- branches/topia-2.6.x/topia-persistence/pom.xml 2012-09-14 10:02:42 UTC (rev 2665)
+++ branches/topia-2.6.x/topia-persistence/pom.xml 2012-09-14 15:31:35 UTC (rev 2666)
@@ -35,7 +35,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.6.14-SNAPSHOT</version>
+ <version>2.7-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.topia</groupId>
Modified: branches/topia-2.6.x/topia-service-migration/pom.xml
===================================================================
--- branches/topia-2.6.x/topia-service-migration/pom.xml 2012-09-14 10:02:42 UTC (rev 2665)
+++ branches/topia-2.6.x/topia-service-migration/pom.xml 2012-09-14 15:31:35 UTC (rev 2666)
@@ -35,7 +35,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.6.14-SNAPSHOT</version>
+ <version>2.7-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.topia</groupId>
Modified: branches/topia-2.6.x/topia-service-replication/pom.xml
===================================================================
--- branches/topia-2.6.x/topia-service-replication/pom.xml 2012-09-14 10:02:42 UTC (rev 2665)
+++ branches/topia-2.6.x/topia-service-replication/pom.xml 2012-09-14 15:31:35 UTC (rev 2666)
@@ -35,7 +35,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.6.14-SNAPSHOT</version>
+ <version>2.7-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.topia</groupId>
Modified: branches/topia-2.6.x/topia-service-security/pom.xml
===================================================================
--- branches/topia-2.6.x/topia-service-security/pom.xml 2012-09-14 10:02:42 UTC (rev 2665)
+++ branches/topia-2.6.x/topia-service-security/pom.xml 2012-09-14 15:31:35 UTC (rev 2666)
@@ -35,7 +35,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.6.14-SNAPSHOT</version>
+ <version>2.7-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.topia</groupId>
1
0
r2665 - branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager
by tchemit@users.nuiton.org Sept. 14, 2012
by tchemit@users.nuiton.org Sept. 14, 2012
Sept. 14, 2012
Author: tchemit
Date: 2012-09-14 12:02:42 +0200 (Fri, 14 Sep 2012)
New Revision: 2665
Url: http://nuiton.org/repositories/revision/topia/2665
Log:
refs #2313: Use new PageBean API from nuiton-utils (improve Topia Filter api)
Added:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterRuleGroupOperator.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterRuleOperator.java
Removed:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterOperation.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterOperationGroup.java
Modified:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterRule.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/TopiaPagerBean.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/TopiaPagerBeanBuilder.java
Deleted: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterOperation.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterOperation.java 2012-09-14 09:51:06 UTC (rev 2664)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterOperation.java 2012-09-14 10:02:42 UTC (rev 2665)
@@ -1,152 +0,0 @@
-package org.nuiton.topia.persistence.pager;
-
-import java.util.Map;
-
-/**
-* TODO
-*
-* @author tchemit <chemit(a)codelutin.com>
-* @since 2.6.14
-*/
-public enum FilterOperation {
- /** Equals operator. */
- eq {
- @Override
- public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
- String ruleFilter = propertyName + " = :" + paramName;
- filterParams.put(paramName, data);
- return ruleFilter;
- }
- },
- /** Not equals operator. */
- ne {
- @Override
- public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
- String ruleFilter = propertyName + " != :" + paramName;
- filterParams.put(paramName, data);
- return ruleFilter;
- }
- },
- /** Contains operator. */
- cn {
- @Override
- public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
- String ruleFilter = propertyName + " like :" + paramName;
- filterParams.put(paramName, "%" + data + "%");
- return ruleFilter;
- }
- },
- /** Not contains operator. */
- nc {
- @Override
- public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
- String ruleFilter = propertyName + " not like :" + paramName;
- filterParams.put(paramName, "%" + data + "%");
- return ruleFilter;
- }
- },
- /** Begins with operator. */
- bw {
- @Override
- public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
- String ruleFilter = propertyName + " like :" + paramName;
- filterParams.put(paramName, data + "%");
- return ruleFilter;
- }
- },
- /** Not between with operator. */
- bn {
- @Override
- public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
- String ruleFilter = propertyName + " not like :" + paramName;
- filterParams.put(paramName, data + "%");
- return ruleFilter;
- }
- },
- /** Ends with operator. */
- ew {
- @Override
- public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
- String ruleFilter = propertyName + " like :" + paramName;
- filterParams.put(paramName, "%" + data);
- return ruleFilter;
- }
- },
- /** Not End with operator. */
- en {
- @Override
- public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
- String ruleFilter = propertyName + " not like :" + paramName;
- filterParams.put(paramName, "%" + data);
- return ruleFilter;
- }
- },
- /** Lesser than operator. */
- lt {
- @Override
- public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
- String ruleFilter = propertyName + " < :" + paramName;
- filterParams.put(paramName, data);
- return ruleFilter;
- }
- },
- /** Lesser or equals operator. */
- le {
- @Override
- public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
- String ruleFilter = propertyName + " <= :" + paramName;
- filterParams.put(paramName, data);
- return ruleFilter;
- }
- },
- /** Greater than operator. */
- gt {
- @Override
- public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
- String ruleFilter = propertyName + " > :" + paramName;
- filterParams.put(paramName, data);
- return ruleFilter;
- }
- },
- /** Greater or equals operator. */
- ge {
- @Override
- public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
- String ruleFilter = propertyName + " >= :" + paramName;
- filterParams.put(paramName, data);
- return ruleFilter;
- }
- },
- /** Is null operator. */
- nu {
- @Override
- public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
- String ruleFilter = propertyName + " is null";
- return ruleFilter;
- }
- },
- /** Is not null operator. */
- nn {
- @Override
- public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
- String ruleFilter = propertyName + " is not null";
- return ruleFilter;
- }
- },
- /** Is among operator. */
- in {
- @Override
- public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
- throw new UnsupportedOperationException();
- }
- },
- /** Not is among operator. */
- ni {
- @Override
- public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
- throw new UnsupportedOperationException();
- }
- };
-
- public abstract String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams);
-}
Deleted: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterOperationGroup.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterOperationGroup.java 2012-09-14 09:51:06 UTC (rev 2664)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterOperationGroup.java 2012-09-14 10:02:42 UTC (rev 2665)
@@ -1,11 +0,0 @@
-package org.nuiton.topia.persistence.pager;
-
-/**
-* TODO
-*
-* @author tchemit <chemit(a)codelutin.com>
-* @since 2.6.14
-*/
-public enum FilterOperationGroup {
- OR, AND
-}
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterRule.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterRule.java 2012-09-14 09:51:06 UTC (rev 2664)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterRule.java 2012-09-14 10:02:42 UTC (rev 2665)
@@ -1,9 +1,33 @@
package org.nuiton.topia.persistence.pager;
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
import java.io.Serializable;
/**
- * TODO
+ * Rule for a filtered pager.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.6.14
@@ -12,19 +36,19 @@
private static final long serialVersionUID = 1L;
- protected final FilterOperation op;
+ protected final FilterRuleOperator op;
protected final String field;
protected final String data;
- public FilterRule(FilterOperation op, String field, String data) {
+ public FilterRule(FilterRuleOperator op, String field, String data) {
this.op = op;
this.field = field;
this.data = data;
}
- public FilterOperation getOp() {
+ public FilterRuleOperator getOp() {
return op;
}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterRule.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Copied: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterRuleGroupOperator.java (from rev 2664, branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterOperationGroup.java)
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterRuleGroupOperator.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterRuleGroupOperator.java 2012-09-14 10:02:42 UTC (rev 2665)
@@ -0,0 +1,35 @@
+package org.nuiton.topia.persistence.pager;
+
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+/**
+ * Define the operator to apply between some rules.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.14
+ */
+public enum FilterRuleGroupOperator {
+ OR, AND
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterRuleGroupOperator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterRuleOperator.java (from rev 2664, branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterOperation.java)
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterRuleOperator.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterRuleOperator.java 2012-09-14 10:02:42 UTC (rev 2665)
@@ -0,0 +1,176 @@
+package org.nuiton.topia.persistence.pager;
+
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import java.util.Map;
+
+/**
+ * Operator used in a rule.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.14
+ */
+public enum FilterRuleOperator {
+ /** Equals operator. */
+ eq {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " = :" + paramName;
+ filterParams.put(paramName, data);
+ return ruleFilter;
+ }
+ },
+ /** Not equals operator. */
+ ne {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " != :" + paramName;
+ filterParams.put(paramName, data);
+ return ruleFilter;
+ }
+ },
+ /** Contains operator. */
+ cn {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " like :" + paramName;
+ filterParams.put(paramName, "%" + data + "%");
+ return ruleFilter;
+ }
+ },
+ /** Not contains operator. */
+ nc {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " not like :" + paramName;
+ filterParams.put(paramName, "%" + data + "%");
+ return ruleFilter;
+ }
+ },
+ /** Begins with operator. */
+ bw {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " like :" + paramName;
+ filterParams.put(paramName, data + "%");
+ return ruleFilter;
+ }
+ },
+ /** Not between with operator. */
+ bn {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " not like :" + paramName;
+ filterParams.put(paramName, data + "%");
+ return ruleFilter;
+ }
+ },
+ /** Ends with operator. */
+ ew {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " like :" + paramName;
+ filterParams.put(paramName, "%" + data);
+ return ruleFilter;
+ }
+ },
+ /** Not End with operator. */
+ en {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " not like :" + paramName;
+ filterParams.put(paramName, "%" + data);
+ return ruleFilter;
+ }
+ },
+ /** Lesser than operator. */
+ lt {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " < :" + paramName;
+ filterParams.put(paramName, data);
+ return ruleFilter;
+ }
+ },
+ /** Lesser or equals operator. */
+ le {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " <= :" + paramName;
+ filterParams.put(paramName, data);
+ return ruleFilter;
+ }
+ },
+ /** Greater than operator. */
+ gt {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " > :" + paramName;
+ filterParams.put(paramName, data);
+ return ruleFilter;
+ }
+ },
+ /** Greater or equals operator. */
+ ge {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " >= :" + paramName;
+ filterParams.put(paramName, data);
+ return ruleFilter;
+ }
+ },
+ /** Is null operator. */
+ nu {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " is null";
+ return ruleFilter;
+ }
+ },
+ /** Is not null operator. */
+ nn {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " is not null";
+ return ruleFilter;
+ }
+ },
+ /** Is among operator. */
+ in {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ throw new UnsupportedOperationException();
+ }
+ },
+ /** Not is among operator. */
+ ni {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ throw new UnsupportedOperationException();
+ }
+ };
+
+ public abstract String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams);
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterRuleOperator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/TopiaPagerBean.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/TopiaPagerBean.java 2012-09-14 09:51:06 UTC (rev 2664)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/TopiaPagerBean.java 2012-09-14 10:02:42 UTC (rev 2665)
@@ -1,12 +1,36 @@
package org.nuiton.topia.persistence.pager;
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
import org.apache.commons.collections.CollectionUtils;
import org.nuiton.util.PagerBean;
import java.util.List;
/**
- * Extension of a {@link PagerBean} to add filter capacity.
+ * Extension of a {@link PagerBean} to add filter and ordering capacities.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.6.14
@@ -21,7 +45,7 @@
// get index row - i.e. user click to sort.
protected String sortColumn;
- protected FilterOperationGroup groupOp;
+ protected FilterRuleGroupOperator groupOp;
private List<FilterRule> rules;
@@ -29,11 +53,11 @@
return groupOp != null && CollectionUtils.isNotEmpty(rules);
}
- public FilterOperationGroup getGroupOp() {
+ public FilterRuleGroupOperator getGroupOp() {
return groupOp;
}
- public void setGroupOp(FilterOperationGroup groupOp) {
+ public void setGroupOp(FilterRuleGroupOperator groupOp) {
this.groupOp = groupOp;
}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/TopiaPagerBean.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/TopiaPagerBeanBuilder.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/TopiaPagerBeanBuilder.java 2012-09-14 09:51:06 UTC (rev 2664)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/TopiaPagerBeanBuilder.java 2012-09-14 10:02:42 UTC (rev 2665)
@@ -1,5 +1,29 @@
package org.nuiton.topia.persistence.pager;
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
@@ -23,7 +47,7 @@
this.bean = bean;
}
- public TopiaPagerBeanBuilder setFilterOperationGroup(FilterOperationGroup groupOp) {
+ public TopiaPagerBeanBuilder setFilterRuleGroup(FilterRuleGroupOperator groupOp) {
bean.setGroupOp(groupOp);
return this;
}
@@ -39,19 +63,19 @@
}
public TopiaPagerBeanBuilder setFilterOperationGroup(String groupOp) {
- setFilterOperationGroup(FilterOperationGroup.valueOf(groupOp));
+ setFilterRuleGroup(FilterRuleGroupOperator.valueOf(groupOp));
return this;
}
- public TopiaPagerBeanBuilder addOperations(Collection<Map<String, String>> operations) {
- for (Map<String, String> operation : operations) {
- addRule(operation);
+ public TopiaPagerBeanBuilder addRules(Collection<Map<String, String>> rules) {
+ for (Map<String, String> rule : rules) {
+ addRule(rule);
}
return this;
}
public TopiaPagerBeanBuilder addRule(String op, String property, String value) {
- FilterOperation operator = FilterOperation.valueOf(op);
+ FilterRuleOperator operator = FilterRuleOperator.valueOf(op);
return addRule(new FilterRule(operator, property, value));
}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/TopiaPagerBeanBuilder.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
1
0
r2664 - in branches/topia-2.6.x: . topia-persistence/src/main/java/org/nuiton/topia/framework topia-persistence/src/main/java/org/nuiton/topia/persistence topia-persistence/src/main/java/org/nuiton/topia/persistence/pager
by tchemit@users.nuiton.org Sept. 14, 2012
by tchemit@users.nuiton.org Sept. 14, 2012
Sept. 14, 2012
Author: tchemit
Date: 2012-09-14 11:51:06 +0200 (Fri, 14 Sep 2012)
New Revision: 2664
Url: http://nuiton.org/repositories/revision/topia/2664
Log:
fixes #2313: Use new PageBean from nuiton-utils + refs #2314: Updates to nuiton-utils 2.6.2
Added:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterOperation.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterOperationGroup.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterRule.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/TopiaPagerBean.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/TopiaPagerBeanBuilder.java
Modified:
branches/topia-2.6.x/pom.xml
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaSQLQuery.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAODeprecated.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaFilterPagerUtil.java
Modified: branches/topia-2.6.x/pom.xml
===================================================================
--- branches/topia-2.6.x/pom.xml 2012-09-13 09:23:35 UTC (rev 2663)
+++ branches/topia-2.6.x/pom.xml 2012-09-14 09:51:06 UTC (rev 2664)
@@ -60,7 +60,7 @@
<!-- libs version -->
<eugeneVersion>2.5</eugeneVersion>
- <nuitonUtilsVersion>2.6</nuitonUtilsVersion>
+ <nuitonUtilsVersion>2.6.2-SNAPSHOT</nuitonUtilsVersion>
<processorPluginVersion>1.2.2</processorPluginVersion>
<nuitonI18nVersion>2.4.1</nuitonI18nVersion>
<xmlrpcVersion>3.1.2</xmlrpcVersion>
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaSQLQuery.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaSQLQuery.java 2012-09-13 09:23:35 UTC (rev 2663)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaSQLQuery.java 2012-09-14 09:51:06 UTC (rev 2664)
@@ -212,9 +212,9 @@
* @throws SQLException if any pb
* @since 2.6.4
*/
- protected int getNbRows(ResultSet set) throws SQLException {
+ protected long getNbRows(ResultSet set) throws SQLException {
- int nbRows = 0;
+ long nbRows = 0;
while (set.next()) {
nbRows++;
}
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java 2012-09-13 09:23:35 UTC (rev 2663)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java 2012-09-14 09:51:06 UTC (rev 2664)
@@ -41,8 +41,8 @@
import org.nuiton.topia.event.TopiaEntityVetoable;
import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.generator.EntityDAOTransformer;
+import org.nuiton.topia.persistence.pager.TopiaPagerBean;
-import java.security.Permission;
import java.util.List;
import java.util.Map;
@@ -442,12 +442,12 @@
* @param params params of the query
* @return entities of the paginated query result
* @throws TopiaException if any pb while getting datas
- * @see TopiaFilterPagerUtil.FilterPagerBean
+ * @see TopiaPagerBean
* @since 2.6.12
*/
<R> List<R> findAllByQueryAndPager(Class<R> type,
String hql,
- TopiaFilterPagerUtil.FilterPagerBean pager,
+ TopiaPagerBean pager,
Object... params) throws TopiaException;
/**
@@ -459,11 +459,11 @@
* @param params params of the query
* @return entities of the paginated query result
* @throws TopiaException if any pb while getting datas
- * @see TopiaFilterPagerUtil.FilterPagerBean
+ * @see TopiaPagerBean
* @since 2.6.12
*/
List<E> findAllByQueryAndPager(String hql,
- TopiaFilterPagerUtil.FilterPagerBean pager,
+ TopiaPagerBean pager,
Object... params) throws TopiaException;
/**
@@ -592,18 +592,18 @@
/**
* Execute the count {@code hql} query and then synch the pager to this
* result (says fill the
- * {@link TopiaFilterPagerUtil.FilterPagerBean#records} field and then adapt
+ * {@link TopiaPagerBean#records} field and then adapt
* the number of pages available and the current number page).
*
* @param hql the count hql to execute
* @param pager the page to synch
* @param params params of the count query
* @throws TopiaException if any pb while getting datas
- * @see TopiaFilterPagerUtil.FilterPagerBean
+ * @see TopiaPagerBean
* @since 2.6.12
*/
void computeAndAddRecordsToPager(String hql,
- TopiaFilterPagerUtil.FilterPagerBean pager,
+ TopiaPagerBean pager,
Object... params) throws TopiaException;
//------------------------------------------------------------------------//
@@ -661,16 +661,17 @@
TopiaContextImplementor getContext();
/**
- * Retourne les permissions a verifier pour l'acces a l'entite pour le
- * service Taas.
+ * Create the simple hql query for the entity managed by the dao.
+ * <p/>
+ * A optional alias can be passed:
+ * <p/>
+ * <pre>FROM MyEntityImpl myAlias</pre>
*
- * @param topiaId topiaId d'une entite
- * @param actions encoded actions
- * @return la liste des permissions
- * @throws TopiaException if any pb while getting datas
+ * @param alias optional alias to use in query
+ * @return the hql query
+ * @since 2.6.14
*/
- List<Permission> getRequestPermission(String topiaId, int actions)
- throws TopiaException;
+ String createSimpleQuery(String alias);
//------------------------------------------------------------------------//
//-- Listener methods ----------------------------------------------------//
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAODeprecated.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAODeprecated.java 2012-09-13 09:23:35 UTC (rev 2663)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAODeprecated.java 2012-09-14 09:51:06 UTC (rev 2664)
@@ -27,6 +27,7 @@
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
+import java.security.Permission;
import java.util.List;
import java.util.Map;
@@ -152,4 +153,17 @@
*/
@Deprecated
int countByQuery(TopiaQuery query) throws TopiaException;
+
+ /**
+ * Retourne les permissions a verifier pour l'acces a l'entite pour le
+ * service Taas.
+ *
+ * @param topiaId topiaId d'une entite
+ * @param actions encoded actions
+ * @return la liste des permissions
+ * @throws TopiaException if any pb while getting datas
+ * @deprecated since 2.6.14, {@link TopiaQuery} will be removed in version 3.0
+ */
+ List<Permission> getRequestPermission(String topiaId, int actions)
+ throws TopiaException;
}
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java 2012-09-13 09:23:35 UTC (rev 2663)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java 2012-09-14 09:51:06 UTC (rev 2664)
@@ -52,7 +52,8 @@
import org.nuiton.topia.event.TopiaEntityVetoable;
import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.framework.TopiaQuery;
-import org.nuiton.util.PagerUtil;
+import org.nuiton.topia.persistence.pager.TopiaPagerBean;
+import org.nuiton.util.PagerBeanUtil;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
@@ -198,6 +199,15 @@
return context;
}
+ @Override
+ public String createSimpleQuery(String alias) {
+ String hql = "FROM " + getTopiaEntityEnum().getImplementationFQN();
+ if (StringUtils.isNotBlank(alias)) {
+ hql += " " + alias;
+ }
+ return hql;
+ }
+
@SuppressWarnings("unchecked")
@Override
public E newInstance() throws TopiaException {
@@ -758,7 +768,7 @@
@Override
public <R> List<R> findAllByQueryAndPager(Class<R> type,
String hql,
- TopiaFilterPagerUtil.FilterPagerBean pager,
+ TopiaPagerBean pager,
Object... params) throws TopiaException {
Preconditions.checkNotNull(pager);
Preconditions.checkNotNull(hql);
@@ -770,15 +780,15 @@
}
}
List<R> result = findAllByQueryWithBound(type, hql,
- pager.getRecordStartIndex(),
- pager.getRecordEndIndex() - 1,
+ (int) pager.getRecordStartIndex(),
+ (int) pager.getRecordEndIndex() - 1,
params);
return result;
}
@Override
public List<E> findAllByQueryAndPager(String hql,
- TopiaFilterPagerUtil.FilterPagerBean pager,
+ TopiaPagerBean pager,
Object... params) throws TopiaException {
return findAllByQueryAndPager(getEntityClass(),
@@ -789,13 +799,13 @@
@Override
public void computeAndAddRecordsToPager(String hql,
- TopiaFilterPagerUtil.FilterPagerBean pager,
+ TopiaPagerBean pager,
Object... params) throws TopiaException {
long records = countByQuery(hql, params);
- pager.setRecords((int) records);
- PagerUtil.computeRecordIndexesAndPagesNumber(pager);
+ pager.setRecords(records);
+ PagerBeanUtil.computeRecordIndexesAndPagesNumber(pager);
}
/**
@@ -837,7 +847,7 @@
protected final Object[] params;
- protected TopiaFilterPagerUtil.FilterPagerBean pager;
+ protected TopiaPagerBean pager;
public FindAllIterator(TopiaDAO<E> dao,
Class<R> type,
@@ -858,11 +868,12 @@
}
// get the count (removing the order-by)
- long count2 = dao.countByQuery("SELECT COUNT(*) " + hql.substring(0, i), params);
- pager = TopiaFilterPagerUtil.newFilterPagerBean();
- pager.setRecords((int) count2);
+ long count2 = dao.countByQuery("SELECT COUNT(*) " +
+ hql.substring(0, i), params);
+ pager = new TopiaPagerBean();
+ pager.setRecords(count2);
pager.setPageSize(batchSize);
- TopiaFilterPagerUtil.computeRecordIndexesAndPagesNumber(pager);
+ PagerBeanUtil.computeRecordIndexesAndPagesNumber(pager);
} catch (TopiaException e) {
throw new TopiaRuntimeException(e);
}
@@ -889,7 +900,7 @@
// increments page index
pager.setPageIndex(pager.getPageIndex() + 1);
- TopiaFilterPagerUtil.computeRecordIndexesAndPagesNumber(pager);
+ PagerBeanUtil.computeRecordIndexesAndPagesNumber(pager);
// load new window of data
try {
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaFilterPagerUtil.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaFilterPagerUtil.java 2012-09-13 09:23:35 UTC (rev 2663)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaFilterPagerUtil.java 2012-09-14 09:51:06 UTC (rev 2664)
@@ -27,6 +27,7 @@
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.persistence.pager.TopiaPagerBean;
import org.nuiton.util.PagerUtil;
import java.io.Serializable;
@@ -42,7 +43,9 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.6.9
+ * @deprecated since 2.6.14, use now {@link TopiaPagerBean}.
*/
+@Deprecated
public class TopiaFilterPagerUtil extends PagerUtil {
protected TopiaFilterPagerUtil() {
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterOperation.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterOperation.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterOperation.java 2012-09-14 09:51:06 UTC (rev 2664)
@@ -0,0 +1,152 @@
+package org.nuiton.topia.persistence.pager;
+
+import java.util.Map;
+
+/**
+* TODO
+*
+* @author tchemit <chemit(a)codelutin.com>
+* @since 2.6.14
+*/
+public enum FilterOperation {
+ /** Equals operator. */
+ eq {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " = :" + paramName;
+ filterParams.put(paramName, data);
+ return ruleFilter;
+ }
+ },
+ /** Not equals operator. */
+ ne {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " != :" + paramName;
+ filterParams.put(paramName, data);
+ return ruleFilter;
+ }
+ },
+ /** Contains operator. */
+ cn {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " like :" + paramName;
+ filterParams.put(paramName, "%" + data + "%");
+ return ruleFilter;
+ }
+ },
+ /** Not contains operator. */
+ nc {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " not like :" + paramName;
+ filterParams.put(paramName, "%" + data + "%");
+ return ruleFilter;
+ }
+ },
+ /** Begins with operator. */
+ bw {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " like :" + paramName;
+ filterParams.put(paramName, data + "%");
+ return ruleFilter;
+ }
+ },
+ /** Not between with operator. */
+ bn {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " not like :" + paramName;
+ filterParams.put(paramName, data + "%");
+ return ruleFilter;
+ }
+ },
+ /** Ends with operator. */
+ ew {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " like :" + paramName;
+ filterParams.put(paramName, "%" + data);
+ return ruleFilter;
+ }
+ },
+ /** Not End with operator. */
+ en {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " not like :" + paramName;
+ filterParams.put(paramName, "%" + data);
+ return ruleFilter;
+ }
+ },
+ /** Lesser than operator. */
+ lt {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " < :" + paramName;
+ filterParams.put(paramName, data);
+ return ruleFilter;
+ }
+ },
+ /** Lesser or equals operator. */
+ le {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " <= :" + paramName;
+ filterParams.put(paramName, data);
+ return ruleFilter;
+ }
+ },
+ /** Greater than operator. */
+ gt {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " > :" + paramName;
+ filterParams.put(paramName, data);
+ return ruleFilter;
+ }
+ },
+ /** Greater or equals operator. */
+ ge {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " >= :" + paramName;
+ filterParams.put(paramName, data);
+ return ruleFilter;
+ }
+ },
+ /** Is null operator. */
+ nu {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " is null";
+ return ruleFilter;
+ }
+ },
+ /** Is not null operator. */
+ nn {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ String ruleFilter = propertyName + " is not null";
+ return ruleFilter;
+ }
+ },
+ /** Is among operator. */
+ in {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ throw new UnsupportedOperationException();
+ }
+ },
+ /** Not is among operator. */
+ ni {
+ @Override
+ public String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams) {
+ throw new UnsupportedOperationException();
+ }
+ };
+
+ public abstract String toHql(String paramName, String propertyName, Object data, Map<String, Object> filterParams);
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterOperation.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterOperationGroup.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterOperationGroup.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterOperationGroup.java 2012-09-14 09:51:06 UTC (rev 2664)
@@ -0,0 +1,11 @@
+package org.nuiton.topia.persistence.pager;
+
+/**
+* TODO
+*
+* @author tchemit <chemit(a)codelutin.com>
+* @since 2.6.14
+*/
+public enum FilterOperationGroup {
+ OR, AND
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterOperationGroup.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterRule.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterRule.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterRule.java 2012-09-14 09:51:06 UTC (rev 2664)
@@ -0,0 +1,38 @@
+package org.nuiton.topia.persistence.pager;
+
+import java.io.Serializable;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.14
+ */
+public class FilterRule implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected final FilterOperation op;
+
+ protected final String field;
+
+ protected final String data;
+
+ public FilterRule(FilterOperation op, String field, String data) {
+ this.op = op;
+ this.field = field;
+ this.data = data;
+ }
+
+ public FilterOperation getOp() {
+ return op;
+ }
+
+ public String getField() {
+ return field;
+ }
+
+ public String getData() {
+ return data;
+ }
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/FilterRule.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/TopiaPagerBean.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/TopiaPagerBean.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/TopiaPagerBean.java 2012-09-14 09:51:06 UTC (rev 2664)
@@ -0,0 +1,64 @@
+package org.nuiton.topia.persistence.pager;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.nuiton.util.PagerBean;
+
+import java.util.List;
+
+/**
+ * Extension of a {@link PagerBean} to add filter capacity.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.14
+ */
+public class TopiaPagerBean extends PagerBean {
+
+ private static final long serialVersionUID = 1L;
+
+ // sorting order - asc or desc
+ protected boolean sortAscendant;
+
+ // get index row - i.e. user click to sort.
+ protected String sortColumn;
+
+ protected FilterOperationGroup groupOp;
+
+ private List<FilterRule> rules;
+
+ public boolean canFilter() {
+ return groupOp != null && CollectionUtils.isNotEmpty(rules);
+ }
+
+ public FilterOperationGroup getGroupOp() {
+ return groupOp;
+ }
+
+ public void setGroupOp(FilterOperationGroup groupOp) {
+ this.groupOp = groupOp;
+ }
+
+ public List<FilterRule> getRules() {
+ return rules;
+ }
+
+ public void setRules(List<FilterRule> rules) {
+ this.rules = rules;
+ }
+
+ public boolean isSortAscendant() {
+ return sortAscendant;
+ }
+
+ public void setSortAscendant(boolean sortAscendant) {
+ this.sortAscendant = sortAscendant;
+ }
+
+ public String getSortColumn() {
+ return sortColumn;
+ }
+
+ public void setSortColumn(String sortColumn) {
+ this.sortColumn = sortColumn;
+ }
+
+}
\ No newline at end of file
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/TopiaPagerBean.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/TopiaPagerBeanBuilder.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/TopiaPagerBeanBuilder.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/TopiaPagerBeanBuilder.java 2012-09-14 09:51:06 UTC (rev 2664)
@@ -0,0 +1,78 @@
+package org.nuiton.topia.persistence.pager;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * To build a {@link TopiaPagerBean} from scratch.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.14
+ */
+public class TopiaPagerBeanBuilder {
+
+ protected final TopiaPagerBean bean;
+
+ public TopiaPagerBeanBuilder() {
+ this(new TopiaPagerBean());
+ }
+
+ public TopiaPagerBeanBuilder(TopiaPagerBean bean) {
+ this.bean = bean;
+ }
+
+ public TopiaPagerBeanBuilder setFilterOperationGroup(FilterOperationGroup groupOp) {
+ bean.setGroupOp(groupOp);
+ return this;
+ }
+
+ public TopiaPagerBeanBuilder setSortcolumn(String sortColumn) {
+ bean.setSortColumn(sortColumn);
+ return this;
+ }
+
+ public TopiaPagerBeanBuilder setSortAscendant(boolean sortAscendant) {
+ bean.setSortAscendant(sortAscendant);
+ return this;
+ }
+
+ public TopiaPagerBeanBuilder setFilterOperationGroup(String groupOp) {
+ setFilterOperationGroup(FilterOperationGroup.valueOf(groupOp));
+ return this;
+ }
+
+ public TopiaPagerBeanBuilder addOperations(Collection<Map<String, String>> operations) {
+ for (Map<String, String> operation : operations) {
+ addRule(operation);
+ }
+ return this;
+ }
+
+ public TopiaPagerBeanBuilder addRule(String op, String property, String value) {
+ FilterOperation operator = FilterOperation.valueOf(op);
+ return addRule(new FilterRule(operator, property, value));
+ }
+
+ public TopiaPagerBeanBuilder addRule(Map<String, String> ruleMap) {
+ String op = ruleMap.get("op");
+ String property = ruleMap.get("field");
+ String value = ruleMap.get("data");
+ return addRule(op, property, value);
+ }
+
+ public TopiaPagerBeanBuilder addRule(FilterRule rule) {
+ List<FilterRule> rules = bean.getRules();
+ if (rules == null) {
+ rules = new LinkedList<FilterRule>();
+ bean.setRules(rules);
+ }
+ rules.add(rule);
+ return this;
+ }
+
+ public TopiaPagerBean toBean() {
+ return bean;
+ }
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/pager/TopiaPagerBeanBuilder.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
1
0
r2663 - in branches/topia-2.6.x/topia-persistence/src: main/java/org/nuiton/topia/persistence test/java/org/nuiton/topia/persistence
by tchemit@users.nuiton.org Sept. 13, 2012
by tchemit@users.nuiton.org Sept. 13, 2012
Sept. 13, 2012
Author: tchemit
Date: 2012-09-13 11:23:35 +0200 (Thu, 13 Sep 2012)
New Revision: 2663
Url: http://nuiton.org/repositories/revision/topia/2663
Log:
refs #2301: Add methods findAllLazyByQuery on TopiaDAO to iterate on result by a lazy mecanism (force to have an orber by in the incoming hql)"
Modified:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java
branches/topia-2.6.x/topia-persistence/src/test/java/org/nuiton/topia/persistence/TopiaDAOTest.java
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java 2012-09-13 04:51:15 UTC (rev 2662)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java 2012-09-13 09:23:35 UTC (rev 2663)
@@ -133,7 +133,7 @@
this,
getEntityClass(),
batchSize,
- "FROM " + getTopiaEntityEnum().getImplementationFQN());
+ "FROM " + getTopiaEntityEnum().getImplementationFQN() + " ORDER BY id");
return iterator;
}
@@ -849,9 +849,18 @@
this.hql = hql;
this.params = params;
try {
- long count = dao.countByQuery("SELECT COUNT(*) " + hql, params);
+ String hql2 = hql.toLowerCase();
+ int i = hql2.indexOf("order by");
+ if (i == -1) {
+ throw new IllegalStateException(
+ "must have a *order by* in hql, " +
+ "but did not find it in " + hql);
+ }
+
+ // get the count (removing the order-by)
+ long count2 = dao.countByQuery("SELECT COUNT(*) " + hql.substring(0, i), params);
pager = TopiaFilterPagerUtil.newFilterPagerBean();
- pager.setRecords((int) count);
+ pager.setRecords((int) count2);
pager.setPageSize(batchSize);
TopiaFilterPagerUtil.computeRecordIndexesAndPagesNumber(pager);
} catch (TopiaException e) {
Modified: branches/topia-2.6.x/topia-persistence/src/test/java/org/nuiton/topia/persistence/TopiaDAOTest.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/test/java/org/nuiton/topia/persistence/TopiaDAOTest.java 2012-09-13 04:51:15 UTC (rev 2662)
+++ branches/topia-2.6.x/topia-persistence/src/test/java/org/nuiton/topia/persistence/TopiaDAOTest.java 2012-09-13 09:23:35 UTC (rev 2663)
@@ -107,7 +107,7 @@
Iterable<Person> allByLazy = dao.findAllLazyByQuery(
100,
- "FROM " + dao.getTopiaEntityEnum().getImplementationFQN());
+ "FROM " + dao.getTopiaEntityEnum().getImplementationFQN() + " ORDER BY id");
List<Person> actual = Lists.newArrayList();
@@ -118,7 +118,7 @@
allByLazy = dao.findAllLazyByQuery(
54,
- "FROM " + dao.getTopiaEntityEnum().getImplementationFQN());
+ "FROM " + dao.getTopiaEntityEnum().getImplementationFQN() + " ORDER BY id");
actual = Lists.newArrayList();
@@ -129,7 +129,7 @@
allByLazy = dao.findAllLazyByQuery(
49,
- "FROM " + dao.getTopiaEntityEnum().getImplementationFQN());
+ "FROM " + dao.getTopiaEntityEnum().getImplementationFQN() + " ORDER BY id");
actual = Lists.newArrayList();
@@ -140,7 +140,7 @@
allByLazy = dao.findAllLazyByQuery(
101,
- "FROM " + dao.getTopiaEntityEnum().getImplementationFQN());
+ "FROM " + dao.getTopiaEntityEnum().getImplementationFQN() + " ORDER BY id");
actual = Lists.newArrayList();
@@ -151,7 +151,7 @@
allByLazy = dao.findAllLazyByQuery(
102,
- "FROM " + dao.getTopiaEntityEnum().getImplementationFQN());
+ "FROM " + dao.getTopiaEntityEnum().getImplementationFQN() + " ORDER BY id");
actual = Lists.newArrayList();
1
0
r2662 - branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out
by tchemit@users.nuiton.org Sept. 13, 2012
by tchemit@users.nuiton.org Sept. 13, 2012
Sept. 13, 2012
Author: tchemit
Date: 2012-09-13 06:51:15 +0200 (Thu, 13 Sep 2012)
New Revision: 2662
Url: http://nuiton.org/repositories/revision/topia/2662
Log:
fixes #2311: Improve entity visitor to export as csv files
Removed:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/Entity2.java
Modified:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/ExportEntityVisitor.java
Deleted: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/Entity2.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/Entity2.java 2012-09-12 15:04:21 UTC (rev 2661)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/Entity2.java 2012-09-13 04:51:15 UTC (rev 2662)
@@ -1,40 +0,0 @@
-package org.nuiton.topia.persistence.csv.out;
-/*
- * #%L
- * ToPIA :: Persistence
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2012 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-import org.nuiton.topia.persistence.EntityVisitor;
-import org.nuiton.topia.persistence.TopiaEntity;
-
-/**
- * To mark some entites visitable but not by generatl
- * {@link TopiaEntity#accept(EntityVisitor)} method.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.6.12
- */
-public interface Entity2 {
-
- void accept2(EntityVisitor visitor);
-
-}
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/ExportEntityVisitor.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/ExportEntityVisitor.java 2012-09-12 15:04:21 UTC (rev 2661)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/ExportEntityVisitor.java 2012-09-13 04:51:15 UTC (rev 2662)
@@ -155,24 +155,26 @@
if (CollectionUtils.isNotEmpty(cValue)) {
- if (isNoChildVisit(propertyName, entity) &&
- Entity2.class.isAssignableFrom(type)) {
+ visitEntityCollection(entity,
+ propertyName,
+ collectionType,
+ type,
+ cValue);
+ }
+ }
+ }
- // special case, when visiting a entity with no child
- // visisting at this time...
- for (Object currentValue : cValue) {
- ((Entity2) currentValue).accept2(this);
- }
- } else {
- for (Object currentValue : cValue) {
- try {
- ((TopiaEntity) currentValue).accept(this);
- } catch (TopiaException e) {
- if (log.isErrorEnabled()) {
- log.error("Can not visit entity " + value, e);
- }
- }
- }
+ protected void visitEntityCollection(TopiaEntity entity,
+ String propertyName,
+ Class<?> collectionType,
+ Class<?> type,
+ Collection<?> cValue) {
+ for (Object currentValue : cValue) {
+ try {
+ ((TopiaEntity) currentValue).accept(this);
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can not visit entity " + currentValue, e);
}
}
}
@@ -207,10 +209,4 @@
T entityEnum = persistenceHelper.getEntityEnum(entityType);
return entityEnum == null ? null : entityExporters.get(entityEnum);
}
-
- protected boolean isNoChildVisit(String propertyName, TopiaEntity entity) {
-
- // by default accept all associations
- return false;
- }
}
1
0
r2661 - in branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv: . in
by tchemit@users.nuiton.org Sept. 12, 2012
by tchemit@users.nuiton.org Sept. 12, 2012
Sept. 12, 2012
Author: tchemit
Date: 2012-09-12 17:04:21 +0200 (Wed, 12 Sep 2012)
New Revision: 2661
Url: http://nuiton.org/repositories/revision/topia/2661
Log:
refs #2310: Add progress model while importing data
Added:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/CsvProgressModel.java
Removed:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/CsvProgressionModel.java
Modified:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvImportResult.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/TopiaCsvImports.java
Copied: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/CsvProgressModel.java (from rev 2660, branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/CsvProgressionModel.java)
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/CsvProgressModel.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/CsvProgressModel.java 2012-09-12 15:04:21 UTC (rev 2661)
@@ -0,0 +1,46 @@
+package org.nuiton.topia.persistence.csv;
+
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import java.io.Serializable;
+
+/**
+ * Csv progress model contract.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.14
+ */
+public interface CsvProgressModel extends Serializable {
+
+ long getNbSteps();
+
+ void setNbSteps(long nbSteps);
+
+ float getProgress();
+
+ void setProgress(float progress);
+
+ void incrementsProgress();
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/CsvProgressModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/CsvProgressionModel.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/CsvProgressionModel.java 2012-09-11 16:47:05 UTC (rev 2660)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/CsvProgressionModel.java 2012-09-12 15:04:21 UTC (rev 2661)
@@ -1,46 +0,0 @@
-package org.nuiton.topia.persistence.csv;
-
-/*
- * #%L
- * ToPIA :: Persistence
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2012 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-import java.io.Serializable;
-
-/**
- * Csv progression model contract.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.6.13
- */
-public interface CsvProgressionModel extends Serializable {
-
- long getNbSteps();
-
- float getProgression();
-
- void setProgression(float progression);
-
- void incrementsProgression();
-
- void setNbSteps(long nbSteps);
-}
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvImportResult.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvImportResult.java 2012-09-11 16:47:05 UTC (rev 2660)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvImportResult.java 2012-09-12 15:04:21 UTC (rev 2661)
@@ -24,7 +24,7 @@
*/
import org.nuiton.topia.persistence.TopiaEntityEnum;
-import org.nuiton.topia.persistence.csv.CsvProgressionModel;
+import org.nuiton.topia.persistence.csv.CsvProgressModel;
import java.io.Serializable;
@@ -54,7 +54,7 @@
/** Count of updated entities. */
protected int numberUpdated;
- protected final CsvProgressionModel progressionModel;
+ protected final CsvProgressModel progressModel;
public static <T extends TopiaEntityEnum> CsvImportResult<T> newResult(T entityType,
String importFileName,
@@ -67,20 +67,20 @@
public static <T extends TopiaEntityEnum> CsvImportResult<T> newResult(T entityType,
String importFileName,
boolean createIfNotFound,
- CsvProgressionModel progressionModel) {
+ CsvProgressModel progressModel) {
CsvImportResult<T> result = new CsvImportResult<T>(entityType, importFileName,
- createIfNotFound, progressionModel);
+ createIfNotFound, progressModel);
return result;
}
protected CsvImportResult(T entityType,
String importFileName,
boolean createIfNotFound,
- CsvProgressionModel progressionModel) {
+ CsvProgressModel progressModel) {
this.entityType = entityType;
this.importFileName = importFileName;
this.createIfNotFound = createIfNotFound;
- this.progressionModel = progressionModel;
+ this.progressModel = progressModel;
}
public T getEntityType() {
@@ -112,7 +112,7 @@
numberUpdated++;
}
- public CsvProgressionModel getProgressionModel() {
- return progressionModel;
+ public CsvProgressModel getProgressModel() {
+ return progressModel;
}
}
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/TopiaCsvImports.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/TopiaCsvImports.java 2012-09-11 16:47:05 UTC (rev 2660)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/TopiaCsvImports.java 2012-09-12 15:04:21 UTC (rev 2661)
@@ -35,7 +35,7 @@
import org.nuiton.topia.persistence.TopiaDAO;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.TopiaEntityEnum;
-import org.nuiton.topia.persistence.csv.CsvProgressionModel;
+import org.nuiton.topia.persistence.csv.CsvProgressModel;
import org.nuiton.topia.persistence.metadata.AssociationMeta;
import org.nuiton.topia.persistence.metadata.MetaFilenameAware;
import org.nuiton.topia.persistence.metadata.TableMeta;
@@ -248,8 +248,8 @@
Import<E> importer,
CsvImportResult<T> csvResult) throws TopiaException {
- CsvProgressionModel progressionModel = csvResult == null ? null :
- csvResult.getProgressionModel();
+ CsvProgressModel progressModel = csvResult == null ? null :
+ csvResult.getProgressModel();
for (E entity : importer) {
Map<String, Object> properties = meta.prepareCreate(
@@ -260,8 +260,8 @@
if (csvResult != null) {
csvResult.incrementsNumberUpdated();
- if (progressionModel != null) {
- progressionModel.incrementsProgression();
+ if (progressModel != null) {
+ progressModel.incrementsProgress();
}
}
}
@@ -275,8 +275,8 @@
TopiaContextImplementor context = dao.getContext();
- CsvProgressionModel progressionModel = csvResult == null ? null :
- csvResult.getProgressionModel();
+ CsvProgressModel progressModel = csvResult == null ? null :
+ csvResult.getProgressModel();
int compt = 0;
for (E entity : importer) {
@@ -289,8 +289,8 @@
if (csvResult != null) {
csvResult.incrementsNumberUpdated();
- if (progressionModel != null) {
- progressionModel.incrementsProgression();
+ if (progressModel != null) {
+ progressModel.incrementsProgress();
}
}
compt++;
@@ -306,8 +306,8 @@
Import<E> importer,
CsvImportResult<T> csvResult) throws TopiaException {
- CsvProgressionModel progressionModel = csvResult == null ? null :
- csvResult.getProgressionModel();
+ CsvProgressModel progressModel = csvResult == null ? null :
+ csvResult.getProgressModel();
List<E> result = Lists.newArrayList();
for (E entity : importer) {
@@ -319,8 +319,8 @@
if (csvResult != null) {
csvResult.incrementsNumberUpdated();
- if (progressionModel != null) {
- progressionModel.incrementsProgression();
+ if (progressModel != null) {
+ progressModel.incrementsProgress();
}
}
@@ -335,8 +335,8 @@
Import<E> importer,
CsvImportResult<T> csvResult) throws TopiaException {
- CsvProgressionModel progressionModel = csvResult == null ? null :
- csvResult.getProgressionModel();
+ CsvProgressModel progressModel = csvResult == null ? null :
+ csvResult.getProgressModel();
for (E entity : importer) {
String topiaId = entity.getTopiaId();
@@ -360,8 +360,8 @@
if (csvResult != null) {
csvResult.incrementsNumberCreated();
- if (progressionModel != null) {
- progressionModel.incrementsProgression();
+ if (progressModel != null) {
+ progressModel.incrementsProgress();
}
}
} else {
@@ -382,8 +382,8 @@
CsvImportResult<T> csvResult,
int nbRowBuffer) throws TopiaException {
- CsvProgressionModel progressionModel = csvResult == null ? null :
- csvResult.getProgressionModel();
+ CsvProgressModel progressModel = csvResult == null ? null :
+ csvResult.getProgressModel();
T source = meta.getSource();
T target = meta.getTarget();
@@ -415,8 +415,8 @@
}
if (csvResult != null) {
csvResult.incrementsNumberUpdated();
- if (progressionModel != null) {
- progressionModel.incrementsProgression();
+ if (progressModel != null) {
+ progressModel.incrementsProgress();
}
}
}
@@ -431,8 +431,8 @@
CsvImportResult<T> csvResult,
int nbRowBuffer) throws TopiaException {
- CsvProgressionModel progressionModel = csvResult == null ? null :
- csvResult.getProgressionModel();
+ CsvProgressModel progressModel = csvResult == null ? null :
+ csvResult.getProgressModel();
T source = meta.getSource();
T target = meta.getTarget();
@@ -468,8 +468,8 @@
}
if (csvResult != null) {
csvResult.incrementsNumberUpdated();
- if (progressionModel != null) {
- progressionModel.incrementsProgression();
+ if (progressModel != null) {
+ progressModel.incrementsProgress();
}
}
}
@@ -485,8 +485,8 @@
CsvImportResult<T> csvResult,
int nbRowBuffer) throws TopiaException {
- CsvProgressionModel progressionModel = csvResult == null ? null :
- csvResult.getProgressionModel();
+ CsvProgressModel progressModel = csvResult == null ? null :
+ csvResult.getProgressModel();
T source = meta.getSource();
T target = meta.getTarget();
@@ -524,8 +524,8 @@
}
if (csvResult != null) {
csvResult.incrementsNumberUpdated();
- if (progressionModel != null) {
- progressionModel.incrementsProgression();
+ if (progressModel != null) {
+ progressModel.incrementsProgress();
}
}
}
@@ -541,8 +541,8 @@
CsvImportResult<T> csvResult,
int nbRowBuffer) throws TopiaException {
- CsvProgressionModel progressionModel = csvResult == null ? null :
- csvResult.getProgressionModel();
+ CsvProgressModel progressModel = csvResult == null ? null :
+ csvResult.getProgressModel();
T source = meta.getSource();
T target = meta.getTarget();
@@ -578,8 +578,8 @@
}
if (csvResult != null) {
csvResult.incrementsNumberUpdated();
- if (progressionModel != null) {
- progressionModel.incrementsProgression();
+ if (progressModel != null) {
+ progressModel.incrementsProgress();
}
}
}
1
0
r2660 - in branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv: . in
by tchemit@users.nuiton.org Sept. 11, 2012
by tchemit@users.nuiton.org Sept. 11, 2012
Sept. 11, 2012
Author: tchemit
Date: 2012-09-11 18:47:05 +0200 (Tue, 11 Sep 2012)
New Revision: 2660
Url: http://nuiton.org/repositories/revision/topia/2660
Log:
fixes #2310: Add progression model while importing data
Added:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/CsvProgressionModel.java
Modified:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvImportResult.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/TopiaCsvImports.java
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/CsvProgressionModel.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/CsvProgressionModel.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/CsvProgressionModel.java 2012-09-11 16:47:05 UTC (rev 2660)
@@ -0,0 +1,46 @@
+package org.nuiton.topia.persistence.csv;
+
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import java.io.Serializable;
+
+/**
+ * Csv progression model contract.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.13
+ */
+public interface CsvProgressionModel extends Serializable {
+
+ long getNbSteps();
+
+ float getProgression();
+
+ void setProgression(float progression);
+
+ void incrementsProgression();
+
+ void setNbSteps(long nbSteps);
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/CsvProgressionModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvImportResult.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvImportResult.java 2012-09-10 12:29:27 UTC (rev 2659)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvImportResult.java 2012-09-11 16:47:05 UTC (rev 2660)
@@ -24,6 +24,7 @@
*/
import org.nuiton.topia.persistence.TopiaEntityEnum;
+import org.nuiton.topia.persistence.csv.CsvProgressionModel;
import java.io.Serializable;
@@ -53,20 +54,33 @@
/** Count of updated entities. */
protected int numberUpdated;
+ protected final CsvProgressionModel progressionModel;
+
public static <T extends TopiaEntityEnum> CsvImportResult<T> newResult(T entityType,
String importFileName,
boolean createIfNotFound) {
+ CsvImportResult<T> result = newResult(entityType, importFileName,
+ createIfNotFound, null);
+ return result;
+ }
+
+ public static <T extends TopiaEntityEnum> CsvImportResult<T> newResult(T entityType,
+ String importFileName,
+ boolean createIfNotFound,
+ CsvProgressionModel progressionModel) {
CsvImportResult<T> result = new CsvImportResult<T>(entityType, importFileName,
- createIfNotFound);
+ createIfNotFound, progressionModel);
return result;
}
protected CsvImportResult(T entityType,
String importFileName,
- boolean createIfNotFound) {
+ boolean createIfNotFound,
+ CsvProgressionModel progressionModel) {
this.entityType = entityType;
this.importFileName = importFileName;
this.createIfNotFound = createIfNotFound;
+ this.progressionModel = progressionModel;
}
public T getEntityType() {
@@ -98,4 +112,7 @@
numberUpdated++;
}
+ public CsvProgressionModel getProgressionModel() {
+ return progressionModel;
+ }
}
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/TopiaCsvImports.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/TopiaCsvImports.java 2012-09-10 12:29:27 UTC (rev 2659)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/TopiaCsvImports.java 2012-09-11 16:47:05 UTC (rev 2660)
@@ -31,9 +31,11 @@
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.persistence.TopiaDAO;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.TopiaEntityEnum;
+import org.nuiton.topia.persistence.csv.CsvProgressionModel;
import org.nuiton.topia.persistence.metadata.AssociationMeta;
import org.nuiton.topia.persistence.metadata.MetaFilenameAware;
import org.nuiton.topia.persistence.metadata.TableMeta;
@@ -186,9 +188,9 @@
* @see ImportStrategy#importTable(TableMeta, Import, CsvImportResult)
*/
public static <T extends TopiaEntityEnum, E extends TopiaEntity> Iterable<E> importTableAndReturn(Reader reader,
- ImportStrategy<T> importStrategy,
- TableMeta<T> meta,
- CsvImportResult<T> csvResult) throws TopiaException, IOException {
+ ImportStrategy<T> importStrategy,
+ TableMeta<T> meta,
+ CsvImportResult<T> csvResult) throws TopiaException, IOException {
if (log.isInfoEnabled()) {
@@ -246,6 +248,8 @@
Import<E> importer,
CsvImportResult<T> csvResult) throws TopiaException {
+ CsvProgressionModel progressionModel = csvResult == null ? null :
+ csvResult.getProgressionModel();
for (E entity : importer) {
Map<String, Object> properties = meta.prepareCreate(
@@ -256,15 +260,54 @@
if (csvResult != null) {
csvResult.incrementsNumberUpdated();
+ if (progressionModel != null) {
+ progressionModel.incrementsProgression();
+ }
}
}
}
+ public static <T extends TopiaEntityEnum, E extends TopiaEntity> void importAllEntities(TopiaDAO<E> dao,
+ TableMeta<T> meta,
+ Import<E> importer,
+ CsvImportResult<T> csvResult,
+ int nbRowBuffer) throws TopiaException {
+
+ TopiaContextImplementor context = dao.getContext();
+
+ CsvProgressionModel progressionModel = csvResult == null ? null :
+ csvResult.getProgressionModel();
+
+ int compt = 0;
+ for (E entity : importer) {
+
+ Map<String, Object> properties = meta.prepareCreate(
+ entity, entity.getTopiaId());
+ E entityToSave = dao.create(properties);
+
+ meta.copy(entity, entityToSave);
+
+ if (csvResult != null) {
+ csvResult.incrementsNumberUpdated();
+ if (progressionModel != null) {
+ progressionModel.incrementsProgression();
+ }
+ }
+ compt++;
+ if (compt % nbRowBuffer == 0) {
+ // flush it
+ context.getHibernate().flush();
+ }
+ }
+ }
+
public static <T extends TopiaEntityEnum, E extends TopiaEntity> Iterable<E> importAllEntitiesAndReturnThem(TopiaDAO<E> dao,
TableMeta<T> meta,
Import<E> importer,
CsvImportResult<T> csvResult) throws TopiaException {
+ CsvProgressionModel progressionModel = csvResult == null ? null :
+ csvResult.getProgressionModel();
List<E> result = Lists.newArrayList();
for (E entity : importer) {
@@ -276,7 +319,11 @@
if (csvResult != null) {
csvResult.incrementsNumberUpdated();
+ if (progressionModel != null) {
+ progressionModel.incrementsProgression();
+ }
}
+
result.add(entityToSave);
}
return result;
@@ -288,6 +335,8 @@
Import<E> importer,
CsvImportResult<T> csvResult) throws TopiaException {
+ CsvProgressionModel progressionModel = csvResult == null ? null :
+ csvResult.getProgressionModel();
for (E entity : importer) {
String topiaId = entity.getTopiaId();
@@ -311,6 +360,9 @@
if (csvResult != null) {
csvResult.incrementsNumberCreated();
+ if (progressionModel != null) {
+ progressionModel.incrementsProgression();
+ }
}
} else {
// existing entity, nothing to create
@@ -330,6 +382,8 @@
CsvImportResult<T> csvResult,
int nbRowBuffer) throws TopiaException {
+ CsvProgressionModel progressionModel = csvResult == null ? null :
+ csvResult.getProgressionModel();
T source = meta.getSource();
T target = meta.getTarget();
@@ -361,6 +415,9 @@
}
if (csvResult != null) {
csvResult.incrementsNumberUpdated();
+ if (progressionModel != null) {
+ progressionModel.incrementsProgression();
+ }
}
}
if (builder.length() > 0) {
@@ -374,6 +431,8 @@
CsvImportResult<T> csvResult,
int nbRowBuffer) throws TopiaException {
+ CsvProgressionModel progressionModel = csvResult == null ? null :
+ csvResult.getProgressionModel();
T source = meta.getSource();
T target = meta.getTarget();
@@ -409,6 +468,9 @@
}
if (csvResult != null) {
csvResult.incrementsNumberUpdated();
+ if (progressionModel != null) {
+ progressionModel.incrementsProgression();
+ }
}
}
if (builder.length() > 0) {
@@ -423,6 +485,8 @@
CsvImportResult<T> csvResult,
int nbRowBuffer) throws TopiaException {
+ CsvProgressionModel progressionModel = csvResult == null ? null :
+ csvResult.getProgressionModel();
T source = meta.getSource();
T target = meta.getTarget();
@@ -460,6 +524,9 @@
}
if (csvResult != null) {
csvResult.incrementsNumberUpdated();
+ if (progressionModel != null) {
+ progressionModel.incrementsProgression();
+ }
}
}
if (builder.length() > 0) {
@@ -474,6 +541,9 @@
CsvImportResult<T> csvResult,
int nbRowBuffer) throws TopiaException {
+ CsvProgressionModel progressionModel = csvResult == null ? null :
+ csvResult.getProgressionModel();
+
T source = meta.getSource();
T target = meta.getTarget();
@@ -508,6 +578,9 @@
}
if (csvResult != null) {
csvResult.incrementsNumberUpdated();
+ if (progressionModel != null) {
+ progressionModel.incrementsProgression();
+ }
}
}
if (builder.length() > 0) {
1
0
r2659 - branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in
by tchemit@users.nuiton.org Sept. 10, 2012
by tchemit@users.nuiton.org Sept. 10, 2012
Sept. 10, 2012
Author: tchemit
Date: 2012-09-10 14:29:27 +0200 (Mon, 10 Sep 2012)
New Revision: 2659
Url: http://nuiton.org/repositories/revision/topia/2659
Log:
fixes #2309: Add a new method to import a talbe and return imported entities
Modified:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/ImportStrategy.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/TopiaCsvImports.java
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/ImportStrategy.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/ImportStrategy.java 2012-09-07 16:21:52 UTC (rev 2658)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/ImportStrategy.java 2012-09-10 12:29:27 UTC (rev 2659)
@@ -49,7 +49,7 @@
ImportModelFactory<T> getModelFactory();
/**
- * Import a table given a {@code importer}. with an optional csv result.
+ * Import a table given a {@code importer} with an optional csv result.
*
* @param meta type of table to import
* @param importer the csv importer
@@ -60,8 +60,22 @@
CsvImportResult<T> csvResult) throws TopiaException;
/**
- * Import a association given a {@code importer}. with an optional csv result.
+ * Import a table given a {@code importer} with an optional csv result,
+ * and return them.
*
+ * @param meta type of table to import
+ * @param importer the csv importer
+ * @param csvResult optional object where to put csv import result
+ * @return imported entities
+ * @throws TopiaException if any db problem
+ * @since 2.6.14
+ */
+ <E extends TopiaEntity> Iterable<E> importTableAndReturnThem(TableMeta<T> meta, Import<E> importer,
+ CsvImportResult<T> csvResult) throws TopiaException;
+
+ /**
+ * Import a association given a {@code importer} with an optional csv result.
+ *
* @param meta type of association to import
* @param importer the csv importer
* @param csvResult optional object where to put csv import result
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/TopiaCsvImports.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/TopiaCsvImports.java 2012-09-07 16:21:52 UTC (rev 2658)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/TopiaCsvImports.java 2012-09-10 12:29:27 UTC (rev 2659)
@@ -164,14 +164,47 @@
ImportModel<E> model = importStrategy.getModelFactory().buildForImport(meta);
Import<E> importer = Import.newImport(model, reader);
try {
- importStrategy.importTable(meta, importer,
- csvResult);
+ importStrategy.importTable(meta, importer, csvResult);
} finally {
importer.close();
}
}
/**
+ * To import a table (given by his {@code meta}) from a reader and a strategy.
+ * <p/>
+ * Result of import can be stored in an optional csv result.
+ *
+ * @param reader where to read csv data
+ * @param importStrategy import strategy used to store csv data
+ * @param meta meta of the data
+ * @param csvResult optional csv result
+ * @param <T> type of entity enum
+ * @param <E> type of data
+ * @throws TopiaException if any db problem while storing datas
+ * @throws IOException if any pb while reading csv data
+ * @see ImportStrategy#importTable(TableMeta, Import, CsvImportResult)
+ */
+ public static <T extends TopiaEntityEnum, E extends TopiaEntity> Iterable<E> importTableAndReturn(Reader reader,
+ ImportStrategy<T> importStrategy,
+ TableMeta<T> meta,
+ CsvImportResult<T> csvResult) throws TopiaException, IOException {
+
+
+ if (log.isInfoEnabled()) {
+ log.info("Will import " + meta);
+ }
+
+ ImportModel<E> model = importStrategy.getModelFactory().buildForImport(meta);
+ Import<E> importer = Import.newImport(model, reader);
+ try {
+ return importStrategy.importTableAndReturnThem(meta, importer, csvResult);
+ } finally {
+ importer.close();
+ }
+ }
+
+ /**
* To import a association (given by his {@code meta}) from a reader and a strategy.
* <p/>
* Result of import can be stored in an optional csv result.
1
0
r2658 - branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in
by tchemit@users.nuiton.org Sept. 7, 2012
by tchemit@users.nuiton.org Sept. 7, 2012
Sept. 7, 2012
Author: tchemit
Date: 2012-09-07 18:21:52 +0200 (Fri, 07 Sep 2012)
New Revision: 2658
Url: http://nuiton.org/repositories/revision/topia/2658
Log:
fixes #2306: CsvFileImportResult does not give back correct entities number
Modified:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvFileImportResult.java
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvFileImportResult.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvFileImportResult.java 2012-09-05 15:59:50 UTC (rev 2657)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvFileImportResult.java 2012-09-07 16:21:52 UTC (rev 2658)
@@ -98,15 +98,13 @@
protected int getInteger(Map<T, Integer> map, T entityType) {
Integer result = map.get(entityType);
- return result == null ? 0 : result;
+ return result;
}
protected void increments(Map<T, Integer> map, T entityType) {
Integer result = map.get(entityType);
- if (result == null) {
-
+ if (result == 0) {
entityTypes.add(entityType);
- result = 0;
}
map.put(entityType, ++result);
}
1
0
r2657 - branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out
by tchemit@users.nuiton.org Sept. 5, 2012
by tchemit@users.nuiton.org Sept. 5, 2012
Sept. 5, 2012
Author: tchemit
Date: 2012-09-05 17:59:50 +0200 (Wed, 05 Sep 2012)
New Revision: 2657
Url: http://nuiton.org/repositories/revision/topia/2657
Log:
fixes #2302: TopiaCsvExport should use as incoming source Iterable not List
Modified:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/PrepareDataForExport.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/TopiaCsvExports.java
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/PrepareDataForExport.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/PrepareDataForExport.java 2012-09-05 15:58:19 UTC (rev 2656)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/PrepareDataForExport.java 2012-09-05 15:59:50 UTC (rev 2657)
@@ -28,8 +28,6 @@
import org.nuiton.topia.persistence.metadata.AssociationMeta;
import org.nuiton.topia.persistence.metadata.TableMeta;
-import java.util.List;
-
/**
* Prepare data to export.
*
@@ -38,7 +36,7 @@
*/
public interface PrepareDataForExport<T extends TopiaEntityEnum> {
- <E extends TopiaEntity> List<E> prepareData(TableMeta<T> tableMeta);
+ <E extends TopiaEntity> Iterable<E> prepareData(TableMeta<T> tableMeta);
- <E extends TopiaEntity> List<E> prepareData(AssociationMeta<T> associationMeta);
+ <E extends TopiaEntity> Iterable<E> prepareData(AssociationMeta<T> associationMeta);
}
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/TopiaCsvExports.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/TopiaCsvExports.java 2012-09-05 15:58:19 UTC (rev 2656)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/TopiaCsvExports.java 2012-09-05 15:59:50 UTC (rev 2657)
@@ -136,8 +136,7 @@
ExportModelFactory<T> modelFactory,
PrepareDataForExport<T> prepareDataForExport) {
-
- List<E> datas = prepareDataForExport.prepareData(tableMeta);
+ Iterable<E> datas = prepareDataForExport.prepareData(tableMeta);
ExportModel<E> model = modelFactory.buildForExport(tableMeta);
return Export.newExport(model, datas);
}
@@ -146,7 +145,7 @@
ExportModelFactory<T> modelFactory,
PrepareDataForExport<T> prepareDataForExport) {
- List<E> datas = prepareDataForExport.prepareData(associationMeta);
+ Iterable<E> datas = prepareDataForExport.prepareData(associationMeta);
ExportModel<E> model = modelFactory.buildForExport(associationMeta);
return Export.newExport(model, datas);
}
1
0
r2656 - branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/framework
by tchemit@users.nuiton.org Sept. 5, 2012
by tchemit@users.nuiton.org Sept. 5, 2012
Sept. 5, 2012
Author: tchemit
Date: 2012-09-05 17:58:19 +0200 (Wed, 05 Sep 2012)
New Revision: 2656
Url: http://nuiton.org/repositories/revision/topia/2656
Log:
fix javadoc
Modified:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java 2012-09-05 15:58:04 UTC (rev 2655)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java 2012-09-05 15:58:19 UTC (rev 2656)
@@ -1403,8 +1403,7 @@
/**
* Clear hibernate cache to free memory.
*
- * @see http://docs.jboss.org/hibernate/orm/3.5/reference/en-US/html/transactions.h…
- * @since 2.6.13
+ * see http://docs.jboss.org/hibernate/orm/3.5/reference/en-US/html/transactions.h…
*/
@Override
public void clearCache() throws TopiaException {
1
0
r2655 - in branches/topia-2.6.x/topia-persistence/src: main/java/org/nuiton/topia/persistence test/java/org/nuiton/topia/persistence
by tchemit@users.nuiton.org Sept. 5, 2012
by tchemit@users.nuiton.org Sept. 5, 2012
Sept. 5, 2012
Author: tchemit
Date: 2012-09-05 17:58:04 +0200 (Wed, 05 Sep 2012)
New Revision: 2655
Url: http://nuiton.org/repositories/revision/topia/2655
Log:
fixes #2301: Add methods findAllLazyByQuery on TopiaDAO to iterate on result by a lazy mecanism
Modified:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java
branches/topia-2.6.x/topia-persistence/src/test/java/org/nuiton/topia/persistence/TopiaDAOTest.java
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java 2012-08-30 14:44:13 UTC (rev 2654)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java 2012-09-05 15:58:04 UTC (rev 2655)
@@ -60,7 +60,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @version $Id$
*/
-public interface TopiaDAO<E extends TopiaEntity> extends TopiaDAODeprecated<E> {
+public interface TopiaDAO<E extends TopiaEntity> extends TopiaDAODeprecated<E>, Iterable<E> {
//------------------------------------------------------------------------//
//-- Create - update - delete methods ------------------------------------//
@@ -328,6 +328,74 @@
Object... params) throws TopiaException;
/**
+ * Gets all entities in lazy mode when executing the given select query
+ * for the dao entity type.
+ * <p/>
+ * <strong>Important note:</strong>
+ *
+ * @param hql hql query
+ * @param params query params
+ * @return entites of the query result
+ * @throws TopiaException if any pb while getting datas
+ * @since 2.6.14
+ */
+ Iterable<E> findAllLazyByQuery(String hql,
+ Object... params) throws TopiaException;
+
+ /**
+ * Gets all entities in lazy mode when executing the given select query
+ * for the given {@code type} which may not be a entity type (int, long, map,...).
+ * <p/>
+ * <strong>Important note:</strong>
+ *
+ * @param type type of data to return
+ * @param hql hql query
+ * @param params query params
+ * @return entites of the query result
+ * @throws TopiaException if any pb while getting datas
+ * @since 2.6.14
+ */
+ <R> Iterable<R> findAllLazyByQuery(Class<R> type,
+ String hql,
+ Object... params) throws TopiaException;
+
+ /**
+ * Gets all entities in lazy mode when executing the given select query
+ * for the dao entity type.
+ * <p/>
+ * <strong>Important note:</strong>
+ *
+ * @param batchSize batch size
+ * @param hql hql query
+ * @param params query params
+ * @return entites of the query result
+ * @throws TopiaException if any pb while getting datas
+ * @since 2.6.14
+ */
+ Iterable<E> findAllLazyByQuery(int batchSize,
+ String hql,
+ Object... params) throws TopiaException;
+
+ /**
+ * Gets all entities in lazy mode when executing the given select query
+ * for the given {@code type} which may not be a entity type (int, long, map,...).
+ * <p/>
+ * <strong>Important note:</strong>
+ *
+ * @param type type of data to return
+ * @param batchSize batch size
+ * @param hql hql query
+ * @param params query params
+ * @return entites of the query result
+ * @throws TopiaException if any pb while getting datas
+ * @since 2.6.14
+ */
+ <R> Iterable<R> findAllLazyByQuery(Class<R> type,
+ int batchSize,
+ String hql,
+ Object... params) throws TopiaException;
+
+ /**
* Gets a page of entities when executing the given select query for the dao
* entity type (will only return the window of {@code startIndex -
* endIndex} entities).
@@ -340,6 +408,25 @@
* @throws TopiaException if any pb while getting datas
* @since 2.6.12
*/
+ <R> List<R> findAllByQueryWithBound(Class<R> type,
+ String hql,
+ int startIndex,
+ int endIndex,
+ Object... params) throws TopiaException;
+
+ /**
+ * Gets a page of entities when executing the given select query for the dao
+ * entity type (will only return the window of {@code startIndex -
+ * endIndex} entities).
+ *
+ * @param hql hql query to execute
+ * @param startIndex first index of entity to return
+ * @param endIndex last index of entity to return
+ * @param params query params
+ * @return entites of the paginated query result
+ * @throws TopiaException if any pb while getting datas
+ * @since 2.6.12
+ */
List<E> findAllByQueryWithBound(String hql,
int startIndex,
int endIndex,
@@ -349,6 +436,7 @@
* Gets a page of entities of the given select {@code hql} query using the
* {@code pager} to obtain the window of entities to return.
*
+ * @param type type of data to return
* @param hql hql query to execute
* @param pager pager to obtan the correct window of data
* @param params params of the query
@@ -357,6 +445,23 @@
* @see TopiaFilterPagerUtil.FilterPagerBean
* @since 2.6.12
*/
+ <R> List<R> findAllByQueryAndPager(Class<R> type,
+ String hql,
+ TopiaFilterPagerUtil.FilterPagerBean pager,
+ Object... params) throws TopiaException;
+
+ /**
+ * Gets a page of entities of the given select {@code hql} query using the
+ * {@code pager} to obtain the window of entities to return.
+ *
+ * @param hql hql query to execute
+ * @param pager pager to obtan the correct window of data
+ * @param params params of the query
+ * @return entities of the paginated query result
+ * @throws TopiaException if any pb while getting datas
+ * @see TopiaFilterPagerUtil.FilterPagerBean
+ * @since 2.6.12
+ */
List<E> findAllByQueryAndPager(String hql,
TopiaFilterPagerUtil.FilterPagerBean pager,
Object... params) throws TopiaException;
@@ -520,6 +625,24 @@
Class<E> getEntityClass();
/**
+ * Obtains the batch size used to load data.
+ * <p/>
+ * Default value if 1000.
+ *
+ * @return the batch size.
+ * @since 2.6.14
+ */
+ int getBatchSize();
+
+ /**
+ * Set a new default batch size.
+ *
+ * @param batchSize new batch size to use when iterating.
+ * @since 2.6.14
+ */
+ void setBatchSize(int batchSize);
+
+ /**
* When TopiaContextImpl create the TopiaDAOHibernate, it must call this
* method just after.
*
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java 2012-08-30 14:44:13 UTC (rev 2654)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java 2012-09-05 15:58:04 UTC (rev 2655)
@@ -38,6 +38,7 @@
package org.nuiton.topia.persistence;
import com.google.common.base.Preconditions;
+import com.google.common.collect.Iterators;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
@@ -46,6 +47,7 @@
import org.hibernate.Session;
import org.hibernate.metadata.ClassMetadata;
import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaRuntimeException;
import org.nuiton.topia.event.TopiaEntityListener;
import org.nuiton.topia.event.TopiaEntityVetoable;
import org.nuiton.topia.framework.TopiaContextImplementor;
@@ -56,8 +58,10 @@
import java.lang.reflect.InvocationTargetException;
import java.security.Permission;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.NoSuchElementException;
/**
* Cette classe permet d'avoir un ensemble de méthode implantée de façon
@@ -79,10 +83,27 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
private static Log log = LogFactory.getLog(TopiaDAOImpl.class);
+ /**
+ * Type of entity managed by this dao.
+ *
+ * @since ever
+ */
protected Class<E> entityClass;
+ /**
+ * Underlying context used by this dao to do actions on db.
+ *
+ * @since ever
+ */
protected TopiaContextImplementor context;
+ /**
+ * Default batch size used to iterate on data.
+ *
+ * @since 2.6.14
+ */
+ private int batchSize = 1000;
+
@Override
public TopiaEntityEnum getTopiaEntityEnum() {
throw new UnsupportedOperationException(
@@ -95,6 +116,28 @@
"This method must be overided in generated DAO");
}
+ @Override
+ public int getBatchSize() {
+ return batchSize;
+ }
+
+ @Override
+ public void setBatchSize(int batchSize) {
+ this.batchSize = batchSize;
+ }
+
+ @Override
+ public Iterator<E> iterator() {
+
+ Iterator<E> iterator = new FindAllIterator<E, E>(
+ this,
+ getEntityClass(),
+ batchSize,
+ "FROM " + getTopiaEntityEnum().getImplementationFQN());
+
+ return iterator;
+ }
+
/**
* Retourne l'id de l'entity
*
@@ -592,12 +635,14 @@
+ " n'a pas de cle primaire naturelle");
}
+ @Override
public boolean existsByQuery(String hql,
Object... params) throws TopiaException {
long count = countByQuery(hql, params);
return count > 0;
}
+ @Override
public long countByQuery(String hql,
Object... params) throws TopiaException {
@@ -607,11 +652,13 @@
return findByQuery(Long.class, hql, params);
}
+ @Override
public E findByQuery(String hql,
Object... params) throws TopiaException {
return findByQuery(getEntityClass(), hql, params);
}
+ @Override
public <R> R findByQuery(Class<R> type,
String hql,
Object... params) throws TopiaException {
@@ -625,12 +672,14 @@
return (R) unique;
}
+ @Override
public List<E> findAllByQuery(String hql,
Object... params) throws TopiaException {
return findAllByQuery(getEntityClass(), hql, params);
}
+ @Override
public <R> List<R> findAllByQuery(Class<R> type,
String hql,
Object... params) throws TopiaException {
@@ -642,20 +691,75 @@
return result;
}
- public List<E> findAllByQueryWithBound(String hql,
- int startIndex,
- int endIndex,
- Object... params) throws TopiaException {
+ @Override
+ public Iterable<E> findAllLazyByQuery(String hql,
+ Object... params) throws TopiaException {
+ return findAllLazyByQuery(batchSize, hql, params);
+ }
+ @Override
+ public <R> Iterable<R> findAllLazyByQuery(Class<R> type,
+ String hql,
+ Object... params) throws TopiaException {
+ return findAllLazyByQuery(type, batchSize, hql, params);
+ }
+
+ @Override
+ public Iterable<E> findAllLazyByQuery(int batchSize,
+ String hql,
+ Object... params) throws TopiaException {
+ return findAllLazyByQuery(getEntityClass(), batchSize, hql, params);
+ }
+
+ @Override
+ public <R> Iterable<R> findAllLazyByQuery(Class<R> type,
+ int batchSize,
+ String hql,
+ Object... params) throws TopiaException {
+
+ final Iterator<R> iterator = new FindAllIterator<E, R>(this,
+ type,
+ batchSize,
+ hql,
+ params);
+ return new Iterable<R>() {
+ @Override
+ public Iterator<R> iterator() {
+ return iterator;
+ }
+ };
+ }
+
+ @Override
+ public <R> List<R> findAllByQueryWithBound(Class<R> type,
+ String hql,
+ int startIndex,
+ int endIndex,
+ Object... params) throws TopiaException {
+ Preconditions.checkNotNull(type);
Preconditions.checkNotNull(hql);
- List<E> result = getContext().find(hql, startIndex, endIndex, params);
+ List<R> result = getContext().find(hql, startIndex, endIndex, params);
return result;
}
- public List<E> findAllByQueryAndPager(String hql,
- TopiaFilterPagerUtil.FilterPagerBean pager,
- Object... params) throws TopiaException {
+ @Override
+ public List<E> findAllByQueryWithBound(String hql,
+ int startIndex,
+ int endIndex,
+ Object... params) throws TopiaException {
+ return findAllByQueryWithBound(getEntityClass(),
+ hql,
+ startIndex,
+ endIndex,
+ params);
+ }
+
+ @Override
+ public <R> List<R> findAllByQueryAndPager(Class<R> type,
+ String hql,
+ TopiaFilterPagerUtil.FilterPagerBean pager,
+ Object... params) throws TopiaException {
Preconditions.checkNotNull(pager);
Preconditions.checkNotNull(hql);
@@ -665,13 +769,25 @@
hql += " DESC";
}
}
- List<E> result = findAllByQueryWithBound(hql,
+ List<R> result = findAllByQueryWithBound(type, hql,
pager.getRecordStartIndex(),
pager.getRecordEndIndex() - 1,
params);
return result;
}
+ @Override
+ public List<E> findAllByQueryAndPager(String hql,
+ TopiaFilterPagerUtil.FilterPagerBean pager,
+ Object... params) throws TopiaException {
+
+ return findAllByQueryAndPager(getEntityClass(),
+ hql,
+ pager,
+ params);
+ }
+
+ @Override
public void computeAndAddRecordsToPager(String hql,
TopiaFilterPagerUtil.FilterPagerBean pager,
Object... params) throws TopiaException {
@@ -709,4 +825,82 @@
return meta;
}
+ public static class FindAllIterator<E extends TopiaEntity, R> implements Iterator<R> {
+
+ protected Iterator<R> data;
+
+ protected final TopiaDAO<E> dao;
+
+ protected final Class<R> type;
+
+ protected final String hql;
+
+ protected final Object[] params;
+
+ protected TopiaFilterPagerUtil.FilterPagerBean pager;
+
+ public FindAllIterator(TopiaDAO<E> dao,
+ Class<R> type,
+ int batchSize,
+ String hql,
+ Object... params) {
+ this.dao = dao;
+ this.type = type;
+ this.hql = hql;
+ this.params = params;
+ try {
+ long count = dao.countByQuery("SELECT COUNT(*) " + hql, params);
+ pager = TopiaFilterPagerUtil.newFilterPagerBean();
+ pager.setRecords((int) count);
+ pager.setPageSize(batchSize);
+ TopiaFilterPagerUtil.computeRecordIndexesAndPagesNumber(pager);
+ } catch (TopiaException e) {
+ throw new TopiaRuntimeException(e);
+ }
+
+ // empty iterator (will be changed at first next call)
+ data = Iterators.emptyIterator();
+ }
+
+ @Override
+ public boolean hasNext() {
+ return data.hasNext() || // no more data
+ pager.getPageIndex() < pager.getPagesNumber();
+ }
+
+ @Override
+ public R next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+
+ if (!data.hasNext()) {
+
+ // must load iterator
+
+ // increments page index
+ pager.setPageIndex(pager.getPageIndex() + 1);
+ TopiaFilterPagerUtil.computeRecordIndexesAndPagesNumber(pager);
+
+ // load new window of data
+ try {
+ data = dao.findAllByQueryAndPager(type,
+ hql,
+ pager,
+ params).iterator();
+ } catch (TopiaException e) {
+ throw new TopiaRuntimeException(e);
+ }
+ }
+
+ R next = data.next();
+ return next;
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException(
+ "This iterator does not support remove operation.");
+ }
+ }
} //TopiaDAOImpl
Modified: branches/topia-2.6.x/topia-persistence/src/test/java/org/nuiton/topia/persistence/TopiaDAOTest.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/test/java/org/nuiton/topia/persistence/TopiaDAOTest.java 2012-08-30 14:44:13 UTC (rev 2654)
+++ branches/topia-2.6.x/topia-persistence/src/test/java/org/nuiton/topia/persistence/TopiaDAOTest.java 2012-09-05 15:58:04 UTC (rev 2655)
@@ -25,12 +25,15 @@
package org.nuiton.topia.persistence;
+import com.google.common.collect.Lists;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.matchers.JUnitMatchers;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaDatabase;
+import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaTestDAOHelper;
import org.nuiton.topia.test.entities.Person;
import org.nuiton.topia.test.entities.PersonDAO;
@@ -51,6 +54,18 @@
@Rule
public final TopiaDatabase db = new TopiaDatabase();
+ protected TopiaContext context;
+
+ protected PersonDAO dao;
+
+ @Before
+ public void setup() throws TopiaException {
+
+ context = db.beginTransaction();
+
+ dao = TopiaTestDAOHelper.getPersonDAO(context);
+ }
+
/**
* Test de creer une entité et de verifier qu'elle est
* présente dans la persistence au sein de la transaction.
@@ -60,30 +75,128 @@
@Test
public void testCreateAndFindInTransaction() throws Exception {
- TopiaContext context = db.beginTransaction();
-
- PersonDAO personDAO = TopiaTestDAOHelper.getPersonDAO(context);
-
// appel 1 find all
- Person person = personDAO.create(Person.PROPERTY_NAME, "toto");
- List<Person> allPerson = personDAO.findAll();
+ Person person = createPerson("toto");
+ List<Person> allPerson = dao.findAll();
Assert.assertEquals(1, allPerson.size());
context.commitTransaction();
// recherce la personne créée dans la même transaction
- Person person2 = personDAO.create(Person.PROPERTY_NAME, "titi");
- allPerson = personDAO.findAll();
+ Person person2 = createPerson("titi");
+ allPerson = dao.findAll();
Assert.assertEquals(2, allPerson.size());
Assert.assertThat(allPerson, JUnitMatchers.hasItem(person2));
context.rollbackTransaction();
// meme test apres roolback
- Person person3 = personDAO.create(Person.PROPERTY_NAME, "tata");
- allPerson = personDAO.findAll();
+ Person person3 = createPerson("tata");
+ allPerson = dao.findAll();
Assert.assertEquals(2, allPerson.size());
Assert.assertThat(allPerson, JUnitMatchers.hasItem(person3));
context.commitTransaction();
}
+
+ @Test
+ public void findAllLazyByQuery() throws TopiaException {
+
+ Assert.assertEquals(dao.count(), 0);
+
+ createPersons(101);
+
+ Iterable<Person> allByLazy = dao.findAllLazyByQuery(
+ 100,
+ "FROM " + dao.getTopiaEntityEnum().getImplementationFQN());
+
+ List<Person> actual = Lists.newArrayList();
+
+ for (Person person : allByLazy) {
+ actual.add(person);
+ }
+ Assert.assertEquals(dao.count(), actual.size());
+
+ allByLazy = dao.findAllLazyByQuery(
+ 54,
+ "FROM " + dao.getTopiaEntityEnum().getImplementationFQN());
+
+ actual = Lists.newArrayList();
+
+ for (Person person : allByLazy) {
+ actual.add(person);
+ }
+ Assert.assertEquals(dao.count(), actual.size());
+
+ allByLazy = dao.findAllLazyByQuery(
+ 49,
+ "FROM " + dao.getTopiaEntityEnum().getImplementationFQN());
+
+ actual = Lists.newArrayList();
+
+ for (Person person : allByLazy) {
+ actual.add(person);
+ }
+ Assert.assertEquals(dao.count(), actual.size());
+
+ allByLazy = dao.findAllLazyByQuery(
+ 101,
+ "FROM " + dao.getTopiaEntityEnum().getImplementationFQN());
+
+ actual = Lists.newArrayList();
+
+ for (Person person : allByLazy) {
+ actual.add(person);
+ }
+ Assert.assertEquals(dao.count(), actual.size());
+
+ allByLazy = dao.findAllLazyByQuery(
+ 102,
+ "FROM " + dao.getTopiaEntityEnum().getImplementationFQN());
+
+ actual = Lists.newArrayList();
+
+ for (Person person : allByLazy) {
+ actual.add(person);
+ }
+ Assert.assertEquals(dao.count(), actual.size());
+ }
+
+ @Test
+ public void iterateOnTopiaDAO() throws TopiaException {
+
+ createPersons(1999);
+
+ List<Person> excepted = dao.findAll();
+
+ List<Person> actual = Lists.newArrayList();
+
+ for (Person person : dao) {
+ Assert.assertThat(excepted, JUnitMatchers.hasItem(person));
+ actual.add(person);
+ }
+ Assert.assertEquals(excepted.size(), actual.size());
+
+ dao.setBatchSize(54);
+
+ actual = Lists.newArrayList();
+
+ for (Person person : dao) {
+ Assert.assertThat(excepted, JUnitMatchers.hasItem(person));
+ actual.add(person);
+ }
+ Assert.assertEquals(excepted.size(), actual.size());
+
+ }
+
+ protected void createPersons(int number) throws TopiaException {
+ for (int i = 0; i < number; i++) {
+ createPerson("toto" + i);
+ }
+
+ context.commitTransaction();
+ }
+
+ protected Person createPerson(String name) throws TopiaException {
+ return dao.create(Person.PROPERTY_NAME, name);
+ }
}
1
0