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
19
Issues
19
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
f1e92b5c
Commit
f1e92b5c
authored
Feb 20, 2014
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Statistics services
parent
86ad0d17
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
143 additions
and
13 deletions
+143
-13
src/main/java/org/genesys2/server/persistence/domain/CountryRepository.java
...genesys2/server/persistence/domain/CountryRepository.java
+3
-0
src/main/java/org/genesys2/server/persistence/domain/FaoInstituteRepository.java
...ys2/server/persistence/domain/FaoInstituteRepository.java
+3
-0
src/main/java/org/genesys2/server/service/GenesysService.java
...main/java/org/genesys2/server/service/GenesysService.java
+2
-0
src/main/java/org/genesys2/server/service/GeoService.java
src/main/java/org/genesys2/server/service/GeoService.java
+2
-0
src/main/java/org/genesys2/server/service/InstituteService.java
...in/java/org/genesys2/server/service/InstituteService.java
+2
-0
src/main/java/org/genesys2/server/service/OrganizationService.java
...java/org/genesys2/server/service/OrganizationService.java
+0
-1
src/main/java/org/genesys2/server/service/StatisticsService.java
...n/java/org/genesys2/server/service/StatisticsService.java
+27
-0
src/main/java/org/genesys2/server/service/impl/ContentServiceImpl.java
.../org/genesys2/server/service/impl/ContentServiceImpl.java
+16
-0
src/main/java/org/genesys2/server/service/impl/GenesysServiceImpl.java
.../org/genesys2/server/service/impl/GenesysServiceImpl.java
+5
-0
src/main/java/org/genesys2/server/service/impl/GeoServiceImpl.java
...java/org/genesys2/server/service/impl/GeoServiceImpl.java
+5
-0
src/main/java/org/genesys2/server/service/impl/InstituteServiceImpl.java
...rg/genesys2/server/service/impl/InstituteServiceImpl.java
+5
-0
src/main/java/org/genesys2/server/service/impl/StatisticsServiceImpl.java
...g/genesys2/server/service/impl/StatisticsServiceImpl.java
+41
-0
src/main/java/org/genesys2/server/servlet/controller/HtmlController.java
...rg/genesys2/server/servlet/controller/HtmlController.java
+17
-4
src/main/resources/content/language.properties
src/main/resources/content/language.properties
+5
-1
src/main/resources/ehcache.xml
src/main/resources/ehcache.xml
+2
-3
src/main/resources/spring/spring.properties
src/main/resources/spring/spring.properties
+1
-1
src/main/webapp/WEB-INF/jsp/index.jsp
src/main/webapp/WEB-INF/jsp/index.jsp
+3
-3
src/main/webapp/html/css/custom.css
src/main/webapp/html/css/custom.css
+4
-0
No files found.
src/main/java/org/genesys2/server/persistence/domain/CountryRepository.java
View file @
f1e92b5c
...
...
@@ -39,6 +39,9 @@ public interface CountryRepository extends JpaRepository<Country, Long> {
@Query
(
"from Country c where c.current=false"
)
List
<
Country
>
findInactive
();
@Query
(
"select count(c) from Country c where c.current = ?1"
)
long
countByCurrent
(
boolean
current
);
List
<
Country
>
findByCurrent
(
boolean
current
);
Page
<
Country
>
findByCurrent
(
boolean
current
,
Pageable
pageable
);
...
...
src/main/java/org/genesys2/server/persistence/domain/FaoInstituteRepository.java
View file @
f1e92b5c
...
...
@@ -42,6 +42,9 @@ public interface FaoInstituteRepository extends JpaRepository<FaoInstitute, Long
@Query
(
"from FaoInstitute fi where fi.accessionCount > 0"
)
Page
<
FaoInstitute
>
listAllActive
(
Pageable
pageable
);
@Query
(
"select count(fi) from FaoInstitute fi where fi.accessionCount > 0"
)
long
countActive
();
@Query
(
"from FaoInstitute fi where fi.code in ( ?1 )"
)
List
<
FaoInstitute
>
findAllByCodes
(
Collection
<
String
>
wiewsCodes
);
...
...
src/main/java/org/genesys2/server/service/GenesysService.java
View file @
f1e92b5c
...
...
@@ -161,4 +161,6 @@ public interface GenesysService {
void
addAccessions
(
List
<
Accession
>
accessions
);
long
countAll
();
}
src/main/java/org/genesys2/server/service/GeoService.java
View file @
f1e92b5c
...
...
@@ -113,4 +113,6 @@ public interface GeoService {
ITPGRFAStatus
getITPGRFAStatus
(
Country
country
);
long
countActive
();
}
src/main/java/org/genesys2/server/service/InstituteService.java
View file @
f1e92b5c
...
...
@@ -55,4 +55,6 @@ public interface InstituteService {
void
updateSettings
(
FaoInstitute
faoInstitute
,
Map
<
String
,
String
>
settings
);
long
countActive
();
}
src/main/java/org/genesys2/server/service/OrganizationService.java
View file @
f1e92b5c
...
...
@@ -48,5 +48,4 @@ public interface OrganizationService {
boolean
addOrganizationInstitutes
(
Organization
organization
,
List
<
String
>
instituteList
);
boolean
setOrganizationInstitutes
(
Organization
organization
,
List
<
String
>
instituteList
);
}
src/main/java/org/genesys2/server/service/StatisticsService.java
0 → 100644
View file @
f1e92b5c
/**
* Copyright 2014 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package
org.genesys2.server.service
;
public
interface
StatisticsService
{
long
numberOfCountries
();
long
numberOfInstitutes
();
long
numberOfAccessions
();
}
src/main/java/org/genesys2/server/service/impl/ContentServiceImpl.java
View file @
f1e92b5c
...
...
@@ -37,6 +37,8 @@ import org.genesys2.server.persistence.domain.ClassPKRepository;
import
org.genesys2.server.service.ContentService
;
import
org.genesys2.server.service.HtmlSanitizer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
...
...
@@ -71,6 +73,7 @@ public class ContentServiceImpl implements ContentService {
}
@Override
@Cacheable
(
value
=
"contentcache"
,
key
=
"#root.methodName"
)
public
List
<
ActivityPost
>
lastNews
()
{
PageRequest
page
=
new
PageRequest
(
0
,
10
,
Direction
.
DESC
,
"postDate"
);
return
postRepository
.
findAll
(
page
).
getContent
();
...
...
@@ -83,11 +86,13 @@ public class ContentServiceImpl implements ContentService {
@Override
@Transactional
(
readOnly
=
false
)
@CacheEvict
(
value
=
"contentcache"
,
allEntries
=
true
)
public
void
save
(
Iterable
<
Article
>
articles
)
{
articleRepository
.
save
(
articles
);
}
@Override
@Cacheable
(
value
=
"contentcache"
,
key
=
"'globalarticle-' + #slug + '-' + #locale.language"
)
public
Article
getGlobalArticle
(
String
slug
,
Locale
locale
,
boolean
useDefault
)
{
return
getArticle
(
Article
.
class
,
null
,
slug
,
locale
,
useDefault
);
}
...
...
@@ -96,16 +101,19 @@ public class ContentServiceImpl implements ContentService {
* Get article, use default locale if required
*/
@Override
@Cacheable
(
value
=
"contentcache"
,
key
=
"'globalarticle-' + #slug + '-' + #locale.language"
)
public
Article
getGlobalArticle
(
String
slug
,
Locale
locale
)
{
return
getGlobalArticle
(
slug
,
locale
,
true
);
}
@Override
@Cacheable
(
value
=
"contentcache"
,
key
=
"'article-' + #entity.class.name + '-' + #entity.id + '-' + #slug + '-' + #locale.language"
)
public
Article
getArticle
(
EntityId
entity
,
String
slug
,
Locale
locale
)
{
return
getArticle
(
entity
.
getClass
(),
entity
.
getId
(),
slug
,
locale
,
true
);
}
@Override
@Cacheable
(
value
=
"contentcache"
,
key
=
"'article-' + #clazz.name + '-' + #id + '-' + #slug + '-' + #locale.language"
)
public
Article
getArticle
(
Class
<?>
clazz
,
Long
id
,
String
slug
,
Locale
locale
,
boolean
useDefault
)
{
Article
article
=
articleRepository
.
findByClassPkAndTargetIdAndSlugAndLang
(
getClassPk
(
clazz
),
id
,
slug
,
locale
.
getLanguage
());
if
(
article
==
null
&&
useDefault
&&
!
locale
.
getLanguage
().
equals
(
getDefaultLocale
().
getLanguage
()))
{
...
...
@@ -117,6 +125,7 @@ public class ContentServiceImpl implements ContentService {
@Override
@Transactional
(
readOnly
=
false
)
@PreAuthorize
(
"hasRole('ADMINISTRATOR')"
)
@CacheEvict
(
value
=
"contentcache"
,
allEntries
=
true
)
public
Article
updateArticle
(
long
id
,
String
slug
,
String
title
,
String
body
)
{
Article
article
=
articleRepository
.
findOne
(
id
);
...
...
@@ -138,6 +147,7 @@ public class ContentServiceImpl implements ContentService {
@Override
@Transactional
(
readOnly
=
false
)
@PreAuthorize
(
"hasRole('ADMINISTRATOR')"
)
@CacheEvict
(
value
=
"contentcache"
,
allEntries
=
true
)
public
Article
createGlobalArticle
(
String
slug
,
Locale
locale
,
String
title
,
String
body
)
{
Article
article
=
getGlobalArticle
(
slug
,
locale
,
false
);
if
(
article
!=
null
)
{
...
...
@@ -167,6 +177,7 @@ public class ContentServiceImpl implements ContentService {
@Override
@Transactional
(
readOnly
=
false
)
@PreAuthorize
(
"hasRole('ADMINISTRATOR')"
)
@CacheEvict
(
value
=
"contentcache"
,
allEntries
=
true
)
public
Article
updateArticle
(
EntityId
entity
,
String
slug
,
String
title
,
String
body
,
Locale
locale
)
{
// return
// articleRepository.findByClassPkAndTargetIdAndSlugAndLang(getClassPk(clazz),
...
...
@@ -177,6 +188,7 @@ public class ContentServiceImpl implements ContentService {
@Override
@Transactional
(
readOnly
=
false
)
@PreAuthorize
(
"hasRole('ADMINISTRATOR')"
)
@CacheEvict
(
value
=
"contentcache"
,
allEntries
=
true
)
public
Article
updateArticle
(
Class
<?>
clazz
,
Long
id
,
String
slug
,
String
title
,
String
body
,
Locale
locale
)
{
Article
article
=
getArticle
(
clazz
,
id
,
slug
,
locale
,
false
);
if
(
article
==
null
||
!
article
.
getLang
().
equals
(
locale
.
getLanguage
()))
{
...
...
@@ -221,6 +233,7 @@ public class ContentServiceImpl implements ContentService {
}
@Override
@Cacheable
(
value
=
"contentcache"
,
key
=
"'activityPost-' + #id"
)
public
ActivityPost
getActivityPost
(
long
id
)
{
return
postRepository
.
findOne
(
id
);
}
...
...
@@ -231,6 +244,7 @@ public class ContentServiceImpl implements ContentService {
@Override
@Transactional
(
readOnly
=
false
)
@PreAuthorize
(
"hasRole('ADMINISTRATOR')"
)
@CacheEvict
(
value
=
"contentcache"
,
allEntries
=
true
)
public
ActivityPost
createActivityPost
(
String
title
,
String
body
)
{
ActivityPost
newPost
=
new
ActivityPost
();
newPost
.
setPostDate
(
GregorianCalendar
.
getInstance
());
...
...
@@ -240,6 +254,7 @@ public class ContentServiceImpl implements ContentService {
@Override
@Transactional
(
readOnly
=
false
)
@PreAuthorize
(
"hasRole('ADMINISTRATOR')"
)
@CacheEvict
(
value
=
"contentcache"
,
allEntries
=
true
)
public
ActivityPost
updateActivityPost
(
long
id
,
String
title
,
String
body
)
{
ActivityPost
post
=
postRepository
.
findOne
(
id
);
return
updatePostData
(
post
,
title
,
body
);
...
...
@@ -255,6 +270,7 @@ public class ContentServiceImpl implements ContentService {
@Override
@Transactional
(
readOnly
=
false
)
@PreAuthorize
(
"hasRole('ADMINISTRATOR')"
)
@CacheEvict
(
value
=
"contentcache"
,
allEntries
=
true
)
public
void
deleteActivityPost
(
long
id
)
{
postRepository
.
delete
(
id
);
}
...
...
src/main/java/org/genesys2/server/service/impl/GenesysServiceImpl.java
View file @
f1e92b5c
...
...
@@ -164,6 +164,11 @@ public class GenesysServiceImpl implements GenesysService, TraitService, Dataset
@Autowired
private
AccessionAliasRepository
accessionAliasRepository
;
@Override
public
long
countAll
()
{
return
accessionRepository
.
count
();
}
@Override
public
long
countByInstitute
(
FaoInstitute
institute
)
{
return
accessionRepository
.
countByInstitute
(
institute
);
...
...
src/main/java/org/genesys2/server/service/impl/GeoServiceImpl.java
View file @
f1e92b5c
...
...
@@ -86,6 +86,11 @@ public class GeoServiceImpl implements GeoService {
Country
.
sort
(
countries
,
locale
);
return
countries
;
}
@Override
public
long
countActive
()
{
return
countryRepository
.
countByCurrent
(
true
);
}
@Override
public
List
<
Country
>
listITPGRFA
(
Locale
locale
)
{
...
...
src/main/java/org/genesys2/server/service/impl/InstituteServiceImpl.java
View file @
f1e92b5c
...
...
@@ -84,6 +84,11 @@ public class InstituteServiceImpl implements InstituteService {
return
instituteRepository
.
listAllActive
(
pageRequest
);
}
@Override
public
long
countActive
()
{
return
instituteRepository
.
countActive
();
}
@Override
public
FaoInstitute
getInstitute
(
String
wiewsCode
)
{
FaoInstitute
inst
=
instituteRepository
.
findByCode
(
wiewsCode
);
...
...
src/main/java/org/genesys2/server/service/impl/StatisticsServiceImpl.java
0 → 100644
View file @
f1e92b5c
package
org.genesys2.server.service.impl
;
import
org.genesys2.server.service.GenesysService
;
import
org.genesys2.server.service.GeoService
;
import
org.genesys2.server.service.InstituteService
;
import
org.genesys2.server.service.StatisticsService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
@Service
@Transactional
(
readOnly
=
true
)
public
class
StatisticsServiceImpl
implements
StatisticsService
{
@Autowired
private
GeoService
geoService
;
@Autowired
private
InstituteService
instituteService
;
@Autowired
private
GenesysService
genesysService
;
@Override
@Cacheable
(
value
=
"statistics"
,
key
=
"'stats.' + #root.methodName"
)
public
long
numberOfCountries
()
{
return
geoService
.
countActive
();
}
@Override
@Cacheable
(
value
=
"statistics"
,
key
=
"'stats.' + #root.methodName"
)
public
long
numberOfInstitutes
()
{
return
instituteService
.
countActive
();
}
@Override
@Cacheable
(
value
=
"statistics"
,
key
=
"'stats.' + #root.methodName"
)
public
long
numberOfAccessions
()
{
return
genesysService
.
countAll
();
}
}
src/main/java/org/genesys2/server/servlet/controller/HtmlController.java
View file @
f1e92b5c
...
...
@@ -28,10 +28,13 @@ import org.genesys2.server.security.lockout.AccountLockoutManager;
import
org.genesys2.server.service.ContentService
;
import
org.genesys2.server.service.CropService
;
import
org.genesys2.server.service.EMailVerificationService
;
import
org.genesys2.server.service.OrganizationService
;
import
org.genesys2.server.service.StatisticsService
;
import
org.genesys2.server.service.UserService
;
import
org.genesys2.util.ReCaptchaUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.security.access.AccessDeniedException
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.ModelMap
;
...
...
@@ -54,9 +57,6 @@ public class HtmlController extends BaseController {
@Autowired
private
CropService
cropService
;
@Autowired
private
ContentService
activityPostService
;
@Autowired
private
Validator
validator
;
...
...
@@ -75,6 +75,12 @@ public class HtmlController extends BaseController {
@Value
(
"${captcha.publicKey}"
)
private
String
captchaPublicKey
;
@Autowired
private
StatisticsService
statisticsService
;
@Autowired
private
OrganizationService
organizationService
;
@RequestMapping
(
"/"
)
public
String
index
()
{
return
"redirect:/welcome"
;
...
...
@@ -86,8 +92,15 @@ public class HtmlController extends BaseController {
model
.
addAttribute
(
"permissionsList"
,
permissionsList
);
// FIXME get user locale!
model
.
addAttribute
(
"cropList"
,
cropService
.
list
(
getLocale
()));
model
.
addAttribute
(
"lastNews"
,
activityPos
tService
.
lastNews
());
model
.
addAttribute
(
"lastNews"
,
conten
tService
.
lastNews
());
model
.
addAttribute
(
"welcomeBlurp"
,
contentService
.
getGlobalArticle
(
"welcome"
,
getLocale
()));
model
.
addAttribute
(
"numberOfCountries"
,
statisticsService
.
numberOfCountries
());
model
.
addAttribute
(
"numberOfInstitutes"
,
statisticsService
.
numberOfInstitutes
());
model
.
addAttribute
(
"numberOfAccessions"
,
statisticsService
.
numberOfAccessions
());
model
.
addAttribute
(
"organizations"
,
organizationService
.
list
(
new
PageRequest
(
0
,
5
)));
return
"/index"
;
}
...
...
src/main/resources/content/language.properties
View file @
f1e92b5c
...
...
@@ -458,4 +458,8 @@ team.user.enter.email=Enter user email
user.not.found
=
User not found
team.profile.update.title
=
Update team information
autocomplete.genus
=
Find Genus...
\ No newline at end of file
autocomplete.genus
=
Find Genus...
stats.number-of-countries
=
{0} Countries
stats.number-of-institutes
=
{0} Institutes
stats.number-of-accessions
=
{0} Accessions
src/main/resources/ehcache.xml
View file @
f1e92b5c
...
...
@@ -21,9 +21,8 @@
<defaultCache
maxElementsInMemory=
"10000"
eternal=
"false"
timeToIdleSeconds=
"1800"
timeToLiveSeconds=
"3600"
overflowToDisk=
"false"
/>
<!--ACL in-memory cache -->
<cache
name=
"sparsedata"
maxElementsInMemory=
"10000"
eternal=
"false"
timeToIdleSeconds=
"1800"
timeToLiveSeconds=
"3600"
overflowToDisk=
"false"
/>
<cache
name=
"sparseentry"
maxElementsInMemory=
"10000"
eternal=
"false"
timeToIdleSeconds=
"1800"
timeToLiveSeconds=
"3600"
overflowToDisk=
"false"
/>
<cache
name=
"statistics"
maxElementsInMemory=
"100"
eternal=
"false"
timeToIdleSeconds=
"60"
timeToLiveSeconds=
"120"
overflowToDisk=
"false"
/>
<cache
name=
"contentcache"
maxElementsInMemory=
"1000"
eternal=
"false"
timeToIdleSeconds=
"60"
timeToLiveSeconds=
"120"
overflowToDisk=
"false"
/>
<!--CACHEABLE CACHES -->
...
...
src/main/resources/spring/spring.properties
View file @
f1e92b5c
...
...
@@ -21,7 +21,7 @@ db.driverClassName=com.mysql.jdbc.Driver
db.dialect
=
org.hibernate.dialect.MySQL5Dialect
db.username
=
root
db.password
=
db.showSql
=
fals
e
db.showSql
=
tru
e
db.hbm2ddl
=
do-nothing
c3p0.acquireIncrement
=
1
...
...
src/main/webapp/WEB-INF/jsp/index.jsp
View file @
f1e92b5c
...
...
@@ -78,9 +78,9 @@
<div
class=
"stats-map"
>
<div
class=
"all-stats"
>
<div
class=
"one-stat"
>
326 Countries
</div>
<div
class=
"one-stat"
>
13.432 Institutes
</div>
<div
class=
"one-stat"
>
2.544.876 Accessions
</div>
<div
class=
"one-stat"
>
<a
href=
"
<c:url
value=
"/geo/"
/>
"
><spring:message
code=
"stats.number-of-countries"
arguments=
"
${
numberOfCountries
}
"
/></a>
</div>
<div
class=
"one-stat"
>
<a
href=
"
<c:url
value=
"/wiews/active"
/>
"
><spring:message
code=
"stats.number-of-institutes"
arguments=
"
${
numberOfInstitutes
}
"
/></a>
</div>
<div
class=
"one-stat"
>
<a
href=
"
<c:url
value=
"/explore"
/>
"
><spring:message
code=
"stats.number-of-accessions"
arguments=
"
${
numberOfAccessions
}
"
/></a>
</div>
</div>
</div>
...
...
src/main/webapp/html/css/custom.css
View file @
f1e92b5c
...
...
@@ -954,6 +954,10 @@ html[dir="rtl"] #stats .stats-map .all-stats {
padding
:
1px
5px
;
}
#stats
.one-stat
a
{
color
:
White
;
}
html
[
dir
=
"rtl"
]
#stats
.stats-map
.one-stat
{
float
:
right
;
}
...
...
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