Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Refactoring and cleanup #49

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f5e223a
Refactor scijava integration
dietzc Aug 29, 2016
ff8a056
Add javadoc to everything and cleanup.
Squareys Sep 12, 2016
82eeeac
Rename ConverterCacheService to KNIMEConverterService
Squareys Sep 12, 2016
3fbb32d
Avoid deprecated setResolved method
Squareys Sep 12, 2016
f23b70d
Always use NodeModuleOutputChangedListener, even for single row outputs
Squareys Sep 12, 2016
b3c4f7a
Pre is never null
Squareys Sep 12, 2016
215d97f
Fix MultiOutputListener @Parameters not being marked resolved
Squareys Sep 12, 2016
fe6e1bb
Avoid deprecated ResourceAwareClassLoader constructor
Squareys Sep 12, 2016
fbd8bef
Move per-node-execution preprocessing into private method.
Squareys Sep 12, 2016
c811481
Fix tiny bug
Squareys Sep 12, 2016
76acbea
Rename KnimeProcessorTest to NodeModuleTest
Squareys Sep 12, 2016
8d9bfd4
Avoid null checking getWidgetStyle()
Squareys Sep 12, 2016
24bc5ad
More javadoc
Squareys Sep 12, 2016
488620f
Use NodeLogger for logging in NodeModules and implement KNIMELogService
Squareys Sep 12, 2016
feeafa9
NodeModuleTest: Adapt to API changes in org.knime.scijava.commands
Squareys Sep 12, 2016
2bd9815
Specify 'manualPush' in constructor instead of setter.
Squareys Sep 12, 2016
6ea385c
Add tests for NodeModule and DefaultNodeModuleService
Squareys Sep 13, 2016
71e1053
Add getPreferredDataType(Class) to KNIMEConverterService
Squareys Sep 13, 2016
d2420bc
Delegate exception during notifyListener()
Squareys Sep 13, 2016
624b28f
Simplyfy getting output DataType for module output.
Squareys Sep 13, 2016
911fe46
Some Code cleanup
Squareys Sep 13, 2016
4e0736e
Remove unused imports
Squareys Sep 13, 2016
255e9fc
Use better way of detecting synthetic "result" ouput
Squareys Sep 26, 2016
321c004
Merge branch 'master' into refactoring-and-cleanup
dietzc Dec 4, 2016
a1480f0
fixes
dietzc Dec 4, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename ConverterCacheService to KNIMEConverterService
Fixes the related FIXMEs.

Signed-off-by: Squareys <[email protected]>
Squareys committed Sep 12, 2016
commit 82eeeace7e719284721ed8fe84880c25f77a767d
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@
import org.knime.core.data.def.IntCell;
import org.knime.core.data.def.LongCell;
import org.knime.core.data.def.StringCell;
import org.knime.scijava.commands.converter.ConverterCacheService;
import org.knime.scijava.commands.converter.KNIMEConverterService;
import org.knime.scijava.commands.io.DefaultInputDataRowService;
import org.knime.scijava.commands.io.DefaultOutputDataRowService;
import org.knime.scijava.commands.io.InputDataRowService;
@@ -60,7 +60,7 @@ public class KnimeProcessorTest {

protected static List<Class<? extends Service>> requiredServices = Arrays.<Class<? extends Service>> asList(
DefaultInputDataRowService.class, DefaultOutputDataRowService.class, CommandService.class,
ConverterCacheService.class);
KNIMEConverterService.class);

// Create the test table
private static final DataRow m_testRow = new DefaultRow(new RowKey("TestRow001"), BooleanCell.TRUE, new IntCell(42),
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
import java.util.Arrays;
import java.util.List;

import org.knime.scijava.commands.converter.ConverterCacheService;
import org.knime.scijava.commands.converter.KNIMEConverterService;
import org.knime.scijava.commands.module.NodeModuleService;
import org.knime.scijava.commands.settings.NodeSettingsService;
import org.knime.scijava.commands.settings.SettingsModelTypeService;
@@ -51,7 +51,7 @@ public class SciJavaGateway {
protected static List<Class<? extends Service>> requiredServices = Arrays
.<Class<? extends Service>> asList(PrefService.class,
ObjectService.class, WidgetService.class, UIService.class,
ConverterCacheService.class, CommandService.class,
KNIMEConverterService.class, CommandService.class,
NodeModuleService.class, SettingsModelTypeService.class,
NodeSettingsService.class, ScriptService.class);

Original file line number Diff line number Diff line change
@@ -27,9 +27,9 @@
*
* @author Gabriel Einsdorf (University of Konstanz)
*/
@Plugin(type = ConverterCacheService.class)
public class DefaultConverterCacheService extends AbstractService
implements ConverterCacheService {
@Plugin(type = KNIMEConverterService.class)
public class DefaultKNIMEConverterService extends AbstractService
implements KNIMEConverterService {

private final DataCellToJavaConverterRegistry m_inRegister = DataCellToJavaConverterRegistry
.getInstance();
@@ -52,11 +52,11 @@ public <O> O convertToJava(final DataCell cell, final Class<O> outputType)
}

@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings("unchecked")
public DataCell convertToKnime(final Object in, final Class<?> inType,
final DataType type, final ExecutionContext ctx) throws Exception {

final JavaToDataCellConverter converter = createNewOutputConverter(
final JavaToDataCellConverter<Object> converter = (JavaToDataCellConverter<Object>) createNewOutputConverter(
inType, type, ctx);

return converter.convert(in);
@@ -72,15 +72,12 @@ private <I> JavaToDataCellConverter<?> createNewOutputConverter(
final Class<? extends Object> outputType = ClassUtil
.ensureObjectType(type);

// TODO Will this use the "Best" dataType?
final Iterator<JavaToDataCellConverterFactory<?>> factoriesIt = m_outRegistry
.getFactoriesForSourceType(outputType).iterator();
final Optional<?> converter = m_outRegistry
.getPreferredConverterFactory(outputType, knimeType);

while (factoriesIt.hasNext()) {
final JavaToDataCellConverterFactory<?> fac = factoriesIt.next();
if (fac.getDestinationType() == knimeType) {
return fac.create(ctx);
}
if (converter.isPresent()) {
return ((JavaToDataCellConverterFactory<?>) converter.get())
.create(ctx);
}

throw new IllegalArgumentException("Can't convert from: "
@@ -156,9 +153,6 @@ public Optional<Class<DataValue>> getMatchingInputValueClass(

@Override
public Optional<Class<?>> getMatchingJavaType(final DataType dataType) {

// FIXME Will this always work with the MissingValue <-> Object
// Converter?
final Optional<DataCellToJavaConverterFactory<?, ?>> o = m_inRegister
.getFactoriesForSourceType(dataType).stream().findFirst();
if (o.isPresent()) {
Original file line number Diff line number Diff line change
@@ -19,10 +19,7 @@
*
* @author Gabriel Einsdorf (University of Konstanz)
*/
// FIXME NAMING (KNIPConverterCache?!)
// FIXME CACHING (isn't implemented everywhere, yet)
// FIXME can we always delegate to Jonathans implementations?
public interface ConverterCacheService extends Service {
public interface KNIMEConverterService extends Service {

/**
* Convert a KNIME cell to the fitting java type.
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
import org.knime.core.node.ExecutionContext;
import org.knime.scijava.commands.CellOutput;
import org.knime.scijava.commands.MultiOutputListener;
import org.knime.scijava.commands.converter.ConverterCacheService;
import org.knime.scijava.commands.converter.KNIMEConverterService;
import org.scijava.Context;
import org.scijava.module.Module;
import org.scijava.module.ModuleInfo;
@@ -33,7 +33,7 @@ class DefaultNodeModule implements NodeModule {
private PluginService ps;

@Parameter
private ConverterCacheService cs;
private KNIMEConverterService cs;

@Parameter
private ModuleService ms;
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
import org.knime.core.node.defaultnodesettings.SettingsModelString;
import org.knime.core.util.UniqueNameGenerator;
import org.knime.scijava.commands.MultiOutputListener;
import org.knime.scijava.commands.converter.ConverterCacheService;
import org.knime.scijava.commands.converter.KNIMEConverterService;
import org.knime.scijava.commands.settings.SettingsModelType;
import org.knime.scijava.commands.settings.SettingsModelTypeService;
import org.knime.scijava.commands.settings.models.SettingsModelColumnSelection;
@@ -41,7 +41,7 @@ public class DefaultNodeModuleService extends AbstractService
private SettingsModelTypeService ts;

@Parameter
private ConverterCacheService cs;
private KNIMEConverterService cs;

@Parameter
private ModuleService ms;
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

import org.knime.core.node.defaultnodesettings.SettingsModel;
import org.knime.core.node.defaultnodesettings.SettingsModelString;
import org.knime.scijava.commands.converter.ConverterCacheService;
import org.knime.scijava.commands.converter.KNIMEConverterService;
import org.scijava.module.ModuleItem;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;
@@ -18,7 +18,7 @@ public class DefaultNodeSettingsService extends AbstractService
implements NodeSettingsService {

@Parameter
private ConverterCacheService cs;
private KNIMEConverterService cs;

@Parameter
private SettingsModelTypeService typeService;
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
import org.knime.core.data.convert.util.ClassUtil;
import org.knime.core.node.defaultnodesettings.SettingsModel;
import org.knime.scijava.commands.StyleHook;
import org.knime.scijava.commands.converter.ConverterCacheService;
import org.knime.scijava.commands.converter.KNIMEConverterService;
import org.knime.scijava.commands.settings.types.SettingsModelColumnSelectionType;
import org.scijava.module.ModuleItem;
import org.scijava.plugin.AbstractSingletonService;
@@ -29,7 +29,7 @@ public class DefaultSettingsModelTypeService
implements SettingsModelTypeService {

@Parameter
private ConverterCacheService cs;
private KNIMEConverterService cs;

private final Map<Class<? extends SettingsModel>, SettingsModelType> m_pluginsByModel = new HashMap<>();
private final Map<Class<?>, SettingsModelType> m_pluginsByValue = new HashMap<>();
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
import org.knime.core.node.NotConfigurableException;
import org.knime.core.node.util.ColumnSelectionPanel;
import org.knime.core.node.util.DataValueColumnFilter;
import org.knime.scijava.commands.converter.ConverterCacheService;
import org.knime.scijava.commands.converter.KNIMEConverterService;
import org.knime.scijava.commands.settings.models.SettingsModelColumnSelection;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;
@@ -27,7 +27,7 @@
public class ColumnSelectionWidget extends SwingInputWidget<String> {

@Parameter
private ConverterCacheService convCache;
private KNIMEConverterService convCache;

// Internal parameters

Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@

import org.knime.core.data.DataCell;
import org.knime.core.data.convert.datacell.JavaToDataCellConverterFactory;
import org.knime.scijava.commands.converter.ConverterCacheService;
import org.knime.scijava.commands.converter.KNIMEConverterService;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;
import org.scijava.ui.swing.widget.SwingInputWidget;
@@ -26,7 +26,7 @@
public class DataTypeSelectionWidget extends SwingInputWidget<String> {

@Parameter
private ConverterCacheService cs;
private KNIMEConverterService cs;

// Internal parameters