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
validator.genesys-pgr.org
Commits
021592d3
Commit
021592d3
authored
Aug 24, 2020
by
Matija Obreza
Browse files
Updates for taxonomy-tools compatibility
parent
8fd2c025
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/genesys/taxonomy/checker/web/config/ApplicationConfig.java
View file @
021592d3
...
...
@@ -28,11 +28,11 @@ import org.genesys.geotools.service.CountryOfOriginService;
import
org.genesys.geotools.service.LandOrSeaService
;
import
org.genesys.geotools.service.impl.CountryOfOriginServiceImpl
;
import
org.genesys.geotools.service.impl.LandOrSeaServiceImpl
;
import
org.genesys.taxonomy.checker.CachingInMemoryTaxonomyDatabase
;
import
org.genesys.taxonomy.checker.InMemoryTaxonomyDatabase
;
import
org.genesys.taxonomy.checker.TaxonomyChecker
;
import
org.genesys.taxonomy.checker.TaxonomyException
;
import
org.genesys.taxonomy.checker.web.service.ProcessService
;
import
org.genesys.taxonomy.checker.web.service.impl.CachingInMemoryTaxonomyDatabase
;
import
org.genesys.taxonomy.checker.web.service.impl.CountryProcessServiceImpl
;
import
org.genesys.taxonomy.checker.web.service.impl.LandOrSeaProcessServiceImpl
;
import
org.genesys.taxonomy.checker.web.service.impl.ProcessServiceImpl
;
...
...
src/main/java/org/genesys/taxonomy/checker/web/service/impl/CachingInMemoryTaxonomyDatabase.java
deleted
100644 → 0
View file @
8fd2c025
/*
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.genesys.taxonomy.checker.web.service.impl
;
import
java.util.List
;
import
java.util.concurrent.ExecutionException
;
import
org.genesys.taxonomy.checker.InMemoryTaxonomyDatabase
;
import
org.genesys.taxonomy.gringlobal.model.SpeciesRow
;
import
com.google.common.cache.Cache
;
import
com.google.common.cache.CacheBuilder
;
/**
* Guava cache supported in-memory taxonomy database.
*/
public
class
CachingInMemoryTaxonomyDatabase
extends
InMemoryTaxonomyDatabase
{
// private final static Logger LOG =
// LoggerFactory.getLogger(CachingInMemoryTaxonomyDatabase.class);
/** The cache genus species. */
private
final
Cache
<
String
,
List
<
SpeciesRow
>>
cacheGenusSpecies
=
CacheBuilder
.
newBuilder
().
maximumSize
(
100
).
build
();
/** The cache genus suggestions. */
private
final
Cache
<
String
,
List
<
String
>>
cacheGenusSuggestions
=
CacheBuilder
.
newBuilder
().
maximumSize
(
100
).
build
();
/** The cache species suggestions. */
private
final
Cache
<
String
,
List
<
String
>>
cacheSpeciesSuggestions
=
CacheBuilder
.
newBuilder
().
maximumSize
(
100
).
build
();
/**
* Gets the all genus species.
*
* @param genus the genus
* @return the all genus species
*/
/*
* (non-Javadoc)
* @see
* org.genesys.taxonomy.checker.InMemoryTaxonomyDatabase#getAllGenusSpecies(java
* .lang.String)
*/
@Override
protected
List
<
SpeciesRow
>
getAllGenusSpecies
(
final
String
genus
)
{
try
{
return
cacheGenusSpecies
.
get
(
genus
,
()
->
CachingInMemoryTaxonomyDatabase
.
super
.
getAllGenusSpecies
(
genus
));
}
catch
(
final
ExecutionException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
/**
* Find similar genus.
*
* @param genus the genus
* @param maxSize the max size
* @return the list
*/
/*
* (non-Javadoc)
* @see
* org.genesys.taxonomy.checker.InMemoryTaxonomyDatabase#findSimilarGenus(java.
* lang.String, int)
*/
@Override
public
List
<
String
>
findSimilarGenus
(
final
String
genus
,
final
int
maxSize
)
{
try
{
return
cacheGenusSuggestions
.
get
(
genus
+
"-"
+
maxSize
,
()
->
CachingInMemoryTaxonomyDatabase
.
super
.
findSimilarGenus
(
genus
,
maxSize
));
}
catch
(
final
ExecutionException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
/**
* Find similar species.
*
* @param genus the genus
* @param species the species
* @param maxSize the max size
* @return the list
*/
/*
* (non-Javadoc)
* @see
* org.genesys.taxonomy.checker.InMemoryTaxonomyDatabase#findSimilarSpecies(java
* .lang.String, java.lang.String, int)
*/
@Override
public
List
<
String
>
findSimilarSpecies
(
final
String
genus
,
final
String
species
,
final
int
maxSize
)
{
try
{
return
cacheSpeciesSuggestions
.
get
(
genus
+
"-"
+
species
+
"-"
+
maxSize
,
()
->
CachingInMemoryTaxonomyDatabase
.
super
.
findSimilarSpecies
(
genus
,
species
,
maxSize
));
}
catch
(
final
ExecutionException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
src/main/java/org/genesys/taxonomy/checker/web/service/impl/TaxonomyProcessServiceImpl.java
View file @
021592d3
...
...
@@ -40,6 +40,7 @@ import org.genesys.taxonomy.checker.web.service.ProcessService;
import
org.genesys.taxonomy.checker.web.util.ApplicationUtils
;
import
org.genesys.taxonomy.gringlobal.component.CabReader
;
import
org.genesys.taxonomy.gringlobal.model.GenusRow
;
import
org.genesys.taxonomy.gringlobal.model.IGrinSpecies
;
import
org.genesys.taxonomy.gringlobal.model.SpeciesRow
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -326,14 +327,14 @@ public class TaxonomyProcessServiceImpl implements ProcessService {
}
if
(
outputHeaders
.
indexOf
(
ApplicationUtils
.
HEADER_GRINTAX_SPECIESID
)
>=
0
)
{
final
List
<
Species
Row
>
speciesRows
=
taxonomyDatabase
.
findSpeciesRow
(
genus
,
species
,
StringUtils
.
defaultIfBlank
(
subtaxa
,
null
));
final
List
<
IGrin
Species
>
speciesRows
=
taxonomyDatabase
.
findSpeciesRow
(
genus
,
species
,
StringUtils
.
defaultIfBlank
(
subtaxa
,
null
));
if
(
speciesRows
.
size
()
==
1
)
{
final
Species
Row
speciesRow
=
speciesRows
.
get
(
0
);
final
IGrin
Species
speciesRow
=
speciesRows
.
get
(
0
);
outputLine
[
outputHeaders
.
indexOf
(
ApplicationUtils
.
HEADER_GRINTAX_SPECIESID
)]
=
speciesRow
.
getSpeciesId
().
toString
();
outputLine
[
outputHeaders
.
indexOf
(
ApplicationUtils
.
HEADER_GRINTAX_SPECIESCURRENT
)]
=
Boolean
.
toString
(
speciesRow
.
isCurrent
());
if
(!
speciesRow
.
isCurrent
()
&&
toCurrentTaxa
)
{
LOG
.
debug
(
"{} is not current"
,
speciesRow
);
final
Species
Row
currentSpecies
=
taxonomyDatabase
.
getSpeciesRow
(
speciesRow
.
getCurrentTaxonomySpeciesId
());
final
IGrin
Species
currentSpecies
=
taxonomyDatabase
.
getSpeciesRow
(
speciesRow
.
getCurrentTaxonomySpeciesId
());
final
String
currentGenus
=
taxonomyDatabase
.
getGenus
(
currentSpecies
.
getGenusId
());
// LOG.warn("Result: {}", Arrays.toString(outputLine));
updateOutputColumn
(
outputLine
,
outputHeaders
.
indexOf
(
ApplicationUtils
.
HEADER_GENUS_CHECK
),
currentGenus
,
genus
,
ApplicationUtils
.
CURRENT_SUFFIX
);
...
...
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