-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented the converter factories for Cells --> POJO and POJO --> C…
…ell for CDKCell3 TODO: It would be worth creating a CDKCellFactory to handle creation of CDK cells. git-svn-id: https://community.knime.org/svn/nodes4knime/trunk@9238 cd80d6f6-f959-11df-8f91-f7e70cbaf77b
- Loading branch information
Showing
4 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...ence.cdk.knime/src/org/openscience/cdk/knime/type/snippets/java/CdkCellToJavaFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.openscience.cdk.knime.type.snippets.java; | ||
|
||
import org.knime.core.data.convert.java.DataCellToJavaConverter; | ||
import org.knime.core.data.convert.java.SimpleDataCellToJavaConverterFactory; | ||
import org.openscience.cdk.interfaces.IAtomContainer; | ||
import org.openscience.cdk.knime.type.CDKAdapterCell; | ||
import org.openscience.cdk.knime.type.CDKCell3; | ||
import org.openscience.cdk.knime.type.CDKValue; | ||
|
||
/** | ||
* Allows access to a CDK Value in Java Snippets. As there is no CDKCellFactory this will | ||
* create a {@link CDKAdapterCell} with a {@link CDKCell3}. | ||
* <br></br> | ||
* TODO: Create a cell factory! | ||
* | ||
* @author Samuel Webb, Lhasa Limited | ||
* @since 1.5.700, 13/03/2017 | ||
* | ||
*/ | ||
public class CdkCellToJavaFactory extends SimpleDataCellToJavaConverterFactory<CDKValue, IAtomContainer> { | ||
public CdkCellToJavaFactory() { | ||
super(CDKValue.class, IAtomContainer.class, new DataCellToJavaConverter<CDKValue, IAtomContainer>() { | ||
@Override | ||
public IAtomContainer convert(CDKValue structure) throws Exception { | ||
return structure.getAtomContainer(); | ||
} | ||
}, "IAtomContainer"); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...ence.cdk.knime/src/org/openscience/cdk/knime/type/snippets/java/JavaToCdkCellFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.openscience.cdk.knime.type.snippets.java; | ||
|
||
import org.knime.core.data.DataCell; | ||
import org.knime.core.data.convert.datacell.JavaToDataCellConverter; | ||
import org.knime.core.data.convert.datacell.SimpleJavaToDataCellConverterFactory; | ||
import org.openscience.cdk.interfaces.IAtomContainer; | ||
import org.openscience.cdk.knime.type.CDKAdapterCell; | ||
import org.openscience.cdk.knime.type.CDKCell3; | ||
|
||
/** | ||
* Converts an IAtomContainer to a CDK Cell. The implementation is not safe to | ||
* updates to CDK Cells as the choice in CDK Cell is currently hard coded. This | ||
* should be replaced with a CDK Cell Factory. | ||
* | ||
* @author Samuel Webb, Lhasa Limited | ||
* @since 1.5.700, 13/03/2017 | ||
*/ | ||
public class JavaToCdkCellFactory extends SimpleJavaToDataCellConverterFactory<IAtomContainer> { | ||
// Constructor | ||
public JavaToCdkCellFactory() { | ||
super(IAtomContainer.class, CDKAdapterCell.RAW_TYPE, new JavaToDataCellConverter<IAtomContainer>() { | ||
@Override | ||
public DataCell convert(IAtomContainer structure) throws Exception { | ||
return new CDKAdapterCell(new CDKCell3(structure)); | ||
} | ||
}, "IAtomContainer"); | ||
|
||
} | ||
} |