use of ubic.gemma.web.services.rest.util.GemmaApiException in project Gemma by PavlidisLab.
the class FilterArg method getObjectFilters.
/**
* Creates an ArrayList of Object Filter arrays, that can be used as a filter parameter for service value object
* retrieval.
*
* @return an ArrayList of Object Filter arrays, each array represents a disjunction (OR) of filters. Arrays
* then represent a conjunction (AND) with other arrays in the list.
*/
public ArrayList<ObjectFilter[]> getObjectFilters() {
this.checkMalformed();
if (propertyNames == null || propertyNames.isEmpty())
return null;
ArrayList<ObjectFilter[]> filterList = new ArrayList<>(propertyNames.size());
for (int i = 0; i < propertyNames.size(); i++) {
try {
String[] properties = propertyNames.get(i);
String[] values = propertyValues.get(i);
String[] operators = propertyOperators.get(i);
Class[] types = propertyTypes.get(i);
ObjectFilter[] filterArray = new ObjectFilter[properties.length];
for (int j = 0; j < properties.length; j++) {
filterArray[j] = new ObjectFilter(properties[j], types[j], values[j], operators[j], objectAlias);
}
filterList.add(filterArray);
} catch (IndexOutOfBoundsException e) {
throw new GemmaApiException(new WellComposedErrorBody(Response.Status.BAD_REQUEST, ERROR_MSG_ARGS_MISALIGNED));
} catch (ParseException e) {
WellComposedErrorBody error = new WellComposedErrorBody(Response.Status.BAD_REQUEST, ERROR_MSG_MALFORMED_REQUEST);
WellComposedErrorBody.addExceptionFields(error, e);
throw new GemmaApiException(error);
}
}
return filterList;
}
use of ubic.gemma.web.services.rest.util.GemmaApiException in project Gemma by PavlidisLab.
the class TaxonArg method getGenesOnChromosome.
/**
* Lists Genes overlapping a location on a specific chromosome on a taxon that this TaxonArg represents.
*
* @param taxonService the service that will be used to retrieve the persistent Taxon object.
* @param chromosomeService the service that will be used to find the Chromosome object.
* @param geneService the service that will be used to retrieve the Gene VOs
* @param chromosomeName name of the chromosome to look on
* @param start the start nucleotide denoting the location to look for genes at.
* @param size the size (in nucleotides) of the location from the 'start' nucleotide.
* @return collection of Gene VOs overlapping the location defined by the 'start' and 'size' parameters.
*/
public Collection<GeneValueObject> getGenesOnChromosome(TaxonService taxonService, ChromosomeService chromosomeService, GeneService geneService, String chromosomeName, long start, int size) {
// Taxon argument
Taxon taxon = this.getPersistentObject(taxonService);
// Chromosome argument
Collection<Chromosome> chromosomes = chromosomeService.find(chromosomeName, taxon);
if (chromosomes.isEmpty()) {
WellComposedErrorBody errorBody = new WellComposedErrorBody(Response.Status.NOT_FOUND, "Chromosome " + chromosomeName + " not found for taxon " + taxon.getScientificName());
throw new GemmaApiException(errorBody);
}
Chromosome chromosome = chromosomes.iterator().next();
// Setup chromosome location
PhysicalLocation region = PhysicalLocation.Factory.newInstance(chromosome);
region.setNucleotide(start);
region.setNucleotideLength(size);
// region.setStrand( strand );
Collection<GeneValueObject> GVOs = geneService.loadValueObjects(geneService.find(region));
if (GVOs == null) {
WellComposedErrorBody errorBody = new WellComposedErrorBody(Response.Status.NOT_FOUND, "No genes found on chromosome " + chromosomeName + " between positions " + start + " and " + start + size + ".");
throw new GemmaApiException(errorBody);
}
return GVOs;
}
use of ubic.gemma.web.services.rest.util.GemmaApiException in project Gemma by PavlidisLab.
the class MutableArg method throwNotFound.
/**
* Throws a GemmaApiException informing that the object this argument represents was not found.
*/
void throwNotFound() {
WellComposedErrorBody errorBody = new WellComposedErrorBody(Response.Status.NOT_FOUND, ERROR_MSG_ENTITY_NOT_FOUND);
WellComposedErrorBody.addExceptionFields(errorBody, new EntityNotFoundException(this.nullCause));
throw new GemmaApiException(errorBody);
}
use of ubic.gemma.web.services.rest.util.GemmaApiException in project Gemma by PavlidisLab.
the class ArrayEntityArg method convertParseException.
/**
* Converts the given parse exception into a GemmaApiException with a well composed error body.
*
* @param e the exception to be converted.
* @return a properly populated GemmaApiException describing the given exception.
*/
GemmaApiException convertParseException(ParseException e) {
WellComposedErrorBody error = new WellComposedErrorBody(Response.Status.BAD_REQUEST, FilterArg.ERROR_MSG_MALFORMED_REQUEST);
WellComposedErrorBody.addExceptionFields(error, e);
return new GemmaApiException(error);
}
use of ubic.gemma.web.services.rest.util.GemmaApiException in project Gemma by PavlidisLab.
the class MalformableArg method checkMalformed.
/**
* Checks whether the instance of this object was created as a malformed argument, and if true, throws an
* exception using the information provided in the constructor.
*/
void checkMalformed() {
if (this.malformed) {
WellComposedErrorBody body = new WellComposedErrorBody(Response.Status.BAD_REQUEST, errorMessage);
WellComposedErrorBody.addExceptionFields(body, this.exception);
throw new GemmaApiException(body);
}
}
Aggregations