Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* ------------------------------------------------------------------------
*
* Copyright by KNIME AG, Zurich, Switzerland
* Website: http://www.knime.com; Email: [email protected]
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses>.
*
* Additional permission under GNU GPL version 3 section 7:
*
* KNIME interoperates with ECLIPSE solely via ECLIPSE's plug-in APIs.
* Hence, KNIME and ECLIPSE are both independent programs and are not
* derived from each other. Should, however, the interpretation of the
* GNU GPL Version 3 ("License") under any applicable laws result in
* KNIME and ECLIPSE being a combined program, KNIME AG herewith grants
* you the additional permission to use and propagate KNIME together with
* ECLIPSE with only the license terms in place for ECLIPSE applying to
* ECLIPSE and the GNU GPL Version 3 applying for KNIME, provided the
* license terms of ECLIPSE themselves allow for the respective use and
* propagation of ECLIPSE together with KNIME.
*
* Additional permission relating to nodes for KNIME that extend the Node
* Extension (and in particular that are based on subclasses of NodeModel,
* NodeDialog, and NodeView) and that only interoperate with KNIME through
* standard APIs ("Nodes"):
* Nodes are deemed to be separate and independent programs and to not be
* covered works. Notwithstanding anything to the contrary in the
* License, the License does not apply to Nodes, you are not required to
* license Nodes under the License, and you are granted a license to
* prepare and propagate Nodes, in each case even if such Nodes are
* propagated with or for interoperation with KNIME. The owner of a Node
* may freely choose the license terms applicable to such Node, including
* when such Node is propagated with or for interoperation with KNIME.
* ---------------------------------------------------------------------
*
* History
* Dec 23, 2025 (GitHub Copilot): created
*/
package org.knime.ext.powerbi.base.nodes.send2;

import java.util.Map;

import org.knime.core.webui.node.dialog.SettingsType;
import org.knime.testing.node.dialog.DefaultNodeSettingsSnapshotTest;

/**
* Snapshot test for SendToPowerBI parameters
*/
@SuppressWarnings("restriction")
public class SendToPowerBINodeParametersTest extends DefaultNodeSettingsSnapshotTest {

protected SendToPowerBINodeParametersTest() {
super(Map.of(SettingsType.MODEL, SendToPowerBINodeParameters.class));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
/*
* ------------------------------------------------------------------------
*
* Copyright by KNIME AG, Zurich, Switzerland
* Website: http://www.knime.com; Email: [email protected]
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses>.
*
* Additional permission under GNU GPL version 3 section 7:
*
* KNIME interoperates with ECLIPSE solely via ECLIPSE's plug-in APIs.
* Hence, KNIME and ECLIPSE are both independent programs and are not
* derived from each other. Should, however, the interpretation of the
* GNU GPL Version 3 ("License") under any applicable laws result in
* KNIME and ECLIPSE being a combined program, KNIME AG herewith grants
* you the additional permission to use and propagate KNIME together with
* ECLIPSE with only the license terms in place for ECLIPSE applying to
* ECLIPSE and the GNU GPL Version 3 applying for KNIME, provided the
* license terms of ECLIPSE themselves allow for the respective use and
* propagation of ECLIPSE together with KNIME.
*
* Additional permission relating to nodes for KNIME that extend the Node
* Extension (and in particular that are based on subclasses of NodeModel,
* NodeDialog, and NodeView) and that only interoperate with KNIME through
* standard APIs ("Nodes"):
* Nodes are deemed to be separate and independent programs and to not be
* covered works. Notwithstanding anything to the contrary in the
* License, the License does not apply to Nodes, you are not required to
* license Nodes under the License, and you are granted a license to
* prepare and propagate Nodes, in each case even if such Nodes are
* propagated with or for interoperation with KNIME. The owner of a Node
* may freely choose the license terms applicable to such Node, including
* when such Node is propagated with or for interoperation with KNIME.
* ------------------------------------------------------------------------
*/
package org.knime.ext.powerbi.base.nodes.send2;

import org.apache.commons.lang3.ArrayUtils;
import org.knime.core.node.InvalidSettingsException;
import org.knime.core.node.NodeSettingsRO;
import org.knime.core.webui.node.dialog.defaultdialog.internal.persistence.ElementFieldPersistor;
import org.knime.ext.powerbi.base.nodes.send2.SendToPowerBINodeParameters.CrossFilterBehavior;
import org.knime.ext.powerbi.base.nodes.send2.SendToPowerBINodeParameters.Relationship;

/**
* Element field persistors for Relationship array elements.
*
* @author Bernd Wiswedel, KNIME GmbH, Konstanz, Germany
*/
@SuppressWarnings("restriction")
final class RelationshipFieldPersistors {

private RelationshipFieldPersistors() {
// Utility class
}

static final class FromTablePersistor implements ElementFieldPersistor<String, Integer, Relationship> {

@Override
public String load(final NodeSettingsRO nodeSettings, final Integer loadContext)
throws InvalidSettingsException {
final var fromTables = nodeSettings.getStringArray(
SendToPowerBINodeSettings2.CFG_KEY_RELATIONSHIP_FROMTABLES, ArrayUtils.EMPTY_STRING_ARRAY);
return loadContext < fromTables.length ? fromTables[loadContext] : "";
}

@Override
public void save(final String param, final Relationship saveDTO) {
saveDTO.m_fromTable = param;
}

@Override
public String[][] getConfigPaths() {
return new String[][]{{SendToPowerBINodeSettings2.CFG_KEY_RELATIONSHIP_FROMTABLES}};
}
}

static final class FromColumnPersistor implements ElementFieldPersistor<String, Integer, Relationship> {

@Override
public String load(final NodeSettingsRO nodeSettings, final Integer loadContext)
throws InvalidSettingsException {
final var fromColumns = nodeSettings.getStringArray(
SendToPowerBINodeSettings2.CFG_KEY_RELATIONSHIP_FROMCOLUMNS, ArrayUtils.EMPTY_STRING_ARRAY);
return loadContext < fromColumns.length ? fromColumns[loadContext] : "";
}

@Override
public void save(final String param, final Relationship saveDTO) {
saveDTO.m_fromColumn = param;
}

@Override
public String[][] getConfigPaths() {
return new String[][]{{SendToPowerBINodeSettings2.CFG_KEY_RELATIONSHIP_FROMCOLUMNS}};
}
}

static final class ToTablePersistor implements ElementFieldPersistor<String, Integer, Relationship> {

@Override
public String load(final NodeSettingsRO nodeSettings, final Integer loadContext)
throws InvalidSettingsException {
final var toTables = nodeSettings.getStringArray(SendToPowerBINodeSettings2.CFG_KEY_RELATIONSHIP_TOTABLES,
ArrayUtils.EMPTY_STRING_ARRAY);
return loadContext < toTables.length ? toTables[loadContext] : "";
}

@Override
public void save(final String param, final Relationship saveDTO) {
saveDTO.m_toTable = param;
}

@Override
public String[][] getConfigPaths() {
return new String[][]{{SendToPowerBINodeSettings2.CFG_KEY_RELATIONSHIP_TOTABLES}};
}
}

static final class ToColumnPersistor implements ElementFieldPersistor<String, Integer, Relationship> {

@Override
public String load(final NodeSettingsRO nodeSettings, final Integer loadContext)
throws InvalidSettingsException {
final var toColumns = nodeSettings.getStringArray(SendToPowerBINodeSettings2.CFG_KEY_RELATIONSHIP_TOCOLUMNS,
ArrayUtils.EMPTY_STRING_ARRAY);
return loadContext < toColumns.length ? toColumns[loadContext] : "";
}

@Override
public void save(final String param, final Relationship saveDTO) {
saveDTO.m_toColumn = param;
}

@Override
public String[][] getConfigPaths() {
return new String[][]{{SendToPowerBINodeSettings2.CFG_KEY_RELATIONSHIP_TOCOLUMNS}};
}
}

static final class CrossFilterBehaviorPersistor
implements ElementFieldPersistor<CrossFilterBehavior, Integer, Relationship> {

@Override
public CrossFilterBehavior load(final NodeSettingsRO nodeSettings, final Integer loadContext)
throws InvalidSettingsException {
final var crossFilterBehaviors = nodeSettings.getStringArray(
SendToPowerBINodeSettings2.CFG_KEY_RELATIONSHIP_CROSSFILTERBEHAVIORS, ArrayUtils.EMPTY_STRING_ARRAY);
return loadContext < crossFilterBehaviors.length
? CrossFilterBehavior.parseFromSerialized(crossFilterBehaviors[loadContext])
: CrossFilterBehavior.AUTOMATIC;
}

@Override
public void save(final CrossFilterBehavior param, final Relationship saveDTO) {
saveDTO.m_crossFilterBehavior = param;
}

@Override
public String[][] getConfigPaths() {
return new String[][]{{SendToPowerBINodeSettings2.CFG_KEY_RELATIONSHIP_CROSSFILTERBEHAVIORS}};
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
* ------------------------------------------------------------------------
*
* Copyright by KNIME AG, Zurich, Switzerland
* Website: http://www.knime.com; Email: [email protected]
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses>.
*
* Additional permission under GNU GPL version 3 section 7:
*
* KNIME interoperates with ECLIPSE solely via ECLIPSE's plug-in APIs.
* Hence, KNIME and ECLIPSE are both independent programs and are not
* derived from each other. Should, however, the interpretation of the
* GNU GPL Version 3 ("License") under any applicable laws result in
* KNIME and ECLIPSE being a combined program, KNIME AG herewith grants
* you the additional permission to use and propagate KNIME together with
* ECLIPSE with only the license terms in place for ECLIPSE applying to
* ECLIPSE and the GNU GPL Version 3 applying for KNIME, provided the
* license terms of ECLIPSE themselves allow for the respective use and
* propagation of ECLIPSE together with KNIME.
*
* Additional permission relating to nodes for KNIME that extend the Node
* Extension (and in particular that are based on subclasses of NodeModel,
* NodeDialog, and NodeView) and that only interoperate with KNIME through
* standard APIs ("Nodes"):
* Nodes are deemed to be separate and independent programs and to not be
* covered works. Notwithstanding anything to the contrary in the
* License, the License does not apply to Nodes, you are not required to
* license Nodes under the License, and you are granted a license to
* prepare and propagate Nodes, in each case even if such Nodes are
* propagated with or for interoperation with KNIME. The owner of a Node
* may freely choose the license terms applicable to such Node, including
* when such Node is propagated with or for interoperation with KNIME.
* ------------------------------------------------------------------------
*/
package org.knime.ext.powerbi.base.nodes.send2;

import java.util.List;

import org.apache.commons.lang3.ArrayUtils;
import org.knime.core.node.InvalidSettingsException;
import org.knime.core.node.NodeSettingsRO;
import org.knime.core.node.NodeSettingsWO;
import org.knime.core.webui.node.dialog.defaultdialog.internal.persistence.ArrayPersistor;
import org.knime.ext.powerbi.base.nodes.send2.SendToPowerBINodeParameters.Relationship;

/**
* Persistor for relationships array that transforms between the old array-based format and the new object-based
* format using ArrayPersistor interface.
*
* @author Bernd Wiswedel, KNIME GmbH, Konstanz, Germany
*/
@SuppressWarnings("restriction")
final class RelationshipsArrayPersistor implements ArrayPersistor<Integer, Relationship> {

@Override
public int getArrayLength(final NodeSettingsRO nodeSettings) throws InvalidSettingsException {
final var fromTables = nodeSettings.getStringArray(SendToPowerBINodeSettings2.CFG_KEY_RELATIONSHIP_FROMTABLES,
ArrayUtils.EMPTY_STRING_ARRAY);
return fromTables.length;
}

@Override
public Integer createElementLoadContext(final int index) {
return index;
}

@Override
public Relationship createElementSaveDTO(final int index) {
return new Relationship();
}

@Override
public void save(final List<Relationship> relationships, final NodeSettingsWO settings) {
final var fromTables = new String[relationships.size()];
final var fromColumns = new String[relationships.size()];
final var toTables = new String[relationships.size()];
final var toColumns = new String[relationships.size()];
final var crossFilterBehaviors = new String[relationships.size()];

for (int i = 0; i < relationships.size(); i++) {
final var relationship = relationships.get(i);
fromTables[i] = relationship.m_fromTable;
fromColumns[i] = relationship.m_fromColumn;
toTables[i] = relationship.m_toTable;
toColumns[i] = relationship.m_toColumn;
crossFilterBehaviors[i] = relationship.m_crossFilterBehavior.getSerialized();
}

settings.addStringArray(SendToPowerBINodeSettings2.CFG_KEY_RELATIONSHIP_FROMTABLES, fromTables);
settings.addStringArray(SendToPowerBINodeSettings2.CFG_KEY_RELATIONSHIP_FROMCOLUMNS, fromColumns);
settings.addStringArray(SendToPowerBINodeSettings2.CFG_KEY_RELATIONSHIP_TOTABLES, toTables);
settings.addStringArray(SendToPowerBINodeSettings2.CFG_KEY_RELATIONSHIP_TOCOLUMNS, toColumns);
settings.addStringArray(SendToPowerBINodeSettings2.CFG_KEY_RELATIONSHIP_CROSSFILTERBEHAVIORS,
crossFilterBehaviors);
}
}
Loading