use of org.springframework.jdbc.core.RowCallbackHandler in project ma-core-public by infiniteautomation.
the class DataPointDao method getPointHierarchy.
/**
* Get the point hierarchy from its cached copy. The read only cached copy should
* never be modified, if you intend to modify it ensure you pass readOnly=false
*
* @param readOnly - do not modify a read only point hierarchy
* @return
*/
public PointHierarchy getPointHierarchy(boolean readOnly) {
if (cachedPointHierarchy == null) {
final Map<Integer, List<PointFolder>> folders = new HashMap<>();
// Get the folder list.
ejt.query("select id, parentId, name from dataPointHierarchy order by name", new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
PointFolder f = new PointFolder(rs.getInt(1), rs.getString(3));
int parentId = rs.getInt(2);
List<PointFolder> folderList = folders.get(parentId);
if (folderList == null) {
folderList = new LinkedList<>();
folders.put(parentId, folderList);
}
folderList.add(f);
}
});
// Create the folder hierarchy.
PointHierarchy ph = new PointHierarchy();
addFoldersToHeirarchy(ph, 0, folders);
// Add data points.
List<DataPointSummary> points = getDataPointSummaries(DataPointExtendedNameComparator.instance);
for (DataPointSummary dp : points) ph.addDataPoint(dp.getPointFolderId(), dp);
cachedPointHierarchy = ph;
}
if (readOnly)
return cachedPointHierarchy;
else
return cachedPointHierarchy.clone();
}
use of org.springframework.jdbc.core.RowCallbackHandler in project musiccabinet by hakko.
the class JdbcTagDao method getCorrectedTags.
@Override
public Map<String, String> getCorrectedTags() {
String sql = "select t.tag_name, tc.tag_name from music.tag t" + " inner join music.tag tc on t.corrected_id = tc.id";
final Map<String, String> correctedTags = new HashMap<>();
jdbcTemplate.query(sql, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
correctedTags.put(rs.getString(1), rs.getString(2));
}
});
return correctedTags;
}
use of org.springframework.jdbc.core.RowCallbackHandler in project musiccabinet by hakko.
the class JdbcLibraryPresenceDao method getFiles.
@Override
public Set<File> getFiles(String directory) {
String sql = "select d.path, f.filename, f.modified, f.size from library.file f" + " inner join library.directory d on f.directory_id = d.id" + " where d.path = ?";
final Set<File> files = new HashSet<>();
jdbcTemplate.query(sql, new Object[] { directory }, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
String directory = rs.getString(1);
String filename = rs.getString(2);
DateTime modified = new DateTime(rs.getTimestamp(3).getTime());
int size = rs.getInt(4);
files.add(new File(directory, filename, modified, size));
}
});
return files;
}
use of org.springframework.jdbc.core.RowCallbackHandler in project dhis2-core by dhis2.
the class JdbcCompleteDataSetRegistrationExchangeStore method writeCompleteness.
// --------------------------------------------------------------------------
// Supportive methods
// --------------------------------------------------------------------------
private void writeCompleteness(String sql, CompleteDataSetRegistrations completeDataSetRegistrations) {
final Calendar calendar = PeriodType.getCalendar();
completeDataSetRegistrations.open();
jdbcTemplate.query(sql, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
CompleteDataSetRegistration completeDataSetRegistration = completeDataSetRegistrations.getCompleteDataSetRegistrationInstance();
PeriodType pt = PeriodType.getPeriodTypeByName(rs.getString("ptname"));
completeDataSetRegistration.open();
completeDataSetRegistration.setDataSet(rs.getString("dsid"));
completeDataSetRegistration.setPeriod(pt.createPeriod(rs.getDate("pestart"), calendar).getIsoDate());
completeDataSetRegistration.setOrganisationUnit(rs.getString("ouid"));
completeDataSetRegistration.setAttributeOptionCombo(rs.getString("aocid"));
completeDataSetRegistration.setDate(removeTime(rs.getString("date")));
completeDataSetRegistration.setStoredBy(rs.getString("storedby"));
completeDataSetRegistration.setLastUpdatedBy(rs.getString("lastupdatedby"));
completeDataSetRegistration.setLastUpdated(removeTime(rs.getString("lastupdated")));
completeDataSetRegistration.setCompleted(rs.getBoolean("iscompleted"));
completeDataSetRegistration.close();
}
});
completeDataSetRegistrations.close();
}
use of org.springframework.jdbc.core.RowCallbackHandler in project dhis2-core by dhis2.
the class HibernateLockExceptionStore method getCombinations.
@Override
public List<LockException> getCombinations() {
final String sql = "select distinct datasetid, periodid from lockexception";
final List<LockException> lockExceptions = new ArrayList<>();
jdbcTemplate.query(sql, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
int dataSetId = rs.getInt(1);
int periodId = rs.getInt(2);
LockException lockException = new LockException();
Period period = periodService.getPeriod(periodId);
DataSet dataSet = dataSetStore.get(dataSetId);
lockException.setDataSet(dataSet);
lockException.setPeriod(period);
lockExceptions.add(lockException);
}
});
return lockExceptions;
}
Aggregations