fixed bug on ranking, after use case: check all/ unceck all
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/speciesdiscovery@77520 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d4b70cdff1
commit
88ecdfdfc1
32
pom.xml
32
pom.xml
|
@ -19,7 +19,7 @@
|
|||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>species-discovery</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>3.2.0-SNAPSHOT</version>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
<name>gCube Species Discovery</name>
|
||||
<description>
|
||||
gCube Species Discovery Portlet lets the users discovery species information from the Species Service.
|
||||
|
@ -52,12 +52,12 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>org.gcube.core</groupId> -->
|
||||
<!-- <artifactId>common-fw-clients</artifactId> -->
|
||||
<!-- <version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version> -->
|
||||
<!-- <scope>runtime</scope> -->
|
||||
<!-- </dependency> -->
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>org.gcube.core</groupId> -->
|
||||
<!-- <artifactId>common-fw-clients</artifactId> -->
|
||||
<!-- <version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version> -->
|
||||
<!-- <scope>runtime</scope> -->
|
||||
<!-- </dependency> -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.data.spd</groupId>
|
||||
|
@ -77,8 +77,8 @@
|
|||
<groupId>org.gcube.data.spd</groupId>
|
||||
<artifactId>spd-model</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<!-- <version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version> -->
|
||||
<!-- <scope>provided</scope> -->
|
||||
<!-- <version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version> -->
|
||||
<!-- <scope>provided</scope> -->
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -105,7 +105,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-wrapper</artifactId>
|
||||
<!-- <version>[1.0.1-SNAPSHOT, 1.1.0-SNAPSHOT)</version> -->
|
||||
<!-- <version>[1.0.1-SNAPSHOT, 1.1.0-SNAPSHOT)</version> -->
|
||||
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
@ -113,7 +113,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-core</artifactId>
|
||||
<!-- <version>[1.0.1-SNAPSHOT, 1.11.0-SNAPSHOT)</version> -->
|
||||
<!-- <version>[1.0.1-SNAPSHOT, 1.11.0-SNAPSHOT)</version> -->
|
||||
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
@ -259,6 +259,15 @@
|
|||
<version>2.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- LOGGER -->
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.16</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
|
@ -271,6 +280,7 @@
|
|||
<version>1.6.4</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
|
|
@ -355,7 +355,7 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
|||
resultRow.setProperties(null);
|
||||
}
|
||||
|
||||
// System.out.println("resultRow "+resultRow);
|
||||
System.out.println("################### ResultRow parents: "+resultRow.getParents());
|
||||
|
||||
chunk.add(resultRow);
|
||||
|
||||
|
|
|
@ -105,8 +105,8 @@ public class SessionUtil {
|
|||
// user = "pasquale.pagano";
|
||||
// user = "lucio.lelii";
|
||||
|
||||
// String scope = "/gcube/devsec"; //Development
|
||||
String scope = "/d4science.research-infrastructures.eu/gCubeApps/BiodiversityResearchEnvironment"; //Production
|
||||
String scope = "/gcube/devsec"; //Development
|
||||
// String scope = "/d4science.research-infrastructures.eu/gCubeApps/BiodiversityResearchEnvironment"; //Production
|
||||
|
||||
httpSession.setAttribute(USERNAME_ATTRIBUTE, user);
|
||||
ASLSession session = SessionManager.getInstance().getASLSession(sessionID, user);
|
||||
|
|
|
@ -152,6 +152,10 @@ public class ResultItemConverter implements Converter<ResultItem, ResultRow> {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//DEBUG
|
||||
// System.out.println("Insert row id: "+row.getId());
|
||||
|
||||
row.setMatchingTaxon(convertTaxon(input));
|
||||
|
||||
row.setBaseTaxonValue(NormalizeString.lowerCaseUpFirstChar(getBaseTaxonValue(TaxonomySearchServiceImpl.BASETAXONOMY,input)));
|
||||
|
@ -186,6 +190,8 @@ public class ResultItemConverter implements Converter<ResultItem, ResultRow> {
|
|||
Taxon tax = new Taxon(count++, taxon.getScientificName(), taxon.getCitation(), NormalizeString.lowerCaseUpFirstChar(taxon.getRank()));
|
||||
listTaxon.add(tax);
|
||||
taxon = taxon.getParent();
|
||||
|
||||
// System.out.println("Insert tax parent id: "+tax.getId());
|
||||
}
|
||||
return listTaxon;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,9 @@ public class TaxonomyItemConverter implements Converter<TaxonomyItem, TaxonomyRo
|
|||
TaxonomyRow taxonomy = createTaxonomyRow(input);
|
||||
|
||||
//SET PARENTS
|
||||
|
||||
// System.out.println("Convert Taxonomy parent for: "+taxonomy.getId());
|
||||
|
||||
taxonomy.setParent(convertParentsTaxonomy(input));
|
||||
|
||||
//SET BASE TAXON
|
||||
|
@ -180,9 +183,15 @@ public class TaxonomyItemConverter implements Converter<TaxonomyItem, TaxonomyRo
|
|||
List<TaxonomyRow> listTaxonomy = new ArrayList<TaxonomyRow>();
|
||||
TaxonomyItem parent = taxon.getParent();
|
||||
|
||||
int i=0;
|
||||
|
||||
while(parent!=null){
|
||||
TaxonomyRow row = createTaxonomyRow(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();
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ package org.gcube.portlets.user.speciesdiscovery.shared;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
|
@ -62,6 +63,7 @@ public class ResultRow implements FetchingElement, SelectableElement, Serializab
|
|||
public final static String PROPERTIES = "properties"; //USED
|
||||
public static final String EXISTS_PROPERTIES = "existsProperties"; //USED
|
||||
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
protected int id;
|
||||
|
@ -528,6 +530,11 @@ public class ResultRow implements FetchingElement, SelectableElement, Serializab
|
|||
|
||||
|
||||
public List<Taxon> getParents() {
|
||||
|
||||
Collections.sort(matchingTaxon);
|
||||
// for (Taxon t : matchingTaxon) {
|
||||
// System.out.println("+++ Parent :" +t.getId() + ", name: "+t.getName() +", rank: "+t.getRank());
|
||||
// }
|
||||
return matchingTaxon;
|
||||
}
|
||||
|
||||
|
@ -561,7 +568,6 @@ public class ResultRow implements FetchingElement, SelectableElement, Serializab
|
|||
this.properties = properties;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
@ -639,4 +645,6 @@ public class ResultRow implements FetchingElement, SelectableElement, Serializab
|
|||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import javax.persistence.Id;
|
|||
*
|
||||
*/
|
||||
@Entity
|
||||
public class Taxon implements Serializable, FetchingElement, TaxonomyInterface {
|
||||
public class Taxon implements Serializable, FetchingElement, TaxonomyInterface, Comparable<Taxon>{
|
||||
|
||||
private static final long serialVersionUID = -3579358036639552802L;
|
||||
|
||||
|
@ -25,6 +25,8 @@ public class Taxon implements Serializable, FetchingElement, TaxonomyInterface {
|
|||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
protected int internalId;
|
||||
|
||||
protected int id;
|
||||
|
||||
protected String name;
|
||||
|
@ -106,10 +108,23 @@ public class Taxon implements Serializable, FetchingElement, TaxonomyInterface {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Comparable on insertion order
|
||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(Taxon o) {
|
||||
return id-o.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Taxon [id=");
|
||||
builder.append("Taxon [internalId=");
|
||||
builder.append(internalId);
|
||||
builder.append(", id=");
|
||||
builder.append(id);
|
||||
builder.append(", name=");
|
||||
builder.append(name);
|
||||
|
@ -120,6 +135,4 @@ public class Taxon implements Serializable, FetchingElement, TaxonomyInterface {
|
|||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ package org.gcube.portlets.user.speciesdiscovery.shared;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
|
@ -22,7 +23,7 @@ import javax.persistence.OneToMany;
|
|||
*/
|
||||
@Entity
|
||||
//@Customizer(org.gcube.portlets.user.speciesdiscovery.server.persistence.dao.TaxonomyCustomizer.class)
|
||||
public class TaxonomyRow implements FetchingElement, Serializable, TaxonomyInterface, TaxonomyProvider, SelectableElement {
|
||||
public class TaxonomyRow implements FetchingElement, Serializable, TaxonomyInterface, TaxonomyProvider, SelectableElement, Comparable<TaxonomyRow> {
|
||||
|
||||
private static final long serialVersionUID = 1028839024130840026L;
|
||||
|
||||
|
@ -101,7 +102,9 @@ public class TaxonomyRow implements FetchingElement, Serializable, TaxonomyInter
|
|||
@OneToMany(cascade=CascadeType.PERSIST, fetch=FetchType.EAGER)
|
||||
protected List<TaxonomyRow> parents;
|
||||
|
||||
//USED FOR PARENT
|
||||
protected String parentID;
|
||||
protected int parentIndex = -1;
|
||||
|
||||
protected TaxonomyRow() {
|
||||
|
||||
|
@ -246,6 +249,7 @@ public class TaxonomyRow implements FetchingElement, Serializable, TaxonomyInter
|
|||
|
||||
@Override
|
||||
public List<TaxonomyRow> getParents() {
|
||||
Collections.sort(parents);
|
||||
return parents;
|
||||
}
|
||||
|
||||
|
@ -422,6 +426,14 @@ public class TaxonomyRow implements FetchingElement, Serializable, TaxonomyInter
|
|||
this.isParent = isParent;
|
||||
}
|
||||
|
||||
public int getParentIndex() {
|
||||
return parentIndex;
|
||||
}
|
||||
|
||||
public void setParentIndex(int parentIndex) {
|
||||
this.parentIndex = parentIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
@ -487,8 +499,18 @@ public class TaxonomyRow implements FetchingElement, Serializable, TaxonomyInter
|
|||
builder.append(parents);
|
||||
builder.append(", parentID=");
|
||||
builder.append(parentID);
|
||||
builder.append(", parentIndex=");
|
||||
builder.append(parentIndex);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* Comparable on insertion order
|
||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(TaxonomyRow o) {
|
||||
return parentIndex - o.getParentIndex();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,14 +28,30 @@ public class ServiceQuery {
|
|||
*/
|
||||
public static void main(String[] args) throws InvalidQueryException, UnsupportedPluginException {
|
||||
String scope = "/gcube/devsec";
|
||||
// String scope = "/d4science.research-infrastructures.eu/gCubeApps/BiodiversityResearchEnvironment"; //Production
|
||||
ScopeProvider.instance.set(scope);
|
||||
Manager call = manager().at(URI.create("http://node24.d.d4science.research-infrastructures.eu:9000")).withTimeout(3, TimeUnit.MINUTES).build();
|
||||
|
||||
|
||||
Manager call = manager().withTimeout(3, TimeUnit.MINUTES).build();
|
||||
|
||||
// Manager call = manager().at(URI.create("http://node24.d.d4science.research-infrastructures.eu:9000")).withTimeout(3, TimeUnit.MINUTES).build();
|
||||
|
||||
//Stream<ResultElement> results = call.search("SEARCH BY CN 'shark' RESOLVE WITH OBIS EXPAND WITH ITIS RETURN Product");
|
||||
Stream<ResultElement> results = call.search("SEARCH BY CN 'shark' RESOLVE WITH OBIS EXPAND WITH ITIS WHERE coordinate <= 15.12, 16.12 RETURN Product");
|
||||
// Stream<ResultElement> results = call.search("SEARCH BY CN 'shark' RESOLVE WITH OBIS EXPAND WITH ITIS WHERE coordinate <= 15.12, 16.12 RETURN Product");
|
||||
|
||||
if (results.hasNext()) results.next();
|
||||
|
||||
// Stream<ResultElement> results = call.search("SEARCH BY SN 'sarda sarda' RESOLVE WITH OBIS EXPAND WITH ITIS WHERE coordinate <= 15.12, 16.12 RETURN Product");
|
||||
|
||||
System.out.println("start query...");
|
||||
|
||||
Stream<ResultElement> results = call.search("SEARCH BY SN 'sarda sarda' RETURN Product");
|
||||
|
||||
int i=0;
|
||||
if (results.hasNext()) {
|
||||
ResultElement elem = results.next();
|
||||
System.out.println(++i +") el: "+elem.getId());
|
||||
|
||||
}
|
||||
|
||||
results.close();
|
||||
System.out.println("DONE");
|
||||
|
|
Reference in New Issue