default boolean exists(long cohortId) throws CatalogDBException { return count(new Query(QueryParams.UID.key(), cohortId)).first() > 0; }
return true; if (cohortDBAdaptor.count(query).first() > 0) { return true;
@Override public QueryResult<Cohort> count(String studyStr, Query query, String sessionId) throws CatalogException { query = ParamUtils.defaultObject(query, Query::new); String userId = userManager.getUserId(sessionId); Study study = studyManager.resolveId(studyStr, userId, new QueryOptions(QueryOptions.INCLUDE, StudyDBAdaptor.QueryParams.VARIABLE_SET.key())); // Fix query if it contains any annotation AnnotationUtils.fixQueryAnnotationSearch(study, query); fixQueryObject(study, query, sessionId); query.append(CohortDBAdaptor.QueryParams.STUDY_UID.key(), study.getUid()); QueryResult<Long> queryResultAux = cohortDBAdaptor.count(query, userId, StudyAclEntry.StudyPermissions.VIEW_COHORTS); return new QueryResult<>("count", queryResultAux.getDbTime(), 0, queryResultAux.first(), queryResultAux.getWarningMsg(), queryResultAux.getErrorMsg(), Collections.emptyList()); }
void checkCanDeleteSamples(MyResourceIds resources) throws CatalogException { for (Long sampleId : resources.getResourceIds()) { authorizationManager.checkSamplePermission(resources.getStudyId(), sampleId, resources.getUser(), SampleAclEntry.SamplePermissions.DELETE); } // Check that the samples are not being used in cohorts Query query = new Query() .append(CohortDBAdaptor.QueryParams.STUDY_UID.key(), resources.getStudyId()) .append(CohortDBAdaptor.QueryParams.SAMPLE_UIDS.key(), resources.getResourceIds()) .append(CohortDBAdaptor.QueryParams.STATUS_NAME.key(), "!=" + Status.DELETED); long count = cohortDBAdaptor.count(query).first(); if (count > 0) { if (resources.getResourceIds().size() == 1) { throw new CatalogException("The sample " + resources.getResourceIds().get(0) + " is part of " + count + " cohorts. Please, " + "first update or delete the cohorts"); } else { throw new CatalogException("Some samples are part of " + count + " cohorts. Please, first update or delete the cohorts"); } } }
studySummary.setJobs(nJobs); Long nCohorts = cohortDBAdaptor.count( new Query(CohortDBAdaptor.QueryParams.STUDY_UID.key(), study.getUid()) .append(CohortDBAdaptor.QueryParams.STATUS_NAME.key(), "!=" + File.FileStatus.TRASHED + ";!="