use of org.knime.base.node.preproc.pmml.missingval.MissingCellHandlerFactory in project knime-core by knime.
the class MissingValueNodeDescriptionHelper method createNodeDescription.
/**
* Adds an additional option tag with name "Missing Value Handler Selection"
* to the fullDescription of the given node
* description.
*
* @param parentDescription the parent description to add the tag to
* @param manager handler factory manager
* @return a node description with the <option=''/> added
* @throws IOException some problem on reading the description
* @throws SAXException not going to happen
*/
public static NodeDescription createNodeDescription(final NodeDescription parentDescription, final MissingCellHandlerFactoryManager manager) throws SAXException, IOException {
NodeDescription createNodeDescription = parentDescription;
Element knimeNode = createNodeDescription.getXMLDescription();
List<MissingCellHandlerFactory> factories = manager.getFactories();
factories.sort((a, b) -> a.getDisplayName().compareTo(b.getDisplayName()));
Element fullDescription = findFullDescription(knimeNode);
if (fullDescription != null) {
MissingCellHandlerDescriptionFactory.addShortDescriptionToNodeDescription(fullDescription, factories);
// with the namespaces and the following xslt transformation
return new NodeDescriptionXmlProxy(createNodeDescription, deepCopy(knimeNode));
}
return createNodeDescription;
}
use of org.knime.base.node.preproc.pmml.missingval.MissingCellHandlerFactory in project knime-core by knime.
the class MissingValueHandlerFactorySelectionPanel method actionPerformed.
/**
* {@inheritDoc}
*/
@Override
public void actionPerformed(final ActionEvent e) {
MissingCellHandlerFactory fac = getSelectedFactory();
if (fac.hasSettingsPanel()) {
// Show card layout panel and activate the correct settings panel
m_argumentsPanel.setVisible(true);
String key = fac.getID();
((CardLayout) m_argumentsPanel.getLayout()).show(m_argumentsPanel, key);
} else {
// If the factory has no settings panel, we can hide the card layout panel.
m_argumentsPanel.setVisible(false);
}
firePropertyChange(SELECTED_FACTORY_CHANGE, null, null);
}
use of org.knime.base.node.preproc.pmml.missingval.MissingCellHandlerFactory in project knime-core by knime.
the class MissingValueHandlerFactorySelectionPanel method getSettings.
/**
* Creates and returns a new settings object for the settings made by the user.
* @return the settings made by the user
* @throws InvalidSettingsException if a user defined panel throws an error while saving its settings.
*/
public MVIndividualSettings getSettings() throws InvalidSettingsException {
MissingCellHandlerFactory currentFactory = getSelectedFactory();
MVIndividualSettings settings = new MVIndividualSettings(currentFactory, m_handlerFactoryManager);
if (m_valueHandlerPanels.containsKey(currentFactory.getID())) {
m_valueHandlerPanels.get(currentFactory.getID()).saveSettingsTo(settings.getSettings());
}
return settings;
}
use of org.knime.base.node.preproc.pmml.missingval.MissingCellHandlerFactory in project knime-core by knime.
the class MissingCellHandlerDescriptionFactory method addShortDescriptionToNodeDescription.
/**
* Adds the short description of the given {@link MissingCellHandlerFactory}s to the fullDescription DOM-Element.
*
* @param fullDescription DOM-Element of a Knime-Node
* @param factoriesOfType registration types
*/
public static void addShortDescriptionToNodeDescription(final Element fullDescription, final Iterable<MissingCellHandlerFactory> factoriesOfType) {
CheckUtils.checkNotNull(factoriesOfType);
StringBuilder builder = new StringBuilder("<option name='Missing Value Handler Selection' optional='false'>" + "Select and configure the missing value handler to be used for data types or columns. " + "Handlers that do not produce valid PMML 4.2 are marked with an asterisk (*).");
for (MissingCellHandlerFactory reg : factoriesOfType) {
MissingCellHandlerDescription description = reg.getDescription();
String shortDescription = StringEscapeUtils.escapeXml(description.getShortDescription());
String name = description.getName();
if (!reg.producesPMML4_2()) {
name += MissingCellHandlerFactory.NO_PMML_INDICATOR;
}
String subDescription = SHORT_DESCRIPTION_TEMPLATE.replace("[NAME]", name).replace("[SHORT_DESCRIPTION]", shortDescription);
try {
// try to parse the xml snippet and ignore it if that fails
loadXmlFromString(subDescription);
builder.append(subDescription);
} catch (ParserConfigurationException | SAXException | IOException e2) {
LOGGER.coding("Fail on adding description for missing cell handler: " + reg.getID(), e2);
}
}
builder.append("</option>");
Document subDescriptionNode;
try {
subDescriptionNode = loadXmlFromString(builder.toString());
Node importedNode = fullDescription.getOwnerDocument().importNode(subDescriptionNode.getFirstChild(), true);
fullDescription.appendChild(importedNode);
} catch (ParserConfigurationException | SAXException | IOException e) {
// that should not happen, as it would be a bug!
LOGGER.coding("Invalid html fallback handling.", e);
throw new IllegalArgumentException("Invalid html fallback handling.", e);
}
}
Aggregations