diff --git a/distro/README b/distro/README
index f15ca84..6c1dd11 100644
--- a/distro/README
+++ b/distro/README
@@ -17,7 +17,7 @@ Authors
Version and Release Date
------------------------
-v. 3.3.0
+v. 3.5.0
Description
-----------
diff --git a/distro/changelog.xml b/distro/changelog.xml
index 78f0eaa..ef8b408 100644
--- a/distro/changelog.xml
+++ b/distro/changelog.xml
@@ -1,4 +1,16 @@
+
+ Portlet updated to support GWT 2.5.1
+ Ticket 2224: was implemented
+
+
+ Enhancements on GUI of SPD portlet was realized (view last query, new expand button are available)
+ The functionalities was updated in order to fit the changes in the service client. New advanced options are now available: "Expand with synonyms", "Unfold the taxa group by".
+
diff --git a/pom.xml b/pom.xml
index 600a586..a6ae81d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -67,6 +67,14 @@
provided
+
+ com.sencha.gxt
+ gxt
+ 2.2.5
+ provided
+
+
+
org.gcube.data.spd
@@ -185,12 +193,10 @@
-
+
- com.sencha.gxt
- gxt
- 2.2.5
- provided
+ org.gcube.applicationsupportlayer
+ accesslogger
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/ConstantsSpeciesDiscovery.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/ConstantsSpeciesDiscovery.java
index 00e2c56..53cead1 100644
--- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/ConstantsSpeciesDiscovery.java
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/ConstantsSpeciesDiscovery.java
@@ -73,7 +73,8 @@ public final class ConstantsSpeciesDiscovery {
public static final String NULL = "null";
public static final String UNDEFINED = "Undefined";
public static final String NOT_FOUND = "not found";
- public static int LIMIT_ITEM_DETAILS = 100;
+ public static int RESULT_ROW_LIMIT_ITEM_DETAILS = 250;
+ public static int TAXONOMY_LIMIT_ITEMS_DETAILS = 100;
//USED IN VIEW DETAILSWINDOW
public static final String THE_MAX_NUMBER_OF_ITEMS_DISPLAYABLE_IS = "The max number of items displayable is ";
@@ -111,5 +112,9 @@ public final class ConstantsSpeciesDiscovery {
public static final String DARWIN_CORE_ARCHIVE = "Darwin Core Archive";
public static final String SAVES_TAXONOMY_CHILDREN_FROM_RESULT = "Saves taxonomy children from result.";
public static final String SAVE_TAXONOMY_CHILDREN = "Save Taxonomy Children";
+
+ //SERVLETS
+ public static final String RESULT_ROW_TABLE = "ResultRowTable";
+ public static final String TAXONOMY_ROW_TABLE = "TaxonomyRowTable";
}
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/SearchController.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/SearchController.java
index 31b8e74..f42824f 100644
--- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/SearchController.java
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/SearchController.java
@@ -82,6 +82,7 @@ import org.gcube.portlets.user.speciesdiscovery.shared.DataSourceModel;
import org.gcube.portlets.user.speciesdiscovery.shared.DownloadState;
import org.gcube.portlets.user.speciesdiscovery.shared.JobOccurrencesModel;
import org.gcube.portlets.user.speciesdiscovery.shared.JobTaxonomyModel;
+import org.gcube.portlets.user.speciesdiscovery.shared.LightTaxonomyRow;
import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesSaveEnum;
import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesStatus;
import org.gcube.portlets.user.speciesdiscovery.shared.ResultRow;
@@ -91,7 +92,6 @@ import org.gcube.portlets.user.speciesdiscovery.shared.SearchFilters;
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType;
import org.gcube.portlets.user.speciesdiscovery.shared.SearchType;
import org.gcube.portlets.user.speciesdiscovery.shared.SpeciesCapability;
-import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
import org.gcube.portlets.user.speciesdiscovery.shared.filter.ResultFilter;
import org.gcube.portlets.user.speciesdiscovery.shared.util.SearchTermValidator;
import org.gcube.portlets.widgets.lighttree.client.ItemType;
@@ -222,11 +222,11 @@ public class SearchController {
boolean selected = updateAllRowSelectionEvent.getSelectionValue();
- String msgRow = result.intValue()==1?"row":"rows";
+ String msgRow = result.intValue()==1?"row was":"rows were";
String msgSel = selected==true?"selected":"deselected";
- Info.display("Info", result.intValue()+" "+msgRow+" was "+msgSel);
+ Info.display("Info", result.intValue()+" "+msgRow+" "+msgSel);
if(updateAllRowSelectionEvent.getSearchType().equals(SearchResultType.SPECIES_PRODUCT))
searchBorderLayoutPanel.getSpeciesCenterPanel().getResultRowPanel().selectAllRows(selected);
@@ -362,8 +362,10 @@ public class SearchController {
public void onSuccess(List result) {
if(result!=null){
- if(result.size()>0){
- Info.display("Species Occurrence Job", result.size() + " occurrence job was submitted");
+ int jobs = result.size();
+ if(jobs>0){
+ String msg = jobs==1? "was":"were";
+ Info.display("Species Occurrence Job", result.size() + " occurrence job "+msg+" submitted");
excecuteGetJobs(SearchResultType.OCCURRENCE_POINT, false);
searchBorderLayoutPanel.getSpeciesSouthPanel().setIconOccurrenceByCounter(result.size());
}
@@ -428,7 +430,7 @@ public class SearchController {
case BYCHILDREN:
- TaxonomyRow taxonomy = createSpeciesJobEvent.getTaxonomy();
+ LightTaxonomyRow taxonomy = createSpeciesJobEvent.getTaxonomy();
SpeciesDiscovery.taxonomySearchService.createTaxonomyJobByChildren(taxonomy.getServiceId(), taxonomy.getName(), taxonomy.getRank(), createSpeciesJobEvent.getDataSourceName(), new AsyncCallback() {
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/cluster/TabItemForTaxonomyRow.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/cluster/TabItemForTaxonomyRow.java
index 4109b3b..731599a 100644
--- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/cluster/TabItemForTaxonomyRow.java
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/cluster/TabItemForTaxonomyRow.java
@@ -2,20 +2,16 @@ package org.gcube.portlets.user.speciesdiscovery.client.cluster;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import org.gcube.portlets.user.speciesdiscovery.client.SpeciesDiscovery;
import org.gcube.portlets.user.speciesdiscovery.client.resources.Resources;
-import org.gcube.portlets.user.speciesdiscovery.client.util.TaxonomyGridField;
-import org.gcube.portlets.user.speciesdiscovery.shared.CommonName;
-import org.gcube.portlets.user.speciesdiscovery.shared.ItemParameter;
+import org.gcube.portlets.user.speciesdiscovery.shared.LightTaxonomyRow;
import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
import org.gcube.portlets.user.speciesdiscovery.shared.util.NormalizeString;
import com.allen_sauer.gwt.log.client.Log;
import com.extjs.gxt.ui.client.widget.ContentPanel;
-import com.extjs.gxt.ui.client.widget.Html;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.TabPanel;
@@ -47,9 +43,9 @@ public class TabItemForTaxonomyRow {
// private List parents = null;
private TablesForTaxonomyRow tablesForTaxonomyRow;
- private TaxonomyRow currentTaxonomy;
+ private LightTaxonomyRow currentTaxonomy;
- public void setCurrentTaxonomy(TaxonomyRow taxonomy){
+ public void setCurrentTaxonomy(LightTaxonomyRow taxonomy){
this.currentTaxonomy = taxonomy;
}
@@ -68,7 +64,7 @@ public class TabItemForTaxonomyRow {
* @return
*/
- public VerticalPanel getPanelClassificationForTaxonomy(TaxonomyRow taxonomy, String dataSource, boolean isNewTab){
+ public VerticalPanel getPanelClassificationForTaxonomy(LightTaxonomyRow taxonomy, String dataSource, boolean isNewTab){
VerticalPanel vpClassification = new VerticalPanel();
vpClassification.setSpacing(5);
@@ -97,7 +93,7 @@ public class TabItemForTaxonomyRow {
* @param isNewTab
* @param parentIndex
*/
- public void createPanelForParentTaxonomy(TaxonomyRow taxon, VerticalPanel vpClassification, String taxonomyServiceId, boolean isNewTab, String dataSource, int parentIndex){
+ public void createPanelForParentTaxonomy(LightTaxonomyRow taxon, VerticalPanel vpClassification, String taxonomyServiceId, boolean isNewTab, String dataSource, int parentIndex){
if(taxon==null)
return;
@@ -128,7 +124,7 @@ public class TabItemForTaxonomyRow {
}
}
- private void loadChildrenListOfItem(final VerticalPanel vpClassification, final TaxonomyRow taxonomyItem, final String dataSource, final String parentName, final int parentIndex){
+ private void loadChildrenListOfItem(final VerticalPanel vpClassification, final LightTaxonomyRow taxonomyItem, final String dataSource, final String parentName, final int parentIndex){
final ContentPanel cp = new ContentPanel();
cp.setId("cp" + taxonomyItem.getId());
@@ -146,10 +142,10 @@ public class TabItemForTaxonomyRow {
// printParent = printParent.getParent();
// }
- SpeciesDiscovery.taxonomySearchService.loadListChildByParentId(taxonomyItem.getServiceId(), new AsyncCallback>() {
+ SpeciesDiscovery.taxonomySearchService.loadListChildrenByParentId(taxonomyItem.getServiceId(), new AsyncCallback>() {
@Override
- public void onSuccess(ArrayList result) {
+ public void onSuccess(ArrayList result) {
Log.trace("Children returned in client: " + result.size() + " for parentName " +parentName);
LayoutContainer lc = new LayoutContainer();
@@ -166,7 +162,7 @@ public class TabItemForTaxonomyRow {
if(result.size()>0){
for (int i=0; i list = new ArrayList();
+ List list = new ArrayList();
list.add(currentTaxonomy);
list.addAll(currentTaxonomy.getParents());
- System.out.println("parentIndex == -1");
+// System.out.println("parentIndex == -1");
printParents(taxon);
taxon.setParent(list);
}
@@ -295,11 +291,11 @@ public class TabItemForTaxonomyRow {
}
- void printParents(TaxonomyRow taxon){
+ void printParents(LightTaxonomyRow taxon){
System.out.println("principal "+taxon.getName());
int i = 0;
- for (TaxonomyRow tax : taxon.getParents()) {
+ for (LightTaxonomyRow tax : taxon.getParents()) {
System.out.println(++i + " parent name " + tax.getName());
}
}
@@ -318,346 +314,346 @@ public class TabItemForTaxonomyRow {
return label;
}
- public Html getHTMLTableForTaxonomy(TaxonomyRow row, boolean isNewTab){
-
- //Init values
- String dataProviderName = "";
- String dataSetCitation= "";
- String matchingAccordionTo= "";
- String rank= "";
-// String matchingCredits= "";
-
- String statusName = "";
- String dateModified = "";
- String statusRemark = "";
-
- String author = "";
- String lsid = "";
- String credits = "";
-
- String propertiesHtml = "";
-
- if(row.getDataProviderName()!=null) dataProviderName = row.getDataProviderName();
- if(row.getStatusName()!=null) statusName = row.getStatusName();
- if(row.getDateModified()!=null) dateModified = row.getDateModified();
-
- if(row.getDataSetCitation()!=null) dataSetCitation = row.getDataSetCitation();
- if(row.getRank()!=null) rank = row.getRank();
- if(row.getAccordingTo()!=null) matchingAccordionTo = row.getAccordingTo();
-
- if(row.getStatusRemarks()!=null) statusRemark = row.getStatusRemarks();
-
- if(row.getAuthor()!=null) author = row.getAuthor();
-
- if(row.getLsid()!=null) lsid = row.getLsid();
-
- if(row.getCredits()!=null) credits = row.getCredits();
-
-
- if(row.getProperties()!=null){
-
- List hashProperties = row.getProperties();
- Collections.sort(hashProperties, ItemParameter.COMPARATOR);
-
- propertiesHtml+="";
-
- for (ItemParameter itemParameter : hashProperties) {
-
- propertiesHtml+=
- "" +
- " "+itemParameter.getKey()+" " +
- " "+itemParameter.getValue()+" " +
- " ";
- }
-
- propertiesHtml+="
";
- }
-
-
- //Create list common name
- String commonNames = "";
-
-// if(isNewTab){
- if(row.getCommonNames()!=null){
- for (CommonName comName : row.getCommonNames()) {
- commonNames+= ""+comName.getName()+" " +" ("+comName.getLanguage()+") - ";
- }
- }
+// public Html getHTMLTableForTaxonomy(TaxonomyRow row, boolean isNewTab){
+//
+// //Init values
+// String dataProviderName = "";
+// String dataSetCitation= "";
+// String matchingAccordionTo= "";
+// String rank= "";
+//// String matchingCredits= "";
+//
+// String statusName = "";
+// String dateModified = "";
+// String statusRemark = "";
+//
+// String author = "";
+// String lsid = "";
+// String credits = "";
+//
+// String propertiesHtml = "";
+//
+// if(row.getDataProviderName()!=null) dataProviderName = row.getDataProviderName();
+// if(row.getStatusName()!=null) statusName = row.getStatusName();
+// if(row.getDateModified()!=null) dateModified = row.getDateModified();
+//
+// if(row.getDataSetCitation()!=null) dataSetCitation = row.getDataSetCitation();
+// if(row.getRank()!=null) rank = row.getRank();
+// if(row.getAccordingTo()!=null) matchingAccordionTo = row.getAccordingTo();
+//
+// if(row.getStatusRemarks()!=null) statusRemark = row.getStatusRemarks();
+//
+// if(row.getAuthor()!=null) author = row.getAuthor();
+//
+// if(row.getLsid()!=null) lsid = row.getLsid();
+//
+// if(row.getCredits()!=null) credits = row.getCredits();
+//
+//
+// if(row.getProperties()!=null){
+//
+// List hashProperties = row.getProperties();
+// Collections.sort(hashProperties, ItemParameter.COMPARATOR);
+//
+// propertiesHtml+="";
+//
+// for (ItemParameter itemParameter : hashProperties) {
+//
+// propertiesHtml+=
+// "" +
+// " "+itemParameter.getKey()+" " +
+// " "+itemParameter.getValue()+" " +
+// " ";
+// }
+//
+// propertiesHtml+="
";
// }
-
-
- String table = "";
-
-// if(isNewTab)
- table+=
- "" +
- " "+TaxonomyGridField.COMMON_NAMES.getName()+" (Language) " +
- " "+commonNames+" " +
- " ";
-
-
- table+="" +
- " "+TaxonomyGridField.STATUSREFNAME.getName()+" " +
- " "+statusName+" " +
- " " +
- "" +
- " "+TaxonomyGridField.STATUS_REMARKS.getName()+" " +
- " "+statusRemark+" " +
- " " +
- "" +
- " "+TaxonomyGridField.DATASOURCE.getName()+" " +
- " "+dataProviderName+" " +
- " " +
- "" +
- " "+TaxonomyGridField.DATEMODIFIED.getName()+" " +
- " "+dateModified+" " +
- " " +
- "" +
- " "+TaxonomyGridField.MATCHING_RANK.getName()+" " +
- " "+rank+" " +
- " " +
- "" +
- " "+TaxonomyGridField.CITATION.getName()+" " +
- " "+dataSetCitation+" " +
- " " +
-// "" +
-// " "+TaxonomyGridField.MATCHING_AUTHOR.getName()+" " +
-// " "+matchingAccordionTo+" " +
+//
+//
+// //Create list common name
+// String commonNames = "";
+//
+//// if(isNewTab){
+// if(row.getCommonNames()!=null){
+// for (CommonName comName : row.getCommonNames()) {
+// commonNames+= ""+comName.getName()+" " +" ("+comName.getLanguage()+") - ";
+// }
+// }
+//// }
+//
+//
+// String table = "";
+//
+//// if(isNewTab)
+// table+=
+// "" +
+// " "+TaxonomyGridField.COMMON_NAMES.getName()+" (Language) " +
+// " "+commonNames+" " +
+// " ";
+//
+//
+// table+="" +
+// " "+TaxonomyGridField.STATUSREFNAME.getName()+" " +
+// " "+statusName+" " +
// " " +
- "" +
- " "+TaxonomyGridField.LSID.getName()+" " +
- " "+lsid+" " +
- " " +
- "" +
- " "+TaxonomyGridField.AUTHOR.getName()+" " +
- " "+author+" " +
- " " +
- "" +
- " "+TaxonomyGridField.CREDITS.getName()+" " +
- " "+credits+" " +
- " " +
-
- "" +
- " "+TaxonomyGridField.PROPERTIES.getName()+" " +
- " "+propertiesHtml+" " +
- " " +
-
- "
";
- return new Html(table);
-
- }
+// " " +
+// " "+TaxonomyGridField.STATUS_REMARKS.getName()+" " +
+// " "+statusRemark+" " +
+// " " +
+// "" +
+// " "+TaxonomyGridField.DATASOURCE.getName()+" " +
+// " "+dataProviderName+" " +
+// " " +
+// "" +
+// " "+TaxonomyGridField.DATEMODIFIED.getName()+" " +
+// " "+dateModified+" " +
+// " " +
+// "" +
+// " "+TaxonomyGridField.MATCHING_RANK.getName()+" " +
+// " "+rank+" " +
+// " " +
+// "" +
+// " "+TaxonomyGridField.CITATION.getName()+" " +
+// " "+dataSetCitation+" " +
+// " " +
+//// "" +
+//// " "+TaxonomyGridField.MATCHING_AUTHOR.getName()+" " +
+//// " "+matchingAccordionTo+" " +
+//// " " +
+// "" +
+// " "+TaxonomyGridField.LSID.getName()+" " +
+// " "+lsid+" " +
+// " " +
+// "" +
+// " "+TaxonomyGridField.AUTHOR.getName()+" " +
+// " "+author+" " +
+// " " +
+// "" +
+// " "+TaxonomyGridField.CREDITS.getName()+" " +
+// " "+credits+" " +
+// " " +
+//
+// "" +
+// " "+TaxonomyGridField.PROPERTIES.getName()+" " +
+// " "+propertiesHtml+" " +
+// " " +
+//
+// "
";
+// return new Html(table);
+//
+// }
+//
+// public FlexTable getHTMLTableForTaxonomyWithRef(final LightTaxonomyRow row,boolean isNewTab, final String dataSource) {
+//
+// // Init values
+// String dataProviderName = "";
+// String dataSetCitation = "";
+// String matchingAccordionTo = "";
+// String rank = "";
+// // String matchingCredits= "";
+//
+// String statusName = "";
+// String dateModified = "";
+// String statusRemark = "";
+//
+// String author = "";
+// String lsid = "";
+// String credits = "";
+//
+// String refId = null;
+//
+// String propertiesHtml = "";
+//
+// if (row.getDataProviderName() != null)
+// dataProviderName = row.getDataProviderName();
+// if (row.getStatusName() != null)
+// statusName = row.getStatusName();
+// if (row.getDateModified() != null)
+// dateModified = row.getDateModified();
+//
+// if (row.getDataSetCitation() != null)
+// dataSetCitation = row.getDataSetCitation();
+// if (row.getRank() != null)
+// rank = row.getRank();
+// if (row.getAccordingTo() != null)
+// matchingAccordionTo = row.getAccordingTo();
+//
+// if (row.getStatusRemarks() != null)
+// statusRemark = row.getStatusRemarks();
+//
+// if (row.getAuthor() != null)
+// author = row.getAuthor();
+//
+// if (row.getLsid() != null)
+// lsid = row.getLsid();
+//
+// if (row.getCredits() != null)
+// credits = row.getCredits();
+//
+// if (row.getStatusRefId() != null && !row.getStatusRefId().isEmpty())
+// refId = row.getStatusRefId();
+//
+// if (row.getProperties() != null) {
+//
+// List hashProperties = row.getProperties();
+// Collections.sort(hashProperties,
+// ItemParameter.COMPARATOR);
+//
+// propertiesHtml += "";
+//
+// for (ItemParameter itemParameter : hashProperties) {
+//
+// propertiesHtml += "" + " "
+// + itemParameter.getKey() + " " + " "
+// + itemParameter.getValue() + " " + " ";
+// }
+//
+// propertiesHtml += "
";
+// }
+//
+// // Create list common name
+// String commonNames = "";
+//
+// // if(isNewTab){
+// if (row.getCommonNames() != null) {
+// for (CommonName comName : row.getCommonNames()) {
+// commonNames += "" + comName.getName() + " " + " ("
+// + comName.getLanguage() + ") - ";
+// }
+// }
+// // }
+//
+// final FlexTable flexTable = new FlexTable();
+//
+// flexTable.setStyleName("imagetable");
+//
+// flexTable.setWidget(0, 0,new Label(TaxonomyGridField.COMMON_NAMES.getName()));
+// flexTable.setWidget(0, 1, new Html(commonNames));
+//
+// flexTable.setWidget(1, 0,new Label(TaxonomyGridField.STATUSREFNAME.getName()));
+// flexTable.setWidget(1, 1, new Label(statusName));
+//
+// if (refId != null) {
+//
+// final String status;
+//
+// if(!statusRemark.isEmpty())
+// status = statusRemark;
+// else
+// status = statusName;
+//
+// final String referenceId = refId;
+//
+// flexTable.setWidget(2, 0, new Label(TaxonomyGridField.STATUS_REMARKS.getName()));
+//
+// AbstractImagePrototype synonyms = AbstractImagePrototype.create(Resources.INSTANCE.getSearch());
+//
+// final Image imageStatusRemark = synonyms.createImage();
+// imageStatusRemark.setStyleName("image-load-synonyms");
+// imageStatusRemark.setAltText("show accepted name");
+// imageStatusRemark.setTitle("show accepted name");
+// final LayoutContainer layoutContainer = new LayoutContainer();
+//
+// final Label labelStatusRemark = new Label(statusRemark);
+// labelStatusRemark.addStyleName("status-of");
+// layoutContainer.add(labelStatusRemark);
+//
+// imageStatusRemark.addClickHandler(new ClickHandler() {
+//
+// @Override
+// public void onClick(ClickEvent event) {
+// flexTable.remove(layoutContainer);
+// if(row.getParents().size()>0)
+// getTaxonomyByReferenceId(flexTable, 2, 1, status, referenceId, dataSource, row.getParents());
+//
+// }
+// });
+//
+// layoutContainer.add(labelStatusRemark);
+// layoutContainer.add(imageStatusRemark);
+//
+// flexTable.setWidget(2, 1, layoutContainer);
+//
+// } else {
+// flexTable.setWidget(2, 0, new Label(TaxonomyGridField.STATUS_REMARKS.getName()));
+// flexTable.setWidget(2, 1, new Label(statusRemark));
+// }
+//
+//
+// //Create row get synonyms
+// flexTable.setWidget(3, 0,new Label(TaxonomyGridField.SYNONYMS.getName()));
+//
+// AbstractImagePrototype synonyms = AbstractImagePrototype.create(Resources.INSTANCE.getSearch());
+//
+// final Image imageSynonyms = synonyms.createImage();
+// imageSynonyms.setStyleName("image-load-synonyms");
+// imageSynonyms.setAltText("show synonyms");
+// imageSynonyms.setTitle("show synonyms");
+//
+// imageSynonyms.addClickHandler(new ClickHandler() {
+//
+// @Override
+// public void onClick(ClickEvent event) {
+// flexTable.remove(imageSynonyms);
+//
+//// DEBUG
+//// System.out.println("getSynonyms of "+row.getName() + " serviceId "+row.getServiceId());
+//
+//
+// if(row.getParents().size()>0){
+//
+//
+// //TODO
+// getSynonymsByReferenceId(flexTable, 3, 1, row.getServiceId(),dataSource, row.getParents());
+//
+//
+//
+// }
+// }
+// });
+//
+// flexTable.setWidget(3, 1, imageSynonyms);
+//
+//
+// flexTable.setWidget(4, 0,new Label(TaxonomyGridField.DATASOURCE.getName()));
+// flexTable.setWidget(4, 1, new Label(dataProviderName));
+//
+// flexTable.setWidget(5, 0,new Label(TaxonomyGridField.DATEMODIFIED.getName()));
+// flexTable.setWidget(5, 1, new Label(dateModified));
+//
+// flexTable.setWidget(6, 0,
+// new Label(TaxonomyGridField.MATCHING_RANK.getName()));
+// flexTable.setWidget(6, 1, new Label(rank));
+//
+// flexTable.setWidget(7, 0,
+// new Label(TaxonomyGridField.CITATION.getName()));
+// flexTable.setWidget(7, 1, new Label(dataSetCitation));
+//
+// flexTable.setWidget(8, 0, new Label(TaxonomyGridField.LSID.getName()));
+// flexTable.setWidget(8, 1, new Label(lsid));
+//
+// flexTable
+// .setWidget(9, 0, new Label(TaxonomyGridField.AUTHOR.getName()));
+// flexTable.setWidget(9, 1, new Label(author));
+//
+// flexTable.setWidget(10, 0,
+// new Label(TaxonomyGridField.CREDITS.getName()));
+// flexTable.setWidget(10, 1, new Label(credits));
+//
+// flexTable.setWidget(11, 0,
+// new Label(TaxonomyGridField.PROPERTIES.getName()));
+// flexTable.setWidget(11, 1, new Html(propertiesHtml));
+//
+// for (int i = 0; i < flexTable.getRowCount(); i++) {
+// flexTable.getFlexCellFormatter().setStyleName(i, 0, "title");
+// }
+//
+// return flexTable;
+//
+// }
- public FlexTable getHTMLTableForTaxonomyWithRef(final TaxonomyRow row,boolean isNewTab, final String dataSource) {
-
- // Init values
- String dataProviderName = "";
- String dataSetCitation = "";
- String matchingAccordionTo = "";
- String rank = "";
- // String matchingCredits= "";
-
- String statusName = "";
- String dateModified = "";
- String statusRemark = "";
-
- String author = "";
- String lsid = "";
- String credits = "";
-
- String refId = null;
-
- String propertiesHtml = "";
-
- if (row.getDataProviderName() != null)
- dataProviderName = row.getDataProviderName();
- if (row.getStatusName() != null)
- statusName = row.getStatusName();
- if (row.getDateModified() != null)
- dateModified = row.getDateModified();
-
- if (row.getDataSetCitation() != null)
- dataSetCitation = row.getDataSetCitation();
- if (row.getRank() != null)
- rank = row.getRank();
- if (row.getAccordingTo() != null)
- matchingAccordionTo = row.getAccordingTo();
-
- if (row.getStatusRemarks() != null)
- statusRemark = row.getStatusRemarks();
-
- if (row.getAuthor() != null)
- author = row.getAuthor();
-
- if (row.getLsid() != null)
- lsid = row.getLsid();
-
- if (row.getCredits() != null)
- credits = row.getCredits();
-
- if (row.getStatusRefId() != null && !row.getStatusRefId().isEmpty())
- refId = row.getStatusRefId();
-
- if (row.getProperties() != null) {
-
- List hashProperties = row.getProperties();
- Collections.sort(hashProperties,
- ItemParameter.COMPARATOR);
-
- propertiesHtml += "";
-
- for (ItemParameter itemParameter : hashProperties) {
-
- propertiesHtml += "" + " "
- + itemParameter.getKey() + " " + " "
- + itemParameter.getValue() + " " + " ";
- }
-
- propertiesHtml += "
";
- }
-
- // Create list common name
- String commonNames = "";
-
- // if(isNewTab){
- if (row.getCommonNames() != null) {
- for (CommonName comName : row.getCommonNames()) {
- commonNames += "" + comName.getName() + " " + " ("
- + comName.getLanguage() + ") - ";
- }
- }
- // }
-
- final FlexTable flexTable = new FlexTable();
-
- flexTable.setStyleName("imagetable");
-
- flexTable.setWidget(0, 0,new Label(TaxonomyGridField.COMMON_NAMES.getName()));
- flexTable.setWidget(0, 1, new Html(commonNames));
-
- flexTable.setWidget(1, 0,new Label(TaxonomyGridField.STATUSREFNAME.getName()));
- flexTable.setWidget(1, 1, new Label(statusName));
-
- if (refId != null) {
-
- final String status;
-
- if(!statusRemark.isEmpty())
- status = statusRemark;
- else
- status = statusName;
-
- final String referenceId = refId;
-
- flexTable.setWidget(2, 0, new Label(TaxonomyGridField.STATUS_REMARKS.getName()));
-
- AbstractImagePrototype synonyms = AbstractImagePrototype.create(Resources.INSTANCE.getSearch());
-
- final Image imageStatusRemark = synonyms.createImage();
- imageStatusRemark.setStyleName("image-load-synonyms");
- imageStatusRemark.setAltText("show accepted name");
- imageStatusRemark.setTitle("show accepted name");
- final LayoutContainer layoutContainer = new LayoutContainer();
-
- final Label labelStatusRemark = new Label(statusRemark);
- labelStatusRemark.addStyleName("status-of");
- layoutContainer.add(labelStatusRemark);
-
- imageStatusRemark.addClickHandler(new ClickHandler() {
-
- @Override
- public void onClick(ClickEvent event) {
- flexTable.remove(layoutContainer);
- if(row.getParents().size()>0)
- getTaxonomyByReferenceId(flexTable, 2, 1, status, referenceId, dataSource, row.getParents());
-
- }
- });
-
- layoutContainer.add(labelStatusRemark);
- layoutContainer.add(imageStatusRemark);
-
- flexTable.setWidget(2, 1, layoutContainer);
-
- } else {
- flexTable.setWidget(2, 0, new Label(TaxonomyGridField.STATUS_REMARKS.getName()));
- flexTable.setWidget(2, 1, new Label(statusRemark));
- }
-
-
- //Create row get synonyms
- flexTable.setWidget(3, 0,new Label(TaxonomyGridField.SYNONYMS.getName()));
-
- AbstractImagePrototype synonyms = AbstractImagePrototype.create(Resources.INSTANCE.getSearch());
-
- final Image imageSynonyms = synonyms.createImage();
- imageSynonyms.setStyleName("image-load-synonyms");
- imageSynonyms.setAltText("show synonyms");
- imageSynonyms.setTitle("show synonyms");
-
- imageSynonyms.addClickHandler(new ClickHandler() {
-
- @Override
- public void onClick(ClickEvent event) {
- flexTable.remove(imageSynonyms);
-
-// DEBUG
-// System.out.println("getSynonyms of "+row.getName() + " serviceId "+row.getServiceId());
-
-
- if(row.getParents().size()>0){
-
-
- //TODO
- getSynonymsByReferenceId(flexTable, 3, 1, row.getServiceId(),dataSource, row.getParents());
-
-
-
- }
- }
- });
-
- flexTable.setWidget(3, 1, imageSynonyms);
-
-
- flexTable.setWidget(4, 0,new Label(TaxonomyGridField.DATASOURCE.getName()));
- flexTable.setWidget(4, 1, new Label(dataProviderName));
-
- flexTable.setWidget(5, 0,new Label(TaxonomyGridField.DATEMODIFIED.getName()));
- flexTable.setWidget(5, 1, new Label(dateModified));
-
- flexTable.setWidget(6, 0,
- new Label(TaxonomyGridField.MATCHING_RANK.getName()));
- flexTable.setWidget(6, 1, new Label(rank));
-
- flexTable.setWidget(7, 0,
- new Label(TaxonomyGridField.CITATION.getName()));
- flexTable.setWidget(7, 1, new Label(dataSetCitation));
-
- flexTable.setWidget(8, 0, new Label(TaxonomyGridField.LSID.getName()));
- flexTable.setWidget(8, 1, new Label(lsid));
-
- flexTable
- .setWidget(9, 0, new Label(TaxonomyGridField.AUTHOR.getName()));
- flexTable.setWidget(9, 1, new Label(author));
-
- flexTable.setWidget(10, 0,
- new Label(TaxonomyGridField.CREDITS.getName()));
- flexTable.setWidget(10, 1, new Label(credits));
-
- flexTable.setWidget(11, 0,
- new Label(TaxonomyGridField.PROPERTIES.getName()));
- flexTable.setWidget(11, 1, new Html(propertiesHtml));
-
- for (int i = 0; i < flexTable.getRowCount(); i++) {
- flexTable.getFlexCellFormatter().setStyleName(i, 0, "title");
- }
-
- return flexTable;
-
- }
-
- public void getSynonymsByReferenceId(FlexTable flexTable, int row, int col, String refId, final String dataSource, final List parents){
+ public void getSynonymsByReferenceId(FlexTable flexTable, int row, int col, String refId, final String dataSource, final List parents){
final LayoutContainer layoutContainer = new LayoutContainer();
final Image loading = AbstractImagePrototype.create(Resources.INSTANCE.loadingBalls()).createImage();
@@ -665,7 +661,7 @@ public class TabItemForTaxonomyRow {
flexTable.setWidget(row, col, layoutContainer);
- SpeciesDiscovery.taxonomySearchService.retrieveSynonymsByRefId(refId, new AsyncCallback>() {
+ SpeciesDiscovery.taxonomySearchService.retrieveSynonymsByRefId(refId, new AsyncCallback>() {
@Override
public void onFailure(Throwable caught) {
@@ -675,7 +671,7 @@ public class TabItemForTaxonomyRow {
}
@Override
- public void onSuccess(List result) {
+ public void onSuccess(List result) {
Log.trace("getReferenceById return " +result.size() + " items");
// System.out.println("getReferenceById return " +result.size() + " items");
@@ -687,7 +683,7 @@ public class TabItemForTaxonomyRow {
if(result.size()>0){
for (int i=0; i parents){
+ public void getTaxonomyByReferenceId(FlexTable flexTable, int row, int col, final String statusRemark, String refId, final String dataSource, final List parents){
final LayoutContainer layoutContainer = new LayoutContainer();
// hp.getElement().getStyle().setBorderStyle(BorderStyle.NONE);
@@ -744,7 +740,7 @@ public class TabItemForTaxonomyRow {
List listId = new ArrayList();
listId.add(refId);
- SpeciesDiscovery.taxonomySearchService.retrieveTaxonomyByIds(listId, new AsyncCallback>() {
+ SpeciesDiscovery.taxonomySearchService.retrieveTaxonomyByIds(listId, new AsyncCallback>() {
@Override
public void onFailure(Throwable caught) {
@@ -754,7 +750,7 @@ public class TabItemForTaxonomyRow {
}
@Override
- public void onSuccess(List result) {
+ public void onSuccess(List result) {
Log.trace("getReferenceById return " +result.size() + " items");
// System.out.println("getReferenceById return " +result.size() + " items");
@@ -770,7 +766,7 @@ public class TabItemForTaxonomyRow {
if(result.size()>0){
for (int i=0; i" + taxon.getName() + "
"));
-// contentPanel.add(new Html("Scientific Classification
"));
-//
-// contentPanel.add(getPanelClassificationForTaxonomy(taxon, dataSource, isNewTab));
-//
-// contentPanel.add(getHTMLTableForTaxonomyWithRef(taxon, isNewTab, dataSource,parentIndex));
-//
-// return contentPanel;
-//
-// }
-
-// protected void addTabItem(final TaxonomyRow taxon, final String dataSource, final int parentIndex){
-//
-//
-// TabItem tabItem = new TabItem();
-//// tabItem.setLayout(new FitLayout());
-// tabItem.setScrollMode(Scroll.AUTO);
-// tabItem.setClosable(true);
-//
-//
-// ContentPanel cp = new ContentPanel();
-// cp.setHeaderVisible(false);
-// ToolBar toolbar = new ToolBar();
-//
-//
-// Button btnSaveTaxonomyChildren = new Button(ConstantsSpeciesDiscovery.SAVE_TAXONOMY_CHILDREN);
-// Menu formatSubMenu = new Menu();
-// btnSaveTaxonomyChildren.setMenu(formatSubMenu);
-// btnSaveTaxonomyChildren.setScale(ButtonScale.SMALL);
-// btnSaveTaxonomyChildren.setIconAlign(IconAlign.TOP);
-// btnSaveTaxonomyChildren.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts()));
-// btnSaveTaxonomyChildren.setToolTip(new ToolTipConfig(ConstantsSpeciesDiscovery.SAVE_TAXONOMY_CHILDREN, ConstantsSpeciesDiscovery.SAVES_TAXONOMY_CHILDREN_FROM_RESULT));
-//
-// MenuItem darwinCoreArchiveItem = new MenuItem(ConstantsSpeciesDiscovery.DARWIN_CORE_ARCHIVE);
-// darwinCoreArchiveItem.setToolTip(new ToolTipConfig(ConstantsSpeciesDiscovery.SAVES_IN_DARWIN_CORE_ARCHIVE_FORMAT));
-// darwinCoreArchiveItem.addSelectionListener(new SelectionListener() {
-//
-// @Override
-// public void componentSelected(MenuEvent ce) {
-// eventBus.fireEvent(new CreateTaxonomyJobEvent(taxon, dataSource, TaxonomyJobType.BYCHILDREN));
-// }
-// });
-//
-// formatSubMenu.add(darwinCoreArchiveItem);
-// toolbar.add(btnSaveTaxonomyChildren);
-//
-// cp.setTopComponent(toolbar);
-// cp.setBodyBorder(false);
-//// cp.setScrollMode(Scroll.AUTOY);
-//
-// String tabName = taxon.getName() + " ("+ dataSource + ")";
-// tabItem.setText(tabName);
-//
-// cp.add(getPanelForTaxonomy(taxon, dataSource, true, parentIndex));
-//
-// tabItem.add(cp);
-//
-// tabPanel.add(tabItem);
-//
-// }
-
}
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/cluster/TablesForTaxonomyRow.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/cluster/TablesForTaxonomyRow.java
index 2eec5ab..2c1b072 100644
--- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/cluster/TablesForTaxonomyRow.java
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/cluster/TablesForTaxonomyRow.java
@@ -6,7 +6,8 @@ import org.gcube.portlets.user.speciesdiscovery.client.ConstantsSpeciesDiscovery
import org.gcube.portlets.user.speciesdiscovery.client.event.CreateTaxonomyJobEvent;
import org.gcube.portlets.user.speciesdiscovery.client.event.CreateTaxonomyJobEvent.TaxonomyJobType;
import org.gcube.portlets.user.speciesdiscovery.client.resources.Resources;
-import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
+import org.gcube.portlets.user.speciesdiscovery.client.util.TaxonomyGridField;
+import org.gcube.portlets.user.speciesdiscovery.shared.LightTaxonomyRow;
import com.extjs.gxt.ui.client.Style.ButtonScale;
import com.extjs.gxt.ui.client.Style.IconAlign;
@@ -15,6 +16,7 @@ import com.extjs.gxt.ui.client.event.MenuEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Html;
+import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.VerticalPanel;
@@ -23,9 +25,19 @@ import com.extjs.gxt.ui.client.widget.menu.Menu;
import com.extjs.gxt.ui.client.widget.menu.MenuItem;
import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.EventBus;
+import com.google.gwt.http.client.Request;
+import com.google.gwt.http.client.RequestBuilder;
+import com.google.gwt.http.client.RequestCallback;
+import com.google.gwt.http.client.RequestException;
+import com.google.gwt.http.client.Response;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.FlexTable;
+import com.google.gwt.user.client.ui.Image;
+import com.google.gwt.user.client.ui.Label;
/**
*
@@ -37,17 +49,19 @@ public class TablesForTaxonomyRow {
private TabPanel tabPanel;
private EventBus eventBus;
- private List parents = null;
+ private List parents = null;
private TabItemForTaxonomyRow tabTR;
+ private AbstractImagePrototype imageLoading = AbstractImagePrototype.create(Resources.INSTANCE.loadingBalls());
+
// private HashMap hashTR = new HashMap();
- public List getParents() {
+ public List getParents() {
return parents;
}
- public void setParents(List parents) {
+ public void setParents(List parents) {
this.parents = parents;
}
@@ -67,39 +81,39 @@ public class TablesForTaxonomyRow {
* @return
*/
- public VerticalPanel getPanelClassificationForTaxonomy(TaxonomyRow taxonomy, String dataSource, boolean isNewTab){
+ public VerticalPanel getPanelClassificationForTaxonomy(LightTaxonomyRow taxonomy, String dataSource, boolean isNewTab){
// hashTR.put(taxonomy.getIdToString(),tabTR);
tabTR.setCurrentTaxonomy(taxonomy);
//DEBUG
- System.out.println("in getPanelClassificationForTaxonomy...");
- System.out.println("principal "+taxonomy.getName() + " id " + taxonomy.getServiceId()+" parents");
- int i=0;
- for (TaxonomyRow tax : taxonomy.getParents()) {
- System.out.println(++i + " parent name " + tax.getName());
- }
+// System.out.println("in getPanelClassificationForTaxonomy...");
+// System.out.println("principal "+taxonomy.getName() + " id " + taxonomy.getServiceId()+" parents");
+// int i=0;
+// for (TaxonomyRow tax : taxonomy.getParents()) {
+// System.out.println(++i + " parent name " + tax.getName());
+// }
return tabTR.getPanelClassificationForTaxonomy(taxonomy, dataSource, isNewTab);
}
- /**
- *
- * @param row
- * @param isNewTab
- * @param dataSource
- * @param parentIndex
- * @return
- */
- public FlexTable getHTMLTableForTaxonomyWithRef(final TaxonomyRow row,boolean isNewTab, final String dataSource) {
-
- return tabTR.getHTMLTableForTaxonomyWithRef(row, isNewTab, dataSource);
- }
+// /**
+// *
+// * @param row
+// * @param isNewTab
+// * @param dataSource
+// * @param parentIndex
+// * @return
+// */
+// public FlexTable getHTMLTableForTaxonomyWithRef(final LightTaxonomyRow row,boolean isNewTab, final String dataSource) {
+//
+// return tabTR.getHTMLTableForTaxonomyWithRef(row, isNewTab, dataSource);
+// }
+//
-
- protected ContentPanel getPanelForTaxonomy(TaxonomyRow taxon, String dataSource, boolean isNewTab) {
+ protected ContentPanel getPanelForTaxonomy(final LightTaxonomyRow taxon, final String dataSource, boolean isNewTab) {
ContentPanel contentPanel = new ContentPanel();
// contentPanel.setLayout(new FitLayout());
@@ -117,13 +131,58 @@ public class TablesForTaxonomyRow {
contentPanel.add(getPanelClassificationForTaxonomy(taxon, dataSource, isNewTab));
- contentPanel.add(getHTMLTableForTaxonomyWithRef(taxon, isNewTab, dataSource));
+ contentPanel.add(new Html("Status and Synonyms
"));
+ contentPanel.add(getStatusAndSynonyms(taxon, dataSource));
+ contentPanel.add(new Html("Other Information
0)
+ tabTR.getTaxonomyByReferenceId(flexTable, 1, 1, status, referenceId, dataSource, taxon.getParents());
+// getTaxonomyByReferenceId(flexTable, 2, 1, status, referenceId, dataSource, taxon.getParents());
+
+ }
+ });
+
+ layoutContainer.add(labelStatusRemark);
+ layoutContainer.add(imageStatusRemark);
+
+ flexTable.setWidget(1, 1, layoutContainer);
+
+ } else {
+ flexTable.setWidget(1, 0, new Label(TaxonomyGridField.STATUS_REMARKS.getName()));
+ flexTable.setWidget(1, 1, new Label(statusRemark));
+ }
+
+
+ //Create row get synonyms
+ flexTable.setWidget(2, 0,new Label(TaxonomyGridField.SYNONYMS.getName()));
+
+ AbstractImagePrototype synonyms = AbstractImagePrototype.create(Resources.INSTANCE.getSearch());
+
+ final Image imageSynonyms = synonyms.createImage();
+ imageSynonyms.setStyleName("image-load-synonyms");
+ imageSynonyms.setAltText("show synonyms");
+ imageSynonyms.setTitle("show synonyms");
+
+ imageSynonyms.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ flexTable.remove(imageSynonyms);
+
+ if(taxon.getParents().size()>0){
+ tabTR.getSynonymsByReferenceId(flexTable, 2, 1, taxon.getServiceId(),dataSource, taxon.getParents());
+ }
+ }
+ });
+
+ flexTable.setWidget(2, 1, imageSynonyms);
+
+ return flexTable;
+ }
}
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/event/CreateTaxonomyJobEvent.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/event/CreateTaxonomyJobEvent.java
index ee808da..4dcf93c 100644
--- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/event/CreateTaxonomyJobEvent.java
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/event/CreateTaxonomyJobEvent.java
@@ -3,7 +3,7 @@
*/
package org.gcube.portlets.user.speciesdiscovery.client.event;
-import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
+import org.gcube.portlets.user.speciesdiscovery.shared.LightTaxonomyRow;
import com.google.gwt.event.shared.GwtEvent;
@@ -15,7 +15,7 @@ import com.google.gwt.event.shared.GwtEvent;
public class CreateTaxonomyJobEvent extends GwtEvent {
public static final GwtEvent.Type TYPE = new Type();
- private TaxonomyRow taxonomy;
+ private LightTaxonomyRow taxonomy;
private String dataSourceName;
public enum TaxonomyJobType {BYCHILDREN, BYIDS};
private TaxonomyJobType jobType;
@@ -37,7 +37,7 @@ public class CreateTaxonomyJobEvent extends GwtEvent loadListChildByParentId(String parentId)
- throws Exception;
+ ArrayList loadListChildrenByParentId(String parentId) throws Exception;
void saveSelectedTaxonomyPoints(String destinationFolderId,
String fileName, SaveFileFormat fileFormat)
@@ -114,11 +116,9 @@ public interface TaxonomySearchService extends RemoteService {
String destinationFolderId, String fileName, String scientificName,
String dataSourceName) throws Exception;
- public List retrieveTaxonomyByIds(List ids)
- throws Exception;
+ public List retrieveTaxonomyByIds(List ids) throws Exception;
- public List retrieveSynonymsByRefId(String refId)
- throws Exception;
+ public List retrieveSynonymsByRefId(String refId) throws Exception;
public List createOccurrencesJob(
List listJobOccurrenceModel,
@@ -193,5 +193,16 @@ public interface TaxonomySearchService extends RemoteService {
* @return
*/
String getLastQuery();
+
+ /**
+ * @param scientificName
+ * @return
+ * @throws Exception
+ */
+ ClusterCommonNameDataSourceForResultRow loadClusterCommonNameForResultRowByScientificName(
+ String scientificName) throws Exception;
+
+ ClusterCommonNameDataSourceForTaxonomyRow loadClusterCommonNameForTaxonomyRowByScientificName(
+ String scientificName);
}
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/rpc/TaxonomySearchServiceAsync.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/rpc/TaxonomySearchServiceAsync.java
index 3ff4f9a..520020b 100644
--- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/rpc/TaxonomySearchServiceAsync.java
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/rpc/TaxonomySearchServiceAsync.java
@@ -12,6 +12,7 @@ import org.gcube.portlets.user.speciesdiscovery.shared.DataSourceModel;
import org.gcube.portlets.user.speciesdiscovery.shared.DownloadState;
import org.gcube.portlets.user.speciesdiscovery.shared.JobOccurrencesModel;
import org.gcube.portlets.user.speciesdiscovery.shared.JobTaxonomyModel;
+import org.gcube.portlets.user.speciesdiscovery.shared.LightTaxonomyRow;
import org.gcube.portlets.user.speciesdiscovery.shared.OccurrenceBatch;
import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesSaveEnum;
import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesStatus;
@@ -23,6 +24,8 @@ import org.gcube.portlets.user.speciesdiscovery.shared.SearchResult;
import org.gcube.portlets.user.speciesdiscovery.shared.SearchStatus;
import org.gcube.portlets.user.speciesdiscovery.shared.Taxon;
import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
+import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterCommonNameDataSourceForResultRow;
+import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterCommonNameDataSourceForTaxonomyRow;
import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterStructuresForResultRow;
import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterStructuresForTaxonomyRow;
import org.gcube.portlets.user.speciesdiscovery.shared.filter.ResultFilter;
@@ -86,7 +89,7 @@ public interface TaxonomySearchServiceAsync {
boolean showOnlySelected,
AsyncCallback> asyncCallback);
- void loadListChildByParentId(String parentId, AsyncCallback> callback);
+ void loadListChildrenByParentId(String parentId, AsyncCallback> asyncCallback);
void saveSelectedTaxonomyPoints(String destinationFolderId, String fileName, SaveFileFormat fileFormat, AsyncCallback callback);
@@ -101,9 +104,9 @@ public interface TaxonomySearchServiceAsync {
void saveTaxonomyJob(String jobIdentifier, String destinationFolderId, String fileName, String scientificName, String dataSourceName, AsyncCallback callback);
- void retrieveTaxonomyByIds(List ids, AsyncCallback> callback);
+ void retrieveTaxonomyByIds(List ids, AsyncCallback> asyncCallback);
- void retrieveSynonymsByRefId(String refId, AsyncCallback> callback);
+ void retrieveSynonymsByRefId(String refId, AsyncCallback> asyncCallback);
void createOccurrencesJob(List listJobOccurrenceModel, SaveFileFormat saveFileFormat, OccurrencesSaveEnum csvType, boolean isByDataSource, int expectedOccurrence, AsyncCallback> callback);
@@ -156,5 +159,13 @@ public interface TaxonomySearchServiceAsync {
AsyncCallback callback);
void getLastQuery(AsyncCallback callback);
+
+ void loadClusterCommonNameForResultRowByScientificName(
+ String scientificName,
+ AsyncCallback callback);
+
+ void loadClusterCommonNameForTaxonomyRowByScientificName(
+ String scientificName,
+ AsyncCallback callback);
}
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/windowdetail/ResultRowDetailsFiller.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/windowdetail/ResultRowDetailsFiller.java
index f088582..14353d6 100644
--- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/windowdetail/ResultRowDetailsFiller.java
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/client/windowdetail/ResultRowDetailsFiller.java
@@ -7,13 +7,10 @@ import java.util.List;
import org.gcube.portlets.user.speciesdiscovery.client.ConstantsSpeciesDiscovery;
import org.gcube.portlets.user.speciesdiscovery.client.SpeciesDiscovery;
-import org.gcube.portlets.user.speciesdiscovery.client.cluster.TablesForResultRow;
import org.gcube.portlets.user.speciesdiscovery.client.event.SearchEvent;
import org.gcube.portlets.user.speciesdiscovery.client.resources.Resources;
-import org.gcube.portlets.user.speciesdiscovery.client.util.stream.ResultRowDataSource;
-import org.gcube.portlets.user.speciesdiscovery.shared.ResultRow;
import org.gcube.portlets.user.speciesdiscovery.shared.SpeciesCapability;
-import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterCommonNameDataSource;
+import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterCommonNameDataSourceForResultRow;
import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterStructuresForResultRow;
import com.allen_sauer.gwt.log.client.Log;
@@ -30,18 +27,30 @@ import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.extjs.gxt.ui.client.widget.layout.TableData;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
+import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.http.client.Request;
+import com.google.gwt.http.client.RequestBuilder;
+import com.google.gwt.http.client.RequestCallback;
+import com.google.gwt.http.client.RequestException;
+import com.google.gwt.http.client.Response;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.Anchor;
+import com.google.gwt.user.client.ui.Image;
public class ResultRowDetailsFiller implements DetailsFiller {
+ /**
+ *
+ */
+
private TabItem tabItemDetails;
private ToolBar toolbarOccurrences;
private AbstractImagePrototype imgAttention = AbstractImagePrototype.create(Resources.INSTANCE.getAttention());
+ private AbstractImagePrototype imageLoading = AbstractImagePrototype.create(Resources.INSTANCE.loadingBalls());
private ContentPanel panelDetails;
private int width = 900;
private List lastlistDataSourceFound;
@@ -77,7 +86,9 @@ public class ResultRowDetailsFiller implements DetailsFiller {
@Override
public void onSuccess(ClusterStructuresForResultRow result) {
- int size = result.getResult().size();
+// int size = result.getResult().size();
+
+ int size = result.getResultSize();
long returnedTime = System.currentTimeMillis();
@@ -89,10 +100,10 @@ public class ResultRowDetailsFiller implements DetailsFiller {
String msg = "";
- if(result.getTotalRow()>size){
+ if(result.getAllResultRowSize()>size){
msg = ConstantsSpeciesDiscovery.ROW_LIMIT_REACHED + " - ";
tabItemDetails.setIcon(imgAttention);
- tabItemDetails.setToolTip(ConstantsSpeciesDiscovery.THE_MAX_NUMBER_OF_ITEMS_DISPLAYABLE_IS+ConstantsSpeciesDiscovery.LIMIT_ITEM_DETAILS);
+ tabItemDetails.setToolTip(ConstantsSpeciesDiscovery.THE_MAX_NUMBER_OF_ITEMS_DISPLAYABLE_IS+ConstantsSpeciesDiscovery.RESULT_ROW_LIMIT_ITEM_DETAILS);
}
msg+= tabItemDetails.getText() + " ("+size +" "+ items+")";
@@ -116,8 +127,10 @@ public class ResultRowDetailsFiller implements DetailsFiller {
private void createCommonNameDetailsPageForResultRow(ClusterStructuresForResultRow result) {
- HashMap> hashResultRowIdTables = result.getHashClusterScientificNameResultRowID();
- HashMap> hashClusterCommonNamesDataSources = result.getHashClusterCommonNamesDataSources();
+ HashMap> hashResultRowIdTables = result.getHashClusterScientificNameResultRowServiceID();
+
+
+// HashMap> hashClusterCommonNamesDataSources = result.getHashClusterCommonNamesDataSources();
String title = common.getSearchTitle();
@@ -187,25 +200,150 @@ public class ResultRowDetailsFiller implements DetailsFiller {
panelDetails.add(common.createExternalLinks(scientificName));
+
String commonNamesTitle = "Common Names (Data Source/s)
";
panelDetails.add(new Html(commonNamesTitle));
-
- ClusterCommonNameDataSource cluster = hashClusterCommonNamesDataSources.get(scientificName);
-
- String tableCommonName = common.createTableWithCheckCommonNameDataSource(cluster.getHashMapCommonNameDataSources(), cluster.getListDataSourcesFound());
- panelDetails.add(new Html(" "+tableCommonName+" "));
+ final LayoutContainer lcCommonName = new LayoutContainer();
+ lcCommonName.setStyleAttribute("width", "99%");
+ lcCommonName.setStyleAttribute("margin", "5px");
+ lcCommonName.setStyleAttribute("padding", "5px");
+ lcCommonName.setStyleAttribute("font-size", "12px");
+
+// lcCommonName.setLayout(new FitLayout());
+
+ final Anchor anchorCommon = new Anchor("Compare Common Names for "+scientificName);
+
+ anchorCommon.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ lcCommonName.remove(anchorCommon);
+ final Image loading = imageLoading.createImage();
+ lcCommonName.add(loading);
+ lcCommonName.layout();
+
+ SpeciesDiscovery.taxonomySearchService.loadClusterCommonNameForResultRowByScientificName(scientificName, new AsyncCallback() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Html htmlTableResult = new Html();
+ htmlTableResult.setHtml(" Error on retrieving data ");
+
+ }
+
+ @Override
+ public void onSuccess(ClusterCommonNameDataSourceForResultRow result) {
+
+
+ Html htmlTableResult = new Html();
+ htmlTableResult.setHtml(" Not Found ");
+
+ if(result !=null){
+
+ if(result.getCluster()!=null){
+ String tableCommonName = common.createTableWithCheckCommonNameDataSource(result.getCluster().getHashMapCommonNameDataSources(), result.getCluster().getListDataSourcesFound());
+ htmlTableResult.setHtml(" "+tableCommonName+" ");
+ }
+ else
+ htmlTableResult.setHtml(" Error on retrieving data ");
+ }else
+ htmlTableResult.setHtml(" Error on retrieving data ");
+
+
+ lcCommonName.remove(loading);
+ lcCommonName.add(htmlTableResult);
+
+ panelDetails.layout();
+ }
+
+
+ });
+
+
+ }
+ });
+
+ lcCommonName.add(anchorCommon);
+
+ panelDetails.add(lcCommonName);
+// ClusterCommonNameDataSource cluster = hashClusterCommonNamesDataSources.get(scientificName);
+
+
+// String tableCommonName = common.createTableWithCheckCommonNameDataSource(cluster.getHashMapCommonNameDataSources(), cluster.getListDataSourcesFound());
+// panelDetails.add(new Html(" "+tableCommonName+" "));
+
+
ArrayList arrayRowID = hashResultRowIdTables.get(scientificName);
+// for(int i=0; i lastlistDataSourceFound;
@@ -100,7 +108,7 @@ public class TaxonomyRowDetailsFiller implements DetailsFiller {
if(result.getTotalRow()>size){
msg = ConstantsSpeciesDiscovery.ROW_LIMIT_REACHED + " - ";
tabItemDetails.setIcon(imgAttention);
- tabItemDetails.setToolTip(ConstantsSpeciesDiscovery.THE_MAX_NUMBER_OF_ITEMS_DISPLAYABLE_IS+ConstantsSpeciesDiscovery.LIMIT_ITEM_DETAILS);
+ tabItemDetails.setToolTip(ConstantsSpeciesDiscovery.THE_MAX_NUMBER_OF_ITEMS_DISPLAYABLE_IS+ConstantsSpeciesDiscovery.TAXONOMY_LIMIT_ITEMS_DETAILS);
}
msg+= tabItemDetails.getText() + " ("+size +" "+ items+")";
@@ -122,9 +130,10 @@ public class TaxonomyRowDetailsFiller implements DetailsFiller {
}
private void createCommonNameDetailsPageForTaxonomyRow(ClusterStructuresForTaxonomyRow result) {
- HashMap> hashTaxonomyRowID = result.getHashClusterScientificNameTaxonomyRowID();
+
+ HashMap> hashTaxonomyRowServiceID = result.getHashClusterScientificNameTaxonomyRowServiceID();
// ArrayList listDataSourceFound = tableClassification.getListFoundDataSources();
- HashMap> hashClusterCommonNamesDataSources = result.getHashClusterCommonNamesDataSources();
+// HashMap> hashClusterCommonNamesDataSources = result.getHashClusterCommonNamesDataSources();
// HashMap> hashHTMLTables = result.getHashClassificationTables();
@@ -135,7 +144,7 @@ public class TaxonomyRowDetailsFiller implements DetailsFiller {
// System.out.println("############# Data Source found " + dataSource);
// }
- List listKey = new ArrayList(hashTaxonomyRowID.keySet());
+ List listKey = new ArrayList(hashTaxonomyRowServiceID.keySet());
Collections.sort(listKey);
@@ -204,16 +213,76 @@ public class TaxonomyRowDetailsFiller implements DetailsFiller {
String commonNamesTitle = "Common Names (Data Source/s)
";
panelDetails.add(new Html(commonNamesTitle));
- ClusterCommonNameDataSource cluster = hashClusterCommonNamesDataSources.get(scientificName);
+ final LayoutContainer lcCommonName = new LayoutContainer();
+ lcCommonName.setStyleAttribute("width", "99%");
+ lcCommonName.setStyleAttribute("margin", "5px");
+ lcCommonName.setStyleAttribute("padding", "5px");
+ lcCommonName.setStyleAttribute("font-size", "12px");
- String tableCommonName = common.createTableWithCheckCommonNameDataSource(cluster.getHashMapCommonNameDataSources(), cluster.getListDataSourcesFound());
- panelDetails.add(new Html(" "+tableCommonName+" "));
+// lcCommonName.setLayout(new FitLayout());
- ArrayList arrayTaxonomyID = hashTaxonomyRowID.get(scientificName);
+ final Anchor anchorCommon = new Anchor("Compare Common Names for "+scientificName);
+
+ anchorCommon.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ lcCommonName.remove(anchorCommon);
+ final Image loading = imageLoading.createImage();
+ lcCommonName.add(loading);
+ lcCommonName.layout();
+ SpeciesDiscovery.taxonomySearchService.loadClusterCommonNameForTaxonomyRowByScientificName(scientificName, new AsyncCallback() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Html htmlTableResult = new Html();
+ htmlTableResult.setHtml(" Error on retrieving data ");
+
+ }
+
+ @Override
+ public void onSuccess(ClusterCommonNameDataSourceForTaxonomyRow result) {
+
+
+ Html htmlTableResult = new Html();
+ htmlTableResult.setHtml(" Not Found ");
+
+ if(result !=null){
+
+ if(result.getCluster()!=null){
+ String tableCommonName = common.createTableWithCheckCommonNameDataSource(result.getCluster().getHashMapCommonNameDataSources(), result.getCluster().getListDataSourcesFound());
+ htmlTableResult.setHtml(" "+tableCommonName+" ");
+ }
+ else
+ htmlTableResult.setHtml(" Error on retrieving data ");
+ }else
+ htmlTableResult.setHtml(" Error on retrieving data ");
+
+
+ lcCommonName.remove(loading);
+ lcCommonName.add(htmlTableResult);
+
+ panelDetails.layout();
+ }
+
+
+ });
+
+
+ }
+ });
+
+ lcCommonName.add(anchorCommon);
+
+ panelDetails.add(lcCommonName);
+
+ ArrayList arrayTaxonomyID = hashTaxonomyRowServiceID.get(scientificName);
for(int i=0; iStatus and Synonyms
"));
+ panelDetails.add(tables.getStatusAndSynonyms(lightTaxonomy, dataSource));
+
+ tables.setParents(lightTaxonomy.getParents());
- tables.setParents(taxonomy.getParents());
- panelDetails.add(tables.getHTMLTableForTaxonomyWithRef(taxonomy, false, dataSource));
+ panelDetails.add(new Html("Other Information
"));
+
+ final LayoutContainer lcRRTables = new LayoutContainer();
+ lcRRTables.setStyleAttribute("width", "99%");
+ // lcRRTables.setLayout(new FitLayout());
+ lcRRTables.setStyleAttribute("margin", "5px");
+ lcRRTables.setStyleAttribute("padding", "5px");
+ lcRRTables.setStyleAttribute("font-size", "12px");
+ panelDetails.add(lcRRTables);
+
+ final Image loading = imageLoading.createImage();
+ lcRRTables.add(loading);
+
+ String urlRequest = GWT.getModuleBaseURL() + ConstantsSpeciesDiscovery.TAXONOMY_ROW_TABLE + "?" +"oid=" + arrayTaxonomyID.get(i);
+
+ RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, urlRequest);
+
+ try {
+ requestBuilder.sendRequest("", new RequestCallback() {
+
+ @Override
+ public void onResponseReceived(Request request, Response response) {
+ lcRRTables.remove(loading);
+ Html respHtml = new Html(response.getText());
+ lcRRTables.add(respHtml);
+ lcRRTables.layout();
+ }
+
+ @Override
+ public void onError(Request request, Throwable exception) {
+ lcRRTables.remove(loading);
+ lcRRTables.add(new Html("Sorry, an error occurred while contacting server, try again"));
+ }
+ });
+
+ } catch (RequestException e) {
+ lcRRTables.remove(loading);
+ lcRRTables.add(new Html("Sorry, an error occurred while contacting server, try again"));
+ }
}
}
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
new file mode 100644
index 0000000..6ee84dd
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/ResultRowTable.java
@@ -0,0 +1,313 @@
+package org.gcube.portlets.user.speciesdiscovery.server;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.log4j.Logger;
+import org.gcube.application.framework.core.session.ASLSession;
+import org.gcube.portlets.user.speciesdiscovery.client.util.SpeciesGridFields;
+import org.gcube.portlets.user.speciesdiscovery.server.asl.SessionUtil;
+import org.gcube.portlets.user.speciesdiscovery.server.persistence.dao.ResultRowPersistence;
+import org.gcube.portlets.user.speciesdiscovery.shared.CommonName;
+import org.gcube.portlets.user.speciesdiscovery.shared.ItemParameter;
+import org.gcube.portlets.user.speciesdiscovery.shared.ResultRow;
+import org.gcube.portlets.user.speciesdiscovery.shared.Taxon;
+import org.gcube.portlets.user.speciesdiscovery.shared.util.NormalizeString;
+
+
+/**
+ *
+ * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
+ * @Sep 6, 2013
+ *
+ */
+public class ResultRowTable extends HttpServlet {
+
+ /**
+ *
+ */
+ public static final String TEXT_HTML = "text/html";
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -9006347088111602996L;
+
+ protected Logger logger = Logger.getLogger(ResultRowTable.class);
+
+
+ protected ASLSession getASLSession(HttpServletRequest req)
+ {
+ return SessionUtil.getAslSession(req.getSession());
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+
+ String resultServiceRowID = "";
+ PrintWriter out = resp.getWriter();
+
+ resp.setContentType(TEXT_HTML);
+
+ try {
+ // get parameters
+ resultServiceRowID = req.getParameter("oid");
+
+ //IS VALID RR ID?
+ if(resultServiceRowID==null || resultServiceRowID.isEmpty()){
+ out.println(error("Parameter oid not found"));
+ }else{
+
+ logger.trace("found oid "+resultServiceRowID);
+
+ try {
+
+ ResultRowPersistence persistence = SessionUtil.getCurrentEJBResultRow(getASLSession(req));
+
+ if(persistence==null){
+ logger.trace("ResultRowPersistence not found in database");
+ out.println(error("Row id not found in database"));
+ out.close();
+ return;
+ }
+
+ CriteriaBuilder queryBuilder = persistence.getCriteriaBuilder();
+ CriteriaQuery cq = queryBuilder.createQuery();
+ Predicate pr1 = queryBuilder.equal(persistence.rootFrom(cq).get(ResultRow.SERVICE_ID_FIELD), resultServiceRowID);
+ cq.where(pr1);
+
+ Iterator iterator = persistence.executeCriteriaQuery(cq).iterator();
+
+ ResultRow row = null;
+
+ while(iterator.hasNext()){
+ row = iterator.next();
+ break;
+ }
+
+ if(row==null){
+ logger.trace("Service Row id not found in database");
+ out.println(error("Service Row id not found in database"));
+ out.close();
+ return;
+ }
+
+ String table = getTableForResultRow(row, getClassification(row.getParents()));
+
+ logger.trace("table for ResultRowPersistence is empty "+table.isEmpty());
+ out.println(table);
+
+ } catch (Exception e) {
+
+ logger.error("Error in ResultRowTable servlet ",e);
+ throw new Exception("Error in ResultRowTable servlet ", e);
+ }
+ }
+
+ out.close(); //CLOSE STREAM
+
+ }catch (Exception e) {
+ String error = "Sorry an error occurred when creating the table for result row with id: "+resultServiceRowID;
+
+ if(out!=null)
+ out.println(error);
+// else
+// throw new ServletException(error);
+
+// logger.error(error, e);
+
+ out.close(); //CLOSE STREAM
+
+ }
+ }
+
+ public String error(String message){
+ String errorPage = "";
+ errorPage +=("Error: "+message+"
");
+ return errorPage;
+ }
+
+ //TODO modified
+ public static String getClassification(List listTaxon)
+ {
+ StringBuilder sb = new StringBuilder();
+
+ for (int i = listTaxon.size()-1; i >= 0; i--) {
+ Taxon taxon = listTaxon.get(i);
+
+ sb.append("");
+
+ if(!NormalizeString.isUndefined(taxon.getRank()))
+ sb.append(taxon.getRank());
+ else
+ sb.append("Rank not found");
+
+ sb.append(" : ");
+
+ if(!NormalizeString.isUndefined(taxon.getName()))
+ sb.append(taxon.getName());
+ else
+ sb.append("Name not found");
+
+ if(i!=0)
+ sb.append(" -> ");
+ }
+ return sb.toString();
+ }
+
+ public String getTableForResultRow(ResultRow row, String classification){
+
+ //Init values
+ String dataSourceName = "";
+ String dataProviderName = "";
+ String dataSetName = "";
+ String dataSetCitation= "";
+ String matchingTaxonName= "";
+ String matchingAccordionTo= "";
+ String matchingRank= "";
+ String matchingCredits= "";
+ int occurencesCount = 0;
+
+ String author = "";
+ String lsid = "";
+ String credits = "";
+
+ String propertiesHtml = "";
+
+
+ //Validate values
+ if(row.getParents()!=null){
+
+ if(row.getParents().get(0).getName()!=null) matchingTaxonName = row.getParents().get(0).getName();
+
+ if(row.getParents().get(0).getAccordingTo()!=null) matchingAccordionTo = row.getParents().get(0).getAccordingTo();
+
+ if(row.getParents().get(0).getRank()!=null) matchingRank = row.getParents().get(0).getRank();
+ }
+
+ if(row.getDataSourceName()!=null) dataSourceName = row.getDataSourceName();
+ if(row.getDataProviderName()!=null) dataProviderName = row.getDataProviderName();
+ if(row.getDataSetName()!=null) dataSetName = row.getDataSetName();
+ if(row.getDataSetCitation()!=null) dataSetCitation = row.getDataSetCitation();
+ if(row.getMatchingCredits()!=null) matchingCredits = row.getMatchingCredits();
+ if(row.getOccurencesCount()!=0) occurencesCount = row.getOccurencesCount();
+
+
+ String commonNames = "";
+ if(row.getCommonNames()!=null){
+ for (CommonName comName : row.getCommonNames()) {
+ commonNames+= ""+comName.getName()+" " +" ("+comName.getLanguage()+") - ";
+ }
+ }
+
+
+ if(row.getAuthor()!=null) author = row.getAuthor();
+
+ if(row.getLsid()!=null) lsid = row.getLsid();
+
+ if(row.getCredits()!=null) credits = row.getCredits();
+
+
+ if(row.getProperties()!=null){
+
+ List listProperties = row.getProperties();
+ Collections.sort(listProperties, ItemParameter.COMPARATOR);
+
+ propertiesHtml+="";
+
+ for (ItemParameter itemParameter : listProperties) {
+
+ propertiesHtml+=
+ "" +
+ " "+itemParameter.getKey()+" " +
+ " "+itemParameter.getValue()+" " +
+ " ";
+ }
+
+ propertiesHtml+="
";
+ }
+
+ String table = "" +
+ "" +
+ " "+matchingTaxonName+" " +
+ " " +
+ "" +
+ " "+SpeciesGridFields.CLASSIFICATION_STRING.getName()+" " +
+ " "+classification+" " +
+ " " +
+ "" +
+ " "+SpeciesGridFields.COMMON_NAMES.getName()+" (Language) " +
+ " "+commonNames+" " +
+ " " +
+
+ "" +
+ " "+SpeciesGridFields.DATASOURCE.getName()+" " +
+ " "+dataSourceName+" " +
+ " " +
+ "" +
+ " "+SpeciesGridFields.DATAPROVIDER.getName()+" " +
+ " "+dataProviderName+" " +
+ " " +
+ "" +
+ " "+SpeciesGridFields.DATASET.getName()+" " +
+ " "+dataSetName+" " +
+ " " +
+// "" +
+// " "+SpeciesGridFields.MATCHING_AUTHOR.getName()+" " +
+// " "+matchingAccordionTo+" " +
+// " " +
+ "" +
+ " "+SpeciesGridFields.MATCHING_RANK.getName()+" " +
+ " "+matchingRank+" " +
+ " " +
+ "" +
+ " "+SpeciesGridFields.DATASET_CITATION.getName()+" " +
+ " "+dataSetCitation+" " +
+ " " +
+// "" +
+// " "+SpeciesGridFields.MATCHING_CREDITS.getName()+" " +
+// " "+matchingCredits+" " +
+// " " +
+ "" +
+ " "+SpeciesGridFields.PRODUCT_OCCURRENCES.getName()+" " +
+ " "+occurencesCount+" " +
+ " " +
+
+ "" +
+ " "+SpeciesGridFields.LSID.getName()+" " +
+ " "+lsid+" " +
+ " " +
+ "" +
+ " "+SpeciesGridFields.AUTHOR.getName()+" " +
+ " "+author+" " +
+ " " +
+ "" +
+ " "+SpeciesGridFields.CREDITS.getName()+" " +
+ " "+credits+" " +
+ " " +
+
+ "" +
+ " "+SpeciesGridFields.PROPERTIES.getName()+" " +
+ " "+propertiesHtml+" " +
+ " " +
+
+ "
";
+ return table;
+
+ }
+
+}
\ No newline at end of file
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
new file mode 100644
index 0000000..df1798c
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/TaxonomyRowTable.java
@@ -0,0 +1,406 @@
+package org.gcube.portlets.user.speciesdiscovery.server;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.log4j.Logger;
+import org.gcube.application.framework.core.session.ASLSession;
+import org.gcube.data.spd.model.products.TaxonomyItem;
+import org.gcube.portlets.user.speciesdiscovery.client.util.TaxonomyGridField;
+import org.gcube.portlets.user.speciesdiscovery.server.asl.SessionUtil;
+import org.gcube.portlets.user.speciesdiscovery.server.persistence.DaoSession;
+import org.gcube.portlets.user.speciesdiscovery.server.persistence.dao.TaxonomyRowPersistence;
+import org.gcube.portlets.user.speciesdiscovery.server.service.SpeciesService;
+import org.gcube.portlets.user.speciesdiscovery.server.service.TaxonomyItemConverter;
+import org.gcube.portlets.user.speciesdiscovery.server.stream.CloseableIterator;
+import org.gcube.portlets.user.speciesdiscovery.server.stream.StreamExtend;
+import org.gcube.portlets.user.speciesdiscovery.shared.CommonName;
+import org.gcube.portlets.user.speciesdiscovery.shared.ItemParameter;
+import org.gcube.portlets.user.speciesdiscovery.shared.SearchServiceException;
+import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
+
+
+/**
+ *
+ * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
+ * @Sep 6, 2013
+ *
+ */
+public class TaxonomyRowTable extends HttpServlet {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 9157876104914505028L;
+
+ /**
+ *
+ */
+ public static final String TEXT_HTML = "text/html";
+
+
+ protected Logger logger = Logger.getLogger(TaxonomyRowTable.class);
+
+
+ protected ASLSession getASLSession(HttpServletRequest req)
+ {
+ return SessionUtil.getAslSession(req.getSession());
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ retrieveTaxonomyRowAsHtmlTable(req, resp);
+ }
+
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ retrieveTaxonomyRowAsHtmlTable(req, resp);
+ }
+
+
+ /**
+ * @param req
+ * @param resp
+ * @throws IOException
+ */
+ private void retrieveTaxonomyRowAsHtmlTable(HttpServletRequest req, HttpServletResponse resp) {
+
+ String taxonomyServiceRowID = "";
+ resp.setContentType(TEXT_HTML);
+ resp.setCharacterEncoding("UTF-8");
+
+ TaxonomyRow row = null;
+ PrintWriter out = null;
+
+ try {
+ out = resp.getWriter();
+ // get parameters
+ taxonomyServiceRowID = req.getParameter("oid");
+
+ ASLSession aslSession = getASLSession(req);
+
+ //IS VALID RR ID?
+ if(taxonomyServiceRowID==null || taxonomyServiceRowID.isEmpty()){
+ out.println(error("Parameter oid not found"));
+ }else{
+
+ logger.trace("doGet found oid "+taxonomyServiceRowID);
+
+ try {
+
+ TaxonomyRowPersistence persistence = SessionUtil.getCurrentEJBTaxonomyItem(aslSession);
+
+ if(persistence==null){
+
+ logger.trace("TaxonomyRowPersistence not found in session, creating it");
+ persistence = new TaxonomyRowPersistence(DaoSession.getEntityManagerFactory(aslSession));
+ }
+
+ CriteriaBuilder queryBuilder = persistence.getCriteriaBuilder();
+ CriteriaQuery cq = queryBuilder.createQuery();
+ Predicate pr1 = queryBuilder.equal(persistence.rootFrom(cq).get(TaxonomyRow.SERVICE_ID_FIELD), taxonomyServiceRowID);
+ cq.where(pr1);
+
+ Iterator iterator = persistence.executeCriteriaQuery(cq).iterator();
+
+ while(iterator.hasNext()){
+ row = iterator.next();
+ break;
+ }
+
+ if(row==null){
+
+ logger.trace("Taxonomy Row with id "+taxonomyServiceRowID+" not found in database");
+
+ row = findingTaxonomyInCaches(taxonomyServiceRowID, getASLSession(req));
+
+ if(row!=null){
+ logger.trace("Taxonomy Row with id "+taxonomyServiceRowID+" found into hash map caches");
+ //ROW was found into database or by service
+ logger.trace("converting taxonomy row to html table");
+ String table = getHTMLTableForTaxonomy(row);
+
+ logger.trace("table for ResultRowPersistence is empty? "+table.isEmpty());
+ out.println(table);
+ out.close();
+ return;
+ }else
+ logger.trace("Taxonomy Row with id "+taxonomyServiceRowID+" doesn't found into hash map caches");
+
+
+ logger.trace("Tentative recovering taxonomy with id "+taxonomyServiceRowID+" from service");
+
+ SpeciesService service = getSpeciesService(req);
+
+ StreamExtend streamIds = new StreamExtend(Arrays.asList(taxonomyServiceRowID).iterator());
+
+ CloseableIterator streamIterator = service.retrieveTaxonomyById(streamIds);
+
+ TaxonomyItemConverter taxonomyItemConverter = new TaxonomyItemConverter(aslSession);
+
+ // int i = 1;
+ while (streamIterator.hasNext()) {
+ TaxonomyItem tax = streamIterator.next();
+ logger.trace("Taxonomy with id "+taxonomyServiceRowID+" found on service, converting");
+ // from TaxonomyItem to LightTaxonomyRow
+ row = taxonomyItemConverter.convert(tax);
+ break;
+ }
+
+ streamIterator.close();
+
+ if(row==null){
+ out.println(error("Sorry, taxonomy with "+taxonomyServiceRowID+" doesn't found in service"));
+ out.close();
+ return;
+ }
+ }
+
+ //ROW was found into database or by service
+ logger.trace("converting taxonomy row to html table");
+ String table = getHTMLTableForTaxonomy(row);
+
+ logger.trace("table for ResultRowPersistence is empty? "+table.isEmpty());
+ out.println(table);
+
+ } catch (Exception e) {
+
+ logger.error("Error in TaxonomyRowTable servlet ",e);
+ throw new Exception("Error in ResultRowTable servlet ", e);
+ }
+ }
+
+ out.close(); //CLOSE STREAM
+
+ }catch (Exception e) {
+ String error = "Sorry an error occurred when creating the table for taxonomy row with id: "+taxonomyServiceRowID;
+
+ if(out==null){
+ try{
+ out = resp.getWriter();
+ } catch (IOException e1) {
+ logger.error("Error on get Writer into servlet ",e);
+ }
+ }
+ out.println(error);
+ out.close(); //CLOSE STREAM
+ }
+
+ }
+
+
+
+
+
+ protected TaxonomyRow findingTaxonomyInCaches(String taxonomyServiceRowID, ASLSession session){
+
+ HashMap hashChildrenTaxa = SessionUtil.getHashMapChildrenTaxonomyCache(session);
+
+
+ if(hashChildrenTaxa!=null){
+ logger.trace("Finding Taxonomy Row with id "+taxonomyServiceRowID+" into hash map children");
+ TaxonomyRow row = hashChildrenTaxa.get(taxonomyServiceRowID);
+
+ if(row!=null){
+ logger.trace("Taxonomy Row with id "+taxonomyServiceRowID+" found into hash map children");
+ return row;
+ }
+ }
+
+ hashChildrenTaxa = SessionUtil.getHashMapSynonymsTaxonomyCache(session);
+
+ if(hashChildrenTaxa!=null){
+ logger.trace("Finding Taxonomy Row with id "+taxonomyServiceRowID+" into hash map synonyms");
+ TaxonomyRow row = hashChildrenTaxa.get(taxonomyServiceRowID);
+
+ if(row!=null){
+ logger.trace("Taxonomy Row with id "+taxonomyServiceRowID+" found into hash map synonyms");
+ return row;
+ }
+ }
+
+ hashChildrenTaxa = SessionUtil.getHashMapTaxonomyByIdsCache(session);
+
+ if(hashChildrenTaxa!=null){
+ logger.trace("Finding Taxonomy Row with id "+taxonomyServiceRowID+" into hash map ByIds");
+ TaxonomyRow row = hashChildrenTaxa.get(taxonomyServiceRowID);
+
+ if(row!=null){
+ logger.trace("Taxonomy Row with id "+taxonomyServiceRowID+" found into hash map ByIds");
+ return row;
+ }
+ }
+
+ return null;
+ }
+
+
+
+ protected SpeciesService getSpeciesService(HttpServletRequest req) throws SearchServiceException
+ {
+ try {
+ ASLSession session = getASLSession(req);
+ return SessionUtil.getService(session);
+ } catch (Exception e) {
+ e.printStackTrace();
+ logger.error("An error occurred when contacting the species service", e);
+ // System.out.println("An error occurred retrieving the service" +e);
+ throw new SearchServiceException("contacting the species service.");
+ }
+ }
+
+ public String error(String message){
+ String errorPage = "";
+ errorPage +=("Error: "+message+"
");
+ return errorPage;
+ }
+
+
+ public String getHTMLTableForTaxonomy(TaxonomyRow row){
+
+ //Init values
+ String dataProviderName = "";
+ String dataSetCitation= "";
+ String matchingAccordionTo= "";
+ String rank= "";
+// String matchingCredits= "";
+
+ String statusName = "";
+ String dateModified = "";
+ String statusRemark = "";
+
+ String author = "";
+ String lsid = "";
+ String credits = "";
+
+ String propertiesHtml = "";
+
+ if(row.getDataProviderName()!=null) dataProviderName = row.getDataProviderName();
+ if(row.getStatusName()!=null) statusName = row.getStatusName();
+ if(row.getDateModified()!=null) dateModified = row.getDateModified();
+
+ if(row.getDataSetCitation()!=null) dataSetCitation = row.getDataSetCitation();
+ if(row.getRank()!=null) rank = row.getRank();
+ if(row.getAccordingTo()!=null) matchingAccordionTo = row.getAccordingTo();
+
+ if(row.getStatusRemarks()!=null) statusRemark = row.getStatusRemarks();
+
+ if(row.getAuthor()!=null) author = row.getAuthor();
+
+ if(row.getLsid()!=null) lsid = row.getLsid();
+
+ if(row.getCredits()!=null) credits = row.getCredits();
+
+
+ //BUILD TABLES PROPERTIES
+ if(row.getProperties()!=null){
+
+ List hashProperties = row.getProperties();
+ Collections.sort(hashProperties, ItemParameter.COMPARATOR);
+
+ propertiesHtml+="";
+
+ for (ItemParameter itemParameter : hashProperties) {
+
+ propertiesHtml+=
+ "" +
+ " "+itemParameter.getKey()+" " +
+ " "+itemParameter.getValue()+" " +
+ " ";
+ }
+
+ propertiesHtml+="
";
+ }
+
+
+ //Create list common name
+ String commonNames = "";
+
+ if(row.getCommonNames()!=null){
+ for (CommonName comName : row.getCommonNames()) {
+ commonNames+= ""+comName.getName()+" " +" ("+comName.getLanguage()+") - ";
+ }
+ }
+
+
+ String table = "";
+
+// if(isNewTab)
+ table+=
+ "" +
+ " "+TaxonomyGridField.COMMON_NAMES.getName()+" (Language) " +
+ " "+commonNames+" " +
+ " ";
+
+
+// table+="" +
+// " "+TaxonomyGridField.STATUSREFNAME.getName()+" " +
+// " "+statusName+" " +
+// " " +
+// "" +
+// " "+TaxonomyGridField.STATUS_REMARKS.getName()+" " +
+// " "+statusRemark+" " +
+// " " +
+
+
+ table +="" +
+ " "+TaxonomyGridField.DATASOURCE.getName()+" " +
+ " "+dataProviderName+" " +
+ " " +
+ "" +
+ " "+TaxonomyGridField.DATEMODIFIED.getName()+" " +
+ " "+dateModified+" " +
+ " " +
+ "" +
+ " "+TaxonomyGridField.MATCHING_RANK.getName()+" " +
+ " "+rank+" " +
+ " " +
+ "" +
+ " "+TaxonomyGridField.CITATION.getName()+" " +
+ " "+dataSetCitation+" " +
+ " " +
+ "" +
+ " "+TaxonomyGridField.LSID.getName()+" " +
+ " "+lsid+" " +
+ " " +
+ "" +
+ " "+TaxonomyGridField.AUTHOR.getName()+" " +
+ " "+author+" " +
+ " " +
+ "" +
+ " "+TaxonomyGridField.CREDITS.getName()+" " +
+ " "+credits+" " +
+ " " +
+
+ "" +
+ " "+TaxonomyGridField.PROPERTIES.getName()+" " +
+ " "+propertiesHtml+" " +
+ " " +
+
+ "
";
+
+ //DEBUG
+// System.out.println("Table: "+table);
+
+ return table;
+
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/TaxonomySearchServiceImpl.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/TaxonomySearchServiceImpl.java
index 6e50935..fdd5bef 100644
--- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/TaxonomySearchServiceImpl.java
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/TaxonomySearchServiceImpl.java
@@ -64,6 +64,7 @@ import org.gcube.portlets.user.speciesdiscovery.server.stream.StreamExtend;
import org.gcube.portlets.user.speciesdiscovery.server.stream.aggregation.FieldAggregator;
import org.gcube.portlets.user.speciesdiscovery.server.stream.aggregation.TaxonomyClassificationAggregator;
import org.gcube.portlets.user.speciesdiscovery.server.util.DateUtil;
+import org.gcube.portlets.user.speciesdiscovery.server.util.GetWorkspaceUtil;
import org.gcube.portlets.user.speciesdiscovery.server.util.QueryUtil;
import org.gcube.portlets.user.speciesdiscovery.shared.CommonName;
import org.gcube.portlets.user.speciesdiscovery.shared.DataSource;
@@ -74,6 +75,7 @@ import org.gcube.portlets.user.speciesdiscovery.shared.FetchingElement;
import org.gcube.portlets.user.speciesdiscovery.shared.ItemParameter;
import org.gcube.portlets.user.speciesdiscovery.shared.JobOccurrencesModel;
import org.gcube.portlets.user.speciesdiscovery.shared.JobTaxonomyModel;
+import org.gcube.portlets.user.speciesdiscovery.shared.LightTaxonomyRow;
import org.gcube.portlets.user.speciesdiscovery.shared.MainTaxonomicRankEnum;
import org.gcube.portlets.user.speciesdiscovery.shared.Occurrence;
import org.gcube.portlets.user.speciesdiscovery.shared.OccurrenceBatch;
@@ -92,8 +94,12 @@ import org.gcube.portlets.user.speciesdiscovery.shared.SearchType;
import org.gcube.portlets.user.speciesdiscovery.shared.Taxon;
import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyJob;
import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
+import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterCommonNameDataSourceForResultRow;
+import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterCommonNameDataSourceForTaxonomyRow;
import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterStructuresForResultRow;
import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterStructuresForTaxonomyRow;
+import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ManagerClusterCommonNameDataSourceForResultRow;
+import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ManagerClusterCommonNameDataSourceForTaxonomyRow;
import org.gcube.portlets.user.speciesdiscovery.shared.filter.ResultFilter;
import org.gcube.portlets.user.speciesdiscovery.shared.util.NormalizeString;
@@ -360,7 +366,8 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
resultRow.setProperties(null);
}
- System.out.println("################### ResultRow parents: "+resultRow.getParents());
+ //FOR DEBUG
+// System.out.println("################### ResultRow parents: "+resultRow.getParents());
chunk.add(resultRow);
@@ -1245,27 +1252,47 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
@Override
- public ArrayList loadListChildByParentId(String parentId) throws Exception {
+ public ArrayList loadListChildrenByParentId(String parentId) throws Exception {
logger.trace("Load List Children By ParentId: " + parentId);
//FOR DEBUG
// System.out.println("Load List Children By ParentId: " + parentId);
- ArrayList listTaxonomyRow = new ArrayList();
+ ArrayList listLightTaxonomyRow = new ArrayList();
+
+ if(parentId==null || parentId.isEmpty()){
+ logger.warn("parentId is null or empty ");
+ return listLightTaxonomyRow;
+ }
+
try {
SpeciesService taxonomyService = getSpeciesService();
CloseableIterator streamIterator = taxonomyService.getTaxonChildrenByParentId(parentId);
+ ASLSession session = getASLSession();
TaxonomyItemConverter converter = new TaxonomyItemConverter(getASLSession());
-
- int i = 0;
+
+ Map mapChildren = SessionUtil.getHashMapChildrenTaxonomyCache(session);
+
+ if(mapChildren==null){
+ logger.trace("Cache taxa children doesn't exists into session, creating..");
+ mapChildren = new HashMap();
+ }
+// int i = 0;
while (streamIterator.hasNext()) {
TaxonomyItem tax = streamIterator.next();
- // from TaxonomyItem to TaxonomyRow
- TaxonomyRow taxonomyRow = converter.convert(tax);
- listTaxonomyRow.add(taxonomyRow);
- logger.trace(i + ") taxonomyRow: " + taxonomyRow);
- i++;
+
+ TaxonomyRow taxonomy = converter.convert(tax);
+
+ if(mapChildren.get(taxonomy.getServiceId())==null){
+ logger.trace("Taxonomy with service id: "+taxonomy.getServiceId()+" doesn't exists into Map Children, adding..");
+ mapChildren.put(taxonomy.getServiceId(),taxonomy);
+ }
+
+ LightTaxonomyRow lightTaxRow = ClusterStructuresForTaxonomyRow.convetTaxonomyRowToLigthTaxonomyRow(taxonomy);
+ listLightTaxonomyRow.add(lightTaxRow);
}
+ SessionUtil.setHashMapChildrenTaxonomyCache(session, mapChildren);
+
streamIterator.close();
} catch (Exception e) {
@@ -1273,9 +1300,9 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
throw new Exception("Error on loadListChildByParentId", e);
}
- logger.trace("Return list children By ParentId - size"+ listTaxonomyRow.size());
+ logger.trace("Return list children By ParentId "+parentId+"- with size: "+ listLightTaxonomyRow.size());
- return listTaxonomyRow;
+ return listLightTaxonomyRow;
}
@Override
@@ -1540,7 +1567,7 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
InputStream inputStream = taxonomyService.getTaxonomyJobFileById(jobIdentifier);
if(inputStream!=null){
- Workspace workspace = org.gcube.portlets.user.speciesdiscovery.server.util.GetWorkspaceUtil.getWorskspace(getASLSession());
+ Workspace workspace = GetWorkspaceUtil.getWorskspace(getASLSession());
logger.trace("input stream is not null");
// System.out.println("input stream is not null");
@@ -1580,7 +1607,7 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
InputStream inputStream = taxonomyService.getTaxonomyJobErrorFileById(jobIdentifier);
if(inputStream!=null){
- Workspace workspace = org.gcube.portlets.user.speciesdiscovery.server.util.GetWorkspaceUtil.getWorskspace(getASLSession());
+ Workspace workspace = GetWorkspaceUtil.getWorskspace(getASLSession());
logger.trace("input stream is not null");
// System.out.println("input stream is not null");
@@ -1607,12 +1634,12 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
}
@Override
- public List retrieveTaxonomyByIds(List ids) throws Exception{
+ public List retrieveTaxonomyByIds(List ids) throws Exception{
logger.trace("retrieveTaxonomyByIds ids size: " + ids.size());
// System.out.println("retrieveTaxonomyByIds ids size: " + ids.size() + " first id " + ids.get(0));
- List listTaxonomyRow = new ArrayList();
+ List listLightTaxonomyRow = new ArrayList();
try {
SpeciesService taxonomyService = getSpeciesService();
@@ -1620,19 +1647,32 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
CloseableIterator streamIterator = taxonomyService.retrieveTaxonomyById(convert);
- TaxonomyItemConverter taxonomyItemConverter = new TaxonomyItemConverter(getASLSession());
+ ASLSession session = getASLSession();
+ TaxonomyItemConverter taxonomyItemConverter = new TaxonomyItemConverter(session);
+
+ Map mapTaxonomyIds = SessionUtil.getHashMapTaxonomyByIdsCache(session);
+
+ if(mapTaxonomyIds==null){
+ logger.trace("Cache taxa ByIds doesn't exists into session, creating..");
+ mapTaxonomyIds = new HashMap();
+ }
- int i = 1;
while (streamIterator.hasNext()) {
TaxonomyItem tax = streamIterator.next();
- // from TaxonomyItem to TaxonomyRow
- TaxonomyRow taxonomyRow = taxonomyItemConverter.convert(tax);
- listTaxonomyRow.add(taxonomyRow);
- logger.trace(i + ") retrieveTaxonomyById: " + taxonomyRow);
-// System.out.println(i + ") retrieveTaxonomyById: " + taxonomyRow);
- i++;
+
+ TaxonomyRow taxonomy = taxonomyItemConverter.convert(tax);
+
+ if(mapTaxonomyIds.get(taxonomy.getServiceId())==null){
+ logger.trace("Taxonomy with service id: "+taxonomy.getServiceId()+" doesn't exists into Map Taxonomy Ids, adding..");
+ mapTaxonomyIds.put(taxonomy.getServiceId(),taxonomy);
+ }
+
+ LightTaxonomyRow lightTaxRow = ClusterStructuresForTaxonomyRow.convetTaxonomyRowToLigthTaxonomyRow(taxonomy);
+ listLightTaxonomyRow.add(lightTaxRow);
}
+ SessionUtil.setHashMapTaxonomyByIdsCache(session, mapTaxonomyIds);
+
streamIterator.close();
} catch (Exception e) {
@@ -1642,47 +1682,60 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
// throw new Exception(e.getMessage());
}
- return listTaxonomyRow;
+ return listLightTaxonomyRow;
}
@Override
- public List retrieveSynonymsByRefId(String refId) throws Exception{
+ public List retrieveSynonymsByRefId(String refId) throws Exception{
logger.trace("retrieveSynonymsById id: " + refId);
//FOR DEBUG
// System.out.println("retrieveSynonymsById id: " + refId);
- List listTaxonomyRow = new ArrayList();
+ List listLightTaxonomyRow = new ArrayList();
try {
SpeciesService taxonomyService = getSpeciesService();
CloseableIterator streamIterator = taxonomyService.retrieveSynonymsById(refId);
+ ASLSession session = getASLSession();
TaxonomyItemConverter taxonomyItemConverter = new TaxonomyItemConverter(getASLSession());
- int i = 1;
+ Map mapSysnosyms = SessionUtil.getHashMapSynonymsTaxonomyCache(getASLSession());
+
+ if(mapSysnosyms==null){
+ logger.trace("Cache synonyms doesn't exists into session, creating..");
+ mapSysnosyms = new HashMap();
+ }
+
+// int i = 1;
while (streamIterator.hasNext()) {
TaxonomyItem tax = streamIterator.next();
- // from TaxonomyItem to TaxonomyRow
- TaxonomyRow taxonomyRow = taxonomyItemConverter.convert(tax);
- listTaxonomyRow.add(taxonomyRow);
- logger.trace(i + ") retrieveSynonymsById: " + taxonomyRow);
-// System.out.println(i + ") retrieveSynonymsById: " + taxonomyRow);
- i++;
+
+ TaxonomyRow taxonomy = taxonomyItemConverter.convert(tax);
+
+ if(mapSysnosyms.get(taxonomy.getServiceId())==null){
+ logger.trace("Taxonomy with service id: "+taxonomy.getServiceId()+" doesn't exists into Map Synonyms, adding..");
+ mapSysnosyms.put(taxonomy.getServiceId(),taxonomy);
+ }
+
+ LightTaxonomyRow lightTaxRow = ClusterStructuresForTaxonomyRow.convetTaxonomyRowToLigthTaxonomyRow(taxonomy);
+ listLightTaxonomyRow.add(lightTaxRow);
}
+ SessionUtil.setHashMapSynonymsTaxonomyCache(session, mapSysnosyms);
+
streamIterator.close();
} catch (Exception e) {
e.printStackTrace();
logger.error("An error retrieve synonyms by Id",e);
-// throw new Exception(e.getMessage());
}
- return listTaxonomyRow;
+ return listLightTaxonomyRow;
}
@@ -1909,7 +1962,7 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
InputStream inputStream = taxonomyService.getOccurrenceJobFileById(jobModel.getJobIdentifier());
if(inputStream!=null){
- Workspace workspace = org.gcube.portlets.user.speciesdiscovery.server.util.GetWorkspaceUtil.getWorskspace(getASLSession());
+ Workspace workspace = GetWorkspaceUtil.getWorskspace(getASLSession());
logger.trace("input stream is not null");
// System.out.println("input stream is not null");
@@ -1960,7 +2013,7 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
InputStream inputStream = taxonomyService.getOccurrenceJobErrorFileById(jobModel.getJobIdentifier());
if(inputStream!=null){
- Workspace workspace = org.gcube.portlets.user.speciesdiscovery.server.util.GetWorkspaceUtil.getWorskspace(getASLSession());
+ Workspace workspace = GetWorkspaceUtil.getWorskspace(getASLSession());
logger.trace("input stream is not null");
// System.out.println("input stream is not null");
@@ -2018,16 +2071,60 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
boolean isReduced = false;
int totalRow = countSelectedRow;
+ ASLSession session = getASLSession();
+ HashMap hashCluster = SessionUtil.getCurrentClusterCommonNameForResultRow(session);
+
+ //Reset cluster for common name
+ if(hashCluster!=null)
+ SessionUtil.setCurrentClusterCommonNameForResultRow(session, null);
+
+
//LIMIT NUMBER OF ITEMS TO ConstantsSpeciesDiscovery.LIMIT_ITEM_DETAILS
- if(countSelectedRow>ConstantsSpeciesDiscovery.LIMIT_ITEM_DETAILS)
- countSelectedRow = ConstantsSpeciesDiscovery.LIMIT_ITEM_DETAILS;
+ if(countSelectedRow>ConstantsSpeciesDiscovery.RESULT_ROW_LIMIT_ITEM_DETAILS)
+ countSelectedRow = ConstantsSpeciesDiscovery.RESULT_ROW_LIMIT_ITEM_DETAILS;
ResultFilter filter = new ResultFilter(false, true, true);
SearchResult searchResults = getSearchResultRows(0, countSelectedRow, filter, true);
- return new ClusterStructuresForResultRow(searchResults,isReduced, totalRow);
+ ClusterStructuresForResultRow cluster = new ClusterStructuresForResultRow(searchResults,isReduced, totalRow);
+
+ //TODO USE THREAD?
+ ManagerClusterCommonNameDataSourceForResultRow manager = new ManagerClusterCommonNameDataSourceForResultRow(cluster.getHashClusterScientificNameResultRowServiceID(), cluster.getHashResult());
+
+ SessionUtil.setCurrentClusterCommonNameForResultRow(getASLSession(), manager.getHashClusterCommonNameDataSource());
+
+ //THIS OBJECT IS NOT USED ON CLIENT
+ cluster.setHashResult(null);
+
+ return cluster;
+
+ }
+
+ @Override
+ public ClusterCommonNameDataSourceForResultRow loadClusterCommonNameForResultRowByScientificName(String scientificName) throws Exception {
+
+ logger.trace("loadClusterCommonNameForResultRowByScientificName for scientific name: "+scientificName);
+
+ HashMap hashCluster = SessionUtil.getCurrentClusterCommonNameForResultRow(getASLSession());
+
+
+ if(hashCluster==null){
+ logger.warn("Error in loadClusterCommonNameForResultRowByScientificName, hashCluster was not found in session");
+ return null;
+
+ }
+
+ ClusterCommonNameDataSourceForResultRow cluster = hashCluster.get(scientificName);
+
+
+ if(cluster==null){
+ logger.warn("Error in loadClusterCommonNameForResultRowByScientificName, cluster was not found in session");
+ return null;
+ }
+
+ return cluster;
}
@@ -2081,9 +2178,35 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
boolean isReduced = false;
int totalRow = countSelectedRow;
+
+ ASLSession session = getASLSession();
+ HashMap hashCluster = SessionUtil.getCurrentClusterCommonNameForTaxonomyRow(session);
+
+ //Reset cluster for common name
+ if(hashCluster!=null)
+ SessionUtil.setCurrentClusterCommonNameForTaxonomyRow(session, null);
+
+
+ HashMap mapOldChildren = SessionUtil.getHashMapChildrenTaxonomyCache(session);
+ //Reset list children to last clustering
+ if(mapOldChildren!=null)
+ SessionUtil.setHashMapChildrenTaxonomyCache(session, null);
+
+ HashMap mapSynonyms = SessionUtil.getHashMapSynonymsTaxonomyCache(session);
+ //Reset list synonyms to last clustering
+ if(mapSynonyms!=null)
+ SessionUtil.setHashMapSynonymsTaxonomyCache(session, null);
+
+ HashMap mapTaxonomyIds = SessionUtil.getHashMapTaxonomyByIdsCache(session);
+ //Reset list synonyms to last clustering
+ if(mapTaxonomyIds!=null)
+ SessionUtil.setHashMapTaxonomyByIdsCache(session, null);
+
+
+
//LIMIT NUMBER OF ITEMS TO ConstantsSpeciesDiscovery.LIMIT_ITEM_DETAILS
- if(countSelectedRow>ConstantsSpeciesDiscovery.LIMIT_ITEM_DETAILS){
- countSelectedRow = ConstantsSpeciesDiscovery.LIMIT_ITEM_DETAILS;
+ if(countSelectedRow>ConstantsSpeciesDiscovery.TAXONOMY_LIMIT_ITEMS_DETAILS){
+ countSelectedRow = ConstantsSpeciesDiscovery.TAXONOMY_LIMIT_ITEMS_DETAILS;
isReduced = true;
}
@@ -2091,7 +2214,18 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
SearchResult searchResults = getSearchTaxonomyRow(0, countSelectedRow, filter, true);
- return new ClusterStructuresForTaxonomyRow(searchResults, isReduced, totalRow);
+ ClusterStructuresForTaxonomyRow cluster = new ClusterStructuresForTaxonomyRow(searchResults,isReduced, totalRow);
+
+
+ //TODO USE THREAD?
+ ManagerClusterCommonNameDataSourceForTaxonomyRow manager = new ManagerClusterCommonNameDataSourceForTaxonomyRow(cluster.getHashClusterScientificNameTaxonomyRowServiceID(), cluster.getHashResult());
+
+ SessionUtil.setCurrentClusterCommonNameForTaxonomyRow(session, manager.getHashClusterCommonNameDataSource());
+
+ //THIS OBJECT IS NOT USED ON CLIENT
+ cluster.setHashResult(null);
+
+ return cluster;
}
@@ -2167,4 +2301,33 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
ASLSession session = getASLSession();
return SessionUtil.getCurrentQuery(session);
}
+
+ /* (non-Javadoc)
+ * @see org.gcube.portlets.user.speciesdiscovery.client.rpc.TaxonomySearchService#loadClusterCommonNameForTaxonomyRowByScientificName(java.lang.String)
+ */
+ @Override
+ public ClusterCommonNameDataSourceForTaxonomyRow loadClusterCommonNameForTaxonomyRowByScientificName(String scientificName) {
+
+ System.out.println("loadClusterCommonNameForTaxonomyRowByScientificName for scientific name: "+scientificName);
+ logger.trace("loadClusterCommonNameForTaxonomyRowByScientificName for scientific name: "+scientificName);
+
+ HashMap hashCluster = SessionUtil.getCurrentClusterCommonNameForTaxonomyRow(getASLSession());
+
+
+ if(hashCluster==null){
+ logger.warn("Error in loadClusterCommonNameForTaxonomyRowByScientificName, hashCluster was not found in session");
+ return null;
+
+ }
+
+ ClusterCommonNameDataSourceForTaxonomyRow cluster = hashCluster.get(scientificName);
+
+
+ if(cluster==null){
+ logger.warn("Error in loadClusterCommonNameForTaxonomyRowByScientificName, cluster was not found in session");
+ return null;
+ }
+
+ return cluster;
+ }
}
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/asl/SessionUtil.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/asl/SessionUtil.java
index cc8cf2d..a46f66e 100644
--- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/asl/SessionUtil.java
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/asl/SessionUtil.java
@@ -3,6 +3,9 @@
*/
package org.gcube.portlets.user.speciesdiscovery.server.asl;
+import java.util.HashMap;
+import java.util.Map;
+
import javax.persistence.EntityManagerFactory;
import javax.servlet.http.HttpSession;
@@ -19,6 +22,9 @@ import org.gcube.portlets.user.speciesdiscovery.server.service.SpeciesService;
import org.gcube.portlets.user.speciesdiscovery.server.session.FetchingSession;
import org.gcube.portlets.user.speciesdiscovery.shared.FetchingElement;
import org.gcube.portlets.user.speciesdiscovery.shared.Occurrence;
+import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
+import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterCommonNameDataSourceForResultRow;
+import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterCommonNameDataSourceForTaxonomyRow;
/**
*
@@ -40,6 +46,11 @@ public class SessionUtil {
public static final String EJB_OCCURRENCES_JOB = "EJB_OCCURRENCES_JOB";
public static final String EJB_TAXONOMY_JOB = "EJB_TAXONOMY_JOB";
public static final String CURRENT_SPD_QUERY = "CURRENT_SPD_QUERY";
+ private static final String CLUSTER_COMMONNAME_FOR_RESULTROW = "CLUSTER_COMMONNAME_FOR_RESULTROW";
+ private static final String CLUSTER_COMMONNAME_FOR_TAXONOMYROW = "CLUSTER_COMMONNAME_FOR_TAXONOMYROW";
+ private static final String CACHE_HASH_MAP_CHILDREN_TAXONOMY = "CACHE_HASH_MAP_CHILDREN_TAXONOMY";
+ private static final String CACHE_HASH_MAP_SYNONYMS_TAXONOMY = "CACHE_HASH_MAP_SYNONYMS_TAXONOMY";
+ private static final String CACHE_HASH_MAP_TAXONOMYID_TAXONOMY = "CACHE_HASH_MAP_TAXONOMYID_TAXONOMY";
protected static Logger logger = Logger.getLogger(SessionUtil.class);
@@ -110,7 +121,7 @@ public class SessionUtil {
httpSession.setAttribute(USERNAME_ATTRIBUTE, user);
ASLSession session = SessionManager.getInstance().getASLSession(sessionID, user);
session.setScope(scope);
-
+
logger.warn("TaxonomySearchServiceImpl STARTING IN TEST MODE - NO USER FOUND");
logger.warn("Created fake Asl session for user "+user + " with scope "+scope);
// session.setScope("/gcube/devsec");
@@ -196,4 +207,95 @@ public class SessionUtil {
return (String) aslSession.getAttribute(CURRENT_SPD_QUERY);
}
+
+ /**
+ * @param hashClusterCommonNameDataSource
+ */
+ public static void setCurrentClusterCommonNameForResultRow(ASLSession session, HashMap hashClusterCommonNameDataSource) {
+ session.setAttribute(CLUSTER_COMMONNAME_FOR_RESULTROW, hashClusterCommonNameDataSource);
+
+ }
+
+ /**
+ * @param hashClusterCommonNameDataSource
+ * @return
+ */
+ public static HashMap getCurrentClusterCommonNameForResultRow(ASLSession session) {
+ return (HashMap) session.getAttribute(CLUSTER_COMMONNAME_FOR_RESULTROW);
+
+ }
+
+
+ /**
+ * @param hashClusterCommonNameDataSource
+ */
+ public static void setCurrentClusterCommonNameForTaxonomyRow(ASLSession session, HashMap hashClusterCommonNameDataSource) {
+ session.setAttribute(CLUSTER_COMMONNAME_FOR_TAXONOMYROW, hashClusterCommonNameDataSource);
+
+ }
+
+ /**
+ * @param hashClusterCommonNameDataSource
+ * @return
+ */
+ public static HashMap getCurrentClusterCommonNameForTaxonomyRow(ASLSession session) {
+ return (HashMap) session.getAttribute(CLUSTER_COMMONNAME_FOR_TAXONOMYROW);
+
+ }
+
+ /**
+ * @return
+ *
+ */
+ public static HashMap getHashMapChildrenTaxonomyCache(ASLSession session) {
+ return (HashMap) session.getAttribute(CACHE_HASH_MAP_CHILDREN_TAXONOMY);
+
+ }
+
+ /**
+ * @return
+ *
+ */
+ public static void setHashMapChildrenTaxonomyCache(ASLSession session, Map list) {
+ session.setAttribute(CACHE_HASH_MAP_CHILDREN_TAXONOMY, list);
+
+ }
+
+
+ /**
+ * @return
+ *
+ */
+ public static HashMap getHashMapSynonymsTaxonomyCache(ASLSession session) {
+ return (HashMap) session.getAttribute(CACHE_HASH_MAP_SYNONYMS_TAXONOMY);
+
+ }
+
+ /**
+ * @return
+ *
+ */
+ public static void setHashMapSynonymsTaxonomyCache(ASLSession session, Map list) {
+ session.setAttribute(CACHE_HASH_MAP_SYNONYMS_TAXONOMY, list);
+
+ }
+
+
+ /**
+ * @return
+ *
+ */
+ public static HashMap getHashMapTaxonomyByIdsCache(ASLSession session) {
+ return (HashMap) session.getAttribute(CACHE_HASH_MAP_TAXONOMYID_TAXONOMY);
+
+ }
+
+ /**
+ * @return
+ *
+ */
+ public static void setHashMapTaxonomyByIdsCache(ASLSession session, Map list) {
+ session.setAttribute(CACHE_HASH_MAP_TAXONOMYID_TAXONOMY, list);
+
+ }
}
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/persistence/AbstractDaoBuffer.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/persistence/AbstractDaoBuffer.java
index e2515f6..7b9d718 100644
--- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/persistence/AbstractDaoBuffer.java
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/persistence/AbstractDaoBuffer.java
@@ -72,5 +72,4 @@ public abstract class AbstractDaoBuffer implements Fe
public List getList(Map filterANDMap, int startIndex, int offset) throws Exception{
return dao.getList(filterANDMap, startIndex, offset);
}
-
}
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/persistence/AbstractSelectableDaoBuffer.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/persistence/AbstractSelectableDaoBuffer.java
index d90f1c3..83e36c4 100644
--- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/persistence/AbstractSelectableDaoBuffer.java
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/persistence/AbstractSelectableDaoBuffer.java
@@ -74,5 +74,4 @@ public abstract class AbstractSelectableDaoBuffer e
return getSelected().size();
}
-
}
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/persistence/DaoSession.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/persistence/DaoSession.java
index f1440c7..2533add 100644
--- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/persistence/DaoSession.java
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/persistence/DaoSession.java
@@ -26,7 +26,7 @@ public class DaoSession {
protected static final String PROPERTY_CATALINA_HOME = "catalina.home";
protected static final String CATALINA_HOME = "CATALINA_HOME";
- protected static final String TEMP_H2DBSPECIES_H2 = "temp/h2dbspecies/h2";
+ protected static final String PERSISTENCE_H2DBSPECIES_H2 = "persistence/h2dbspecies/h2";
public static Logger logger = Logger.getLogger(DaoSession.class);
private static final String JDBCDRIVER = "jdbc:h2:";
@@ -63,7 +63,7 @@ public class DaoSession {
String username = session.getUsername();
String scope = session.getScopeName();
- return JDBCDRIVER +getTomcatFolder()+TEMP_H2DBSPECIES_H2+getUsernameScopeValue(username,scope)+";create=true";
+ return JDBCDRIVER +getTomcatFolder()+PERSISTENCE_H2DBSPECIES_H2+getUsernameScopeValue(username,scope)+";create=true";
}
@@ -145,7 +145,7 @@ public class DaoSession {
logger.error("error on get connection url "+e, e);
String username = session.getUsername();
String scope = session.getScopeName();
- properties.put("javax.persistence.jdbc.url", JDBCDRIVER+"/temp/h2dbspecies/h2"+getUsernameScopeValue(username,scope)+";create=true");
+ properties.put("javax.persistence.jdbc.url", JDBCDRIVER+getTomcatFolder()+"/temp/h2dbspecies/h2"+getUsernameScopeValue(username,scope)+";create=true");
}
//emf = Persistence.createEntityManagerFactory("jpablogPUnit");
return Persistence.createEntityManagerFactory("SPD_PERSISTENCE_FACTORY",properties);
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/persistence/ResultRowBuffer.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/persistence/ResultRowBuffer.java
index a253403..d28ef1c 100644
--- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/persistence/ResultRowBuffer.java
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/persistence/ResultRowBuffer.java
@@ -52,8 +52,7 @@ public class ResultRowBuffer extends AbstractSelectableDaoBuffer impl
@Override
public void add(ResultRow row) throws Exception{
//FOR DEBUG
-// logger.trace("Add item "+ row.getServiceId());
- logger.trace("Add item "+ row.getId() + " service id: " +row.getServiceId());
+// logger.trace("Add item "+ row.getId() + " service id: " +row.getServiceId());
super.add(row);
}
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/persistence/TaxonomyRowBuffer.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/persistence/TaxonomyRowBuffer.java
index 3941f51..d6d7a09 100644
--- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/persistence/TaxonomyRowBuffer.java
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/persistence/TaxonomyRowBuffer.java
@@ -46,8 +46,7 @@ public class TaxonomyRowBuffer extends AbstractSelectableDaoBuffer
public void add(TaxonomyRow row) throws Exception
{
//DEBUG
- logger.trace("Add item "+ row.getId() + " service id: " +row.getServiceId());
-// logger.trace("Add item "+ row);
+// logger.trace("Add item "+ row.getId() + " service id: " +row.getServiceId());
super.add(row);
}
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 6e0227a..ec85e5e 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
@@ -12,6 +12,7 @@ import org.gcube.portlets.user.speciesdiscovery.server.TaxonomySearchServiceImpl
import org.gcube.portlets.user.speciesdiscovery.server.stream.Converter;
import org.gcube.portlets.user.speciesdiscovery.shared.CommonName;
import org.gcube.portlets.user.speciesdiscovery.shared.ItemParameter;
+import org.gcube.portlets.user.speciesdiscovery.shared.LightTaxonomyRow;
import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
import org.gcube.portlets.user.speciesdiscovery.shared.util.NormalizeString;
@@ -53,6 +54,87 @@ public class TaxonomyItemConverter implements Converter0)
+ taxonomy.setParentID(""+taxonomy.getParents().get(0).getId());
+
+ return taxonomy;
+ }
+
+
+ protected LightTaxonomyRow createLightTaxonomyRow(TaxonomyItem input) throws Exception{
+
+ LightTaxonomyRow tax = new LightTaxonomyRow(id++);
+
+
+ if(input.getId()!=null){
+ tax.setServiceId(input.getId());
+ }
+
+ if(input.getProvider()!=null && !input.getProvider().isEmpty()){
+ tax.setDataProviderId(input.getProvider());
+ tax.setDataProviderName(input.getProvider());
+ }else{
+ tax.setDataProviderId(ConstantsSpeciesDiscovery.NOT_FOUND);
+ tax.setDataProviderName(ConstantsSpeciesDiscovery.NOT_FOUND);
+ }
+
+
+ if(input.getRank()!=null && !input.getRank().isEmpty()){
+ tax.setRank(NormalizeString.lowerCaseUpFirstChar(input.getRank()));
+ }else{
+ tax.setRank(ConstantsSpeciesDiscovery.NOT_FOUND);
+ }
+
+ if(input.getScientificName()!=null && !input.getScientificName().isEmpty()){
+ tax.setName(input.getScientificName());
+ }else{
+ tax.setName(ConstantsSpeciesDiscovery.NOT_FOUND);
+ }
+
+ if(input.getStatus()!=null){
+
+ if(input.getStatus().getRefId()!=null && !input.getStatus().getRefId().isEmpty()){
+ tax.setStatusRefId(input.getStatus().getRefId());
+ }else{
+ tax.setStatusRefId("");
+ }
+
+
+ if(input.getStatus().getStatusAsString()!=null && !input.getStatus().getStatusAsString().isEmpty()){
+ tax.setStatusRemarks(input.getStatus().getStatusAsString());
+ }else{
+ tax.setStatusRemarks(ConstantsSpeciesDiscovery.NOT_FOUND);
+ }
+
+ if(input.getStatus().getStatus()!=null){
+
+ if(input.getStatus().getStatus().name()!=null && !input.getStatus().getStatus().name().isEmpty()){
+ tax.setStatusName(input.getStatus().getStatus().name());
+ }else{
+ tax.setStatusName(ConstantsSpeciesDiscovery.NOT_FOUND);
+ }
+
+ }
+
+ }
+ return tax;
+ }
+
protected TaxonomyRow createTaxonomyRow(TaxonomyItem input) throws Exception{
@@ -177,6 +259,43 @@ public class TaxonomyItemConverter implements Converter listTaxonomy = taxon.getParents();
+
+ for (LightTaxonomyRow taxonomyRow : listTaxonomy) {
+
+ if(taxonomyRow.getRank().compareToIgnoreCase(rank)==0)
+ return taxonomyRow.getName();
+ }
+
+ return TaxonomySearchServiceImpl.TAXONOMYUNKNOWN;
+ }
+
+
+ protected List convertParentsLightTaxonomy(TaxonomyItem taxon) throws Exception
+ {
+ if (taxon == null) return null;
+ List listTaxonomy = new ArrayList();
+ TaxonomyItem parent = taxon.getParent();
+
+ int i=0;
+
+ while(parent!=null){
+ LightTaxonomyRow row = createLightTaxonomyRow(parent);
+ row.setParent(true);
+ row.setParentIndex(i++);
+
+// System.out.println("Insert Taxonomy parent id: "+row.getId() + ", row.getParentIndex: "+row.getParentIndex());
+
+ listTaxonomy.add(row);
+ parent = parent.getParent();
+ }
+
+ return listTaxonomy;
+ }
+
+
protected List convertParentsTaxonomy(TaxonomyItem taxon) throws Exception
{
if (taxon == null) return null;
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/util/StorageUtil.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/util/StorageUtil.java
index c40570a..7c23ae8 100644
--- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/util/StorageUtil.java
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/server/util/StorageUtil.java
@@ -14,8 +14,8 @@ import org.gcube.contentmanager.storageclient.model.protocol.smp.SMPURLConnectio
public class StorageUtil {
- protected Logger logger = Logger.getLogger(StorageUtil.class);
-
+ protected static Logger logger = Logger.getLogger(StorageUtil.class);
+
public static InputStream getInputStreamByStorageClient(String url) throws Exception {
Handler.activateProtocol();
@@ -40,11 +40,13 @@ public class StorageUtil {
InputStream is=uc.getInputStream();
return is;
}
-
-
+
public static void main(String[] args) throws Exception {
InputStream is = getInputStreamByStorageClient("smp:/51e1065ee4b0a159b8c25cc8?5ezvFfBOLqb2cBxvyAbVnOhbxBCSqhv+Z4BC5NS/+OwS5RYBeaUL5FS9eDyNubiTI4vSpggUgPA+jm9rQxwbisfhkOW/m6l2IYG9BKb8AEJFLgVvG3FJTk0+4xV9iM/hNQvChZjoJZna0aPXkHN4Eg==");
+
+
+
}
}
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/JobTaxonomyModel.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/JobTaxonomyModel.java
index 55a6573..a491841 100644
--- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/JobTaxonomyModel.java
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/JobTaxonomyModel.java
@@ -129,8 +129,8 @@ public class JobTaxonomyModel implements Serializable {
return submitTime;
}
- public void setSubmitTime(Date submitTime) {
- this.submitTime = submitTime;
+ public void setSubmitTime(Date startTime) {
+ this.submitTime = startTime;
}
public Date getEndTime() {
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/LightTaxonomyRow.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/LightTaxonomyRow.java
new file mode 100644
index 0000000..5735ae5
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/LightTaxonomyRow.java
@@ -0,0 +1,253 @@
+/**
+ *
+ */
+package org.gcube.portlets.user.speciesdiscovery.shared;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ *
+ * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
+ *
+ */
+public class LightTaxonomyRow implements FetchingElement, Serializable, Comparable {
+
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3303399965998066897L;
+
+ public final static String ID_FIELD = "id";
+ public final static String DATAPROVIDER_NAME = "dataProviderName";
+ public static final String DATAPROVIDER_ID = "dataProviderId";
+ public final static String RANK = "rank";
+ public static final String NAME = "name";
+ public static final String STATUSREFID = "statusRefId";
+ public static final String STATUSNAME = "statusName";
+ public final static String PARENT_ID = "parentID";
+ public final static String IS_PARENT = "isParent";
+ public final static String SERVICE_ID_FIELD = "serviceIdField";
+ public final static String STATUS_REMARKS = "statusRemarks";
+
+ public static final String BASE_TAXON_VALUE = "baseTaxonValue";
+
+ protected String name;
+ protected String serviceIdField;
+ protected String dataProviderId;
+ protected String dataProviderName;
+ protected String rank;
+ private String statusRefId;
+ private String statusName;
+
+ protected String baseTaxonValue;
+ protected String statusRemarks;
+
+ private boolean isParent = false;
+
+ protected List parents;
+
+ //USED FOR PARENT
+ protected String parentID;
+ protected int id;
+ protected int parentIndex = -1;
+
+ protected LightTaxonomyRow() {
+
+
+ }
+
+ /**
+ * @param id
+ */
+ public LightTaxonomyRow(int id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the id
+ */
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @return the id
+ */
+ public String getIdToString() {
+ return id+"";
+ }
+
+ public void setBaseTaxonValue(String taxonomyValue) {
+ this.baseTaxonValue = taxonomyValue;
+
+ }
+
+ public String getBaseTaxonValue() {
+ return baseTaxonValue;
+ }
+
+ /**
+ * @return the dataProviderId
+ */
+ public String getDataProviderId() {
+ return dataProviderId;
+ }
+
+ /**
+ * @param dataProviderId
+ * the dataProviderId to set
+ */
+ public void setDataProviderId(String dataProviderId) {
+ this.dataProviderId = dataProviderId;
+ }
+
+ /**
+ * @return the dataProviderName
+ */
+ public String getDataProviderName() {
+ return dataProviderName;
+ }
+
+ /**
+ * @param dataProviderName
+ * the dataProviderName to set
+ */
+ public void setDataProviderName(String dataProviderName) {
+ this.dataProviderName = dataProviderName;
+ }
+
+ public String getRank() {
+ return rank;
+ }
+
+ public void setRank(String rank) {
+ this.rank = rank;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setStatusRefId(String statusRefId) {
+ this.statusRefId = statusRefId;
+
+ }
+
+ public void setStatusName(String statusName) {
+ this.statusName = statusName;
+
+ }
+
+ public void setParent(List parent) {
+ this.parents = parent;
+ }
+
+ public List getParents() {
+ Collections.sort(parents);
+ return parents;
+ }
+
+ public String getStatusRefId() {
+ return statusRefId;
+ }
+
+ public String getStatusName() {
+ return statusName;
+ }
+
+ public String getTaxonId() {
+ return ""+id;
+ }
+
+ public String getParentID() {
+ return parentID;
+ }
+
+ public void setParentID(String parentID) {
+ this.parentID = parentID;
+ }
+
+ public String getServiceId() {
+ return serviceIdField;
+ }
+
+ public void setServiceId(String serviceIdField) {
+ this.serviceIdField = serviceIdField;
+ }
+
+ public String getStatusRemarks() {
+ return statusRemarks;
+ }
+
+ public void setStatusRemarks(String statusRemarks) {
+ this.statusRemarks = statusRemarks;
+ }
+
+ public boolean isParent() {
+ return isParent;
+ }
+
+ public void setParent(boolean isParent) {
+ this.isParent = isParent;
+ }
+
+ public int getParentIndex() {
+ return parentIndex;
+ }
+
+ public void setParentIndex(int parentIndex) {
+ this.parentIndex = parentIndex;
+ }
+
+ /* (non-Javadoc)
+ * Comparable on insertion order
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public int compareTo(LightTaxonomyRow o) {
+ return parentIndex - o.getParentIndex();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("MinimalTaxonomyRow [id=");
+ builder.append(id);
+ builder.append(", name=");
+ builder.append(name);
+ builder.append(", serviceIdField=");
+ builder.append(serviceIdField);
+ builder.append(", dataProviderId=");
+ builder.append(dataProviderId);
+ builder.append(", dataProviderName=");
+ builder.append(dataProviderName);
+ builder.append(", rank=");
+ builder.append(rank);
+ builder.append(", statusRefId=");
+ builder.append(statusRefId);
+ builder.append(", statusName=");
+ builder.append(statusName);
+ builder.append(", baseTaxonValue=");
+ builder.append(baseTaxonValue);
+ builder.append(", statusRemarks=");
+ builder.append(statusRemarks);
+ builder.append(", isParent=");
+ builder.append(isParent);
+ builder.append(", parents=");
+ builder.append(parents);
+ builder.append(", parentID=");
+ builder.append(parentID);
+ builder.append(", parentIndex=");
+ builder.append(parentIndex);
+ builder.append("]");
+ return builder.toString();
+ }
+
+}
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ClusterCommonNameDataSource.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ClusterCommonNameDataSource.java
index 11c9551..0edeb32 100644
--- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ClusterCommonNameDataSource.java
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ClusterCommonNameDataSource.java
@@ -11,13 +11,28 @@ import org.gcube.portlets.user.speciesdiscovery.shared.ResultRow;
import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
import org.gcube.portlets.user.speciesdiscovery.shared.util.NormalizeString;
+/**
+ *
+ * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
+ * @Sep 5, 2013
+ *
+ * @param
+ */
+//@Entity
public class ClusterCommonNameDataSource implements Serializable{
/**
*
*/
+
+
private static final long serialVersionUID = -4602671242562941238L;
+// @Id
+// @GeneratedValue(strategy = GenerationType.IDENTITY)
+// private int internalId;
+
+
private HashMap> hashMapCommonNameDataSources = new HashMap>();
private ArrayList listDataSourcesFound = new ArrayList();
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ClusterCommonNameDataSourceForResultRow.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ClusterCommonNameDataSourceForResultRow.java
new file mode 100644
index 0000000..acef75a
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ClusterCommonNameDataSourceForResultRow.java
@@ -0,0 +1,78 @@
+/**
+ *
+ */
+package org.gcube.portlets.user.speciesdiscovery.shared.cluster;
+
+import java.io.Serializable;
+
+import org.gcube.portlets.user.speciesdiscovery.shared.ResultRow;
+
+/**
+ * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
+ * @Sep 5, 2013
+ *
+ */
+//@Entity
+public class ClusterCommonNameDataSourceForResultRow implements Serializable{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -7566939414748687391L;
+
+// @Id
+// @GeneratedValue(strategy = GenerationType.IDENTITY)
+// private int internalId;
+
+ private String scientificName; //IS THE KEY
+
+ private ClusterCommonNameDataSource cluster = new ClusterCommonNameDataSource(); //NEW CLUSTER
+
+
+ public ClusterCommonNameDataSourceForResultRow(){}
+
+ /**
+ * @param scientificName
+ * @param cluster
+ */
+ public ClusterCommonNameDataSourceForResultRow(String scientificName, ClusterCommonNameDataSource cluster) {
+ super();
+ this.scientificName = scientificName;
+ this.cluster = cluster;
+ }
+
+ public String getScientificName() {
+ return scientificName;
+ }
+
+ public void setScientificName(String scientificName) {
+ this.scientificName = scientificName;
+ }
+
+ public ClusterCommonNameDataSource getCluster() {
+ return cluster;
+ }
+
+ public void setCluster(ClusterCommonNameDataSource cluster) {
+ this.cluster = cluster;
+ }
+
+
+// public int getInternalId() {
+// return internalId;
+// }
+
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("ClusterCommonNameDataSourceForResultRow [scientificName=");
+ builder.append(scientificName);
+ builder.append(", cluster=");
+ builder.append(cluster);
+ builder.append("]");
+ return builder.toString();
+ }
+
+
+}
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ClusterCommonNameDataSourceForTaxonomyRow.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ClusterCommonNameDataSourceForTaxonomyRow.java
new file mode 100644
index 0000000..d4ef15f
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ClusterCommonNameDataSourceForTaxonomyRow.java
@@ -0,0 +1,67 @@
+/**
+ *
+ */
+package org.gcube.portlets.user.speciesdiscovery.shared.cluster;
+
+import java.io.Serializable;
+
+import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
+
+/**
+ *
+ * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
+ * @Sep 18, 2013
+ *
+ */
+public class ClusterCommonNameDataSourceForTaxonomyRow implements Serializable{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 769286880968121045L;
+
+ private String scientificName; //IS THE KEY
+
+ private ClusterCommonNameDataSource cluster = new ClusterCommonNameDataSource(); //NEW CLUSTER
+
+
+ public ClusterCommonNameDataSourceForTaxonomyRow(){}
+
+ /**
+ * @param scientificName
+ * @param cluster
+ */
+ public ClusterCommonNameDataSourceForTaxonomyRow(String scientificName, ClusterCommonNameDataSource cluster) {
+ super();
+ this.scientificName = scientificName;
+ this.cluster = cluster;
+ }
+
+ public String getScientificName() {
+ return scientificName;
+ }
+
+ public void setScientificName(String scientificName) {
+ this.scientificName = scientificName;
+ }
+
+ public ClusterCommonNameDataSource getCluster() {
+ return cluster;
+ }
+
+ public void setCluster(ClusterCommonNameDataSource cluster) {
+ this.cluster = cluster;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("ClusterCommonNameDataSourceForTaxonomyRow [scientificName=");
+ builder.append(scientificName);
+ builder.append(", cluster=");
+ builder.append(cluster);
+ builder.append("]");
+ return builder.toString();
+ }
+
+}
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ClusterStructuresForResultRow.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ClusterStructuresForResultRow.java
index 8baf2c2..4e82ffd 100644
--- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ClusterStructuresForResultRow.java
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ClusterStructuresForResultRow.java
@@ -22,51 +22,36 @@ public class ClusterStructuresForResultRow implements Serializable{
*
*/
private static final long serialVersionUID = 1205113606387863736L;
-
- private ArrayList listResultRowID;
- private Map hashResult = new HashMap();
+ private ArrayList listResultRowServiceID;
private ArrayList listFoundDataSources = new ArrayList();
- private HashMap> hashClusterCommonNamesDataSources = new HashMap>(); //HASH scientific name - cluster
- private HashMap> hashScientificNameResultRowID = new HashMap>(); //HASH scientific name - result row ID
+ private HashMap> hashScientificNameResultRowServiceID = new HashMap>(); //HASH scientific name - result row service ID
private boolean isReduced;
- private int totalRow;
+ private int allResultRowSize;
+ private int resultSize;
+
+ private Map hashResult = new HashMap(); //HASH result row service ID - result row
+
public ClusterStructuresForResultRow(){}
public ClusterStructuresForResultRow(SearchResult result, boolean isReduced, int totalRow){
- //Create hashMap ID - resultRow
+ //Create hashMap service ID - resultRow
for (ResultRow row : result.getResults()) {
- hashResult.put(row.getIdToString(), row);
+// hashResult.put(row.getIdToString(), row);
+
+ hashResult.put(row.getServiceId(), row);
}
-
+//
this.isReduced = isReduced;
- this.totalRow = totalRow;
+
+ this.allResultRowSize = totalRow;
+ this.resultSize = result.getResults().size();
createStructures(result.getResults());
- createStructuresForCommonName();
+// createStructuresForCommonName();
}
- public void createStructuresForCommonName(){
-
- if(hashScientificNameResultRowID.size()>0){
-
- for(String scientificName : hashScientificNameResultRowID.keySet()){
-
- ArrayList listResultRowServiceID = hashScientificNameResultRowID.get(scientificName); //get RR serviceID
-
- ClusterCommonNameDataSource cluster = new ClusterCommonNameDataSource(); //NEW CLUSTER
-
- for(int i=0; i arrayListRR){
@@ -84,13 +69,13 @@ public class ClusterStructuresForResultRow implements Serializable{
else
keyScientificName = NormalizeString.lowerCaseUpFirstChar(keyScientificName);
- if(hashScientificNameResultRowID.get(keyScientificName)==null){
+ if(hashScientificNameResultRowServiceID.get(keyScientificName)==null){
- listResultRowID = new ArrayList(); //USED FOR CLUSTER COMMON NAMES
+ listResultRowServiceID = new ArrayList(); //USED FOR CLUSTER COMMON NAMES
}
else{
- listResultRowID = hashScientificNameResultRowID.get(keyScientificName); //USED FOR CLUSTER COMMON NAMES
+ listResultRowServiceID = hashScientificNameResultRowServiceID.get(keyScientificName); //USED FOR CLUSTER COMMON NAMES
}
}
@@ -102,31 +87,30 @@ public class ClusterStructuresForResultRow implements Serializable{
if(listFoundDataSources.indexOf(dataSource)==-1)
listFoundDataSources.add(dataSource);
- listResultRowID.add(row.getIdToString()+"");
+// listResultRowServiceID.add(row.getIdToString()+"");
+
+ listResultRowServiceID.add(row.getServiceId());
+
//USED FOR CLUSTER COMMON NAMES
- hashScientificNameResultRowID.put(keyScientificName, listResultRowID);
+ hashScientificNameResultRowServiceID.put(keyScientificName, listResultRowServiceID);
}
}
}
- public HashMap> getHashClusterScientificNameResultRowID() {
- return hashScientificNameResultRowID;
+ public HashMap> getHashClusterScientificNameResultRowServiceID() {
+ return hashScientificNameResultRowServiceID;
}
public List getListFoundDataSources() {
return listFoundDataSources;
}
- public HashMap> getHashClusterCommonNamesDataSources() {
- return hashClusterCommonNamesDataSources;
+ public ArrayList getListResultRowID() {
+ return listResultRowServiceID;
}
- public List getResult() {
- return new ArrayList(hashResult.values());
- }
-
- public ResultRow getResultRowByRowID(String key) {
- return hashResult.get(key);
+ public void setListResultRowID(ArrayList listResultRowID) {
+ this.listResultRowServiceID = listResultRowID;
}
public boolean isReduced() {
@@ -137,12 +121,31 @@ public class ClusterStructuresForResultRow implements Serializable{
this.isReduced = isReduced;
}
- public int getTotalRow() {
- return totalRow;
+ public int getAllResultRowSize() {
+ return allResultRowSize;
}
- public void setTotalRow(int totalRow) {
- this.totalRow = totalRow;
+ public void setAllResultRowSize(int allResultRowSize) {
+ this.allResultRowSize = allResultRowSize;
}
+ public int getResultSize() {
+ return resultSize;
+ }
+
+ public void setResultSize(int resultSize) {
+ this.resultSize = resultSize;
+ }
+
+ public void setListFoundDataSources(ArrayList listFoundDataSources) {
+ this.listFoundDataSources = listFoundDataSources;
+ }
+
+ public Map getHashResult() {
+ return hashResult;
+ }
+
+ public void setHashResult(Map hashResult) {
+ this.hashResult = hashResult;
+ }
}
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ClusterStructuresForTaxonomyRow.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ClusterStructuresForTaxonomyRow.java
index bd28a49..b75d32f 100644
--- a/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ClusterStructuresForTaxonomyRow.java
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ClusterStructuresForTaxonomyRow.java
@@ -3,8 +3,10 @@ package org.gcube.portlets.user.speciesdiscovery.shared.cluster;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import org.gcube.portlets.user.speciesdiscovery.shared.LightTaxonomyRow;
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResult;
import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
import org.gcube.portlets.user.speciesdiscovery.shared.util.NormalizeString;
@@ -23,63 +25,62 @@ public class ClusterStructuresForTaxonomyRow implements Serializable{
*/
private static final long serialVersionUID = 2680552140187511057L;
- private Map hashResult = new HashMap();
- private HashMap> hashClusterCommonNamesDataSources = new HashMap>();
- private HashMap> hashClusterScientificNameTaxonomyRowID = new HashMap>(); //HASH scientific name - taxonomy row ID
+ //USED ON CLIENT
+ private Map hashLightResult = new HashMap();
+
+ private HashMap> hashClusterScientificNameTaxonomyRowServiceID = new HashMap>(); //HASH scientific name - taxonomy row service ID
private ArrayList listFoundDataSources = new ArrayList();
- private ArrayList listTaxonomyRowID;
+ private ArrayList listTaxonomyRowServiceID;
private boolean isReduced;
private int totalRow;
+
+ //USED ON SERVER FOR CLUSERING ON COMMON NAMES
+ private Map hashResult = new HashMap();
public ClusterStructuresForTaxonomyRow(){
}
public ClusterStructuresForTaxonomyRow(SearchResult result, boolean isReduced, int totalRow) {
- //Create hashMap row ID - resultRow
- for (TaxonomyRow row : result.getResults()) {
- hashResult.put(row.getIdToString(), row);
+ //Create hashMap row service ID - resultRow
+ for (TaxonomyRow row : result.getResults()){
-// int parentsSize = row.getParents().size();
-//
-// //FILL LIST PARENT FOR PARENTS ITEM
-// for(int i=parentsSize-1; i>=0; i--){
-// TaxonomyRow taxon = row.getParents().get(i);
-// List sublistParents = new ArrayList();
-//// for (TaxonomyRow taxon : taxonomy.getParents()) {
-//
-// if(i+1!=parentsSize)
-// sublistParents.addAll(row.getParents().subList(i+1, parentsSize));
-//
-// taxon.setParent(sublistParents);
-//
-////// DEBUG
-//// System.out.println("parent of "+taxon.getName());
-//// for (TaxonomyRow tax : sublistParents) {
-//// System.out.println("taxon.getName() " + tax.getName());
-//// }
-//// System.out.println("\n\n");
-// }
+ LightTaxonomyRow lr = convetTaxonomyRowToLigthTaxonomyRow(row);
- //DEBUG
-// System.out.println("principal "+row.getName() + " id " + row.getServiceId()+" parents");
-// for (TaxonomyRow tax : row.getParents()) {
-// System.out.println("taxon.getName() " + tax.getName());
-// System.out.println("parent of "+tax.getName());
-// for (TaxonomyRow taxon : tax.getParents()) {
-// System.out.println("taxon.getName() " + taxon.getName());
-// }
-// System.out.println("\n\n");
-// }
+ List parents = new ArrayList();
+ for (TaxonomyRow txParent: row.getParents()) {
+ parents.add(convetTaxonomyRowToLigthTaxonomyRow(txParent));
+ }
+
+ lr.setParent(parents);
+ hashLightResult.put(row.getServiceId(), lr);
+ hashResult.put(row.getServiceId(), row);
}
this.isReduced = isReduced;
this.totalRow = totalRow;
createStructures(result.getResults());
- createStructuresForCommonName();
+ }
+
+ public static LightTaxonomyRow convetTaxonomyRowToLigthTaxonomyRow(TaxonomyRow row){
+
+ LightTaxonomyRow lr = new LightTaxonomyRow(row.getId());
+ lr.setServiceId(row.getServiceId());
+ lr.setBaseTaxonValue(row.getBaseTaxonValue());
+ lr.setDataProviderId(row.getDataProviderId());
+ lr.setDataProviderName(row.getDataProviderName());
+ lr.setName(row.getName());
+ lr.setParentID(row.getParentID());
+ lr.setRank(row.getRank());
+ lr.setParentIndex(row.getParentIndex());
+ lr.setStatusName(row.getStatusName());
+ lr.setStatusRefId(row.getStatusRefId());
+ lr.setStatusRemarks(row.getStatusRemarks());
+
+ return lr;
}
public void createStructures(ArrayList arrayListTax){
@@ -100,69 +101,41 @@ public class ClusterStructuresForTaxonomyRow implements Serializable{
else
keyScientificName = NormalizeString.lowerCaseUpFirstChar(keyScientificName);
- if(hashClusterScientificNameTaxonomyRowID.get(keyScientificName)==null){
+ if(hashClusterScientificNameTaxonomyRowServiceID.get(keyScientificName)==null){
- listTaxonomyRowID = new ArrayList(); //USED FOR CLUSTER COMMON NAMES
+ listTaxonomyRowServiceID = new ArrayList(); //USED FOR CLUSTER COMMON NAMES
}
else{
- listTaxonomyRowID = hashClusterScientificNameTaxonomyRowID.get(keyScientificName); //USED FOR CLUSTER COMMON NAMES
+ listTaxonomyRowServiceID = hashClusterScientificNameTaxonomyRowServiceID.get(keyScientificName); //USED FOR CLUSTER COMMON NAMES
}
if(listFoundDataSources.indexOf(dataSource)==-1)
listFoundDataSources.add(dataSource);
- listTaxonomyRowID.add(row.getIdToString());
- hashClusterScientificNameTaxonomyRowID.put(keyScientificName, listTaxonomyRowID);
+ listTaxonomyRowServiceID.add(row.getServiceId());
+ hashClusterScientificNameTaxonomyRowServiceID.put(keyScientificName, listTaxonomyRowServiceID);
}
}
}
-
- public void createStructuresForCommonName(){
-
- if(hashClusterScientificNameTaxonomyRowID.size()>0){
-
- for(String scientificName : hashClusterScientificNameTaxonomyRowID.keySet()){
-
- ArrayList listTaxonomyRowID = hashClusterScientificNameTaxonomyRowID.get(scientificName);
-
- ClusterCommonNameDataSource cluster = new ClusterCommonNameDataSource(); //NEW CLUSTER
-
- for(int i=0; i getListFoundDataSources() {
return listFoundDataSources;
}
- public HashMap> getHashClusterScientificNameTaxonomyRowID() {
- return hashClusterScientificNameTaxonomyRowID;
+ public HashMap> getHashClusterScientificNameTaxonomyRowServiceID() {
+ return hashClusterScientificNameTaxonomyRowServiceID;
}
- public HashMap> getHashClusterCommonNamesDataSources() {
- return hashClusterCommonNamesDataSources;
- }
-
- public ArrayList getResult() {
- return new ArrayList(hashResult.values());
+ public ArrayList getResult() {
+ return new ArrayList(hashLightResult.values());
}
- public TaxonomyRow getTaxonomyRowByKey(String key) {
- return hashResult.get(key);
+ public LightTaxonomyRow getLightTaxonomyRowByKey(String key) {
+ return hashLightResult.get(key);
}
public boolean isReduced() {
@@ -181,4 +154,16 @@ public class ClusterStructuresForTaxonomyRow implements Serializable{
this.totalRow = totalRow;
}
+ public Map getHashLightResult() {
+ return hashLightResult;
+ }
+
+ public Map getHashResult() {
+ return hashResult;
+ }
+
+ public void setHashResult(Map hashResult) {
+ this.hashResult = hashResult;
+ }
+
}
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ManagerClusterCommonNameDataSourceForResultRow.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ManagerClusterCommonNameDataSourceForResultRow.java
new file mode 100644
index 0000000..9b025d6
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ManagerClusterCommonNameDataSourceForResultRow.java
@@ -0,0 +1,110 @@
+/**
+ *
+ */
+package org.gcube.portlets.user.speciesdiscovery.shared.cluster;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.gcube.portlets.user.speciesdiscovery.shared.ResultRow;
+
+/**
+ * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
+ * @Sep 5, 2013
+ *
+ * This class calculates the cluster for common names / data sources: hashClusterCommonNameDataSource
+ */
+public class ManagerClusterCommonNameDataSourceForResultRow {
+
+
+ private HashMap> hashScientificNameResultRowServiceID = new HashMap>(); //HASH scientific name - result row service ID
+ private Map hashResult = new HashMap();
+
+ private HashMap hashClusterCommonNameDataSource = new HashMap(); //HASH scientific name - cluster
+
+
+ /**
+ * @param hashScientificNameResultRowID
+ * @param hashClusterCommonNameDataSource
+ * @param hashResult
+ * @throws Exception
+ */
+ public ManagerClusterCommonNameDataSourceForResultRow(HashMap> hashScientificNameResultRowID, Map hashResult) throws Exception {
+
+ this.hashScientificNameResultRowServiceID = hashScientificNameResultRowID;
+ this.hashResult = hashResult;
+
+ createStructuresForCommonName();
+
+ }
+
+
+ public void createStructuresForCommonName() throws Exception{
+
+ if(hashScientificNameResultRowServiceID.size()>0){
+
+ for(String scientificName : hashScientificNameResultRowServiceID.keySet()){
+
+ ArrayList listResultRowServiceID = hashScientificNameResultRowServiceID.get(scientificName); //get RR serviceID
+
+ ClusterCommonNameDataSource cluster = new ClusterCommonNameDataSource(); //NEW CLUSTER
+
+ for(int i=0; i> getHashScientificNameResultRowID() {
+ return hashScientificNameResultRowServiceID;
+ }
+
+
+ public void setHashScientificNameResultRowID(
+ HashMap> hashScientificNameResultRowID) {
+ this.hashScientificNameResultRowServiceID = hashScientificNameResultRowID;
+ }
+
+
+ public HashMap getHashClusterCommonNameDataSource() {
+ return hashClusterCommonNameDataSource;
+ }
+
+
+ public void setHashClusterCommonNameDataSource(
+ HashMap hashClusterCommonNameDataSource) {
+ this.hashClusterCommonNameDataSource = hashClusterCommonNameDataSource;
+ }
+
+
+ public Map getHashResult() {
+ return hashResult;
+ }
+
+
+ public void setHashResult(Map hashResult) {
+ this.hashResult = hashResult;
+ }
+
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("ManagerClusterCommonNameDataSource [hashScientificNameResultRowID=");
+ builder.append(hashScientificNameResultRowServiceID);
+ builder.append(", hashClusterCommonNameDataSource=");
+ builder.append(hashClusterCommonNameDataSource);
+ builder.append(", hashResult=");
+ builder.append(hashResult);
+ builder.append("]");
+ return builder.toString();
+ }
+
+}
diff --git a/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ManagerClusterCommonNameDataSourceForTaxonomyRow.java b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ManagerClusterCommonNameDataSourceForTaxonomyRow.java
new file mode 100644
index 0000000..6ff81bb
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/speciesdiscovery/shared/cluster/ManagerClusterCommonNameDataSourceForTaxonomyRow.java
@@ -0,0 +1,113 @@
+/**
+ *
+ */
+package org.gcube.portlets.user.speciesdiscovery.shared.cluster;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
+
+/**
+ *
+ * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
+ * @Sep 18, 2013
+ *
+ * This class calculates the cluster for common names / data sources: hashClusterCommonNameDataSource
+ *
+ */
+public class ManagerClusterCommonNameDataSourceForTaxonomyRow {
+
+
+ private HashMap> hashScientificNameTaxonomyRowServiceID = new HashMap>(); //HASH scientific name - taxonomy row service ID
+ private Map hashResult = new HashMap();
+
+ private HashMap hashClusterCommonNameDataSource = new HashMap(); //HASH scientific name - cluster
+
+
+ /**
+ * @param hashScientificNameResultRowServiceID
+ * @param hashClusterCommonNameDataSource
+ * @param hashResult
+ * @throws Exception
+ */
+ public ManagerClusterCommonNameDataSourceForTaxonomyRow(HashMap> hashScientificNameResultRowServiceID, Map hashResult) throws Exception {
+
+ this.hashScientificNameTaxonomyRowServiceID = hashScientificNameResultRowServiceID;
+ this.hashResult = hashResult;
+
+ createStructuresForCommonName();
+
+ }
+
+
+ public void createStructuresForCommonName() throws Exception{
+
+
+ if(hashScientificNameTaxonomyRowServiceID.size()>0){
+
+ for(String scientificName : hashScientificNameTaxonomyRowServiceID.keySet()){
+
+ ArrayList listTaxonomyRowServiceID = hashScientificNameTaxonomyRowServiceID.get(scientificName);
+
+ ClusterCommonNameDataSource cluster = new ClusterCommonNameDataSource(); //NEW CLUSTER
+
+ for(int i=0; i> getHashScientificNameResultRowID() {
+ return hashScientificNameTaxonomyRowServiceID;
+ }
+
+
+ public void setHashScientificNameResultRowID(
+ HashMap> hashScientificNameResultRowID) {
+ this.hashScientificNameTaxonomyRowServiceID = hashScientificNameResultRowID;
+ }
+
+
+ public HashMap getHashClusterCommonNameDataSource() {
+ return hashClusterCommonNameDataSource;
+ }
+
+
+ public void setHashClusterCommonNameDataSource(HashMap hashClusterCommonNameDataSource) {
+ this.hashClusterCommonNameDataSource = hashClusterCommonNameDataSource;
+ }
+
+
+ public Map getHashResult() {
+ return hashResult;
+ }
+
+
+ public void setHashResult(Map hashResult) {
+ this.hashResult = hashResult;
+ }
+
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("ManagerClusterCommonNameDataSourceForTaxonomyRow [hashScientificNameTaxonomyRowServiceID=");
+ builder.append(hashScientificNameTaxonomyRowServiceID);
+ builder.append(", hashResult=");
+ builder.append(hashResult);
+ builder.append(", hashClusterCommonNameDataSource=");
+ builder.append(hashClusterCommonNameDataSource);
+ builder.append("]");
+ return builder.toString();
+ }
+
+}