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
12
Issues
12
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
61d9dfe9
Commit
61d9dfe9
authored
Sep 09, 2016
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Download SGSV file before importing
parent
42ca97b0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
24 deletions
+63
-24
src/main/java/org/genesys2/server/service/worker/SGSVUpdate.java
...n/java/org/genesys2/server/service/worker/SGSVUpdate.java
+17
-6
src/main/webapp/WEB-INF/jsp/accession/details.jsp
src/main/webapp/WEB-INF/jsp/accession/details.jsp
+46
-18
No files found.
src/main/java/org/genesys2/server/service/worker/SGSVUpdate.java
View file @
61d9dfe9
...
...
@@ -16,10 +16,12 @@
package
org.genesys2.server.service.worker
;
import
java.io.BufferedOutputStream
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
...
...
@@ -29,6 +31,7 @@ import java.util.List;
import
java.util.stream.Collectors
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang.ArrayUtils
;
import
org.apache.commons.lang.StringUtils
;
...
...
@@ -51,6 +54,7 @@ import org.springframework.dao.CannotAcquireLockException;
import
org.springframework.orm.ObjectOptimisticLockingFailureException
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.StreamUtils
;
import
com.opencsv.CSVReader
;
...
...
@@ -69,10 +73,10 @@ public class SGSVUpdate {
private
static
final
String
SGSV_DOWNLOAD_URL
=
"http://www.nordgen.org/sgsv/download.php?file=/scope/sgsv/files/sgsv_templates.tab"
;
static
final
String
[]
SGSV_HEADERS
=
{
"sgsv_id"
,
"institute_code"
,
"deposit_box_number"
,
"collection_name"
,
"accession_number"
,
"full_scientific_name"
,
"country_of_collection_or_source"
,
"
number_of_seeds"
,
"regeneration_month_and_year"
,
"other_accession_designations"
,
"provider_institute_code"
,
"accession_url"
,
"country_code"
,
"country_name"
,
"continent_name"
,
"seeds
"
,
"
genus"
,
"species_epithet"
,
"species"
,
"taxon_name"
,
"date_of_deposit"
,
"date_of_dataset"
,
"sgsv_template_id"
,
"box_id"
,
"sgsv_taxon_id"
,
"taxon_authority"
,
"infraspesific_epith
et"
,
"vernacular_name"
,
"itis_tsn"
,
"sgsv_genus_id"
,
"accession_name"
};
static
final
String
[]
SGSV_HEADERS
=
{
"sgsv_id"
,
"institute_code"
,
"deposit_box_number"
,
"collection_name"
,
"accession_number"
,
"full_scientific_name"
,
"
country_of_collection_or_source"
,
"number_of_seeds"
,
"regeneration_month_and_year"
,
"other_accession_designations"
,
"provider_institute_code"
,
"accession_url
"
,
"
country_code"
,
"country_name"
,
"continent_name"
,
"seeds"
,
"genus"
,
"species_epithet"
,
"species"
,
"taxon_name"
,
"date_of_deposit"
,
"date_of_datas
et"
,
"
sgsv_template_id"
,
"box_id"
,
"sgsv_taxon_id"
,
"taxon_authority"
,
"infraspesific_epithet"
,
"
vernacular_name"
,
"itis_tsn"
,
"sgsv_genus_id"
,
"accession_name"
};
private
static
final
DateTimeFormatter
SGSV_DATE_FORMAT
=
DateTimeFormat
.
forPattern
(
"yyyy-MM-dd"
);
...
...
@@ -107,8 +111,10 @@ public class SGSVUpdate {
final
HttpGet
httpget
=
new
HttpGet
(
SGSV_DOWNLOAD_URL
);
HttpResponse
response
=
null
;
File
tempFile
=
null
;
final
CloseableHttpClient
httpclient
=
HttpClientBuilder
.
create
().
build
();
try
{
tempFile
=
File
.
createTempFile
(
"sgsv"
,
".csv"
);
response
=
httpclient
.
execute
(
httpget
);
LOG
.
debug
(
response
.
getStatusLine
());
...
...
@@ -121,12 +127,17 @@ public class SGSVUpdate {
}
LOG
.
debug
(
entity
.
getContentType
()
+
" "
+
entity
.
getContentLength
());
LOG
.
warn
(
"Downloading SGSV data to "
+
tempFile
.
getAbsolutePath
());
StreamUtils
.
copy
(
entity
.
getContent
(),
new
BufferedOutputStream
(
new
FileOutputStream
(
tempFile
)));
LOG
.
warn
(
"Data download completed to "
+
tempFile
.
getAbsolutePath
());
importSGSVStream
(
entity
.
getContent
());
IOUtils
.
closeQuietly
(
httpclient
);
importSGSVStream
(
new
FileInputStream
(
tempFile
));
}
catch
(
final
Throwable
e
)
{
LOG
.
error
(
e
,
e
);
LOG
.
error
(
"SGSV import failed to complete."
,
e
);
}
finally
{
IOUtils
.
closeQuietly
(
httpclient
);
FileUtils
.
deleteQuietly
(
tempFile
);
}
}
...
...
src/main/webapp/WEB-INF/jsp/accession/details.jsp
View file @
61d9dfe9
...
...
@@ -803,41 +803,69 @@
</h4>
<c:forEach
items=
"
${
svalbardDeposits
}
"
var=
"svalbardData"
>
<div
class=
"section-inner-content clearfix"
>
<
c:if
test=
"
${
svalbardData
.
id
ne
null
}
"
>
<div
class=
"
row
"
>
<
div
class=
"col-lg-6 col-md-6 col-sm-6 col-xs-12"
>
<
div
class=
"row
"
>
<div
class=
"
col-lg-6 col-md-6 col-sm-6 col-xs-12
"
>
<
p
>
<spring:message
code=
"accession.svalbard-data.url"
/>
</div>
<div
class=
"col-lg-6 col-md-6 col-sm-6 col-xs-12"
>
<a
target=
"_blank"
title=
"
<spring:message
code=
"accession.svalbard-data.url-title"
/>
"
href=
"
<c:url
value=
"http://www.nordgen.org/sgsv/index.php?app=data_unit&unit=sgsv&unit_id=${svalbardData.id}"
/>
"
><spring:message
code=
"accession.svalbard-data.url-text"
arguments=
"
${
accession
.
accessionName
}
"
/></a>
</div>
</p>
</div>
</c:if>
<div
class=
"col-lg-6 col-md-6 col-sm-6 col-xs-12"
>
<p>
<a
target=
"_blank"
title=
"
<spring:message
code=
"accession.svalbard-data.url-title"
/>
"
href=
"
<c:url
value=
"http://www.nordgen.org/sgsv/index.php?app=data_unit&unit=sgsv&unit_id=${svalbardData.id}"
/>
"
>
<spring:message
code=
"accession.svalbard-data.url-text"
arguments=
"
${
svalbardData
.
acceNumb
}
"
/>
</a>
</p>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-lg-6 col-md-6 col-sm-6 col-xs-12"
>
<spring:message
code=
"accession.svalbard-data.depositDate"
/>
<p>
<spring:message
code=
"accession.svalbard-data.depositDate"
/>
</p>
</div>
<div
class=
"col-lg-6 col-md-6 col-sm-6 col-xs-12"
>
<p>
<c:out
value=
"
${
svalbardData
.
depositDate
}
"
/>
</p>
</div>
<div
class=
"col-lg-6 col-md-6 col-sm-6 col-xs-12"
><c:out
value=
"
${
svalbardData
.
depositDate
}
"
/></div>
</div>
<div
class=
"row"
>
<div
class=
"col-lg-6 col-md-6 col-sm-6 col-xs-12"
>
<spring:message
code=
"accession.svalbard-data.regenerationInformation"
/>
<p>
<spring:message
code=
"accession.svalbard-data.regenerationInformation"
/>
</p>
</div>
<div
class=
"col-lg-6 col-md-6 col-sm-6 col-xs-12"
>
<p>
<c:out
value=
"
${
svalbardData
.
regenerationInformation
}
"
/>
</p>
</div>
<div
class=
"col-lg-6 col-md-6 col-sm-6 col-xs-12"
><c:out
value=
"
${
svalbardData
.
regenerationInformation
}
"
/></div>
</div>
<div
class=
"row"
>
<div
class=
"col-lg-6 col-md-6 col-sm-6 col-xs-12"
>
<spring:message
code=
"accession.svalbard-data.boxNumber"
/>
<p>
<spring:message
code=
"accession.svalbard-data.boxNumber"
/>
</p>
</div>
<div
class=
"col-lg-6 col-md-6 col-sm-6 col-xs-12"
>
<p>
<c:out
value=
"
${
svalbardData
.
boxNumber
}
"
/>
</p>
</div>
<div
class=
"col-lg-6 col-md-6 col-sm-6 col-xs-12"
><c:out
value=
"
${
svalbardData
.
boxNumber
}
"
/></div>
</div>
<div
class=
"row"
>
<div
class=
"col-lg-6 col-md-6 col-sm-6 col-xs-12"
>
<spring:message
code=
"accession.svalbard-data.quantity"
/>
<p>
<spring:message
code=
"accession.svalbard-data.quantity"
/>
<p>
</div>
<div
class=
"col-lg-6 col-md-6 col-sm-6 col-xs-12"
>
<p>
<c:out
value=
"
${
svalbardData
.
quantity
}
"
/>
</p>
</div>
<div
class=
"col-lg-6 col-md-6 col-sm-6 col-xs-12"
><c:out
value=
"
${
svalbardData
.
quantity
}
"
/></div>
</div>
</div>
</c:forEach>
...
...
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