From: <ba...@us...> - 2010-07-30 17:33:38
|
Revision: 3538 http://obo.svn.sourceforge.net/obo/?rev=3538&view=rev Author: balhoff Date: 2010-07-30 17:33:31 +0000 (Fri, 30 Jul 2010) Log Message: ----------- Now returning orders and families in taxon query service. Modified Paths: -------------- OBD-WS/trunk/src/org/phenoscape/obd/query/AnnotatedTaxaQueryBuilder.java OBD-WS/trunk/src/org/phenoscape/obd/query/PhenoscapeDataStore.java OBD-WS/trunk/src/org/phenoscape/ws/application/PhenoscapeWebServiceApplication.java Modified: OBD-WS/trunk/src/org/phenoscape/obd/query/AnnotatedTaxaQueryBuilder.java =================================================================== --- OBD-WS/trunk/src/org/phenoscape/obd/query/AnnotatedTaxaQueryBuilder.java 2010-07-30 16:50:54 UTC (rev 3537) +++ OBD-WS/trunk/src/org/phenoscape/obd/query/AnnotatedTaxaQueryBuilder.java 2010-07-30 17:33:31 UTC (rev 3538) @@ -17,8 +17,8 @@ private final AnnotationsQueryConfig config; private final boolean totalOnly; - private static final String SELECT = "SELECT DISTINCT queryable_taxon_annotation.taxon_node_id, queryable_taxon_annotation.taxon_uid, queryable_taxon_annotation.taxon_label, queryable_taxon_annotation.taxon_rank_node_id, queryable_taxon_annotation.taxon_rank_uid, queryable_taxon_annotation.taxon_rank_label, queryable_taxon_annotation.taxon_is_extinct FROM queryable_taxon_annotation "; - private static final String SELECT_WITH_TAXONOMY = "SELECT queryable_taxon_annotation.taxon_node_id, queryable_taxon_annotation.taxon_uid, queryable_taxon_annotation.taxon_label, queryable_taxon_annotation.taxon_rank_node_id, queryable_taxon_annotation.taxon_rank_uid, queryable_taxon_annotation.taxon_rank_label, queryable_taxon_annotation.taxon_is_extinct, family_taxon.node_id AS taxon_family_node_id, family_taxon.uid AS taxon_family_uid, family_taxon.label AS taxon_family_label, family_taxon.is_extinct AS taxon_family_is_extinct, order_taxon.node_id AS taxon_order_node_id, order_taxon.uid AS taxon_order_uid, order_taxon.label AS taxon_order_label, order_taxon.is_extinct AS taxon_order_is_extinct FROM "; + private static final String SELECT = "SELECT DISTINCT queryable_taxon_annotation.taxon_node_id, queryable_taxon_annotation.taxon_uid, queryable_taxon_annotation.taxon_label, queryable_taxon_annotation.taxon_rank_node_id, queryable_taxon_annotation.taxon_rank_uid, queryable_taxon_annotation.taxon_rank_label, queryable_taxon_annotation.taxon_is_extinct, queryable_taxon_annotation.taxon_family_node_id, queryable_taxon_annotation.taxon_order_node_id FROM queryable_taxon_annotation "; + private static final String SELECT_WITH_TAXONOMY = "SELECT taxon_node_id, taxon_uid, taxon_label, taxon_rank_node_id, taxon_rank_uid, taxon_rank_label, taxon_is_extinct, family_taxon.node_id AS taxon_family_node_id, family_taxon.uid AS taxon_family_uid, family_taxon.label AS taxon_family_label, family_taxon.is_extinct AS taxon_family_is_extinct, order_taxon.node_id AS taxon_order_node_id, order_taxon.uid AS taxon_order_uid, order_taxon.label AS taxon_order_label, order_taxon.is_extinct AS taxon_order_is_extinct FROM "; private static final String TABLE = "queryable_taxon_annotation"; private static final Map<SORT_COLUMN, String> COLUMNS = new HashMap<SORT_COLUMN, String>(); static { @@ -26,7 +26,7 @@ COLUMNS.put(SORT_COLUMN.FAMILY, "taxon_family_label"); COLUMNS.put(SORT_COLUMN.ORDER, "taxon_order_label"); } - private static final String TAXONOMY_JOIN = " LEFT JOIN taxon family_taxon ON (family_taxon.node_id = queryable_taxon_annotation.taxon_family_node_id) JOIN taxon order_taxon ON (order_taxon.node_id = queryable_taxon_annotation.taxon_order_node_id) "; + private static final String TAXONOMY_JOIN = " LEFT JOIN taxon family_taxon ON (family_taxon.node_id = taxon_family_node_id) LEFT JOIN taxon order_taxon ON (order_taxon.node_id = taxon_order_node_id) "; public AnnotatedTaxaQueryBuilder(AnnotationsQueryConfig config, boolean totalOnly) { this.config = config; @@ -85,8 +85,7 @@ if (this.totalOnly) { query = "SELECT count(*) FROM (" + baseQuery + ") AS query"; } else { - //TODO may need to add an AS - query = SELECT_WITH_TAXONOMY + baseQuery + TAXONOMY_JOIN + "ORDER BY " + COLUMNS.get(this.config.getSortColumn()) + " " + this.getSortText() + "LIMIT ? OFFSET ? " ; + query = SELECT_WITH_TAXONOMY + "(" + baseQuery + ") AS query " + TAXONOMY_JOIN + "ORDER BY " + COLUMNS.get(this.config.getSortColumn()) + " " + this.getSortText() + "LIMIT ? OFFSET ? " ; } log().debug("Query: " + query); return query; Modified: OBD-WS/trunk/src/org/phenoscape/obd/query/PhenoscapeDataStore.java =================================================================== --- OBD-WS/trunk/src/org/phenoscape/obd/query/PhenoscapeDataStore.java 2010-07-30 16:50:54 UTC (rev 3537) +++ OBD-WS/trunk/src/org/phenoscape/obd/query/PhenoscapeDataStore.java 2010-07-30 17:33:31 UTC (rev 3538) @@ -365,7 +365,6 @@ } private GeneAnnotation createGeneAnnotation(ResultSet result) throws SQLException { - //TODO this needs to check for empty strings before creating terms final GeneAnnotation annotation = new GeneAnnotation(); final GeneTerm gene = new GeneTerm(result.getInt("gene_node_id"), null); gene.setUID(result.getString("gene_uid")); @@ -373,7 +372,9 @@ annotation.setGene(gene); annotation.setEntity(new SimpleTerm(result.getString("entity_uid"), result.getString("entity_label"))); annotation.setQuality(new SimpleTerm(result.getString("quality_uid"), result.getString("quality_label"))); - annotation.setRelatedEntity(new SimpleTerm(result.getString("related_entity_uid"), result.getString("related_entity_label"))); + if (result.getString("related_entity_uid") != null) { + annotation.setRelatedEntity(new SimpleTerm(result.getString("related_entity_uid"), result.getString("related_entity_label"))); + } return annotation; } Modified: OBD-WS/trunk/src/org/phenoscape/ws/application/PhenoscapeWebServiceApplication.java =================================================================== --- OBD-WS/trunk/src/org/phenoscape/ws/application/PhenoscapeWebServiceApplication.java 2010-07-30 16:50:54 UTC (rev 3537) +++ OBD-WS/trunk/src/org/phenoscape/ws/application/PhenoscapeWebServiceApplication.java 2010-07-30 17:33:31 UTC (rev 3538) @@ -53,7 +53,7 @@ router.attach("/timestamp", KBTimestampResource.class).setMatchingMode(Template.MODE_STARTS_WITH); router.attach("/annotation/gene", GeneAnnotationsResource.class); router.attach("/annotation/taxon/distinct", TaxonAnnotationsResource.class); - router.attach("/taxa/annotated", TaxaResource.class); + router.attach("/taxon/annotated", TaxaResource.class); router.attach("/gene/annotated", GenesResource.class); router.attach("/report/count/publications", PublicationCountsResource.class); router.attach("/report/count/characters/published", PublishedCharacterCountsResource.class); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |