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
This commit is contained in:
Francesco Mangiacrapa 2013-11-26 14:28:22 +00:00
parent c51f6ef716
commit b40c5c4b3a
21 changed files with 160 additions and 102 deletions

View File

@ -97,15 +97,6 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.gcube.data.spd</groupId>
<artifactId>spd-model</artifactId>
<version>1.0.0-SNAPSHOT</version>
<!-- UNCOMMENT THIS FOR RELEASE -->
<!-- <version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version> -->
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>org.gcube.resources.discovery</groupId> <groupId>org.gcube.resources.discovery</groupId>
<artifactId>discovery-client</artifactId> <artifactId>discovery-client</artifactId>

View File

@ -29,7 +29,7 @@ public class TablesForResultRow {
String matchingCredits= ""; String matchingCredits= "";
int occurencesCount = 0; int occurencesCount = 0;
String author = ""; String scientificNameAuthorship = "";
String lsid = ""; String lsid = "";
String credits = ""; 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(); if(row.getLsid()!=null) lsid = row.getLsid();
@ -139,8 +139,8 @@ public class TablesForResultRow {
" <td>"+lsid+"</td>" + " <td>"+lsid+"</td>" +
"</tr>" + "</tr>" +
"<tr>" + "<tr>" +
" <td class=\"title\">"+SpeciesGridFields.AUTHOR.getName()+"</td>" + " <td class=\"title\">"+SpeciesGridFields.SCIENTIFICNAMEAUTHORSHIP.getName()+"</td>" +
" <td>"+author+"</td>" + " <td>"+scientificNameAuthorship+"</td>" +
"</tr>" + "</tr>" +
"<tr>" + "<tr>" +
" <td class=\"title\">"+SpeciesGridFields.CREDITS.getName()+"</td>" + " <td class=\"title\">"+SpeciesGridFields.CREDITS.getName()+"</td>" +

View File

@ -117,7 +117,7 @@ public class SpeciesGrid extends ContentPanel implements SpeciesViewInterface {
ColumnConfig matchingName = Util.createColumnConfig(SpeciesGridFields.MATCHING_NAME, 180); ColumnConfig matchingName = Util.createColumnConfig(SpeciesGridFields.MATCHING_NAME, 180);
columns.add(matchingName); columns.add(matchingName);
ColumnConfig author = Util.createColumnConfig(TaxonomyGridField.AUTHOR, 150); ColumnConfig author = Util.createColumnConfig(TaxonomyGridField.SCIENTIFICNAMEAUTHORSHIP, 150);
columns.add(author); columns.add(author);
ColumnConfig accordingTo = Util.createColumnConfig(SpeciesGridFields.MATCHING_AUTHOR, 200); ColumnConfig accordingTo = Util.createColumnConfig(SpeciesGridFields.MATCHING_AUTHOR, 200);

View File

@ -96,7 +96,7 @@ public class TaxonomyGrid extends ContentPanel implements SpeciesViewInterface {
ColumnConfig matchingName = Util.createColumnConfig(TaxonomyGridField.SCIENTIFIC_NAME, 180); ColumnConfig matchingName = Util.createColumnConfig(TaxonomyGridField.SCIENTIFIC_NAME, 180);
columns.add(matchingName); columns.add(matchingName);
ColumnConfig author = Util.createColumnConfig(TaxonomyGridField.AUTHOR, 150); ColumnConfig author = Util.createColumnConfig(TaxonomyGridField.SCIENTIFICNAMEAUTHORSHIP, 150);
columns.add(author); columns.add(author);
ColumnConfig dataProvider = Util.createColumnConfig(TaxonomyGridField.DATASOURCE, 250); ColumnConfig dataProvider = Util.createColumnConfig(TaxonomyGridField.DATASOURCE, 250);

View File

@ -18,12 +18,13 @@ public enum OccurencesGridFields implements GridField {
DATAPROVIDER("dataProvider", "Data Provider"), DATAPROVIDER("dataProvider", "Data Provider"),
DATASET("dataSet","Dataset"), DATASET("dataSet","Dataset"),
AUTHOR("author", "Author"), SCIENTIFICNAMEAUTHORSHIP("scientificNameAuthorship", "S.N. Authorship"),
CREDITS("credits", "Credits"), CREDITS("credits", "Credits"),
// LSID("lsid", "LSID"), // LSID("lsid", "LSID"),
PROPERTIES("properties", "Properties"), PROPERTIES("properties", "Properties"),
RECORDED_BY("recordedBy", "RecordedBy"), RECORDED_BY("recordedBy", "Recorded By"),
IDENTIFIED_BY("identifiedBy","Identified By"),
EVENT_DATE("eventDate", "EventDate"), EVENT_DATE("eventDate", "EventDate"),
MODIFIED("modified", "Modified"), MODIFIED("modified", "Modified"),
SCIENTIFIC_NAME("scientificName", "ScientificName"), SCIENTIFIC_NAME("scientificName", "ScientificName"),

View File

@ -25,7 +25,7 @@ public enum SpeciesGridFields implements GridField {
PRODUCT_LAYERS("productLayers", "Layers"), PRODUCT_LAYERS("productLayers", "Layers"),
PRODUCT_OCCURRENCES("productOccurrences", "Occurrences"), PRODUCT_OCCURRENCES("productOccurrences", "Occurrences"),
AUTHOR("author", "Author"), SCIENTIFICNAMEAUTHORSHIP("scientificNameAuthorship", "S.N. Authorship"),
CREDITS("credits", "Credits"), CREDITS("credits", "Credits"),
LSID("lsid", "LSID"), LSID("lsid", "LSID"),
PROPERTIES("properties", "Properties"), PROPERTIES("properties", "Properties"),

View File

@ -17,7 +17,7 @@ public enum TaxonomyGridField implements GridField {
// NAME("name", "Name"), // NAME("name", "Name"),
MATCHING_AUTHOR("accordingTo", "According to"), MATCHING_AUTHOR("accordingTo", "According to"),
AUTHOR("author", "Author"), SCIENTIFICNAMEAUTHORSHIP("scientificNameAuthorship", "S.N. Authorship"),
CREDITS("credits", "Credits"), CREDITS("credits", "Credits"),
LSID("lsid", "LSID"), LSID("lsid", "LSID"),
PROPERTIES("properties", "Properties"), PROPERTIES("properties", "Properties"),

View File

@ -60,13 +60,13 @@ public class OccurrencesDataSource implements DataSource{
{ {
BaseModelData data = new BaseModelData(); BaseModelData data = new BaseModelData();
String author = ""; String authorship = "";
String lsid = ""; String lsid = "";
String credits = ""; String credits = "";
String propertiesHtml = ""; String propertiesHtml = "";
if(occurrence.getAuthor()!=null) author = occurrence.getAuthor(); if(occurrence.getScientificNameAuthorship()!=null) authorship = occurrence.getScientificNameAuthorship();
if(occurrence.getLsid()!=null) lsid = occurrence.getLsid(); 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.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.LSID.getId(), lsid);
data.set(OccurencesGridFields.CREDITS.getId(), credits); data.set(OccurencesGridFields.CREDITS.getId(), credits);
data.set(OccurencesGridFields.PROPERTIES.getId(), propertiesHtml); data.set(OccurencesGridFields.PROPERTIES.getId(), propertiesHtml);
data.set(OccurencesGridFields.RECORDED_BY.getId(), occurrence.getRecordedBy()); 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.EVENT_DATE.getId(), occurrence.getEventDate());
data.set(OccurencesGridFields.MODIFIED.getId(), occurrence.getModified()); data.set(OccurencesGridFields.MODIFIED.getId(), occurrence.getModified());
data.set(OccurencesGridFields.SCIENTIFIC_NAME.getId(), occurrence.getScientificName()); data.set(OccurencesGridFields.SCIENTIFIC_NAME.getId(), occurrence.getScientificName());

View File

@ -144,7 +144,7 @@ public class ResultRowDataSource implements DataSource {
int mapCount= 0; int mapCount= 0;
int layerCount = 0; int layerCount = 0;
int occurencesCount = 0; int occurencesCount = 0;
String author = ""; String authorship = "";
List<ItemParameter> listProperties = new ArrayList<ItemParameter>(); List<ItemParameter> listProperties = new ArrayList<ItemParameter>();
@ -174,7 +174,7 @@ public class ResultRowDataSource implements DataSource {
if(row.getMapsCount()!=0) mapCount = row.getMapsCount(); if(row.getMapsCount()!=0) mapCount = row.getMapsCount();
if(row.getLayersCount()!=0) layerCount = row.getLayersCount(); if(row.getLayersCount()!=0) layerCount = row.getLayersCount();
if(row.getOccurencesCount()!=0) occurencesCount = row.getOccurencesCount(); 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(); 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.MATCHING_CREDITS.getId(),matchingCredits);
data.set(SpeciesGridFields.PROPERTIES.getId(),listProperties); data.set(SpeciesGridFields.PROPERTIES.getId(),listProperties);
data.set(SpeciesGridFields.AUTHOR.getId(), author); data.set(SpeciesGridFields.SCIENTIFICNAMEAUTHORSHIP.getId(), authorship);
List<CommonName> listCommonName = new ArrayList<CommonName>(); List<CommonName> listCommonName = new ArrayList<CommonName>();

View File

@ -124,7 +124,7 @@ public class TaxonomyRowDataSource implements DataSource {
// if(row.getAccordingTo()!=null) matchingAccordingTo = row.getAccordingTo(); // if(row.getAccordingTo()!=null) matchingAccordingTo = row.getAccordingTo();
if(row.getStatusRemarks()!=null) statusRemarks = row.getStatusRemarks(); if(row.getStatusRemarks()!=null) statusRemarks = row.getStatusRemarks();
if(row.getProperties()!=null) hashProperties = row.getProperties(); 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){ if(row.getParents()!=null){
classificationString = getClassification(row.getParents()); classificationString = getClassification(row.getParents());
@ -141,7 +141,7 @@ public class TaxonomyRowDataSource implements DataSource {
data.set(TaxonomyGridField.STATUSREFNAME.getId(), statusRefName); data.set(TaxonomyGridField.STATUSREFNAME.getId(), statusRefName);
data.set(TaxonomyGridField.STATUSREFID.getId(), statusRedId); data.set(TaxonomyGridField.STATUSREFID.getId(), statusRedId);
data.set(TaxonomyGridField.DATEMODIFIED.getId(), dateModified); 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.MATCHING_ACCORDING_TO.getId(),matchingAccordingTo);
data.set(TaxonomyGridField.STATUS_REMARKS.getId(),statusRemarks); data.set(TaxonomyGridField.STATUS_REMARKS.getId(),statusRemarks);

View File

@ -207,7 +207,7 @@ public class ResultRowTable extends HttpServlet {
String matchingCredits= ""; String matchingCredits= "";
int occurencesCount = 0; int occurencesCount = 0;
String author = ""; String scientificNameAuthorship = "";
String lsid = ""; String lsid = "";
String credits = ""; 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(); if(row.getLsid()!=null) lsid = row.getLsid();
@ -317,8 +317,8 @@ public class ResultRowTable extends HttpServlet {
" <td>"+lsid+"</td>" + " <td>"+lsid+"</td>" +
"</tr>" + "</tr>" +
"<tr>" + "<tr>" +
" <td class=\"title\">"+SpeciesGridFields.AUTHOR.getName()+"</td>" + " <td class=\"title\">"+SpeciesGridFields.SCIENTIFICNAMEAUTHORSHIP.getName()+"</td>" +
" <td>"+author+"</td>" + " <td>"+scientificNameAuthorship+"</td>" +
"</tr>" + "</tr>" +
"<tr>" + "<tr>" +
" <td class=\"title\">"+SpeciesGridFields.CREDITS.getName()+"</td>" + " <td class=\"title\">"+SpeciesGridFields.CREDITS.getName()+"</td>" +

View File

@ -313,7 +313,7 @@ public class TaxonomyRowTable extends HttpServlet {
String dateModified = ""; String dateModified = "";
String statusRemark = ""; String statusRemark = "";
String author = ""; String scientificNameAuthorship = "";
String lsid = ""; String lsid = "";
String credits = ""; String credits = "";
@ -329,7 +329,7 @@ public class TaxonomyRowTable extends HttpServlet {
if(row.getStatusRemarks()!=null) statusRemark = row.getStatusRemarks(); 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(); if(row.getLsid()!=null) lsid = row.getLsid();
@ -408,8 +408,8 @@ public class TaxonomyRowTable extends HttpServlet {
" <td>"+lsid+"</td>" + " <td>"+lsid+"</td>" +
"</tr>" + "</tr>" +
"<tr>" + "<tr>" +
" <td class=\"title\">"+TaxonomyGridField.AUTHOR.getName()+"</td>" + " <td class=\"title\">"+TaxonomyGridField.SCIENTIFICNAMEAUTHORSHIP.getName()+"</td>" +
" <td>"+author+"</td>" + " <td>"+scientificNameAuthorship+"</td>" +
"</tr>" + "</tr>" +
"<tr>" + "<tr>" +
" <td class=\"title\">"+TaxonomyGridField.CREDITS.getName()+"</td>" + " <td class=\"title\">"+TaxonomyGridField.CREDITS.getName()+"</td>" +

View File

@ -54,13 +54,12 @@ public class OccurrenceConverter implements Converter<OccurrencePoint, org.gcube
} }
//set author //set author
if(input.getAuthor()!=null && !input.getAuthor().isEmpty()){ if(input.getScientificNameAuthorship()!=null && !input.getScientificNameAuthorship().isEmpty()){
occurrence.setAuthor(StringEscapeUtils.escapeSql(input.getAuthor())); occurrence.setScientificNameAuthorship(StringEscapeUtils.escapeSql(input.getScientificNameAuthorship()));
} }
else else
occurrence.setAuthor(ConstantsSpeciesDiscovery.NOT_FOUND); occurrence.setScientificNameAuthorship(ConstantsSpeciesDiscovery.NOT_FOUND);
//set credits //set credits
if(input.getCredits()!=null && !input.getCredits().isEmpty()){ if(input.getCredits()!=null && !input.getCredits().isEmpty()){
@ -70,6 +69,13 @@ public class OccurrenceConverter implements Converter<OccurrencePoint, org.gcube
occurrence.setCredits(ConstantsSpeciesDiscovery.NOT_FOUND); occurrence.setCredits(ConstantsSpeciesDiscovery.NOT_FOUND);
//set credits
if(input.getIdentifiedBy()!=null && !input.getIdentifiedBy().isEmpty()){
occurrence.setIdentifiedBy(StringEscapeUtils.escapeSql(input.getIdentifiedBy()));
}
else
occurrence.setIdentifiedBy(ConstantsSpeciesDiscovery.NOT_FOUND);
if(input.getDataSet()!=null){ if(input.getDataSet()!=null){
occurrence.setDataSet(cleanValueEscapeSql(input.getDataSet().getName())); occurrence.setDataSet(cleanValueEscapeSql(input.getDataSet().getName()));

View File

@ -58,12 +58,12 @@ public class ResultItemConverter implements Converter<ResultItem, ResultRow> {
} }
//set author //set author
if(input.getAuthor()!=null && !input.getAuthor().isEmpty()){ if(input.getScientificNameAuthorship()!=null && !input.getScientificNameAuthorship().isEmpty()){
// row.setAuthor(StringEscapeUtils.escapeSql(input.getAuthor())); // row.setAuthor(StringEscapeUtils.escapeSql(input.getAuthor()));
row.setAuthor(input.getAuthor()); row.setScientificNameAuthorship(input.getScientificNameAuthorship());
} }
else else
row.setAuthor(ConstantsSpeciesDiscovery.NOT_FOUND); row.setScientificNameAuthorship(ConstantsSpeciesDiscovery.NOT_FOUND);
//set credits //set credits
if(input.getCredits()!=null && !input.getCredits().isEmpty()){ if(input.getCredits()!=null && !input.getCredits().isEmpty()){

View File

@ -155,11 +155,11 @@ public class TaxonomyItemConverter implements Converter<TaxonomyItem, TaxonomyRo
tax.setServiceId(input.getId()); tax.setServiceId(input.getId());
} }
if(input.getAuthor()!=null && !input.getAuthor().isEmpty()){ if(input.getScientificNameAuthorship()!=null && !input.getScientificNameAuthorship().isEmpty()){
tax.setAuthor(input.getAuthor()); tax.setScientificNameAuthorship(input.getScientificNameAuthorship());
} }
else else
tax.setAuthor(ConstantsSpeciesDiscovery.NOT_FOUND); tax.setScientificNameAuthorship(ConstantsSpeciesDiscovery.NOT_FOUND);
if(input.getCredits()!=null && !input.getCredits().isEmpty()){ if(input.getCredits()!=null && !input.getCredits().isEmpty()){
tax.setCredits(input.getCredits()); tax.setCredits(input.getCredits());

View File

@ -68,7 +68,7 @@ public class IteratorPointInfo implements Stream<PointInfo> {
listMetaData.add(new KeyValue(Occurrence.DATAPROVIDER, NormalizeString.validateUndefined(occrs.getDataProvider()))); 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.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.LSID, NormalizeString.validateUndefined(occrs.getLsid())));
listMetaData.add(new KeyValue(Occurrence.CREDITS, NormalizeString.validateUndefined(occrs.getCredits()))); listMetaData.add(new KeyValue(Occurrence.CREDITS, NormalizeString.validateUndefined(occrs.getCredits())));

View File

@ -24,10 +24,11 @@ public class OccurenceCSVConverter implements Converter<Occurrence, List<String>
"dataProvider", "dataProvider",
"dataSource", "dataSource",
"author", "scientificNameAuthorship",
// "lsid", // "lsid",
"credits", "credits",
"identifiedBy",
"recordedBy", "recordedBy",
"eventDate", "eventDate",
"modified", "modified",
@ -56,10 +57,11 @@ public class OccurenceCSVConverter implements Converter<Occurrence, List<String>
fields.add(cleanValue(input.getDataProvider())); fields.add(cleanValue(input.getDataProvider()));
fields.add(cleanValue(input.getDataSource())); fields.add(cleanValue(input.getDataSource()));
fields.add(cleanValue(input.getAuthor())); fields.add(cleanValue(input.getScientificNameAuthorship()));
// fields.add(cleanValue(input.getLsid())); // fields.add(cleanValue(input.getLsid()));
fields.add(cleanValue(input.getCredits())); fields.add(cleanValue(input.getCredits()));
fields.add(cleanValue(input.getIdentifiedBy()));
fields.add(cleanValue(input.getRecordedBy())); fields.add(cleanValue(input.getRecordedBy()));
fields.add(cleanValue(input.getEventDate())); fields.add(cleanValue(input.getEventDate()));
fields.add(cleanValue(input.getModified())); fields.add(cleanValue(input.getModified()));

View File

@ -31,6 +31,8 @@ public class Occurrence implements Serializable, FetchingElement {
public final static String COLLECTION_CODE = "collectionCode"; public final static String COLLECTION_CODE = "collectionCode";
public final static String CATALOGUE_NUMBER = "catalogueNumber"; public final static String CATALOGUE_NUMBER = "catalogueNumber";
public final static String RECORD_BY = "recordedBy"; 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 EVENT_DATE = "eventDate";
public final static String MODIFIED = "modified"; public final static String MODIFIED = "modified";
public final static String SCIENTIFICNAME = "scientificName"; 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 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 CREDITS = "credits"; //USED
public final static String LSID = "lsid"; //USED public final static String LSID = "lsid"; //USED
public final static String PROPERTIES = "properties"; //TODO public final static String PROPERTIES = "properties"; //TODO
@ -68,6 +70,7 @@ public class Occurrence implements Serializable, FetchingElement {
protected String collectionCode; protected String collectionCode;
protected String catalogueNumber; protected String catalogueNumber;
protected String recordedBy; protected String recordedBy;
protected String identifiedBy;
protected String eventDate; protected String eventDate;
protected String modified; protected String modified;
protected String scientificName; protected String scientificName;
@ -86,7 +89,7 @@ public class Occurrence implements Serializable, FetchingElement {
protected String dataProvider; protected String dataProvider;
protected String dataSet; protected String dataSet;
protected String dataSource; protected String dataSource;
protected String author; protected String scientificNameAuthorship;
protected String credits; protected String credits;
protected String lsid; protected String lsid;
@ -399,14 +402,6 @@ public class Occurrence implements Serializable, FetchingElement {
return dataProvider; return dataProvider;
} }
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getCredits() { public String getCredits() {
return credits; return credits;
} }
@ -436,6 +431,23 @@ public class Occurrence implements Serializable, FetchingElement {
this.properties = properties; 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 @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
@ -449,6 +461,8 @@ public class Occurrence implements Serializable, FetchingElement {
builder.append(catalogueNumber); builder.append(catalogueNumber);
builder.append(", recordedBy="); builder.append(", recordedBy=");
builder.append(recordedBy); builder.append(recordedBy);
builder.append(", identifiedBy=");
builder.append(identifiedBy);
builder.append(", eventDate="); builder.append(", eventDate=");
builder.append(eventDate); builder.append(eventDate);
builder.append(", modified="); builder.append(", modified=");
@ -485,8 +499,8 @@ public class Occurrence implements Serializable, FetchingElement {
builder.append(dataSet); builder.append(dataSet);
builder.append(", dataSource="); builder.append(", dataSource=");
builder.append(dataSource); builder.append(dataSource);
builder.append(", author="); builder.append(", scientificNameAuthorship=");
builder.append(author); builder.append(scientificNameAuthorship);
builder.append(", credits="); builder.append(", credits=");
builder.append(credits); builder.append(credits);
builder.append(", lsid="); builder.append(", lsid=");
@ -497,7 +511,6 @@ public class Occurrence implements Serializable, FetchingElement {
builder.append(existsProperties); builder.append(existsProperties);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }
} }

View File

@ -57,7 +57,7 @@ public class ResultRow implements FetchingElement, SelectableElement, Serializab
public static final String GENUS_ID = "genusID"; public static final String GENUS_ID = "genusID";
public static final String SPECIES_ID = "speciesID"; 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 CREDITS = "credits"; //USED
public final static String LSID = "lsid"; //USED public final static String LSID = "lsid"; //USED
public final static String PROPERTIES = "properties"; //USED public final static String PROPERTIES = "properties"; //USED
@ -105,7 +105,7 @@ public class ResultRow implements FetchingElement, SelectableElement, Serializab
protected String familyID; protected String familyID;
protected String genusID; protected String genusID;
protected String speciesID; protected String speciesID;
protected String author; protected String scientificNameAuthorship;
protected String credits; protected String credits;
protected String lsid; protected String lsid;
// protected String propertiesAsXml; // 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() { public String getCredits() {
return credits; return credits;
} }
@ -567,7 +559,18 @@ public class ResultRow implements FetchingElement, SelectableElement, Serializab
public void setProperties(List<ItemParameter> properties) { public void setProperties(List<ItemParameter> properties) {
this.properties = properties; this.properties = properties;
} }
public String getScientificNameAuthorship() {
return scientificNameAuthorship;
}
public void setScientificNameAuthorship(String scientificNameAuthorship) {
this.scientificNameAuthorship = scientificNameAuthorship;
}
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
@ -633,8 +636,8 @@ public class ResultRow implements FetchingElement, SelectableElement, Serializab
builder.append(genusID); builder.append(genusID);
builder.append(", speciesID="); builder.append(", speciesID=");
builder.append(speciesID); builder.append(speciesID);
builder.append(", author="); builder.append(", scientificNameAuthorship=");
builder.append(author); builder.append(scientificNameAuthorship);
builder.append(", credits="); builder.append(", credits=");
builder.append(credits); builder.append(credits);
builder.append(", lsid="); builder.append(", lsid=");
@ -646,5 +649,4 @@ public class ResultRow implements FetchingElement, SelectableElement, Serializab
} }
} }

View File

@ -45,7 +45,7 @@ public class TaxonomyRow implements FetchingElement, Serializable, TaxonomyInter
public final static String SERVICE_ID_FIELD = "serviceIdField"; public final static String SERVICE_ID_FIELD = "serviceIdField";
public final static String STATUS_REMARKS = "statusRemarks"; 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 CREDITS = "credits"; //USED
public final static String LSID = "lsid"; //USED public final static String LSID = "lsid"; //USED
public final static String PROPERTIES = "properties"; //TODO public final static String PROPERTIES = "properties"; //TODO
@ -64,7 +64,7 @@ public class TaxonomyRow implements FetchingElement, Serializable, TaxonomyInter
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
protected int id; protected int id;
protected String author; protected String scientificNameAuthorship;
protected String credits; protected String credits;
protected String lsid; protected String lsid;
@ -377,15 +377,6 @@ public class TaxonomyRow implements FetchingElement, Serializable, TaxonomyInter
this.statusRemarks = statusRemarks; this.statusRemarks = statusRemarks;
} }
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getCredits() { public String getCredits() {
return credits; return credits;
} }
@ -434,13 +425,31 @@ public class TaxonomyRow implements FetchingElement, Serializable, TaxonomyInter
this.parentIndex = parentIndex; 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 @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("TaxonomyRow [id="); builder.append("TaxonomyRow [id=");
builder.append(id); builder.append(id);
builder.append(", author="); builder.append(", scientificNameAuthorship=");
builder.append(author); builder.append(scientificNameAuthorship);
builder.append(", credits="); builder.append(", credits=");
builder.append(credits); builder.append(credits);
builder.append(", lsid="); builder.append(", lsid=");
@ -504,13 +513,5 @@ public class TaxonomyRow implements FetchingElement, Serializable, TaxonomyInter
builder.append("]"); builder.append("]");
return builder.toString(); 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();
}
} }

View File

@ -7,13 +7,22 @@ import static org.gcube.data.spd.client.plugins.AbstractPlugin.manager;
import java.util.concurrent.TimeUnit; 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.common.scope.api.ScopeProvider;
import org.gcube.data.spd.client.proxies.Manager; import org.gcube.data.spd.client.proxies.Manager;
import org.gcube.data.spd.model.exceptions.InvalidQueryException; import org.gcube.data.spd.model.exceptions.InvalidQueryException;
import org.gcube.data.spd.model.products.ResultElement; 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.UnsupportedCapabilityException;
import org.gcube.data.spd.stubs.exceptions.UnsupportedPluginException; import org.gcube.data.spd.stubs.exceptions.UnsupportedPluginException;
import org.gcube.data.streams.Stream; 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" * @author "Federico De Faveri defaveri@isti.cnr.it"
@ -27,11 +36,15 @@ public class ServiceQuery {
* @throws InvalidQueryException * @throws InvalidQueryException
* @throws UnsupportedCapabilityException * @throws UnsupportedCapabilityException
*/ */
private static String username = "test.user";
public static void main(String[] args) throws InvalidQueryException, UnsupportedPluginException, UnsupportedCapabilityException { public static void main(String[] args) throws InvalidQueryException, UnsupportedPluginException, UnsupportedCapabilityException {
String scope = "/gcube/devsec"; String scope = "/gcube/devsec";
// String scope = "/d4science.research-infrastructures.eu/gCubeApps/BiodiversityResearchEnvironment"; //Production // String scope = "/d4science.research-infrastructures.eu/gCubeApps/BiodiversityResearchEnvironment"; //Production
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
ASLSession session = SessionManager.getInstance().getASLSession("123", username);
Manager call = manager().withTimeout(3, TimeUnit.MINUTES).build(); Manager call = manager().withTimeout(3, TimeUnit.MINUTES).build();
@ -45,17 +58,45 @@ public class ServiceQuery {
System.out.println("start query..."); System.out.println("start query...");
Stream<ResultElement> results = call.search("SEARCH BY SN 'sarda sarda' RETURN Product"); Stream<ResultElement> results = call.search("SEARCH BY SN 'Latimeria chalumnae' IN GBIF RETURN Product HAVING xpath(\"//product[type='Occurrence' and count>0]\")");
// Stream<ResultElement> results = call.search("SEARCH BY SN 'Palinurus elephas' IN WoRMS RETURN Taxon");
StreamIterator<ResultElement> input = new StreamIterator<ResultElement>(results);
System.out.println("Results from service...");
int i=0; int i=0;
if (results.hasNext()) { while(results.hasNext()) {
ResultElement elem = results.next(); 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<ResultElement, ResultItem> caster = buildCaster(input);
//from ResultItem to ResultRow
ResultItemConverter converter = new ResultItemConverter(session);
ConversionIterator<ResultItem, ResultRow> inputConverter = new ConversionIterator<ResultItem, ResultRow>(caster, converter);
while (inputConverter.hasNext()) {
ResultRow row = inputConverter.next();
System.out.println(++i +") row: "+row);
}
results.close(); results.close();
System.out.println("DONE"); System.out.println("DONE");
} }
protected static <I,O> ConversionIterator<I, O> buildCaster(CloseableIterator<I> input)
{
CastConverter<I, O> elementConverter = new CastConverter<I, O>();
ConversionIterator<I, O> caster = new ConversionIterator<I, O>(input, elementConverter);
return caster;
}
} }