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
53009221
Commit
53009221
authored
Mar 14, 2014
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GRIN taxonomy model and initial tests
parent
bc1517d2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
487 additions
and
0 deletions
+487
-0
pom.xml
pom.xml
+6
-0
src/main/java/org/genesys2/server/model/VersionedModel.java
src/main/java/org/genesys2/server/model/VersionedModel.java
+36
-0
src/main/java/org/genesys2/server/model/impl/GrinTaxonomy.java
...ain/java/org/genesys2/server/model/impl/GrinTaxonomy.java
+268
-0
src/test/java/org/genesys2/server/test/GRINTaxonomyTest.java
src/test/java/org/genesys2/server/test/GRINTaxonomyTest.java
+177
-0
No files found.
pom.xml
View file @
53009221
...
...
@@ -497,6 +497,12 @@
<artifactId>
spring-data-jpa
</artifactId>
<version>
1.4.4.RELEASE
</version>
</dependency>
<dependency>
<groupId>
org.jamel.dbf
</groupId>
<artifactId>
dbf-reader
</artifactId>
<version>
0.1.0
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
<build>
...
...
src/main/java/org/genesys2/server/model/VersionedModel.java
0 → 100644
View file @
53009221
/**
* Copyright 2014 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.genesys2.server.model
;
import
javax.persistence.MappedSuperclass
;
import
javax.persistence.Version
;
@MappedSuperclass
public
abstract
class
VersionedModel
extends
BusinessModel
{
private
static
final
long
serialVersionUID
=
8415401512360230669L
;
@Version
private
long
version
=
0
;
public
long
getVersion
()
{
return
version
;
}
public
void
setVersion
(
long
version
)
{
this
.
version
=
version
;
}
}
src/main/java/org/genesys2/server/model/impl/GrinTaxonomy.java
0 → 100644
View file @
53009221
/**
* Copyright 2014 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.genesys2.server.model.impl
;
import
java.util.Date
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Temporal
;
import
javax.persistence.TemporalType
;
import
org.genesys2.server.model.VersionedModel
;
/**
* GRIN taxonomy based on "species 2.dbf" from
* http://www.ars-grin.gov/misc/tax/species.zip
*
* @author matijaobreza
*/
@Entity
public
class
GrinTaxonomy
extends
VersionedModel
{
@Column
(
unique
=
true
,
nullable
=
false
)
private
Long
taxno
;
@Column
(
nullable
=
true
)
private
Long
validTaxNo
;
@Column
(
length
=
30
)
private
String
genus
;
private
Character
sHybrid
;
@Column
(
length
=
30
)
private
String
species
;
@Column
(
length
=
100
)
private
String
sAuthor
;
private
Character
sSpHybrid
;
@Column
(
length
=
30
)
private
String
subSp
;
@Column
(
length
=
100
)
private
String
subSpAuthor
;
private
Character
varHybrid
;
@Column
(
length
=
30
)
private
String
var
;
@Column
(
length
=
100
)
private
String
varAuthor
;
private
Character
svHybrid
;
@Column
(
length
=
30
)
private
String
subVar
;
@Column
(
length
=
100
)
private
String
svAuthor
;
private
Character
fHybrid
;
@Column
(
length
=
30
)
private
String
forma
;
@Column
(
length
=
100
)
private
String
fAuthor
;
@Column
(
length
=
240
)
private
String
protologue
;
@Column
(
length
=
254
)
private
String
taxcmt
;
@Temporal
(
TemporalType
.
DATE
)
private
Date
createdDate
;
@Temporal
(
TemporalType
.
DATE
)
private
Date
modifiedDate
;
@Temporal
(
TemporalType
.
DATE
)
private
Date
verifiedDate
;
public
Long
getTaxno
()
{
return
taxno
;
}
public
void
setTaxno
(
Long
taxno
)
{
this
.
taxno
=
taxno
;
}
public
Long
getValidTaxNo
()
{
return
validTaxNo
;
}
public
void
setValidTaxNo
(
Long
validTaxNo
)
{
this
.
validTaxNo
=
validTaxNo
;
}
public
String
getGenus
()
{
return
genus
;
}
public
void
setGenus
(
String
genus
)
{
this
.
genus
=
genus
;
}
public
Character
getsHybrid
()
{
return
sHybrid
;
}
public
void
setsHybrid
(
Character
sHybrid
)
{
this
.
sHybrid
=
sHybrid
;
}
public
String
getSpecies
()
{
return
species
;
}
public
void
setSpecies
(
String
species
)
{
this
.
species
=
species
;
}
public
String
getsAuthor
()
{
return
sAuthor
;
}
public
void
setsAuthor
(
String
sAuthor
)
{
this
.
sAuthor
=
sAuthor
;
}
public
Character
getsSpHybrid
()
{
return
sSpHybrid
;
}
public
void
setsSpHybrid
(
Character
sSpHybrid
)
{
this
.
sSpHybrid
=
sSpHybrid
;
}
public
String
getSubSp
()
{
return
subSp
;
}
public
void
setSubSp
(
String
subSp
)
{
this
.
subSp
=
subSp
;
}
public
String
getSubSpAuthor
()
{
return
subSpAuthor
;
}
public
void
setSubSpAuthor
(
String
subSpAuthor
)
{
this
.
subSpAuthor
=
subSpAuthor
;
}
public
Character
getVarHybrid
()
{
return
varHybrid
;
}
public
void
setVarHybrid
(
Character
varHybrid
)
{
this
.
varHybrid
=
varHybrid
;
}
public
String
getVar
()
{
return
var
;
}
public
void
setVar
(
String
var
)
{
this
.
var
=
var
;
}
public
String
getVarAuthor
()
{
return
varAuthor
;
}
public
void
setVarAuthor
(
String
varAuthor
)
{
this
.
varAuthor
=
varAuthor
;
}
public
Character
getSvHybrid
()
{
return
svHybrid
;
}
public
void
setSvHybrid
(
Character
svHybrid
)
{
this
.
svHybrid
=
svHybrid
;
}
public
String
getSubVar
()
{
return
subVar
;
}
public
void
setSubVar
(
String
subVar
)
{
this
.
subVar
=
subVar
;
}
public
String
getSvAuthor
()
{
return
svAuthor
;
}
public
void
setSvAuthor
(
String
svAuthor
)
{
this
.
svAuthor
=
svAuthor
;
}
public
Character
getfHybrid
()
{
return
fHybrid
;
}
public
void
setfHybrid
(
Character
fHybrid
)
{
this
.
fHybrid
=
fHybrid
;
}
public
String
getForma
()
{
return
forma
;
}
public
void
setForma
(
String
forma
)
{
this
.
forma
=
forma
;
}
public
String
getfAuthor
()
{
return
fAuthor
;
}
public
void
setfAuthor
(
String
fAuthor
)
{
this
.
fAuthor
=
fAuthor
;
}
public
String
getProtologue
()
{
return
protologue
;
}
public
void
setProtologue
(
String
protologue
)
{
this
.
protologue
=
protologue
;
}
public
String
getTaxcmt
()
{
return
taxcmt
;
}
public
void
setTaxcmt
(
String
taxcmt
)
{
this
.
taxcmt
=
taxcmt
;
}
public
Date
getCreatedDate
()
{
return
createdDate
;
}
public
void
setCreatedDate
(
Date
createdDate
)
{
this
.
createdDate
=
createdDate
;
}
public
Date
getModifiedDate
()
{
return
modifiedDate
;
}
public
void
setModifiedDate
(
Date
modifiedDate
)
{
this
.
modifiedDate
=
modifiedDate
;
}
public
Date
getVerifiedDate
()
{
return
verifiedDate
;
}
public
void
setVerifiedDate
(
Date
verifiedDate
)
{
this
.
verifiedDate
=
verifiedDate
;
}
}
src/test/java/org/genesys2/server/test/GRINTaxonomyTest.java
0 → 100644
View file @
53009221
/**
* Copyright 2014 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.genesys2.server.test
;
import
java.io.File
;
import
java.util.Date
;
import
org.jamel.dbf.processor.DbfProcessor
;
import
org.jamel.dbf.processor.DbfRowProcessor
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Value
;
/**
* Test DBF reader of GRIN Taxonomy data from http://www.ars-grin.gov/misc/tax/
*
* @author matijaobreza
*/
@Ignore
public
class
GRINTaxonomyTest
{
@Value
(
"${download.files.dir}"
)
private
String
filesDir
=
"./data"
;
// @Test
public
void
dbInfoTest
()
{
String
dbfInfo
=
DbfProcessor
.
readDbfInfo
(
new
File
(
"genusno.dbf"
));
System
.
out
.
println
(
dbfInfo
);
}
/**
* Common names
*/
// @Test
public
void
testCommon
()
{
File
dbf
=
new
File
(
"common.dbf"
);
String
dbfInfo
=
DbfProcessor
.
readDbfInfo
(
dbf
);
System
.
out
.
println
(
dbfInfo
);
DbfProcessor
.
processDbf
(
dbf
,
new
DbfRowProcessor
()
{
@Override
public
void
processRow
(
Object
[]
row
)
{
System
.
out
.
print
(
new
String
((
byte
[])
row
[
0
]).
trim
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(((
Number
)
row
[
1
]).
longValue
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(
new
String
((
byte
[])
row
[
2
]).
trim
());
System
.
out
.
println
();
}
});
}
@Test
public
void
testSpecies
()
{
File
dbf
=
new
File
(
filesDir
,
"species 2.dbf"
);
String
dbfInfo
=
DbfProcessor
.
readDbfInfo
(
dbf
);
System
.
out
.
println
(
dbfInfo
);
DbfProcessor
.
processDbf
(
dbf
,
new
DbfRowProcessor
()
{
@Override
public
void
processRow
(
Object
[]
row
)
{
// if (! "Zea".equals(new String((byte[]) row[3]).trim())) {
// return;
// }
// if ("".equals(new String((byte[]) row[4]).trim()) ||
// "".equals(new String((byte[]) row[8]).trim()) ) {
// return;
// }
System
.
out
.
print
(((
Number
)
row
[
0
]).
longValue
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(((
Number
)
row
[
1
]).
longValue
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(
new
String
((
byte
[])
row
[
3
]).
trim
());
System
.
out
.
print
(
", 4="
);
System
.
out
.
print
(
new
String
((
byte
[])
row
[
4
]).
trim
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(
new
String
((
byte
[])
row
[
5
]).
trim
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(
new
String
((
byte
[])
row
[
6
]).
trim
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(
new
String
((
byte
[])
row
[
7
]).
trim
());
System
.
out
.
print
(
", SUB >> "
);
System
.
out
.
print
(
new
String
((
byte
[])
row
[
8
]).
trim
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(
new
String
((
byte
[])
row
[
9
]).
trim
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(
new
String
((
byte
[])
row
[
10
]).
trim
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(
new
String
((
byte
[])
row
[
11
]).
trim
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(
new
String
((
byte
[])
row
[
12
]).
trim
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(
new
String
((
byte
[])
row
[
13
]).
trim
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(
new
String
((
byte
[])
row
[
14
]).
trim
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(
new
String
((
byte
[])
row
[
15
]).
trim
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(
new
String
((
byte
[])
row
[
16
]).
trim
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(
new
String
((
byte
[])
row
[
17
]).
trim
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(
new
String
((
byte
[])
row
[
18
]).
trim
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(
new
String
((
byte
[])
row
[
20
]).
trim
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(
new
String
((
byte
[])
row
[
21
]).
trim
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
((
Date
)
row
[
24
]);
System
.
out
.
print
(
", "
);
System
.
out
.
print
((
Date
)
row
[
25
]);
System
.
out
.
println
();
}
});
}
// @Test
public
void
testGenusno
()
{
File
dbf
=
new
File
(
"genusno.dbf"
);
String
dbfInfo
=
DbfProcessor
.
readDbfInfo
(
dbf
);
System
.
out
.
println
(
dbfInfo
);
DbfProcessor
.
processDbf
(
dbf
,
new
DbfRowProcessor
()
{
@Override
public
void
processRow
(
Object
[]
row
)
{
System
.
out
.
print
(
new
String
((
byte
[])
row
[
0
]).
trim
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(
new
String
((
byte
[])
row
[
1
]).
trim
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(((
Number
)
row
[
2
]).
longValue
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(((
Number
)
row
[
3
]).
longValue
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(
new
String
((
byte
[])
row
[
4
]).
trim
());
System
.
out
.
println
();
}
});
}
// @Test
public
void
testTaxonno
()
{
File
dbf
=
new
File
(
"taxonno.dbf"
);
String
dbfInfo
=
DbfProcessor
.
readDbfInfo
(
dbf
);
System
.
out
.
println
(
dbfInfo
);
DbfProcessor
.
processDbf
(
dbf
,
new
DbfRowProcessor
()
{
@Override
public
void
processRow
(
Object
[]
row
)
{
System
.
out
.
print
(
new
String
((
byte
[])
row
[
0
]).
trim
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(
new
String
((
byte
[])
row
[
1
]).
trim
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(((
Number
)
row
[
2
]).
longValue
());
System
.
out
.
print
(
", "
);
System
.
out
.
print
(((
Number
)
row
[
3
]).
longValue
());
System
.
out
.
println
();
}
});
}
}
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