use of org.sagebionetworks.repo.model.QueryResults in project Synapse-Repository-Services by Sage-Bionetworks.
the class NodeQueryServiceImpl method query.
@Override
public QueryResults query(String userId, String query, HttpServletRequest request) throws DatastoreException, ParseException, NotFoundException, UnauthorizedException {
// Parse and validate the query
QueryStatement stmt = new QueryStatement(query);
// Convert from a query statement to a basic query
BasicQuery basic = QueryTranslator.createBasicQuery(stmt);
QueryResults results = executeQueryWithAnnotations(userId, basic, request);
results.setResults(formulateResult(stmt, results.getResults()));
return results;
}
use of org.sagebionetworks.repo.model.QueryResults in project Synapse-Repository-Services by Sage-Bionetworks.
the class DBOUserGroupDAOImpl method getMigrationObjectData.
@Override
public QueryResults<MigratableObjectData> getMigrationObjectData(long offset, long limit, boolean includeDependencies) throws DatastoreException {
// get a page of user groups
List<MigratableObjectData> ods = null;
{
MapSqlParameterSource param = new MapSqlParameterSource();
param.addValue(OFFSET_PARAM_NAME, offset);
param.addValue(LIMIT_PARAM_NAME, limit);
ods = simpleJdbcTemplate.query(SELECT_ALL_PAGINATED_WITH_ETAG, new RowMapper<MigratableObjectData>() {
@Override
public MigratableObjectData mapRow(ResultSet rs, int rowNum) throws SQLException {
// NOTE this is an outer join, so we have to handle the case in which there
// is no etag for the given user group
String ugId = rs.getString(COL_USER_GROUP_ID);
String etag = rs.getString(COL_USER_PROFILE_ETAG);
if (etag == null)
etag = DEFAULT_ETAG;
MigratableObjectData od = new MigratableObjectData();
MigratableObjectDescriptor id = new MigratableObjectDescriptor();
id.setId(ugId);
id.setType(MigratableObjectType.PRINCIPAL);
od.setId(id);
od.setEtag(etag);
// UserGroups have no dependencies
od.setDependencies(new HashSet<MigratableObjectDescriptor>(0));
return od;
}
}, param);
}
QueryResults<MigratableObjectData> queryResults = new QueryResults<MigratableObjectData>();
queryResults.setResults(ods);
queryResults.setTotalNumberOfResults((int) getCount());
return queryResults;
}
use of org.sagebionetworks.repo.model.QueryResults in project Synapse-Repository-Services by Sage-Bionetworks.
the class AccessApprovalManagerImpl method getAccessApprovalsForEntity.
@Override
public QueryResults<AccessApproval> getAccessApprovalsForEntity(UserInfo userInfo, String entityId) throws DatastoreException, NotFoundException, ForbiddenException {
ACTUtils.verifyACTTeamMembershipOrIsAdmin(userInfo, userGroupDAO);
List<AccessRequirement> ars = accessRequirementDAO.getForNode(entityId);
List<AccessApproval> aas = new ArrayList<AccessApproval>();
for (AccessRequirement ar : ars) {
aas.addAll(accessApprovalDAO.getForAccessRequirement(ar.getId().toString()));
}
QueryResults<AccessApproval> result = new QueryResults<AccessApproval>(aas, aas.size());
return result;
}
use of org.sagebionetworks.repo.model.QueryResults in project Synapse-Repository-Services by Sage-Bionetworks.
the class UserProfileManagerImpl method getInRange.
@Override
public QueryResults<UserProfile> getInRange(UserInfo userInfo, long startIncl, long endExcl, boolean includeEmail) throws DatastoreException, NotFoundException {
ObjectSchema schema = SchemaCache.getSchema(UserProfile.class);
List<UserProfile> userProfiles = userProfileDAO.getInRange(startIncl, endExcl, schema);
long totalNumberOfResults = userProfileDAO.getCount();
for (UserProfile userProfile : userProfiles) {
UserProfileManagerUtils.clearPrivateFields(userProfile);
if (includeEmail) {
UserGroup userGroup = userGroupDAO.get(userProfile.getOwnerId());
if (userGroup != null)
userProfile.setEmail(StringUtil.obfuscateEmailAddress(userGroup.getName()));
}
}
QueryResults<UserProfile> result = new QueryResults<UserProfile>(userProfiles, (int) totalNumberOfResults);
return result;
}
use of org.sagebionetworks.repo.model.QueryResults in project Synapse-Repository-Services by Sage-Bionetworks.
the class NodeDAOImpl method getMigrationObjectDataWithoutDependencies.
public QueryResults<MigratableObjectData> getMigrationObjectDataWithoutDependencies(long offset, long limit) throws DatastoreException {
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue(OFFSET_PARAM_NAME, offset);
params.addValue(LIMIT_PARAM_NAME, limit);
List<MigratableObjectData> ods = this.simpleJdbcTemplate.query(SQL_GET_NODES_PAGINATED, new RowMapper<MigratableObjectData>() {
@Override
public MigratableObjectData mapRow(ResultSet rs, int rowNum) throws SQLException {
MigratableObjectData data = new MigratableObjectData();
data.setId(ObjectDescriptorUtils.createEntityObjectDescriptor(rs.getLong(COL_NODE_ID)));
data.setEtag(rs.getString(COL_NODE_ETAG));
data.setDependencies(new HashSet<MigratableObjectDescriptor>(0));
return data;
}
}, params);
QueryResults<MigratableObjectData> queryResults = new QueryResults<MigratableObjectData>();
queryResults.setResults(ods);
queryResults.setTotalNumberOfResults((int) getCount());
return queryResults;
}
Aggregations