use of ubic.gemma.web.remote.JsonReaderResponse in project Gemma by PavlidisLab.
the class CharacteristicBrowserController method browse.
public JsonReaderResponse<AnnotationValueObject> browse(ListBatchCommand batch) {
Integer count = characteristicService.countAll();
List<AnnotationValueObject> results = new ArrayList<>();
Collection<Characteristic> records;
if (StringUtils.isNotBlank(batch.getSort())) {
String o = batch.getSort();
String orderBy;
switch(o) {
case "className":
orderBy = "category";
break;
case "termName":
orderBy = "value";
break;
case "evidenceCode":
orderBy = "evidenceCode";
break;
default:
throw new IllegalArgumentException("Unknown sort field: " + o);
}
boolean descending = batch.getDir() != null && batch.getDir().equalsIgnoreCase("DESC");
records = characteristicService.browse(batch.getStart(), batch.getLimit(), orderBy, descending);
} else {
records = characteristicService.browse(batch.getStart(), batch.getLimit());
}
Map<Characteristic, Object> charToParent = characteristicService.getParents(records);
for (Object o : records) {
Characteristic c = (Characteristic) o;
Object parent = charToParent.get(c);
AnnotationValueObject avo = new AnnotationValueObject();
avo.setId(c.getId());
avo.setClassName(c.getCategory());
avo.setTermName(c.getValue());
if (c.getEvidenceCode() != null)
avo.setEvidenceCode(c.getEvidenceCode().toString());
populateClassValues(c, avo);
if (parent != null) {
populateParentInformation(avo, parent);
}
results.add(avo);
}
return new JsonReaderResponse<>(results, count);
}
use of ubic.gemma.web.remote.JsonReaderResponse in project Gemma by PavlidisLab.
the class BibliographicReferenceControllerImpl method browse.
@Override
public JsonReaderResponse<BibliographicReferenceValueObject> browse(ListBatchCommand batch) {
Integer count = this.bibliographicReferenceService.countAll();
List<BibliographicReference> records = this.getBatch(batch);
Map<BibliographicReference, Collection<ExpressionExperiment>> relatedExperiments = this.bibliographicReferenceService.getRelatedExperiments(records);
List<BibliographicReferenceValueObject> valueObjects = new ArrayList<>();
for (BibliographicReference ref : records) {
ref = this.bibliographicReferenceService.thaw(ref);
BibliographicReferenceValueObject vo = new BibliographicReferenceValueObject(ref);
if (relatedExperiments.containsKey(ref)) {
vo.setExperiments(expressionExperimentService.loadValueObjects(relatedExperiments.get(ref)));
}
valueObjects.add(vo);
// adding phenotype information to the Bibliographic Reference
Collection<PhenotypeAssociation> phenotypeAssociations = this.phenotypeAssociationService.findPhenotypesForBibliographicReference(vo.getPubAccession());
Collection<BibliographicPhenotypesValueObject> bibliographicPhenotypesValueObjects = BibliographicPhenotypesValueObject.phenotypeAssociations2BibliographicPhenotypesValueObjects(phenotypeAssociations);
vo.setBibliographicPhenotypes(bibliographicPhenotypesValueObjects);
}
return new JsonReaderResponse<>(valueObjects, count);
}
use of ubic.gemma.web.remote.JsonReaderResponse in project Gemma by PavlidisLab.
the class ExpressionExperimentController method loadExpressionExperimentsWithQcIssues.
/**
* AJAX; get a collection of experiments that have had samples removed due to outliers
* TODO: and experiment that have possible batch effects detected
*
* @return json reader response
*/
public JsonReaderResponse<JSONObject> loadExpressionExperimentsWithQcIssues() {
Collection<ExpressionExperiment> outlierEEs = expressionExperimentService.getExperimentsWithOutliers();
Collection<ExpressionExperiment> ees = new HashSet<>();
ees.addAll(outlierEEs);
// ees.addAll( batchEffectEEs );
List<JSONObject> jsonRecords = new ArrayList<>();
for (ExpressionExperiment ee : ees) {
// noinspection MismatchedQueryAndUpdateOfCollection
JSONObject record = new JSONObject();
record.element("id", ee.getId());
record.element("shortName", ee.getShortName());
record.element("name", ee.getName());
if (outlierEEs.contains(ee)) {
record.element("sampleRemoved", true);
}
// record.element( "batchEffect", batchEffectEEs.contains( ee ) );
jsonRecords.add(record);
}
return new JsonReaderResponse<>(jsonRecords);
}
use of ubic.gemma.web.remote.JsonReaderResponse in project Gemma by PavlidisLab.
the class GeneralSearchControllerImpl method ajaxSearch.
@Override
public JsonReaderResponse<SearchResult> ajaxSearch(SearchSettingsValueObject settingsValueObject) {
SearchSettings settings = SearchSettingsValueObject.toEntity(settingsValueObject);
List<SearchResult> finalResults = new ArrayList<>();
if (settings == null || StringUtils.isBlank(settings.getQuery()) || StringUtils.isBlank(settings.getQuery().replaceAll("\\*", ""))) {
// FIXME validate input better, and return error.
BaseFormController.log.info("No query or invalid.");
// return new ListRange( finalResults );
throw new IllegalArgumentException("Query '" + settings + "' was invalid");
}
StopWatch watch = new StopWatch();
watch.start();
((SearchSettingsImpl) settings).setDoHighlighting(true);
Map<Class<?>, List<SearchResult>> searchResults = searchService.search(settings);
watch.stop();
if (watch.getTime() > 500) {
BaseFormController.log.info("Search service work on: " + settings + " took " + watch.getTime() + " ms");
}
/*
* FIXME sort by the number of hits per class, so smallest number of hits is at the top.
*/
watch.reset();
watch.start();
if (searchResults != null) {
for (Class<?> clazz : searchResults.keySet()) {
List<SearchResult> results = searchResults.get(clazz);
if (results.size() == 0)
continue;
BaseFormController.log.info("Search for: " + settings + "; result: " + results.size() + " " + clazz.getSimpleName() + "s");
/*
* Now put the valueObjects inside the SearchResults in score order.
*/
Collections.sort(results);
this.fillValueObjects(clazz, results, settings);
finalResults.addAll(results);
}
}
if (watch.getTime() > 500) {
BaseFormController.log.info("Final unpacking of results for query:" + settings + " took " + watch.getTime() + " ms");
}
return new JsonReaderResponse<>(finalResults);
}
Aggregations