From: Franz W. <jav...@us...> - 2005-11-21 12:40:31
|
Update of /cvsroot/dcm4che/dcm4jboss-ejb/src/java/org/dcm4chex/archive/ejb/jdbc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7371/src/java/org/dcm4chex/archive/ejb/jdbc Added Files: Tag: DCM4JBOSS_2_2_1_BRANCH QueryAllStudiesCmd.java Log Message: added --- NEW FILE: QueryAllStudiesCmd.java --- /****************************************** * * * dcm4che: A OpenSource DICOM Toolkit * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ******************************************/ package org.dcm4chex.archive.ejb.jdbc; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import org.dcm4che.data.DcmObjectFactory; /** * * @author gun...@ti... * @version $Revision: 1.1.2.1 $ $Date: 2005/11/21 12:40:23 $ * @since 14.01.2004 */ public class QueryAllStudiesCmd extends BaseCmd { public static int transactionIsolationLevel = 0; private static final DcmObjectFactory dof = DcmObjectFactory.getInstance(); private static final String[] SELECT_ATTRIBUTE = { "Study.pk" }; private static final String[] ENTITY = { "Study"}; private final SqlBuilder sqlBuilder = new SqlBuilder(); public QueryAllStudiesCmd() throws SQLException { super(transactionIsolationLevel); sqlBuilder.setFrom(ENTITY); } public int count() throws SQLException { try { sqlBuilder.setSelectCount(); execute(sqlBuilder.getSql()); next(); return rs.getInt(1); } finally { rs = null; } } public List list(int offset, int limit) throws SQLException { sqlBuilder.setSelect(SELECT_ATTRIBUTE); sqlBuilder.addOrderBy("Study.pk", SqlBuilder.ASC); sqlBuilder.setOffset(offset); sqlBuilder.setLimit(limit); try { execute(sqlBuilder.getSql()); ArrayList result = new ArrayList(); while (next()) { result.add(new Integer(rs.getInt(1))); } return result; } finally { rs = null; } } } |