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
21
Issues
21
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
50c0b09c
Commit
50c0b09c
authored
Mar 19, 2014
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FIX Taxonomy also updated when only sub-elements are provided for update
(e.g. only spauthor)
parent
611c201d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
11 deletions
+29
-11
src/main/java/org/genesys2/server/model/genesys/Taxonomy2.java
...ain/java/org/genesys2/server/model/genesys/Taxonomy2.java
+15
-1
src/main/java/org/genesys2/server/model/json/GenesysJsonFactory.java
...va/org/genesys2/server/model/json/GenesysJsonFactory.java
+11
-6
src/main/java/org/genesys2/server/service/impl/BatchRESTServiceImpl.java
...rg/genesys2/server/service/impl/BatchRESTServiceImpl.java
+3
-4
No files found.
src/main/java/org/genesys2/server/model/genesys/Taxonomy2.java
View file @
50c0b09c
...
...
@@ -66,6 +66,19 @@ public class Taxonomy2 extends GlobalVersionedAuditedModel {
@OneToMany
(
cascade
=
{},
fetch
=
FetchType
.
LAZY
,
mappedBy
=
"taxonomy"
)
private
List
<
CropTaxonomy
>
cropTaxonomies
;
public
Taxonomy2
()
{
}
public
Taxonomy2
(
Taxonomy2
taxonomy
)
{
if
(
taxonomy
!=
null
)
{
this
.
genus
=
taxonomy
.
genus
;
this
.
species
=
taxonomy
.
species
;
this
.
spAuthor
=
taxonomy
.
spAuthor
;
this
.
subtaxa
=
taxonomy
.
subtaxa
;
this
.
subtAuthor
=
taxonomy
.
subtAuthor
;
}
}
@PrePersist
private
void
prePersist
()
{
this
.
taxonName
=
getTaxonName
();
...
...
@@ -166,7 +179,8 @@ public class Taxonomy2 extends GlobalVersionedAuditedModel {
@Override
public
String
toString
()
{
return
MessageFormat
.
format
(
"Tax id={0} taxonName={1} genus={2} sp={3} spauthor={4} subtaxa={5} subtauthor={6}"
,
id
,
getTaxonName
(),
genus
,
species
,
spAuthor
,
subtaxa
,
subtAuthor
);
return
MessageFormat
.
format
(
"Tax id={0} taxonName={1} genus={2} sp={3} spauthor={4} subtaxa={5} subtauthor={6}"
,
id
,
getTaxonName
(),
genus
,
species
,
spAuthor
,
subtaxa
,
subtAuthor
);
}
}
src/main/java/org/genesys2/server/model/json/GenesysJsonFactory.java
View file @
50c0b09c
...
...
@@ -21,12 +21,17 @@ public class GenesysJsonFactory {
aj
.
setUuid
(
accession
.
getUuid
());
Taxonomy2
tax
=
accession
.
getTaxonomy
();
aj
.
setGenus
(
tax
.
getGenus
());
aj
.
setSpecies
(
tax
.
getSpecies
());
aj
.
setSpauthor
(
tax
.
getSpAuthor
());
aj
.
setSubtaxa
(
tax
.
getSubtaxa
());
aj
.
setSubtauthor
(
tax
.
getSubtAuthor
());
aj
.
setOrgCty
(
accession
.
getCountryOfOrigin
().
getCode3
());
if
(
tax
!=
null
)
{
aj
.
setGenus
(
tax
.
getGenus
());
aj
.
setSpecies
(
tax
.
getSpecies
());
aj
.
setSpauthor
(
tax
.
getSpAuthor
());
aj
.
setSubtaxa
(
tax
.
getSubtaxa
());
aj
.
setSubtauthor
(
tax
.
getSubtAuthor
());
}
if
(
accession
.
getCountryOfOrigin
()
!=
null
)
{
aj
.
setOrgCty
(
accession
.
getCountryOfOrigin
().
getCode3
());
}
aj
.
setAcqDate
(
accession
.
getAcquisitionDate
());
aj
.
setMlsStat
(
accession
.
getMlsStatus
());
aj
.
setInTrust
(
accession
.
getInTrust
());
...
...
src/main/java/org/genesys2/server/service/impl/BatchRESTServiceImpl.java
View file @
50c0b09c
...
...
@@ -444,11 +444,9 @@ public class BatchRESTServiceImpl implements BatchRESTService {
boolean
updated
=
false
;
// Do not persist this one, temporary use
Taxonomy2
current
=
new
Taxonomy2
();
Taxonomy2
taxonomy
=
accession
.
getTaxonomy
();
Taxonomy2
current
=
new
Taxonomy2
(
taxonomy
);
// Load JSON values into "current"
if
(
taxonomy
!=
null
)
current
.
setId
(
taxonomy
.
getId
());
current
.
setGenus
(
stringIfProvided
(
accnJson
.
get
(
"genus"
),
current
.
getGenus
()));
current
.
setGenus
(
stringIfProvided
(
accnJson
.
get
(
"newGenus"
),
current
.
getGenus
()));
current
.
setSpecies
(
stringIfProvided
(
accnJson
.
get
(
"species"
),
current
.
getSpecies
()));
...
...
@@ -459,7 +457,7 @@ public class BatchRESTServiceImpl implements BatchRESTService {
Taxonomy2
ensuredTaxonomy
=
taxonomyService
.
ensureTaxonomy2
(
current
.
getGenus
(),
current
.
getSpecies
(),
current
.
getSpAuthor
(),
current
.
getSubtaxa
(),
current
.
getSubtAuthor
());
if
(!(
ensuredTaxonomy
.
sameAs
(
current
)))
{
if
(!(
ensuredTaxonomy
.
sameAs
(
taxonomy
)))
{
accession
.
setTaxonomy
(
ensuredTaxonomy
);
accession
.
setTaxGenus
(
ensuredTaxonomy
.
getTaxGenus
());
...
...
@@ -485,6 +483,7 @@ public class BatchRESTServiceImpl implements BatchRESTService {
// We expect a String node
throw
new
RESTApiDataTypeException
(
"Not a String"
);
}
if
(
jsonNode
.
isNull
())
return
null
;
return
StringUtils
.
defaultIfBlank
(
jsonNode
.
textValue
(),
currentValue
);
}
return
currentValue
;
...
...
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