empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From inem...@apache.org
Subject empire-db git commit: DBRecordCallbackHandler and DBRecordMapper method changed
Date Sun, 25 Oct 2015 08:48:49 GMT
Repository: empire-db
Updated Branches:
  refs/heads/master 11ff2d595 -> 7ac3454c4


DBRecordCallbackHandler and DBRecordMapper method changed

Project: http://git-wip-us.apache.org/repos/asf/empire-db/repo
Commit: http://git-wip-us.apache.org/repos/asf/empire-db/commit/7ac3454c
Tree: http://git-wip-us.apache.org/repos/asf/empire-db/tree/7ac3454c
Diff: http://git-wip-us.apache.org/repos/asf/empire-db/diff/7ac3454c

Branch: refs/heads/master
Commit: 7ac3454c455da17b01b562946d5986c2ffeb222f
Parents: 11ff2d5
Author: inemeth <inemeth@apache.org>
Authored: Sun Oct 25 09:43:59 2015 +0100
Committer: inemeth <inemeth@apache.org>
Committed: Sun Oct 25 09:43:59 2015 +0100

----------------------------------------------------------------------
 .../apache/empire/spring/DBRecordCallbackHandler.java |  2 +-
 .../java/org/apache/empire/spring/DBRecordMapper.java |  4 +++-
 .../java/org/apache/empire/spring/EmpireTemplate.java | 14 ++++++++------
 .../apache/empire/spring/example1/EmpireAppImpl.java  | 10 +++++-----
 .../empire/spring/example2/EmployeeDaoImpl.java       | 10 +++++-----
 5 files changed, 22 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/empire-db/blob/7ac3454c/empire-db-spring/src/main/java/org/apache/empire/spring/DBRecordCallbackHandler.java
----------------------------------------------------------------------
diff --git a/empire-db-spring/src/main/java/org/apache/empire/spring/DBRecordCallbackHandler.java
b/empire-db-spring/src/main/java/org/apache/empire/spring/DBRecordCallbackHandler.java
index aa0a318..8484299 100644
--- a/empire-db-spring/src/main/java/org/apache/empire/spring/DBRecordCallbackHandler.java
+++ b/empire-db-spring/src/main/java/org/apache/empire/spring/DBRecordCallbackHandler.java
@@ -39,6 +39,6 @@ public interface DBRecordCallbackHandler {
 	 * @param record
 	 */
 
-	void processRow(DBRecordData record);
+	void processRecord(DBRecordData record);
 
 }

http://git-wip-us.apache.org/repos/asf/empire-db/blob/7ac3454c/empire-db-spring/src/main/java/org/apache/empire/spring/DBRecordMapper.java
----------------------------------------------------------------------
diff --git a/empire-db-spring/src/main/java/org/apache/empire/spring/DBRecordMapper.java b/empire-db-spring/src/main/java/org/apache/empire/spring/DBRecordMapper.java
index 1a58bc6..6820eca 100644
--- a/empire-db-spring/src/main/java/org/apache/empire/spring/DBRecordMapper.java
+++ b/empire-db-spring/src/main/java/org/apache/empire/spring/DBRecordMapper.java
@@ -39,9 +39,11 @@ public interface DBRecordMapper<K> {
 	 * 
 	 * @param record
 	 *            the DBRecordData to map
+	 * @param rowNum
+	 *            the number of the current row
 	 * @return the result object
 	 */
 
-	public abstract K read(DBRecordData record);
+	public abstract K mapRecord(DBRecordData record, int rowNum);
 
 }

http://git-wip-us.apache.org/repos/asf/empire-db/blob/7ac3454c/empire-db-spring/src/main/java/org/apache/empire/spring/EmpireTemplate.java
----------------------------------------------------------------------
diff --git a/empire-db-spring/src/main/java/org/apache/empire/spring/EmpireTemplate.java b/empire-db-spring/src/main/java/org/apache/empire/spring/EmpireTemplate.java
index a0fac01..ddf3301 100644
--- a/empire-db-spring/src/main/java/org/apache/empire/spring/EmpireTemplate.java
+++ b/empire-db-spring/src/main/java/org/apache/empire/spring/EmpireTemplate.java
@@ -231,7 +231,7 @@ public class EmpireTemplate implements InitializingBean {
 		class SingleValueMapper implements DBRecordMapper<Object> {
 
 			@Override
-			public Object read(DBRecordData record) {
+			public Object mapRecord(DBRecordData record, int rowNum) {
 				return record.getValue(col);
 			}
 
@@ -277,7 +277,7 @@ public class EmpireTemplate implements InitializingBean {
 		class SingleLongMapper implements DBRecordMapper<Long> {
 
 			@Override
-			public Long read(DBRecordData record) {
+			public Long mapRecord(DBRecordData record, int rowNum) {
 				return record.isNull(col) ? defaultValue : record.getLong(col);
 			}
 
@@ -324,7 +324,7 @@ public class EmpireTemplate implements InitializingBean {
 		class SingleIntegerMapper implements DBRecordMapper<Integer> {
 
 			@Override
-			public Integer read(DBRecordData record) {
+			public Integer mapRecord(DBRecordData record, int rowNum) {
 				return record.isNull(col) ? defaultValue : record.getInt(col);
 			}
 
@@ -362,7 +362,7 @@ public class EmpireTemplate implements InitializingBean {
 		class SingleStringMapper implements DBRecordMapper<String> {
 
 			@Override
-			public String read(DBRecordData record) {
+			public String mapRecord(DBRecordData record, int rowNum) {
 				return record.getString(col);
 			}
 
@@ -803,7 +803,7 @@ public class EmpireTemplate implements InitializingBean {
 		public Object process(DBReader reader) {
 			try {
 				while (reader.moveNext()) {
-					this.rowCallbackHandler.processRow(reader);
+					this.rowCallbackHandler.processRecord(reader);
 				}
 				return null;
 			} finally {
@@ -827,9 +827,11 @@ public class EmpireTemplate implements InitializingBean {
 		public List<K> process(DBReader reader) {
 			try {
 				List<K> results = new ArrayList<K>();
+				int rowNum = 0;
 
 				while (reader.moveNext()) {
-					results.add(this.dataReader.read(reader));
+					results.add(this.dataReader.mapRecord(reader, rowNum));
+					rowNum++;
 				}
 
 				return results;

http://git-wip-us.apache.org/repos/asf/empire-db/blob/7ac3454c/empire-db-spring/src/main/java/org/apache/empire/spring/example1/EmpireAppImpl.java
----------------------------------------------------------------------
diff --git a/empire-db-spring/src/main/java/org/apache/empire/spring/example1/EmpireAppImpl.java
b/empire-db-spring/src/main/java/org/apache/empire/spring/example1/EmpireAppImpl.java
index d5d1e49..f35ed89 100644
--- a/empire-db-spring/src/main/java/org/apache/empire/spring/example1/EmpireAppImpl.java
+++ b/empire-db-spring/src/main/java/org/apache/empire/spring/example1/EmpireAppImpl.java
@@ -38,11 +38,11 @@ import org.apache.empire.db.derby.DBDatabaseDriverDerby;
 import org.apache.empire.db.h2.DBDatabaseDriverH2;
 import org.apache.empire.db.hsql.DBDatabaseDriverHSql;
 import org.apache.empire.db.postgresql.DBDatabaseDriverPostgreSQL;
-import org.apache.empire.spring.EmpireDaoSupport;
-import org.apache.empire.spring.DBRecordMapper;
 import org.apache.empire.spring.DBReaderExtractor;
-import org.apache.empire.spring.EmpireRecord;
 import org.apache.empire.spring.DBRecordCallbackHandler;
+import org.apache.empire.spring.DBRecordMapper;
+import org.apache.empire.spring.EmpireDaoSupport;
+import org.apache.empire.spring.EmpireRecord;
 import org.apache.empire.xml.XMLWriter;
 import org.springframework.dao.DataAccessException;
 import org.springframework.jdbc.core.ConnectionCallback;
@@ -176,7 +176,7 @@ public class EmpireAppImpl extends EmpireDaoSupport implements EmpireApp
{
 				// Text-Output by iterating through all records.
 				DBRecordCallbackHandler readerImpl = new DBRecordCallbackHandler() {
 
-					public void processRow(DBRecordData reader) {
+					public void processRecord(DBRecordData reader) {
 						System.out.println(reader.getString(EMP.EMPLOYEE_ID)
 								+ "\t"
 								+ reader.getString(EMPLOYEE_FULLNAME)
@@ -272,7 +272,7 @@ public class EmpireAppImpl extends EmpireDaoSupport implements EmpireApp
{
 			this.table = table;
 		}
 
-		public Map<Object, Object> read(DBRecordData record) {
+		public Map<Object, Object> mapRecord(DBRecordData record, int rowNum) {
 			Map<Object, Object> dep = new HashMap<Object, Object>();
 			for (DBColumn col : table.getColumns()) {
 				dep.put(col.getName(), record.getValue(col));

http://git-wip-us.apache.org/repos/asf/empire-db/blob/7ac3454c/empire-db-spring/src/main/java/org/apache/empire/spring/example2/EmployeeDaoImpl.java
----------------------------------------------------------------------
diff --git a/empire-db-spring/src/main/java/org/apache/empire/spring/example2/EmployeeDaoImpl.java
b/empire-db-spring/src/main/java/org/apache/empire/spring/example2/EmployeeDaoImpl.java
index 2974180..b454ef2 100644
--- a/empire-db-spring/src/main/java/org/apache/empire/spring/example2/EmployeeDaoImpl.java
+++ b/empire-db-spring/src/main/java/org/apache/empire/spring/example2/EmployeeDaoImpl.java
@@ -26,10 +26,10 @@ import org.apache.empire.db.DBCommand;
 import org.apache.empire.db.DBJoinType;
 import org.apache.empire.db.DBRecord;
 import org.apache.empire.db.DBRecordData;
-import org.apache.empire.spring.EmpireDaoSupport;
 import org.apache.empire.spring.DBRecordMapper;
-import org.apache.empire.spring.EmpireRecord;
 import org.apache.empire.spring.DBRecordWriter;
+import org.apache.empire.spring.EmpireDaoSupport;
+import org.apache.empire.spring.EmpireRecord;
 import org.apache.empire.spring.example1.SampleDB;
 import org.apache.empire.spring.example1.SampleDB.Departments;
 import org.apache.empire.spring.example1.SampleDB.Employees;
@@ -149,7 +149,7 @@ public class EmployeeDaoImpl extends EmpireDaoSupport implements EmployeeDao
{
 		DepartmentMapper departmentMapper = new DepartmentMapper();
 
         @Override
-		public Employee read(DBRecordData record) {
+		public Employee mapRecord(DBRecordData record, int rowNum) {
 			Employee result = new Employee();
             // Auto-copy all properties
 			record.getBeanProperties(result);
@@ -160,7 +160,7 @@ public class EmployeeDaoImpl extends EmpireDaoSupport implements EmployeeDao
{
 			result.setGender(Employee.Gender.valueOf(record.getString(EMPLOYEES.GENDER)));
 			result.setPhoneNumber(record.getString(EMPLOYEES.PHONE_NUMBER));
 			*/
-			result.setDepartment(departmentMapper.read(record));
+			result.setDepartment(departmentMapper.mapRecord(record, rowNum));
 			return result;
 		}
 
@@ -191,7 +191,7 @@ public class EmployeeDaoImpl extends EmpireDaoSupport implements EmployeeDao
{
 		Map<Integer, Department> cache = new HashMap<Integer, Department>();
 
         @Override
-		public Department read(DBRecordData record) {
+		public Department mapRecord(DBRecordData record, int rowNum) {
 
 			Integer id = record.getInt(DEPARTMENTS.DEPARTMENT_ID);
 


Mime
View raw message