Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Genesys Backend
Commits
2d846a15
Commit
2d846a15
authored
Jan 02, 2015
by
Matija Obreza
Browse files
CropService is @Cached
parent
fdac8c30
Changes
1
Show whitespace changes
Inline
Side-by-side
src/main/java/org/genesys2/server/service/impl/CropServiceImpl.java
View file @
2d846a15
...
...
@@ -40,6 +40,8 @@ import org.genesys2.server.persistence.domain.Taxonomy2Repository;
import
org.genesys2.server.service.CropService
;
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.Pageable
;
import
org.springframework.security.access.prepost.PreAuthorize
;
...
...
@@ -51,6 +53,8 @@ import org.springframework.transaction.annotation.Transactional;
@Transactional
(
readOnly
=
true
)
public
class
CropServiceImpl
implements
CropService
{
private
static
final
String
CACHE_CROP_TAXONOMYCROPS
=
"hibernate.org.genesys2.server.model.impl.Crop.taxonomyCrops"
;
public
static
final
Log
LOG
=
LogFactory
.
getLog
(
CropServiceImpl
.
class
);
@Autowired
...
...
@@ -100,6 +104,7 @@ public class CropServiceImpl implements CropService {
}
@Override
@Cacheable
(
value
=
CACHE_CROP_TAXONOMYCROPS
,
key
=
"#taxonomy2.id"
)
public
List
<
Crop
>
getCrops
(
Taxonomy2
taxonomy2
)
{
return
cropTaxonomyRepository
.
findCropsByTaxonomy
(
taxonomy2
);
}
...
...
@@ -107,6 +112,7 @@ public class CropServiceImpl implements CropService {
@Override
@Transactional
(
readOnly
=
false
,
propagation
=
Propagation
.
REQUIRES_NEW
)
@PreAuthorize
(
"hasRole('ADMINISTRATOR')"
)
@CacheEvict
(
value
=
CACHE_CROP_TAXONOMYCROPS
,
allEntries
=
true
)
public
void
rebuildTaxonomies
()
{
LOG
.
warn
(
"REBUILDING ALL CROP TAXONOMIES!"
);
...
...
@@ -120,6 +126,7 @@ public class CropServiceImpl implements CropService {
@Override
@Transactional
(
readOnly
=
false
)
@PreAuthorize
(
"hasRole('ADMINISTRATOR')"
)
@CacheEvict
(
value
=
CACHE_CROP_TAXONOMYCROPS
,
allEntries
=
true
)
public
void
rebuildTaxonomies
(
Crop
crop
)
{
LOG
.
info
(
"Rebuilding crop taxonomy for: "
+
crop
.
getName
());
// for all rules
...
...
@@ -308,6 +315,7 @@ public class CropServiceImpl implements CropService {
@Override
@Transactional
(
readOnly
=
false
)
@CacheEvict
(
value
=
CACHE_CROP_TAXONOMYCROPS
,
key
=
"#taxonomy.id"
)
public
void
updateCropTaxonomyLists
(
Taxonomy2
taxonomy
)
{
// Load all rules
List
<
CropRule
>
cropRules
=
cropRuleRepository
.
findAll
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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