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
45
Issues
45
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
2a977f6e
Commit
2a977f6e
authored
Apr 15, 2016
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
opencsv upgraded
parent
6e0bedfd
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
61 additions
and
91 deletions
+61
-91
pom.xml
pom.xml
+5
-5
src/main/java/org/genesys2/server/service/impl/CSVResultSetHelper.java
.../org/genesys2/server/service/impl/CSVResultSetHelper.java
+46
-64
src/main/java/org/genesys2/server/service/impl/GenesysServiceImpl.java
.../org/genesys2/server/service/impl/GenesysServiceImpl.java
+3
-3
src/main/java/org/genesys2/server/service/worker/GeoNamesCountrySource.java
...genesys2/server/service/worker/GeoNamesCountrySource.java
+1
-1
src/main/java/org/genesys2/server/service/worker/ITPGRFAStatusUpdater.java
.../genesys2/server/service/worker/ITPGRFAStatusUpdater.java
+1
-1
src/main/java/org/genesys2/server/service/worker/InstituteUpdater.java
.../org/genesys2/server/service/worker/InstituteUpdater.java
+4
-8
src/main/java/org/genesys2/server/service/worker/SGSVUpdate.java
...n/java/org/genesys2/server/service/worker/SGSVUpdate.java
+1
-9
No files found.
pom.xml
View file @
2a977f6e
...
...
@@ -325,11 +325,6 @@
<scope>
runtime
</scope>
</dependency>
<dependency>
<groupId>
net.sf.opencsv
</groupId>
<artifactId>
opencsv
</artifactId>
<version>
2.3
</version>
</dependency>
<dependency>
<groupId>
org.sitemesh
</groupId>
<artifactId>
sitemesh
</artifactId>
...
...
@@ -502,6 +497,11 @@
<artifactId>
jsoup
</artifactId>
<version>
1.8.2
</version>
</dependency>
<dependency>
<groupId>
com.opencsv
</groupId>
<artifactId>
opencsv
</artifactId>
<version>
3.7
</version>
</dependency>
</dependencies>
<build>
...
...
src/main/java/org/genesys2/server/service/impl/CSVResultSetHelper.java
View file @
2a977f6e
...
...
@@ -2,22 +2,18 @@ package org.genesys2.server.service.impl;
import
java.io.IOException
;
import
java.io.Reader
;
import
java.math.BigDecimal
;
import
java.sql.Clob
;
import
java.sql.ResultSet
;
import
java.sql.ResultSetMetaData
;
import
java.sql.SQLException
;
import
java.sql.Time
;
import
java.sql.Timestamp
;
import
java.sql.Types
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.UUID
;
import
org.genesys2.util.NumberUtils
;
import
au.com.bytecode
.opencsv.ResultSetHelperService
;
import
com
.opencsv.ResultSetHelperService
;
/**
* This class extends {@link ResultSetHelperService} by adding support for UUID.
...
...
@@ -34,56 +30,43 @@ public class CSVResultSetHelper extends ResultSetHelperService {
private
static
final
int
LONGNVARCHAR
=
-
16
;
private
static
final
int
NCLOB
=
2011
;
/// Copied straight from superclass
/**
* Get all the column values from the result set.
*
* @param rs
* - the ResultSet containing the values.
* @param trim
* - values should have white spaces trimmed.
* @param dateFormatString
* - format String for dates.
* @param timeFormatString
* - format String for timestamps.
* @return - String array containing all the column values.
* @throws SQLException
* - thrown by the result set.
* @throws IOException
* - thrown by the result set.
*/
@Override
public
String
[]
getColumnValues
(
ResultSet
rs
)
throws
SQLException
,
IOException
{
public
String
[]
getColumnValues
(
ResultSet
rs
,
boolean
trim
,
String
dateFormatString
,
String
timeFormatString
)
throws
SQLException
,
IOException
{
List
<
String
>
values
=
new
ArrayList
<
String
>();
ResultSetMetaData
metadata
=
rs
.
getMetaData
();
for
(
int
i
=
0
;
i
<
metadata
.
getColumnCount
();
i
++)
{
values
.
add
(
getColumnValue
(
rs
,
metadata
.
getColumnType
(
i
+
1
),
i
+
1
));
values
.
add
(
getColumnValue
(
rs
,
metadata
.
getColumnType
(
i
+
1
),
i
+
1
,
trim
,
dateFormatString
,
timeFormatString
));
}
String
[]
valueArray
=
new
String
[
values
.
size
()];
return
values
.
toArray
(
valueArray
);
}
private
String
handleObject
(
Object
obj
)
{
return
obj
==
null
?
""
:
String
.
valueOf
(
obj
);
}
private
String
handleBigDecimal
(
BigDecimal
decimal
)
{
return
decimal
==
null
?
""
:
decimal
.
toString
();
}
private
String
handleLong
(
ResultSet
rs
,
int
columnIndex
)
throws
SQLException
{
long
lv
=
rs
.
getLong
(
columnIndex
);
return
rs
.
wasNull
()
?
""
:
Long
.
toString
(
lv
);
}
private
String
handleInteger
(
ResultSet
rs
,
int
columnIndex
)
throws
SQLException
{
int
i
=
rs
.
getInt
(
columnIndex
);
return
rs
.
wasNull
()
?
""
:
Integer
.
toString
(
i
);
}
private
String
handleDate
(
ResultSet
rs
,
int
columnIndex
)
throws
SQLException
{
java
.
sql
.
Date
date
=
rs
.
getDate
(
columnIndex
);
String
value
=
null
;
if
(
date
!=
null
)
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"dd-MMM-yyyy"
);
value
=
dateFormat
.
format
(
date
);
}
return
value
;
}
private
String
handleBinary
(
ResultSet
rs
,
int
colIndex
)
throws
SQLException
{
byte
[]
bs
=
rs
.
getBytes
(
colIndex
);
if
(
bs
==
null
)
{
return
null
;
}
if
(
bs
.
length
==
16
)
{
// UUID?
UUID
uuid
=
NumberUtils
.
toUUID
(
bs
);
...
...
@@ -94,16 +77,19 @@ public class CSVResultSetHelper extends ResultSetHelperService {
}
}
private
String
handleTime
(
Time
time
)
{
return
time
==
null
?
null
:
time
.
toString
();
}
private
String
handleTimestamp
(
Timestamp
timestamp
)
{
SimpleDateFormat
timeFormat
=
new
SimpleDateFormat
(
"dd-MMM-yyyy HH:mm:ss"
);
return
timestamp
==
null
?
null
:
timeFormat
.
format
(
timestamp
);
private
static
String
read
(
Clob
c
)
throws
SQLException
,
IOException
{
StringBuilder
sb
=
new
StringBuilder
((
int
)
c
.
length
());
Reader
r
=
c
.
getCharacterStream
();
char
[]
cbuf
=
new
char
[
CLOBBUFFERSIZE
];
int
n
;
while
((
n
=
r
.
read
(
cbuf
,
0
,
cbuf
.
length
))
!=
-
1
)
{
sb
.
append
(
cbuf
,
0
,
n
);
}
return
sb
.
toString
();
}
private
String
getColumnValue
(
ResultSet
rs
,
int
colType
,
int
colIndex
)
throws
SQLException
,
IOException
{
private
String
getColumnValue
(
ResultSet
rs
,
int
colType
,
int
colIndex
,
boolean
trim
,
String
dateFormatString
,
String
timestampFormatString
)
throws
SQLException
,
IOException
{
String
value
=
""
;
...
...
@@ -127,25 +113,29 @@ public class CSVResultSetHelper extends ResultSetHelperService {
value
=
handleLong
(
rs
,
colIndex
);
break
;
case
Types
.
DECIMAL
:
case
Types
.
DOUBLE
:
case
Types
.
FLOAT
:
case
Types
.
REAL
:
case
Types
.
NUMERIC
:
value
=
handleBigDecimal
(
rs
.
getBigDecimal
(
colIndex
));
break
;
case
Types
.
DOUBLE
:
value
=
handleDouble
(
rs
.
getDouble
(
colIndex
));
break
;
case
Types
.
FLOAT
:
value
=
handleFloat
(
rs
.
getFloat
(
colIndex
));
break
;
case
Types
.
INTEGER
:
case
Types
.
TINYINT
:
case
Types
.
SMALLINT
:
value
=
handleInteger
(
rs
,
colIndex
);
break
;
case
Types
.
DATE
:
value
=
handleDate
(
rs
,
colIndex
);
value
=
handleDate
(
rs
,
colIndex
,
dateFormatString
);
break
;
case
Types
.
TIME
:
value
=
handleTime
(
rs
.
getTime
(
colIndex
));
break
;
case
Types
.
TIMESTAMP
:
value
=
handleTimestamp
(
rs
.
getTimestamp
(
colIndex
));
value
=
handleTimestamp
(
rs
.
getTimestamp
(
colIndex
)
,
timestampFormatString
);
break
;
case
NVARCHAR:
// todo : use rs.getNString
case
NCHAR:
// todo : use rs.getNString
...
...
@@ -153,13 +143,17 @@ public class CSVResultSetHelper extends ResultSetHelperService {
case
Types
.
LONGVARCHAR
:
case
Types
.
VARCHAR
:
case
Types
.
CHAR
:
value
=
rs
.
getString
(
colIndex
);
String
columnValue
=
rs
.
getString
(
colIndex
);
if
(
trim
&&
columnValue
!=
null
)
{
value
=
columnValue
.
trim
();
}
else
{
value
=
columnValue
;
}
break
;
case
Types
.
BINARY
:
value
=
handleBinary
(
rs
,
colIndex
);
break
;
default
:
// System.err.println("SQLType not handled " + colType);
value
=
""
;
}
...
...
@@ -168,17 +162,5 @@ public class CSVResultSetHelper extends ResultSetHelperService {
}
return
value
;
}
private
static
String
read
(
Clob
c
)
throws
SQLException
,
IOException
{
StringBuilder
sb
=
new
StringBuilder
((
int
)
c
.
length
());
Reader
r
=
c
.
getCharacterStream
();
char
[]
cbuf
=
new
char
[
CLOBBUFFERSIZE
];
int
n
;
while
((
n
=
r
.
read
(
cbuf
,
0
,
cbuf
.
length
))
!=
-
1
)
{
sb
.
append
(
cbuf
,
0
,
n
);
}
return
sb
.
toString
();
}
}
src/main/java/org/genesys2/server/service/impl/GenesysServiceImpl.java
View file @
2a977f6e
...
...
@@ -119,9 +119,9 @@ import org.springframework.security.acls.domain.BasePermission;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
au.com.bytecode
.opencsv.CSVWriter
;
import
au.com.bytecode
.opencsv.ResultSetHelper
;
import
au.com.bytecode
.opencsv.ResultSetHelperService
;
import
com
.opencsv.CSVWriter
;
import
com
.opencsv.ResultSetHelper
;
import
com
.opencsv.ResultSetHelperService
;
@Service
@Transactional
(
readOnly
=
true
)
...
...
src/main/java/org/genesys2/server/service/worker/GeoNamesCountrySource.java
View file @
2a977f6e
...
...
@@ -37,7 +37,7 @@ import org.apache.http.impl.client.HttpClientBuilder;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
au.com.bytecode
.opencsv.CSVReader
;
import
com
.opencsv.CSVReader
;
/**
* Fetch and parse country information from
...
...
src/main/java/org/genesys2/server/service/worker/ITPGRFAStatusUpdater.java
View file @
2a977f6e
...
...
@@ -43,7 +43,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.core.task.TaskExecutor
;
import
org.springframework.stereotype.Component
;
import
au.com.bytecode
.opencsv.CSVReader
;
import
com
.opencsv.CSVReader
;
/**
* Update country ITPGRFA status by fetching data from
...
...
src/main/java/org/genesys2/server/service/worker/InstituteUpdater.java
View file @
2a977f6e
...
...
@@ -46,7 +46,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.core.task.TaskExecutor
;
import
org.springframework.stereotype.Component
;
import
au.com.bytecode
.opencsv.CSVReader
;
import
com
.opencsv.CSVReader
;
@Component
public
class
InstituteUpdater
{
...
...
@@ -225,12 +225,6 @@ public class InstituteUpdater {
LOG
.
info
(
"Updating FaoInstitutes: "
+
toSave
.
size
());
instituteService
.
update
(
toSave
);
}
// try {
// Thread.sleep(2000);
// } catch (final InterruptedException e) {
// LOG.warn(e.getMessage());
// }
}
private
FaoInstitute
insertData
(
String
[]
line
)
{
...
...
@@ -267,7 +261,9 @@ public class InstituteUpdater {
}
faoInstitute
.
setAcronym
(
acronym
);
faoInstitute
.
setFullName
(
fullName
);
LOG
.
info
(
"Updating: "
+
instCode
+
" "
+
fullName
);
if
(
LOG
.
isTraceEnabled
())
{
LOG
.
trace
(
"Updating: code="
+
instCode
+
" fullname='"
+
fullName
+
"' acronym="
+
acronym
);
}
faoInstitute
.
setPgrActivity
(
pgrActivity
);
faoInstitute
.
setMaintainsCollection
(
maintColl
);
faoInstitute
.
setEmail
(
email
);
...
...
src/main/java/org/genesys2/server/service/worker/SGSVUpdate.java
View file @
2a977f6e
...
...
@@ -38,8 +38,6 @@ import org.genesys2.server.model.genesys.Accession;
import
org.genesys2.server.model.genesys.SvalbardData
;
import
org.genesys2.server.persistence.domain.SvalbardRepository
;
import
org.genesys2.server.service.GenesysService
;
import
org.genesys2.server.service.GeoService
;
import
org.genesys2.server.service.TaxonomyService
;
import
org.hibernate.exception.ConstraintViolationException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.task.TaskExecutor
;
...
...
@@ -47,7 +45,7 @@ import org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureExcep
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.stereotype.Component
;
import
au.com.bytecode
.opencsv.CSVReader
;
import
com
.opencsv.CSVReader
;
@Component
public
class
SGSVUpdate
{
...
...
@@ -71,12 +69,6 @@ public class SGSVUpdate {
@Autowired
private
GenesysService
genesysService
;
@Autowired
private
TaxonomyService
taxonomyService
;
@Autowired
private
GeoService
geoService
;
@Autowired
private
SvalbardRepository
svalbardRepository
;
...
...
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