use of org.apache.ibatis.session.ResultHandler in project alfresco-repository by Alfresco.
the class PropertyValueDAOImpl method findPropertiesByIds.
@Override
protected void findPropertiesByIds(List<Long> ids, final PropertyFinderCallback callback) {
ResultHandler valueResultHandler = new ResultHandler() {
public void handleResult(ResultContext context) {
PropertyIdQueryResult result = (PropertyIdQueryResult) context.getResultObject();
Long id = result.getPropId();
// Make the serializable value
List<PropertyIdSearchRow> rows = result.getPropValues();
Serializable value = convertPropertyIdSearchRows(rows);
callback.handleProperty(id, value);
}
};
// A row handler to roll up individual rows
Configuration configuration = template.getConfiguration();
RollupResultHandler rollupResultHandler = new RollupResultHandler(configuration, KEY_COLUMNS_FINDBYIDS, "propValues", valueResultHandler);
// Query using the IDs
PropertyIdQueryParameter params = new PropertyIdQueryParameter();
params.setRootPropIds(ids);
template.select(SELECT_PROPERTIES_BY_IDS, params, rollupResultHandler);
// Process any remaining results
rollupResultHandler.processLastResults();
// Done
}
use of org.apache.ibatis.session.ResultHandler in project alfresco-repository by Alfresco.
the class NodeDAOImpl method getNodeIdsIntervalForType.
@Override
@SuppressWarnings("rawtypes")
public Pair<Long, Long> getNodeIdsIntervalForType(QName type, Long startTxnTime, Long endTxnTime) {
final Pair<Long, Long> intervalPair = new Pair<Long, Long>(LONG_ZERO, LONG_ZERO);
Pair<Long, QName> typePair = qnameDAO.getQName(type);
if (typePair == null) {
// Return default
return intervalPair;
}
TransactionQueryEntity txnQuery = new TransactionQueryEntity();
txnQuery.setTypeQNameId(typePair.getFirst());
txnQuery.setMinCommitTime(startTxnTime);
txnQuery.setMaxCommitTime(endTxnTime);
ResultHandler resultHandler = new ResultHandler() {
@SuppressWarnings("unchecked")
public void handleResult(ResultContext context) {
Map<Long, Long> result = (Map<Long, Long>) context.getResultObject();
if (result != null) {
intervalPair.setFirst(result.get("minId"));
intervalPair.setSecond(result.get("maxId"));
}
}
};
template.select(SELECT_NODE_INTERVAL_BY_TYPE, txnQuery, resultHandler);
return intervalPair;
}
use of org.apache.ibatis.session.ResultHandler in project alfresco-repository by Alfresco.
the class NodeDAOImpl method selectNodePropertiesByDataType.
@SuppressWarnings("rawtypes")
@Override
public List<NodePropertyEntity> selectNodePropertiesByDataType(QName dataType, long minNodeId, long maxNodeId) {
int typeOrdinal = NodePropertyValue.convertToTypeOrdinal(dataType);
IdsEntity ids = new IdsEntity();
ids.setIdOne((long) typeOrdinal);
ids.setIdTwo(minNodeId);
ids.setIdThree(maxNodeId);
final List<NodePropertyEntity> properties = new ArrayList<NodePropertyEntity>();
template.select(SELECT_PROPERTIES_BY_ACTUAL_TYPE, ids, new ResultHandler() {
@Override
public void handleResult(ResultContext context) {
properties.add((NodePropertyEntity) context.getResultObject());
}
});
return properties;
}
Aggregations