Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
biopet.biopet
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
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
Mirrors
biopet.biopet
Commits
10c5ff4c
Commit
10c5ff4c
authored
10 years ago
by
Peter van 't Hof
Browse files
Options
Downloads
Patches
Plain Diff
addError instead of throwing an exeption
parent
f8f5f0ad
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/ConfigUtils.scala
+28
-26
28 additions, 26 deletions
...rc/main/scala/nl/lumc/sasc/biopet/utils/ConfigUtils.scala
with
28 additions
and
26 deletions
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/ConfigUtils.scala
+
28
−
26
View file @
10c5ff4c
...
...
@@ -16,6 +16,7 @@
package
nl.lumc.sasc.biopet.utils
import
java.io.File
import
nl.lumc.sasc.biopet.core.BiopetQScript
import
nl.lumc.sasc.biopet.core.Logging
import
nl.lumc.sasc.biopet.core.config.ConfigValue
import
argonaut._
,
Argonaut
.
_
...
...
@@ -330,13 +331,14 @@ object ConfigUtils extends Logging {
trait
ImplicitConversions
{
import
scala.language.implicitConversions
//TODO: unit test on message
private
def
requiredValue
(
value
:
ConfigValue
)
:
Unit
=
{
if
(!
valueExists
(
value
))
throw
new
IllegalStateException
(
"Value does not exist but is required, key: "
+
value
.
requestIndex
.
key
+
private
def
requiredValue
(
value
:
ConfigValue
)
:
Boolean
=
{
val
exist
=
valueExists
(
value
)
if
(!
exist
)
BiopetQScript
.
addError
(
"Value does not exist but is required, key: "
+
value
.
requestIndex
.
key
+
" module: "
+
value
.
requestIndex
.
module
+
(
if
(
value
.
requestIndex
.
path
!=
Nil
)
" path: "
+
value
.
requestIndex
.
path
.
mkString
(
"->"
)
else
""
))
exist
}
private
def
valueExists
(
value
:
ConfigValue
)
:
Boolean
=
{
...
...
@@ -349,8 +351,8 @@ object ConfigUtils extends Logging {
* @return
*/
implicit
def
configValue2file
(
value
:
ConfigValue
)
:
File
=
{
requiredValue
(
value
)
new
File
(
any2string
(
value
.
value
)
)
if
(
requiredValue
(
value
)
)
new
File
(
any2string
(
value
.
value
))
else
new
File
(
""
)
}
/**
...
...
@@ -369,8 +371,8 @@ object ConfigUtils extends Logging {
* @return
*/
implicit
def
configValue2string
(
value
:
ConfigValue
)
:
String
=
{
requiredValue
(
value
)
any2string
(
value
.
value
)
if
(
requiredValue
(
value
)
)
any2string
(
value
.
value
)
else
""
}
/**
...
...
@@ -389,8 +391,8 @@ object ConfigUtils extends Logging {
* @return
*/
implicit
def
configValue2long
(
value
:
ConfigValue
)
:
Long
=
{
requiredValue
(
value
)
any2long
(
value
.
value
)
if
(
requiredValue
(
value
)
)
any2long
(
value
.
value
)
else
0L
}
/**
...
...
@@ -409,8 +411,8 @@ object ConfigUtils extends Logging {
* @return
*/
implicit
def
configValue2int
(
value
:
ConfigValue
)
:
Int
=
{
requiredValue
(
value
)
any2int
(
value
.
value
)
if
(
requiredValue
(
value
)
)
any2int
(
value
.
value
)
else
0
}
/**
...
...
@@ -429,8 +431,8 @@ object ConfigUtils extends Logging {
* @return
*/
implicit
def
configValue2double
(
value
:
ConfigValue
)
:
Double
=
{
requiredValue
(
value
)
any2double
(
value
.
value
)
if
(
requiredValue
(
value
)
)
any2double
(
value
.
value
)
else
0.0
}
/**
...
...
@@ -449,8 +451,8 @@ object ConfigUtils extends Logging {
* @return
*/
implicit
def
configValue2float
(
value
:
ConfigValue
)
:
Float
=
{
requiredValue
(
value
)
any2float
(
value
.
value
)
if
(
requiredValue
(
value
)
)
any2float
(
value
.
value
)
else
0f
}
/**
...
...
@@ -469,8 +471,8 @@ object ConfigUtils extends Logging {
* @return
*/
implicit
def
configValue2boolean
(
value
:
ConfigValue
)
:
Boolean
=
{
requiredValue
(
value
)
any2boolean
(
value
.
value
)
if
(
requiredValue
(
value
)
)
any2boolean
(
value
.
value
)
else
false
}
/**
...
...
@@ -489,8 +491,8 @@ object ConfigUtils extends Logging {
* @return
*/
implicit
def
configValue2list
(
value
:
ConfigValue
)
:
List
[
Any
]
=
{
requiredValue
(
value
)
any2list
(
value
.
value
)
if
(
requiredValue
(
value
)
)
any2list
(
value
.
value
)
else
Nil
}
/**
...
...
@@ -499,8 +501,8 @@ object ConfigUtils extends Logging {
* @return
*/
implicit
def
configValue2stringList
(
value
:
ConfigValue
)
:
List
[
String
]
=
{
requiredValue
(
value
)
any2stringList
(
value
.
value
)
if
(
requiredValue
(
value
)
)
any2stringList
(
value
.
value
)
else
Nil
}
/**
...
...
@@ -509,8 +511,8 @@ object ConfigUtils extends Logging {
* @return
*/
implicit
def
configValue2stringSet
(
value
:
ConfigValue
)
:
Set
[
String
]
=
{
requiredValue
(
value
)
any2stringList
(
value
.
value
).
to
Set
if
(
requiredValue
(
value
)
)
any2stringList
(
value
.
value
).
toSet
else
Set
()
}
/**
...
...
@@ -519,8 +521,8 @@ object ConfigUtils extends Logging {
* @return
*/
implicit
def
configValue2map
(
value
:
ConfigValue
)
:
Map
[
String
,
Any
]
=
{
requiredValue
(
value
)
any2map
(
value
.
value
)
if
(
requiredValue
(
value
)
)
any2map
(
value
.
value
)
else
Map
(
)
}
}
}
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