git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/speciesdiscovery@71065 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
a8a203bb1c
commit
6282760e36
|
@ -112,7 +112,7 @@ public class TaxonomyRowDataSource implements DataSource {
|
|||
String author = "";
|
||||
List<ItemParameter> hashProperties = new ArrayList<ItemParameter>();
|
||||
|
||||
Log.trace("Taxonomy returned in client: " + row);
|
||||
// Log.trace("Taxonomy returned in client: " + row);
|
||||
|
||||
if(row.getDataProviderName()!=null) dataProviderName = row.getDataProviderName();
|
||||
if(row.getDataSetCitation()!=null) dataSetCitation = row.getDataSetCitation();
|
||||
|
|
|
@ -6,7 +6,7 @@ package org.gcube.portlets.user.speciesdiscovery.server.persistence;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.gcube.portlets.user.speciesdiscovery.server.persistence.dao.AbstractPersistence;
|
||||
import org.gcube.portlets.user.speciesdiscovery.server.session.FetchingBuffer;
|
||||
import org.gcube.portlets.user.speciesdiscovery.shared.FetchingElement;
|
||||
|
@ -17,7 +17,7 @@ import org.gcube.portlets.user.speciesdiscovery.shared.FetchingElement;
|
|||
*/
|
||||
public abstract class AbstractDaoBuffer<T extends FetchingElement> implements FetchingBuffer<T> {
|
||||
|
||||
protected GCUBELog logger = new GCUBELog(AbstractDaoBuffer.class);
|
||||
protected Logger logger = Logger.getLogger(AbstractDaoBuffer.class);
|
||||
|
||||
protected AbstractPersistence<T> dao;
|
||||
|
||||
|
|
|
@ -161,7 +161,8 @@ public class ResultRowBuffer extends AbstractSelectableDaoBuffer<ResultRow> impl
|
|||
try {
|
||||
|
||||
CriteriaBuilder queryBuilder = taxonDao.getCriteriaBuilder();
|
||||
value = NormalizeString.lowerCaseUpFirstChar(activeFiltersObject.getRankName());
|
||||
value = activeFiltersObject.getRankName();
|
||||
// value = NormalizeString.lowerCaseUpFirstChar(activeFiltersObject.getRankName());
|
||||
CriteriaQuery<Object> cq = queryBuilder.createQuery();
|
||||
Predicate pr1 = queryBuilder.equal(taxonDao.rootFrom(cq).get(Taxon.RANK), NormalizeString.validateUndefined(value));
|
||||
cq.where(pr1);
|
||||
|
|
|
@ -129,7 +129,7 @@ public class TaxonomyRowBuffer extends AbstractSelectableDaoBuffer<TaxonomyRow>
|
|||
cq.where(pr1);
|
||||
|
||||
//TODO FIXME empty value
|
||||
logger.trace("FILTER BY DATA PROVIDER: "+ value );
|
||||
logger.trace("FILTER BY DATA SOURCE: "+ value );
|
||||
|
||||
iterator = dao.executeCriteriaQuery(cq).iterator();
|
||||
|
||||
|
@ -145,12 +145,15 @@ public class TaxonomyRowBuffer extends AbstractSelectableDaoBuffer<TaxonomyRow>
|
|||
try {
|
||||
|
||||
CriteriaBuilder queryBuilder = dao.getCriteriaBuilder();
|
||||
value = NormalizeString.lowerCaseUpFirstChar(activeFiltersObject.getRankName());
|
||||
value = activeFiltersObject.getRankName();
|
||||
// value = NormalizeString.lowerCaseUpFirstChar(activeFiltersObject.getRankName());
|
||||
logger.trace("in rank filter - value: "+value);
|
||||
CriteriaQuery<Object> cq = queryBuilder.createQuery();
|
||||
Predicate pr1 = queryBuilder.equal(dao.rootFrom(cq).get(TaxonomyRow.RANK), NormalizeString.validateUndefined(value));
|
||||
cq.where(pr1);
|
||||
|
||||
logger.trace("FILTER BY RANK: "+ value );
|
||||
|
||||
iterator = dao.executeCriteriaQuery(cq).iterator();
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.gcube.portlets.user.speciesdiscovery.server.service;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.data.spd.model.TaxonomyItem;
|
||||
|
@ -62,55 +61,55 @@ public class TaxonomyItemConverter implements Converter<TaxonomyItem, TaxonomyRo
|
|||
//Fill properties
|
||||
if(listProperties!=null){
|
||||
for (ElementProperty elementProperty : listProperties)
|
||||
tax.getProperties().add(new ItemParameter(StringEscapeUtils.escapeSql(elementProperty.getName()), StringEscapeUtils.escapeSql(elementProperty.getValue())));
|
||||
tax.getProperties().add(new ItemParameter(elementProperty.getName(), elementProperty.getValue()));
|
||||
|
||||
tax.setExistsProperties(true);
|
||||
}
|
||||
|
||||
if(input.getId()!=null){
|
||||
tax.setServiceId(StringEscapeUtils.escapeSql(input.getId()));
|
||||
tax.setServiceId(input.getId());
|
||||
}
|
||||
|
||||
if(input.getAuthor()!=null && !input.getAuthor().isEmpty()){
|
||||
tax.setAuthor(StringEscapeUtils.escapeSql(input.getAuthor()));
|
||||
tax.setAuthor(input.getAuthor());
|
||||
}
|
||||
else
|
||||
tax.setAuthor(ConstantsSpeciesDiscovery.NOT_FOUND);
|
||||
|
||||
if(input.getCredits()!=null && !input.getCredits().isEmpty()){
|
||||
tax.setCredits(StringEscapeUtils.escapeSql(input.getCredits()));
|
||||
tax.setCredits(input.getCredits());
|
||||
}
|
||||
else
|
||||
tax.setCredits(ConstantsSpeciesDiscovery.NOT_FOUND);
|
||||
|
||||
if(input.getLsid()!=null && !input.getLsid().isEmpty()){
|
||||
tax.setLsid(StringEscapeUtils.escapeSql(input.getLsid()));
|
||||
tax.setLsid(input.getLsid());
|
||||
}
|
||||
else
|
||||
tax.setLsid(ConstantsSpeciesDiscovery.NOT_FOUND);
|
||||
|
||||
if(input.getProvider()!=null && !input.getProvider().isEmpty()){
|
||||
tax.setDataProviderId(StringEscapeUtils.escapeSql(input.getProvider()));
|
||||
tax.setDataProviderName(StringEscapeUtils.escapeSql(input.getProvider()));
|
||||
tax.setDataProviderId(input.getProvider());
|
||||
tax.setDataProviderName(input.getProvider());
|
||||
}else{
|
||||
tax.setDataProviderId(ConstantsSpeciesDiscovery.NOT_FOUND);
|
||||
tax.setDataProviderName(ConstantsSpeciesDiscovery.NOT_FOUND);
|
||||
}
|
||||
|
||||
if(input.getCitation()!=null && !input.getCitation().isEmpty()){
|
||||
tax.setDataSetCitation(StringEscapeUtils.escapeSql(input.getCitation()));
|
||||
tax.setDataSetCitation(input.getCitation());
|
||||
}else{
|
||||
tax.setDataSetCitation(ConstantsSpeciesDiscovery.NOT_FOUND);
|
||||
}
|
||||
|
||||
if(input.getRank()!=null && !input.getRank().isEmpty()){
|
||||
tax.setRank(StringEscapeUtils.escapeSql(NormalizeString.lowerCaseUpFirstChar(input.getRank())));
|
||||
tax.setRank(NormalizeString.lowerCaseUpFirstChar(input.getRank()));
|
||||
}else{
|
||||
tax.setRank(ConstantsSpeciesDiscovery.NOT_FOUND);
|
||||
}
|
||||
|
||||
if(input.getScientificName()!=null && !input.getScientificName().isEmpty()){
|
||||
tax.setName(StringEscapeUtils.escapeSql(input.getScientificName()));
|
||||
tax.setName(input.getScientificName());
|
||||
}else{
|
||||
tax.setName(ConstantsSpeciesDiscovery.NOT_FOUND);
|
||||
}
|
||||
|
@ -118,14 +117,14 @@ public class TaxonomyItemConverter implements Converter<TaxonomyItem, TaxonomyRo
|
|||
if(input.getStatus()!=null){
|
||||
|
||||
if(input.getStatus().getRefId()!=null && !input.getStatus().getRefId().isEmpty()){
|
||||
tax.setStatusRefId(StringEscapeUtils.escapeSql(input.getStatus().getRefId()));
|
||||
tax.setStatusRefId(input.getStatus().getRefId());
|
||||
}else{
|
||||
tax.setStatusRefId("");
|
||||
}
|
||||
|
||||
|
||||
if(input.getStatus().getStatusAsString()!=null && !input.getStatus().getStatusAsString().isEmpty()){
|
||||
tax.setStatusRemarks(StringEscapeUtils.escapeSql(input.getStatus().getStatusAsString()));
|
||||
tax.setStatusRemarks(input.getStatus().getStatusAsString());
|
||||
}else{
|
||||
tax.setStatusRemarks(ConstantsSpeciesDiscovery.NOT_FOUND);
|
||||
}
|
||||
|
@ -133,7 +132,7 @@ public class TaxonomyItemConverter implements Converter<TaxonomyItem, TaxonomyRo
|
|||
if(input.getStatus().getStatus()!=null){
|
||||
|
||||
if(input.getStatus().getStatus().name()!=null && !input.getStatus().getStatus().name().isEmpty()){
|
||||
tax.setStatusName(StringEscapeUtils.escapeSql(input.getStatus().getStatus().name()));
|
||||
tax.setStatusName(input.getStatus().getStatus().name());
|
||||
}else{
|
||||
tax.setStatusName(ConstantsSpeciesDiscovery.NOT_FOUND);
|
||||
}
|
||||
|
|
|
@ -67,6 +67,8 @@ public class Fetcher<T extends FetchingElement> implements Runnable, Closeable {
|
|||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error in source.next() " + e.getMessage(), e);
|
||||
e.printStackTrace();
|
||||
silentClose();
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,7 +82,7 @@ public class Fetcher<T extends FetchingElement> implements Runnable, Closeable {
|
|||
}
|
||||
|
||||
if(source==null)
|
||||
logger.trace("exit because source iterator is null");
|
||||
logger.warn("exit because source iterator is null");
|
||||
|
||||
logger.trace("exit fetch run - complete true");
|
||||
complete = true;
|
||||
|
@ -93,7 +95,7 @@ public class Fetcher<T extends FetchingElement> implements Runnable, Closeable {
|
|||
try {
|
||||
close();
|
||||
} catch (IOException e) {
|
||||
logger.warn("Error during silent close", e);
|
||||
logger.error("Error during silent close", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyProvider;
|
|||
|
||||
/**
|
||||
* @author "Federico De Faveri defaveri@isti.cnr.it"
|
||||
* modified by Francesco Mangiacrapa february 2013
|
||||
*
|
||||
*/
|
||||
public class TaxonomyClassificationAggregator<T extends TaxonomyProvider> implements Aggregator<T, EnumMap<MainTaxonomicRankEnum, HashMap<String, ClassificationModel>>> {
|
||||
|
@ -52,7 +53,7 @@ public class TaxonomyClassificationAggregator<T extends TaxonomyProvider> implem
|
|||
|
||||
List<? extends TaxonomyInterface> matchingTaxon = row.getParents();
|
||||
|
||||
if(matchingTaxon == null) return;
|
||||
if(matchingTaxon == null || matchingTaxon.size()==0) return;
|
||||
|
||||
EnumMap<MainTaxonomicRankEnum, TaxonomyInterface> groupedTaxon = groupTaxonByRank(matchingTaxon);
|
||||
|
||||
|
@ -86,45 +87,6 @@ public class TaxonomyClassificationAggregator<T extends TaxonomyProvider> implem
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO RIFARE
|
||||
// TaxonomyInterface matchingTaxon = row.getParents();
|
||||
//
|
||||
// if(matchingTaxon == null) return;
|
||||
//
|
||||
// EnumMap<MainTaxonomicRankEnum, TaxonomyInterface> groupedTaxon = groupTaxonByRank(matchingTaxon);
|
||||
//
|
||||
// for (MainTaxonomicRankEnum aggregationRank: MainTaxonomicRankEnum.values()){
|
||||
//
|
||||
// TaxonomyInterface taxon = groupedTaxon.get(aggregationRank);
|
||||
//
|
||||
// String taxonId;
|
||||
//
|
||||
// //IF RANK CLASS EXISTS INSERT INTO HASHMAP GROUP BY RANK
|
||||
// if (taxon!=null && taxon.getName()!=null) {
|
||||
// taxonId = addTaxonToAggregation(aggregationRank, taxon, row.getBaseTaxonValue(), row.getBaseTaxonValue(), taxon.getRank());
|
||||
// setClassification(row, aggregationRank, taxonId);
|
||||
// } else {
|
||||
//
|
||||
// String unknownRank = matchingTaxon.getRank()!=null?matchingTaxon.getRank():TAXONOMYUNKNOWN; // GET THE FIRST RANK CLASS
|
||||
//
|
||||
// //IF BASETAXONOMY CLASS IS NOT UNKNOWN - INSERT INTO HASHMAP GROUP BY FIRST RANK
|
||||
// if(!row.getBaseTaxonValue().equalsIgnoreCase(TAXONOMYUNKNOWN)) {
|
||||
// taxonId = addTaxonToAggregation(aggregationRank, row.getParents(), row.getBaseTaxonValue(), row.getBaseTaxonValue(), unknownRank);
|
||||
// setClassification(row, aggregationRank, taxonId);
|
||||
// } else {
|
||||
// //BASETAXONOMY UNKNOWN - INSERT INTO HASHMAP GROUP BY haskKey UNKNOWN RANK
|
||||
//
|
||||
// String haskKey = "["+UNK+" "+aggregationRank+"]" + " "+unknownRank;
|
||||
// String unkName = matchingTaxon.getName()!=null?matchingTaxon.getName():TAXONOMYUNKNOWN; // GET THE FIRST RANK NAME
|
||||
//
|
||||
// taxonId = addTaxonToAggregation(aggregationRank, haskKey, unkName, row.getBaseTaxonValue(), row.getBaseTaxonValue(), unknownRank);
|
||||
// setClassification(row, aggregationRank, taxonId);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
protected void setClassification(TaxonomyProvider input, MainTaxonomicRankEnum rank, String value)
|
||||
|
@ -151,33 +113,10 @@ public class TaxonomyClassificationAggregator<T extends TaxonomyProvider> implem
|
|||
if (rank!=null) groupedTaxon.put(rank, taxonomyInterface);
|
||||
}
|
||||
}
|
||||
|
||||
// while(taxon!=null){
|
||||
// if (taxon.getRank()!=null) {
|
||||
// MainTaxonomicRankEnum rank = RANKS.get(taxon.getRank().toLowerCase());
|
||||
// if (rank!=null) groupedTaxon.put(rank, taxon);
|
||||
// }
|
||||
// taxon = taxon.getParent();
|
||||
// }
|
||||
|
||||
return groupedTaxon;
|
||||
}
|
||||
|
||||
// protected EnumMap<MainTaxonomicRankEnum, TaxonomyInterface> groupTaxonByRank(TaxonomyInterface taxon)
|
||||
// {
|
||||
// EnumMap<MainTaxonomicRankEnum, TaxonomyInterface> groupedTaxon = new EnumMap<MainTaxonomicRankEnum, TaxonomyInterface>(MainTaxonomicRankEnum.class);
|
||||
//
|
||||
// while(taxon!=null){
|
||||
// if (taxon.getRank()!=null) {
|
||||
// MainTaxonomicRankEnum rank = RANKS.get(taxon.getRank().toLowerCase());
|
||||
// if (rank!=null) groupedTaxon.put(rank, taxon);
|
||||
// }
|
||||
// taxon = taxon.getParent();
|
||||
// }
|
||||
//
|
||||
// return groupedTaxon;
|
||||
// }
|
||||
|
||||
protected String addTaxonToAggregation(MainTaxonomicRankEnum aggregationRank, TaxonomyInterface taxon, String baseTaxonId, String baseTaxonValue, String classificationRank)
|
||||
{
|
||||
String taxonName = taxon.getName().toLowerCase();
|
||||
|
|
|
@ -426,65 +426,65 @@ public class TaxonomyRow implements FetchingElement, Serializable, TaxonomyInter
|
|||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("TaxonomyRow [id=");
|
||||
// builder.append(id);
|
||||
// builder.append(", author=");
|
||||
// builder.append(author);
|
||||
// builder.append(", credits=");
|
||||
// builder.append(credits);
|
||||
// builder.append(", lsid=");
|
||||
// builder.append(lsid);
|
||||
// builder.append(", name=");
|
||||
// builder.append(name);
|
||||
// builder.append(", serviceIdField=");
|
||||
// builder.append(serviceIdField);
|
||||
// builder.append(", selected=");
|
||||
// builder.append(selected);
|
||||
// builder.append(", dataProviderId=");
|
||||
// builder.append(dataProviderId);
|
||||
// builder.append(", dataProviderName=");
|
||||
// builder.append(dataProviderName);
|
||||
// builder.append(", dataSetCitation=");
|
||||
// builder.append(dataSetCitation);
|
||||
// builder.append(", matchingAccording=");
|
||||
// builder.append(matchingAccording);
|
||||
// builder.append(", baseTaxonValue=");
|
||||
// builder.append(baseTaxonValue);
|
||||
// builder.append(", rank=");
|
||||
// builder.append(rank);
|
||||
// builder.append(", statusRefId=");
|
||||
// builder.append(statusRefId);
|
||||
// builder.append(", statusName=");
|
||||
// builder.append(statusName);
|
||||
// builder.append(", dateModified=");
|
||||
// builder.append(dateModified);
|
||||
// builder.append(", kingdomID=");
|
||||
// builder.append(kingdomID);
|
||||
// builder.append(", phylumID=");
|
||||
// builder.append(phylumID);
|
||||
// builder.append(", classID=");
|
||||
// builder.append(classID);
|
||||
// builder.append(", orderID=");
|
||||
// builder.append(orderID);
|
||||
// builder.append(", familyID=");
|
||||
// builder.append(familyID);
|
||||
// builder.append(", genusID=");
|
||||
// builder.append(genusID);
|
||||
// builder.append(", speciesID=");
|
||||
// builder.append(speciesID);
|
||||
// builder.append(", existsCommonName=");
|
||||
// builder.append(existsCommonName);
|
||||
// builder.append(", statusRemarks=");
|
||||
// builder.append(statusRemarks);
|
||||
// builder.append(", existsProperties=");
|
||||
// builder.append(existsProperties);
|
||||
// builder.append(", isParent=");
|
||||
// builder.append(isParent);
|
||||
builder.append(id);
|
||||
builder.append(", author=");
|
||||
builder.append(author);
|
||||
builder.append(", credits=");
|
||||
builder.append(credits);
|
||||
builder.append(", lsid=");
|
||||
builder.append(lsid);
|
||||
builder.append(", name=");
|
||||
builder.append(name);
|
||||
builder.append(", serviceIdField=");
|
||||
builder.append(serviceIdField);
|
||||
builder.append(", selected=");
|
||||
builder.append(selected);
|
||||
builder.append(", dataProviderId=");
|
||||
builder.append(dataProviderId);
|
||||
builder.append(", dataProviderName=");
|
||||
builder.append(dataProviderName);
|
||||
builder.append(", dataSetCitation=");
|
||||
builder.append(dataSetCitation);
|
||||
builder.append(", matchingAccording=");
|
||||
builder.append(matchingAccording);
|
||||
builder.append(", baseTaxonValue=");
|
||||
builder.append(baseTaxonValue);
|
||||
builder.append(", rank=");
|
||||
builder.append(rank);
|
||||
builder.append(", statusRefId=");
|
||||
builder.append(statusRefId);
|
||||
builder.append(", statusName=");
|
||||
builder.append(statusName);
|
||||
builder.append(", dateModified=");
|
||||
builder.append(dateModified);
|
||||
builder.append(", kingdomID=");
|
||||
builder.append(kingdomID);
|
||||
builder.append(", phylumID=");
|
||||
builder.append(phylumID);
|
||||
builder.append(", classID=");
|
||||
builder.append(classID);
|
||||
builder.append(", orderID=");
|
||||
builder.append(orderID);
|
||||
builder.append(", familyID=");
|
||||
builder.append(familyID);
|
||||
builder.append(", genusID=");
|
||||
builder.append(genusID);
|
||||
builder.append(", speciesID=");
|
||||
builder.append(speciesID);
|
||||
builder.append(", existsCommonName=");
|
||||
builder.append(existsCommonName);
|
||||
builder.append(", statusRemarks=");
|
||||
builder.append(statusRemarks);
|
||||
builder.append(", existsProperties=");
|
||||
builder.append(existsProperties);
|
||||
builder.append(", isParent=");
|
||||
builder.append(isParent);
|
||||
builder.append(", commonNames=");
|
||||
builder.append(commonNames);
|
||||
builder.append(", properties=");
|
||||
builder.append(properties);
|
||||
// builder.append(", parents=");
|
||||
// builder.append(parents);
|
||||
builder.append(", parents=");
|
||||
builder.append(parents);
|
||||
builder.append(", parentID=");
|
||||
builder.append(parentID);
|
||||
builder.append("]");
|
||||
|
|
Reference in New Issue