use of org.sagebionetworks.repo.model.dbo.persistence.DBONodeAccessRequirement in project Synapse-Repository-Services by Sage-Bionetworks.
the class DBOAccessRequirementDAOImpl method getEntities.
public List<Long> getEntities(Long accessRequirementId) {
MapSqlParameterSource param = new MapSqlParameterSource();
param.addValue(COL_NODE_ACCESS_REQUIREMENT_REQUIREMENT_ID, accessRequirementId);
List<DBONodeAccessRequirement> nars = simpleJdbcTemplate.query(SELECT_FOR_NAR_SQL, nodeAccessRequirementRowMapper, param);
List<Long> ans = new ArrayList<Long>();
for (DBONodeAccessRequirement nar : nars) ans.add(nar.getNodeId());
return ans;
}
use of org.sagebionetworks.repo.model.dbo.persistence.DBONodeAccessRequirement in project Synapse-Repository-Services by Sage-Bionetworks.
the class DBOAccessRequirementDAOImpl method populateNodeAccessRequirement.
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void populateNodeAccessRequirement(Long accessRequirementId, List<String> entityIds) throws DatastoreException {
if (entityIds == null || entityIds.isEmpty())
return;
List<DBONodeAccessRequirement> batch = new ArrayList<DBONodeAccessRequirement>();
for (String s : new HashSet<String>(entityIds)) {
// eliminate duplicate entityIds
DBONodeAccessRequirement nar = new DBONodeAccessRequirement();
nar.setAccessRequirementId(accessRequirementId);
Long nodeId = KeyFactory.stringToKey(s);
nar.setNodeId(nodeId);
batch.add(nar);
}
basicDao.createBatch(batch);
}
use of org.sagebionetworks.repo.model.dbo.persistence.DBONodeAccessRequirement in project Synapse-Repository-Services by Sage-Bionetworks.
the class DBOAccessRequirementDAOImpl method getMigrationObjectData.
@Override
public QueryResults<MigratableObjectData> getMigrationObjectData(long offset, long limit, boolean includeDependencies) throws DatastoreException {
// (1) get one 'page' of AccessRequirements (just their IDs and Etags)
List<MigratableObjectData> ods = null;
{
MapSqlParameterSource param = new MapSqlParameterSource();
param.addValue(OFFSET_PARAM_NAME, offset);
param.addValue(LIMIT_PARAM_NAME, limit);
ods = simpleJdbcTemplate.query(SELECT_FOR_RANGE_SQL, new RowMapper<MigratableObjectData>() {
@Override
public MigratableObjectData mapRow(ResultSet rs, int rowNum) throws SQLException {
String id = rs.getString(COL_ACCESS_REQUIREMENT_ID);
String etag = rs.getString(COL_ACCESS_REQUIREMENT_ETAG);
MigratableObjectData objectData = new MigratableObjectData();
MigratableObjectDescriptor od = new MigratableObjectDescriptor();
od.setId(id);
od.setType(MigratableObjectType.ACCESSREQUIREMENT);
objectData.setId(od);
objectData.setEtag(etag);
objectData.setDependencies(new HashSet<MigratableObjectDescriptor>(0));
return objectData;
}
}, param);
}
// (2) find the dependencies
if (includeDependencies && !ods.isEmpty()) {
Map<String, MigratableObjectData> arMap = new HashMap<String, MigratableObjectData>();
for (MigratableObjectData od : ods) arMap.put(od.getId().getId(), od);
List<DBONodeAccessRequirement> nars = null;
{
MapSqlParameterSource param = new MapSqlParameterSource();
param.addValue(COL_NODE_ACCESS_REQUIREMENT_REQUIREMENT_ID, arMap.keySet());
nars = simpleJdbcTemplate.query(SELECT_FOR_MULTIPLE_NAR_SQL, nodeAccessRequirementRowMapper, param);
}
// (3) add the dependencies to the objects
for (DBONodeAccessRequirement nar : nars) {
MigratableObjectDescriptor od = ObjectDescriptorUtils.createEntityObjectDescriptor(nar.getNodeId());
MigratableObjectData objectData = arMap.get(nar.getAccessRequirementId().toString());
objectData.getDependencies().add(od);
}
}
// (4) return the 'page' of objects, along with the total result count
QueryResults<MigratableObjectData> queryResults = new QueryResults<MigratableObjectData>();
queryResults.setResults(ods);
queryResults.setTotalNumberOfResults((int) getCount());
return queryResults;
}
Aggregations