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
efccf89d
Commit
efccf89d
authored
Jul 13, 2018
by
Matija Obreza
Browse files
Finalized migration to updated data model
- Uploader - JSPs
parent
82c8bf50
Changes
20
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
efccf89d
...
...
@@ -645,6 +645,9 @@
<artifactId>
jetty-maven-plugin
</artifactId>
<version>
${jetty.version}
</version>
<configuration>
<httpConnector>
<port>
8080
</port>
</httpConnector>
<stopPort>
8888
</stopPort>
<stopKey>
stop
</stopKey>
<jvmArgs>
-Dspring.profiles.active=dev -Xmx2048M -Xms1024M -XX:MaxPermSize=128M -Djava.awt.headless=true -server -Dorg.eclipse.jetty.server.Request.maxFormContentSize=5000000
</jvmArgs>
...
...
src/main/java/org/genesys2/server/model/genesys/Accession.java
View file @
efccf89d
...
...
@@ -36,7 +36,13 @@ import org.springframework.data.elasticsearch.annotations.Document;
uniqueConstraints
=
{
@UniqueConstraint
(
name
=
"UQ_accession_genus_inst"
,
columnNames
=
{
"instituteId"
,
"genus"
,
"acceNumb"
}),
@UniqueConstraint
(
name
=
"UQ_accession_doi"
,
columnNames
=
{
"doi"
})
},
// Indexes
indexes
=
{
@Index
(
name
=
"IX_acceNumb"
,
columnList
=
"acceNumb"
),
@Index
(
name
=
"IX_seqNo"
,
columnList
=
"seqNo"
),
@Index
(
name
=
"IX_accession_lastModifiedDate"
,
columnList
=
"lastModifiedDate"
)
})
indexes
=
{
@Index
(
name
=
"IX_acceNumb"
,
columnList
=
"acceNumb"
),
@Index
(
name
=
"IX_inst_seqNo"
,
columnList
=
"instituteId,seqNo"
),
@Index
(
name
=
"IX_origcty_seqNo"
,
columnList
=
"orgCtyId,seqNo"
),
@Index
(
name
=
"IX_taxa_seq"
,
columnList
=
"taxonomyId2,seqNo"
),
@Index
(
name
=
"IX_seqNo"
,
columnList
=
"seqNo"
),
@Index
(
name
=
"IX_accession_lastModifiedDate"
,
columnList
=
"lastModifiedDate"
)
})
@Audited
@Document
(
indexName
=
"genesys"
)
public
class
Accession
extends
AccessionData
{
...
...
src/main/java/org/genesys2/server/model/genesys/AccessionData.java
View file @
efccf89d
...
...
@@ -328,7 +328,7 @@ public abstract class AccessionData extends AuditedVersionedModel implements IdU
@Override
public
String
toString
()
{
return
MessageFormat
.
format
(
"Accession id={0,number,##########} UUID={1}"
,
accessionId
.
getId
(),
getUuid
());
return
MessageFormat
.
format
(
"Accession id={0,number,##########} UUID={1}
{2} {3} {4}
"
,
accessionId
.
getId
(),
getUuid
()
,
instituteCode
,
accessionNumber
,
genus
);
}
public
String
getAcceUrl
()
{
...
...
@@ -431,18 +431,35 @@ public abstract class AccessionData extends AuditedVersionedModel implements IdU
public
Integer
getSampleStatus
()
{
return
this
.
sampStat
;
}
@Transient
@JsonIgnore
// For EL
public
Boolean
getAvailable
()
{
return
this
.
available
;
}
@Transient
@JsonIgnore
// For EL
public
Boolean
getAvailability
()
{
return
this
.
available
;
}
@Transient
@JsonIgnore
// For EL
public
Boolean
getHistoric
()
{
return
this
.
historic
;
}
@Transient
@JsonIgnore
// For EL
public
String
getInstCode
()
{
return
this
.
instituteCode
;
}
}
src/main/java/org/genesys2/server/model/genesys/AccessionId.java
View file @
efccf89d
...
...
@@ -114,6 +114,11 @@ public class AccessionId extends AuditedVersionedModel implements IdUUID {
@CollectionTable
(
name
=
"accession_breedercode"
,
joinColumns
=
@JoinColumn
(
name
=
"accessionId"
,
referencedColumnName
=
"id"
))
private
Set
<
String
>
breederCode
;
@Column
(
name
=
"breederName"
,
nullable
=
false
,
length
=
250
)
@ElementCollection
(
fetch
=
FetchType
.
LAZY
)
@CollectionTable
(
name
=
"accession_breedername"
,
joinColumns
=
@JoinColumn
(
name
=
"accessionId"
,
referencedColumnName
=
"id"
))
private
Set
<
String
>
breederName
;
@PrePersist
private
void
prepersist
()
{
if
(
uuid
==
null
)
{
...
...
@@ -193,6 +198,14 @@ public class AccessionId extends AuditedVersionedModel implements IdUUID {
public
void
setBreederCode
(
Set
<
String
>
breederCode
)
{
this
.
breederCode
=
breederCode
;
}
public
Set
<
String
>
getBreederName
()
{
return
breederName
;
}
public
void
setBreederName
(
Set
<
String
>
breederName
)
{
this
.
breederName
=
breederName
;
}
public
Set
<
String
>
getDuplSite
()
{
return
duplSite
;
...
...
src/main/java/org/genesys2/server/model/genesys/Taxonomy2.java
View file @
efccf89d
...
...
@@ -183,7 +183,7 @@ public class Taxonomy2 extends GlobalVersionedAuditedModel {
}
public
Long
getTaxGenus
()
{
return
this
.
taxGenus
;
return
this
.
taxGenus
==
null
?
this
.
getId
()
:
this
.
taxGenus
;
}
public
void
setTaxGenus
(
Long
taxGenus
)
{
...
...
@@ -191,7 +191,7 @@ public class Taxonomy2 extends GlobalVersionedAuditedModel {
}
public
Long
getTaxSpecies
()
{
return
this
.
taxSpecies
;
return
this
.
taxSpecies
==
null
?
this
.
getId
()
:
this
.
taxSpecies
;
}
public
void
setTaxSpecies
(
Long
taxSpecies
)
{
...
...
src/main/java/org/genesys2/server/model/impl/FaoInstitute.java
View file @
efccf89d
...
...
@@ -97,10 +97,8 @@ public class FaoInstitute extends BasicModel implements GeoReferencedEntity, Acl
private
Double
latitude
;
private
Double
longitude
;
private
Double
elevation
;
private
boolean
uniqueAcceNumbs
=
true
;
@Column
(
name
=
"allowMaterialRequests"
,
columnDefinition
=
"boolean default true"
,
nullable
=
false
)
private
boolean
allowMaterialRequests
=
true
;
private
boolean
uniqueAcceNumbs
=
false
;
private
boolean
allowMaterialRequests
=
false
;
public
FaoInstitute
()
{
}
...
...
src/main/java/org/genesys2/server/persistence/domain/AccessionRepositoryCustomImpl.java
View file @
efccf89d
...
...
@@ -162,12 +162,12 @@ public class AccessionRepositoryCustomImpl implements AccessionRepositoryCustom,
}
if
(
uniqueAcceNumbs
)
{
restrictions
.
add
(
root
.
get
(
"accessionN
ame
"
).
in
(
acceNumbs
));
restrictions
.
add
(
root
.
get
(
"accessionN
umber
"
).
in
(
acceNumbs
));
LOG
.
trace
(
"*** {} accenumbs={}"
,
institute
.
getCode
(),
acceNumbs
);
}
else
{
// A lot of .. (acceNumb=? and genus=?)
for
(
AccessionIdentifier3
ah
:
accessionIds
)
{
restrictions
.
add
(
criteriaBuilder
.
and
(
criteriaBuilder
.
equal
(
root
.
get
(
"accessionN
ame
"
),
ah
.
getAccessionNumber
()),
criteriaBuilder
.
equal
(
tax
.
get
(
"genus"
),
ah
.
getGenus
())));
restrictions
.
add
(
criteriaBuilder
.
and
(
criteriaBuilder
.
equal
(
root
.
get
(
"accessionN
umber
"
),
ah
.
getAccessionNumber
()),
criteriaBuilder
.
equal
(
tax
.
get
(
"genus"
),
ah
.
getGenus
())));
}
}
cq
.
where
(
criteriaBuilder
.
and
(
criteriaBuilder
.
equal
(
root
.
get
(
"institute"
),
institute
),
criteriaBuilder
.
or
(
restrictions
.
toArray
(
EMPTY_PREDICATE_ARRAY
))));
...
...
@@ -206,9 +206,9 @@ public class AccessionRepositoryCustomImpl implements AccessionRepositoryCustom,
if
(
doi
!=
null
)
{
restrictions
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"doi"
),
doi
));
}
else
if
(
institute
.
hasUniqueAcceNumbs
())
{
restrictions
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"accessionN
ame
"
),
acceNumb
));
restrictions
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"accessionN
umber
"
),
acceNumb
));
}
else
{
restrictions
.
add
(
criteriaBuilder
.
and
(
criteriaBuilder
.
equal
(
root
.
get
(
"accessionN
ame
"
),
acceNumb
),
criteriaBuilder
.
equal
(
tax
.
get
(
"genus"
),
genus
)));
restrictions
.
add
(
criteriaBuilder
.
and
(
criteriaBuilder
.
equal
(
root
.
get
(
"accessionN
umber
"
),
acceNumb
),
criteriaBuilder
.
equal
(
tax
.
get
(
"genus"
),
genus
)));
}
cq
.
where
(
criteriaBuilder
.
and
(
criteriaBuilder
.
equal
(
root
.
get
(
"institute"
),
institute
),
criteriaBuilder
.
or
(
restrictions
.
toArray
(
new
Predicate
[]
{}))));
...
...
src/main/java/org/genesys2/server/service/impl/DirectMysqlQuery.java
View file @
efccf89d
...
...
@@ -47,6 +47,22 @@ public class DirectMysqlQuery {
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
DirectMysqlQuery
.
class
);
private
static
final
String
SPACE
=
" "
;
public
static
final
String
TABLE_ACCEID
=
"acce"
;
public
static
final
String
TABLE_ACCESSION
=
"accession"
;
public
static
final
String
TABLE_ACCESSION_STORAGE
=
"accession_storage"
;
public
static
final
String
TABLE_ACCESSION_COLLECT
=
"accession_collect"
;
public
static
final
String
TABLE_ACCESSION_ALIAS
=
"accession_alias"
;
public
static
final
String
TABLE_ACCESSION_GEO
=
"accession_geo"
;
public
static
final
String
TABLE_ACCESSION_LIST
=
"accession_list"
;
public
static
final
String
TABLE_ACCESION_LISTITEMS
=
"accession_listitem"
;
public
static
final
String
TABLE_ORGANIZATIONINSTITUTE
=
"organizationinstitute"
;
public
static
final
String
TABLE_CROP
=
"crop"
;
public
static
final
String
TABLE_PDCI
=
"pdci"
;
public
static
final
String
TABLE_TAXONOMY
=
"taxonomy2"
;
public
static
final
String
TABLE_ORGANIZATION
=
"organization"
;
public
static
final
String
TABLE_COUNTRY
=
"country"
;
public
static
final
String
TABLE_FAOINSTITUTE
=
"faoinstitute"
;
final
Set
<
String
>
tables
=
new
HashSet
<
String
>();
final
List
<
Object
>
params
=
new
ArrayList
<
Object
>();
final
StringBuffer
sb
,
whereBuffer
=
new
StringBuffer
(),
sortBuffer
=
new
StringBuffer
();
...
...
@@ -105,63 +121,65 @@ public class DirectMysqlQuery {
protected
DirectMysqlQuery
join
(
AppliedFilters
filters
)
{
if
(
filters
.
hasFilter
(
FilterConstants
.
UUID
))
{
innerJoin
(
TABLE_ACCEID
,
null
,
"acce.id=a.id"
);
}
if
(
filters
.
hasFilter
(
FilterConstants
.
LISTS
))
{
innerJoin
(
"accelistitems"
,
"ali"
,
"ali.acceid=a.id"
);
innerJoin
(
"accelist"
,
"al"
,
"al.id=ali.listid"
);
innerJoin
(
TABLE_ACCEID
,
null
,
"acce.id=a.id"
);
innerJoin
(
TABLE_ACCESION_LISTITEMS
,
"ali"
,
"ali.acceid=acce.id"
);
innerJoin
(
TABLE_ACCESSION_LIST
,
"al"
,
"al.id=ali.listid"
);
}
if
(
filters
.
hasFilter
(
FilterConstants
.
TAXONOMY_GENUS
)
||
filters
.
hasFilter
(
FilterConstants
.
TAXONOMY_SPECIES
)
||
filters
.
hasFilter
(
FilterConstants
.
TAXONOMY_SUBTAXA
)
||
filters
.
hasFilter
(
FilterConstants
.
TAXONOMY_SCINAME
))
{
if
(
filters
.
hasFilter
(
FilterConstants
.
TAXONOMY_GENUS
)
||
filters
.
hasFilter
(
FilterConstants
.
TAXONOMY_SPECIES
)
||
filters
.
hasFilter
(
FilterConstants
.
TAXONOMY_SUBTAXA
)
||
filters
.
hasFilter
(
FilterConstants
.
TAXONOMY_SCINAME
))
{
innerJoin
(
"taxonomy2"
,
"t"
,
"t.id=a.taxonomyId2"
);
innerJoin
(
TABLE_TAXONOMY
,
"t"
,
"t.id=a.taxonomyId2"
);
}
if
(
filters
.
hasFilter
(
FilterConstants
.
CROPS
))
{
innerJoin
(
"crop"
,
null
,
"crop.id=a.cropId"
);
innerJoin
(
TABLE_CROP
,
null
,
"crop.id=a.cropId"
);
}
if
(
filters
.
hasFilter
(
FilterConstants
.
UUID
))
{
innerJoin
(
"acce"
,
null
,
"acce.id=a.id"
);
}
if
(
filters
.
hasFilter
(
FilterConstants
.
PDCI
))
{
innerJoin
(
"pdci"
,
null
,
"pdci.accessionId=a.id"
);
innerJoin
(
TABLE_ACCEID
,
null
,
"acce.id=a.id"
);
innerJoin
(
TABLE_PDCI
,
null
,
"pdci.id=acce.pdciId"
);
}
// if (filters.hasFilter(FilterConstants.ORGCTY_ISO3)) {
// innerJoin("country", "cty", "cty.id=a.orgCtyId");
// }
if
(
/* filters.hasFilter(FilterConstants.INSTCODE) || */
filters
.
hasFilter
(
FilterConstants
.
INSTITUTE_COUNTRY_ISO3
)
||
filters
.
hasFilter
(
FilterConstants
.
INSTITUTE_NETWORK
))
{
if
(
filters
.
hasFilter
(
FilterConstants
.
INSTCODE
)
||
filters
.
hasFilter
(
FilterConstants
.
INSTITUTE_COUNTRY_ISO3
)
||
filters
.
hasFilter
(
FilterConstants
.
INSTITUTE_NETWORK
))
{
innerJoin
(
"faoinstitute"
,
"fao"
,
"fao.id=a.instituteId"
);
innerJoin
(
TABLE_FAOINSTITUTE
,
"fao"
,
"fao.id=a.instituteId"
);
if
(
filters
.
hasFilter
(
FilterConstants
.
INSTITUTE_COUNTRY_ISO3
))
{
innerJoin
(
"country"
,
"faocty"
,
"faocty.id=fao.countryId"
);
innerJoin
(
TABLE_COUNTRY
,
"faocty"
,
"faocty.id=fao.countryId"
);
}
if
(
filters
.
hasFilter
(
FilterConstants
.
INSTITUTE_NETWORK
))
{
innerJoin
(
"organizationinstitute"
,
"oi"
,
"oi.instituteId=fao.id"
);
innerJoin
(
"organization"
,
"org"
,
"org.id=oi.organizationId"
);
innerJoin
(
TABLE_ORGANIZATIONINSTITUTE
,
"oi"
,
"oi.instituteId=fao.id"
);
innerJoin
(
TABLE_ORGANIZATION
,
"org"
,
"org.id=oi.organizationId"
);
}
}
if
(
filters
.
hasFilter
(
FilterConstants
.
GEO_LATITUDE
)
||
filters
.
hasFilter
(
FilterConstants
.
GEO_LONGITUDE
)
||
filters
.
hasFilter
(
FilterConstants
.
GEO_ELEVATION
))
{
innerJoin
(
"accessiongeo"
,
"geo"
,
"geo.accessionId=a.id"
);
if
(
filters
.
hasFilter
(
FilterConstants
.
GEO_LATITUDE
)
||
filters
.
hasFilter
(
FilterConstants
.
GEO_LONGITUDE
)
||
filters
.
hasFilter
(
FilterConstants
.
GEO_ELEVATION
))
{
innerJoin
(
TABLE_ACCESSION_GEO
,
"geo"
,
"geo.id=acce.geoId"
);
}
if
(
filters
.
hasFilter
(
FilterConstants
.
ALIAS
))
{
innerJoin
(
"accessionalias"
,
"accename"
,
"accename.accessionId=a.id"
);
innerJoin
(
TABLE_ACCESSION_ALIAS
,
"accename"
,
"accename.accessionId=a
cce
.id"
);
}
if
(
filters
.
hasFilter
(
FilterConstants
.
COLLMISSID
))
{
innerJoin
(
"accessioncollect"
,
"col"
,
"col.accessionId=a.id"
);
innerJoin
(
TABLE_ACCEID
,
null
,
"acce.id=a.id"
);
innerJoin
(
TABLE_ACCESSION_COLLECT
,
"col"
,
"col.id=acce.collId"
);
}
if
(
filters
.
hasFilter
(
FilterConstants
.
STORAGE
))
{
outerJoin
(
"accessionstorage"
,
"storage"
,
"storage.accessionId=a.id"
);
innerJoin
(
TABLE_ACCEID
,
null
,
"acce.id=a.id"
);
outerJoin
(
TABLE_ACCESSION_STORAGE
,
"storage"
,
"storage.accessionId=acce.id"
);
}
return
this
;
...
...
@@ -170,17 +188,12 @@ public class DirectMysqlQuery {
protected
DirectMysqlQuery
filter
(
AppliedFilters
filters
,
MethodResolver
methodResolver
)
{
createQuery
(
whereBuffer
,
"a.id"
,
filters
.
get
(
FilterConstants
.
ID
),
params
);
createQuery
(
whereBuffer
,
"acce.uuid"
,
filters
.
get
(
FilterConstants
.
UUID
),
params
);
{
// FIXME Are these two still used?
createQuery
(
whereBuffer
,
"t.taxGenus"
,
filters
.
get
(
"genusId"
),
params
);
createQuery
(
whereBuffer
,
"t.taxSpecies"
,
filters
.
get
(
"speciesId"
),
params
);
}
createQuery
(
whereBuffer
,
"al.uuid"
,
filters
.
get
(
FilterConstants
.
LISTS
),
params
);
createQuery
(
whereBuffer
,
"a.acceNumb"
,
filters
.
get
(
FilterConstants
.
ACCENUMB
),
params
);
createQuery
(
whereBuffer
,
"a.seqNo"
,
filters
.
get
(
FilterConstants
.
SEQUENTIAL_NUMBER
),
params
);
createQuery
(
whereBuffer
,
"a.lastModifiedDate"
,
filters
.
get
(
FilterConstants
.
LAST_MODIFIED_DATE
),
params
);
createQuery
(
whereBuffer
,
"a.orgCty"
,
filters
.
get
(
FilterConstants
.
ORGCTY_ISO3
),
params
);
createQuery
(
whereBuffer
,
"
a.instC
ode"
,
filters
.
get
(
FilterConstants
.
INSTCODE
),
params
);
createQuery
(
whereBuffer
,
"a.or
i
gCty"
,
filters
.
get
(
FilterConstants
.
ORGCTY_ISO3
),
params
);
createQuery
(
whereBuffer
,
"
fao.c
ode"
,
filters
.
get
(
FilterConstants
.
INSTCODE
),
params
);
createQuery
(
whereBuffer
,
"a.cropName"
,
filters
.
get
(
FilterConstants
.
CROPNAME
),
params
);
createQuery
(
whereBuffer
,
"faocty.code3"
,
filters
.
get
(
FilterConstants
.
INSTITUTE_COUNTRY_ISO3
),
params
);
createQuery
(
whereBuffer
,
"a.inSGSV"
,
filters
.
get
(
FilterConstants
.
SGSV
),
params
);
...
...
src/main/java/org/genesys2/server/service/impl/GenesysFilterServiceImpl.java
View file @
efccf89d
...
...
@@ -123,7 +123,7 @@ public class GenesysFilterServiceImpl implements GenesysFilterService {
throw
new
RuntimeException
(
"Genesys does not support requests for data beyond "
+
PAGINATION_MAXPAGE_LIMIT
+
"th page."
);
}
final
DirectMysqlQuery
directQuery
=
new
DirectMysqlQuery
(
"accession"
,
"a"
);
final
DirectMysqlQuery
directQuery
=
new
DirectMysqlQuery
(
DirectMysqlQuery
.
TABLE_ACCESSION
,
"a"
);
directQuery
.
jsonFilter
(
filters
,
new
MethodResolver
()
{
@Override
public
Method
getMethod
(
long
methodId
)
{
...
...
@@ -170,7 +170,7 @@ public class GenesysFilterServiceImpl implements GenesysFilterService {
throw
new
MaxPageLimitException
(
PAGINATION_MAXPAGE_LIMIT
,
pageable
.
getPageNumber
()
+
1
);
}
final
DirectMysqlQuery
directQuery
=
new
DirectMysqlQuery
(
"accession"
,
"a"
);
final
DirectMysqlQuery
directQuery
=
new
DirectMysqlQuery
(
DirectMysqlQuery
.
TABLE_ACCESSION
,
"a"
);
directQuery
.
jsonFilter
(
filters
,
new
MethodResolver
()
{
@Override
public
Method
getMethod
(
long
methodId
)
{
...
...
@@ -394,14 +394,16 @@ public class GenesysFilterServiceImpl implements GenesysFilterService {
}
}
final
DirectMysqlQuery
directQuery
=
new
DirectMysqlQuery
(
"accessiongeo"
,
"geo"
);
directQuery
.
filterTile
(
zoom
,
xtile
,
ytile
);
final
DirectMysqlQuery
directQuery
=
new
DirectMysqlQuery
(
DirectMysqlQuery
.
TABLE_ACCESSION_GEO
,
"geo"
);
if
(!
filters
.
isEmpty
()
||
!
distinct
)
{
// Join accession table when we have filters or looking at details
directQuery
.
innerJoin
(
"accession"
,
"a"
,
"a.id=geo.accessionId"
);
directQuery
.
innerJoin
(
DirectMysqlQuery
.
TABLE_ACCEID
,
null
,
"acce.geoId=geo.id"
);
directQuery
.
innerJoin
(
DirectMysqlQuery
.
TABLE_ACCESSION
,
"a"
,
"a.id=acce.id"
);
}
directQuery
.
filterTile
(
zoom
,
xtile
,
ytile
);
if
(!
filters
.
isEmpty
())
{
directQuery
.
join
(
filters
);
directQuery
.
filter
(
filters
,
new
MethodResolver
()
{
...
...
src/main/java/org/genesys2/server/service/impl/GenesysServiceImpl.java
View file @
efccf89d
...
...
@@ -355,6 +355,8 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
accessionId
.
getAliases
().
size
();
if
(
accessionId
.
getBreederCode
()
!=
null
)
accessionId
.
getBreederCode
().
size
();
if
(
accessionId
.
getBreederName
()
!=
null
)
accessionId
.
getBreederName
().
size
();
if
(
accessionId
.
getDuplSite
()
!=
null
)
accessionId
.
getDuplSite
().
size
();
if
(
accessionId
.
getRemarks
()
!=
null
)
...
...
src/main/java/org/genesys2/server/service/impl/TaxonomyServiceImpl.java
View file @
efccf89d
...
...
@@ -208,7 +208,7 @@ public class TaxonomyServiceImpl implements TaxonomyService {
public
void
cleanupTaxonomies
()
{
Set
<
BigInteger
>
referencedIds
=
taxonomy2Repository
.
findTaxonomyReferencedIds
();
Set
<
Long
>
allIds
=
taxonomy2Repository
.
findTaxonomyIds
();
for
(
BigInteger
integer:
referencedIds
)
{
for
(
BigInteger
integer
:
referencedIds
)
{
allIds
.
remove
(
integer
.
longValue
());
}
...
...
@@ -216,13 +216,13 @@ public class TaxonomyServiceImpl implements TaxonomyService {
taxonomy2Repository
.
removeUnusedIds
(
allIds
);
}
}
@Override
@Transactional
(
timeout
=
50
,
isolation
=
Isolation
.
READ_UNCOMMITTED
,
propagation
=
Propagation
.
REQUIRED
)
public
Taxonomy2
ensureTaxonomy
(
Taxonomy2
example
)
{
example
.
sanitize
();
Taxonomy2
existing
=
taxonomy2Repository
.
findByGenusAndSpeciesAndSpAuthorAndSubtaxaAndSubtAuthor
(
example
.
getGenus
(),
example
.
getSpecies
(),
example
.
getSpAuthor
(),
example
.
getSubtaxa
(),
example
.
getSubtAuthor
());
Taxonomy2
existing
=
taxonomy2Repository
.
findByGenusAndSpeciesAndSpAuthorAndSubtaxaAndSubtAuthor
(
example
.
getGenus
(),
example
.
getSpecies
(),
example
.
getSpAuthor
(),
example
.
getSubtaxa
(),
example
.
getSubtAuthor
());
if
(
existing
==
null
)
{
LOG
.
debug
(
"Adding taxonomy {} {} {} {} {}"
,
example
.
getGenus
(),
example
.
getSpecies
(),
example
.
getSpAuthor
(),
example
.
getSubtaxa
(),
example
.
getSubtAuthor
());
Taxonomy2
newTaxa
=
new
Taxonomy2
();
...
...
@@ -231,7 +231,35 @@ public class TaxonomyServiceImpl implements TaxonomyService {
newTaxa
.
setSpAuthor
(
example
.
getSpAuthor
());
newTaxa
.
setSubtaxa
(
example
.
getSubtaxa
());
newTaxa
.
setSubtAuthor
(
example
.
getSubtAuthor
());
return
taxonomy2Repository
.
save
(
newTaxa
.
sanitize
());
Taxonomy2
tsP
=
new
Taxonomy2
();
tsP
.
setGenus
(
newTaxa
.
getGenus
());
tsP
.
setSpecies
(
newTaxa
.
getSpecies
());
tsP
.
sanitize
();
if
(
tsP
.
equalTo
(
newTaxa
))
{
// equal to species level
tsP
.
setSpecies
(
null
);
tsP
.
sanitize
();
// get genus id
if
(!
tsP
.
equalTo
(
newTaxa
))
{
tsP
=
ensureTaxonomy
(
tsP
);
newTaxa
.
setTaxGenus
(
tsP
.
getTaxGenus
());
}
else
{
// incoming taxonomy is genus level only.
// System.err.println("What now " + newTaxa + " == " + tsP);
}
}
else
{
// not equal to species level, ensure taxSpecies
tsP
=
ensureTaxonomy
(
tsP
);
newTaxa
.
setTaxGenus
(
tsP
.
getTaxGenus
());
newTaxa
.
setTaxSpecies
(
tsP
.
getId
());
}
Taxonomy2
t
=
taxonomy2Repository
.
save
(
newTaxa
.
sanitize
());
// self-references
t
.
setTaxGenus
(
t
.
getTaxGenus
());
t
.
setTaxSpecies
(
t
.
getTaxSpecies
());
return
taxonomy2Repository
.
save
(
t
);
}
else
{
return
existing
;
}
...
...
src/main/java/org/genesys2/server/service/worker/AccessionUploader.java
View file @
efccf89d
...
...
@@ -18,11 +18,13 @@ package org.genesys2.server.service.worker;
import
java.io.IOException
;
import
java.lang.reflect.Field
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.elasticsearch.common.lang3.StringUtils
;
import
org.genesys2.server.model.genesys.Accession
;
import
org.genesys2.server.model.genesys.AccessionAlias
;
import
org.genesys2.server.model.genesys.AccessionAlias.AliasType
;
...
...
@@ -112,6 +114,7 @@ public class AccessionUploader implements InitializingBean {
assert
(
updates
.
isArray
());
ObjectReader
reader
=
objectMapper
.
readerFor
(
Accession
.
class
);
Date
batchDate
=
new
Date
();
final
List
<
Accession
>
accessions
=
new
ArrayList
<>(
updates
.
size
());
final
List
<
AccessionOpResponse
>
responses
=
new
ArrayList
<>(
updates
.
size
());
List
<
Accession
>
toSave
=
new
ArrayList
<>(
updates
.
size
());
...
...
@@ -159,12 +162,15 @@ public class AccessionUploader implements InitializingBean {
LOG
.
trace
(
"Upserting: {}"
,
update
);
Accession
accession
=
existingAccessions
.
stream
().
filter
(
existing
->
{
return
(
existing
.
getDoi
()
!=
null
&&
existing
.
getDoi
().
equals
(
updateA
.
getDoi
()))
||
(
existing
.
getInstituteCode
().
equals
(
updateA
.
getInstituteCode
())
&&
existing
.
getAccessionNumber
().
equals
(
updateA
.
getAccessionNumber
())
&&
existing
.
getTaxonomy
().
getGenus
().
equals
(
updateA
.
getTaxonomy
().
getGenus
()));
return
(
existing
.
getDoi
()
!=
null
&&
existing
.
getDoi
().
equals
(
updateA
.
getDoi
()))
// or by triplet
||
(
StringUtils
.
equalsIgnoreCase
(
existing
.
getInstituteCode
(),
updateA
.
getInstituteCode
())
&&
StringUtils
.
equalsIgnoreCase
(
existing
.
getAccessionNumber
(),
updateA
.
getAccessionNumber
())
&&
StringUtils
.
equalsIgnoreCase
(
existing
.
getTaxonomy
().
getGenus
(),
updateA
.
getTaxonomy
().
getGenus
()));
}).
findFirst
().
orElse
(
null
);
if
(
accession
==
null
)
{
LOG
.
trace
(
"New accesson"
);
// LOG.trace("New accesson");
LOG
.
trace
(
"New accession {} not in {}"
,
update
,
existingAccessions
);
response
.
setResult
(
new
UpsertResult
(
UpsertResult
.
Type
.
INSERT
));
accession
=
new
Accession
();
accession
.
setAccessionId
(
new
AccessionId
());
...
...
@@ -176,6 +182,7 @@ public class AccessionUploader implements InitializingBean {
try
{
accession
=
applyChanges
(
update
,
updateA
,
accession
);
accession
.
setLastModifiedDate
(
batchDate
);
PDCI
pdci
=
accession
.
getAccessionId
().
getPdci
();
if
(
pdci
==
null
)
{
...
...
@@ -215,7 +222,7 @@ public class AccessionUploader implements InitializingBean {
if
(
"taxonomy"
.
equals
(
fieldName
))
{
updateTaxonomy
(
update
.
get
(
"taxonomy"
),
updateA
.
getTaxonomy
(),
accession
);
}
else
if
(
"orgCty"
.
equals
(
fieldName
))
{
}
else
if
(
"or
i
gCty"
.
equals
(
fieldName
))
{
updateOrigCty
(
updateA
.
getOrigCty
(),
accession
);
}
else
if
(
"geo"
.
equals
(
fieldName
))
{
...
...
src/main/java/org/genesys2/server/servlet/controller/AccessionController.java
View file @
efccf89d
...
...
@@ -34,6 +34,7 @@ import org.genesys2.server.model.elastic.AccessionDetails;
import
org.genesys2.server.model.genesys.Accession
;
import
org.genesys2.server.model.genesys.AccessionCollect
;
import
org.genesys2.server.model.genesys.AccessionGeo
;
import
org.genesys2.server.model.genesys.AccessionId
;
import
org.genesys2.server.model.genesys.Taxonomy2
;
import
org.genesys2.server.model.impl.Crop
;
import
org.genesys2.server.model.impl.FaoInstitute
;
...
...
@@ -138,34 +139,37 @@ public class AccessionController extends BaseController {
* @return
*/
public
ModelAndView
displayAccession
(
ModelMap
model
,
Accession
accession
)
{
AccessionId
accessionId
=
accession
.
getAccessionId
();
model
.
addAttribute
(
"accession"
,
accession
);
model
.
addAttribute
(
"auditAccession"
,
auditService
.
auditLogs
(
accession
));
model
.
addAttribute
(
"accessionNames"
,
genesysService
.
listAccessionNames
(
accession
.
getAccessionId
()
));
model
.
addAttribute
(
"accessionAliases"
,
accession
.
getAccessionId
()
.
getAliases
());
model
.
addAttribute
(
"accessionNames"
,
genesysService
.
listAccessionNames
(
accession
Id
));
model
.
addAttribute
(
"accessionAliases"
,
accession
Id
.
getAliases
());
model
.
addAttribute
(
"accessionExchange"
,
accession
);
AccessionCollect
accessionCollect
=
accession
.
getAccessionId
()
.
getColl
();
AccessionCollect
accessionCollect
=
accession
Id
.
getColl
();
model
.
addAttribute
(
"accessionCollect"
,
accessionCollect
);
model
.
addAttribute
(
"accessionBreeding"
,
accession
);
AccessionGeo
accessionGeo
=
accession
.
getAccessionId
()
.
getGeo
();
AccessionGeo
accessionGeo
=
accession
Id
.
getGeo
();
model
.
addAttribute
(
"accessionGeo"
,
accessionGeo
);
if
(
SecurityContextHolder
.
getContext
().
getAuthentication
().
isAuthenticated
())
{
// only for authenticated users
model
.
addAttribute
(
"auditAccession"
,
auditService
.
auditLogs
(
accession
));
model
.
addAttribute
(
"auditAccessionId"
,
auditService
.
auditLogs
(
accessionId
));
model
.
addAttribute
(
"auditAccessionCollect"
,
auditService
.
auditLogs
(
accessionCollect
));
model
.
addAttribute
(
"auditAccessionGeo"
,
auditService
.
auditLogs
(
accessionGeo
));
}
model
.
addAttribute
(
"svalbardDeposits"
,
genesysService
.
getSvalbardData
(
accession
.
getAccessionId
()
));
model
.
addAttribute
(
"accessionRemarks"
,
accession
.
getAccessionId
()
.
getRemarks
());
model
.
addAttribute
(
"svalbardDeposits"
,
genesysService
.
getSvalbardData
(
accession
Id
));
model
.
addAttribute
(
"accessionRemarks"
,
accession
Id
.
getRemarks
());
model
.
addAttribute
(
"metadatas"
,
genesysService
.
listMetadata
(
accession
.
getAccessionId
()
));
model
.
addAttribute
(
"methods"
,
traitService
.
listMethods
(
accession
.
getAccessionId
()
));
model
.
addAttribute
(
"methodValues"
,
genesysService
.
getAccessionTraitValues
(
accession
.
getAccessionId
()
));
model
.
addAttribute
(
"metadatas"
,
genesysService
.
listMetadata
(
accession
Id
));
model
.
addAttribute
(
"methods"
,
traitService
.
listMethods
(
accession
Id
));
model
.
addAttribute
(
"methodValues"
,
genesysService
.
getAccessionTraitValues
(
accession
Id
));
if
(
accession
.
getCrop
()
!=
null
)
{
List
<
Crop
>
crops
=
new
ArrayList
<
Crop
>();
...
...
@@ -184,7 +188,7 @@ public class AccessionController extends BaseController {
}
}
model
.
addAttribute
(
"pdci"
,
accession
.
getAccessionId
()
.
getPdci
());
model
.
addAttribute
(
"pdci"
,
accession
Id
.
getPdci
());
model
.
addAttribute
(
"institutePDCI"
,
statisticsService
.
statisticsPDCI
(
accession
.
getInstitute
()));
ImageGallery
imageGallery
=
null
;
...
...
src/main/java/org/genesys2/server/servlet/controller/RequestController.java
View file @
efccf89d
...
...
@@ -86,7 +86,7 @@ public class RequestController extends BaseController {
model
.
addAttribute
(
"totalCount"
,
selectionBean
.
size
());
model
.
addAttribute
(
"availableCount"
,
genesysService
.
countAvailableForDistribution
(
selectionBean
.
copy
()));
model
.
addAttribute
(
"pagedData"
,
genesysService
.
listAccessions
(
selectionBean
.
copy
(),
new
PageRequest
(
page
-
1
,
50
,
new
Sort
(
"accessionN
ame
"
))));
model
.
addAttribute
(
"pagedData"
,
genesysService
.
listAccessions
(
selectionBean
.
copy
(),
new
PageRequest
(
page
-
1
,
50
,
new
Sort
(
"accessionN
umber
"
))));
return
"/request/index"
;
}
...
...
src/main/java/org/genesys2/server/servlet/controller/SelectionController.java
View file @
efccf89d
...
...
@@ -87,7 +87,7 @@ public class SelectionController extends BaseController {
@RequestMapping
(
value
=
"/"
)
public
String
view
(
ModelMap
model
,
@RequestParam
(
value
=
"page"
,
required
=
false
,
defaultValue
=
"1"
)
int
page
)
{
model
.
addAttribute
(
"pagedData"
,
genesysService
.
listAccessionsDetails
(
selectionBean
.
copy
(),
new
PageRequest
(
page
-
1
,
50
,
new
Sort
(
"accessionN
ame
"
))));
model
.
addAttribute
(
"pagedData"
,
genesysService
.
listAccessionsDetails
(
selectionBean
.
copy
(),
new
PageRequest
(
page
-
1
,
50
,
new
Sort
(
"accessionN
umber
"
))));
model
.
addAttribute
(
"selection"
,
selectionBean
);
// Add userAccessionLists when authenticated
...
...
src/main/java/org/genesys2/server/servlet/controller/rest/AccessionController.java
View file @
efccf89d
...
...
@@ -406,6 +406,8 @@ public class AccessionController extends RestController {
upgradeRename
(
update
,
"acqDate"
,
"acquisitionDate"
);
upgradeRename
(
update
,
"bredCode"
,
"breederCode"
);
upgradeRename
(
update
,
"mlsStat"
,
"mlsStatus"
);
upgradeRename
(
update
,
"orgCty"
,
"origCty"
);
if
(
update
.
has
(
"geo"
))
{
ObjectNode
geo
=
(
ObjectNode
)
update
.
get
(
"geo"
);
...
...
src/main/resources/liquibase/liquibase-changeLog.yml
View file @
efccf89d
...
...
@@ -1292,6 +1292,39 @@ databaseChangeLog: