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
TULIP-CPS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
NUI
TULIP-CPS
Commits
05795c44
Commit
05795c44
authored
Apr 04, 2017
by
Nico Mack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed logging
parent
39819854
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
48 deletions
+72
-48
CPS/src/lu/list/itis/dkd/tui/cps/system/executor/JavascriptExecutor.java
.../itis/dkd/tui/cps/system/executor/JavascriptExecutor.java
+9
-9
CPS/src/lu/list/itis/dkd/tui/cps/system/executor/OctaveExecutor.java
...list/itis/dkd/tui/cps/system/executor/OctaveExecutor.java
+9
-9
CPS/src/lu/list/itis/dkd/tui/cps/system/executor/PythonExecutor.java
...list/itis/dkd/tui/cps/system/executor/PythonExecutor.java
+40
-21
CPS/src/lu/list/itis/dkd/tui/cps/system/executor/SqlExecutor.java
...lu/list/itis/dkd/tui/cps/system/executor/SqlExecutor.java
+7
-9
CPS/src/lu/list/itis/dkd/tui/cps/variable/VectorVariable.java
...src/lu/list/itis/dkd/tui/cps/variable/VectorVariable.java
+7
-0
No files found.
CPS/src/lu/list/itis/dkd/tui/cps/system/executor/JavascriptExecutor.java
View file @
05795c44
...
...
@@ -28,10 +28,10 @@ public class JavascriptExecutor extends Executor {
}
@Override
public
void
set
(
Variable
variable
)
{
public
void
set
(
Variable
<?>
variable
)
{
engine
.
put
(
variable
.
getName
(),
variable
.
getValue
());
if
(
LOGGER
.
is
Trace
Enabled
())
{
LOGGER
.
trace
(
"Parameter {} = {}"
,
variable
.
getName
(),
variable
.
getValue
());
//$NON-NLS-1$
if
(
LOGGER
.
is
Info
Enabled
())
{
LOGGER
.
info
(
"Parameter {} = {}"
,
variable
.
getName
(),
variable
.
getValue
());
//$NON-NLS-1$
}
}
...
...
@@ -41,8 +41,8 @@ public class JavascriptExecutor extends Executor {
long
elapsed
=
System
.
currentTimeMillis
();
result
=
engine
.
eval
(
script
);
elapsed
=
System
.
currentTimeMillis
()
-
elapsed
;
if
(
LOGGER
.
is
Trace
Enabled
())
{
LOGGER
.
trace
(
"Eval => {} | took {} ms!"
,
script
,
elapsed
);
//$NON-NLS-1$
if
(
LOGGER
.
is
Info
Enabled
())
{
LOGGER
.
info
(
"Eval => {} | took {} ms!"
,
script
,
elapsed
);
//$NON-NLS-1$
}
}
catch
(
ScriptException
exception
)
{
this
.
executionErrors
.
append
(
exception
.
toString
());
...
...
@@ -54,10 +54,10 @@ public class JavascriptExecutor extends Executor {
}
@Override
public
Variable
get
(
Variable
variable
)
{
variable
.
setValue
(
result
);
if
(
LOGGER
.
is
Trace
Enabled
())
{
LOGGER
.
trace
(
"Result {} = {}"
,
variable
.
getName
(),
result
);
//$NON-NLS-1$
public
Variable
<?>
get
(
Variable
<?>
variable
)
{
variable
.
setValue
FromObject
(
result
);
if
(
LOGGER
.
is
Info
Enabled
())
{
LOGGER
.
info
(
"Result {} = {}"
,
variable
.
getName
(),
result
);
//$NON-NLS-1$
}
return
variable
;
}
...
...
CPS/src/lu/list/itis/dkd/tui/cps/system/executor/OctaveExecutor.java
View file @
05795c44
...
...
@@ -44,11 +44,11 @@ public class OctaveExecutor extends Executor {
}
@Override
public
void
set
(
Variable
variable
)
{
public
void
set
(
Variable
<?>
variable
)
{
Double
numericValue
=
Double
.
valueOf
(
variable
.
getValue
().
toString
());
engine
.
put
(
variable
.
getName
(),
Octave
.
scalar
(
numericValue
));
if
(
LOGGER
.
is
Trace
Enabled
())
{
LOGGER
.
trace
(
"Parameter {} = {}"
,
variable
.
getName
(),
variable
.
getValue
());
//$NON-NLS-1$
if
(
LOGGER
.
is
Info
Enabled
())
{
LOGGER
.
info
(
"Parameter {} = {}"
,
variable
.
getName
(),
variable
.
getValue
());
//$NON-NLS-1$
}
}
...
...
@@ -57,18 +57,18 @@ public class OctaveExecutor extends Executor {
long
elapsed
=
System
.
currentTimeMillis
();
engine
.
eval
(
script
);
elapsed
=
System
.
currentTimeMillis
()
-
elapsed
;
if
(
LOGGER
.
is
Trace
Enabled
())
{
LOGGER
.
trace
(
"Eval => {} | took {} ms!"
,
script
,
elapsed
);
//$NON-NLS-1$
if
(
LOGGER
.
is
Info
Enabled
())
{
LOGGER
.
info
(
"Eval => {} | took {} ms!"
,
script
,
elapsed
);
//$NON-NLS-1$
}
return
true
;
}
@Override
public
Variable
get
(
Variable
variable
)
{
public
Variable
<?>
get
(
Variable
<?>
variable
)
{
OctaveDouble
result
=
engine
.
get
(
OctaveDouble
.
class
,
variable
.
getName
());
variable
.
setValue
(
result
.
get
(
1
));
if
(
LOGGER
.
is
Trace
Enabled
())
{
LOGGER
.
trace
(
"Result {} = {}"
,
variable
.
getName
(),
result
.
get
(
1
));
//$NON-NLS-1$
variable
.
setValue
FromObject
(
result
.
get
(
1
));
if
(
LOGGER
.
is
Info
Enabled
())
{
LOGGER
.
info
(
"Result {} = {}"
,
variable
.
getName
(),
result
.
get
(
1
));
//$NON-NLS-1$
}
return
variable
;
...
...
CPS/src/lu/list/itis/dkd/tui/cps/system/executor/PythonExecutor.java
View file @
05795c44
...
...
@@ -6,6 +6,7 @@ import lu.list.itis.dkd.tui.cps.variable.VectorVariable;
import
org.python.core.PyArray
;
import
org.python.core.PyFloat
;
import
org.python.core.PyInteger
;
import
org.python.core.PyObject
;
import
org.python.core.PyTuple
;
import
org.python.util.PythonInterpreter
;
...
...
@@ -51,27 +52,45 @@ public class PythonExecutor extends Executor {
@Override
public
void
set
(
Variable
<?>
variable
)
{
if
(
variable
instanceof
VectorVariable
)
{
VectorVariable
<
Double
>
vector
=
(
VectorVariable
<
Double
>)
variable
;
List
<
Double
>
list
=
vector
.
getValue
();
if
(!
list
.
isEmpty
())
{
PyArray
array
=
new
PyArray
(
Double
.
class
,
list
.
size
());
int
index
=
0
;
for
(
Double
value
:
list
)
{
if
(
value
==
null
)
value
=
Double
.
valueOf
(
0
);
array
.
set
(
index
++,
new
PyFloat
(
value
));
}
engine
.
set
(
variable
.
getName
(),
array
);
if
(
LOGGER
.
isTraceEnabled
())
{
LOGGER
.
trace
(
"Parameter -> {} = {}"
,
variable
.
getName
(),
list
.
toString
());
//$NON-NLS-1$
VectorVariable
<?>
vector
=
(
VectorVariable
<
Double
>)
variable
;
if
(!
vector
.
isEmpty
())
{
PyArray
array
=
null
;
if
(
Double
.
class
.
isAssignableFrom
(
vector
.
getClassOfValues
()))
{
List
<
Double
>
list
=
(
List
<
Double
>)
vector
.
getValue
();
array
=
new
PyArray
(
Double
.
class
,
list
.
size
());
int
index
=
0
;
for
(
Double
value
:
list
)
{
if
(
value
==
null
)
value
=
Double
.
valueOf
(
0
);
array
.
set
(
index
++,
new
PyFloat
(
value
));
}
engine
.
set
(
variable
.
getName
(),
array
);
if
(
LOGGER
.
isInfoEnabled
())
{
LOGGER
.
info
(
"Parameter -> {} = {}"
,
variable
.
getName
(),
list
.
toString
());
//$NON-NLS-1$
}
}
else
if
(
Integer
.
class
.
isAssignableFrom
(
vector
.
getClassOfValues
()))
{
List
<
Integer
>
list
=
(
List
<
Integer
>)
vector
.
getValue
();
array
=
new
PyArray
(
Integer
.
class
,
list
.
size
());
int
index
=
0
;
for
(
Integer
value
:
list
)
{
if
(
value
==
null
)
value
=
Integer
.
valueOf
(
0
);
array
.
set
(
index
++,
new
PyInteger
(
value
));
}
engine
.
set
(
variable
.
getName
(),
array
);
if
(
LOGGER
.
isInfoEnabled
())
{
LOGGER
.
info
(
"Parameter -> {} = {}"
,
variable
.
getName
(),
list
.
toString
());
//$NON-NLS-1$
}
}
}
}
else
{
Double
numericValue
=
Double
.
valueOf
(
variable
.
getValue
().
toString
());
engine
.
set
(
variable
.
getName
(),
new
PyFloat
(
numericValue
));
if
(
LOGGER
.
is
Trace
Enabled
())
{
LOGGER
.
trace
(
"Parameter -> {} = {}"
,
variable
.
getName
(),
variable
.
getValue
());
//$NON-NLS-1$
if
(
LOGGER
.
is
Info
Enabled
())
{
LOGGER
.
info
(
"Parameter -> {} = {}"
,
variable
.
getName
(),
variable
.
getValue
());
//$NON-NLS-1$
}
}
}
...
...
@@ -81,8 +100,8 @@ public class PythonExecutor extends Executor {
long
elapsed
=
System
.
currentTimeMillis
();
engine
.
exec
(
script
);
elapsed
=
System
.
currentTimeMillis
()
-
elapsed
;
if
(
LOGGER
.
is
Trace
Enabled
())
{
LOGGER
.
trace
(
"Eval took {} ms | {}"
,
elapsed
,
script
);
//$NON-NLS-1$
if
(
LOGGER
.
is
Info
Enabled
())
{
LOGGER
.
info
(
"Eval took {} ms | {}"
,
elapsed
,
script
);
//$NON-NLS-1$
}
return
true
;
}
...
...
@@ -96,14 +115,14 @@ public class PythonExecutor extends Executor {
if
(
tupleMatcher
.
matches
())
{
PyTuple
tuple
=
(
PyTuple
)
engine
.
get
(
tupleMatcher
.
group
(
1
));
result
=
tuple
.
__getattr__
(
tupleMatcher
.
group
(
2
));
if
(
LOGGER
.
is
Trace
Enabled
())
{
LOGGER
.
trace
(
"Result <- {} = {}.{} = {}"
,
variable
.
getName
(),
tupleMatcher
.
group
(
1
),
tupleMatcher
.
group
(
2
),
result
);
//$NON-NLS-1$
if
(
LOGGER
.
is
Info
Enabled
())
{
LOGGER
.
info
(
"Result <- {} = {}.{} = {}"
,
variable
.
getName
(),
tupleMatcher
.
group
(
1
),
tupleMatcher
.
group
(
2
),
result
);
//$NON-NLS-1$
}
}
}
else
{
result
=
engine
.
get
(
variable
.
getName
());
if
(
LOGGER
.
is
Trace
Enabled
())
{
LOGGER
.
trace
(
"Result <- {} = {}"
,
variable
.
getName
(),
result
);
//$NON-NLS-1$
if
(
LOGGER
.
is
Info
Enabled
())
{
LOGGER
.
info
(
"Result <- {} = {}"
,
variable
.
getName
(),
result
);
//$NON-NLS-1$
}
}
...
...
CPS/src/lu/list/itis/dkd/tui/cps/system/executor/SqlExecutor.java
View file @
05795c44
...
...
@@ -291,8 +291,8 @@ public class SqlExecutor extends Executor {
@Override
public
void
set
(
Variable
<?>
variable
)
{
parameters
.
put
(
variable
.
getName
(),
variable
.
getValue
());
if
(
LOGGER
.
is
Trace
Enabled
())
{
LOGGER
.
trace
(
"Parameter -> {} = {}"
,
variable
.
getName
(),
variable
.
getValue
());
//$NON-NLS-1$
if
(
LOGGER
.
is
Info
Enabled
())
{
LOGGER
.
info
(
"Parameter -> {} = {}"
,
variable
.
getName
(),
variable
.
getValue
());
//$NON-NLS-1$
}
}
...
...
@@ -319,8 +319,8 @@ public class SqlExecutor extends Executor {
columnTypes
=
this
.
getColumnTypes
(
rows
);
columnValues
=
this
.
convertResults
(
rows
);
elapsed
=
System
.
currentTimeMillis
()
-
elapsed
;
if
(
LOGGER
.
is
Trace
Enabled
())
{
LOGGER
.
trace
(
"Eval took {} ms | {}"
,
elapsed
,
script
);
//$NON-NLS-1$
if
(
LOGGER
.
is
Info
Enabled
())
{
LOGGER
.
info
(
"Eval took {} ms | {}"
,
elapsed
,
script
);
//$NON-NLS-1$
}
}
catch
(
SQLException
e
)
{
...
...
@@ -388,14 +388,12 @@ public class SqlExecutor extends Executor {
Object
[]
values
=
columnValues
.
get
(
0
);
variable
.
setValueFromObject
(
values
[
index
]);
}
else
{
if
(
LOGGER
.
isTraceEnabled
())
{
LOGGER
.
trace
(
"Query returned no results!"
);
//$NON-NLS-1$
}
LOGGER
.
info
(
"Query returned no results!"
);
//$NON-NLS-1$
}
}
}
if
(
LOGGER
.
is
Trace
Enabled
())
{
LOGGER
.
trace
(
"Result <- {} = {}"
,
variable
.
getName
(),
variable
.
getValue
());
//$NON-NLS-1$
if
(
LOGGER
.
is
Info
Enabled
())
{
LOGGER
.
info
(
"Result <- {} = {}"
,
variable
.
getName
(),
variable
.
getValue
());
//$NON-NLS-1$
}
return
variable
;
...
...
CPS/src/lu/list/itis/dkd/tui/cps/variable/VectorVariable.java
View file @
05795c44
...
...
@@ -35,6 +35,13 @@ public class VectorVariable<B> extends Variable<List<B>> implements Collection<B
value
=
new
ArrayList
<
B
>();
}
public
Class
<?>
getClassOfValues
()
{
if
(!
value
.
isEmpty
())
{
return
value
.
get
(
0
).
getClass
();
}
return
value
.
getClass
();
}
/** {@inheritDoc} */
@Override
public
List
<
B
>
getValue
()
{
...
...
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