/impl/src/java/pt/estgp/estgweb/services/common/ISearchResults.java |
---|
24,6 → 24,7 |
public String getSearchType(); |
public String getModuleInternalKey(); |
public String getDescription(); |
public List<IFacet> getFacets(); |
} |
/impl/src/java/pt/estgp/estgweb/services/common/impl/DefaultSearchResults.java |
---|
3,6 → 3,7 |
import pt.estgp.estgweb.services.common.ISearchResults; |
import pt.estgp.estgweb.services.common.ModuleEnum; |
import pt.estgp.estgweb.services.common.IResult; |
import pt.estgp.estgweb.services.common.IFacet; |
import java.util.List; |
import java.util.ArrayList; |
28,6 → 29,7 |
private String searchType; |
private String moduleInternalKey = null; |
private String description; |
private List<IFacet> facets; |
public ModuleEnum getModule() { |
147,4 → 149,13 |
public void setDescription(String description) { |
this.description = description; |
} |
public List<IFacet> getFacets() { |
return facets; |
} |
public void setFacets(List<IFacet> facets) { |
this.facets = facets; |
} |
} |
/impl/src/java/pt/estgp/estgweb/services/common/DefaultFacet.java |
---|
New file |
0,0 → 1,31 |
package pt.estgp.estgweb.services.common; |
import java.util.List; |
/** |
* @author Jorge Machado |
* @date 18/Nov/2009 |
* @time 11:20:10 |
* @email machadofisher@gmail.com |
*/ |
public class DefaultFacet implements IFacet{ |
String index; |
List<IFacetLabel> labels; |
public String getIndex() { |
return index; |
} |
public void setIndex(String index) { |
this.index = index; |
} |
public List<IFacetLabel> getLabels() { |
return labels; |
} |
public void setLabels(List<IFacetLabel> labels) { |
this.labels = labels; |
} |
} |
/impl/src/java/pt/estgp/estgweb/services/common/DefaultFacetLabel.java |
---|
New file |
0,0 → 1,30 |
package pt.estgp.estgweb.services.common; |
/** |
* @author Jorge Machado |
* @date 18/Nov/2009 |
* @time 11:21:02 |
* @email machadofisher@gmail.com |
*/ |
public class DefaultFacetLabel implements IFacetLabel |
{ |
String label; |
int ocurrences; |
public String getLabel() { |
return label; |
} |
public void setLabel(String label) { |
this.label = label; |
} |
public int getOcurrences() { |
return ocurrences; |
} |
public void setOcurrences(int ocurrences) { |
this.ocurrences = ocurrences; |
} |
} |
/impl/src/java/pt/estgp/estgweb/services/common/IFacet.java |
---|
New file |
0,0 → 1,14 |
package pt.estgp.estgweb.services.common; |
import java.util.List; |
/** |
* @author Jorge Machado |
* @date 18/Nov/2009 |
* @time 11:06:18 |
* @email machadofisher@gmail.com |
*/ |
public interface IFacet { |
public String getIndex(); |
public List<IFacetLabel> getLabels(); |
} |
/impl/src/java/pt/estgp/estgweb/services/common/IFacetLabel.java |
---|
New file |
0,0 → 1,12 |
package pt.estgp.estgweb.services.common; |
/** |
* @author Jorge Machado |
* @date 18/Nov/2009 |
* @time 11:19:24 |
* @email machadofisher@gmail.com |
*/ |
public interface IFacetLabel { |
public String getLabel(); |
public int getOcurrences(); |
} |
/impl/src/java/pt/estgp/estgweb/services/srusources/SruSourcesCommonServices.java |
---|
118,7 → 118,7 |
} |
String finalQuery = sruSourceView.getCollectionField() + ":(" + collectionQuery.toString() + ") AND (" + search + ")"; |
logger.error("Sru server " + sruSourceView.getName() + " final query: " + finalQuery); |
String sruRequest = sruSourceView.getUrl() + "?query=" + URLEncoder.encode(finalQuery,"UTF-8") + "&verb=getSRUResponseWithThisQuery&startRecord=" + page + "&maximumRecords=" + maxResults; |
String sruRequest = sruSourceView.getUrl() + "?query=" + URLEncoder.encode(finalQuery,"UTF-8") + "&verb=getSRUResponseWithThisQuery&startRecord=" + ((page*maxResults)+1) + "&maximumRecords=" + maxResults; |
URL url = new URL(sruRequest); |
Document dom = Dom4jUtil.parse(url); |
150,11 → 150,24 |
{ |
DefaultResult defaultResult = new DefaultResult(); |
defaultResult.setTitle(((Element)fileRelativePath).getText()); |
String relativePathStr = ((Element)fileRelativePath).getText(); |
defaultResult.setTitle(relativePathStr); |
// defaultResult.setSubTitle(courseUnit.getCourseName()); |
// defaultResult.setSubTitleKey(false); |
// defaultResult.setText(courseUnit.getObjectives()); |
defaultResult.setUrl(((Element)fileUrl).getTextTrim()); |
String urlStr = ((Element)fileUrl).getTextTrim(); |
String[] pathItems = relativePathStr.trim().split("\\\\"); |
StringBuilder pathBuidler = new StringBuilder(); |
for(String item: pathItems) |
{ |
if(item.trim().length() > 0) |
pathBuidler.append("/").append(URLEncoder.encode(item,"ISO-8859-1").replace("+","%20")); |
} |
urlStr = urlStr.substring(0,urlStr.length() - (relativePathStr.length())) + pathBuidler.toString(); |
defaultResult.setUrl(urlStr); |
defaultResult.setAbsoluteUrl(true); |
XPath xPathCollection = dom.createXPath("./files:collection"); |
183,6 → 196,32 |
logger.warn("File retured from SRU without filePath query:" + search + " page:" + page); |
} |
/*Facets*/ |
List<IFacet> facets = new ArrayList<IFacet>(); |
XPath xPathFacets = dom.createXPath("//files:facet"); |
xPathFacets.setNamespaceURIs(namespaces); |
List<Element> facetsElems = xPathFacets.selectNodes(dom); |
for(Element facetElem: facetsElems) |
{ |
DefaultFacet defaultFacet = new DefaultFacet(); |
defaultFacet.setLabels(new ArrayList<IFacetLabel>()); |
defaultFacet.setIndex(facetElem.attribute("name").getValue()); |
XPath xPathFacetLabel = dom.createXPath("./files:facetLabel"); |
xPathFacetLabel.setNamespaceURIs(namespaces); |
List<Element> facetLabelElems = xPathFacets.selectNodes(facetElem); |
for(Element facetLabelElem: facetLabelElems) |
{ |
DefaultFacetLabel facetLabel = new DefaultFacetLabel(); |
facetLabel.setOcurrences(Integer.parseInt(facetLabelElem.attribute("ocurr").getValue())); |
facetLabel.setLabel(facetLabelElem.getTextTrim()); |
defaultFacet.getLabels().add(facetLabel); |
} |
if(defaultFacet.getLabels().size()>0) |
facets.add(defaultFacet); |
} |
if(facets.size() > 0) |
searchResultsSource.setFacets(facets); |
} |
catch (Throwable e) |
{ |
/impl/src/web/public/search/searchResults.jsp |
---|
150,7 → 150,7 |
</logic:notEmpty> |
<b>(${searchResults.totalResults})</b> |
<a id="${searchResults.module.messageKey}SeeMore" |
href="javascript:showOrHideOne('${searchResults.module.messageKey}')"> |
href="javascript:showOrHideOne('${searchResults.module.messageKey}_${searchResults.moduleInternalKey}')"> |
<bean:message key="search.see.more"/> |
</a> |
</h1> |
162,7 → 162,7 |
else |
visibility = Globals.HIDDEN; |
%> |
<div class="module" id="<%=searchResults.getModule().getMessageKey()%>" style="<%=visibility%>"> |
<div class="module" id="${searchResults.module.messageKey}_${searchResults.moduleInternalKey}" style="<%=visibility%>"> |
<div id="${searchResults.module.messageKey}Results"> |
<logic:iterate id="result" name="searchResults" property="results" |
type="pt.estgp.estgweb.services.common.IResult"> |