Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2XB3FinalProject
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christopher Schankula
2XB3FinalProject
Commits
6c63ed75
Commit
6c63ed75
authored
7 years ago
by
Christopher Schankula
Browse files
Options
Downloads
Patches
Plain Diff
error handling on WormsAPI idToClassification
parent
12dedb8a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/biotree/BioTree.java
+9
-5
9 additions, 5 deletions
src/biotree/BioTree.java
src/biotree/TestBioTree.java
+1
-0
1 addition, 0 deletions
src/biotree/TestBioTree.java
src/biotree/WormsAPI.java
+1
-0
1 addition, 0 deletions
src/biotree/WormsAPI.java
with
11 additions
and
5 deletions
src/biotree/BioTree.java
+
9
−
5
View file @
6c63ed75
...
...
@@ -45,9 +45,10 @@ public class BioTree {
* @param taxonId The taxonId of the possible new entry
* @return taxonId of new species entry
*/
public
static
i
nt
processRecord
(
int
taxonId
)
{
public
static
I
nt
eger
processRecord
(
int
taxonId
)
{
//pass taxonId directly to function to add / increment it
processTaxonId
(
taxonId
);
if
(
processTaxonId
(
taxonId
))
return
null
;
System
.
out
.
println
(
taxonId
);
return
taxonId
;
}
...
...
@@ -59,10 +60,10 @@ public class BioTree {
* @return taxonId of new / existing entry
* @throws IOException
*/
public
static
i
nt
processRecord
(
String
scientificName
)
throws
IOException
{
public
static
I
nt
eger
processRecord
(
String
scientificName
)
throws
IOException
{
//reverse lookup based on name, try adding the found taxonId.
int
taxonId
=
WormsAPI
.
nameToID
(
scientificName
);
processTaxonId
(
taxonId
);
if
(
processTaxonId
(
taxonId
)
)
return
null
;
return
taxonId
;
}
...
...
@@ -70,8 +71,9 @@ public class BioTree {
* Process a new entry if it doesn't exist. If it does exist, increment the number
* of Records for this classification by one.
* @param taxonId New / existing TaxonID to add / increment count thereof.
* @return true if the process failed, false if nothing went wrong
*/
private
static
void
processTaxonId
(
int
taxonId
)
{
private
static
boolean
processTaxonId
(
int
taxonId
)
{
TaxonNode
[]
newNodes
=
null
;
//possible eventual new nodes
TaxonNode
tx
=
nodes
.
get
(
taxonId
);
//search tree to see if the node exists already
if
(
tx
!=
null
)
//if it does exist, increment its count
...
...
@@ -83,6 +85,7 @@ public class BioTree {
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
if
(
newNodes
==
null
)
return
true
;
newNodes
[
newNodes
.
length
-
1
].
incCount
();
//one of the new nodes exists
for
(
int
i
=
newNodes
.
length
-
1
;
i
>=
0
;
i
--)
{
//iterate over all node starting from lowest child
...
...
@@ -102,6 +105,7 @@ public class BioTree {
break
;
}
}
return
false
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
src/biotree/TestBioTree.java
+
1
−
0
View file @
6c63ed75
...
...
@@ -20,6 +20,7 @@ public class TestBioTree {
BioTree
.
processRecord
(
125122
);
BioTree
.
processRecord
(
125392
);
BioTree
.
processRecord
(
125391
);
BioTree
.
processRecord
(
600000000
);
//System.out.println(nodes.size());
//System.out.println(nodes.get(123207));
//Iterable<Integer> keys = nodes.keys();
...
...
This diff is collapsed.
Click to expand it.
src/biotree/WormsAPI.java
+
1
−
0
View file @
6c63ed75
...
...
@@ -79,6 +79,7 @@ public class WormsAPI {
public
static
TaxonNode
[]
idToClassification
(
int
taxonId
)
throws
IOException
,
ParseException
{
String
resp
=
makeRequest
(
String
.
format
(
"http://marinespecies.org/rest/AphiaClassificationByAphiaID/%d"
,
taxonId
));
if
(
resp
.
length
()
==
0
)
return
null
;
JSONParser
parser
=
new
JSONParser
();
JSONObject
json
=
(
JSONObject
)
parser
.
parse
(
resp
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment