List of usage examples for org.apache.commons.collections ListUtils removeAll
public static List removeAll(Collection collection, Collection remove)
remove
from collection
. From source file:org.kuali.rice.krad.devtools.datadictionary.ReloadingDataDictionary.java
public void urlContentChanged(final URL url) { LOG.info("reloading dictionary configuration for " + url.toString()); try {/*from w ww . ja v a2 s . c o m*/ InputStream urlStream = url.openStream(); InputStreamResource resource = new InputStreamResource(urlStream); List<String> beforeReloadBeanNames = Arrays.asList(ddBeans.getBeanDefinitionNames()); int originalValidationMode = xmlReader.getValidationMode(); xmlReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD); xmlReader.loadBeanDefinitions(resource); xmlReader.setValidationMode(originalValidationMode); List<String> afterReloadBeanNames = Arrays.asList(ddBeans.getBeanDefinitionNames()); List<String> addedBeanNames = ListUtils.removeAll(afterReloadBeanNames, beforeReloadBeanNames); String namespace = KRADConstants.DEFAULT_NAMESPACE; if (urlToNamespaceMapping.containsKey(url.toString())) { namespace = urlToNamespaceMapping.get(url.toString()); } ddIndex.addBeanNamesToNamespace(namespace, addedBeanNames); performDictionaryPostProcessing(true); } catch (Exception e) { LOG.info("Exception in dictionary hot deploy: " + e.getMessage(), e); } }
From source file:ubic.gemma.persistence.service.analysis.expression.diff.DifferentialExpressionAnalysisDaoImpl.java
@Override public Map<Long, Collection<DifferentialExpressionAnalysisValueObject>> getAnalysesByExperimentIds( Collection<Long> expressionExperimentIds, int offset, int limit) { /*/*w ww. j a v a2 s .com*/ * There are three cases to consider: the ids are experiments; the ids are experiment subsets; the ids are * experiments that have subsets. */ Map<Long, Collection<DifferentialExpressionAnalysisValueObject>> r = new HashMap<>(); Map<Long, Collection<Long>> arrayDesignsUsed = CommonQueries .getArrayDesignsUsedEEMap(expressionExperimentIds, this.getSessionFactory().getCurrentSession()); /* * Fetch analyses of experiments or subsets. */ //noinspection unchecked Collection<DifferentialExpressionAnalysis> hits = this.getSessionFactory().getCurrentSession().createQuery( "select distinct a from DifferentialExpressionAnalysis a join fetch a.experimentAnalyzed e join" + " fetch a.resultSets rs join fetch rs.hitListSizes where e.id in (:eeids)") .setParameterList("eeids", expressionExperimentIds).setFirstResult(offset) .setMaxResults(limit > 0 ? limit : -1).list(); /* * FIXME the above query yields a warning * "firstResult/maxResults specified with collection fetch; applying in memory!" */ Map<Long, Collection<FactorValue>> ee2fv = new HashMap<>(); List<Object[]> fvs; if (!hits.isEmpty()) { // factor values for the experiments. //noinspection unchecked fvs = this.getSessionFactory().getCurrentSession().createQuery("select distinct ee.id, fv from " + "ExpressionExperiment" + " ee join ee.bioAssays ba join ba.sampleUsed bm join bm.factorValues fv where ee.id in (:ees)") .setParameterList("ees", expressionExperimentIds).list(); this.addFactorValues(ee2fv, fvs); // also get factor values for subsets - those not found yet. Collection<Long> used = new HashSet<>(); for (DifferentialExpressionAnalysis a : hits) { used.add(a.getExperimentAnalyzed().getId()); } List probableSubSetIds = ListUtils.removeAll(used, ee2fv.keySet()); if (!probableSubSetIds.isEmpty()) { //noinspection unchecked fvs = this.getSessionFactory().getCurrentSession().createQuery("select distinct ee.id, fv from " + "ExpressionExperimentSubSet" + " ee join ee.bioAssays ba join ba.sampleUsed bm join bm.factorValues fv where ee.id in (:ees)") .setParameterList("ees", probableSubSetIds).list(); this.addFactorValues(ee2fv, fvs); } } /* * Subsets of those same experiments (there might not be any) */ //noinspection unchecked List<DifferentialExpressionAnalysis> analysesOfSubsets = this.getSessionFactory().getCurrentSession() .createQuery("select distinct a from " + "ExpressionExperimentSubSet" + " ee, DifferentialExpressionAnalysis a" + " join ee.sourceExperiment see " + " join fetch a.experimentAnalyzed eeanalyzed where see.id in (:eeids) and ee=eeanalyzed") .setParameterList("eeids", expressionExperimentIds).list(); if (!analysesOfSubsets.isEmpty()) { hits.addAll(analysesOfSubsets); Collection<Long> experimentSubsetIds = new HashSet<>(); for (DifferentialExpressionAnalysis a : analysesOfSubsets) { ExpressionExperimentSubSet subset = (ExpressionExperimentSubSet) a.getExperimentAnalyzed(); experimentSubsetIds.add(subset.getId()); } // factor value information for the subset. The key output is the ID of the subset, not of the source // experiment. //noinspection unchecked fvs = this.getSessionFactory().getCurrentSession().createQuery("select distinct ee.id, fv from " + "ExpressionExperimentSubSet" + " ee join ee.bioAssays ba join ba.sampleUsed bm join bm.factorValues fv where ee.id in (:ees)") .setParameterList("ees", experimentSubsetIds).list(); this.addFactorValues(ee2fv, fvs); } // postprocesss... if (hits.isEmpty()) { return r; } Collection<DifferentialExpressionAnalysisValueObject> summaries = this.convertToValueObjects(hits, arrayDesignsUsed, ee2fv); for (DifferentialExpressionAnalysisValueObject an : summaries) { Long bioAssaySetId; if (an.getSourceExperiment() != null) { bioAssaySetId = an.getSourceExperiment(); } else { bioAssaySetId = an.getBioAssaySetId(); } if (!r.containsKey(bioAssaySetId)) { r.put(bioAssaySetId, new ArrayList<DifferentialExpressionAnalysisValueObject>()); } r.get(bioAssaySetId).add(an); } return r; }
From source file:ubic.gemma.persistence.util.CommonQueries.java
/** * @param ees experiments//from w w w .j a va 2 s . c o m * @param session session * @return map of experiment to collection of array design ids. If any of the ids given are for subsets, then the * key in the return value will be for the subset, not the source experiment (so it is consistent with the * input) */ public static Map<Long, Collection<Long>> getArrayDesignsUsedEEMap(Collection<Long> ees, Session session) { Map<Long, Collection<Long>> ee2ads = new HashMap<>(); if (ees == null || ees.isEmpty()) return ee2ads; final String eeAdQuery = "select distinct ee.id,ad.id from ExpressionExperiment as ee inner join " + "ee.bioAssays b inner join b.arrayDesignUsed ad where ee.id in (:ees)"; org.hibernate.Query queryObject = session.createQuery(eeAdQuery); queryObject.setParameterList("ees", ees); queryObject.setReadOnly(true); queryObject.setFlushMode(FlushMode.MANUAL); List<?> qr = queryObject.list(); ee2ads = CommonQueries.addAllAds(ee2ads, qr); if (ee2ads.size() < ees.size()) { // ids might be invalid, but also might be subsets. Note that the output key is for the subset, not the // source. String subsetQuery = "select distinct ees.id,ad.id from ExpressionExperimentSubSet as ees join ees.sourceExperiment ee " + " join ee.bioAssays b join b.arrayDesignUsed ad where ees.id in (:ees)"; //noinspection unchecked Collection<Long> possibleEEsubsets = ListUtils.removeAll(ees, ee2ads.keySet()); // note: CollectionUtils.removeAll has a bug. qr = session.createQuery(subsetQuery).setParameterList("ees", possibleEEsubsets).list(); ee2ads = CommonQueries.addAllAds(ee2ads, qr); } return ee2ads; }