List of usage examples for org.hibernate Criteria createCriteria
public Criteria createCriteria(String associationPath) throws HibernateException;
From source file:gov.nih.nci.caintegrator.data.CaIntegrator2DaoImpl.java
License:BSD License
/** * {@inheritDoc}//www .j a va2 s .com */ @Override @SuppressWarnings(UNCHECKED) // Hibernate operations are untyped public List<SampleAcquisition> findMatchingSamples(AbstractAnnotationCriterion criterion, Study study) { if (!criterion.getEntityType().equals(EntityTypeEnum.SAMPLE)) { return new ArrayList<SampleAcquisition>(); } else { Criteria sampleAcquisitionCrit = getCurrentSession().createCriteria(SampleAcquisition.class); createAnnotationValuesCriteria(criterion, sampleAcquisitionCrit, ANNOTATION_VALUE_COLLECTION_ASSOCIATION); createStudySubjectAssignmentCriteria( sampleAcquisitionCrit.createCriteria(STUDY_SUBJECT_ASSIGNMENT_ASSOCIATION), study); return sampleAcquisitionCrit.list(); } }
From source file:gov.nih.nci.caintegrator.data.CaIntegrator2DaoImpl.java
License:BSD License
/** * {@inheritDoc}//from w w w .ja va 2 s . c o m */ @Override @SuppressWarnings(UNCHECKED) // Hibernate operations are untyped public List<StudySubjectAssignment> findMatchingSubjects(AbstractAnnotationCriterion criterion, Study study) { if (!criterion.getEntityType().equals(EntityTypeEnum.SUBJECT)) { return new ArrayList<StudySubjectAssignment>(); } Criteria studySubjectAssignmentCrit = getCurrentSession().createCriteria(StudySubjectAssignment.class); if (criterion instanceof IdentifierCriterion) { studySubjectAssignmentCrit.add(AbstractAnnotationCriterionHandler.create(criterion).translate()); } else { createAnnotationValuesCriteria(criterion, studySubjectAssignmentCrit.createCriteria("subjectAnnotationCollection"), ANNOTATION_VALUE_ASSOCIATION); } createStudySubjectAssignmentCriteria(studySubjectAssignmentCrit, study); return studySubjectAssignmentCrit.list(); }
From source file:gov.nih.nci.caintegrator.data.CaIntegrator2DaoImpl.java
License:BSD License
/** * {@inheritDoc}/*w ww . jav a2 s . co m*/ */ @Override @SuppressWarnings(UNCHECKED) // Hibernate operations are untyped public Set<AbstractReporter> findReportersForGenes(Set<String> geneSymbols, ReporterTypeEnum reporterType, Study study, Platform platform) { Set<ReporterList> studyReporterLists = getStudyReporterLists(study, reporterType, platform); if (studyReporterLists.isEmpty()) { return Collections.emptySet(); } Set<AbstractReporter> reporters = new HashSet<AbstractReporter>(); Criteria criteria = getCurrentSession().createCriteria(AbstractReporter.class); if (!geneSymbols.isEmpty()) { criteria.createCriteria(GENES_ASSOCIATION).add(Restrictions.in(SYMBOL_ATTRIBUTE, geneSymbols)); } criteria.add(Restrictions.in("reporterList", studyReporterLists)); reporters.addAll(criteria.list()); return reporters; }
From source file:gov.nih.nci.caintegrator.data.CaIntegrator2DaoImpl.java
License:BSD License
/** * {@inheritDoc}/*from w w w.j a va2 s .com*/ */ @Override @SuppressWarnings(UNCHECKED) // Hibernate operations are untyped public List<SegmentData> findMatchingSegmentDatasByLocation(List<SegmentData> segmentDatasToMatch, Study study, Platform platform) { Criteria segmentDataCrit = getCurrentSession().createCriteria(SegmentData.class); Criteria arrayDataCrit = segmentDataCrit.createCriteria("arrayData"); Criteria reporterListsCrit = arrayDataCrit.createCriteria("reporterLists"); reporterListsCrit.add(Restrictions.eq(PLATFORM_ASSOCIATION, platform)); arrayDataCrit.add(Restrictions.eq(STUDY_ASSOCIATION, study)); Junction overallOrStatement = Restrictions.disjunction(); for (SegmentData segmentData : segmentDatasToMatch) { ChromosomalLocation location = segmentData.getLocation(); overallOrStatement.add(Restrictions.conjunction() .add(Restrictions.eq("Location.startPosition", location.getStartPosition())) .add(Restrictions.eq("Location.endPosition", location.getEndPosition()))); } segmentDataCrit.add(overallOrStatement); return segmentDataCrit.list(); }
From source file:gov.nih.nci.caintegrator.data.CaIntegrator2DaoImpl.java
License:BSD License
/** * {@inheritDoc}/*from w w w. java 2 s . com*/ */ @Override @SuppressWarnings(UNCHECKED) // Hibernate operations are untyped public List<Gene> findGenesByLocation(String chromosome, Integer startPosition, Integer endPosition, GenomeBuildVersionEnum genomeBuildVersion) { String locStartPosition = "location.startPosition"; String locEndPosition = "location.endPosition"; Criteria geneLocationCriteria = getCurrentSession().createCriteria(GeneChromosomalLocation.class); // (gene.startPos <= startPosition && gene.endPos >= startPosition) // || (gene.startPos >= lowerInput && gene.startPos <= higherInput) Junction overallOrStatement = Restrictions.disjunction(); overallOrStatement.add(Restrictions.conjunction().add(Restrictions.le(locStartPosition, startPosition)) .add(Restrictions.ge(locEndPosition, startPosition))); overallOrStatement.add(Restrictions.conjunction().add(Restrictions.ge(locStartPosition, startPosition)) .add(Restrictions.le(locStartPosition, endPosition))); geneLocationCriteria.add(overallOrStatement); geneLocationCriteria.add(getChromosomeRestriction(chromosome)); geneLocationCriteria.createCriteria("geneLocationConfiguration") .add(Restrictions.eq("genomeBuildVersion", genomeBuildVersion)); geneLocationCriteria.setProjection(Projections.property("geneSymbol")); List<String> geneSymbols = geneLocationCriteria.list(); return geneSymbols.isEmpty() ? new ArrayList<Gene>() : getCurrentSession().createCriteria(Gene.class) .setProjection(Projections.distinct(Projections.property(SYMBOL_ATTRIBUTE))) .add(Restrictions.in(SYMBOL_ATTRIBUTE, geneSymbols)).addOrder(Order.asc(SYMBOL_ATTRIBUTE)) .list(); }
From source file:gov.nih.nci.caintegrator.data.CaIntegrator2DaoImpl.java
License:BSD License
/** * This function adds the values criteria for getting back the correct annotation values. * @param criterion - The main criterion object for the values we want. * @param mainAnnotationCriteria - The Criteria on the object that links directly to AbstractAnnotationValue * @param annotationValueRelationship - Relationship name that the above object has with AbstractAnnotationValue *///from w w w.j ava 2 s . c o m private void createAnnotationValuesCriteria(AbstractAnnotationCriterion criterion, Criteria mainAnnotationCriteria, String annotationValueRelationship) { if (criterion != null && criterion.getAnnotationFieldDescriptor() != null) { Criteria valuesCrit = mainAnnotationCriteria.createCriteria(annotationValueRelationship); valuesCrit.add(Restrictions.eq(ANNOTATION_DEFINITION_ASSOCIATION, criterion.getAnnotationFieldDescriptor().getDefinition())); valuesCrit.add(AbstractAnnotationCriterionHandler.create(criterion).translate()); } }
From source file:gov.nih.nci.caintegrator.data.CaIntegrator2DaoImpl.java
License:BSD License
/** * Adds the criteria to the AnnotationValue object which will associate it to the given Study. * @param study//from ww w .j a v a 2 s .c om * @param entityType * @param abstractAnnotationValueCriteria */ private void addValuesToStudyCriteria(Study study, EntityTypeEnum entityType, Criteria abstractAnnotationValueCriteria) { switch (entityType) { case SUBJECT: abstractAnnotationValueCriteria.createCriteria("subjectAnnotation") .createCriteria("studySubjectAssignment").add(Restrictions.eq(STUDY_ASSOCIATION, study)); break; case IMAGESERIES: abstractAnnotationValueCriteria.createCriteria("imageSeries").createCriteria("imageStudy") .createCriteria(STUDY_SUBJECT_ASSIGNMENT_ASSOCIATION) .add(Restrictions.eq(STUDY_ASSOCIATION, study)); break; case IMAGE: abstractAnnotationValueCriteria.createCriteria("image").createCriteria("series") .createCriteria("imageStudy").createCriteria(STUDY_SUBJECT_ASSIGNMENT_ASSOCIATION) .add(Restrictions.eq(STUDY_ASSOCIATION, study)); break; case SAMPLE: abstractAnnotationValueCriteria.createCriteria("sampleAcquisition") .createCriteria(STUDY_SUBJECT_ASSIGNMENT_ASSOCIATION) .add(Restrictions.eq(STUDY_ASSOCIATION, study)); break; default: throw new IllegalStateException("Unknown Entity Type."); } }
From source file:gov.nih.nci.caintegrator.data.CaIntegrator2DaoImpl.java
License:BSD License
/** * {@inheritDoc}//from ww w . j av a 2 s . c om */ @Override @SuppressWarnings(UNCHECKED) public ImageDataSourceConfiguration retrieveImagingDataSourceForStudy(Study study) { Criteria imagingDataSourceConfigurationCrit = getCurrentSession() .createCriteria(ImageDataSourceConfiguration.class); imagingDataSourceConfigurationCrit.createCriteria("studyConfiguration") .add(Restrictions.eq(STUDY_ASSOCIATION, study)); List<ImageDataSourceConfiguration> sourceList = imagingDataSourceConfigurationCrit.list(); if (sourceList != null && !sourceList.isEmpty()) { return sourceList.get(0); } return null; }
From source file:gov.nih.nci.caintegrator.data.CopyNumberAlterationCriterionConverter.java
License:BSD License
Criteria retrieveSegmentDataCriteria(Study study, Platform platform, Session currentSession) { Criteria segmentDataCrit = currentSession.createCriteria(SegmentData.class); Criteria arrayDataCrit = segmentDataCrit.createCriteria("arrayData"); arrayDataCrit.createCriteria("reporterLists").add(Restrictions.eq("platform", platform)); arrayDataCrit.add(Restrictions.eq("study", study)); if (CopyNumberCriterionTypeEnum.SEGMENT_VALUE.equals(copyNumberCriterion.getCopyNumberCriterionType())) { addSegmentValueCriterion(segmentDataCrit); } else { // Calls type... addCallsValueCriterion(segmentDataCrit); }/* ww w . j a va 2 s. com*/ addGenomicIntervalTypeToCriteria(segmentDataCrit, currentSession, platform.getGenomeVersion()); return segmentDataCrit; }
From source file:gov.nih.nci.caintegrator.studyQueryService.germline.SNPFrequencyFindingHandler.java
License:BSD License
private List<Population> handlePopulationCriteria(SNPFrequencyFindingCriteriaDTO findingCritDTO, Session session) {// w w w . ja v a 2 s. co m String[] populationNames = findingCritDTO.getPopulationNames(); Long studyId = findingCritDTO.getStudyCriteria().getId(); if ((populationNames == null || populationNames.length < 1) && (studyId == null)) { return new ArrayList<Population>(); } Criteria popCrit = session.createCriteria(Population.class); if (populationNames != null && populationNames.length > 0) { popCrit.add(Restrictions.in("name", populationNames)); } boolean appendStudy = isAddStudyCriteria(findingCritDTO); if (appendStudy) { Criteria studyCrit = popCrit.createCriteria("studyCollection"); addStudyCriteria(findingCritDTO, studyCrit, session); } List<Population> populationList = popCrit.list(); return populationList; }