From b40c5c4b3a0869c20c0a95e190b392772443751d Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Tue, 26 Nov 2013 14:28:22 +0000 Subject: [PATCH] updated to support new spd-model at version 3.0.0-SNAPSHOT git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/speciesdiscovery@86191 82a268e6-3cf1-43bd-a215-b396298e98cf --- pom.xml | 9 ---- .../client/cluster/TablesForResultRow.java | 8 +-- .../client/resultview/SpeciesGrid.java | 2 +- .../client/resultview/TaxonomyGrid.java | 2 +- .../client/util/OccurencesGridFields.java | 5 +- .../client/util/SpeciesGridFields.java | 2 +- .../client/util/TaxonomyGridField.java | 2 +- .../util/stream/OccurrencesDataSource.java | 7 +-- .../util/stream/ResultRowDataSource.java | 6 +-- .../util/stream/TaxonomyRowDataSource.java | 4 +- .../server/ResultRowTable.java | 8 +-- .../server/TaxonomyRowTable.java | 8 +-- .../server/service/OccurrenceConverter.java | 14 ++++-- .../server/service/ResultItemConverter.java | 6 +-- .../server/service/TaxonomyItemConverter.java | 6 +-- .../server/stream/IteratorPointInfo.java | 2 +- .../server/stream/OccurenceCSVConverter.java | 6 ++- .../speciesdiscovery/shared/Occurrence.java | 41 ++++++++++------ .../speciesdiscovery/shared/ResultRow.java | 30 ++++++------ .../speciesdiscovery/shared/TaxonomyRow.java | 45 ++++++++--------- .../speciesdiscovery/client/ServiceQuery.java | 49 +++++++++++++++++-- 21 files changed, 160 insertions(+), 102 deletions(-) diff --git a/pom.xml b/pom.xml index a875bdc..c6fe032 100644 --- a/pom.xml +++ b/pom.xml @@ -97,15 +97,6 @@ provided - - org.gcube.data.spd - spd-model - 1.0.0-SNAPSHOT - - - provided - - org.gcube.resources.discovery discovery-client diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/cluster/TablesForResultRow.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/cluster/TablesForResultRow.java index a2182d7..7fa904a 100644 --- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/cluster/TablesForResultRow.java +++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/cluster/TablesForResultRow.java @@ -29,7 +29,7 @@ public class TablesForResultRow { String matchingCredits= ""; int occurencesCount = 0; - String author = ""; + String scientificNameAuthorship = ""; String lsid = ""; String credits = ""; @@ -62,7 +62,7 @@ public class TablesForResultRow { } - if(row.getAuthor()!=null) author = row.getAuthor(); + if(row.getScientificNameAuthorship()!=null) scientificNameAuthorship = row.getScientificNameAuthorship(); if(row.getLsid()!=null) lsid = row.getLsid(); @@ -139,8 +139,8 @@ public class TablesForResultRow { " "+lsid+"" + "" + "" + - " "+SpeciesGridFields.AUTHOR.getName()+"" + - " "+author+"" + + " "+SpeciesGridFields.SCIENTIFICNAMEAUTHORSHIP.getName()+"" + + " "+scientificNameAuthorship+"" + "" + "" + " "+SpeciesGridFields.CREDITS.getName()+"" + diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/resultview/SpeciesGrid.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/resultview/SpeciesGrid.java index 8ecf16e..3f9d2b1 100644 --- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/resultview/SpeciesGrid.java +++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/resultview/SpeciesGrid.java @@ -117,7 +117,7 @@ public class SpeciesGrid extends ContentPanel implements SpeciesViewInterface { ColumnConfig matchingName = Util.createColumnConfig(SpeciesGridFields.MATCHING_NAME, 180); columns.add(matchingName); - ColumnConfig author = Util.createColumnConfig(TaxonomyGridField.AUTHOR, 150); + ColumnConfig author = Util.createColumnConfig(TaxonomyGridField.SCIENTIFICNAMEAUTHORSHIP, 150); columns.add(author); ColumnConfig accordingTo = Util.createColumnConfig(SpeciesGridFields.MATCHING_AUTHOR, 200); diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/resultview/TaxonomyGrid.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/resultview/TaxonomyGrid.java index 57ffb87..7c89479 100644 --- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/resultview/TaxonomyGrid.java +++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/resultview/TaxonomyGrid.java @@ -96,7 +96,7 @@ public class TaxonomyGrid extends ContentPanel implements SpeciesViewInterface { ColumnConfig matchingName = Util.createColumnConfig(TaxonomyGridField.SCIENTIFIC_NAME, 180); columns.add(matchingName); - ColumnConfig author = Util.createColumnConfig(TaxonomyGridField.AUTHOR, 150); + ColumnConfig author = Util.createColumnConfig(TaxonomyGridField.SCIENTIFICNAMEAUTHORSHIP, 150); columns.add(author); ColumnConfig dataProvider = Util.createColumnConfig(TaxonomyGridField.DATASOURCE, 250); diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/OccurencesGridFields.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/OccurencesGridFields.java index 81b5e50..fb42766 100644 --- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/OccurencesGridFields.java +++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/OccurencesGridFields.java @@ -18,12 +18,13 @@ public enum OccurencesGridFields implements GridField { DATAPROVIDER("dataProvider", "Data Provider"), DATASET("dataSet","Dataset"), - AUTHOR("author", "Author"), + SCIENTIFICNAMEAUTHORSHIP("scientificNameAuthorship", "S.N. Authorship"), CREDITS("credits", "Credits"), // LSID("lsid", "LSID"), PROPERTIES("properties", "Properties"), - RECORDED_BY("recordedBy", "RecordedBy"), + RECORDED_BY("recordedBy", "Recorded By"), + IDENTIFIED_BY("identifiedBy","Identified By"), EVENT_DATE("eventDate", "EventDate"), MODIFIED("modified", "Modified"), SCIENTIFIC_NAME("scientificName", "ScientificName"), diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/SpeciesGridFields.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/SpeciesGridFields.java index c847ef1..48d040d 100644 --- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/SpeciesGridFields.java +++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/SpeciesGridFields.java @@ -25,7 +25,7 @@ public enum SpeciesGridFields implements GridField { PRODUCT_LAYERS("productLayers", "Layers"), PRODUCT_OCCURRENCES("productOccurrences", "Occurrences"), - AUTHOR("author", "Author"), + SCIENTIFICNAMEAUTHORSHIP("scientificNameAuthorship", "S.N. Authorship"), CREDITS("credits", "Credits"), LSID("lsid", "LSID"), PROPERTIES("properties", "Properties"), diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/TaxonomyGridField.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/TaxonomyGridField.java index ff400a4..f0662b8 100644 --- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/TaxonomyGridField.java +++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/TaxonomyGridField.java @@ -17,7 +17,7 @@ public enum TaxonomyGridField implements GridField { // NAME("name", "Name"), MATCHING_AUTHOR("accordingTo", "According to"), - AUTHOR("author", "Author"), + SCIENTIFICNAMEAUTHORSHIP("scientificNameAuthorship", "S.N. Authorship"), CREDITS("credits", "Credits"), LSID("lsid", "LSID"), PROPERTIES("properties", "Properties"), diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/stream/OccurrencesDataSource.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/stream/OccurrencesDataSource.java index bc501f7..f595ee2 100644 --- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/stream/OccurrencesDataSource.java +++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/stream/OccurrencesDataSource.java @@ -60,13 +60,13 @@ public class OccurrencesDataSource implements DataSource{ { BaseModelData data = new BaseModelData(); - String author = ""; + String authorship = ""; String lsid = ""; String credits = ""; String propertiesHtml = ""; - if(occurrence.getAuthor()!=null) author = occurrence.getAuthor(); + if(occurrence.getScientificNameAuthorship()!=null) authorship = occurrence.getScientificNameAuthorship(); if(occurrence.getLsid()!=null) lsid = occurrence.getLsid(); @@ -101,12 +101,13 @@ public class OccurrencesDataSource implements DataSource{ data.set(OccurencesGridFields.DATASOURCE.getId(), occurrence.getDataSource()); - data.set(OccurencesGridFields.AUTHOR.getId(),author); + data.set(OccurencesGridFields.SCIENTIFICNAMEAUTHORSHIP.getId(),authorship); // data.set(OccurencesGridFields.LSID.getId(), lsid); data.set(OccurencesGridFields.CREDITS.getId(), credits); data.set(OccurencesGridFields.PROPERTIES.getId(), propertiesHtml); data.set(OccurencesGridFields.RECORDED_BY.getId(), occurrence.getRecordedBy()); + data.set(OccurencesGridFields.IDENTIFIED_BY.getId(), occurrence.getIdentifiedBy()); data.set(OccurencesGridFields.EVENT_DATE.getId(), occurrence.getEventDate()); data.set(OccurencesGridFields.MODIFIED.getId(), occurrence.getModified()); data.set(OccurencesGridFields.SCIENTIFIC_NAME.getId(), occurrence.getScientificName()); diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/stream/ResultRowDataSource.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/stream/ResultRowDataSource.java index dfa5d21..8ecf948 100644 --- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/stream/ResultRowDataSource.java +++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/stream/ResultRowDataSource.java @@ -144,7 +144,7 @@ public class ResultRowDataSource implements DataSource { int mapCount= 0; int layerCount = 0; int occurencesCount = 0; - String author = ""; + String authorship = ""; List listProperties = new ArrayList(); @@ -174,7 +174,7 @@ public class ResultRowDataSource implements DataSource { if(row.getMapsCount()!=0) mapCount = row.getMapsCount(); if(row.getLayersCount()!=0) layerCount = row.getLayersCount(); if(row.getOccurencesCount()!=0) occurencesCount = row.getOccurencesCount(); - if(row.getAuthor()!=null) author = row.getAuthor(); + if(row.getScientificNameAuthorship()!=null) authorship = row.getScientificNameAuthorship(); if(row.getProperties()!=null) listProperties = row.getProperties(); @@ -192,7 +192,7 @@ public class ResultRowDataSource implements DataSource { data.set(SpeciesGridFields.MATCHING_CREDITS.getId(),matchingCredits); data.set(SpeciesGridFields.PROPERTIES.getId(),listProperties); - data.set(SpeciesGridFields.AUTHOR.getId(), author); + data.set(SpeciesGridFields.SCIENTIFICNAMEAUTHORSHIP.getId(), authorship); List listCommonName = new ArrayList(); diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/stream/TaxonomyRowDataSource.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/stream/TaxonomyRowDataSource.java index 08edfa3..6a255fb 100644 --- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/stream/TaxonomyRowDataSource.java +++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/util/stream/TaxonomyRowDataSource.java @@ -124,7 +124,7 @@ public class TaxonomyRowDataSource implements DataSource { // if(row.getAccordingTo()!=null) matchingAccordingTo = row.getAccordingTo(); if(row.getStatusRemarks()!=null) statusRemarks = row.getStatusRemarks(); if(row.getProperties()!=null) hashProperties = row.getProperties(); - if(row.getAuthor()!=null) author = row.getAuthor(); + if(row.getScientificNameAuthorship()!=null) author = row.getScientificNameAuthorship(); if(row.getParents()!=null){ classificationString = getClassification(row.getParents()); @@ -141,7 +141,7 @@ public class TaxonomyRowDataSource implements DataSource { data.set(TaxonomyGridField.STATUSREFNAME.getId(), statusRefName); data.set(TaxonomyGridField.STATUSREFID.getId(), statusRedId); data.set(TaxonomyGridField.DATEMODIFIED.getId(), dateModified); - data.set(TaxonomyGridField.AUTHOR.getId(), author); + data.set(TaxonomyGridField.SCIENTIFICNAMEAUTHORSHIP.getId(), author); // data.set(TaxonomyGridField.MATCHING_ACCORDING_TO.getId(),matchingAccordingTo); data.set(TaxonomyGridField.STATUS_REMARKS.getId(),statusRemarks); diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/ResultRowTable.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/ResultRowTable.java index d885e5c..e93e4ae 100644 --- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/ResultRowTable.java +++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/ResultRowTable.java @@ -207,7 +207,7 @@ public class ResultRowTable extends HttpServlet { String matchingCredits= ""; int occurencesCount = 0; - String author = ""; + String scientificNameAuthorship = ""; String lsid = ""; String credits = ""; @@ -240,7 +240,7 @@ public class ResultRowTable extends HttpServlet { } - if(row.getAuthor()!=null) author = row.getAuthor(); + if(row.getScientificNameAuthorship()!=null) scientificNameAuthorship = row.getScientificNameAuthorship(); if(row.getLsid()!=null) lsid = row.getLsid(); @@ -317,8 +317,8 @@ public class ResultRowTable extends HttpServlet { " "+lsid+"" + "" + "" + - " "+SpeciesGridFields.AUTHOR.getName()+"" + - " "+author+"" + + " "+SpeciesGridFields.SCIENTIFICNAMEAUTHORSHIP.getName()+"" + + " "+scientificNameAuthorship+"" + "" + "" + " "+SpeciesGridFields.CREDITS.getName()+"" + diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/TaxonomyRowTable.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/TaxonomyRowTable.java index dec897e..ba50aa8 100644 --- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/TaxonomyRowTable.java +++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/TaxonomyRowTable.java @@ -313,7 +313,7 @@ public class TaxonomyRowTable extends HttpServlet { String dateModified = ""; String statusRemark = ""; - String author = ""; + String scientificNameAuthorship = ""; String lsid = ""; String credits = ""; @@ -329,7 +329,7 @@ public class TaxonomyRowTable extends HttpServlet { if(row.getStatusRemarks()!=null) statusRemark = row.getStatusRemarks(); - if(row.getAuthor()!=null) author = row.getAuthor(); + if(row.getScientificNameAuthorship()!=null) scientificNameAuthorship = row.getScientificNameAuthorship(); if(row.getLsid()!=null) lsid = row.getLsid(); @@ -408,8 +408,8 @@ public class TaxonomyRowTable extends HttpServlet { " "+lsid+"" + "" + "" + - " "+TaxonomyGridField.AUTHOR.getName()+"" + - " "+author+"" + + " "+TaxonomyGridField.SCIENTIFICNAMEAUTHORSHIP.getName()+"" + + " "+scientificNameAuthorship+"" + "" + "" + " "+TaxonomyGridField.CREDITS.getName()+"" + diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/service/OccurrenceConverter.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/service/OccurrenceConverter.java index 655e917..32dcfea 100644 --- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/service/OccurrenceConverter.java +++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/service/OccurrenceConverter.java @@ -54,13 +54,12 @@ public class OccurrenceConverter implements Converter { } //set author - if(input.getAuthor()!=null && !input.getAuthor().isEmpty()){ + if(input.getScientificNameAuthorship()!=null && !input.getScientificNameAuthorship().isEmpty()){ // row.setAuthor(StringEscapeUtils.escapeSql(input.getAuthor())); - row.setAuthor(input.getAuthor()); + row.setScientificNameAuthorship(input.getScientificNameAuthorship()); } else - row.setAuthor(ConstantsSpeciesDiscovery.NOT_FOUND); + row.setScientificNameAuthorship(ConstantsSpeciesDiscovery.NOT_FOUND); //set credits if(input.getCredits()!=null && !input.getCredits().isEmpty()){ diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/service/TaxonomyItemConverter.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/service/TaxonomyItemConverter.java index ec85e5e..456434a 100644 --- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/service/TaxonomyItemConverter.java +++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/service/TaxonomyItemConverter.java @@ -155,11 +155,11 @@ public class TaxonomyItemConverter implements Converter { listMetaData.add(new KeyValue(Occurrence.DATAPROVIDER, NormalizeString.validateUndefined(occrs.getDataProvider()))); listMetaData.add(new KeyValue(Occurrence.DATASET, NormalizeString.validateUndefined(occrs.getDataSet()))); - listMetaData.add(new KeyValue(Occurrence.AUTHOR, NormalizeString.validateUndefined(occrs.getAuthor()))); + listMetaData.add(new KeyValue(Occurrence.SCIENTIFICNAMEAUTHORSHIP, NormalizeString.validateUndefined(occrs.getScientificNameAuthorship()))); listMetaData.add(new KeyValue(Occurrence.LSID, NormalizeString.validateUndefined(occrs.getLsid()))); listMetaData.add(new KeyValue(Occurrence.CREDITS, NormalizeString.validateUndefined(occrs.getCredits()))); diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/stream/OccurenceCSVConverter.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/stream/OccurenceCSVConverter.java index 2b43892..1e6c9d1 100644 --- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/stream/OccurenceCSVConverter.java +++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/stream/OccurenceCSVConverter.java @@ -24,10 +24,11 @@ public class OccurenceCSVConverter implements Converter "dataProvider", "dataSource", - "author", + "scientificNameAuthorship", // "lsid", "credits", + "identifiedBy", "recordedBy", "eventDate", "modified", @@ -56,10 +57,11 @@ public class OccurenceCSVConverter implements Converter fields.add(cleanValue(input.getDataProvider())); fields.add(cleanValue(input.getDataSource())); - fields.add(cleanValue(input.getAuthor())); + fields.add(cleanValue(input.getScientificNameAuthorship())); // fields.add(cleanValue(input.getLsid())); fields.add(cleanValue(input.getCredits())); + fields.add(cleanValue(input.getIdentifiedBy())); fields.add(cleanValue(input.getRecordedBy())); fields.add(cleanValue(input.getEventDate())); fields.add(cleanValue(input.getModified())); diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/Occurrence.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/Occurrence.java index 544318c..60c3483 100644 --- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/Occurrence.java +++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/Occurrence.java @@ -31,6 +31,8 @@ public class Occurrence implements Serializable, FetchingElement { public final static String COLLECTION_CODE = "collectionCode"; public final static String CATALOGUE_NUMBER = "catalogueNumber"; public final static String RECORD_BY = "recordedBy"; + public final static String IDENTIFIED_BY = "identifiedBy"; + public final static String EVENT_DATE = "eventDate"; public final static String MODIFIED = "modified"; public final static String SCIENTIFICNAME = "scientificName"; @@ -54,7 +56,7 @@ public class Occurrence implements Serializable, FetchingElement { public final static String SERVICE_ID_FIELD = "serviceIdField"; - public final static String AUTHOR = "author"; //USED + public final static String SCIENTIFICNAMEAUTHORSHIP = "scientificNameAuthorship"; //USED public final static String CREDITS = "credits"; //USED public final static String LSID = "lsid"; //USED public final static String PROPERTIES = "properties"; //TODO @@ -68,6 +70,7 @@ public class Occurrence implements Serializable, FetchingElement { protected String collectionCode; protected String catalogueNumber; protected String recordedBy; + protected String identifiedBy; protected String eventDate; protected String modified; protected String scientificName; @@ -86,7 +89,7 @@ public class Occurrence implements Serializable, FetchingElement { protected String dataProvider; protected String dataSet; protected String dataSource; - protected String author; + protected String scientificNameAuthorship; protected String credits; protected String lsid; @@ -399,14 +402,6 @@ public class Occurrence implements Serializable, FetchingElement { return dataProvider; } - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - public String getCredits() { return credits; } @@ -436,6 +431,23 @@ public class Occurrence implements Serializable, FetchingElement { this.properties = properties; } + public String getScientificNameAuthorship() { + return scientificNameAuthorship; + } + + public void setScientificNameAuthorship(String scientificNameAuthorship) { + this.scientificNameAuthorship = scientificNameAuthorship; + } + + + public String getIdentifiedBy() { + return identifiedBy; + } + + public void setIdentifiedBy(String identifiedBy) { + this.identifiedBy = identifiedBy; + } + @Override public String toString() { StringBuilder builder = new StringBuilder(); @@ -449,6 +461,8 @@ public class Occurrence implements Serializable, FetchingElement { builder.append(catalogueNumber); builder.append(", recordedBy="); builder.append(recordedBy); + builder.append(", identifiedBy="); + builder.append(identifiedBy); builder.append(", eventDate="); builder.append(eventDate); builder.append(", modified="); @@ -485,8 +499,8 @@ public class Occurrence implements Serializable, FetchingElement { builder.append(dataSet); builder.append(", dataSource="); builder.append(dataSource); - builder.append(", author="); - builder.append(author); + builder.append(", scientificNameAuthorship="); + builder.append(scientificNameAuthorship); builder.append(", credits="); builder.append(credits); builder.append(", lsid="); @@ -497,7 +511,6 @@ public class Occurrence implements Serializable, FetchingElement { builder.append(existsProperties); builder.append("]"); return builder.toString(); - } - + } } diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/ResultRow.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/ResultRow.java index 3dbb9cb..bafad19 100644 --- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/ResultRow.java +++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/ResultRow.java @@ -57,7 +57,7 @@ public class ResultRow implements FetchingElement, SelectableElement, Serializab public static final String GENUS_ID = "genusID"; public static final String SPECIES_ID = "speciesID"; - public final static String AUTHOR = "author"; //USED + public final static String SCIENTIFICNAMEAUTHORSHIP = "scientificNameAuthorship"; //USED public final static String CREDITS = "credits"; //USED public final static String LSID = "lsid"; //USED public final static String PROPERTIES = "properties"; //USED @@ -105,7 +105,7 @@ public class ResultRow implements FetchingElement, SelectableElement, Serializab protected String familyID; protected String genusID; protected String speciesID; - protected String author; + protected String scientificNameAuthorship; protected String credits; protected String lsid; // protected String propertiesAsXml; @@ -496,14 +496,6 @@ public class ResultRow implements FetchingElement, SelectableElement, Serializab } - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - public String getCredits() { return credits; } @@ -567,7 +559,18 @@ public class ResultRow implements FetchingElement, SelectableElement, Serializab public void setProperties(List properties) { this.properties = properties; } - + + + public String getScientificNameAuthorship() { + return scientificNameAuthorship; + } + + + public void setScientificNameAuthorship(String scientificNameAuthorship) { + this.scientificNameAuthorship = scientificNameAuthorship; + } + + @Override public String toString() { StringBuilder builder = new StringBuilder(); @@ -633,8 +636,8 @@ public class ResultRow implements FetchingElement, SelectableElement, Serializab builder.append(genusID); builder.append(", speciesID="); builder.append(speciesID); - builder.append(", author="); - builder.append(author); + builder.append(", scientificNameAuthorship="); + builder.append(scientificNameAuthorship); builder.append(", credits="); builder.append(credits); builder.append(", lsid="); @@ -646,5 +649,4 @@ public class ResultRow implements FetchingElement, SelectableElement, Serializab } - } diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/TaxonomyRow.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/TaxonomyRow.java index 9149f03..70a1344 100644 --- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/TaxonomyRow.java +++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/TaxonomyRow.java @@ -45,7 +45,7 @@ public class TaxonomyRow implements FetchingElement, Serializable, TaxonomyInter public final static String SERVICE_ID_FIELD = "serviceIdField"; public final static String STATUS_REMARKS = "statusRemarks"; - public final static String AUTHOR = "author"; //USED + public final static String SCIENTIFICNAMEAUTHORSHIP = "scientificNameAuthorship"; //USED public final static String CREDITS = "credits"; //USED public final static String LSID = "lsid"; //USED public final static String PROPERTIES = "properties"; //TODO @@ -64,7 +64,7 @@ public class TaxonomyRow implements FetchingElement, Serializable, TaxonomyInter @Id @GeneratedValue(strategy = GenerationType.IDENTITY) protected int id; - protected String author; + protected String scientificNameAuthorship; protected String credits; protected String lsid; @@ -377,15 +377,6 @@ public class TaxonomyRow implements FetchingElement, Serializable, TaxonomyInter this.statusRemarks = statusRemarks; } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - public String getCredits() { return credits; } @@ -434,13 +425,31 @@ public class TaxonomyRow implements FetchingElement, Serializable, TaxonomyInter this.parentIndex = parentIndex; } + + /* (non-Javadoc) + * Comparable on insertion order + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + @Override + public int compareTo(TaxonomyRow o) { + return parentIndex - o.getParentIndex(); + } + + public String getScientificNameAuthorship() { + return scientificNameAuthorship; + } + + public void setScientificNameAuthorship(String scientificNameAuthorship) { + this.scientificNameAuthorship = scientificNameAuthorship; + } + @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("TaxonomyRow [id="); builder.append(id); - builder.append(", author="); - builder.append(author); + builder.append(", scientificNameAuthorship="); + builder.append(scientificNameAuthorship); builder.append(", credits="); builder.append(credits); builder.append(", lsid="); @@ -504,13 +513,5 @@ public class TaxonomyRow implements FetchingElement, Serializable, TaxonomyInter builder.append("]"); return builder.toString(); } - - /* (non-Javadoc) - * Comparable on insertion order - * @see java.lang.Comparable#compareTo(java.lang.Object) - */ - @Override - public int compareTo(TaxonomyRow o) { - return parentIndex - o.getParentIndex(); - } + } diff --git a/src/test/java/org/gcube/portlets/user/speciesdiscovery/client/ServiceQuery.java b/src/test/java/org/gcube/portlets/user/speciesdiscovery/client/ServiceQuery.java index 8bbf97d..994bd0e 100644 --- a/src/test/java/org/gcube/portlets/user/speciesdiscovery/client/ServiceQuery.java +++ b/src/test/java/org/gcube/portlets/user/speciesdiscovery/client/ServiceQuery.java @@ -7,13 +7,22 @@ import static org.gcube.data.spd.client.plugins.AbstractPlugin.manager; import java.util.concurrent.TimeUnit; +import org.gcube.application.framework.core.session.ASLSession; +import org.gcube.application.framework.core.session.SessionManager; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.data.spd.client.proxies.Manager; import org.gcube.data.spd.model.exceptions.InvalidQueryException; import org.gcube.data.spd.model.products.ResultElement; +import org.gcube.data.spd.model.products.ResultItem; import org.gcube.data.spd.stubs.exceptions.UnsupportedCapabilityException; import org.gcube.data.spd.stubs.exceptions.UnsupportedPluginException; import org.gcube.data.streams.Stream; +import org.gcube.portlets.user.speciesdiscovery.server.service.ResultItemConverter; +import org.gcube.portlets.user.speciesdiscovery.server.service.StreamIterator; +import org.gcube.portlets.user.speciesdiscovery.server.stream.CastConverter; +import org.gcube.portlets.user.speciesdiscovery.server.stream.CloseableIterator; +import org.gcube.portlets.user.speciesdiscovery.server.stream.ConversionIterator; +import org.gcube.portlets.user.speciesdiscovery.shared.ResultRow; /** * @author "Federico De Faveri defaveri@isti.cnr.it" @@ -27,11 +36,15 @@ public class ServiceQuery { * @throws InvalidQueryException * @throws UnsupportedCapabilityException */ + + private static String username = "test.user"; + public static void main(String[] args) throws InvalidQueryException, UnsupportedPluginException, UnsupportedCapabilityException { String scope = "/gcube/devsec"; // String scope = "/d4science.research-infrastructures.eu/gCubeApps/BiodiversityResearchEnvironment"; //Production ScopeProvider.instance.set(scope); + ASLSession session = SessionManager.getInstance().getASLSession("123", username); Manager call = manager().withTimeout(3, TimeUnit.MINUTES).build(); @@ -45,17 +58,45 @@ public class ServiceQuery { System.out.println("start query..."); - Stream results = call.search("SEARCH BY SN 'sarda sarda' RETURN Product"); + Stream results = call.search("SEARCH BY SN 'Latimeria chalumnae' IN GBIF RETURN Product HAVING xpath(\"//product[type='Occurrence' and count>0]\")"); +// Stream results = call.search("SEARCH BY SN 'Palinurus elephas' IN WoRMS RETURN Taxon"); + + StreamIterator input = new StreamIterator(results); + + + System.out.println("Results from service..."); int i=0; - if (results.hasNext()) { + while(results.hasNext()) { ResultElement elem = results.next(); - System.out.println(++i +") el: "+elem.getId()); - + System.out.println(++i +") el: "+elem.getId() +" type: "+elem.getType().name()); } + + System.out.println("Results from conversion..."); + ConversionIterator caster = buildCaster(input); + + //from ResultItem to ResultRow + ResultItemConverter converter = new ResultItemConverter(session); + ConversionIterator inputConverter = new ConversionIterator(caster, converter); + + while (inputConverter.hasNext()) { + ResultRow row = inputConverter.next(); + + System.out.println(++i +") row: "+row); + + } + + results.close(); System.out.println("DONE"); } + + protected static ConversionIterator buildCaster(CloseableIterator input) + { + CastConverter elementConverter = new CastConverter(); + ConversionIterator caster = new ConversionIterator(input, elementConverter); + return caster; + } }