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
fdbabd5d
Commit
fdbabd5d
authored
Feb 27, 2014
by
Matija Obreza
Browse files
REST: Taxonomy updated conditionally
parent
8f9f5874
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/genesys2/server/model/impl/FaoInstitute.java
View file @
fdbabd5d
...
...
@@ -87,7 +87,7 @@ public class FaoInstitute extends BusinessModel implements GeoReferencedEntity,
private
Double
latitude
;
private
Double
longitude
;
private
Double
elevation
;
private
boolean
uniqueAcceNumbs
;
private
boolean
uniqueAcceNumbs
=
true
;
public
FaoInstitute
()
{
}
...
...
@@ -215,7 +215,7 @@ public class FaoInstitute extends BusinessModel implements GeoReferencedEntity,
public
boolean
hasUniqueAcceNumbs
()
{
return
this
.
uniqueAcceNumbs
;
}
public
void
setUniqueAcceNumbs
(
boolean
uniqueAcceNumbs
)
{
this
.
uniqueAcceNumbs
=
uniqueAcceNumbs
;
}
...
...
src/main/java/org/genesys2/server/service/impl/BatchRESTServiceImpl.java
View file @
fdbabd5d
...
...
@@ -130,13 +130,19 @@ public class BatchRESTServiceImpl implements BatchRESTService {
updated
=
true
;
}
if
(
accession
.
getId
()
==
null
||
(
useUniqueAcceNumbs
&&
accnJson
.
get
(
"genus"
)
!=
null
)
||
accnJson
.
get
(
"newGenus"
)
!=
null
||
accnJson
.
get
(
"species"
)
!=
null
||
accnJson
.
get
(
"spauthor"
)
!=
null
||
accnJson
.
get
(
"subtaxa"
)
!=
null
||
accnJson
.
get
(
"subtauthor"
)
!=
null
)
{
updated
|=
updateTaxonomy
(
accession
,
accnJson
);
}
updated
|=
updateAcceNumb
(
accession
,
accnJson
.
get
(
"newAcceNumb"
));
updated
|=
updateTaxonomy
(
accession
,
accnJson
);
updated
|=
updateOrgCty
(
accession
,
accnJson
.
get
(
"orgCty"
));
updated
|=
updateUuid
(
accession
,
accnJson
.
get
(
"uuid"
));
// TODO Move other setters to methods
JsonNode
value
=
accnJson
.
get
(
"acqDate"
);
if
(
value
!=
null
)
{
String
acqDate
=
value
.
isNull
()
?
null
:
value
.
textValue
();
...
...
@@ -375,7 +381,7 @@ public class BatchRESTServiceImpl implements BatchRESTService {
throw
new
RESTApiValueException
(
"newAcceNumb cannot be null"
);
}
String
newAcceNumb
=
value
.
textValue
();
String
newAcceNumb
=
value
.
textValue
();
if
(!
StringUtils
.
equals
(
newAcceNumb
,
accession
.
getAccessionName
()))
{
accession
.
setAccessionName
(
newAcceNumb
);
return
true
;
...
...
@@ -444,12 +450,12 @@ public class BatchRESTServiceImpl implements BatchRESTService {
}
// Load JSON values into "current"
current
.
setGenus
(
StringUtils
.
defaultIfBlank
(
stringIfProvided
(
accnJson
.
get
(
"genus"
)
)
,
current
.
getGenus
()));
current
.
setGenus
(
StringUtils
.
defaultIfBlank
(
stringIfProvided
(
accnJson
.
get
(
"newGenus"
)
)
,
current
.
getGenus
()));
current
.
setSpecies
(
StringUtils
.
defaultIfBlank
(
stringIfProvided
(
accnJson
.
get
(
"species"
)
)
,
current
.
getSpecies
()));
current
.
setSpAuthor
(
StringUtils
.
defaultIfBlank
(
stringIfProvided
(
accnJson
.
get
(
"spauthor"
)
)
,
current
.
getSpAuthor
()));
current
.
setSubtaxa
(
StringUtils
.
defaultIfBlank
(
stringIfProvided
(
accnJson
.
get
(
"subtaxa"
)
)
,
current
.
getSubtaxa
()));
current
.
setSubtAuthor
(
StringUtils
.
defaultIfBlank
(
stringIfProvided
(
accnJson
.
get
(
"subtauthor"
)
)
,
current
.
getSubtAuthor
()));
current
.
setGenus
(
stringIfProvided
(
accnJson
.
get
(
"genus"
),
current
.
getGenus
()));
current
.
setGenus
(
stringIfProvided
(
accnJson
.
get
(
"newGenus"
),
current
.
getGenus
()));
current
.
setSpecies
(
stringIfProvided
(
accnJson
.
get
(
"species"
),
current
.
getSpecies
()));
current
.
setSpAuthor
(
stringIfProvided
(
accnJson
.
get
(
"spauthor"
),
current
.
getSpAuthor
()));
current
.
setSubtaxa
(
stringIfProvided
(
accnJson
.
get
(
"subtaxa"
),
current
.
getSubtaxa
()));
current
.
setSubtAuthor
(
stringIfProvided
(
accnJson
.
get
(
"subtauthor"
),
current
.
getSubtAuthor
()));
Taxonomy2
ensuredTaxonomy
=
null
;
if
(
current
.
getId
()
==
null
...
...
@@ -470,21 +476,19 @@ public class BatchRESTServiceImpl implements BatchRESTService {
* Return
*
* @param jsonNode
* @param currentValue
* @return
* @throws RESTApiDataTypeException
*/
private
String
stringIfProvided
(
JsonNode
jsonNode
)
throws
RESTApiException
{
private
String
stringIfProvided
(
JsonNode
jsonNode
,
String
currentValue
)
throws
RESTApiException
{
if
(
jsonNode
!=
null
)
{
if
(!
jsonNode
.
isTextual
())
{
if
(
!
jsonNode
.
isNull
()
&&
!
jsonNode
.
isTextual
())
{
// We expect a String node
throw
new
RESTApiDataTypeException
(
"Not a String"
);
}
if
(
StringUtils
.
isBlank
(
jsonNode
.
textValue
()))
{
throw
new
RESTApiValueException
(
"Value cannot be a blank String"
);
}
return
StringUtils
.
defaultIfBlank
(
jsonNode
.
textValue
(),
null
);
return
StringUtils
.
defaultIfBlank
(
jsonNode
.
textValue
(),
currentValue
);
}
return
null
;
return
currentValue
;
}
private
String
arrayToString
(
ArrayNode
arr
)
{
...
...
src/main/resources/spring/spring.properties
View file @
fdbabd5d
...
...
@@ -21,7 +21,7 @@ db.driverClassName=com.mysql.jdbc.Driver
db.dialect
=
org.hibernate.dialect.MySQL5Dialect
db.username
=
root
db.password
=
db.showSql
=
tru
e
db.showSql
=
fals
e
db.hbm2ddl
=
do-nothing
c3p0.acquireIncrement
=
1
...
...
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