Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Genesys Backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
12
Issues
12
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Genesys PGR
Genesys Backend
Commits
cf10361f
Commit
cf10361f
authored
May 03, 2016
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Full-text search: update display of articles, posts, countries and institutes
parent
c38258c5
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
131 additions
and
24 deletions
+131
-24
src/main/java/org/genesys2/server/service/impl/FullTextSearchServiceImpl.java
...nesys2/server/service/impl/FullTextSearchServiceImpl.java
+10
-7
src/main/java/org/genesys2/server/servlet/controller/SearchController.java
.../genesys2/server/servlet/controller/SearchController.java
+14
-3
src/main/sourceapp/0/styles/genesys.scss
src/main/sourceapp/0/styles/genesys.scss
+17
-0
src/main/sourceapp/1/styles/genesys.scss
src/main/sourceapp/1/styles/genesys.scss
+23
-1
src/main/webapp/WEB-INF/jsp/search2/index.jsp
src/main/webapp/WEB-INF/jsp/search2/index.jsp
+7
-5
src/main/webapp/WEB-INF/tags/mini/activitypost.tag
src/main/webapp/WEB-INF/tags/mini/activitypost.tag
+26
-0
src/main/webapp/WEB-INF/tags/mini/article.tag
src/main/webapp/WEB-INF/tags/mini/article.tag
+24
-0
src/main/webapp/WEB-INF/tags/mini/country.tag
src/main/webapp/WEB-INF/tags/mini/country.tag
+1
-1
src/main/webapp/WEB-INF/tags/mini/institute.tag
src/main/webapp/WEB-INF/tags/mini/institute.tag
+9
-7
No files found.
src/main/java/org/genesys2/server/service/impl/FullTextSearchServiceImpl.java
View file @
cf10361f
...
@@ -193,6 +193,10 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
...
@@ -193,6 +193,10 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
return
instituteRepository
.
findOne
(
id
);
return
instituteRepository
.
findOne
(
id
);
}
else
if
(
Country
.
class
.
getName
().
equals
(
className
))
{
}
else
if
(
Country
.
class
.
getName
().
equals
(
className
))
{
return
countryRepository
.
findOne
(
id
);
return
countryRepository
.
findOne
(
id
);
}
else
if
(
ActivityPost
.
class
.
getName
().
equals
(
className
))
{
return
postRepository
.
findOne
(
id
);
}
else
if
(
Article
.
class
.
getName
().
equals
(
className
))
{
return
articleRepository
.
findOne
(
id
);
}
else
{
}
else
{
throw
new
UnsupportedOperationException
(
"Missing toEntity implementation for class="
+
className
);
throw
new
UnsupportedOperationException
(
"Missing toEntity implementation for class="
+
className
);
}
}
...
@@ -460,7 +464,6 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
...
@@ -460,7 +464,6 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
// FIXME Should not include articles that belong to institutes or
// FIXME Should not include articles that belong to institutes or
// countries
// countries
final
Article
article
=
(
Article
)
model
;
final
Article
article
=
(
Article
)
model
;
document
.
setClassPK
(
article
.
getClassPk
());
document
.
setBody
(
article
.
getBody
());
document
.
setBody
(
article
.
getBody
());
document
.
setSummary
(
article
.
getSummary
());
document
.
setSummary
(
article
.
getSummary
());
document
.
setLanguage
(
article
.
getLang
());
document
.
setLanguage
(
article
.
getLang
());
...
@@ -469,19 +472,19 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
...
@@ -469,19 +472,19 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
document
.
setUrlToContent
(
"/content/"
+
article
.
getSlug
());
document
.
setUrlToContent
(
"/content/"
+
article
.
getSlug
());
}
else
if
(
model
instanceof
ActivityPost
)
{
}
else
if
(
model
instanceof
ActivityPost
)
{
updateDocument
ForCountry
((
ActivityPost
)
model
,
document
);
updateDocument
((
ActivityPost
)
model
,
document
);
}
else
if
(
model
instanceof
Country
)
{
}
else
if
(
model
instanceof
Country
)
{
updateDocument
ForCountry
((
Country
)
model
,
document
);
updateDocument
((
Country
)
model
,
document
);
}
else
if
(
model
instanceof
FaoInstitute
)
{
}
else
if
(
model
instanceof
FaoInstitute
)
{
updateDocument
ForFaoInstitute
((
FaoInstitute
)
model
,
document
);
updateDocument
((
FaoInstitute
)
model
,
document
);
}
}
return
document
;
return
document
;
}
}
private
void
updateDocument
ForCountry
(
ActivityPost
activityPost
,
FullTextDocument
document
)
{
private
void
updateDocument
(
ActivityPost
activityPost
,
FullTextDocument
document
)
{
document
.
setBody
(
activityPost
.
getBody
());
document
.
setBody
(
activityPost
.
getBody
());
document
.
setSummary
(
activityPost
.
getTitle
());
document
.
setSummary
(
activityPost
.
getTitle
());
document
.
setCreatedDate
(
activityPost
.
getCreatedDate
());
document
.
setCreatedDate
(
activityPost
.
getCreatedDate
());
...
@@ -489,7 +492,7 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
...
@@ -489,7 +492,7 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
document
.
setUrlToContent
(
"/content/news/"
+
activityPost
.
getId
()
+
"/"
+
this
.
jspHelper
.
suggestUrlForText
(
activityPost
.
getTitle
()));
document
.
setUrlToContent
(
"/content/news/"
+
activityPost
.
getId
()
+
"/"
+
this
.
jspHelper
.
suggestUrlForText
(
activityPost
.
getTitle
()));
}
}
private
void
updateDocument
ForCountry
(
Country
country
,
FullTextDocument
document
)
{
private
void
updateDocument
(
Country
country
,
FullTextDocument
document
)
{
document
.
setUrlToContent
(
"/geo/"
+
country
.
getCode3
());
document
.
setUrlToContent
(
"/geo/"
+
country
.
getCode3
());
document
.
setLanguage
(
contentService
.
getDefaultLocale
().
getLanguage
());
document
.
setLanguage
(
contentService
.
getDefaultLocale
().
getLanguage
());
document
.
setSummary
(
country
.
getCode3
()
+
" "
+
country
.
getNameL
());
document
.
setSummary
(
country
.
getCode3
()
+
" "
+
country
.
getNameL
());
...
@@ -500,7 +503,7 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
...
@@ -500,7 +503,7 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
}
}
}
}
private
void
updateDocument
ForFaoInstitute
(
FaoInstitute
institute
,
FullTextDocument
document
)
{
private
void
updateDocument
(
FaoInstitute
institute
,
FullTextDocument
document
)
{
document
.
setUrlToContent
(
"/wiews/"
+
institute
.
getCode
());
document
.
setUrlToContent
(
"/wiews/"
+
institute
.
getCode
());
document
.
setLanguage
(
contentService
.
getDefaultLocale
().
getLanguage
());
document
.
setLanguage
(
contentService
.
getDefaultLocale
().
getLanguage
());
document
.
setSummary
(
institute
.
getCode
()
+
" "
+
institute
.
getAcronym
()
+
" "
+
institute
.
getFullName
());
document
.
setSummary
(
institute
.
getCode
()
+
" "
+
institute
.
getAcronym
()
+
" "
+
institute
.
getFullName
());
...
...
src/main/java/org/genesys2/server/servlet/controller/SearchController.java
View file @
cf10361f
...
@@ -24,6 +24,8 @@ import org.apache.commons.lang.ArrayUtils;
...
@@ -24,6 +24,8 @@ import org.apache.commons.lang.ArrayUtils;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.commons.logging.LogFactory
;
import
org.genesys2.server.model.impl.ActivityPost
;
import
org.genesys2.server.model.impl.Article
;
import
org.genesys2.server.model.impl.ClassPK
;
import
org.genesys2.server.model.impl.ClassPK
;
import
org.genesys2.server.model.impl.Country
;
import
org.genesys2.server.model.impl.Country
;
import
org.genesys2.server.model.impl.FaoInstitute
;
import
org.genesys2.server.model.impl.FaoInstitute
;
...
@@ -142,10 +144,14 @@ public class SearchController {
...
@@ -142,10 +144,14 @@ public class SearchController {
@RequestMapping
(
"/acn/search2"
)
@RequestMapping
(
"/acn/search2"
)
public
String
findFullTextDocument
(
ModelMap
model
,
@RequestParam
(
required
=
false
,
value
=
"q"
)
String
searchQuery
,
public
String
findFullTextDocument
(
ModelMap
model
,
@RequestParam
(
required
=
false
,
value
=
"q"
)
String
searchQuery
,
@RequestParam
(
value
=
"page"
,
required
=
true
,
defaultValue
=
"1"
)
int
page
,
@RequestParam
(
value
=
"page"
,
required
=
true
,
defaultValue
=
"1"
)
int
page
,
@RequestParam
(
value
=
"section"
,
required
=
true
,
defaultValue
=
"accession"
)
String
section
)
throws
SearchException
{
@RequestParam
(
value
=
"section"
,
required
=
false
,
defaultValue
=
"accession"
)
String
section
)
throws
SearchException
{
if
(
StringUtils
.
isBlank
(
section
))
{
section
=
"accession"
;
}
ClassPK
classPK
=
contentService
.
getClassPk
(
section
);
ClassPK
classPK
=
contentService
.
getClassPk
(
section
);
if
(
classPK
==
null
)
{
if
(
classPK
==
null
&&
!
"accession"
.
equals
(
section
)
)
{
LOG
.
warn
(
"No search section "
+
section
);
LOG
.
warn
(
"No search section "
+
section
);
throw
new
SearchException
(
"No such search section"
);
throw
new
SearchException
(
"No such search section"
);
}
}
...
@@ -160,8 +166,13 @@ public class SearchController {
...
@@ -160,8 +166,13 @@ public class SearchController {
model
.
addAttribute
(
"pagedData"
,
fullTextSearchService
.
search
(
searchQuery
,
new
PageRequest
(
page
-
1
,
50
),
FaoInstitute
.
class
));
model
.
addAttribute
(
"pagedData"
,
fullTextSearchService
.
search
(
searchQuery
,
new
PageRequest
(
page
-
1
,
50
),
FaoInstitute
.
class
));
}
else
if
(
"country"
.
equals
(
section
))
{
}
else
if
(
"country"
.
equals
(
section
))
{
model
.
addAttribute
(
"pagedData"
,
fullTextSearchService
.
search
(
searchQuery
,
new
PageRequest
(
page
-
1
,
50
),
Country
.
class
));
model
.
addAttribute
(
"pagedData"
,
fullTextSearchService
.
search
(
searchQuery
,
new
PageRequest
(
page
-
1
,
50
),
Country
.
class
));
}
else
if
(
"article"
.
equals
(
section
))
{
model
.
addAttribute
(
"pagedData"
,
fullTextSearchService
.
search
(
searchQuery
,
new
PageRequest
(
page
-
1
,
50
),
Article
.
class
));
}
else
if
(
"activitypost"
.
equals
(
section
))
{
model
.
addAttribute
(
"pagedData"
,
fullTextSearchService
.
search
(
searchQuery
,
new
PageRequest
(
page
-
1
,
50
),
ActivityPost
.
class
));
}
else
{
}
else
{
model
.
addAttribute
(
"pagedData"
,
fullTextSearchService
.
search
(
searchQuery
,
new
PageRequest
(
page
-
1
,
50
),
section
));
LOG
.
error
(
"Unsupported full-text searchfor section: "
+
section
);
throw
new
UnsupportedOperationException
(
"No such search section"
);
}
}
}
catch
(
SearchException
e
)
{
}
catch
(
SearchException
e
)
{
LOG
.
info
(
"Searching for: "
+
searchQuery
+
" failed with error "
+
e
.
getMessage
());
LOG
.
info
(
"Searching for: "
+
searchQuery
+
" failed with error "
+
e
.
getMessage
());
...
...
src/main/sourceapp/0/styles/genesys.scss
View file @
cf10361f
...
@@ -2487,3 +2487,20 @@ div[x-href] {
...
@@ -2487,3 +2487,20 @@ div[x-href] {
.dropdown-menu.view-columns
li
{
.dropdown-menu.view-columns
li
{
padding
:
0
10px
;
padding
:
0
10px
;
}
}
.genesys-mini
{
.title
{
margin
:
0
.5em
0
;
font-size
:
130%
;
}
.summary
{
margin
:
0
.5em
0
;
margin-left
:
3em
;
}
.url
{
margin
:
0
.5em
0
;
color
:
Gray
;
}
}
src/main/sourceapp/1/styles/genesys.scss
View file @
cf10361f
...
@@ -653,4 +653,26 @@ span.idx-col {
...
@@ -653,4 +653,26 @@ span.idx-col {
img
{
img
{
width
:
100%
;
width
:
100%
;
}
}
}
}
\ No newline at end of file
.genesys-mini
{
.title
{
margin
:
0
.5em
0
;
font-size
:
130%
;
}
.summary
{
margin
:
0
.5em
0
;
margin-left
:
3em
;
}
.url
{
margin
:
0
.5em
0
;
color
:
Gray
;
}
.not-current
{
font-style
:
italic
;
opacity
:
0
.5
;
}
}
src/main/webapp/WEB-INF/jsp/search2/index.jsp
View file @
cf10361f
...
@@ -71,12 +71,8 @@
...
@@ -71,12 +71,8 @@
<td
class=
"notimportant"
><spring:message
code=
"accession.holdingInstitute"
/></td>
<td
class=
"notimportant"
><spring:message
code=
"accession.holdingInstitute"
/></td>
</c:if>
</c:if>
<c:if
test=
"
${
section
eq
'article'
}
"
>
<c:if
test=
"
${
section
eq
'article'
}
"
>
<td>
Body
</td>
<td>
Summary
</td>
</c:if>
</c:if>
<c:if
test=
"
${
section
eq
'activitypost'
}
"
>
<c:if
test=
"
${
section
eq
'activitypost'
}
"
>
<td>
Body
</td>
<td>
Title
</td>
</c:if>
</c:if>
<c:if
test=
"
${
section
eq
'country'
}
"
>
<c:if
test=
"
${
section
eq
'country'
}
"
>
</c:if>
</c:if>
...
@@ -104,9 +100,15 @@
...
@@ -104,9 +100,15 @@
<c:when
test=
"
${
section
eq
'institute'
}
"
>
<c:when
test=
"
${
section
eq
'institute'
}
"
>
<td><mini:institute
institute=
"
${
unit
}
"
/></td>
<td><mini:institute
institute=
"
${
unit
}
"
/></td>
</c:when>
</c:when>
<c:when
test=
"
${
section
eq
'article'
}
"
>
<td><mini:article
article=
"
${
unit
}
"
/></td>
</c:when>
<c:when
test=
"
${
section
eq
'activitypost'
}
"
>
<td><mini:activitypost
activityPost=
"
${
unit
}
"
/></td>
</c:when>
<c:otherwise>
<c:otherwise>
<td>
<td>
" ${section} "
<b><c:out
value=
"
${
section
}
"
/></b>
<a
href=
"
<c:url
value=
"
${
unit
.
urlToContent
}
"
/>
"
>
<a
href=
"
<c:url
value=
"
${
unit
.
urlToContent
}
"
/>
"
>
<c:set
var=
"body"
value=
"
${
unit
.
body
}
"
/>
<c:set
var=
"body"
value=
"
${
unit
.
body
}
"
/>
<c:if
test=
"
${
fn:
length
(
body
)
>
100
}
"
>
<c:if
test=
"
${
fn:
length
(
body
)
>
100
}
"
>
...
...
src/main/webapp/WEB-INF/tags/mini/activitypost.tag
0 → 100644
View file @
cf10361f
<%@ tag description="Display article" pageEncoding="UTF-8"%>
<%@ tag body-content="empty"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="security"
uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="local" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="cms" tagdir="/WEB-INF/tags/cms"%>
<%@ attribute name="activityPost" required="true"
type="org.genesys2.server.model.impl.ActivityPost"%>
<div class="genesys-mini genesy-post">
<div class="title">
<c:out escapeXml="false" value="${activityPost.title}" />
</div>
<div class="url">
<a
href="<c:url value="/content/news/${activityPost.id}/${jspHelper.suggestUrlForText(activityPost.title)}" />">
<c:url
value="/content/news/${activityPost.id}/${jspHelper.suggestUrlForText(activityPost.title)}" />
</a>
</div>
<div class="summary free-text">
<c:out escapeXml="false" value="${activityPost.body}" />
</div>
</div>
src/main/webapp/WEB-INF/tags/mini/article.tag
0 → 100644
View file @
cf10361f
<%@ tag description="Display article" pageEncoding="UTF-8"%>
<%@ tag body-content="empty"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="security"
uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="local" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="cms" tagdir="/WEB-INF/tags/cms"%>
<%@ attribute name="article" required="true"
type="org.genesys2.server.model.impl.Article"%>
<div class="genesys-mini genesy-article">
<div class="title">
<a href="<c:url value="/${article.lang}/content/${article.slug}" />">
<c:out value="${article.title}" />
</a>
</div>
<div class="summary free-text">
<c:out escapeXml="false" value="${article.summary}" />
</div>
<div class="language">
<em><c:out value="${article.lang}" /></em>
</div>
</div>
src/main/webapp/WEB-INF/tags/mini/country.tag
View file @
cf10361f
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
<a href="<c:url value="/geo/${country.code3}" />"><c:out
<a href="<c:url value="/geo/${country.code3}" />"><c:out
value="${country.code3}" /></a>
value="${country.code3}" /></a>
</div>
</div>
<div class="
nam
e">
<div class="
titl
e">
<c:out value="${country.getName(pageContext.response.locale)}" />
<c:out value="${country.getName(pageContext.response.locale)}" />
</div>
</div>
</div>
</div>
src/main/webapp/WEB-INF/tags/mini/institute.tag
View file @
cf10361f
...
@@ -9,15 +9,11 @@
...
@@ -9,15 +9,11 @@
type="org.genesys2.server.model.impl.FaoInstitute"%>
type="org.genesys2.server.model.impl.FaoInstitute"%>
<div class="genesys-mini genesys-institute">
<div class="genesys-mini genesys-institute">
<div class="
code
">
<div class="
title ${institute.current ? '' : 'not-current'}
">
<a href="<c:url value="/wiews/${institute.code}" />"><c:out
<a href="<c:url value="/wiews/${institute.code}" />"><c:out
value="${institute.code}" /></a>
value="${institute.code}" /></a>
</div>
<div class="fullName">
<c:out value="${institute.fullName}" />
<c:out value="${institute.fullName}" />
</div>
<span class="acronym"><c:out value="${institute.acronym}" /></span>
<div class="acronym">
<c:out value="${institute.acronym}" />
</div>
</div>
<div class="accessionCount">
<div class="accessionCount">
<c:choose>
<c:choose>
...
@@ -25,8 +21,14 @@
...
@@ -25,8 +21,14 @@
<spring:message code="faoInstitutes.stat.accessionCount" />
<spring:message code="faoInstitutes.stat.accessionCount" />
<a href="<c:url value="/wiews/${institute.code}/data" />"><fmt:formatNumber value="${institute.accessionCount}" /></a>
<a href="<c:url value="/wiews/${institute.code}/data" />"><fmt:formatNumber value="${institute.accessionCount}" /></a>
</c:when>
</c:when>
<c:when test="${! institute.current}">
<!-- Link to active -->
<a href="<c:url value="/wiews/${faoInstitute.vCode}" />">
<spring:message code="faoInstitute.view-current-institute" arguments="${institute.vCode}" />
</a>
</c:when>
<c:otherwise>
<c:otherwise>
<spring:message code="faoInstitute.no-accessions-registered" />
</c:otherwise>
</c:otherwise>
</c:choose>
</c:choose>
</div>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment