/** * Returns the objects collection. * * @param */ protected IObjects getIObjects(int _nMaxSize) throws PureException { SearchForm thisform = (SearchForm) form; // 1. to get the query filter QueryFilter filter = thisform.getQueryFilter(); if (filter.getSelect() == null) { filter.addPropertySelect("this", "*"); } // 2. to render SQL IContentMgr mgr = ArkContentHelper.getContentMgrOf(thisform.getEntityMetadata().getEntityClass()); List params = new ArrayList(); String strSQL = filter.toSQL(params); if (this.isFromTemp()) { strSQL = strSQL.replaceAll("\\{this\\}", mgr.getTempTable(true) + " this"); } logger.debug("SQL=" + strSQL); // 3. to execute the query IStatement query = null; try { query = mgr.createQuery(strSQL, 0); filter.registerEntitiesInQuery(query); query.setParameters(0, params); if (_nMaxSize > 0) { query.setMaxSize(_nMaxSize); } return query.executeQuery(); } finally { params.clear(); if (query != null) query.clear(); } }
private int getPublicationId(String _sISSN) throws PureException { IStatement query = null; IObjects result = null; try { IContentMgr mgr = ArkContentHelper.getContentMgrOf(Publication.class); final String strSQL = "SELECT * FROM {this} WHERE {this.publishCode}='" + _sISSN + '\''; query = mgr.createQuery(strSQL, 1); result = query.executeQuery(); Publication publication = (Publication) result.next(); if (publication != null) return publication.getId(); return 0; } finally { DolphinHelper.clear(result, query); } }
/** @see com.pureinfo.srm.project.domain.IProjectPersonMgr#findAllByRelativeId(int) */ protected void deleteAllByRelativeId(DolphinObject _newObj, String _sRelativeIdName, Class _clazz) throws PureException { IStatement query = null; try { String strSQL = "SELECT * FROM {this} WHERE {this." + _sRelativeIdName + "} = ?"; IContentMgr mgr = ArkContentHelper.getContentMgrOf(_clazz); query = mgr.createQuery(strSQL, 0); query.setInt(0, _newObj.getIntProperty("id", 0)); mgr.delete(query.executeQuery()); } catch (Exception ex) { ex.printStackTrace(System.err); throw new PureException( SRMExceptionTypes.PP_FINDALL_PERSONS_OFPROJECT, "RelativeId: " + _newObj.getIntProperty("id", 0), ex); } finally { if (query != null) { query.clear(); } LocalContextHelper.closeSession(); } }