9
9
import org .knime .core .data .DataRow ;
10
10
import org .knime .core .data .DataType ;
11
11
import org .knime .core .node .ExecutionContext ;
12
+ import org .knime .core .node .NodeLogger ;
12
13
import org .knime .scijava .commands .CellOutput ;
13
14
import org .knime .scijava .commands .MultiOutputListener ;
14
15
import org .knime .scijava .commands .converter .KNIMEConverterService ;
16
+ import org .knime .scijava .commands .log .KNIMELogService ;
15
17
import org .scijava .Context ;
18
+ import org .scijava .log .LogService ;
16
19
import org .scijava .module .Module ;
17
20
import org .scijava .module .ModuleInfo ;
18
21
import org .scijava .module .ModuleItem ;
@@ -47,6 +50,8 @@ class DefaultNodeModule implements NodeModule {
47
50
48
51
private final NodeModuleOutputChangedListener outputListener ;
49
52
53
+ private final LogService logService ;
54
+
50
55
/**
51
56
* Constructor.
52
57
*
@@ -60,17 +65,21 @@ class DefaultNodeModule implements NodeModule {
60
65
* mapping of input column index to input items of the module
61
66
* @param outputMapping
62
67
* mapping of output items to types for the cells to for them
68
+ * @param logger
69
+ * NodeLogger to delegate output to.
63
70
*/
64
71
public DefaultNodeModule (final Context context , final ModuleInfo info ,
65
72
final Map <String , Object > params ,
66
73
final Map <Integer , ModuleItem <?>> inputMapping ,
67
- final Map <ModuleItem <?>, DataType > outputMapping ) {
74
+ final Map <ModuleItem <?>, DataType > outputMapping ,
75
+ final NodeLogger logger ) {
68
76
context .inject (this );
69
77
70
78
this .inputMapping = inputMapping ;
71
79
this .outputMapping = outputMapping ;
72
80
this .module = ms .createModule (info );
73
81
this .outputListener = new NodeModuleOutputChangedListener ();
82
+ this .logService = new KNIMELogService (logger );
74
83
75
84
preProcess (params );
76
85
}
@@ -97,11 +106,18 @@ private void preProcess(final Map<String, Object> params) {
97
106
98
107
for (final ModuleItem <?> item : this .module .getInfo ().inputs ()) {
99
108
if (MultiOutputListener .class .equals (item .getType ())) {
109
+ /* MultiOutputListener */
100
110
final String name = item .getName ();
101
111
102
112
module .setInput (name , outputListener );
103
113
module .resolveInput (name );
104
114
outputListener .enableManualPush (true );
115
+ } else if (LogService .class .equals (item .getType ())) {
116
+ /* LogService */
117
+ final String name = item .getName ();
118
+
119
+ module .setInput (name , logService );
120
+ module .resolveInput (name );
105
121
}
106
122
}
107
123
}
@@ -164,8 +180,7 @@ public void notifyListener() {
164
180
output .push (cells .toArray (new DataCell [cells .size ()]));
165
181
}
166
182
} catch (final Exception e ) {
167
- // FIXME
168
- e .printStackTrace ();
183
+ logService .error ("Unable to push output row." , e );
169
184
}
170
185
}
171
186
0 commit comments