Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Genesys Backend
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
41
Issues
41
List
Boards
Labels
Milestones
Packages
Packages
Container Registry
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Genesys PGR
Genesys Backend
Commits
c4557538
Commit
c4557538
authored
Nov 21, 2018
by
Maxym Borodenko
Committed by
Matija Obreza
Nov 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added @Validated to Subsets
parent
0337d424
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
2 deletions
+30
-2
src/main/java/org/genesys2/server/model/genesys/AccessionRef.java
.../java/org/genesys2/server/model/genesys/AccessionRef.java
+10
-0
src/main/java/org/genesys2/server/model/impl/Subset.java
src/main/java/org/genesys2/server/model/impl/Subset.java
+14
-0
src/main/java/org/genesys2/server/service/impl/SubsetServiceImpl.java
...a/org/genesys2/server/service/impl/SubsetServiceImpl.java
+6
-2
No files found.
src/main/java/org/genesys2/server/model/genesys/AccessionRef.java
View file @
c4557538
...
...
@@ -22,6 +22,8 @@ import javax.persistence.Embeddable;
import
javax.persistence.FetchType
;
import
javax.persistence.JoinColumn
;
import
javax.persistence.ManyToOne
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Size
;
import
org.genesys.blocks.model.JsonViews
;
import
org.genesys2.server.model.impl.AccessionIdentifier3
;
...
...
@@ -43,22 +45,30 @@ public class AccessionRef implements AccessionIdentifier3, Serializable {
private
static
final
long
serialVersionUID
=
1L
;
/** The DOI. */
@Size
(
max
=
100
)
@Column
(
length
=
100
)
private
String
doi
;
/** The inst code. */
@NotNull
@Size
(
max
=
10
)
@Column
(
length
=
10
,
nullable
=
false
)
private
String
instCode
;
/** The acce numb. */
@NotNull
@Size
(
max
=
50
)
@Column
(
nullable
=
false
,
length
=
50
)
private
String
acceNumb
;
/** The genus. */
@NotNull
@Size
(
max
=
100
)
@Column
(
nullable
=
false
,
length
=
100
)
private
String
genus
;
/** The species. */
@Size
(
max
=
100
)
@Column
(
nullable
=
true
,
length
=
100
)
private
String
species
;
...
...
src/main/java/org/genesys2/server/model/impl/Subset.java
View file @
c4557538
...
...
@@ -35,6 +35,9 @@ import javax.persistence.OneToMany;
import
javax.persistence.PrePersist
;
import
javax.persistence.PreUpdate
;
import
javax.persistence.Table
;
import
javax.validation.Valid
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Size
;
import
org.genesys.blocks.model.JsonViews
;
import
org.genesys.blocks.model.SelfCleaning
;
...
...
@@ -61,6 +64,8 @@ public class Subset extends UuidModel implements AclAwareModel, SelfCleaning {
private
static
final
long
serialVersionUID
=
7021405309572916429L
;
/** The title. */
@NotNull
@Size
(
max
=
250
)
@Column
(
length
=
250
,
nullable
=
false
)
protected
String
title
;
...
...
@@ -71,19 +76,24 @@ public class Subset extends UuidModel implements AclAwareModel, SelfCleaning {
protected
String
description
;
/** The publisher. */
@Size
(
max
=
250
)
@Column
(
length
=
250
)
protected
String
publisher
;
/** The date created. */
@Size
(
max
=
100
)
@Column
(
length
=
100
)
protected
String
dateCreated
;
/** The wiews code. */
@NotNull
@Size
(
max
=
8
)
@Column
(
name
=
"wiews_code"
,
length
=
8
,
nullable
=
false
)
private
String
wiewsCode
;
/** The institute. */
@NotNull
@ManyToOne
(
cascade
=
{},
optional
=
false
)
@JoinColumn
(
name
=
"institute_id"
,
updatable
=
false
)
@JsonView
({
JsonViews
.
Public
.
class
})
...
...
@@ -96,9 +106,11 @@ public class Subset extends UuidModel implements AclAwareModel, SelfCleaning {
indexes
=
{
@Index
(
columnList
=
"subsetId, instCode, acceNumb"
),
@Index
(
columnList
=
"subsetId, genus"
)
})
@Field
(
type
=
FieldType
.
Object
)
@JsonIgnore
@Valid
private
Set
<
AccessionRef
>
accessionRefs
;
/** The accession count. */
@NotNull
@Column
(
name
=
"accession_count"
,
nullable
=
false
)
private
int
accessionCount
=
0
;
...
...
@@ -120,10 +132,12 @@ public class Subset extends UuidModel implements AclAwareModel, SelfCleaning {
private
Set
<
String
>
crops
;
/** The date when subset was authored. */
@Size
(
max
=
8
)
@Column
(
length
=
8
)
private
String
date
;
/** The source. */
@Size
(
max
=
200
)
@Column
(
length
=
200
)
private
String
source
;
...
...
src/main/java/org/genesys2/server/service/impl/SubsetServiceImpl.java
View file @
c4557538
...
...
@@ -65,9 +65,11 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Isolation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.validation.annotation.Validated
;
import
com.querydsl.core.BooleanBuilder
;
import
com.querydsl.core.types.Predicate
;
import
javax.validation.Valid
;
/**
* The Class SubsetServiceImpl.
...
...
@@ -150,7 +152,8 @@ public class SubsetServiceImpl implements SubsetService {
@Override
@Transactional
@PreAuthorize
(
"hasRole('ADMINISTRATOR') or hasPermission(#institute, 'WRITE')"
)
public
Subset
create
(
final
FaoInstitute
institute
,
final
Subset
source
)
{
@Validated
public
Subset
create
(
final
FaoInstitute
institute
,
@Valid
final
Subset
source
)
{
LOG
.
info
(
"Create Subset."
);
if
(!
StringUtils
.
equals
(
institute
.
getCode
(),
source
.
getWiewsCode
()))
{
throw
new
InvalidApiUsageException
(
"Institute code of the subset does not match the code of Institute"
);
...
...
@@ -251,7 +254,8 @@ public class SubsetServiceImpl implements SubsetService {
@Override
@Transactional
@PreAuthorize
(
"hasRole('ADMINISTRATOR') or hasPermission(#source, 'WRITE')"
)
public
Subset
update
(
final
Subset
source
)
{
@Validated
public
Subset
update
(
@Valid
final
Subset
source
)
{
LOG
.
info
(
"Update Subset."
);
final
Subset
subset
=
loadSubset
(
source
);
copyValues
(
subset
,
source
);
...
...
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