Projet merged with private version at revision 83976
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/speciesdiscovery@83979 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
cf85009708
commit
c234e93a19
|
@ -17,7 +17,7 @@ Authors
|
|||
|
||||
Version and Release Date
|
||||
------------------------
|
||||
v. 3.3.0
|
||||
v. 3.5.0
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
@ -1,4 +1,16 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset
|
||||
component="org.gcube.application.speciesmanagement.speciesdiscovery.3-5-0"
|
||||
date="24-10-2013">
|
||||
<Change>Portlet updated to support GWT 2.5.1</Change>
|
||||
<Change>Ticket 2224: was implemented</Change>
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.application.speciesmanagement.speciesdiscovery.3-4-0"
|
||||
date="06-09-2013">
|
||||
<Change>Enhancements on GUI of SPD portlet was realized (view last query, new expand button are available)</Change>
|
||||
<Change>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".</Change>
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.application.speciesmanagement.speciesdiscovery.3-3-0"
|
||||
date="09-07-2013">
|
||||
|
|
16
pom.xml
16
pom.xml
|
@ -67,6 +67,14 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sencha.gxt</groupId>
|
||||
<artifactId>gxt</artifactId>
|
||||
<version>2.2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- SPD service dependecies -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.data.spd</groupId>
|
||||
|
@ -185,12 +193,10 @@
|
|||
<!-- <scope>provided</scope> -->
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- ACCESS-LOGGER -->
|
||||
<dependency>
|
||||
<groupId>com.sencha.gxt</groupId>
|
||||
<artifactId>gxt</artifactId>
|
||||
<version>2.2.5</version>
|
||||
<scope>provided</scope>
|
||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>accesslogger</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- FWS -->
|
||||
|
|
|
@ -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";
|
||||
|
||||
}
|
||||
|
|
|
@ -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<JobOccurrencesModel> 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<JobTaxonomyModel>() {
|
||||
|
||||
|
|
|
@ -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<TaxonomyRow> 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<ArrayList<TaxonomyRow>>() {
|
||||
SpeciesDiscovery.taxonomySearchService.loadListChildrenByParentId(taxonomyItem.getServiceId(), new AsyncCallback<ArrayList<LightTaxonomyRow>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(ArrayList<TaxonomyRow> result) {
|
||||
public void onSuccess(ArrayList<LightTaxonomyRow> 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<result.size()-1; i++) {
|
||||
TaxonomyRow taxonomy = result.get(i);
|
||||
LightTaxonomyRow taxonomy = result.get(i);
|
||||
// //FOR DEBUG
|
||||
// System.out.println("child "+taxonomy);
|
||||
|
||||
|
@ -184,7 +180,7 @@ public class TabItemForTaxonomyRow {
|
|||
lc.add(comma);
|
||||
}
|
||||
|
||||
TaxonomyRow taxonomy = result.get(result.size()-1);
|
||||
LightTaxonomyRow taxonomy = result.get(result.size()-1);
|
||||
|
||||
if(!setRank)
|
||||
setRank = replaceLabelRank(hp, labelRank, taxonomy.getRank());
|
||||
|
@ -252,7 +248,7 @@ public class TabItemForTaxonomyRow {
|
|||
* @return
|
||||
*/
|
||||
|
||||
private Anchor getAnchorByTaxonomy(final TaxonomyRow taxon, final String dataSource, final int parentIndex)
|
||||
private Anchor getAnchorByTaxonomy(final LightTaxonomyRow taxon, final String dataSource, final int parentIndex)
|
||||
{
|
||||
Anchor anchor = null;
|
||||
|
||||
|
@ -273,11 +269,11 @@ public class TabItemForTaxonomyRow {
|
|||
}
|
||||
else if(parentIndex == -1){ //items loaded from get children - the current Taxonomy item is the parent
|
||||
|
||||
List<TaxonomyRow> list = new ArrayList<TaxonomyRow>();
|
||||
List<LightTaxonomyRow> list = new ArrayList<LightTaxonomyRow>();
|
||||
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<ItemParameter> hashProperties = row.getProperties();
|
||||
Collections.sort(hashProperties, ItemParameter.COMPARATOR);
|
||||
|
||||
propertiesHtml+="<table class=\"parameters\">";
|
||||
|
||||
for (ItemParameter itemParameter : hashProperties) {
|
||||
|
||||
propertiesHtml+=
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+itemParameter.getKey()+"</td>" +
|
||||
" <td>"+itemParameter.getValue()+"</td>" +
|
||||
"</tr>";
|
||||
}
|
||||
|
||||
propertiesHtml+="</table>";
|
||||
}
|
||||
|
||||
|
||||
//Create list common name
|
||||
String commonNames = "";
|
||||
|
||||
// if(isNewTab){
|
||||
if(row.getCommonNames()!=null){
|
||||
for (CommonName comName : row.getCommonNames()) {
|
||||
commonNames+= "<b>"+comName.getName()+"</b>" +" ("+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<ItemParameter> hashProperties = row.getProperties();
|
||||
// Collections.sort(hashProperties, ItemParameter.COMPARATOR);
|
||||
//
|
||||
// propertiesHtml+="<table class=\"parameters\">";
|
||||
//
|
||||
// for (ItemParameter itemParameter : hashProperties) {
|
||||
//
|
||||
// propertiesHtml+=
|
||||
// "<tr>" +
|
||||
// " <td class=\"title\">"+itemParameter.getKey()+"</td>" +
|
||||
// " <td>"+itemParameter.getValue()+"</td>" +
|
||||
// "</tr>";
|
||||
// }
|
||||
//
|
||||
// propertiesHtml+="</table>";
|
||||
// }
|
||||
|
||||
|
||||
String table = "<table class=\"imagetable\">";
|
||||
|
||||
// if(isNewTab)
|
||||
table+=
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+TaxonomyGridField.COMMON_NAMES.getName()+" (Language)</td>" +
|
||||
" <td>"+commonNames+"</td>" +
|
||||
"</tr>";
|
||||
|
||||
|
||||
table+="<tr>" +
|
||||
" <td class=\"title\">"+TaxonomyGridField.STATUSREFNAME.getName()+"</td>" +
|
||||
" <td>"+statusName+"</td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+TaxonomyGridField.STATUS_REMARKS.getName()+"</td>" +
|
||||
" <td>"+statusRemark+"</td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+TaxonomyGridField.DATASOURCE.getName()+"</td>" +
|
||||
" <td>"+dataProviderName+"</td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+TaxonomyGridField.DATEMODIFIED.getName()+"</td>" +
|
||||
" <td>"+dateModified+"</td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+TaxonomyGridField.MATCHING_RANK.getName()+"</td>" +
|
||||
" <td>"+rank+"</td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+TaxonomyGridField.CITATION.getName()+"</td>" +
|
||||
" <td>"+dataSetCitation+"</td>" +
|
||||
"</tr>" +
|
||||
// "<tr>" +
|
||||
// " <td class=\"title\">"+TaxonomyGridField.MATCHING_AUTHOR.getName()+"</td>" +
|
||||
// " <td>"+matchingAccordionTo+"</td>" +
|
||||
//
|
||||
//
|
||||
// //Create list common name
|
||||
// String commonNames = "";
|
||||
//
|
||||
//// if(isNewTab){
|
||||
// if(row.getCommonNames()!=null){
|
||||
// for (CommonName comName : row.getCommonNames()) {
|
||||
// commonNames+= "<b>"+comName.getName()+"</b>" +" ("+comName.getLanguage()+") - ";
|
||||
// }
|
||||
// }
|
||||
//// }
|
||||
//
|
||||
//
|
||||
// String table = "<table class=\"imagetable\">";
|
||||
//
|
||||
//// if(isNewTab)
|
||||
// table+=
|
||||
// "<tr>" +
|
||||
// " <td class=\"title\">"+TaxonomyGridField.COMMON_NAMES.getName()+" (Language)</td>" +
|
||||
// " <td>"+commonNames+"</td>" +
|
||||
// "</tr>";
|
||||
//
|
||||
//
|
||||
// table+="<tr>" +
|
||||
// " <td class=\"title\">"+TaxonomyGridField.STATUSREFNAME.getName()+"</td>" +
|
||||
// " <td>"+statusName+"</td>" +
|
||||
// "</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+TaxonomyGridField.LSID.getName()+"</td>" +
|
||||
" <td>"+lsid+"</td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+TaxonomyGridField.AUTHOR.getName()+"</td>" +
|
||||
" <td>"+author+"</td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+TaxonomyGridField.CREDITS.getName()+"</td>" +
|
||||
" <td>"+credits+"</td>" +
|
||||
"</tr>" +
|
||||
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+TaxonomyGridField.PROPERTIES.getName()+"</td>" +
|
||||
" <td>"+propertiesHtml+"</td>" +
|
||||
"</tr>" +
|
||||
|
||||
"</table>";
|
||||
return new Html(table);
|
||||
|
||||
}
|
||||
// "<tr>" +
|
||||
// " <td class=\"title\">"+TaxonomyGridField.STATUS_REMARKS.getName()+"</td>" +
|
||||
// " <td>"+statusRemark+"</td>" +
|
||||
// "</tr>" +
|
||||
// "<tr>" +
|
||||
// " <td class=\"title\">"+TaxonomyGridField.DATASOURCE.getName()+"</td>" +
|
||||
// " <td>"+dataProviderName+"</td>" +
|
||||
// "</tr>" +
|
||||
// "<tr>" +
|
||||
// " <td class=\"title\">"+TaxonomyGridField.DATEMODIFIED.getName()+"</td>" +
|
||||
// " <td>"+dateModified+"</td>" +
|
||||
// "</tr>" +
|
||||
// "<tr>" +
|
||||
// " <td class=\"title\">"+TaxonomyGridField.MATCHING_RANK.getName()+"</td>" +
|
||||
// " <td>"+rank+"</td>" +
|
||||
// "</tr>" +
|
||||
// "<tr>" +
|
||||
// " <td class=\"title\">"+TaxonomyGridField.CITATION.getName()+"</td>" +
|
||||
// " <td>"+dataSetCitation+"</td>" +
|
||||
// "</tr>" +
|
||||
//// "<tr>" +
|
||||
//// " <td class=\"title\">"+TaxonomyGridField.MATCHING_AUTHOR.getName()+"</td>" +
|
||||
//// " <td>"+matchingAccordionTo+"</td>" +
|
||||
//// "</tr>" +
|
||||
// "<tr>" +
|
||||
// " <td class=\"title\">"+TaxonomyGridField.LSID.getName()+"</td>" +
|
||||
// " <td>"+lsid+"</td>" +
|
||||
// "</tr>" +
|
||||
// "<tr>" +
|
||||
// " <td class=\"title\">"+TaxonomyGridField.AUTHOR.getName()+"</td>" +
|
||||
// " <td>"+author+"</td>" +
|
||||
// "</tr>" +
|
||||
// "<tr>" +
|
||||
// " <td class=\"title\">"+TaxonomyGridField.CREDITS.getName()+"</td>" +
|
||||
// " <td>"+credits+"</td>" +
|
||||
// "</tr>" +
|
||||
//
|
||||
// "<tr>" +
|
||||
// " <td class=\"title\">"+TaxonomyGridField.PROPERTIES.getName()+"</td>" +
|
||||
// " <td>"+propertiesHtml+"</td>" +
|
||||
// "</tr>" +
|
||||
//
|
||||
// "</table>";
|
||||
// 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<ItemParameter> hashProperties = row.getProperties();
|
||||
// Collections.sort(hashProperties,
|
||||
// ItemParameter.COMPARATOR);
|
||||
//
|
||||
// propertiesHtml += "<table class=\"parameters\">";
|
||||
//
|
||||
// for (ItemParameter itemParameter : hashProperties) {
|
||||
//
|
||||
// propertiesHtml += "<tr>" + " <td class=\"title\">"
|
||||
// + itemParameter.getKey() + "</td>" + " <td>"
|
||||
// + itemParameter.getValue() + "</td>" + "</tr>";
|
||||
// }
|
||||
//
|
||||
// propertiesHtml += "</table>";
|
||||
// }
|
||||
//
|
||||
// // Create list common name
|
||||
// String commonNames = "";
|
||||
//
|
||||
// // if(isNewTab){
|
||||
// if (row.getCommonNames() != null) {
|
||||
// for (CommonName comName : row.getCommonNames()) {
|
||||
// commonNames += "<b>" + comName.getName() + "</b>" + " ("
|
||||
// + 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<ItemParameter> hashProperties = row.getProperties();
|
||||
Collections.sort(hashProperties,
|
||||
ItemParameter.COMPARATOR);
|
||||
|
||||
propertiesHtml += "<table class=\"parameters\">";
|
||||
|
||||
for (ItemParameter itemParameter : hashProperties) {
|
||||
|
||||
propertiesHtml += "<tr>" + " <td class=\"title\">"
|
||||
+ itemParameter.getKey() + "</td>" + " <td>"
|
||||
+ itemParameter.getValue() + "</td>" + "</tr>";
|
||||
}
|
||||
|
||||
propertiesHtml += "</table>";
|
||||
}
|
||||
|
||||
// Create list common name
|
||||
String commonNames = "";
|
||||
|
||||
// if(isNewTab){
|
||||
if (row.getCommonNames() != null) {
|
||||
for (CommonName comName : row.getCommonNames()) {
|
||||
commonNames += "<b>" + comName.getName() + "</b>" + " ("
|
||||
+ 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<TaxonomyRow> parents){
|
||||
public void getSynonymsByReferenceId(FlexTable flexTable, int row, int col, String refId, final String dataSource, final List<LightTaxonomyRow> 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<List<TaxonomyRow>>() {
|
||||
SpeciesDiscovery.taxonomySearchService.retrieveSynonymsByRefId(refId, new AsyncCallback<List<LightTaxonomyRow>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
@ -675,7 +671,7 @@ public class TabItemForTaxonomyRow {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<TaxonomyRow> result) {
|
||||
public void onSuccess(List<LightTaxonomyRow> 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<result.size()-1; i++) {
|
||||
TaxonomyRow taxonomy = result.get(i);
|
||||
LightTaxonomyRow taxonomy = result.get(i);
|
||||
// System.out.println("child "+taxonomy);
|
||||
|
||||
//SET PARENTS
|
||||
|
@ -704,7 +700,7 @@ public class TabItemForTaxonomyRow {
|
|||
lc.add(comma);
|
||||
}
|
||||
|
||||
TaxonomyRow taxonomy = result.get(result.size()-1);
|
||||
LightTaxonomyRow taxonomy = result.get(result.size()-1);
|
||||
|
||||
// System.out.println("child "+taxonomy);
|
||||
//SET PARENTS
|
||||
|
@ -727,7 +723,7 @@ public class TabItemForTaxonomyRow {
|
|||
}
|
||||
|
||||
|
||||
public void getTaxonomyByReferenceId(FlexTable flexTable, int row, int col, final String statusRemark, String refId, final String dataSource, final List<TaxonomyRow> parents){
|
||||
public void getTaxonomyByReferenceId(FlexTable flexTable, int row, int col, final String statusRemark, String refId, final String dataSource, final List<LightTaxonomyRow> parents){
|
||||
|
||||
final LayoutContainer layoutContainer = new LayoutContainer();
|
||||
// hp.getElement().getStyle().setBorderStyle(BorderStyle.NONE);
|
||||
|
@ -744,7 +740,7 @@ public class TabItemForTaxonomyRow {
|
|||
List<String> listId = new ArrayList<String>();
|
||||
listId.add(refId);
|
||||
|
||||
SpeciesDiscovery.taxonomySearchService.retrieveTaxonomyByIds(listId, new AsyncCallback<List<TaxonomyRow>>() {
|
||||
SpeciesDiscovery.taxonomySearchService.retrieveTaxonomyByIds(listId, new AsyncCallback<List<LightTaxonomyRow>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
@ -754,7 +750,7 @@ public class TabItemForTaxonomyRow {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<TaxonomyRow> result) {
|
||||
public void onSuccess(List<LightTaxonomyRow> 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<result.size()-1; i++) {
|
||||
TaxonomyRow taxonomy = result.get(i);
|
||||
LightTaxonomyRow taxonomy = result.get(i);
|
||||
// System.out.println("child "+taxonomy);
|
||||
|
||||
//SET PARENTS
|
||||
|
@ -782,21 +778,16 @@ public class TabItemForTaxonomyRow {
|
|||
lc.add(comma);
|
||||
}
|
||||
|
||||
TaxonomyRow taxonomy = result.get(result.size()-1);
|
||||
LightTaxonomyRow taxonomy = result.get(result.size()-1);
|
||||
|
||||
//FOR DEBUG
|
||||
// System.out.println("child "+taxonomy);
|
||||
//SET PARENTS
|
||||
taxonomy.setParent(parents);
|
||||
|
||||
|
||||
|
||||
//TODO
|
||||
lc.add(getAnchorByTaxonomy(taxonomy, dataSource, -2));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
layoutContainer.add(lc);
|
||||
|
@ -807,80 +798,4 @@ public class TabItemForTaxonomyRow {
|
|||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
// protected ContentPanel getPanelForTaxonomy(TaxonomyRow taxon, String dataSource, boolean isNewTab, final int parentIndex) {
|
||||
//
|
||||
// ContentPanel contentPanel = new ContentPanel();
|
||||
//// contentPanel.setLayout(new FitLayout());
|
||||
// contentPanel.setHeaderVisible(false);
|
||||
// contentPanel.setBodyBorder(false);
|
||||
//
|
||||
// contentPanel.setStyleAttribute("padding", "5px");
|
||||
// contentPanel.setStyleAttribute("margin", "5px");
|
||||
//
|
||||
// VerticalPanel verticaPanel = new VerticalPanel();
|
||||
// verticaPanel.setSize("100%", "100%");
|
||||
//
|
||||
// contentPanel.add(new Html("<br/><br/><p style=\"font-size:18px;\"><b>" + taxon.getName() + "</b></p><hr>"));
|
||||
// contentPanel.add(new Html("<br/><br/><p style=\"font-size:12px;\"><b>Scientific Classification</b></p><br/>"));
|
||||
//
|
||||
// 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<MenuEvent>() {
|
||||
//
|
||||
// @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);
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -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<TaxonomyRow> parents = null;
|
||||
private List<LightTaxonomyRow> parents = null;
|
||||
private TabItemForTaxonomyRow tabTR;
|
||||
|
||||
private AbstractImagePrototype imageLoading = AbstractImagePrototype.create(Resources.INSTANCE.loadingBalls());
|
||||
|
||||
// private HashMap<String, TabItemForTaxonomyRow> hashTR = new HashMap<String, TabItemForTaxonomyRow>();
|
||||
|
||||
|
||||
public List<TaxonomyRow> getParents() {
|
||||
public List<LightTaxonomyRow> getParents() {
|
||||
return parents;
|
||||
}
|
||||
|
||||
public void setParents(List<TaxonomyRow> parents) {
|
||||
public void setParents(List<LightTaxonomyRow> 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("<p style=\"font-size:11px; margin-top:10px;\"><b>Status and Synonyms</b></p>"));
|
||||
contentPanel.add(getStatusAndSynonyms(taxon, dataSource));
|
||||
contentPanel.add(new Html("<p style=\"font-size:11px; margin-top:10px;\"><b>Other Information</b></p"));
|
||||
|
||||
// HorizontalPanel hp = new HorizontalPanel();
|
||||
|
||||
// contentPanel.add(getHTMLTableForTaxonomyWithRef(taxon, isNewTab, dataSource));
|
||||
|
||||
|
||||
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");
|
||||
contentPanel.add(lcRRTables);
|
||||
|
||||
final Image loading = imageLoading.createImage();
|
||||
lcRRTables.add(loading);
|
||||
|
||||
String urlRequest = GWT.getModuleBaseURL() + ConstantsSpeciesDiscovery.TAXONOMY_ROW_TABLE + "?" +"oid=" + taxon.getServiceId();
|
||||
|
||||
RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.POST, urlRequest);
|
||||
requestBuilder.setHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
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"));
|
||||
}
|
||||
|
||||
return contentPanel;
|
||||
|
||||
}
|
||||
|
||||
protected void addTabItem(final TaxonomyRow taxon, final String dataSource){
|
||||
protected void addTabItem(final LightTaxonomyRow taxon, final String dataSource){
|
||||
|
||||
this.tabTR = new TabItemForTaxonomyRow(this, this.tabPanel, this.eventBus);
|
||||
|
||||
|
@ -174,5 +233,103 @@ public class TablesForTaxonomyRow {
|
|||
|
||||
}
|
||||
|
||||
|
||||
public FlexTable getStatusAndSynonyms(final LightTaxonomyRow taxon, final String dataSource){
|
||||
|
||||
String refId = null;
|
||||
String statusRemark="";
|
||||
String statusName="";
|
||||
|
||||
|
||||
if (taxon.getStatusRefId() != null && !taxon.getStatusRefId().isEmpty())
|
||||
refId = taxon.getStatusRefId();
|
||||
|
||||
if (taxon.getStatusRemarks() != null)
|
||||
statusRemark = taxon.getStatusRemarks();
|
||||
|
||||
if (taxon.getStatusName() != null)
|
||||
statusName = taxon.getStatusName();
|
||||
|
||||
//BUILD TABLE WITH STATUS REF ID; STATUS REMARK AND SYNONYMS
|
||||
final FlexTable flexTable = new FlexTable();
|
||||
flexTable.setStyleName("imagetable-status");
|
||||
|
||||
flexTable.setWidget(0, 0, new Label(TaxonomyGridField.STATUSREFNAME.getName()));
|
||||
flexTable.setWidget(0, 1, new Label(statusName));
|
||||
|
||||
if (refId != null) {
|
||||
|
||||
final String status;
|
||||
|
||||
if(!statusRemark.isEmpty())
|
||||
status = statusRemark;
|
||||
else
|
||||
status = statusName;
|
||||
|
||||
final String referenceId = refId;
|
||||
|
||||
flexTable.setWidget(1, 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(taxon.getParents().size()>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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<CreateTaxonomyJobEventHandler> {
|
||||
|
||||
public static final GwtEvent.Type<CreateTaxonomyJobEventHandler> TYPE = new Type<CreateTaxonomyJobEventHandler>();
|
||||
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<CreateTaxonomyJobEventHandl
|
|||
* @param type
|
||||
* @param rank
|
||||
*/
|
||||
public CreateTaxonomyJobEvent(TaxonomyRow taxonomy, String dataSourceName, TaxonomyJobType jobType) {
|
||||
public CreateTaxonomyJobEvent(LightTaxonomyRow taxonomy, String dataSourceName, TaxonomyJobType jobType) {
|
||||
this.taxonomy = taxonomy;
|
||||
this.dataSourceName = dataSourceName;
|
||||
this.jobType = jobType;
|
||||
|
@ -55,11 +55,11 @@ public class CreateTaxonomyJobEvent extends GwtEvent<CreateTaxonomyJobEventHandl
|
|||
return jobType;
|
||||
}
|
||||
|
||||
public TaxonomyRow getTaxonomy() {
|
||||
public LightTaxonomyRow getTaxonomy() {
|
||||
return taxonomy;
|
||||
}
|
||||
|
||||
public void setTaxonomy(TaxonomyRow taxonomy) {
|
||||
public void setTaxonomy(LightTaxonomyRow taxonomy) {
|
||||
this.taxonomy = taxonomy;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
@ -24,6 +25,8 @@ import org.gcube.portlets.user.speciesdiscovery.shared.SearchServiceException;
|
|||
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;
|
||||
|
@ -93,8 +96,7 @@ public interface TaxonomySearchService extends RemoteService {
|
|||
ResultFilter activeFiltersObject, boolean showOnlySelected)
|
||||
throws SearchServiceException;
|
||||
|
||||
public ArrayList<TaxonomyRow> loadListChildByParentId(String parentId)
|
||||
throws Exception;
|
||||
ArrayList<LightTaxonomyRow> 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<TaxonomyRow> retrieveTaxonomyByIds(List<String> ids)
|
||||
throws Exception;
|
||||
public List<LightTaxonomyRow> retrieveTaxonomyByIds(List<String> ids) throws Exception;
|
||||
|
||||
public List<TaxonomyRow> retrieveSynonymsByRefId(String refId)
|
||||
throws Exception;
|
||||
public List<LightTaxonomyRow> retrieveSynonymsByRefId(String refId) throws Exception;
|
||||
|
||||
public List<JobOccurrencesModel> createOccurrencesJob(
|
||||
List<JobOccurrencesModel> 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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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<SearchResult<TaxonomyRow>> asyncCallback);
|
||||
|
||||
void loadListChildByParentId(String parentId, AsyncCallback<ArrayList<TaxonomyRow>> callback);
|
||||
void loadListChildrenByParentId(String parentId, AsyncCallback<ArrayList<LightTaxonomyRow>> asyncCallback);
|
||||
|
||||
void saveSelectedTaxonomyPoints(String destinationFolderId, String fileName, SaveFileFormat fileFormat, AsyncCallback<Void> callback);
|
||||
|
||||
|
@ -101,9 +104,9 @@ public interface TaxonomySearchServiceAsync {
|
|||
|
||||
void saveTaxonomyJob(String jobIdentifier, String destinationFolderId, String fileName, String scientificName, String dataSourceName, AsyncCallback<Boolean> callback);
|
||||
|
||||
void retrieveTaxonomyByIds(List<String> ids, AsyncCallback<List<TaxonomyRow>> callback);
|
||||
void retrieveTaxonomyByIds(List<String> ids, AsyncCallback<List<LightTaxonomyRow>> asyncCallback);
|
||||
|
||||
void retrieveSynonymsByRefId(String refId, AsyncCallback<List<TaxonomyRow>> callback);
|
||||
void retrieveSynonymsByRefId(String refId, AsyncCallback<List<LightTaxonomyRow>> asyncCallback);
|
||||
|
||||
void createOccurrencesJob(List<JobOccurrencesModel> listJobOccurrenceModel, SaveFileFormat saveFileFormat, OccurrencesSaveEnum csvType, boolean isByDataSource, int expectedOccurrence, AsyncCallback<List<JobOccurrencesModel>> callback);
|
||||
|
||||
|
@ -156,5 +159,13 @@ public interface TaxonomySearchServiceAsync {
|
|||
AsyncCallback<Boolean> callback);
|
||||
|
||||
void getLastQuery(AsyncCallback<String> callback);
|
||||
|
||||
void loadClusterCommonNameForResultRowByScientificName(
|
||||
String scientificName,
|
||||
AsyncCallback<ClusterCommonNameDataSourceForResultRow> callback);
|
||||
|
||||
void loadClusterCommonNameForTaxonomyRowByScientificName(
|
||||
String scientificName,
|
||||
AsyncCallback<ClusterCommonNameDataSourceForTaxonomyRow> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -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<String> 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<String, ArrayList<String>> hashResultRowIdTables = result.getHashClusterScientificNameResultRowID();
|
||||
HashMap<String, ClusterCommonNameDataSource<ResultRow>> hashClusterCommonNamesDataSources = result.getHashClusterCommonNamesDataSources();
|
||||
HashMap<String, ArrayList<String>> hashResultRowIdTables = result.getHashClusterScientificNameResultRowServiceID();
|
||||
|
||||
|
||||
// HashMap<String, ClusterCommonNameDataSource<ResultRow>> hashClusterCommonNamesDataSources = result.getHashClusterCommonNamesDataSources();
|
||||
|
||||
String title = common.getSearchTitle();
|
||||
|
||||
|
@ -187,25 +200,150 @@ public class ResultRowDetailsFiller implements DetailsFiller {
|
|||
|
||||
panelDetails.add(common.createExternalLinks(scientificName));
|
||||
|
||||
|
||||
String commonNamesTitle = "<p style=\"font-size:12px;\"><b>Common Names (Data Source/s)</b></p>";
|
||||
panelDetails.add(new Html(commonNamesTitle));
|
||||
|
||||
ClusterCommonNameDataSource<ResultRow> cluster = hashClusterCommonNamesDataSources.get(scientificName);
|
||||
|
||||
String tableCommonName = common.createTableWithCheckCommonNameDataSource(cluster.getHashMapCommonNameDataSources(), cluster.getListDataSourcesFound());
|
||||
panelDetails.add(new Html("<br/>"+tableCommonName+"<br/><br/>"));
|
||||
|
||||
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<ClusterCommonNameDataSourceForResultRow>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Html htmlTableResult = new Html();
|
||||
htmlTableResult.setHtml("<br/>Error on retrieving data<br/><br/>");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ClusterCommonNameDataSourceForResultRow result) {
|
||||
|
||||
|
||||
Html htmlTableResult = new Html();
|
||||
htmlTableResult.setHtml("<br/>Not Found<br/><br/>");
|
||||
|
||||
if(result !=null){
|
||||
|
||||
if(result.getCluster()!=null){
|
||||
String tableCommonName = common.createTableWithCheckCommonNameDataSource(result.getCluster().getHashMapCommonNameDataSources(), result.getCluster().getListDataSourcesFound());
|
||||
htmlTableResult.setHtml("<br/>"+tableCommonName+"<br/><br/>");
|
||||
}
|
||||
else
|
||||
htmlTableResult.setHtml("<br/>Error on retrieving data<br/><br/>");
|
||||
}else
|
||||
htmlTableResult.setHtml("<br/>Error on retrieving data<br/><br/>");
|
||||
|
||||
|
||||
lcCommonName.remove(loading);
|
||||
lcCommonName.add(htmlTableResult);
|
||||
|
||||
panelDetails.layout();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
lcCommonName.add(anchorCommon);
|
||||
|
||||
panelDetails.add(lcCommonName);
|
||||
// ClusterCommonNameDataSource<ResultRow> cluster = hashClusterCommonNamesDataSources.get(scientificName);
|
||||
|
||||
|
||||
// String tableCommonName = common.createTableWithCheckCommonNameDataSource(cluster.getHashMapCommonNameDataSources(), cluster.getListDataSourcesFound());
|
||||
// panelDetails.add(new Html("<br/>"+tableCommonName+"<br/><br/>"));
|
||||
|
||||
|
||||
ArrayList<String> arrayRowID = hashResultRowIdTables.get(scientificName);
|
||||
|
||||
// for(int i=0; i<arrayRowID.size(); i++ ){
|
||||
// ResultRow row = result.getResultRowByRowID(arrayRowID.get(i));
|
||||
// Html table = TablesForResultRow.getTableForResultRow(row, ResultRowDataSource.getClassification(row.getParents()));
|
||||
// panelDetails.add(table);
|
||||
// }
|
||||
|
||||
for(int i=0; i<arrayRowID.size(); i++ ){
|
||||
ResultRow row = result.getResultRowByRowID(arrayRowID.get(i));
|
||||
Html table = TablesForResultRow.getTableForResultRow(row, ResultRowDataSource.getClassification(row.getParents()));
|
||||
panelDetails.add(table);
|
||||
|
||||
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.RESULT_ROW_TABLE + "?" +"oid=" + arrayRowID.get(i);
|
||||
|
||||
RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, urlRequest);
|
||||
|
||||
try {
|
||||
|
||||
requestBuilder.sendRequest("", new RequestCallback() {
|
||||
|
||||
@Override
|
||||
public void onResponseReceived(Request request, Response response) {
|
||||
|
||||
// int status = response.getStatusCode();
|
||||
// System.out.println("status: "+status);
|
||||
lcRRTables.remove(loading);
|
||||
// lcRRTables.setLayout(new FitLayout());
|
||||
Html respHtml = new Html(response.getText());
|
||||
// respHtml.setId("respHtml"+respHtml.getId());
|
||||
// respHtml.setStyleAttribute("width", "99%");
|
||||
// System.out.println("response text is: "+response.getText());
|
||||
lcRRTables.add(respHtml);
|
||||
lcRRTables.layout();
|
||||
// panelDetails.layout();
|
||||
// if(status==200){
|
||||
// lcRRTables.add(new Html(response.getText()));
|
||||
// }else{ //OK STATUS
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
@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"));
|
||||
}
|
||||
|
||||
// panelDetails.add(lcRRTables);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
panelDetails.layout(true);
|
||||
|
||||
// panelDetails.layout(true);
|
||||
panelDetails.layout();
|
||||
|
||||
}
|
||||
@Override
|
||||
|
|
|
@ -13,9 +13,9 @@ import org.gcube.portlets.user.speciesdiscovery.client.cluster.TablesForTaxonomy
|
|||
import org.gcube.portlets.user.speciesdiscovery.client.event.SearchEvent;
|
||||
import org.gcube.portlets.user.speciesdiscovery.client.resources.Resources;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.DataSourceModel;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.LightTaxonomyRow;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.SpeciesCapability;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterCommonNameDataSource;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterCommonNameDataSourceForTaxonomyRow;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterStructuresForTaxonomyRow;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
@ -34,18 +34,26 @@ 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.dom.client.Style.Unit;
|
||||
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 TaxonomyRowDetailsFiller implements DetailsFiller {
|
||||
|
||||
private TabItem tabItemDetails;
|
||||
private ToolBar toolbarTaxonomy;
|
||||
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<String> 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<String, ArrayList<String>> hashTaxonomyRowID = result.getHashClusterScientificNameTaxonomyRowID();
|
||||
|
||||
HashMap<String, ArrayList<String>> hashTaxonomyRowServiceID = result.getHashClusterScientificNameTaxonomyRowServiceID();
|
||||
// ArrayList<String> listDataSourceFound = tableClassification.getListFoundDataSources();
|
||||
HashMap<String,ClusterCommonNameDataSource<TaxonomyRow>> hashClusterCommonNamesDataSources = result.getHashClusterCommonNamesDataSources();
|
||||
// HashMap<String,ClusterCommonNameDataSource<TaxonomyRow>> hashClusterCommonNamesDataSources = result.getHashClusterCommonNamesDataSources();
|
||||
|
||||
// HashMap<String, ArrayList<GxtClassificationModel>> hashHTMLTables = result.getHashClassificationTables();
|
||||
|
||||
|
@ -135,7 +144,7 @@ public class TaxonomyRowDetailsFiller implements DetailsFiller {
|
|||
// System.out.println("############# Data Source found " + dataSource);
|
||||
// }
|
||||
|
||||
List<String> listKey = new ArrayList<String>(hashTaxonomyRowID.keySet());
|
||||
List<String> listKey = new ArrayList<String>(hashTaxonomyRowServiceID.keySet());
|
||||
Collections.sort(listKey);
|
||||
|
||||
|
||||
|
@ -204,16 +213,76 @@ public class TaxonomyRowDetailsFiller implements DetailsFiller {
|
|||
String commonNamesTitle = "<p style=\"font-size:12px;\"><b>Common Names (Data Source/s)</b></p>";
|
||||
panelDetails.add(new Html(commonNamesTitle));
|
||||
|
||||
ClusterCommonNameDataSource<TaxonomyRow> 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("<br/>"+tableCommonName+"<br/>"));
|
||||
// lcCommonName.setLayout(new FitLayout());
|
||||
|
||||
ArrayList<String> 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<ClusterCommonNameDataSourceForTaxonomyRow>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Html htmlTableResult = new Html();
|
||||
htmlTableResult.setHtml("<br/>Error on retrieving data<br/><br/>");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ClusterCommonNameDataSourceForTaxonomyRow result) {
|
||||
|
||||
|
||||
Html htmlTableResult = new Html();
|
||||
htmlTableResult.setHtml("<br/>Not Found<br/><br/>");
|
||||
|
||||
if(result !=null){
|
||||
|
||||
if(result.getCluster()!=null){
|
||||
String tableCommonName = common.createTableWithCheckCommonNameDataSource(result.getCluster().getHashMapCommonNameDataSources(), result.getCluster().getListDataSourcesFound());
|
||||
htmlTableResult.setHtml("<br/>"+tableCommonName+"<br/><br/>");
|
||||
}
|
||||
else
|
||||
htmlTableResult.setHtml("<br/>Error on retrieving data<br/><br/>");
|
||||
}else
|
||||
htmlTableResult.setHtml("<br/>Error on retrieving data<br/><br/>");
|
||||
|
||||
|
||||
lcCommonName.remove(loading);
|
||||
lcCommonName.add(htmlTableResult);
|
||||
|
||||
panelDetails.layout();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
lcCommonName.add(anchorCommon);
|
||||
|
||||
panelDetails.add(lcCommonName);
|
||||
|
||||
ArrayList<String> arrayTaxonomyID = hashTaxonomyRowServiceID.get(scientificName);
|
||||
|
||||
for(int i=0; i<arrayTaxonomyID.size(); i++ ){
|
||||
TaxonomyRow taxonomy = result.getTaxonomyRowByKey(arrayTaxonomyID.get(i));
|
||||
String dataSource = taxonomy.getDataProviderName();
|
||||
|
||||
LightTaxonomyRow lightTaxonomy = result.getLightTaxonomyRowByKey(arrayTaxonomyID.get(i));
|
||||
|
||||
String dataSource = lightTaxonomy.getDataProviderName();
|
||||
|
||||
TablesForTaxonomyRow tables = new TablesForTaxonomyRow(tabPanel, SearchController.eventBus);
|
||||
|
||||
|
@ -228,12 +297,54 @@ public class TaxonomyRowDetailsFiller implements DetailsFiller {
|
|||
createAbout.getElement().getStyle().setMarginLeft(25, Unit.PX);
|
||||
horizontalPanel.add(createAbout);
|
||||
}
|
||||
|
||||
|
||||
panelDetails.add(horizontalPanel);
|
||||
panelDetails.add(tables.getPanelClassificationForTaxonomy(taxonomy, dataSource, false));
|
||||
panelDetails.add(tables.getPanelClassificationForTaxonomy(lightTaxonomy, dataSource, false));
|
||||
|
||||
panelDetails.add(new Html("<p style=\"font-size:11px; margin-top:10px;\"><b>Status and Synonyms</b></p>"));
|
||||
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("<p style=\"font-size:11px; margin-top:10px;\"><b>Other Information</b></p>"));
|
||||
|
||||
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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Object> cq = queryBuilder.createQuery();
|
||||
Predicate pr1 = queryBuilder.equal(persistence.rootFrom(cq).get(ResultRow.SERVICE_ID_FIELD), resultServiceRowID);
|
||||
cq.where(pr1);
|
||||
|
||||
Iterator<ResultRow> 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 +=("<p>Error: "+message+"</p>");
|
||||
return errorPage;
|
||||
}
|
||||
|
||||
//TODO modified
|
||||
public static String getClassification(List<Taxon> listTaxon)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (int i = listTaxon.size()-1; i >= 0; i--) {
|
||||
Taxon taxon = listTaxon.get(i);
|
||||
|
||||
sb.append("<b>");
|
||||
|
||||
if(!NormalizeString.isUndefined(taxon.getRank()))
|
||||
sb.append(taxon.getRank());
|
||||
else
|
||||
sb.append("Rank not found");
|
||||
|
||||
sb.append("</b>: ");
|
||||
|
||||
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+= "<b>"+comName.getName()+"</b>" +" ("+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<ItemParameter> listProperties = row.getProperties();
|
||||
Collections.sort(listProperties, ItemParameter.COMPARATOR);
|
||||
|
||||
propertiesHtml+="<table class=\"parameters\">";
|
||||
|
||||
for (ItemParameter itemParameter : listProperties) {
|
||||
|
||||
propertiesHtml+=
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+itemParameter.getKey()+"</td>" +
|
||||
" <td>"+itemParameter.getValue()+"</td>" +
|
||||
"</tr>";
|
||||
}
|
||||
|
||||
propertiesHtml+="</table>";
|
||||
}
|
||||
|
||||
String table = "<table class=\"imagetable\">" +
|
||||
"<tr>" +
|
||||
" <th>"+matchingTaxonName+"</th>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+SpeciesGridFields.CLASSIFICATION_STRING.getName()+"</td>" +
|
||||
" <td>"+classification+"</td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+SpeciesGridFields.COMMON_NAMES.getName()+" (Language)</td>" +
|
||||
" <td>"+commonNames+"</td>" +
|
||||
"</tr>" +
|
||||
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+SpeciesGridFields.DATASOURCE.getName()+"</td>" +
|
||||
" <td>"+dataSourceName+"</td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+SpeciesGridFields.DATAPROVIDER.getName()+"</td>" +
|
||||
" <td>"+dataProviderName+"</td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+SpeciesGridFields.DATASET.getName()+"</td>" +
|
||||
" <td>"+dataSetName+"</td>" +
|
||||
"</tr>" +
|
||||
// "<tr>" +
|
||||
// " <td class=\"title\">"+SpeciesGridFields.MATCHING_AUTHOR.getName()+"</td>" +
|
||||
// " <td>"+matchingAccordionTo+"</td>" +
|
||||
// "</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+SpeciesGridFields.MATCHING_RANK.getName()+"</td>" +
|
||||
" <td>"+matchingRank+"</td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+SpeciesGridFields.DATASET_CITATION.getName()+"</td>" +
|
||||
" <td>"+dataSetCitation+"</td>" +
|
||||
"</tr>" +
|
||||
// "<tr>" +
|
||||
// " <td class=\"title\">"+SpeciesGridFields.MATCHING_CREDITS.getName()+"</td>" +
|
||||
// " <td>"+matchingCredits+"</td>" +
|
||||
// "</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+SpeciesGridFields.PRODUCT_OCCURRENCES.getName()+"</td>" +
|
||||
" <td>"+occurencesCount+"</td>" +
|
||||
"</tr>" +
|
||||
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+SpeciesGridFields.LSID.getName()+"</td>" +
|
||||
" <td>"+lsid+"</td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+SpeciesGridFields.AUTHOR.getName()+"</td>" +
|
||||
" <td>"+author+"</td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+SpeciesGridFields.CREDITS.getName()+"</td>" +
|
||||
" <td>"+credits+"</td>" +
|
||||
"</tr>" +
|
||||
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+SpeciesGridFields.PROPERTIES.getName()+"</td>" +
|
||||
" <td>"+propertiesHtml+"</td>" +
|
||||
"</tr>" +
|
||||
|
||||
"</table>";
|
||||
return table;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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<Object> cq = queryBuilder.createQuery();
|
||||
Predicate pr1 = queryBuilder.equal(persistence.rootFrom(cq).get(TaxonomyRow.SERVICE_ID_FIELD), taxonomyServiceRowID);
|
||||
cq.where(pr1);
|
||||
|
||||
Iterator<TaxonomyRow> 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<String> streamIds = new StreamExtend<String>(Arrays.asList(taxonomyServiceRowID).iterator());
|
||||
|
||||
CloseableIterator<TaxonomyItem> 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<String, TaxonomyRow> 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 +=("<p>Error: "+message+"</p>");
|
||||
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<ItemParameter> hashProperties = row.getProperties();
|
||||
Collections.sort(hashProperties, ItemParameter.COMPARATOR);
|
||||
|
||||
propertiesHtml+="<table class=\"parameters\">";
|
||||
|
||||
for (ItemParameter itemParameter : hashProperties) {
|
||||
|
||||
propertiesHtml+=
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+itemParameter.getKey()+"</td>" +
|
||||
" <td>"+itemParameter.getValue()+"</td>" +
|
||||
"</tr>";
|
||||
}
|
||||
|
||||
propertiesHtml+="</table>";
|
||||
}
|
||||
|
||||
|
||||
//Create list common name
|
||||
String commonNames = "";
|
||||
|
||||
if(row.getCommonNames()!=null){
|
||||
for (CommonName comName : row.getCommonNames()) {
|
||||
commonNames+= "<b>"+comName.getName()+"</b>" +" ("+comName.getLanguage()+") - ";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String table = "<table class=\"imagetable\">";
|
||||
|
||||
// if(isNewTab)
|
||||
table+=
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+TaxonomyGridField.COMMON_NAMES.getName()+" (Language)</td>" +
|
||||
" <td>"+commonNames+"</td>" +
|
||||
"</tr>";
|
||||
|
||||
|
||||
// table+="<tr>" +
|
||||
// " <td class=\"title\">"+TaxonomyGridField.STATUSREFNAME.getName()+"</td>" +
|
||||
// " <td>"+statusName+"</td>" +
|
||||
// "</tr>" +
|
||||
// "<tr>" +
|
||||
// " <td class=\"title\">"+TaxonomyGridField.STATUS_REMARKS.getName()+"</td>" +
|
||||
// " <td>"+statusRemark+"</td>" +
|
||||
// "</tr>" +
|
||||
|
||||
|
||||
table +="<tr>" +
|
||||
" <td class=\"title\">"+TaxonomyGridField.DATASOURCE.getName()+"</td>" +
|
||||
" <td>"+dataProviderName+"</td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+TaxonomyGridField.DATEMODIFIED.getName()+"</td>" +
|
||||
" <td>"+dateModified+"</td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+TaxonomyGridField.MATCHING_RANK.getName()+"</td>" +
|
||||
" <td>"+rank+"</td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+TaxonomyGridField.CITATION.getName()+"</td>" +
|
||||
" <td>"+dataSetCitation+"</td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+TaxonomyGridField.LSID.getName()+"</td>" +
|
||||
" <td>"+lsid+"</td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+TaxonomyGridField.AUTHOR.getName()+"</td>" +
|
||||
" <td>"+author+"</td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+TaxonomyGridField.CREDITS.getName()+"</td>" +
|
||||
" <td>"+credits+"</td>" +
|
||||
"</tr>" +
|
||||
|
||||
"<tr>" +
|
||||
" <td class=\"title\">"+TaxonomyGridField.PROPERTIES.getName()+"</td>" +
|
||||
" <td>"+propertiesHtml+"</td>" +
|
||||
"</tr>" +
|
||||
|
||||
"</table>";
|
||||
|
||||
//DEBUG
|
||||
// System.out.println("Table: "+table);
|
||||
|
||||
return table;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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<TaxonomyRow> loadListChildByParentId(String parentId) throws Exception {
|
||||
public ArrayList<LightTaxonomyRow> 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<TaxonomyRow> listTaxonomyRow = new ArrayList<TaxonomyRow>();
|
||||
ArrayList<LightTaxonomyRow> listLightTaxonomyRow = new ArrayList<LightTaxonomyRow>();
|
||||
|
||||
if(parentId==null || parentId.isEmpty()){
|
||||
logger.warn("parentId is null or empty ");
|
||||
return listLightTaxonomyRow;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
SpeciesService taxonomyService = getSpeciesService();
|
||||
CloseableIterator<TaxonomyItem> streamIterator = taxonomyService.getTaxonChildrenByParentId(parentId);
|
||||
ASLSession session = getASLSession();
|
||||
TaxonomyItemConverter converter = new TaxonomyItemConverter(getASLSession());
|
||||
|
||||
int i = 0;
|
||||
|
||||
Map<String, TaxonomyRow> mapChildren = SessionUtil.getHashMapChildrenTaxonomyCache(session);
|
||||
|
||||
if(mapChildren==null){
|
||||
logger.trace("Cache taxa children doesn't exists into session, creating..");
|
||||
mapChildren = new HashMap<String, TaxonomyRow>();
|
||||
}
|
||||
// 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<TaxonomyRow> retrieveTaxonomyByIds(List<String> ids) throws Exception{
|
||||
public List<LightTaxonomyRow> retrieveTaxonomyByIds(List<String> ids) throws Exception{
|
||||
logger.trace("retrieveTaxonomyByIds ids size: " + ids.size());
|
||||
|
||||
// System.out.println("retrieveTaxonomyByIds ids size: " + ids.size() + " first id " + ids.get(0));
|
||||
|
||||
List<TaxonomyRow> listTaxonomyRow = new ArrayList<TaxonomyRow>();
|
||||
List<LightTaxonomyRow> listLightTaxonomyRow = new ArrayList<LightTaxonomyRow>();
|
||||
try {
|
||||
|
||||
SpeciesService taxonomyService = getSpeciesService();
|
||||
|
@ -1620,19 +1647,32 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
|||
|
||||
CloseableIterator<TaxonomyItem> streamIterator = taxonomyService.retrieveTaxonomyById(convert);
|
||||
|
||||
TaxonomyItemConverter taxonomyItemConverter = new TaxonomyItemConverter(getASLSession());
|
||||
ASLSession session = getASLSession();
|
||||
TaxonomyItemConverter taxonomyItemConverter = new TaxonomyItemConverter(session);
|
||||
|
||||
Map<String, TaxonomyRow> mapTaxonomyIds = SessionUtil.getHashMapTaxonomyByIdsCache(session);
|
||||
|
||||
if(mapTaxonomyIds==null){
|
||||
logger.trace("Cache taxa ByIds doesn't exists into session, creating..");
|
||||
mapTaxonomyIds = new HashMap<String, TaxonomyRow>();
|
||||
}
|
||||
|
||||
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<TaxonomyRow> retrieveSynonymsByRefId(String refId) throws Exception{
|
||||
public List<LightTaxonomyRow> retrieveSynonymsByRefId(String refId) throws Exception{
|
||||
logger.trace("retrieveSynonymsById id: " + refId);
|
||||
|
||||
//FOR DEBUG
|
||||
// System.out.println("retrieveSynonymsById id: " + refId);
|
||||
|
||||
List<TaxonomyRow> listTaxonomyRow = new ArrayList<TaxonomyRow>();
|
||||
List<LightTaxonomyRow> listLightTaxonomyRow = new ArrayList<LightTaxonomyRow>();
|
||||
try {
|
||||
|
||||
SpeciesService taxonomyService = getSpeciesService();
|
||||
|
||||
CloseableIterator<TaxonomyItem> streamIterator = taxonomyService.retrieveSynonymsById(refId);
|
||||
|
||||
ASLSession session = getASLSession();
|
||||
TaxonomyItemConverter taxonomyItemConverter = new TaxonomyItemConverter(getASLSession());
|
||||
|
||||
int i = 1;
|
||||
Map<String, TaxonomyRow> mapSysnosyms = SessionUtil.getHashMapSynonymsTaxonomyCache(getASLSession());
|
||||
|
||||
if(mapSysnosyms==null){
|
||||
logger.trace("Cache synonyms doesn't exists into session, creating..");
|
||||
mapSysnosyms = new HashMap<String, TaxonomyRow>();
|
||||
}
|
||||
|
||||
// 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<String, ClusterCommonNameDataSourceForResultRow> 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<ResultRow> 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<String, ClusterCommonNameDataSourceForResultRow> 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<String, ClusterCommonNameDataSourceForTaxonomyRow> hashCluster = SessionUtil.getCurrentClusterCommonNameForTaxonomyRow(session);
|
||||
|
||||
//Reset cluster for common name
|
||||
if(hashCluster!=null)
|
||||
SessionUtil.setCurrentClusterCommonNameForTaxonomyRow(session, null);
|
||||
|
||||
|
||||
HashMap<String, TaxonomyRow> mapOldChildren = SessionUtil.getHashMapChildrenTaxonomyCache(session);
|
||||
//Reset list children to last clustering
|
||||
if(mapOldChildren!=null)
|
||||
SessionUtil.setHashMapChildrenTaxonomyCache(session, null);
|
||||
|
||||
HashMap<String, TaxonomyRow> mapSynonyms = SessionUtil.getHashMapSynonymsTaxonomyCache(session);
|
||||
//Reset list synonyms to last clustering
|
||||
if(mapSynonyms!=null)
|
||||
SessionUtil.setHashMapSynonymsTaxonomyCache(session, null);
|
||||
|
||||
HashMap<String, TaxonomyRow> 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<TaxonomyRow> 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<String, ClusterCommonNameDataSourceForTaxonomyRow> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<String, ClusterCommonNameDataSourceForResultRow> hashClusterCommonNameDataSource) {
|
||||
session.setAttribute(CLUSTER_COMMONNAME_FOR_RESULTROW, hashClusterCommonNameDataSource);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hashClusterCommonNameDataSource
|
||||
* @return
|
||||
*/
|
||||
public static HashMap<String, ClusterCommonNameDataSourceForResultRow> getCurrentClusterCommonNameForResultRow(ASLSession session) {
|
||||
return (HashMap<String, ClusterCommonNameDataSourceForResultRow>) session.getAttribute(CLUSTER_COMMONNAME_FOR_RESULTROW);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param hashClusterCommonNameDataSource
|
||||
*/
|
||||
public static void setCurrentClusterCommonNameForTaxonomyRow(ASLSession session, HashMap<String, ClusterCommonNameDataSourceForTaxonomyRow> hashClusterCommonNameDataSource) {
|
||||
session.setAttribute(CLUSTER_COMMONNAME_FOR_TAXONOMYROW, hashClusterCommonNameDataSource);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hashClusterCommonNameDataSource
|
||||
* @return
|
||||
*/
|
||||
public static HashMap<String, ClusterCommonNameDataSourceForTaxonomyRow> getCurrentClusterCommonNameForTaxonomyRow(ASLSession session) {
|
||||
return (HashMap<String, ClusterCommonNameDataSourceForTaxonomyRow>) session.getAttribute(CLUSTER_COMMONNAME_FOR_TAXONOMYROW);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
public static HashMap<String, TaxonomyRow> getHashMapChildrenTaxonomyCache(ASLSession session) {
|
||||
return (HashMap<String, TaxonomyRow>) session.getAttribute(CACHE_HASH_MAP_CHILDREN_TAXONOMY);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
public static void setHashMapChildrenTaxonomyCache(ASLSession session, Map<String, TaxonomyRow> list) {
|
||||
session.setAttribute(CACHE_HASH_MAP_CHILDREN_TAXONOMY, list);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
public static HashMap<String, TaxonomyRow> getHashMapSynonymsTaxonomyCache(ASLSession session) {
|
||||
return (HashMap<String, TaxonomyRow>) session.getAttribute(CACHE_HASH_MAP_SYNONYMS_TAXONOMY);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
public static void setHashMapSynonymsTaxonomyCache(ASLSession session, Map<String, TaxonomyRow> list) {
|
||||
session.setAttribute(CACHE_HASH_MAP_SYNONYMS_TAXONOMY, list);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
public static HashMap<String, TaxonomyRow> getHashMapTaxonomyByIdsCache(ASLSession session) {
|
||||
return (HashMap<String, TaxonomyRow>) session.getAttribute(CACHE_HASH_MAP_TAXONOMYID_TAXONOMY);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
public static void setHashMapTaxonomyByIdsCache(ASLSession session, Map<String, TaxonomyRow> list) {
|
||||
session.setAttribute(CACHE_HASH_MAP_TAXONOMYID_TAXONOMY, list);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,5 +72,4 @@ public abstract class AbstractDaoBuffer<T extends FetchingElement> implements Fe
|
|||
public List<T> getList(Map<String, String> filterANDMap, int startIndex, int offset) throws Exception{
|
||||
return dao.getList(filterANDMap, startIndex, offset);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -74,5 +74,4 @@ public abstract class AbstractSelectableDaoBuffer<T extends SelectableElement> e
|
|||
return getSelected().size();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -52,8 +52,7 @@ public class ResultRowBuffer extends AbstractSelectableDaoBuffer<ResultRow> 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);
|
||||
}
|
||||
|
|
|
@ -46,8 +46,7 @@ public class TaxonomyRowBuffer extends AbstractSelectableDaoBuffer<TaxonomyRow>
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -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 Converter<TaxonomyItem, TaxonomyRo
|
|||
|
||||
return taxonomy;
|
||||
}
|
||||
|
||||
|
||||
public LightTaxonomyRow convertLightTaxonomy(TaxonomyItem input) throws Exception {
|
||||
|
||||
LightTaxonomyRow taxonomy = createLightTaxonomyRow(input);
|
||||
|
||||
//SET PARENTS
|
||||
|
||||
// System.out.println("Convert Taxonomy parent for: "+taxonomy.getId());
|
||||
|
||||
taxonomy.setParent(convertParentsLightTaxonomy(input));
|
||||
|
||||
//SET BASE TAXON
|
||||
taxonomy.setBaseTaxonValue(NormalizeString.lowerCaseUpFirstChar(getTaxonomyValue(TaxonomySearchServiceImpl.BASETAXONOMY,taxonomy)));
|
||||
|
||||
if(taxonomy.getParents()!=null && taxonomy.getParents().size()>0)
|
||||
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<TaxonomyItem, TaxonomyRo
|
|||
}
|
||||
|
||||
|
||||
private String getTaxonomyValue(String rank, LightTaxonomyRow taxon){
|
||||
|
||||
List<LightTaxonomyRow> listTaxonomy = taxon.getParents();
|
||||
|
||||
for (LightTaxonomyRow taxonomyRow : listTaxonomy) {
|
||||
|
||||
if(taxonomyRow.getRank().compareToIgnoreCase(rank)==0)
|
||||
return taxonomyRow.getName();
|
||||
}
|
||||
|
||||
return TaxonomySearchServiceImpl.TAXONOMYUNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
protected List<LightTaxonomyRow> convertParentsLightTaxonomy(TaxonomyItem taxon) throws Exception
|
||||
{
|
||||
if (taxon == null) return null;
|
||||
List<LightTaxonomyRow> listTaxonomy = new ArrayList<LightTaxonomyRow>();
|
||||
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<TaxonomyRow> convertParentsTaxonomy(TaxonomyItem taxon) throws Exception
|
||||
{
|
||||
if (taxon == null) return null;
|
||||
|
|
|
@ -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==");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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<LightTaxonomyRow> {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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<LightTaxonomyRow> 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<LightTaxonomyRow> parent) {
|
||||
this.parents = parent;
|
||||
}
|
||||
|
||||
public List<LightTaxonomyRow> 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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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 <T>
|
||||
*/
|
||||
//@Entity
|
||||
public class ClusterCommonNameDataSource<T extends FetchingElement> implements Serializable{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
private static final long serialVersionUID = -4602671242562941238L;
|
||||
|
||||
// @Id
|
||||
// @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
// private int internalId;
|
||||
|
||||
|
||||
private HashMap<String, ArrayList<String>> hashMapCommonNameDataSources = new HashMap<String, ArrayList<String>>();
|
||||
private ArrayList<String> listDataSourcesFound = new ArrayList<String>();
|
||||
|
||||
|
|
|
@ -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<ResultRow> cluster = new ClusterCommonNameDataSource<ResultRow>(); //NEW CLUSTER
|
||||
|
||||
|
||||
public ClusterCommonNameDataSourceForResultRow(){}
|
||||
|
||||
/**
|
||||
* @param scientificName
|
||||
* @param cluster
|
||||
*/
|
||||
public ClusterCommonNameDataSourceForResultRow(String scientificName, ClusterCommonNameDataSource<ResultRow> cluster) {
|
||||
super();
|
||||
this.scientificName = scientificName;
|
||||
this.cluster = cluster;
|
||||
}
|
||||
|
||||
public String getScientificName() {
|
||||
return scientificName;
|
||||
}
|
||||
|
||||
public void setScientificName(String scientificName) {
|
||||
this.scientificName = scientificName;
|
||||
}
|
||||
|
||||
public ClusterCommonNameDataSource<ResultRow> getCluster() {
|
||||
return cluster;
|
||||
}
|
||||
|
||||
public void setCluster(ClusterCommonNameDataSource<ResultRow> 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();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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<TaxonomyRow> cluster = new ClusterCommonNameDataSource<TaxonomyRow>(); //NEW CLUSTER
|
||||
|
||||
|
||||
public ClusterCommonNameDataSourceForTaxonomyRow(){}
|
||||
|
||||
/**
|
||||
* @param scientificName
|
||||
* @param cluster
|
||||
*/
|
||||
public ClusterCommonNameDataSourceForTaxonomyRow(String scientificName, ClusterCommonNameDataSource<TaxonomyRow> cluster) {
|
||||
super();
|
||||
this.scientificName = scientificName;
|
||||
this.cluster = cluster;
|
||||
}
|
||||
|
||||
public String getScientificName() {
|
||||
return scientificName;
|
||||
}
|
||||
|
||||
public void setScientificName(String scientificName) {
|
||||
this.scientificName = scientificName;
|
||||
}
|
||||
|
||||
public ClusterCommonNameDataSource<TaxonomyRow> getCluster() {
|
||||
return cluster;
|
||||
}
|
||||
|
||||
public void setCluster(ClusterCommonNameDataSource<TaxonomyRow> 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();
|
||||
}
|
||||
|
||||
}
|
|
@ -22,51 +22,36 @@ public class ClusterStructuresForResultRow implements Serializable{
|
|||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1205113606387863736L;
|
||||
|
||||
private ArrayList<String> listResultRowID;
|
||||
private Map<String, ResultRow> hashResult = new HashMap<String, ResultRow>();
|
||||
private ArrayList<String> listResultRowServiceID;
|
||||
private ArrayList<String> listFoundDataSources = new ArrayList<String>();
|
||||
private HashMap<String,ClusterCommonNameDataSource<ResultRow>> hashClusterCommonNamesDataSources = new HashMap<String,ClusterCommonNameDataSource<ResultRow>>(); //HASH scientific name - cluster
|
||||
private HashMap<String, ArrayList<String>> hashScientificNameResultRowID = new HashMap<String, ArrayList<String>>(); //HASH scientific name - result row ID
|
||||
private HashMap<String, ArrayList<String>> hashScientificNameResultRowServiceID = new HashMap<String, ArrayList<String>>(); //HASH scientific name - result row service ID
|
||||
private boolean isReduced;
|
||||
private int totalRow;
|
||||
private int allResultRowSize;
|
||||
|
||||
private int resultSize;
|
||||
|
||||
private Map<String, ResultRow> hashResult = new HashMap<String, ResultRow>(); //HASH result row service ID - result row
|
||||
|
||||
public ClusterStructuresForResultRow(){}
|
||||
|
||||
public ClusterStructuresForResultRow(SearchResult<ResultRow> 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<String> listResultRowServiceID = hashScientificNameResultRowID.get(scientificName); //get RR serviceID
|
||||
|
||||
ClusterCommonNameDataSource<ResultRow> cluster = new ClusterCommonNameDataSource<ResultRow>(); //NEW CLUSTER
|
||||
|
||||
for(int i=0; i<listResultRowServiceID.size(); i++){
|
||||
ResultRow row = hashResult.get(listResultRowServiceID.get(i));
|
||||
cluster.updateHashCommonNamesDataSources(row);
|
||||
}
|
||||
|
||||
hashClusterCommonNamesDataSources.put(scientificName, cluster);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void createStructures(ArrayList<ResultRow> 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<String>(); //USED FOR CLUSTER COMMON NAMES
|
||||
listResultRowServiceID = new ArrayList<String>(); //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<String, ArrayList<String>> getHashClusterScientificNameResultRowID() {
|
||||
return hashScientificNameResultRowID;
|
||||
public HashMap<String, ArrayList<String>> getHashClusterScientificNameResultRowServiceID() {
|
||||
return hashScientificNameResultRowServiceID;
|
||||
}
|
||||
|
||||
public List<String> getListFoundDataSources() {
|
||||
return listFoundDataSources;
|
||||
}
|
||||
|
||||
public HashMap<String, ClusterCommonNameDataSource<ResultRow>> getHashClusterCommonNamesDataSources() {
|
||||
return hashClusterCommonNamesDataSources;
|
||||
public ArrayList<String> getListResultRowID() {
|
||||
return listResultRowServiceID;
|
||||
}
|
||||
|
||||
public List<ResultRow> getResult() {
|
||||
return new ArrayList<ResultRow>(hashResult.values());
|
||||
}
|
||||
|
||||
public ResultRow getResultRowByRowID(String key) {
|
||||
return hashResult.get(key);
|
||||
public void setListResultRowID(ArrayList<String> 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<String> listFoundDataSources) {
|
||||
this.listFoundDataSources = listFoundDataSources;
|
||||
}
|
||||
|
||||
public Map<String, ResultRow> getHashResult() {
|
||||
return hashResult;
|
||||
}
|
||||
|
||||
public void setHashResult(Map<String, ResultRow> hashResult) {
|
||||
this.hashResult = hashResult;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<String, TaxonomyRow> hashResult = new HashMap<String, TaxonomyRow>();
|
||||
private HashMap<String,ClusterCommonNameDataSource<TaxonomyRow>> hashClusterCommonNamesDataSources = new HashMap<String,ClusterCommonNameDataSource<TaxonomyRow>>();
|
||||
private HashMap<String, ArrayList<String>> hashClusterScientificNameTaxonomyRowID = new HashMap<String, ArrayList<String>>(); //HASH scientific name - taxonomy row ID
|
||||
//USED ON CLIENT
|
||||
private Map<String, LightTaxonomyRow> hashLightResult = new HashMap<String, LightTaxonomyRow>();
|
||||
|
||||
private HashMap<String, ArrayList<String>> hashClusterScientificNameTaxonomyRowServiceID = new HashMap<String, ArrayList<String>>(); //HASH scientific name - taxonomy row service ID
|
||||
private ArrayList<String> listFoundDataSources = new ArrayList<String>();
|
||||
private ArrayList<String> listTaxonomyRowID;
|
||||
private ArrayList<String> listTaxonomyRowServiceID;
|
||||
|
||||
private boolean isReduced;
|
||||
|
||||
private int totalRow;
|
||||
|
||||
//USED ON SERVER FOR CLUSERING ON COMMON NAMES
|
||||
private Map<String, TaxonomyRow> hashResult = new HashMap<String, TaxonomyRow>();
|
||||
|
||||
public ClusterStructuresForTaxonomyRow(){
|
||||
|
||||
}
|
||||
|
||||
public ClusterStructuresForTaxonomyRow(SearchResult<TaxonomyRow> 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<TaxonomyRow> sublistParents = new ArrayList<TaxonomyRow>();
|
||||
//// 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<LightTaxonomyRow> parents = new ArrayList<LightTaxonomyRow>();
|
||||
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<TaxonomyRow> 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<String>(); //USED FOR CLUSTER COMMON NAMES
|
||||
listTaxonomyRowServiceID = new ArrayList<String>(); //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<String> listTaxonomyRowID = hashClusterScientificNameTaxonomyRowID.get(scientificName);
|
||||
|
||||
ClusterCommonNameDataSource<TaxonomyRow> cluster = new ClusterCommonNameDataSource<TaxonomyRow>(); //NEW CLUSTER
|
||||
|
||||
for(int i=0; i<listTaxonomyRowID.size(); i++){
|
||||
TaxonomyRow row = hashResult.get(listTaxonomyRowID.get(i));
|
||||
cluster.updateHashCommonNamesDataSources(row);
|
||||
}
|
||||
|
||||
hashClusterCommonNamesDataSources.put(scientificName, cluster);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<String> getListFoundDataSources() {
|
||||
return listFoundDataSources;
|
||||
}
|
||||
|
||||
public HashMap<String, ArrayList<String>> getHashClusterScientificNameTaxonomyRowID() {
|
||||
return hashClusterScientificNameTaxonomyRowID;
|
||||
public HashMap<String, ArrayList<String>> getHashClusterScientificNameTaxonomyRowServiceID() {
|
||||
return hashClusterScientificNameTaxonomyRowServiceID;
|
||||
}
|
||||
|
||||
public HashMap<String, ClusterCommonNameDataSource<TaxonomyRow>> getHashClusterCommonNamesDataSources() {
|
||||
return hashClusterCommonNamesDataSources;
|
||||
}
|
||||
|
||||
public ArrayList<TaxonomyRow> getResult() {
|
||||
return new ArrayList<TaxonomyRow>(hashResult.values());
|
||||
public ArrayList<LightTaxonomyRow> getResult() {
|
||||
return new ArrayList<LightTaxonomyRow>(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<String, LightTaxonomyRow> getHashLightResult() {
|
||||
return hashLightResult;
|
||||
}
|
||||
|
||||
public Map<String, TaxonomyRow> getHashResult() {
|
||||
return hashResult;
|
||||
}
|
||||
|
||||
public void setHashResult(Map<String, TaxonomyRow> hashResult) {
|
||||
this.hashResult = hashResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<String, ArrayList<String>> hashScientificNameResultRowServiceID = new HashMap<String, ArrayList<String>>(); //HASH scientific name - result row service ID
|
||||
private Map<String, ResultRow> hashResult = new HashMap<String, ResultRow>();
|
||||
|
||||
private HashMap<String, ClusterCommonNameDataSourceForResultRow> hashClusterCommonNameDataSource = new HashMap<String, ClusterCommonNameDataSourceForResultRow>(); //HASH scientific name - cluster
|
||||
|
||||
|
||||
/**
|
||||
* @param hashScientificNameResultRowID
|
||||
* @param hashClusterCommonNameDataSource
|
||||
* @param hashResult
|
||||
* @throws Exception
|
||||
*/
|
||||
public ManagerClusterCommonNameDataSourceForResultRow(HashMap<String, ArrayList<String>> hashScientificNameResultRowID, Map<String, ResultRow> 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<String> listResultRowServiceID = hashScientificNameResultRowServiceID.get(scientificName); //get RR serviceID
|
||||
|
||||
ClusterCommonNameDataSource<ResultRow> cluster = new ClusterCommonNameDataSource<ResultRow>(); //NEW CLUSTER
|
||||
|
||||
for(int i=0; i<listResultRowServiceID.size(); i++){
|
||||
ResultRow row = hashResult.get(listResultRowServiceID.get(i));
|
||||
cluster.updateHashCommonNamesDataSources(row);
|
||||
}
|
||||
|
||||
hashClusterCommonNameDataSource.put(scientificName, new ClusterCommonNameDataSourceForResultRow(scientificName, cluster));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public HashMap<String, ArrayList<String>> getHashScientificNameResultRowID() {
|
||||
return hashScientificNameResultRowServiceID;
|
||||
}
|
||||
|
||||
|
||||
public void setHashScientificNameResultRowID(
|
||||
HashMap<String, ArrayList<String>> hashScientificNameResultRowID) {
|
||||
this.hashScientificNameResultRowServiceID = hashScientificNameResultRowID;
|
||||
}
|
||||
|
||||
|
||||
public HashMap<String, ClusterCommonNameDataSourceForResultRow> getHashClusterCommonNameDataSource() {
|
||||
return hashClusterCommonNameDataSource;
|
||||
}
|
||||
|
||||
|
||||
public void setHashClusterCommonNameDataSource(
|
||||
HashMap<String, ClusterCommonNameDataSourceForResultRow> hashClusterCommonNameDataSource) {
|
||||
this.hashClusterCommonNameDataSource = hashClusterCommonNameDataSource;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, ResultRow> getHashResult() {
|
||||
return hashResult;
|
||||
}
|
||||
|
||||
|
||||
public void setHashResult(Map<String, ResultRow> 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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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<String, ArrayList<String>> hashScientificNameTaxonomyRowServiceID = new HashMap<String, ArrayList<String>>(); //HASH scientific name - taxonomy row service ID
|
||||
private Map<String, TaxonomyRow> hashResult = new HashMap<String, TaxonomyRow>();
|
||||
|
||||
private HashMap<String, ClusterCommonNameDataSourceForTaxonomyRow> hashClusterCommonNameDataSource = new HashMap<String, ClusterCommonNameDataSourceForTaxonomyRow>(); //HASH scientific name - cluster
|
||||
|
||||
|
||||
/**
|
||||
* @param hashScientificNameResultRowServiceID
|
||||
* @param hashClusterCommonNameDataSource
|
||||
* @param hashResult
|
||||
* @throws Exception
|
||||
*/
|
||||
public ManagerClusterCommonNameDataSourceForTaxonomyRow(HashMap<String, ArrayList<String>> hashScientificNameResultRowServiceID, Map<String, TaxonomyRow> 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<String> listTaxonomyRowServiceID = hashScientificNameTaxonomyRowServiceID.get(scientificName);
|
||||
|
||||
ClusterCommonNameDataSource<TaxonomyRow> cluster = new ClusterCommonNameDataSource<TaxonomyRow>(); //NEW CLUSTER
|
||||
|
||||
for(int i=0; i<listTaxonomyRowServiceID.size(); i++){
|
||||
TaxonomyRow row = hashResult.get(listTaxonomyRowServiceID.get(i));
|
||||
cluster.updateHashCommonNamesDataSources(row);
|
||||
}
|
||||
|
||||
hashClusterCommonNameDataSource.put(scientificName, new ClusterCommonNameDataSourceForTaxonomyRow(scientificName, cluster));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public HashMap<String, ArrayList<String>> getHashScientificNameResultRowID() {
|
||||
return hashScientificNameTaxonomyRowServiceID;
|
||||
}
|
||||
|
||||
|
||||
public void setHashScientificNameResultRowID(
|
||||
HashMap<String, ArrayList<String>> hashScientificNameResultRowID) {
|
||||
this.hashScientificNameTaxonomyRowServiceID = hashScientificNameResultRowID;
|
||||
}
|
||||
|
||||
|
||||
public HashMap<String, ClusterCommonNameDataSourceForTaxonomyRow> getHashClusterCommonNameDataSource() {
|
||||
return hashClusterCommonNameDataSource;
|
||||
}
|
||||
|
||||
|
||||
public void setHashClusterCommonNameDataSource(HashMap<String, ClusterCommonNameDataSourceForTaxonomyRow> hashClusterCommonNameDataSource) {
|
||||
this.hashClusterCommonNameDataSource = hashClusterCommonNameDataSource;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, TaxonomyRow> getHashResult() {
|
||||
return hashResult;
|
||||
}
|
||||
|
||||
|
||||
public void setHashResult(Map<String, TaxonomyRow> 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();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue