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
45
Issues
45
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
cabaec62
Commit
cabaec62
authored
Aug 04, 2016
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Project view with data
parent
b20d3590
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
238 additions
and
25 deletions
+238
-25
src/main/java/org/genesys2/server/persistence/domain/AccessionListRepository.java
...s2/server/persistence/domain/AccessionListRepository.java
+4
-0
src/main/java/org/genesys2/server/service/AccessionListService.java
...ava/org/genesys2/server/service/AccessionListService.java
+7
-0
src/main/java/org/genesys2/server/service/impl/AccessionListServiceImpl.java
...enesys2/server/service/impl/AccessionListServiceImpl.java
+10
-0
src/main/java/org/genesys2/server/servlet/controller/ProjectController.java
...genesys2/server/servlet/controller/ProjectController.java
+90
-11
src/main/resources/content/language.properties
src/main/resources/content/language.properties
+1
-1
src/main/webapp/WEB-INF/jsp/project/view.jsp
src/main/webapp/WEB-INF/jsp/project/view.jsp
+126
-13
No files found.
src/main/java/org/genesys2/server/persistence/domain/AccessionListRepository.java
View file @
cabaec62
...
...
@@ -50,9 +50,13 @@ public interface AccessionListRepository extends JpaRepository<AccessionList, Lo
@Query
(
nativeQuery
=
true
,
value
=
"select count(acceid) from accelistitems where listid = ?1"
)
int
sizeOf
(
AccessionList
list
);
@Query
(
nativeQuery
=
true
,
value
=
"select count(distinct acceid) from accelistitems where listid in (?1)"
)
int
distinctCount
(
List
<
AccessionList
>
accessionLists
);
@Query
(
"from AccessionList al where al.shared=1 order by al.title asc"
)
List
<
AccessionList
>
findShared
();
@Query
(
"select uuid from AccessionList al where al.title=?1"
)
UUID
getUUIDByTitle
(
String
title
);
}
src/main/java/org/genesys2/server/service/AccessionListService.java
View file @
cabaec62
...
...
@@ -55,6 +55,13 @@ public interface AccessionListService {
int
sizeOf
(
AccessionList
accessionList
);
/**
* Number of unique accessions in all lists
* @param accessionLists
* @return the number of unique accessions in all lists
*/
int
distinctCount
(
List
<
AccessionList
>
accessionLists
);
List
<
AccessionList
>
findShared
();
UUID
getUUIDByTitle
(
String
title
);
...
...
src/main/java/org/genesys2/server/service/impl/AccessionListServiceImpl.java
View file @
cabaec62
...
...
@@ -168,6 +168,16 @@ public class AccessionListServiceImpl implements AccessionListService {
return
accessionListRepository
.
sizeOf
(
list
);
}
/* (non-Javadoc)
* @see org.genesys2.server.service.AccessionListService#distinctCount(java.util.List)
*/
@Override
public
int
distinctCount
(
List
<
AccessionList
>
accessionLists
)
{
if
(
accessionLists
.
size
()
==
0
)
return
0
;
return
accessionListRepository
.
distinctCount
(
accessionLists
);
}
@Override
@PreAuthorize
(
"isAuthenticated()"
)
public
List
<
AccessionList
>
findShared
()
{
...
...
src/main/java/org/genesys2/server/servlet/controller/ProjectController.java
View file @
cabaec62
...
...
@@ -16,19 +16,27 @@
package
org.genesys2.server.servlet.controller
;
import
java.util.UUID
;
import
java.util.Set
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.util.ArrayList
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.ArrayList
;
import
java.util.Locale
;
import
java.util.Set
;
import
java.util.UUID
;
import
org.apache.commons.lang.StringUtils
;
import
org.genesys2.server.model.impl.AccessionList
;
import
org.genesys2.server.model.impl.Project
;
import
org.genesys2.server.service.AccessionListService
;
import
org.genesys2.server.service.ContentService
;
import
org.genesys2.server.service.ElasticService
;
import
org.genesys2.server.service.FilterConstants
;
import
org.genesys2.server.service.ProjectService
;
import
org.genesys2.server.service.impl.FilterHandler
;
import
org.genesys2.server.service.impl.FilterHandler.AppliedFilter
;
import
org.genesys2.server.service.impl.FilterHandler.AppliedFilters
;
import
org.genesys2.server.service.impl.SearchException
;
import
org.genesys2.spring.ResourceNotFoundException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.i18n.LocaleContextHolder
;
...
...
@@ -53,6 +61,9 @@ public class ProjectController extends BaseController {
@Autowired
private
AccessionListService
accessionListService
;
@Autowired
private
ElasticService
elasticService
;
@Autowired
ContentService
contentService
;
...
...
@@ -72,18 +83,49 @@ public class ProjectController extends BaseController {
}
@RequestMapping
(
"/{code}"
)
public
String
viewProject
(
ModelMap
model
Map
,
@PathVariable
(
value
=
"code"
)
String
code
)
{
public
String
viewProject
(
ModelMap
model
,
@PathVariable
(
value
=
"code"
)
String
code
)
{
Project
project
=
projectService
.
getProjectByCode
(
code
);
if
(
project
!=
null
)
{
modelMap
.
addAttribute
(
"project"
,
project
);
modelMap
.
addAttribute
(
"accessionLists"
,
accessionListService
.
getLists
(
project
.
getAccessionLists
()));
modelMap
.
addAttribute
(
"blurp"
,
contentService
.
getArticle
(
project
,
"blurp"
,
getLocale
()));
model
.
addAttribute
(
"project"
,
project
);
List
<
AccessionList
>
accessionLists
=
accessionListService
.
getLists
(
project
.
getAccessionLists
());
model
.
addAttribute
(
"accessionLists"
,
accessionLists
);
model
.
addAttribute
(
"blurp"
,
contentService
.
getArticle
(
project
,
"blurp"
,
getLocale
()));
// Statistics
int
countByProject
=
accessionListService
.
distinctCount
(
accessionLists
);
model
.
addAttribute
(
"countByProject"
,
countByProject
);
if
(
countByProject
>
0
)
{
AppliedFilters
filters
=
projectFilters
(
project
);
model
.
addAttribute
(
"jsonFilter"
,
filters
.
toString
());
try
{
model
.
addAttribute
(
"statisticsCrop"
,
elasticService
.
termStatisticsAuto
(
filters
,
FilterConstants
.
CROPS
,
5
));
model
.
addAttribute
(
"statisticsGenus"
,
elasticService
.
termStatisticsAuto
(
filters
,
FilterConstants
.
TAXONOMY_GENUS
,
5
));
model
.
addAttribute
(
"statisticsTaxonomy"
,
elasticService
.
termStatisticsAuto
(
filters
,
FilterConstants
.
TAXONOMY_GENUSSPECIES
,
5
));
model
.
addAttribute
(
"statisticsOrigCty"
,
elasticService
.
termStatisticsAuto
(
filters
,
FilterConstants
.
ORGCTY_ISO3
,
100
));
}
catch
(
SearchException
e
)
{
_logger
.
warn
(
e
.
getMessage
());
}
}
}
else
{
throw
new
ResourceNotFoundException
(
"No project with code "
+
code
);
}
return
"/project/view"
;
}
private
AppliedFilters
projectFilters
(
Project
project
)
{
AppliedFilters
filters
=
new
AppliedFilters
();
AppliedFilter
listsFilter
=
new
AppliedFilter
().
setFilterName
(
FilterConstants
.
LISTS
);
for
(
UUID
uuid
:
project
.
getAccessionLists
())
{
listsFilter
.
addFilterValue
(
new
FilterHandler
.
LiteralValueFilter
(
uuid
.
toString
()));
}
filters
.
add
(
listsFilter
);
return
filters
;
}
@RequestMapping
(
"/add-project"
)
public
String
addProject
(
ModelMap
modelMap
)
{
modelMap
.
addAttribute
(
"project"
,
new
Project
());
...
...
@@ -98,8 +140,7 @@ public class ProjectController extends BaseController {
@RequestMapping
(
"/update-project"
)
public
String
update
(
ModelMap
modelMap
,
@ModelAttribute
(
"project"
)
Project
p
,
@RequestParam
(
"blurp"
)
String
aboutBody
,
@RequestParam
(
value
=
"summary"
,
required
=
false
)
String
summary
,
@RequestParam
(
value
=
"accessionListTitle"
,
required
=
false
)
List
<
String
>
titles
)
{
@RequestParam
(
value
=
"summary"
,
required
=
false
)
String
summary
,
@RequestParam
(
value
=
"accessionListTitle"
,
required
=
false
)
List
<
String
>
titles
)
{
_logger
.
debug
(
"Updating project "
+
p
.
getCode
());
Project
project
=
null
;
...
...
@@ -117,8 +158,10 @@ public class ProjectController extends BaseController {
Set
<
String
>
titlesWithoutDuplicates
=
new
LinkedHashSet
<
String
>(
titles
);
List
<
UUID
>
projectAccessionLists
=
new
ArrayList
<
UUID
>();
for
(
String
title:
titlesWithoutDuplicates
)
{
projectAccessionLists
.
add
(
accessionListService
.
getUUIDByTitle
(
title
));
for
(
String
title
:
titlesWithoutDuplicates
)
{
if
(
StringUtils
.
isNotBlank
(
title
))
{
projectAccessionLists
.
add
(
accessionListService
.
getUUIDByTitle
(
title
));
}
}
project
.
setAccessionLists
(
projectAccessionLists
);
...
...
@@ -144,6 +187,42 @@ public class ProjectController extends BaseController {
return
StringUtils
.
EMPTY
;
}
@RequestMapping
(
"/{code}/data"
)
public
String
viewProjectData
(
ModelMap
model
,
@PathVariable
(
value
=
"code"
)
String
code
)
{
Project
project
=
projectService
.
getProjectByCode
(
code
);
if
(
project
!=
null
&&
project
.
getAccessionLists
().
size
()
>
0
)
{
AppliedFilters
filters
=
projectFilters
(
project
);
model
.
addAttribute
(
"filter"
,
filters
.
toString
());
return
"redirect:/explore"
;
}
else
{
throw
new
ResourceNotFoundException
();
}
}
@RequestMapping
(
"/{code}/data/map"
)
public
String
viewProjectMap
(
ModelMap
model
,
@PathVariable
(
value
=
"code"
)
String
code
)
{
Project
project
=
projectService
.
getProjectByCode
(
code
);
if
(
project
!=
null
&&
project
.
getAccessionLists
().
size
()
>
0
)
{
AppliedFilters
filters
=
projectFilters
(
project
);
model
.
addAttribute
(
"filter"
,
filters
.
toString
());
return
"redirect:/explore/map"
;
}
else
{
throw
new
ResourceNotFoundException
();
}
}
@RequestMapping
(
"/{code}/overview"
)
public
String
overview
(
ModelMap
model
,
@PathVariable
(
value
=
"code"
)
String
code
)
throws
UnsupportedEncodingException
{
Project
project
=
projectService
.
getProjectByCode
(
code
);
if
(
project
!=
null
&&
project
.
getAccessionLists
().
size
()
>
0
)
{
AppliedFilters
filters
=
projectFilters
(
project
);
return
"forward:/explore/overview?filter="
+
URLEncoder
.
encode
(
filters
.
toString
(),
"UTF8"
);
}
else
{
throw
new
ResourceNotFoundException
();
}
}
protected
Locale
getLocale
()
{
return
LocaleContextHolder
.
getLocale
();
}
...
...
src/main/resources/content/language.properties
View file @
cabaec62
...
...
@@ -178,7 +178,7 @@ faoInstitutes.page.data.title=Accessions in {0}
faoInstitute.accessions.at
=
Accessions at {0}
faoInstitutes.viewAll
=
View all registered institutes
faoInstitutes.viewActiveOnly
=
View institutes with accessions in Genesys
faoInstitute.no-accessions-registered
=
Please get in touch with us if you can facilitate in providing data from this instit
i
ute.
faoInstitute.no-accessions-registered
=
Please get in touch with us if you can facilitate in providing data from this institute.
faoInstitute.institute-not-current
=
This record is archived.
faoInstitute.view-current-institute
=
Navigate to {0}.
faoInstitute.country
=
Country
...
...
src/main/webapp/WEB-INF/jsp/project/view.jsp
View file @
cabaec62
...
...
@@ -9,7 +9,7 @@
</head>
<body>
<h1>
${project.name}
<c:out
value=
"
${
project
.
name
}
"
/>
<small>
<c:out
value=
"
${
project
.
code
}
"
/>
</small>
...
...
@@ -30,25 +30,138 @@
<%@include
file=
"/WEB-INF/jsp/content/include/blurp-display.jsp"
%>
</c:if>
<c:if
test=
"
${
fn:
length
(
accessionLists
)
gt
0
}
"
>
<div
class=
"content-section-2015"
>
<h3>
<div
class=
"content-section-2015"
>
<h3>
<span>
<spring:message
code=
"heading.general-info"
/>
</span>
</h3>
<div
class=
"row"
>
<div
class=
"col-md-offset-2 col-md-10"
>
<ul
class=
"funny-list statistics"
>
<li
class=
"clearfix odd"
>
<span
class=
"stats-number"
>
<fmt:formatNumber
value=
"
${
countByProject
}
"
/>
</span>
<spring:message
code=
"faoInstitutes.stat.accessionCount"
/>
</li>
</ul>
<c:if
test=
"
${
countByProject
gt
0
}
"
>
<a
class=
"btn btn-primary"
title=
"
<spring:message
code=
"faoInstitute.data-title"
arguments=
"
${
project
.
name
}
"
/>
"
href=
"
<c:url
value=
"/project/${project.code}/data"
/>
"
>
<span
class=
"glyphicon glyphicon-list"
></span>
<spring:message
code=
"view.accessions"
/>
</a>
<a
class=
"btn btn-default"
title=
"
<spring:message
code=
"faoInstitute.overview-title"
arguments=
"
${
project
.
name
}
"
/>
"
href=
"
<c:url
value=
"/project/${project.code}/overview"
/>
"
>
<span
class=
"glyphicon glyphicon-eye-open"
></span>
<spring:message
code=
"data-overview.short"
/>
</a>
</c:if>
</div>
</div>
<c:if
test=
"
${
statisticsCrop
ne
null
and
statisticsCrop
.
totalCount
gt
0
}
"
>
<h4>
<span>
<spring:message
code=
"faoInstitute.stat-by-crop"
/>
</span>
</h4>
<div
class=
"row"
>
<div
class=
"col-md-offset-2 col-md-10"
>
<local:term
-result termResult="${statisticsCrop}" type="crop"
/>
</div>
</div>
</c:if>
<c:if
test=
"
${
statisticsGenus
ne
null
and
statisticsGenus
.
totalCount
gt
0
}
"
>
<h4>
<span>
<spring:message
code=
"faoInstitute.stat-by-genus"
/>
</span>
</h4>
<div
class=
"row"
>
<div
class=
"col-md-offset-2 col-md-10"
>
<local:term
-result termResult="${statisticsGenus}" type="genus"
/>
</div>
</div>
</c:if>
<c:if
test=
"
${
statisticsTaxonomy
ne
null
and
statisticsTaxonomy
.
totalCount
gt
0
}
"
>
<h4>
<span>
<spring:message
code=
"
project.accessionList
s"
/>
<spring:message
code=
"
faoInstitute.stat-by-specie
s"
/>
</span>
</h
3
>
</h
4
>
<div
class=
"row"
>
<div
class=
"col-md-offset-2 col-md-10"
>
<ul>
<c:forEach
items=
"
${
accessionLists
}
"
var=
"accessionList"
>
<local:term
-result termResult="${statisticsTaxonomy}" type="species"
/>
</div>
</div>
</c:if>
<c:if
test=
"
${
statisticsOrigCty
ne
null
and
statisticsOrigCty
.
totalCount
gt
0
}
"
>
<h4>
<span>
<spring:message
code=
"accession.orgCty"
/>
</span>
</h4>
<div
class=
"row"
>
<div
class=
"col-md-offset-2 col-md-10"
>
<local:term
-result termResult="${statisticsOrigCty}" type="country"
/>
</div>
</div>
</c:if>
<c:if
test=
"
${
fn:
length
(
accessionLists
)
gt
0
}
"
>
<div
class=
"content-section-2015"
>
<h3>
<span>
<spring:message
code=
"project.accessionLists"
/>
</span>
</h3>
<div
class=
"row"
>
<div
class=
"col-md-offset-2 col-md-10"
>
<ul>
<c:forEach
items=
"
${
accessionLists
}
"
var=
"accessionList"
>
<li>
<a
href=
"
<c:url
value=
"/explore"
><c:param
name=
"filter"
value=
'{"lists":["${accessionList.uuid}"]}'
/></c:url>
"
>
<c:out
value=
"
${
accessionList
.
title
}
"
/>
</a>
</li>
</c:forEach>
</ul>
</div>
</div>
</div>
</c:if>
<c:if
test=
"
${
countByProject
gt
0
}
"
>
<div
class=
"content-section-2015"
>
<h3>
<span>
<spring:message
code=
"heading.see-also"
/>
</span>
</h3>
<div
class=
"row"
>
<div
class=
"col-md-offset-2 col-md-10"
>
<ul
class=
"see-also"
>
<li>
<a
href=
"
<c:url
value=
"/explore"
><c:param
name=
"filter"
value=
'{"lists":["${accessionList.uuid}"]}'
/></c:url>
"
><c:out
value=
"
${
accessionList
.
title
}
"
/></a>
<a
href=
"
<c:url
value=
"/project/${project.code}/data/map"
/>
"
>
<spring:message
code=
"see-also.map"
/>
</a>
</li>
</c:forEach>
</ul>
<li>
<a
href=
"
<c:url
value=
"/project/${project.code}/overview"
/>
"
>
<spring:message
code=
"see-also.overview"
/>
</a>
</li>
</ul>
</div>
</div>
</div>
</
div
>
</c:if>
</
c:if
>
</body>
</html>
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