@Test public void multiTaxonAllUnknownReturnFields() { StringBuilder query = new StringBuilder(); CypherReturnClauseBuilder.appendReturnClauseMap( query, QueryType.MULTI_TAXON_ALL, unknownFields()); assertThat(query.toString(), is(" RETURN " + "sourceTaxon.externalId as source_taxon_external_id," + "sourceTaxon.name as source_taxon_name," + "sourceTaxon.path as source_taxon_path," + "sourceSpecimen.lifeStageLabel as source_specimen_life_stage," + "sourceSpecimen.basisOfRecordLabel as source_specimen_basis_of_record," + "interaction.label as interaction_type," + "targetTaxon.externalId as target_taxon_external_id," + "targetTaxon.name as target_taxon_name," + "targetTaxon.path as target_taxon_path," + "targetSpecimen.lifeStageLabel as target_specimen_life_stage," + "targetSpecimen.basisOfRecordLabel as target_specimen_basis_of_record," + "loc.latitude as latitude," + "loc.longitude as longitude," + "study.title as study_title")); }
static void appendReturnClauseMap(StringBuilder query, QueryType queryType, Map parameterMap) { List<String> requestedReturnFields = CypherQueryBuilder.collectRequestedFields(parameterMap); if (QueryType.isDistinct(queryType) && QueryType.usesSpecimenData(queryType)) { query.append(" WITH distinct ") .append(ResultObject.TARGET_TAXON.getLabel()) .append(", ") .append(ResultObject.INTERACTION.getLabel()) .append(".label as ") .append(ResultObject.INTERACTION_TYPE.getLabel()) .append(", ") .append(ResultObject.SOURCE_TAXON.getLabel()); appendAggregateCountersIfNeeded(query, requestedReturnFields); } query.append(" "); appendTaxonIdPrefixClause(query, queryType, parameterMap, requestedReturnFields); appendReturnClause(query, queryType, requestedReturnFields); List<String> counters = QueryType.aggregateCountersIn(requestedReturnFields); if (!counters.isEmpty() && (collectParamValues(parameterMap, ParamName.SOURCE_TAXON).isEmpty() || collectParamValues(parameterMap, ParamName.TARGET_TAXON).isEmpty()) ) { } }
CypherReturnClauseBuilder { static void appendReturnClauseMap(StringBuilder query, QueryType queryType, Map parameterMap) { List<String> requestedReturnFields = CypherQueryBuilder.collectRequestedFields(parameterMap); if (QueryType.isDistinct(queryType) && QueryType.usesSpecimenData(queryType)) { query.append(" WITH distinct ") .append(ResultObject.TARGET_TAXON.getLabel()) .append(", ") .append(ResultObject.INTERACTION.getLabel()) .append(".label as ") .append(ResultObject.INTERACTION_TYPE.getLabel()) .append(", ") .append(ResultObject.SOURCE_TAXON.getLabel()); appendAggregateCountersIfNeeded(query, requestedReturnFields); } query.append(" "); appendTaxonIdPrefixClause(query, queryType, parameterMap, requestedReturnFields); appendReturnClause(query, queryType, requestedReturnFields); List<String> counters = QueryType.aggregateCountersIn(requestedReturnFields); if (!counters.isEmpty() && (collectParamValues(parameterMap, ParamName.SOURCE_TAXON).isEmpty() || collectParamValues(parameterMap, ParamName.TARGET_TAXON).isEmpty()) ) { } } }
CypherReturnClauseBuilder { static void appendReturnClauseMap(StringBuilder query, QueryType queryType, Map parameterMap) { List<String> requestedReturnFields = CypherQueryBuilder.collectRequestedFields(parameterMap); if (QueryType.isDistinct(queryType) && QueryType.usesSpecimenData(queryType)) { query.append(" WITH distinct ") .append(ResultObject.TARGET_TAXON.getLabel()) .append(", ") .append(ResultObject.INTERACTION.getLabel()) .append(".label as ") .append(ResultObject.INTERACTION_TYPE.getLabel()) .append(", ") .append(ResultObject.SOURCE_TAXON.getLabel()); appendAggregateCountersIfNeeded(query, requestedReturnFields); } query.append(" "); appendTaxonIdPrefixClause(query, queryType, parameterMap, requestedReturnFields); appendReturnClause(query, queryType, requestedReturnFields); List<String> counters = QueryType.aggregateCountersIn(requestedReturnFields); if (!counters.isEmpty() && (collectParamValues(parameterMap, ParamName.SOURCE_TAXON).isEmpty() || collectParamValues(parameterMap, ParamName.TARGET_TAXON).isEmpty()) ) { } }  }
CypherReturnClauseBuilder { static void appendReturnClauseMap(StringBuilder query, QueryType queryType, Map parameterMap) { List<String> requestedReturnFields = CypherQueryBuilder.collectRequestedFields(parameterMap); if (QueryType.isDistinct(queryType) && QueryType.usesSpecimenData(queryType)) { query.append(" WITH distinct ") .append(ResultObject.TARGET_TAXON.getLabel()) .append(", ") .append(ResultObject.INTERACTION.getLabel()) .append(".label as ") .append(ResultObject.INTERACTION_TYPE.getLabel()) .append(", ") .append(ResultObject.SOURCE_TAXON.getLabel()); appendAggregateCountersIfNeeded(query, requestedReturnFields); } query.append(" "); appendTaxonIdPrefixClause(query, queryType, parameterMap, requestedReturnFields); appendReturnClause(query, queryType, requestedReturnFields); List<String> counters = QueryType.aggregateCountersIn(requestedReturnFields); if (!counters.isEmpty() && (collectParamValues(parameterMap, ParamName.SOURCE_TAXON).isEmpty() || collectParamValues(parameterMap, ParamName.TARGET_TAXON).isEmpty()) ) { } }   }
CypherReturnClauseBuilder { static void appendReturnClauseMap(StringBuilder query, QueryType queryType, Map parameterMap) { List<String> requestedReturnFields = CypherQueryBuilder.collectRequestedFields(parameterMap); if (QueryType.isDistinct(queryType) && QueryType.usesSpecimenData(queryType)) { query.append(" WITH distinct ") .append(ResultObject.TARGET_TAXON.getLabel()) .append(", ") .append(ResultObject.INTERACTION.getLabel()) .append(".label as ") .append(ResultObject.INTERACTION_TYPE.getLabel()) .append(", ") .append(ResultObject.SOURCE_TAXON.getLabel()); appendAggregateCountersIfNeeded(query, requestedReturnFields); } query.append(" "); appendTaxonIdPrefixClause(query, queryType, parameterMap, requestedReturnFields); appendReturnClause(query, queryType, requestedReturnFields); List<String> counters = QueryType.aggregateCountersIn(requestedReturnFields); if (!counters.isEmpty() && (collectParamValues(parameterMap, ParamName.SOURCE_TAXON).isEmpty() || collectParamValues(parameterMap, ParamName.TARGET_TAXON).isEmpty()) ) { } }    }