List of usage examples for org.hibernate ScrollableResults getString
String getString(int col);
From source file:org.dcm4chee.archive.query.impl.StudyQuery.java
License:LGPL
@Override public Attributes toAttributes(ScrollableResults results, QueryContext context) { Long studyPk = results.getLong(0); Integer numberOfInstancesI = results.getInteger(1); int numberOfStudyRelatedInstances; int numberOfStudyRelatedSeries; String modalitiesInStudy;//from www. j a v a2 s.c o m String sopClassesInStudy; String retrieveAETs; Availability availability; int numberOfStudyVisibleInstances; Date studyLastUpdateTime; if (numberOfInstancesI != null) { numberOfStudyRelatedInstances = numberOfInstancesI; if (numberOfStudyRelatedInstances == 0) return null; numberOfStudyRelatedSeries = results.getInteger(2); modalitiesInStudy = results.getString(3); sopClassesInStudy = results.getString(4); retrieveAETs = results.getString(5); availability = (Availability) results.get(6); numberOfStudyVisibleInstances = results.getInteger(7); studyLastUpdateTime = results.getDate(8); } else { StudyQueryAttributes studyView = context.getQueryService().createStudyView(studyPk, context.getQueryParam()); numberOfStudyRelatedInstances = studyView.getNumberOfInstances(); if (numberOfStudyRelatedInstances == 0) return null; numberOfStudyRelatedSeries = studyView.getNumberOfSeries(); modalitiesInStudy = studyView.getRawModalitiesInStudy(); sopClassesInStudy = studyView.getRawSOPClassesInStudy(); retrieveAETs = studyView.getRawRetrieveAETs(); availability = studyView.getAvailability(); numberOfStudyVisibleInstances = studyView.getNumberOfVisibleInstances(); studyLastUpdateTime = studyView.getLastUpdateTime(); } byte[] studyByteAttributes = results.getBinary(9); byte[] patientByteAttributes = results.getBinary(10); Attributes patientAttrs = new Attributes(); Attributes studyAttrs = new Attributes(); Utils.decodeAttributes(patientAttrs, patientByteAttributes); Utils.decodeAttributes(studyAttrs, studyByteAttributes); Attributes attrs = Utils.mergeAndNormalize(patientAttrs, studyAttrs); ArchiveDeviceExtension ade = context.getArchiveAEExtension().getApplicationEntity().getDevice() .getDeviceExtension(ArchiveDeviceExtension.class); Utils.setStudyQueryAttributes(attrs, numberOfStudyRelatedSeries, numberOfStudyRelatedInstances, modalitiesInStudy, sopClassesInStudy, numberOfStudyVisibleInstances, ade.getPrivateDerivedFields().findStudyNumberOfVisibleInstancesTag(), studyLastUpdateTime, ade.getPrivateDerivedFields().findStudyUpdateTimeTag()); Utils.setRetrieveAET(attrs, retrieveAETs); Utils.setAvailability(attrs, availability); return attrs; }
From source file:org.openbravo.dal.service.OBQuery.java
License:Open Source License
/** * Computes the row number of a record which has the id which is passed in as a parameter. The * rownumber computation takes into account the filter and sorting settings of the the OBQuery * object.//from w ww .j a v a 2s.c o m * * @param targetId * the record id * @return the row number or -1 if not found */ public int getRowNumber(String targetId) { String qryStr = createQueryString(); if (qryStr.toLowerCase().contains(FROM_SPACED)) { final int index = qryStr.indexOf(FROM_SPACED) + FROM_SPACED.length(); qryStr = qryStr.substring(index); } final Query qry = getSession().createQuery("select " + usedAlias + "id " + FROM_SPACED + qryStr); setParameters(qry); final ScrollableResults results = qry.scroll(ScrollMode.FORWARD_ONLY); try { while (results.next()) { final String id = results.getString(0); if (id.equals(targetId)) { return results.getRowNumber(); } } } finally { results.close(); } return -1; }