@Override public ClinicalAnalysis setStudyUid(long studyUid) { super.setStudyUid(studyUid); return this; }
@Override public ClinicalAnalysis setUid(long uid) { super.setUid(uid); return this; }
@Override public QueryResult<Job> update(String studyStr, String entryStr, ObjectMap parameters, QueryOptions options, String sessionId) throws CatalogException { ParamUtils.checkObj(parameters, "parameters"); options = ParamUtils.defaultObject(options, QueryOptions::new); MyResource resource = getUid(entryStr, studyStr, sessionId); authorizationManager.checkJobPermission(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), JobAclEntry.JobPermissions.UPDATE); QueryResult<Job> queryResult = jobDBAdaptor.update(resource.getResource().getUid(), parameters, QueryOptions.empty()); auditManager.recordUpdate(AuditRecord.Resource.job, resource.getResource().getUid(), resource.getUser(), parameters, null, null); return queryResult; }
public List<QueryResult<R>> get(String studyStr, List<String> entryList, Query query, QueryOptions options, boolean silent, String sessionId) throws CatalogException { List<QueryResult<R>> resultList = new ArrayList<>(entryList.size()); query = ParamUtils.defaultObject(query, Query::new); for (String entry : entryList) { Query queryCopy = new Query(query); try { MyResource<R> resource = getUid(entry, studyStr, sessionId); queryCopy.put("uid", resource.getResource().getUid()); QueryResult<R> rQueryResult = get(resource.getStudy().getFqn(), queryCopy, options, sessionId); rQueryResult.setId(entry); resultList.add(rQueryResult); } catch (CatalogException e) { if (silent) { resultList.add(new QueryResult<>(entry, 0, 0, 0, "", e.toString(), new ArrayList<>(0))); } else { throw e; } } } return resultList; }
public QueryResult<Job> visit(String studyStr, String jobId, String sessionId) throws CatalogException { MyResource resource = getUid(jobId, studyStr, sessionId); authorizationManager.checkJobPermission(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), JobAclEntry.JobPermissions.VIEW); ObjectMap params = new ObjectMap(JobDBAdaptor.QueryParams.VISITED.key(), true); return jobDBAdaptor.update(resource.getResource().getUid(), params, QueryOptions.empty()); }
@Override public Job setUid(long uid) { super.setUid(uid); return this; }
@Override public Job setStudyUid(long studyUid) { super.setStudyUid(studyUid); return this; }
/** * Fetch the R object. * * @param studyStr Study id in string format. Could be one of [id|user@aliasProject:aliasStudy|aliasProject:aliasStudy|aliasStudy]. * @param entryStr Entry id to be fetched. * @param options QueryOptions object, like "include", "exclude", "limit" and "skip". * @param sessionId sessionId * @return All matching elements. * @throws CatalogException CatalogException. */ public QueryResult<R> get(String studyStr, String entryStr, QueryOptions options, String sessionId) throws CatalogException { Query query = new Query(); MyResource resources = getUid(entryStr, studyStr, sessionId); query.put("uid", resources.getResource().getUid()); return get(studyStr, query, options, sessionId); }
public void setStatus(String studyStr, String id, String status, String message, String sessionId) throws CatalogException { MyResource resource = getUid(id, studyStr, sessionId); authorizationManager.checkCohortPermission(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), CohortAclEntry.CohortPermissions.UPDATE); if (status != null && !Cohort.CohortStatus.isValid(status)) { throw new CatalogException("The status " + status + " is not valid cohort status."); } ObjectMap parameters = new ObjectMap(); parameters.putIfNotNull(CohortDBAdaptor.QueryParams.STATUS_NAME.key(), status); parameters.putIfNotNull(CohortDBAdaptor.QueryParams.STATUS_MSG.key(), message); cohortDBAdaptor.update(resource.getResource().getUid(), parameters, new QueryOptions()); auditManager.recordUpdate(AuditRecord.Resource.cohort, resource.getResource().getUid(), resource.getUser(), parameters, null, null); }
public void setStatus(String studyStr, String id, String status, String message, String sessionId) throws CatalogException { ParamUtils.checkParameter(sessionId, "sessionId"); MyResource resource = getUid(id, studyStr, sessionId); authorizationManager.checkJobPermission(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), JobAclEntry.JobPermissions.UPDATE); if (status != null && !Job.JobStatus.isValid(status)) { throw new CatalogException("The status " + status + " is not valid job status."); } ObjectMap parameters = new ObjectMap(); parameters.putIfNotNull(JobDBAdaptor.QueryParams.STATUS_NAME.key(), status); parameters.putIfNotNull(JobDBAdaptor.QueryParams.STATUS_MSG.key(), message); jobDBAdaptor.update(resource.getResource().getUid(), parameters, QueryOptions.empty()); auditManager.recordUpdate(AuditRecord.Resource.job, resource.getResource().getUid(), resource.getUser(), parameters, null, null); }
private void fixQuery(Study study, Query query, String sessionId) throws CatalogException { if (StringUtils.isNotEmpty(query.getString(IndividualDBAdaptor.QueryParams.FATHER.key()))) { MyResource resource = getUid(query.getString(IndividualDBAdaptor.QueryParams.FATHER.key()), study.getFqn(), sessionId); query.remove(IndividualDBAdaptor.QueryParams.FATHER.key()); query.append(IndividualDBAdaptor.QueryParams.FATHER_UID.key(), resource.getResource().getUid()); } if (StringUtils.isNotEmpty(query.getString(IndividualDBAdaptor.QueryParams.MOTHER.key()))) { MyResource resource = getUid(query.getString(IndividualDBAdaptor.QueryParams.MOTHER.key()), study.getFqn(), sessionId); query.remove(IndividualDBAdaptor.QueryParams.MOTHER.key()); query.append(IndividualDBAdaptor.QueryParams.MOTHER_UID.key(), resource.getResource().getUid()); } if (StringUtils.isNotEmpty(query.getString(IndividualDBAdaptor.QueryParams.SAMPLES.key()))) { MyResources<Sample> resource = catalogManager.getSampleManager().getUids( query.getString(IndividualDBAdaptor.QueryParams.SAMPLES.key()), study.getFqn(), sessionId); query.remove(IndividualDBAdaptor.QueryParams.SAMPLES.key()); query.append(IndividualDBAdaptor.QueryParams.SAMPLE_UIDS.key(), resource.getResourceList().stream().map(Sample::getUid) .collect(Collectors.toList())); } }
Collections.emptyList()); } else { Query query = new Query("uid", resource.getResource().getUid()); QueryOptions options = new QueryOptions(QueryOptions.INCLUDE, Constants.ANNOTATION_SET_NAME + "." + annotationSetName);
@Override public QueryResult groupBy(@Nullable String studyStr, Query query, List<String> fields, QueryOptions options, String sessionId) throws CatalogException { query = ParamUtils.defaultObject(query, Query::new); options = ParamUtils.defaultObject(options, QueryOptions::new); if (fields == null || fields.size() == 0) { throw new CatalogException("Empty fields parameter."); } String userId = userManager.getUserId(sessionId); Study study = catalogManager.getStudyManager().resolveId(studyStr, userId); // Fix query if it contains any annotation AnnotationUtils.fixQueryAnnotationSearch(study, userId, query, authorizationManager); AnnotationUtils.fixQueryOptionAnnotation(options); // Add study id to the query query.put(SampleDBAdaptor.QueryParams.STUDY_UID.key(), study.getUid()); if (StringUtils.isNotEmpty(query.getString(SampleDBAdaptor.QueryParams.INDIVIDUAL.key()))) { String individualStr = query.getString(SampleDBAdaptor.QueryParams.INDIVIDUAL.key()); if (NumberUtils.isCreatable(individualStr) && Long.parseLong(individualStr) <= 0) { query.put(SampleDBAdaptor.QueryParams.INDIVIDUAL_UID.key(), -1); } else { MyResource resource = catalogManager.getIndividualManager().getUid(individualStr, studyStr, sessionId); query.put(SampleDBAdaptor.QueryParams.INDIVIDUAL_UID.key(), resource.getResource().getUid()); } query.remove(SampleDBAdaptor.QueryParams.INDIVIDUAL.key()); } QueryResult queryResult = sampleDBAdaptor.groupBy(query, fields, options, userId); return ParamUtils.defaultObject(queryResult, QueryResult::new); }
MyResource tmpResource = getUid((String) map.get(IndividualDBAdaptor.QueryParams.ID.key()), studyStr, sessionId); parameters.remove(IndividualDBAdaptor.QueryParams.FATHER.key()); parameters.put(IndividualDBAdaptor.QueryParams.FATHER_UID.key(), tmpResource.getResource().getUid()); } else { throw new CatalogException("Cannot update father parameter. Father name or id not passed"); MyResource tmpResource = getUid((String) map.get(IndividualDBAdaptor.QueryParams.ID.key()), studyStr, sessionId); parameters.remove(IndividualDBAdaptor.QueryParams.MOTHER.key()); parameters.put(IndividualDBAdaptor.QueryParams.MOTHER_UID.key(), tmpResource.getResource().getUid()); } else { throw new CatalogException("Cannot update mother parameter. Mother name or id not passed");
long familyId = resource.getResource().getUid(); authorizationManager.checkFamilyPermission(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), FamilyAclEntry.FamilyPermissions.WRITE_ANNOTATIONS); authorizationManager.checkFamilyPermission(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), FamilyAclEntry.FamilyPermissions.UPDATE);