You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hop.apache.org by ha...@apache.org on 2022/07/01 13:44:59 UTC
[hop] branch master updated: HOP-4003: sonar cleanup
This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/master by this push:
new e1ca020bf2 HOP-4003: sonar cleanup
new 9bdc7c6dd2 Merge pull request #1561 from hansva/master
e1ca020bf2 is described below
commit e1ca020bf2609e310cfbee8057865d1ad574908d
Author: Hans Van Akelyen <ha...@gmail.com>
AuthorDate: Fri Jul 1 15:03:57 2022 +0200
HOP-4003: sonar cleanup
---
.../actions/snowflake/WarehouseManager.java | 1113 +++----
.../actions/snowflake/WarehouseManagerDialog.java | 2166 +++++++-------
.../snowflake/bulkloader/SnowflakeBulkLoader.java | 1503 +++++-----
.../bulkloader/SnowflakeBulkLoaderData.java | 91 +-
.../bulkloader/SnowflakeBulkLoaderDialog.java | 3160 ++++++++++----------
.../bulkloader/SnowflakeBulkLoaderField.java | 177 +-
.../bulkloader/SnowflakeBulkLoaderMeta.java | 127 +-
7 files changed, 4182 insertions(+), 4155 deletions(-)
diff --git a/plugins/actions/snowflake/src/main/java/org/apache/hop/workflow/actions/snowflake/WarehouseManager.java b/plugins/actions/snowflake/src/main/java/org/apache/hop/workflow/actions/snowflake/WarehouseManager.java
index c4b579de48..40eb49230a 100644
--- a/plugins/actions/snowflake/src/main/java/org/apache/hop/workflow/actions/snowflake/WarehouseManager.java
+++ b/plugins/actions/snowflake/src/main/java/org/apache/hop/workflow/actions/snowflake/WarehouseManager.java
@@ -41,616 +41,653 @@ import static org.apache.hop.workflow.action.validator.ActionValidatorUtils.andV
import static org.apache.hop.workflow.action.validator.ActionValidatorUtils.notBlankValidator;
import static org.apache.hop.workflow.action.validator.AndValidator.putValidators;
-@SuppressWarnings( { "WeakerAccess", "unused" } )
-@Action( id = "SnowflakeWarehouseManager",
- image = "snowflake-whm.svg",
- name = "Action.Name",
- description = "Action.Description",
- categoryDescription = "Category.Description",
- documentationUrl = ""
- )
+@Action(
+ id = "SnowflakeWarehouseManager",
+ image = "snowflake-whm.svg",
+ name = "Action.Name",
+ description = "Action.Description",
+ categoryDescription = "Category.Description",
+ documentationUrl = "")
public class WarehouseManager extends ActionBase implements Cloneable, IAction {
- public static final String MANAGEMENT_ACTION = "managementAction";
- public static final String REPLACE = "replace";
- public static final String FAIL_IF_EXISTS = "failIfExists";
- public static final String WAREHOUSE_NAME = "warehouseName";
- public static final String WAREHOUSE_SIZE = "warehouseSize";
- public static final String WAREHOUSE_TYPE = "warehouseType";
- public static final String MAX_CLUSTER_COUNT = "maxClusterCount";
- public static final String MIN_CLUSTER_COUNT = "minClusterCount";
- public static final String AUTO_SUSPEND = "autoSuspend";
- public static final String AUTO_RESUME = "autoResume";
- public static final String INITIALLY_SUSPENDED = "initiallySuspended";
- public static final String COMMENT = "comment";
- public static final String RESOURCE_MONITOR = "resourceMonitor";
- public static final String CONNECTION = "connection";
- /**
- * The type of management actions this action supports
- */
- private static final String[] MANAGEMENT_ACTIONS = { "create", "drop", "resume", "suspend", "alter" };
- public static final int MANAGEMENT_ACTION_CREATE = 0;
- public static final int MANAGEMENT_ACTION_DROP = 1;
- public static final int MANAGEMENT_ACTION_RESUME = 2;
- public static final int MANAGEMENT_ACTION_SUSPEND = 3;
- public static final int MANAGEMENT_ACTION_ALTER = 4;
-
- /**
- * The valid warehouse sizes
- */
- private static final String[] WAREHOUSE_SIZES = { "XSMALL", "SMALL", "MEDIUM", "LARGE", "XLARGE", "XXLARGE", "XXXLARGE" };
- /**
- * The valid warehouse types
- */
- private static final String[] WAREHOUSE_TYPES = { "Standard", "Enterprise" };
- public static final String FAIL_IF_NOT_EXISTS = "failIfNotExists";
- private static Class<?> PKG = WarehouseManager.class; // for i18n purposes, needed by Translator2!! $NON-NLS-1$
- /**
- * The database to connect to.
- */
- private DatabaseMeta databaseMeta;
-
- /**
- * The management action to perform.
- */
- private String managementAction;
-
- /**
- * The name of the warehouse.
- */
- private String warehouseName;
-
- /**
- * CREATE: If the warehouse exists, should it be replaced
- */
- private boolean replace;
-
- /**
- * CREATE: Fail if the warehouse exists
- */
- private boolean failIfExists;
-
- /**
- * DROP: Fail if the warehouse does not exist
- */
- private boolean failIfNotExists;
-
- /**
- * CREATE: The warehouse size to use
- */
- private String warehouseSize;
-
- /**
- * CREATE: The warehouse type to use
- */
- private String warehouseType;
-
- /**
- * CREATE: The maximum cluster size
- */
- private String maxClusterCount;
-
- /**
- * CREATE: The minimum cluster size
- */
- private String minClusterCount;
-
- /**
- * CREATE: Should the warehouse automatically suspend
- */
- private String autoSuspend;
-
- /**
- * CREATE: Should the warehouse automatically resume when it receives a statement
- */
- private boolean autoResume;
-
- /**
- * CREATE: Should the warehouse start in a suspended state
- */
- private boolean initiallySuspended;
-
- /**
- * CREATE: The resource monitor to control the warehouse for billing
- */
- private String resourceMonitor;
-
- /**
- * CREATE: The comment to associate with the statement
- */
- private String comment;
-
- public WarehouseManager( String name ) {
- super( name, "" );
- setDefault();
- }
-
- public WarehouseManager() {
- this( "" );
- setDefault();
- }
-
- public void setDefault() {
- failIfExists = true;
- failIfNotExists = true;
- }
-
- public Object clone() {
- return super.clone();
- }
-
- public DatabaseMeta getDatabaseMeta() {
- return databaseMeta;
- }
-
- public void setDatabaseMeta( DatabaseMeta databaseMeta ) {
- this.databaseMeta = databaseMeta;
- }
+ public static final String MANAGEMENT_ACTION = "managementAction";
+ public static final String REPLACE = "replace";
+ public static final String FAIL_IF_EXISTS = "failIfExists";
+ public static final String WAREHOUSE_NAME = "warehouseName";
+ public static final String WAREHOUSE_SIZE = "warehouseSize";
+ public static final String WAREHOUSE_TYPE = "warehouseType";
+ public static final String MAX_CLUSTER_COUNT = "maxClusterCount";
+ public static final String MIN_CLUSTER_COUNT = "minClusterCount";
+ public static final String AUTO_SUSPEND = "autoSuspend";
+ public static final String AUTO_RESUME = "autoResume";
+ public static final String INITIALLY_SUSPENDED = "initiallySuspended";
+ public static final String COMMENT = "comment";
+ public static final String RESOURCE_MONITOR = "resourceMonitor";
+ public static final String CONNECTION = "connection";
+ /** The type of management actions this action supports */
+ private static final String[] MANAGEMENT_ACTIONS = {
+ "create", "drop", "resume", "suspend", "alter"
+ };
+
+ public static final int MANAGEMENT_ACTION_CREATE = 0;
+ public static final int MANAGEMENT_ACTION_DROP = 1;
+ public static final int MANAGEMENT_ACTION_RESUME = 2;
+ public static final int MANAGEMENT_ACTION_SUSPEND = 3;
+ public static final int MANAGEMENT_ACTION_ALTER = 4;
+
+ /** The valid warehouse sizes */
+ private static final String[] WAREHOUSE_SIZES = {
+ "XSMALL", "SMALL", "MEDIUM", "LARGE", "XLARGE", "XXLARGE", "XXXLARGE"
+ };
+ /** The valid warehouse types */
+ private static final String[] WAREHOUSE_TYPES = {"Standard", "Enterprise"};
+
+ public static final String FAIL_IF_NOT_EXISTS = "failIfNotExists";
+ private static final Class<?> PKG =
+ WarehouseManager.class; // for i18n purposes, needed by Translator2!! $NON-NLS-1$
+ /** The database to connect to. */
+ private DatabaseMeta databaseMeta;
+
+ /** The management action to perform. */
+ private String managementAction;
+
+ /** The name of the warehouse. */
+ private String warehouseName;
+
+ /** CREATE: If the warehouse exists, should it be replaced */
+ private boolean replace;
+
+ /** CREATE: Fail if the warehouse exists */
+ private boolean failIfExists;
+
+ /** DROP: Fail if the warehouse does not exist */
+ private boolean failIfNotExists;
+
+ /** CREATE: The warehouse size to use */
+ private String warehouseSize;
+
+ /** CREATE: The warehouse type to use */
+ private String warehouseType;
+
+ /** CREATE: The maximum cluster size */
+ private String maxClusterCount;
+
+ /** CREATE: The minimum cluster size */
+ private String minClusterCount;
+
+ /** CREATE: Should the warehouse automatically suspend */
+ private String autoSuspend;
+
+ /** CREATE: Should the warehouse automatically resume when it receives a statement */
+ private boolean autoResume;
+
+ /** CREATE: Should the warehouse start in a suspended state */
+ private boolean initiallySuspended;
+
+ /** CREATE: The resource monitor to control the warehouse for billing */
+ private String resourceMonitor;
+
+ /** CREATE: The comment to associate with the statement */
+ private String comment;
+
+ public WarehouseManager(String name) {
+ super(name, "");
+ setDefault();
+ }
+
+ public WarehouseManager() {
+ this("");
+ setDefault();
+ }
+
+ public void setDefault() {
+ failIfExists = true;
+ failIfNotExists = true;
+ }
+
+ @Override
+ public Object clone() {
+ return super.clone();
+ }
+
+ public DatabaseMeta getDatabaseMeta() {
+ return databaseMeta;
+ }
+
+ public void setDatabaseMeta(DatabaseMeta databaseMeta) {
+ this.databaseMeta = databaseMeta;
+ }
+
+ public String getManagementAction() {
+ return managementAction;
+ }
+
+ public void setManagementAction(String managementAction) {
+ this.managementAction = managementAction;
+ }
- public String getManagementAction() {
- return managementAction;
- }
-
- public void setManagementAction( String managementAction ) {
- this.managementAction = managementAction;
- }
-
- public int getManagementActionId() {
- if ( managementAction != null ) {
- for ( int i = 0; i < MANAGEMENT_ACTIONS.length; i++ ) {
- if ( managementAction.equals( MANAGEMENT_ACTIONS[i] ) ) {
- return i;
- }
- }
+ public int getManagementActionId() {
+ if (managementAction != null) {
+ for (int i = 0; i < MANAGEMENT_ACTIONS.length; i++) {
+ if (managementAction.equals(MANAGEMENT_ACTIONS[i])) {
+ return i;
}
- return -1;
+ }
}
+ return -1;
+ }
- public void setManagementActionById( int managementActionId ) {
- if ( managementActionId >= 0 && managementActionId <= MANAGEMENT_ACTIONS.length ) {
- managementAction = MANAGEMENT_ACTIONS[managementActionId];
- } else {
- managementAction = null;
- }
+ public void setManagementActionById(int managementActionId) {
+ if (managementActionId >= 0 && managementActionId <= MANAGEMENT_ACTIONS.length) {
+ managementAction = MANAGEMENT_ACTIONS[managementActionId];
+ } else {
+ managementAction = null;
}
+ }
- public String getWarehouseName() {
- return warehouseName;
- }
+ public String getWarehouseName() {
+ return warehouseName;
+ }
- public void setWarehouseName( String warehouseName ) {
- this.warehouseName = warehouseName;
- }
+ public void setWarehouseName(String warehouseName) {
+ this.warehouseName = warehouseName;
+ }
- public boolean isReplace() {
- return replace;
- }
+ public boolean isReplace() {
+ return replace;
+ }
- public void setReplace( boolean replace ) {
- this.replace = replace;
- }
+ public void setReplace(boolean replace) {
+ this.replace = replace;
+ }
- public boolean isFailIfExists() {
- return failIfExists;
- }
+ public boolean isFailIfExists() {
+ return failIfExists;
+ }
- public void setFailIfExists( boolean failIfExists ) {
- this.failIfExists = failIfExists;
- }
+ public void setFailIfExists(boolean failIfExists) {
+ this.failIfExists = failIfExists;
+ }
- public boolean isFailIfNotExists() {
- return failIfNotExists;
- }
+ public boolean isFailIfNotExists() {
+ return failIfNotExists;
+ }
- public void setFailIfNotExists( boolean failIfNotExists ) {
- this.failIfNotExists = failIfNotExists;
- }
+ public void setFailIfNotExists(boolean failIfNotExists) {
+ this.failIfNotExists = failIfNotExists;
+ }
- public String getWarehouseSize() {
- return warehouseSize;
- }
+ public String getWarehouseSize() {
+ return warehouseSize;
+ }
- public void setWarehouseSize( String warehouseSize ) {
- this.warehouseSize = warehouseSize;
- }
+ public void setWarehouseSize(String warehouseSize) {
+ this.warehouseSize = warehouseSize;
+ }
- public int getWarehouseSizeId() {
- if ( warehouseSize != null ) {
- for ( int i = 0; i < WAREHOUSE_SIZES.length; i++ ) {
- if ( warehouseSize.equals( WAREHOUSE_SIZES[i] ) ) {
- return i;
- }
- }
+ public int getWarehouseSizeId() {
+ if (warehouseSize != null) {
+ for (int i = 0; i < WAREHOUSE_SIZES.length; i++) {
+ if (warehouseSize.equals(WAREHOUSE_SIZES[i])) {
+ return i;
}
- return -1;
+ }
}
+ return -1;
+ }
- public void setWarehouseSizeById( int warehouseSizeId ) {
- if ( warehouseSizeId >= 0 && warehouseSizeId < WAREHOUSE_SIZES.length ) {
- warehouseSize = WAREHOUSE_SIZES[warehouseSizeId];
- } else {
- warehouseSize = null;
- }
+ public void setWarehouseSizeById(int warehouseSizeId) {
+ if (warehouseSizeId >= 0 && warehouseSizeId < WAREHOUSE_SIZES.length) {
+ warehouseSize = WAREHOUSE_SIZES[warehouseSizeId];
+ } else {
+ warehouseSize = null;
}
+ }
- public String getWarehouseType() {
- return warehouseType;
- }
+ public String getWarehouseType() {
+ return warehouseType;
+ }
- public void setWarehouseType( String warehouseType ) {
- this.warehouseType = warehouseType;
- }
+ public void setWarehouseType(String warehouseType) {
+ this.warehouseType = warehouseType;
+ }
- public int getWarehouseTypeId() {
- if ( warehouseType != null ) {
- for ( int i = 0; i < WAREHOUSE_TYPES.length; i++ ) {
- if ( warehouseType.equals( WAREHOUSE_TYPES[i] ) ) {
- return i;
- }
- }
+ public int getWarehouseTypeId() {
+ if (warehouseType != null) {
+ for (int i = 0; i < WAREHOUSE_TYPES.length; i++) {
+ if (warehouseType.equals(WAREHOUSE_TYPES[i])) {
+ return i;
}
- return -1;
- }
-
- public void setWarehouseTypeById( int warehouseTypeId ) {
- if ( warehouseTypeId >= 0 && warehouseTypeId < WAREHOUSE_TYPES.length ) {
- warehouseType = WAREHOUSE_TYPES[warehouseTypeId];
- } else {
- warehouseType = null;
+ }
+ }
+ return -1;
+ }
+
+ public void setWarehouseTypeById(int warehouseTypeId) {
+ if (warehouseTypeId >= 0 && warehouseTypeId < WAREHOUSE_TYPES.length) {
+ warehouseType = WAREHOUSE_TYPES[warehouseTypeId];
+ } else {
+ warehouseType = null;
+ }
+ }
+
+ public String getMaxClusterCount() {
+ return maxClusterCount;
+ }
+
+ public void setMaxClusterCount(String maxClusterCount) {
+ this.maxClusterCount = maxClusterCount;
+ }
+
+ public String getMinClusterCount() {
+ return minClusterCount;
+ }
+
+ public void setMinClusterCount(String minClusterCount) {
+ this.minClusterCount = minClusterCount;
+ }
+
+ public String getAutoSuspend() {
+ return autoSuspend;
+ }
+
+ public void setAutoSuspend(String autoSuspend) {
+ this.autoSuspend = autoSuspend;
+ }
+
+ public boolean isAutoResume() {
+ return autoResume;
+ }
+
+ public void setAutoResume(boolean autoResume) {
+ this.autoResume = autoResume;
+ }
+
+ public boolean isInitiallySuspended() {
+ return initiallySuspended;
+ }
+
+ public void setInitiallySuspended(boolean initiallySuspended) {
+ this.initiallySuspended = initiallySuspended;
+ }
+
+ public String getResourceMonitor() {
+ return resourceMonitor;
+ }
+
+ public void setResourceMonitor(String resourceMonitor) {
+ this.resourceMonitor = resourceMonitor;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+
+ @Override
+ public String getXml() {
+ StringBuffer returnValue = new StringBuffer(300);
+
+ returnValue.append(super.getXml());
+ returnValue
+ .append(" ")
+ .append(
+ XmlHandler.addTagValue(
+ CONNECTION, databaseMeta == null ? null : databaseMeta.getName()));
+ returnValue
+ .append(" ")
+ .append(
+ XmlHandler.addTagValue(
+ MANAGEMENT_ACTION, getManagementAction())); // $NON-NLS-1$ //$NON-NLS-2$
+ returnValue
+ .append(" ")
+ .append(XmlHandler.addTagValue(REPLACE, isReplace())); // $NON-NLS-1$ //$NON-NLS-2$
+ returnValue
+ .append(" ")
+ .append(
+ XmlHandler.addTagValue(FAIL_IF_EXISTS, isFailIfExists())); // $NON-NLS-1$ //$NON-NLS-2$
+ returnValue
+ .append(" ")
+ .append(
+ XmlHandler.addTagValue(
+ WAREHOUSE_NAME, getWarehouseName())); // $NON-NLS-1$ //$NON-NLS-2$
+ returnValue
+ .append(" ")
+ .append(
+ XmlHandler.addTagValue(
+ WAREHOUSE_SIZE, getWarehouseSize())); // $NON-NLS-1$ //$NON-NLS-2$
+ returnValue
+ .append(" ")
+ .append(
+ XmlHandler.addTagValue(
+ WAREHOUSE_TYPE, getWarehouseType())); // $NON-NLS-1$ //$NON-NLS-2$
+ returnValue
+ .append(" ")
+ .append(
+ XmlHandler.addTagValue(
+ MAX_CLUSTER_COUNT, getMaxClusterCount())); // $NON-NLS-1$ //$NON-NLS-2$
+ returnValue
+ .append(" ")
+ .append(
+ XmlHandler.addTagValue(
+ MIN_CLUSTER_COUNT, getMinClusterCount())); // $NON-NLS-1$ //$NON-NLS-2$
+ returnValue
+ .append(" ")
+ .append(
+ XmlHandler.addTagValue(AUTO_SUSPEND, getAutoSuspend())); // $NON-NLS-1$ //$NON-NLS-2$
+ returnValue
+ .append(" ")
+ .append(XmlHandler.addTagValue(AUTO_RESUME, isAutoResume())); // $NON-NLS-1$ //$NON-NLS-2$
+ returnValue
+ .append(" ")
+ .append(
+ XmlHandler.addTagValue(
+ INITIALLY_SUSPENDED, isInitiallySuspended())); // $NON-NLS-1$ //$NON-NLS-2$
+ returnValue
+ .append(" ")
+ .append(
+ XmlHandler.addTagValue(
+ RESOURCE_MONITOR, getResourceMonitor())); // $NON-NLS-1$ //$NON-NLS-2$
+ returnValue
+ .append(" ")
+ .append(XmlHandler.addTagValue(COMMENT, getComment())); // $NON-NLS-1$ //$NON-NLS-2$
+ returnValue
+ .append(" ")
+ .append(XmlHandler.addTagValue(FAIL_IF_NOT_EXISTS, isFailIfNotExists()));
+
+ return returnValue.toString();
+ }
+
+ @Override
+ public void loadXml(Node entryNode, IHopMetadataProvider metadataProvider, IVariables variables)
+ throws HopXmlException {
+ try {
+ super.loadXml(entryNode);
+ String dbname = XmlHandler.getTagValue(entryNode, CONNECTION);
+ databaseMeta = DatabaseMeta.loadDatabase(metadataProvider, dbname);
+
+ setManagementAction(XmlHandler.getTagValue(entryNode, MANAGEMENT_ACTION));
+ setReplace("Y".equalsIgnoreCase(XmlHandler.getTagValue(entryNode, REPLACE)));
+ setFailIfExists("Y".equalsIgnoreCase(XmlHandler.getTagValue(entryNode, FAIL_IF_EXISTS)));
+ setWarehouseName(XmlHandler.getTagValue(entryNode, WAREHOUSE_NAME));
+ setWarehouseSize(XmlHandler.getTagValue(entryNode, WAREHOUSE_SIZE));
+ setWarehouseType(XmlHandler.getTagValue(entryNode, WAREHOUSE_TYPE));
+ setMaxClusterCount(XmlHandler.getTagValue(entryNode, MAX_CLUSTER_COUNT));
+ setMinClusterCount(XmlHandler.getTagValue(entryNode, MIN_CLUSTER_COUNT));
+ setAutoSuspend(XmlHandler.getTagValue(entryNode, AUTO_SUSPEND));
+ setAutoResume("Y".equalsIgnoreCase(XmlHandler.getTagValue(entryNode, AUTO_RESUME)));
+ setInitiallySuspended(
+ "Y".equalsIgnoreCase(XmlHandler.getTagValue(entryNode, INITIALLY_SUSPENDED)));
+ setResourceMonitor(XmlHandler.getTagValue(entryNode, RESOURCE_MONITOR));
+ setComment(XmlHandler.getTagValue(entryNode, COMMENT));
+ setFailIfNotExists(
+ "Y".equalsIgnoreCase(XmlHandler.getTagValue(entryNode, FAIL_IF_NOT_EXISTS)));
+ } catch (HopXmlException dbe) {
+ throw new HopXmlException(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Error.Exception.UnableLoadXML"),
+ dbe);
+ }
+ }
+
+ @Override
+ public void clear() {
+ super.clear();
+
+ setManagementAction(null);
+ setReplace(false);
+ setFailIfExists(false);
+ setWarehouseName(null);
+ setWarehouseSize(null);
+ setWarehouseType(null);
+ setMaxClusterCount(null);
+ setMinClusterCount(null);
+ setAutoSuspend(null);
+ setAutoResume(false);
+ setInitiallySuspended(false);
+ setResourceMonitor(null);
+ setComment(null);
+ setDatabaseMeta(null);
+ setFailIfNotExists(true);
+ }
+
+ public boolean validate() {
+ boolean result = true;
+ if (databaseMeta == null || StringUtil.isEmpty(databaseMeta.getName())) {
+ logError(BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Validate.DatabaseIsEmpty"));
+ result = false;
+ } else if (StringUtil.isEmpty(managementAction)) {
+ logError(BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Validate.ManagementAction"));
+ result = false;
+ } else if (managementAction.equals(MANAGEMENT_ACTIONS[MANAGEMENT_ACTION_CREATE])) {
+ if (!StringUtil.isEmpty(resolve(maxClusterCount))
+ && Const.toInt(resolve(maxClusterCount), -1) <= 0) {
+
+ logError(
+ BaseMessages.getString(
+ PKG,
+ "SnowflakeWarehouseManager.Validate.MaxClusterCount",
+ resolve(maxClusterCount)));
+ return false;
+ }
+
+ if (!StringUtil.isEmpty(resolve(minClusterCount))
+ && Const.toInt(resolve(minClusterCount), -1) < 0) {
+
+ logError(
+ BaseMessages.getString(
+ PKG,
+ "SnowflakeWarehouseManager.Validate.MinClusterCount",
+ resolve(minClusterCount)));
+ return false;
+ }
+
+ if (!StringUtil.isEmpty(resolve(autoSuspend)) && Const.toInt(resolve(autoSuspend), -1) < 0) {
+ logError(
+ BaseMessages.getString(
+ PKG, "SnowflakeWarehouseManager.Validate.AutoSuspend", resolve(autoSuspend)));
+ return false;
+ }
+ }
+ return result;
+ }
+
+ public Result execute(Result previousResult, int nr) throws HopException {
+
+ Result result = previousResult;
+ result.setResult(validate());
+ if (!result.getResult()) {
+ return result;
+ }
+
+ Database db = null;
+ try {
+ db = new Database(this, this, databaseMeta);
+ String sql = null;
+ String successMessage = null;
+
+ if (managementAction.equals(MANAGEMENT_ACTIONS[MANAGEMENT_ACTION_CREATE])) {
+ sql = getCreateSQL();
+ successMessage =
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Log.Create.Success");
+ } else if (managementAction.equals(MANAGEMENT_ACTIONS[MANAGEMENT_ACTION_DROP])) {
+ sql = getDropSQL();
+ successMessage = BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Log.Drop.Success");
+ } else if (managementAction.equals(MANAGEMENT_ACTIONS[MANAGEMENT_ACTION_RESUME])) {
+ sql = getResumeSQL();
+ successMessage =
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Log.Resume.Success");
+ } else if (managementAction.equals(MANAGEMENT_ACTIONS[MANAGEMENT_ACTION_SUSPEND])) {
+ sql = getSuspendSQL();
+ successMessage =
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Log.Suspend.Success");
+ } else if (managementAction.equals(MANAGEMENT_ACTIONS[MANAGEMENT_ACTION_ALTER])) {
+ sql = getAlterSQL();
+ successMessage = BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Log.Alter.Success");
+ }
+
+ if (sql == null) {
+ throw new HopException("Unable to generate action, could not find action type");
+ }
+
+ db.connect();
+ logDebug("Executing SQL " + sql);
+ db.execStatements(sql);
+ logBasic(successMessage);
+
+ } catch (Exception ex) {
+ logError("Error managing warehouse", ex);
+ result.setResult(false);
+ } finally {
+ try {
+ if (db != null) {
+ db.disconnect();
}
+ } catch (Exception ex) {
+ logError("Unable to disconnect from database", ex);
+ }
}
- public String getMaxClusterCount() {
- return maxClusterCount;
- }
+ return result;
+ }
- public void setMaxClusterCount( String maxClusterCount ) {
- this.maxClusterCount = maxClusterCount;
+ private String getDropSQL() {
+ StringBuilder sql = new StringBuilder();
+ sql.append("DROP WAREHOUSE ");
+ if (!failIfNotExists) {
+ sql.append("IF EXISTS ");
}
+ sql.append(resolve(warehouseName)).append(";\ncommit;");
+ return sql.toString();
+ }
- public String getMinClusterCount() {
- return minClusterCount;
+ private String getResumeSQL() {
+ StringBuilder sql = new StringBuilder();
+ sql.append("ALTER WAREHOUSE ");
+ if (!failIfNotExists) {
+ sql.append("IF EXISTS ");
}
+ sql.append(resolve(warehouseName)).append(" RESUME;\ncommit;");
+ return sql.toString();
+ }
- public void setMinClusterCount( String minClusterCount ) {
- this.minClusterCount = minClusterCount;
+ private String getSuspendSQL() {
+ StringBuilder sql = new StringBuilder();
+ sql.append("ALTER WAREHOUSE ");
+ if (!failIfNotExists) {
+ sql.append("IF EXISTS ");
}
+ sql.append(resolve(warehouseName)).append(" SUSPEND;\ncommit;");
+ return sql.toString();
+ }
- public String getAutoSuspend() {
- return autoSuspend;
+ private String getCreateSQL() {
+ StringBuilder sql = new StringBuilder();
+ sql.append("CREATE ");
+ if (replace) {
+ sql.append("OR REPLACE ");
}
-
- public void setAutoSuspend( String autoSuspend ) {
- this.autoSuspend = autoSuspend;
+ sql.append("WAREHOUSE ");
+ if (!failIfExists && !replace) {
+ sql.append("IF NOT EXISTS ");
}
+ sql.append(warehouseName).append(" WITH ");
- public boolean isAutoResume() {
- return autoResume;
+ if (!StringUtil.isEmpty(resolve(warehouseSize))) {
+ sql.append("WAREHOUSE_SIZE = '").append(resolve(warehouseSize)).append("' ");
}
- public void setAutoResume( boolean autoResume ) {
- this.autoResume = autoResume;
+ if (!StringUtil.isEmpty(resolve(warehouseType))) {
+ sql.append("WAREHOUSE_TYPE = ").append(resolve(warehouseType)).append(" ");
}
- public boolean isInitiallySuspended() {
- return initiallySuspended;
+ if (!StringUtil.isEmpty(resolve(maxClusterCount))) {
+ sql.append("MAX_CLUSTER_COUNT = ").append(resolve(maxClusterCount)).append(" ");
}
- public void setInitiallySuspended( boolean initiallySuspended ) {
- this.initiallySuspended = initiallySuspended;
+ if (!StringUtil.isEmpty(resolve(minClusterCount))) {
+ sql.append("MIN_CLUSTER_COUNT = ").append(resolve(minClusterCount)).append(" ");
}
- public String getResourceMonitor() {
- return resourceMonitor;
+ if (!StringUtil.isEmpty(resolve(autoSuspend))) {
+ sql.append("AUTO_SUSPEND = ").append(Const.toInt(resolve(autoSuspend), 0) * 60).append(" ");
}
- public void setResourceMonitor( String resourceMonitor ) {
- this.resourceMonitor = resourceMonitor;
- }
+ sql.append("AUTO_RESUME = ").append(autoResume).append(" ");
+ sql.append("INITIALLY_SUSPENDED = ").append(initiallySuspended).append(" ");
- public String getComment() {
- return comment;
+ if (!StringUtil.isEmpty(resolve(resourceMonitor))) {
+ sql.append("RESOURCE_MONITOR = '").append(resolve(resourceMonitor)).append("' ");
}
- public void setComment( String comment ) {
- this.comment = comment;
+ if (!StringUtil.isEmpty(resolve(comment))) {
+ sql.append("COMMENT = \"").append(comment.replaceAll("\"", "\"\"")).append("\" ");
}
- @Override
- public String getXml() {
- StringBuffer returnValue = new StringBuffer( 300 );
-
- returnValue.append( super.getXml() );
- returnValue.append( " " ).append(
- XmlHandler.addTagValue( CONNECTION, databaseMeta == null ? null : databaseMeta.getName() ) );
- returnValue.append( " " ).append( XmlHandler.addTagValue( MANAGEMENT_ACTION, getManagementAction() ) ); //$NON-NLS-1$ //$NON-NLS-2$
- returnValue.append( " " ).append( XmlHandler.addTagValue( REPLACE, isReplace() ) ); //$NON-NLS-1$ //$NON-NLS-2$
- returnValue.append( " " ).append( XmlHandler.addTagValue( FAIL_IF_EXISTS, isFailIfExists() ) ); //$NON-NLS-1$ //$NON-NLS-2$
- returnValue.append( " " ).append( XmlHandler.addTagValue( WAREHOUSE_NAME, getWarehouseName() ) ); //$NON-NLS-1$ //$NON-NLS-2$
- returnValue.append( " " ).append( XmlHandler.addTagValue( WAREHOUSE_SIZE, getWarehouseSize() ) ); //$NON-NLS-1$ //$NON-NLS-2$
- returnValue.append( " " ).append( XmlHandler.addTagValue( WAREHOUSE_TYPE, getWarehouseType() ) ); //$NON-NLS-1$ //$NON-NLS-2$
- returnValue.append( " " ).append( XmlHandler.addTagValue( MAX_CLUSTER_COUNT, getMaxClusterCount() ) ); //$NON-NLS-1$ //$NON-NLS-2$
- returnValue.append( " " ).append( XmlHandler.addTagValue( MIN_CLUSTER_COUNT, getMinClusterCount() ) ); //$NON-NLS-1$ //$NON-NLS-2$
- returnValue.append( " " ).append( XmlHandler.addTagValue( AUTO_SUSPEND, getAutoSuspend() ) ); //$NON-NLS-1$ //$NON-NLS-2$
- returnValue.append( " " ).append( XmlHandler.addTagValue( AUTO_RESUME, isAutoResume() ) ); //$NON-NLS-1$ //$NON-NLS-2$
- returnValue.append( " " ).append( XmlHandler.addTagValue( INITIALLY_SUSPENDED, isInitiallySuspended() ) ); //$NON-NLS-1$ //$NON-NLS-2$
- returnValue.append( " " ).append( XmlHandler.addTagValue( RESOURCE_MONITOR, getResourceMonitor() ) ); //$NON-NLS-1$ //$NON-NLS-2$
- returnValue.append( " " ).append( XmlHandler.addTagValue( COMMENT, getComment() ) ); //$NON-NLS-1$ //$NON-NLS-2$
- returnValue.append( " " ).append( XmlHandler.addTagValue( FAIL_IF_NOT_EXISTS, isFailIfNotExists() ) );
-
- return returnValue.toString();
- }
+ sql.append(";\ncommit;");
+ return sql.toString();
+ }
- @Override
- public void loadXml(Node entryNode, IHopMetadataProvider metadataProvider, IVariables variables) throws HopXmlException {
- try {
- super.loadXml( entryNode);
- String dbname = XmlHandler.getTagValue( entryNode, CONNECTION );
- databaseMeta = DatabaseMeta.loadDatabase(metadataProvider, dbname);
-
- setManagementAction( XmlHandler.getTagValue( entryNode, MANAGEMENT_ACTION ) );
- setReplace( "Y".equalsIgnoreCase( XmlHandler.getTagValue( entryNode, REPLACE ) ) );
- setFailIfExists( "Y".equalsIgnoreCase( XmlHandler.getTagValue( entryNode, FAIL_IF_EXISTS ) ) );
- setWarehouseName( XmlHandler.getTagValue( entryNode, WAREHOUSE_NAME ) );
- setWarehouseSize( XmlHandler.getTagValue( entryNode, WAREHOUSE_SIZE ) );
- setWarehouseType( XmlHandler.getTagValue( entryNode, WAREHOUSE_TYPE ) );
- setMaxClusterCount( XmlHandler.getTagValue( entryNode, MAX_CLUSTER_COUNT ) );
- setMinClusterCount( XmlHandler.getTagValue( entryNode, MIN_CLUSTER_COUNT ) );
- setAutoSuspend( XmlHandler.getTagValue( entryNode, AUTO_SUSPEND ) );
- setAutoResume( "Y".equalsIgnoreCase( XmlHandler.getTagValue( entryNode, AUTO_RESUME ) ) );
- setInitiallySuspended( "Y".equalsIgnoreCase( XmlHandler.getTagValue( entryNode, INITIALLY_SUSPENDED ) ) );
- setResourceMonitor( XmlHandler.getTagValue( entryNode, RESOURCE_MONITOR ) );
- setComment( XmlHandler.getTagValue( entryNode, COMMENT ) );
- setFailIfNotExists( "Y".equalsIgnoreCase( XmlHandler.getTagValue( entryNode, FAIL_IF_NOT_EXISTS ) ) );
- } catch ( HopXmlException dbe ) {
- throw new HopXmlException( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Error.Exception.UnableLoadXML" ), dbe );
- }
+ private String getAlterSQL() {
+ StringBuilder sql = new StringBuilder();
+ sql.append("ALTER WAREHOUSE ");
+ if (!failIfNotExists) {
+ sql.append("IF EXISTS ");
}
+ sql.append(warehouseName).append(" SET ");
- public void clear() {
- super.clear();
-
- setManagementAction( null );
- setReplace( false );
- setFailIfExists( false );
- setWarehouseName( null );
- setWarehouseSize( null );
- setWarehouseType( null );
- setMaxClusterCount( null );
- setMinClusterCount( null );
- setAutoSuspend( null );
- setAutoResume( false );
- setInitiallySuspended( false );
- setResourceMonitor( null );
- setComment( null );
- setDatabaseMeta( null );
- setFailIfNotExists( true );
+ if (!StringUtil.isEmpty(resolve(warehouseSize))) {
+ sql.append("WAREHOUSE_SIZE = '").append(resolve(warehouseSize)).append("' ");
}
- public boolean validate() throws HopException {
- boolean result = true;
- if ( databaseMeta == null || StringUtil.isEmpty( databaseMeta.getName() ) ) {
- logError( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Validate.DatabaseIsEmpty" ) );
- result = false;
- } else if ( StringUtil.isEmpty( managementAction ) ) {
- logError( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Validate.ManagementAction" ) );
- result = false;
- } else if ( managementAction.equals( MANAGEMENT_ACTIONS[MANAGEMENT_ACTION_CREATE] ) ) {
- if ( !StringUtil.isEmpty( resolve( maxClusterCount ) )
- && Const.toInt( resolve( maxClusterCount ), -1 ) <= 0 ) {
-
- logError( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Validate.MaxClusterCount",
- resolve( maxClusterCount ) ) );
- return false;
- }
-
- if ( !StringUtil.isEmpty( resolve( minClusterCount ) )
- && Const.toInt( resolve( minClusterCount ), -1 ) < 0 ) {
-
- logError( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Validate.MinClusterCount",
- resolve( minClusterCount ) ) );
- return false;
- }
-
- if ( !StringUtil.isEmpty( resolve( autoSuspend ) )
- && Const.toInt( resolve( autoSuspend ), -1 ) < 0 ) {
- logError( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Validate.AutoSuspend",
- resolve( autoSuspend ) ) );
- return false;
- }
- }
- return result;
+ if (!StringUtil.isEmpty(resolve(warehouseType))) {
+ sql.append("WAREHOUSE_TYPE = ").append(resolve(warehouseType)).append(" ");
}
- public Result execute(Result previousResult, int nr ) throws HopException {
-
- Result result = previousResult;
- result.setResult( validate() );
- if ( !result.getResult() ) {
- return result;
- }
-
- Database db = null;
- try {
- db = new Database( this, this, databaseMeta );
- String SQL = null;
- String successMessage = null;
-
- if ( managementAction.equals( MANAGEMENT_ACTIONS[MANAGEMENT_ACTION_CREATE] ) ) {
- SQL = getCreateSQL();
- successMessage = BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Log.Create.Success" );
- } else if ( managementAction.equals( MANAGEMENT_ACTIONS[MANAGEMENT_ACTION_DROP] ) ) {
- SQL = getDropSQL();
- successMessage = BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Log.Drop.Success" );
- } else if ( managementAction.equals( MANAGEMENT_ACTIONS[MANAGEMENT_ACTION_RESUME] ) ) {
- SQL = getResumeSQL();
- successMessage = BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Log.Resume.Success" );
- } else if ( managementAction.equals( MANAGEMENT_ACTIONS[MANAGEMENT_ACTION_SUSPEND] ) ) {
- SQL = getSuspendSQL();
- successMessage = BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Log.Suspend.Success" );
- } else if ( managementAction.equals( MANAGEMENT_ACTIONS[MANAGEMENT_ACTION_ALTER] ) ) {
- SQL = getAlterSQL();
- successMessage = BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Log.Alter.Success" );
- }
-
- if ( SQL == null ) {
- throw new HopException( "Unable to generate action, could not find action type" );
- }
-
- db.connect();
- logDebug( "Executing SQL " + SQL );
- db.execStatements( SQL );
- logBasic( successMessage );
-
- } catch( Exception ex ) {
- logError( "Error managing warehouse", ex );
- result.setResult( false );
- } finally {
- try {
- if ( db != null ) {
- db.disconnect();
- }
- } catch ( Exception ex ) {
- logError( "Unable to disconnect from database", ex );
- }
- }
-
- return result;
-
+ if (!StringUtil.isEmpty(resolve(maxClusterCount))) {
+ sql.append("MAX_CLUSTER_COUNT = ").append(resolve(maxClusterCount)).append(" ");
}
- private String getDropSQL() {
- StringBuilder sql = new StringBuilder();
- sql.append( "DROP WAREHOUSE " );
- if ( !failIfNotExists ) {
- sql.append( "IF EXISTS " );
- }
- sql.append( resolve( warehouseName ) ).append( ";\ncommit;" );
- return sql.toString();
- }
-
- private String getResumeSQL() {
- StringBuilder sql = new StringBuilder();
- sql.append( "ALTER WAREHOUSE " );
- if ( !failIfNotExists ) {
- sql.append( "IF EXISTS " );
- }
- sql.append( resolve( warehouseName ) ).append( " RESUME;\ncommit;" );
- return sql.toString();
+ if (!StringUtil.isEmpty(resolve(minClusterCount))) {
+ sql.append("MIN_CLUSTER_COUNT = ").append(resolve(minClusterCount)).append(" ");
}
- private String getSuspendSQL() {
- StringBuilder sql = new StringBuilder();
- sql.append( "ALTER WAREHOUSE " );
- if ( !failIfNotExists ) {
- sql.append( "IF EXISTS " );
- }
- sql.append( resolve( warehouseName ) ).append( " SUSPEND;\ncommit;" );
- return sql.toString();
+ if (!StringUtil.isEmpty(resolve(autoSuspend))) {
+ sql.append("AUTO_SUSPEND = ").append(Const.toInt(resolve(autoSuspend), 0) * 60).append(" ");
}
- private String getCreateSQL() {
- StringBuilder sql = new StringBuilder();
- sql.append( "CREATE " );
- if ( replace ) {
- sql.append( "OR REPLACE " );
- }
- sql.append( "WAREHOUSE " );
- if ( !failIfExists && !replace ) {
- sql.append( "IF NOT EXISTS " );
- }
- sql.append( warehouseName ).append( " WITH " );
-
- if ( !StringUtil.isEmpty( resolve( warehouseSize ) ) ) {
- sql.append( "WAREHOUSE_SIZE = '" ).append( resolve( warehouseSize ) ).append( "' " );
- }
-
- if ( !StringUtil.isEmpty( resolve( warehouseType ) ) ) {
- sql.append( "WAREHOUSE_TYPE = " ).append( resolve( warehouseType ) ).append( " " );
- }
-
- if ( !StringUtil.isEmpty( resolve( maxClusterCount ) ) ) {
- sql.append( "MAX_CLUSTER_COUNT = " ).append( resolve( maxClusterCount ) ).append( " " );
- }
-
- if ( !StringUtil.isEmpty( resolve( minClusterCount ) ) ) {
- sql.append( "MIN_CLUSTER_COUNT = " ).append(resolve( minClusterCount ) ).append( " " );
- }
-
- if ( !StringUtil.isEmpty( resolve( autoSuspend ) ) ) {
- sql.append( "AUTO_SUSPEND = " ).append( Const.toInt(resolve( autoSuspend ), 0 ) * 60 ).append( " " );
- }
-
- sql.append( "AUTO_RESUME = " ).append( autoResume ).append( " " );
- sql.append( "INITIALLY_SUSPENDED = " ).append( initiallySuspended ).append( " " );
-
- if ( !StringUtil.isEmpty( resolve( resourceMonitor ) ) ) {
- sql.append( "RESOURCE_MONITOR = '" ).append( resolve( resourceMonitor ) ).append( "' " );
- }
-
- if ( !StringUtil.isEmpty( resolve( comment ) ) ) {
- sql.append( "COMMENT = \"" ).append( comment.replaceAll( "\"", "\"\"" ) ).append( "\" " );
- }
+ sql.append("AUTO_RESUME = ").append(autoResume).append(" ");
- sql.append( ";\ncommit;" );
- return sql.toString();
+ if (!StringUtil.isEmpty(resolve(resourceMonitor))) {
+ sql.append("RESOURCE_MONITOR = '").append(resolve(resourceMonitor)).append("' ");
}
- private String getAlterSQL() {
- StringBuilder sql = new StringBuilder();
- sql.append( "ALTER WAREHOUSE " );
- if ( !failIfNotExists ) {
- sql.append( "IF EXISTS " );
- }
- sql.append( warehouseName ).append( " SET " );
-
- if ( !StringUtil.isEmpty(resolve( warehouseSize ) ) ) {
- sql.append( "WAREHOUSE_SIZE = '" ).append( resolve( warehouseSize ) ).append( "' " );
- }
-
- if ( !StringUtil.isEmpty( resolve( warehouseType ) ) ) {
- sql.append( "WAREHOUSE_TYPE = " ).append( resolve( warehouseType ) ).append( " " );
- }
-
- if ( !StringUtil.isEmpty( resolve( maxClusterCount ) ) ) {
- sql.append( "MAX_CLUSTER_COUNT = " ).append( resolve( maxClusterCount ) ).append( " " );
- }
-
- if ( !StringUtil.isEmpty( resolve( minClusterCount ) ) ) {
- sql.append( "MIN_CLUSTER_COUNT = " ).append( resolve( minClusterCount ) ).append( " " );
- }
-
- if ( !StringUtil.isEmpty( resolve( autoSuspend ) ) ) {
- sql.append( "AUTO_SUSPEND = " ).append( Const.toInt(resolve( autoSuspend ), 0 ) * 60 ).append( " " );
- }
-
- sql.append( "AUTO_RESUME = " ).append( autoResume ).append( " " );
-
- if ( !StringUtil.isEmpty( resolve( resourceMonitor ) ) ) {
- sql.append( "RESOURCE_MONITOR = '" ).append( resolve( resourceMonitor ) ).append( "' " );
- }
-
- if ( !StringUtil.isEmpty( resolve( comment ) ) ) {
- sql.append( "COMMENT = \"" ).append( comment.replaceAll( "\"", "\"\"" ) ).append( "\" " );
- }
-
- sql.append( ";\ncommit;" );
- return sql.toString();
+ if (!StringUtil.isEmpty(resolve(comment))) {
+ sql.append("COMMENT = \"").append(comment.replaceAll("\"", "\"\"")).append("\" ");
}
+ sql.append(";\ncommit;");
+ return sql.toString();
+ }
- public boolean evaluates() {
- return true;
- }
+ public boolean evaluates() {
+ return true;
+ }
- public boolean isUnconditional() {
- return true;
- }
+ @Override
+ public boolean isUnconditional() {
+ return true;
+ }
- @Override
- public void check(List<ICheckResult> remarks, WorkflowMeta workflowMeta,
- IVariables variables, IHopMetadataProvider metadataProvider) {
- andValidator().validate( this, CONNECTION, remarks, putValidators( notBlankValidator() ) );
- andValidator().validate( this, WAREHOUSE_NAME, remarks, putValidators( notBlankValidator() ) );
- andValidator().validate( this, MANAGEMENT_ACTION, remarks, putValidators( notBlankValidator() ) );
- }
+ @Override
+ public void check(
+ List<ICheckResult> remarks,
+ WorkflowMeta workflowMeta,
+ IVariables variables,
+ IHopMetadataProvider metadataProvider) {
+ andValidator().validate(this, CONNECTION, remarks, putValidators(notBlankValidator()));
+ andValidator().validate(this, WAREHOUSE_NAME, remarks, putValidators(notBlankValidator()));
+ andValidator().validate(this, MANAGEMENT_ACTION, remarks, putValidators(notBlankValidator()));
+ }
}
diff --git a/plugins/actions/snowflake/src/main/java/org/apache/hop/workflow/actions/snowflake/WarehouseManagerDialog.java b/plugins/actions/snowflake/src/main/java/org/apache/hop/workflow/actions/snowflake/WarehouseManagerDialog.java
index f059d801f3..b112b60852 100644
--- a/plugins/actions/snowflake/src/main/java/org/apache/hop/workflow/actions/snowflake/WarehouseManagerDialog.java
+++ b/plugins/actions/snowflake/src/main/java/org/apache/hop/workflow/actions/snowflake/WarehouseManagerDialog.java
@@ -41,1167 +41,1149 @@ import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.program.Program;
import org.eclipse.swt.widgets.*;
import java.sql.ResultSet;
-@SuppressWarnings( "FieldCanBeLocal" )
+@SuppressWarnings("FieldCanBeLocal")
public class WarehouseManagerDialog extends ActionDialog implements IActionDialog {
- private static Class<?> PKG = WarehouseManager.class; // for i18n purposes, needed by Translator2!! $NON-NLS-1$
+ private static final Class<?> PKG =
+ WarehouseManager.class; // for i18n purposes, needed by Translator2!! $NON-NLS-1$
- private static final String[] MANAGEMENT_ACTION_DESCS = new String[]{
- BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Action.Create" ),
- BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Action.Drop" ),
- BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Action.Resume" ),
- BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Action.Suspend" ),
- BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Action.Alter" )
- };
+ private static final String[] MANAGEMENT_ACTION_DESCS =
+ new String[] {
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Action.Create"),
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Action.Drop"),
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Action.Resume"),
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Action.Suspend"),
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Action.Alter")
+ };
- private static final String[] WAREHOUSE_SIZE_DESCS = new String[]{
- BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Size.Xsmall" ),
- BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Size.Small" ),
- BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Size.Medium" ),
- BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Size.Large" ),
- BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Size.Xlarge" ),
- BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Size.Xxlarge" ),
- BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Size.Xxxlarge" )
- };
+ private static final String[] WAREHOUSE_SIZE_DESCS =
+ new String[] {
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Size.Xsmall"),
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Size.Small"),
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Size.Medium"),
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Size.Large"),
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Size.Xlarge"),
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Size.Xxlarge"),
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Size.Xxxlarge")
+ };
- private static final String[] WAREHOUSE_TYPE_DESCS = new String[]{
- BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Type.Standard" ),
- BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Type.Enterprise" )
- };
+ private static final String[] WAREHOUSE_TYPE_DESCS =
+ new String[] {
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Type.Standard"),
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Type.Enterprise")
+ };
- private WarehouseManager warehouseManager;
+ private WarehouseManager warehouseManager;
- /**
- * Action name line
- */
- private Label wlName;
- private Text wName;
- private FormData fdlName, fdName;
+ private Text wName;
- private MetaSelectionLine<DatabaseMeta> wConnection;
+ private MetaSelectionLine<DatabaseMeta> wConnection;
- private Label wlWarehouseName;
- private ComboVar wWarehouseName;
- private FormData fdlWarehouseName, fdWarehouseName;
+ private ComboVar wWarehouseName;
- private Label wlAction;
- private CCombo wAction;
- private FormData fdlAction, fdAction;
+ private CCombo wAction;
- private Group wCreateGroup;
- private FormData fdgCreateGroup;
+ private Group wCreateGroup;
- private Label wlCreateReplace;
- private Button wCreateReplace;
- private FormData fdlCreateReplace, fdCreateReplace;
+ private Button wCreateReplace;
- private Label wlCreateFailIfExists;
- private Button wCreateFailIfExists;
- private FormData fdlCreateFailIfExists, fdCreateFailIfExists;
+ private Button wCreateFailIfExists;
- private Label wlCreateWarehouseSize;
- private ComboVar wCreateWarehouseSize;
- private FormData fdlCreateWarehouseSize, fdCreateWarehouseSize;
+ private ComboVar wCreateWarehouseSize;
- private Label wlCreateWarehouseType;
- private ComboVar wCreateWarehouseType;
- private FormData fdlCreateWarehouseType, fdCreateWarehouseType;
+ private ComboVar wCreateWarehouseType;
- private Label wlCreateMaxClusterSize;
- private TextVar wCreateMaxClusterSize;
- private FormData fdlCreateMaxClusterSize, fdCreateMaxClusterSize;
+ private TextVar wCreateMaxClusterSize;
- private Label wlCreateMinClusterSize;
- private TextVar wCreateMinClusterSize;
- private FormData fdlCreateMinClusterSize, fdCreateMinClusterSize;
+ private TextVar wCreateMinClusterSize;
- private Label wlCreateAutoSuspend;
- private TextVar wCreateAutoSuspend;
- private FormData fdlCreateAutoSuspend, fdCreateAutoSuspend;
+ private TextVar wCreateAutoSuspend;
- private Label wlCreateAutoResume;
- private Button wCreateAutoResume;
- private FormData fdlCreateAutoResume, fdCreateAutoResume;
+ private Button wCreateAutoResume;
- private Label wlCreateInitialSuspend;
- private Button wCreateInitialSuspend;
- private FormData fdlCreateInitialSuspend, fdCreateInitialSuspend;
+ private Button wCreateInitialSuspend;
- private Label wlCreateResourceMonitor;
- private ComboVar wCreateResourceMonitor;
- private FormData fdlCreateResourceMonitor, fdCreateResourceMonitor;
+ private ComboVar wCreateResourceMonitor;
- private Label wlCreateComment;
- private TextVar wCreateComment;
- private FormData fdlCreateComment, fdCreateComment;
+ private TextVar wCreateComment;
- private Group wDropGroup;
- private FormData fdgDropGroup;
+ private Group wDropGroup;
- private Label wlDropFailIfNotExists;
- private Button wDropFailIfNotExists;
- private FormData fdlDropFailIfNotExists, fdDropFailIfNotExists;
+ private Button wDropFailIfNotExists;
- private Group wResumeGroup;
- private FormData fdgResumeGroup;
+ private Group wResumeGroup;
- private Label wlResumeFailIfNotExists;
- private Button wResumeFailIfNotExists;
- private FormData fdlResumeFailIfNotExists, fdResumeFailIfNotExists;
+ private Button wResumeFailIfNotExists;
- private Group wSuspendGroup;
- private FormData fdgSuspendGroup;
+ private Group wSuspendGroup;
- private Label wlSuspendFailIfNotExists;
- private Button wSuspendFailIfNotExists;
- private FormData fdlSuspendFailIfNotExists, fdSuspendFailIfNotExists;
+ private Button wSuspendFailIfNotExists;
- private Group wAlterGroup;
- private FormData fdgAlterGroup;
+ private Group wAlterGroup;
- private Label wlAlterFailIfNotExists;
- private Button wAlterFailIfNotExists;
- private FormData fdlAlterFailIfNotExists, fdAlterFailIfNotExists;
+ private Button wAlterFailIfNotExists;
- private Label wlAlterWarehouseSize;
- private ComboVar wAlterWarehouseSize;
- private FormData fdlAlterWarehouseSize, fdAlterWarehouseSize;
+ private ComboVar wAlterWarehouseSize;
- private Label wlAlterWarehouseType;
- private ComboVar wAlterWarehouseType;
- private FormData fdlAlterWarehouseType, fdAlterWarehouseType;
+ private ComboVar wAlterWarehouseType;
- private Label wlAlterMaxClusterSize;
- private TextVar wAlterMaxClusterSize;
- private FormData fdlAlterMaxClusterSize, fdAlterMaxClusterSize;
+ private TextVar wAlterMaxClusterSize;
- private Label wlAlterMinClusterSize;
- private TextVar wAlterMinClusterSize;
- private FormData fdlAlterMinClusterSize, fdAlterMinClusterSize;
+ private TextVar wAlterMinClusterSize;
- private Label wlAlterAutoSuspend;
- private TextVar wAlterAutoSuspend;
- private FormData fdlAlterAutoSuspend, fdAlterAutoSuspend;
+ private TextVar wAlterAutoSuspend;
- private Label wlAlterAutoResume;
- private Button wAlterAutoResume;
- private FormData fdlAlterAutoResume, fdAlterAutoResume;
+ private Button wAlterAutoResume;
- private Label wlAlterResourceMonitor;
- private ComboVar wAlterResourceMonitor;
- private FormData fdlAlterResourceMonitor, fdAlterResourceMonitor;
+ private ComboVar wAlterResourceMonitor;
- private Label wlAlterComment;
- private TextVar wAlterComment;
- private FormData fdlAlterComment, fdAlterComment;
+ private TextVar wAlterComment;
- private Button wOK, wCancel;
+ private boolean backupChanged;
- private Listener lsOK, lsCancel;
+ private Shell shell;
- private boolean backupChanged;
+ public WarehouseManagerDialog(
+ Shell parent, IAction action, WorkflowMeta workflowMeta, IVariables variables) {
+ super(parent, workflowMeta, variables);
+ warehouseManager = (WarehouseManager) action;
+ }
- private Display display;
- private Shell shell;
+ public IAction open() {
+ Shell parent = getParent();
+ Display display = parent.getDisplay();
- public WarehouseManagerDialog(Shell parent, IAction action, WorkflowMeta workflowMeta, IVariables variables ) {
- super( parent, workflowMeta, variables );
- warehouseManager = (WarehouseManager) action;
- }
+ shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.MAX | SWT.RESIZE);
+ props.setLook(shell);
+ WorkflowDialog.setShellImage(shell, warehouseManager);
- public IAction open() {
- Shell parent = getParent();
- display = parent.getDisplay();
-
- shell = new Shell( parent, SWT.DIALOG_TRIM| SWT.MIN | SWT.MAX | SWT.RESIZE );
- props.setLook( shell );
- WorkflowDialog.setShellImage( shell, warehouseManager);
-
- backupChanged = warehouseManager.hasChanged();
-
- FormLayout formLayout = new FormLayout();
- formLayout.marginWidth = Const.FORM_MARGIN;
- formLayout.marginHeight = Const.FORM_MARGIN;
-
- shell.setLayout( formLayout );
- shell.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Title" ) );
-
- int middle = props.getMiddlePct();
- int margin = Const.MARGIN;
-
- // Name line
- wlName = new Label( shell, SWT.RIGHT );
- wlName.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Name.Label" ) );
- props.setLook( wlName );
- fdlName = new FormData();
- fdlName.left = new FormAttachment( 0, 0 );
- fdlName.top = new FormAttachment( 0, 0 );
- fdlName.right = new FormAttachment( middle, 0 );
- wlName.setLayoutData( fdlName );
-
- wName = new Text( shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- props.setLook( wName );
- fdName = new FormData();
- fdName.top = new FormAttachment( 0, 0 );
- fdName.left = new FormAttachment( middle, margin );
- fdName.right = new FormAttachment( 100, 0 );
- wName.setLayoutData( fdName );
-
- // Connection line
- wConnection = addConnectionLine( shell, wName, warehouseManager.getDatabaseMeta(), null );
- if ( warehouseManager.getDatabaseMeta() == null && workflowMeta.nrDatabases() == 1 ) {
- wConnection.select( 0 );
- }
+ backupChanged = warehouseManager.hasChanged();
- // Warehouse name line
- //
- wlWarehouseName = new Label( shell, SWT.RIGHT );
- wlWarehouseName.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.WarehouseName.Label" ) );
- props.setLook( wlWarehouseName );
- fdlWarehouseName = new FormData();
- fdlWarehouseName.left = new FormAttachment( 0, 0 );
- fdlWarehouseName.top = new FormAttachment( wConnection, margin * 2 );
- fdlWarehouseName.right = new FormAttachment( middle, -margin );
- wlWarehouseName.setLayoutData( fdlWarehouseName );
-
- wWarehouseName = new ComboVar( variables, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- props.setLook( wWarehouseName );
- fdWarehouseName = new FormData();
- fdWarehouseName.left = new FormAttachment( middle, 0 );
- fdWarehouseName.top = new FormAttachment( wConnection, margin * 2 );
- fdWarehouseName.right = new FormAttachment( 100, 0 );
- wWarehouseName.setLayoutData( fdWarehouseName );
- wWarehouseName.addFocusListener( new FocusAdapter() {
- /**
- * Get the list of stages for the schema, and populate the stage name drop down.
- *
- * @param focusEvent The event
- */
- @Override
- public void focusGained( FocusEvent focusEvent ) {
- DatabaseMeta databaseMeta = workflowMeta.findDatabase( wConnection.getText(), variables);
- if ( databaseMeta != null ) {
- String warehouseName = wWarehouseName.getText();
- wWarehouseName.removeAll();
- Database db = null;
- try {
- db = new Database( loggingObject, variables, databaseMeta );
- db.connect();
- ResultSet resultSet = db.openQuery( "show warehouses;", null, null, ResultSet.FETCH_FORWARD, false );
- IRowMeta rowMeta = db.getReturnRowMeta();
- Object[] row = db.getRow( resultSet );
- int nameField = rowMeta.indexOfValue( "NAME" );
- if ( nameField >= 0 ) {
- while ( row != null ) {
- String name = rowMeta.getString( row, nameField );
- wWarehouseName.add( name );
- row = db.getRow( resultSet );
- }
- } else {
- throw new HopException( "Unable to find warehouse name field in result" );
- }
- db.closeQuery( resultSet );
- if ( warehouseName != null ) {
- wWarehouseName.setText( warehouseName );
- }
- } catch ( Exception ex ) {
- warehouseManager.logDebug( "Error getting warehouses", ex );
- } finally {
- db.disconnect();
- }
- }
+ FormLayout formLayout = new FormLayout();
+ formLayout.marginWidth = Const.FORM_MARGIN;
+ formLayout.marginHeight = Const.FORM_MARGIN;
- }
- } );
-
-
- // ///////////////////
- // Action line
- // ///////////////////
- wlAction = new Label( shell, SWT.RIGHT );
- wlAction.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Action.Label" ) );
- props.setLook( wlAction );
- fdlAction = new FormData();
- fdlAction.left = new FormAttachment( 0, 0 );
- fdlAction.right = new FormAttachment( middle, -margin );
- fdlAction.top = new FormAttachment( wWarehouseName, margin );
- wlAction.setLayoutData( fdlAction );
-
- wAction = new CCombo( shell, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER );
- wAction.setItems( MANAGEMENT_ACTION_DESCS );
- props.setLook( wAction );
- fdAction = new FormData();
- fdAction.left = new FormAttachment( middle, 0 );
- fdAction.top = new FormAttachment( wWarehouseName, margin );
- fdAction.right = new FormAttachment( 100, 0 );
- wAction.setLayoutData( fdAction );
- wAction.addSelectionListener( new SelectionAdapter() {
- @Override
- public void widgetSelected( SelectionEvent selectionEvent ) {
- setFlags();
- }
- } );
-
- /////////////////////
- // Start Create Warehouse Group
- /////////////////////
- wCreateGroup = new Group( shell, SWT.SHADOW_ETCHED_IN );
- wCreateGroup.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Group.CreateWarehouse.Label" ) );
- FormLayout createWarehouseLayout = new FormLayout();
- createWarehouseLayout.marginWidth = 3;
- createWarehouseLayout.marginHeight = 3;
- wCreateGroup.setLayout( createWarehouseLayout );
- props.setLook( wCreateGroup );
-
- fdgCreateGroup = new FormData();
- fdgCreateGroup.left = new FormAttachment( 0, 0 );
- fdgCreateGroup.right = new FormAttachment( 100, 0 );
- fdgCreateGroup.top = new FormAttachment( wAction, margin * 2 );
- // fdgCreateGroup.bottom = new FormAttachment( 100, -margin * 2 );
- wCreateGroup.setLayoutData( fdgCreateGroup );
-
- // //////////////////////
- // Replace line
- // /////////////////////
- wlCreateReplace = new Label( wCreateGroup, SWT.RIGHT );
- wlCreateReplace.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Create.Replace.Label" ) );
- wlCreateReplace.setToolTipText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Create.Replace.Tooltip" ) );
- props.setLook( wlCreateReplace );
- fdlCreateReplace = new FormData();
- fdlCreateReplace.left = new FormAttachment( 0, 0 );
- fdlCreateReplace.top = new FormAttachment( 0, margin * 2);
- fdlCreateReplace.right = new FormAttachment( middle, -margin );
- wlCreateReplace.setLayoutData( fdlCreateReplace );
-
- wCreateReplace = new Button( wCreateGroup, SWT.CHECK );
- props.setLook( wCreateReplace );
- fdCreateReplace = new FormData();
- fdCreateReplace.left = new FormAttachment( middle, 0 );
- fdCreateReplace.top = new FormAttachment( 0, margin * 2);
- fdCreateReplace.right = new FormAttachment( 100, 0 );
- wCreateReplace.setLayoutData( fdCreateReplace );
- wCreateReplace.addListener( SWT.Selection, e -> warehouseManager.setChanged() );
- wCreateReplace.addListener(SWT.Selection, e -> setFlags() );
-
- // /////////////////////
- // Fail if exists line
- // /////////////////////
- wlCreateFailIfExists = new Label( wCreateGroup, SWT.RIGHT );
- wlCreateFailIfExists.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Create.FailIfExists.Label" ) );
- props.setLook( wlCreateFailIfExists );
- fdlCreateFailIfExists = new FormData();
- fdlCreateFailIfExists.left = new FormAttachment( 0, 0 );
- fdlCreateFailIfExists.top = new FormAttachment( wCreateReplace, margin * 2);
- fdlCreateFailIfExists.right = new FormAttachment( middle, -margin );
- wlCreateFailIfExists.setLayoutData( fdlCreateFailIfExists );
-
- wCreateFailIfExists = new Button( wCreateGroup, SWT.CHECK );
- props.setLook( wCreateFailIfExists );
- fdCreateFailIfExists = new FormData();
- fdCreateFailIfExists.left = new FormAttachment( middle, 0 );
- fdCreateFailIfExists.top = new FormAttachment( wCreateReplace, margin * 2);
- fdCreateFailIfExists.right = new FormAttachment( 100, 0 );
- wCreateFailIfExists.setLayoutData( fdCreateFailIfExists );
- wCreateFailIfExists.addListener(SWT.Selection, e -> warehouseManager.setChanged() );
-
- // Warehouse Size
- //
- wlCreateWarehouseSize = new Label( wCreateGroup, SWT.RIGHT );
- wlCreateWarehouseSize.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.CreateWarehouseSize.Label" ) );
- props.setLook( wlCreateWarehouseSize );
- fdlCreateWarehouseSize = new FormData();
- fdlCreateWarehouseSize.left = new FormAttachment( 0, 0 );
- fdlCreateWarehouseSize.top = new FormAttachment( wCreateFailIfExists, margin * 2);
- fdlCreateWarehouseSize.right = new FormAttachment( middle, -margin );
- wlCreateWarehouseSize.setLayoutData( fdlCreateWarehouseSize );
-
- wCreateWarehouseSize = new ComboVar( variables, wCreateGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- props.setLook( wCreateWarehouseSize );
- wCreateWarehouseSize.addListener(SWT.Modify, e -> warehouseManager.setChanged());
- fdCreateWarehouseSize = new FormData();
- fdCreateWarehouseSize.left = new FormAttachment( middle, 0 );
- fdCreateWarehouseSize.top = new FormAttachment( wCreateFailIfExists, margin * 2);
- fdCreateWarehouseSize.right = new FormAttachment( 100, 0 );
- wCreateWarehouseSize.setLayoutData( fdCreateWarehouseSize );
- wCreateWarehouseSize.setItems( WAREHOUSE_SIZE_DESCS );
-
- // Warehouse Type
- //
- wlCreateWarehouseType = new Label( wCreateGroup, SWT.RIGHT );
- wlCreateWarehouseType.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.CreateWarehouseType.Label" ) );
- props.setLook( wlCreateWarehouseType );
- fdlCreateWarehouseType = new FormData();
- fdlCreateWarehouseType.left = new FormAttachment( 0, 0 );
- fdlCreateWarehouseType.top = new FormAttachment( wCreateWarehouseSize, margin * 2);
- fdlCreateWarehouseType.right = new FormAttachment( middle, -margin );
- wlCreateWarehouseType.setLayoutData( fdlCreateWarehouseType );
-
- wCreateWarehouseType = new ComboVar( variables, wCreateGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- props.setLook( wCreateWarehouseType );
- wCreateWarehouseType.addListener(SWT.Modify, e -> warehouseManager.setChanged() );
- fdCreateWarehouseType = new FormData();
- fdCreateWarehouseType.left = new FormAttachment( middle, 0 );
- fdCreateWarehouseType.top = new FormAttachment( wCreateWarehouseSize, margin * 2);
- fdCreateWarehouseType.right = new FormAttachment( 100, 0 );
- wCreateWarehouseType.setLayoutData( fdCreateWarehouseType );
- wCreateWarehouseType.setItems( WAREHOUSE_TYPE_DESCS );
-
- // /////////////////////
- // Max Cluster Size
- // /////////////////////
- wlCreateMaxClusterSize = new Label( wCreateGroup, SWT.RIGHT );
- wlCreateMaxClusterSize.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Create.MaxClusterSize.Label" ) );
- props.setLook( wlCreateMaxClusterSize );
- fdlCreateMaxClusterSize = new FormData();
- fdlCreateMaxClusterSize.left = new FormAttachment( 0, 0 );
- fdlCreateMaxClusterSize.top = new FormAttachment( wCreateWarehouseType, margin * 2);
- fdlCreateMaxClusterSize.right = new FormAttachment( middle, -margin );
- wlCreateMaxClusterSize.setLayoutData( fdlCreateMaxClusterSize );
-
- wCreateMaxClusterSize = new TextVar( variables, wCreateGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- props.setLook( wCreateGroup );
- wCreateMaxClusterSize.addListener(SWT.Modify, e -> warehouseManager.setChanged() );
- fdCreateMaxClusterSize = new FormData();
- fdCreateMaxClusterSize.left = new FormAttachment( middle, 0 );
- fdCreateMaxClusterSize.right = new FormAttachment( 100, 0 );
- fdCreateMaxClusterSize.top = new FormAttachment( wCreateWarehouseType, margin * 2);
- wCreateMaxClusterSize.setLayoutData( fdCreateMaxClusterSize );
-
- // /////////////////////
- // Min Cluster Size
- // /////////////////////
- wlCreateMinClusterSize = new Label( wCreateGroup, SWT.RIGHT );
- wlCreateMinClusterSize.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Create.MinClusterSize.Label" ) );
- props.setLook( wlCreateMinClusterSize );
- fdlCreateMinClusterSize = new FormData();
- fdlCreateMinClusterSize.left = new FormAttachment( 0, 0 );
- fdlCreateMinClusterSize.top = new FormAttachment( wCreateMaxClusterSize, margin * 2 );
- fdlCreateMinClusterSize.right = new FormAttachment( middle, -margin );
- wlCreateMinClusterSize.setLayoutData( fdlCreateMinClusterSize );
-
- wCreateMinClusterSize = new TextVar( variables, wCreateGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- props.setLook( wCreateGroup );
- wCreateMinClusterSize.addListener(SWT.Modify, e -> warehouseManager.setChanged());
- fdCreateMinClusterSize = new FormData();
- fdCreateMinClusterSize.left = new FormAttachment( middle, 0 );
- fdCreateMinClusterSize.right = new FormAttachment( 100, 0 );
- fdCreateMinClusterSize.top = new FormAttachment( wCreateMaxClusterSize, margin * 2);
- wCreateMinClusterSize.setLayoutData( fdCreateMinClusterSize );
-
- // /////////////////////
- // Auto Suspend Size
- // /////////////////////
- wlCreateAutoSuspend = new Label( wCreateGroup, SWT.RIGHT );
- wlCreateAutoSuspend.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Create.AutoSuspend.Label" ) );
- wlCreateAutoSuspend.setToolTipText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Create.AutoSuspend.Tooltip" ) );
- props.setLook( wlCreateAutoSuspend );
- fdlCreateAutoSuspend = new FormData();
- fdlCreateAutoSuspend.left = new FormAttachment( 0, 0 );
- fdlCreateAutoSuspend.top = new FormAttachment( wCreateMinClusterSize, margin * 2);
- fdlCreateAutoSuspend.right = new FormAttachment( middle, -margin );
- wlCreateAutoSuspend.setLayoutData( fdlCreateAutoSuspend );
-
- wCreateAutoSuspend = new TextVar( variables, wCreateGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- props.setLook( wCreateGroup );
- wCreateAutoSuspend.addListener(SWT.Modify, e -> warehouseManager.setChanged() );
- fdCreateAutoSuspend = new FormData();
- fdCreateAutoSuspend.left = new FormAttachment( middle, 0 );
- fdCreateAutoSuspend.right = new FormAttachment( 100, 0 );
- fdCreateAutoSuspend.top = new FormAttachment( wCreateMinClusterSize, margin * 2);
- wCreateAutoSuspend.setLayoutData( fdCreateAutoSuspend );
-
- // /////////////////////
- // Auto-resume
- // /////////////////////
- wlCreateAutoResume = new Label( wCreateGroup, SWT.RIGHT );
- wlCreateAutoResume.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Create.AutoResume.Label" ) );
- props.setLook( wlCreateAutoResume );
- fdlCreateAutoResume = new FormData();
- fdlCreateAutoResume.left = new FormAttachment( 0, 0 );
- fdlCreateAutoResume.top = new FormAttachment( wCreateAutoSuspend, margin * 2);
- fdlCreateAutoResume.right = new FormAttachment( middle, -margin );
- wlCreateAutoResume.setLayoutData( fdlCreateAutoResume );
-
- wCreateAutoResume = new Button( wCreateGroup, SWT.CHECK );
- props.setLook( wCreateAutoResume );
- fdCreateAutoResume = new FormData();
- fdCreateAutoResume.left = new FormAttachment( middle, 0 );
- fdCreateAutoResume.top = new FormAttachment( wCreateAutoSuspend, margin * 2);
- fdCreateAutoResume.right = new FormAttachment( 100, 0 );
- wCreateAutoResume.setLayoutData( fdCreateAutoResume );
- wCreateAutoResume.addListener(SWT.Selection, e -> warehouseManager.setChanged());
-
- // /////////////////////
- // Auto-resume
- // /////////////////////
- wlCreateInitialSuspend = new Label( wCreateGroup, SWT.RIGHT );
- wlCreateInitialSuspend.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Create.InitialSuspend.Label" ) );
- wlCreateInitialSuspend.setToolTipText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Create.InitialSuspend.Tooltip" ) );
- props.setLook( wlCreateInitialSuspend );
- fdlCreateInitialSuspend = new FormData();
- fdlCreateInitialSuspend.left = new FormAttachment( 0, 0 );
- fdlCreateInitialSuspend.top = new FormAttachment( wCreateAutoResume, margin * 2);
- fdlCreateInitialSuspend.right = new FormAttachment( middle, -margin );
- wlCreateInitialSuspend.setLayoutData( fdlCreateInitialSuspend );
-
- wCreateInitialSuspend = new Button( wCreateGroup, SWT.CHECK );
- props.setLook( wCreateInitialSuspend );
- fdCreateInitialSuspend = new FormData();
- fdCreateInitialSuspend.left = new FormAttachment( middle, 0 );
- fdCreateInitialSuspend.top = new FormAttachment( wCreateAutoResume, margin * 2);
- fdCreateInitialSuspend.right = new FormAttachment( 100, 0 );
- wCreateInitialSuspend.setLayoutData( fdCreateInitialSuspend );
- wCreateInitialSuspend.addListener(SWT.Selection, e -> warehouseManager.setChanged());
-
- // Resource monitor line
- //
- wlCreateResourceMonitor = new Label( wCreateGroup, SWT.RIGHT );
- wlCreateResourceMonitor.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.ResourceMonitor.Label" ) );
- props.setLook( wlCreateResourceMonitor );
- fdlCreateResourceMonitor = new FormData();
- fdlCreateResourceMonitor.left = new FormAttachment( 0, 0 );
- fdlCreateResourceMonitor.top = new FormAttachment( wCreateInitialSuspend, margin * 2);
- fdlCreateResourceMonitor.right = new FormAttachment( middle, -margin );
- wlCreateResourceMonitor.setLayoutData( fdlCreateResourceMonitor );
-
- wCreateResourceMonitor = new ComboVar( variables, wCreateGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- props.setLook( wCreateResourceMonitor );
- wCreateResourceMonitor.addListener( SWT.Modify, e -> warehouseManager.setChanged());
- fdCreateResourceMonitor = new FormData();
- fdCreateResourceMonitor.left = new FormAttachment( middle, 0 );
- fdCreateResourceMonitor.top = new FormAttachment( wCreateInitialSuspend, margin * 2);
- fdCreateResourceMonitor.right = new FormAttachment( 100, 0 );
- wCreateResourceMonitor.setLayoutData( fdCreateResourceMonitor );
- wCreateResourceMonitor.addFocusListener( new FocusAdapter() {
- /**
- * Get the list of stages for the schema, and populate the stage name drop down.
- *
- * @param focusEvent The event
- */
- @SuppressWarnings( "Duplicates" )
- @Override
- public void focusGained( FocusEvent focusEvent ) {
- getResourceMonitors();
- }
- } );
-
- // /////////////////////
- //Comment Line
- // /////////////////////
- wlCreateComment = new Label( wCreateGroup, SWT.RIGHT );
- wlCreateComment.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Create.Comment.Label" ) );
- props.setLook( wlCreateComment );
- fdlCreateComment = new FormData();
- fdlCreateComment.left = new FormAttachment( 0, 0 );
- fdlCreateComment.top = new FormAttachment( wCreateResourceMonitor, margin * 2);
- fdlCreateComment.right = new FormAttachment( middle, -margin );
- wlCreateComment.setLayoutData( fdlCreateComment );
-
- wCreateComment = new TextVar( variables, wCreateGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- props.setLook( wCreateGroup );
- wCreateComment.addListener( SWT.Modify, e -> warehouseManager.setChanged() );
- fdCreateComment = new FormData();
- fdCreateComment.left = new FormAttachment( middle, 0 );
- fdCreateComment.right = new FormAttachment( 100, 0 );
- fdCreateComment.top = new FormAttachment( wCreateResourceMonitor, margin * 2);
- wCreateComment.setLayoutData( fdCreateComment );
-
- /////////////////////
- // Start Drop Warehouse Group
- /////////////////////
- wDropGroup = new Group( shell, SWT.SHADOW_ETCHED_IN );
- wDropGroup.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Group.DropWarehouse.Label" ) );
- FormLayout dropWarehouseLayout = new FormLayout();
- dropWarehouseLayout.marginWidth = 3;
- dropWarehouseLayout.marginHeight = 3;
- wDropGroup.setLayout( dropWarehouseLayout );
- props.setLook( wDropGroup );
-
- fdgDropGroup = new FormData();
- fdgDropGroup.left = new FormAttachment( 0, 0 );
- fdgDropGroup.right = new FormAttachment( 100, 0 );
- fdgDropGroup.top = new FormAttachment( wAction, margin * 2 );
- // fdgCreateGroup.bottom = new FormAttachment( 100, -margin * 2 );
- wDropGroup.setLayoutData( fdgDropGroup );
-
- // //////////////////////
- // Fail if Not exists line
- // /////////////////////
- wlDropFailIfNotExists = new Label( wDropGroup, SWT.RIGHT );
- wlDropFailIfNotExists.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Drop.FailIfNotExists.Label" ) );
- props.setLook( wlDropFailIfNotExists );
- fdlDropFailIfNotExists = new FormData();
- fdlDropFailIfNotExists.left = new FormAttachment( 0, 0 );
- fdlDropFailIfNotExists.top = new FormAttachment( 0, margin );
- fdlDropFailIfNotExists.right = new FormAttachment( middle, -margin );
- wlDropFailIfNotExists.setLayoutData( fdlDropFailIfNotExists );
-
- wDropFailIfNotExists = new Button( wDropGroup, SWT.CHECK );
- props.setLook( wDropFailIfNotExists );
- fdDropFailIfNotExists = new FormData();
- fdDropFailIfNotExists.left = new FormAttachment( middle, 0 );
- fdDropFailIfNotExists.top = new FormAttachment( 0, margin );
- fdDropFailIfNotExists.right = new FormAttachment( 100, 0 );
- wDropFailIfNotExists.setLayoutData( fdDropFailIfNotExists );
- wDropFailIfNotExists.addListener(SWT.Selection, e -> warehouseManager.setChanged() );
-
- /////////////////////
- // Start Resume Warehouse Group
- /////////////////////
- wResumeGroup = new Group( shell, SWT.SHADOW_ETCHED_IN );
- wResumeGroup.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Group.ResumeWarehouse.Label" ) );
- FormLayout resumeWarehouseLayout = new FormLayout();
- resumeWarehouseLayout.marginWidth = 3;
- resumeWarehouseLayout.marginHeight = 3;
- wResumeGroup.setLayout( resumeWarehouseLayout );
- props.setLook( wResumeGroup );
-
- fdgResumeGroup = new FormData();
- fdgResumeGroup.left = new FormAttachment( 0, 0 );
- fdgResumeGroup.right = new FormAttachment( 100, 0 );
- fdgResumeGroup.top = new FormAttachment( wAction, margin * 2 );
- // fdgCreateGroup.bottom = new FormAttachment( 100, -margin * 2 );
- wResumeGroup.setLayoutData( fdgResumeGroup );
-
- // //////////////////////
- // Fail if Not exists line
- // /////////////////////
- wlResumeFailIfNotExists = new Label( wResumeGroup, SWT.RIGHT );
- wlResumeFailIfNotExists.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Resume.FailIfNotExists.Label" ) );
- props.setLook( wlResumeFailIfNotExists );
- fdlResumeFailIfNotExists = new FormData();
- fdlResumeFailIfNotExists.left = new FormAttachment( 0, 0 );
- fdlResumeFailIfNotExists.top = new FormAttachment( 0, margin );
- fdlResumeFailIfNotExists.right = new FormAttachment( middle, -margin );
- wlResumeFailIfNotExists.setLayoutData( fdlResumeFailIfNotExists );
-
- wResumeFailIfNotExists = new Button( wResumeGroup, SWT.CHECK );
- props.setLook( wResumeFailIfNotExists );
- fdResumeFailIfNotExists = new FormData();
- fdResumeFailIfNotExists.left = new FormAttachment( middle, 0 );
- fdResumeFailIfNotExists.top = new FormAttachment( 0, margin );
- fdResumeFailIfNotExists.right = new FormAttachment( 100, 0 );
- wResumeFailIfNotExists.setLayoutData( fdResumeFailIfNotExists );
- wResumeFailIfNotExists.addListener(SWT.Selection, e -> warehouseManager.setChanged() );
-
-
- /////////////////////
- // Start Suspend Warehouse Group
- /////////////////////
- wSuspendGroup = new Group( shell, SWT.SHADOW_ETCHED_IN );
- wSuspendGroup.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Group.SuspendWarehouse.Label" ) );
- FormLayout suspendWarehouseLayout = new FormLayout();
- suspendWarehouseLayout.marginWidth = 3;
- suspendWarehouseLayout.marginHeight = 3;
- wSuspendGroup.setLayout( suspendWarehouseLayout );
- props.setLook( wSuspendGroup );
-
- fdgSuspendGroup = new FormData();
- fdgSuspendGroup.left = new FormAttachment( 0, 0 );
- fdgSuspendGroup.right = new FormAttachment( 100, 0 );
- fdgSuspendGroup.top = new FormAttachment( wAction, margin * 2 );
- // fdgCreateGroup.bottom = new FormAttachment( 100, -margin * 2 );
- wSuspendGroup.setLayoutData( fdgSuspendGroup );
-
- // //////////////////////
- // Fail if Not exists line
- // /////////////////////
- wlSuspendFailIfNotExists = new Label( wSuspendGroup, SWT.RIGHT );
- wlSuspendFailIfNotExists.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Suspend.FailIfNotExists.Label" ) );
- props.setLook( wlSuspendFailIfNotExists );
- fdlSuspendFailIfNotExists = new FormData();
- fdlSuspendFailIfNotExists.left = new FormAttachment( 0, 0 );
- fdlSuspendFailIfNotExists.top = new FormAttachment( 0, margin );
- fdlSuspendFailIfNotExists.right = new FormAttachment( middle, -margin );
- wlSuspendFailIfNotExists.setLayoutData( fdlSuspendFailIfNotExists );
-
- wSuspendFailIfNotExists = new Button( wSuspendGroup, SWT.CHECK );
- props.setLook( wSuspendFailIfNotExists );
- fdSuspendFailIfNotExists = new FormData();
- fdSuspendFailIfNotExists.left = new FormAttachment( middle, 0 );
- fdSuspendFailIfNotExists.top = new FormAttachment( 0, margin );
- fdSuspendFailIfNotExists.right = new FormAttachment( 100, 0 );
- wSuspendFailIfNotExists.setLayoutData( fdSuspendFailIfNotExists );
- wSuspendFailIfNotExists.addListener(SWT.Selection, e -> warehouseManager.setChanged() );
-
- /////////////////////
- // Start Alter Warehouse Group
- /////////////////////
- wAlterGroup = new Group( shell, SWT.SHADOW_ETCHED_IN );
- wAlterGroup.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Group.AlterWarehouse.Label" ) );
- FormLayout alterWarehouseLayout = new FormLayout();
- alterWarehouseLayout.marginWidth = 3;
- alterWarehouseLayout.marginHeight = 3;
- wAlterGroup.setLayout( alterWarehouseLayout );
- props.setLook( wAlterGroup );
-
- fdgAlterGroup = new FormData();
- fdgAlterGroup.left = new FormAttachment( 0, 0 );
- fdgAlterGroup.right = new FormAttachment( 100, 0 );
- fdgAlterGroup.top = new FormAttachment( wAction, margin * 2 );
- // fdgAlterGroup.bottom = new FormAttachment( 100, -margin * 2 );
- wAlterGroup.setLayoutData( fdgAlterGroup );
-
- // //////////////////////
- // Fail if Not exists line
- // /////////////////////
- wlAlterFailIfNotExists = new Label( wAlterGroup, SWT.RIGHT );
- wlAlterFailIfNotExists.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Alter.FailIfNotExists.Label" ) );
- props.setLook( wlAlterFailIfNotExists );
- fdlAlterFailIfNotExists = new FormData();
- fdlAlterFailIfNotExists.left = new FormAttachment( 0, 0 );
- fdlAlterFailIfNotExists.top = new FormAttachment( 0, margin );
- fdlAlterFailIfNotExists.right = new FormAttachment( middle, -margin );
- wlAlterFailIfNotExists.setLayoutData( fdlAlterFailIfNotExists );
-
- wAlterFailIfNotExists = new Button( wAlterGroup, SWT.CHECK );
- props.setLook( wAlterFailIfNotExists );
- fdAlterFailIfNotExists = new FormData();
- fdAlterFailIfNotExists.left = new FormAttachment( middle, 0 );
- fdAlterFailIfNotExists.top = new FormAttachment( 0, margin );
- fdAlterFailIfNotExists.right = new FormAttachment( 100, 0 );
- wAlterFailIfNotExists.setLayoutData( fdAlterFailIfNotExists );
- wAlterFailIfNotExists.addListener(SWT.Selection, e -> warehouseManager.setChanged());
-
- // Warehouse Size
- //
- wlAlterWarehouseSize = new Label( wAlterGroup, SWT.RIGHT );
- wlAlterWarehouseSize.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.AlterWarehouseSize.Label" ) );
- props.setLook( wlAlterWarehouseSize );
- fdlAlterWarehouseSize = new FormData();
- fdlAlterWarehouseSize.left = new FormAttachment( 0, 0 );
- fdlAlterWarehouseSize.top = new FormAttachment( wAlterFailIfNotExists, margin );
- fdlAlterWarehouseSize.right = new FormAttachment( middle, -margin );
- wlAlterWarehouseSize.setLayoutData( fdlAlterWarehouseSize );
-
- wAlterWarehouseSize = new ComboVar( variables, wAlterGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- props.setLook( wAlterWarehouseSize );
- wAlterWarehouseSize.addListener( SWT.Modify, e -> warehouseManager.setChanged() );
- fdAlterWarehouseSize = new FormData();
- fdAlterWarehouseSize.left = new FormAttachment( middle, 0 );
- fdAlterWarehouseSize.top = new FormAttachment( wAlterFailIfNotExists, margin );
- fdAlterWarehouseSize.right = new FormAttachment( 100, 0 );
- wAlterWarehouseSize.setLayoutData( fdAlterWarehouseSize );
- wAlterWarehouseSize.setItems( WAREHOUSE_SIZE_DESCS );
-
- // Warehouse Type
- //
- wlAlterWarehouseType = new Label( wAlterGroup, SWT.RIGHT );
- wlAlterWarehouseType.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.AlterWarehouseType.Label" ) );
- props.setLook( wlAlterWarehouseType );
- fdlAlterWarehouseType = new FormData();
- fdlAlterWarehouseType.left = new FormAttachment( 0, 0 );
- fdlAlterWarehouseType.top = new FormAttachment( wAlterWarehouseSize, margin );
- fdlAlterWarehouseType.right = new FormAttachment( middle, -margin );
- wlAlterWarehouseType.setLayoutData( fdlAlterWarehouseType );
-
- wAlterWarehouseType = new ComboVar( variables, wAlterGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- props.setLook( wAlterWarehouseType );
- wAlterWarehouseType.addListener( SWT.Modify, e -> warehouseManager.setChanged() );
- fdAlterWarehouseType = new FormData();
- fdAlterWarehouseType.left = new FormAttachment( middle, 0 );
- fdAlterWarehouseType.top = new FormAttachment( wAlterWarehouseSize, margin );
- fdAlterWarehouseType.right = new FormAttachment( 100, 0 );
- wAlterWarehouseType.setLayoutData( fdAlterWarehouseType );
- wAlterWarehouseType.setItems( WAREHOUSE_TYPE_DESCS );
-
- // /////////////////////
- // Max Cluster Size
- // /////////////////////
- wlAlterMaxClusterSize = new Label( wAlterGroup, SWT.RIGHT );
- wlAlterMaxClusterSize.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Alter.MaxClusterSize.Label" ) );
- props.setLook( wlAlterMaxClusterSize );
- fdlAlterMaxClusterSize = new FormData();
- fdlAlterMaxClusterSize.left = new FormAttachment( 0, 0 );
- fdlAlterMaxClusterSize.top = new FormAttachment( wAlterWarehouseType, margin );
- fdlAlterMaxClusterSize.right = new FormAttachment( middle, -margin );
- wlAlterMaxClusterSize.setLayoutData( fdlAlterMaxClusterSize );
-
- wAlterMaxClusterSize = new TextVar( variables, wAlterGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- props.setLook( wAlterGroup );
- wAlterMaxClusterSize.addListener(SWT.Modify, e -> warehouseManager.setChanged() );
- fdAlterMaxClusterSize = new FormData();
- fdAlterMaxClusterSize.left = new FormAttachment( middle, 0 );
- fdAlterMaxClusterSize.right = new FormAttachment( 100, 0 );
- fdAlterMaxClusterSize.top = new FormAttachment( wAlterWarehouseType, margin );
- wAlterMaxClusterSize.setLayoutData( fdAlterMaxClusterSize );
-
- // /////////////////////
- // Min Cluster Size
- // /////////////////////
- wlAlterMinClusterSize = new Label( wAlterGroup, SWT.RIGHT );
- wlAlterMinClusterSize.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Alter.MinClusterSize.Label" ) );
- props.setLook( wlAlterMinClusterSize );
- fdlAlterMinClusterSize = new FormData();
- fdlAlterMinClusterSize.left = new FormAttachment( 0, 0 );
- fdlAlterMinClusterSize.top = new FormAttachment( wAlterMaxClusterSize, margin );
- fdlAlterMinClusterSize.right = new FormAttachment( middle, -margin );
- wlAlterMinClusterSize.setLayoutData( fdlAlterMinClusterSize );
-
- wAlterMinClusterSize = new TextVar( variables, wAlterGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- props.setLook( wAlterGroup );
- wAlterMinClusterSize.addListener(SWT.Modify, e -> warehouseManager.setChanged() );
- fdAlterMinClusterSize = new FormData();
- fdAlterMinClusterSize.left = new FormAttachment( middle, 0 );
- fdAlterMinClusterSize.right = new FormAttachment( 100, 0 );
- fdAlterMinClusterSize.top = new FormAttachment( wAlterMaxClusterSize, margin );
- wAlterMinClusterSize.setLayoutData( fdAlterMinClusterSize );
-
- // /////////////////////
- // Auto Suspend Size
- // /////////////////////
- wlAlterAutoSuspend = new Label( wAlterGroup, SWT.RIGHT );
- wlAlterAutoSuspend.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Alter.AutoSuspend.Label" ) );
- wlAlterAutoSuspend.setToolTipText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Alter.AutoSuspend.Tooltip" ) );
- props.setLook( wlAlterAutoSuspend );
- fdlAlterAutoSuspend = new FormData();
- fdlAlterAutoSuspend.left = new FormAttachment( 0, 0 );
- fdlAlterAutoSuspend.top = new FormAttachment( wAlterMinClusterSize, margin );
- fdlAlterAutoSuspend.right = new FormAttachment( middle, -margin );
- wlAlterAutoSuspend.setLayoutData( fdlAlterAutoSuspend );
-
- wAlterAutoSuspend = new TextVar( variables, wAlterGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- props.setLook( wAlterGroup );
- wAlterAutoSuspend.addListener( SWT.Modify, e -> warehouseManager.setChanged() );
- fdAlterAutoSuspend = new FormData();
- fdAlterAutoSuspend.left = new FormAttachment( middle, 0 );
- fdAlterAutoSuspend.right = new FormAttachment( 100, 0 );
- fdAlterAutoSuspend.top = new FormAttachment( wAlterMinClusterSize, margin );
- wAlterAutoSuspend.setLayoutData( fdAlterAutoSuspend );
-
- // /////////////////////
- // Auto-resume
- // /////////////////////
- wlAlterAutoResume = new Label( wAlterGroup, SWT.RIGHT );
- wlAlterAutoResume.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Alter.AutoResume.Label" ) );
- props.setLook( wlAlterAutoResume );
- fdlAlterAutoResume = new FormData();
- fdlAlterAutoResume.left = new FormAttachment( 0, 0 );
- fdlAlterAutoResume.top = new FormAttachment( wAlterAutoSuspend, margin );
- fdlAlterAutoResume.right = new FormAttachment( middle, -margin );
- wlAlterAutoResume.setLayoutData( fdlAlterAutoResume );
-
- wAlterAutoResume = new Button( wAlterGroup, SWT.CHECK );
- props.setLook( wAlterAutoResume );
- fdAlterAutoResume = new FormData();
- fdAlterAutoResume.left = new FormAttachment( middle, 0 );
- fdAlterAutoResume.top = new FormAttachment( wAlterAutoSuspend, margin );
- fdAlterAutoResume.right = new FormAttachment( 100, 0 );
- wAlterAutoResume.setLayoutData( fdAlterAutoResume );
- wAlterAutoResume.addListener(SWT.Selection, e -> warehouseManager.setChanged());
-
- // Resource monitor line
- //
- wlAlterResourceMonitor = new Label( wAlterGroup, SWT.RIGHT );
- wlAlterResourceMonitor.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.ResourceMonitor.Label" ) );
- props.setLook( wlAlterResourceMonitor );
- fdlAlterResourceMonitor = new FormData();
- fdlAlterResourceMonitor.left = new FormAttachment( 0, 0 );
- fdlAlterResourceMonitor.top = new FormAttachment( wAlterAutoResume, margin );
- fdlAlterResourceMonitor.right = new FormAttachment( middle, -margin );
- wlAlterResourceMonitor.setLayoutData( fdlAlterResourceMonitor );
-
- wAlterResourceMonitor = new ComboVar( variables, wAlterGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- props.setLook( wAlterResourceMonitor );
- wAlterResourceMonitor.addListener(SWT.Modify, e -> warehouseManager.setChanged() );
- fdAlterResourceMonitor = new FormData();
- fdAlterResourceMonitor.left = new FormAttachment( middle, 0 );
- fdAlterResourceMonitor.top = new FormAttachment( wAlterAutoResume, margin );
- fdAlterResourceMonitor.right = new FormAttachment( 100, 0 );
- wAlterResourceMonitor.setLayoutData( fdAlterResourceMonitor );
- wAlterResourceMonitor.addFocusListener( new FocusAdapter() {
- /**
- * Get the list of stages for the schema, and populate the stage name drop down.
- *
- * @param focusEvent The event
- */
- @SuppressWarnings( "Duplicates" )
- @Override
- public void focusGained( FocusEvent focusEvent ) {
- getResourceMonitors();
+ shell.setLayout(formLayout);
+ shell.setText(BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Title"));
- }
- } );
-
- // /////////////////////
- //Comment Line
- // /////////////////////
- wlAlterComment = new Label( wAlterGroup, SWT.RIGHT );
- wlAlterComment.setText( BaseMessages.getString( PKG, "SnowflakeWarehouseManager.Dialog.Alter.Comment.Label" ) );
- props.setLook( wlAlterComment );
- fdlAlterComment = new FormData();
- fdlAlterComment.left = new FormAttachment( 0, 0 );
- fdlAlterComment.top = new FormAttachment( wAlterResourceMonitor, margin );
- fdlAlterComment.right = new FormAttachment( middle, -margin );
- wlAlterComment.setLayoutData( fdlAlterComment );
-
- wAlterComment = new TextVar( variables, wAlterGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- props.setLook( wAlterGroup );
- wAlterComment.addListener(SWT.Modify, e -> warehouseManager.setChanged() );
- fdAlterComment = new FormData();
- fdAlterComment.left = new FormAttachment( middle, 0 );
- fdAlterComment.right = new FormAttachment( 100, 0 );
- fdAlterComment.top = new FormAttachment( wAlterResourceMonitor, margin );
- wAlterComment.setLayoutData( fdAlterComment );
-
-
- // Some buttons
- wOK = new Button( shell, SWT.PUSH );
- wOK.setText( BaseMessages.getString( PKG, "System.Button.OK" ) );
- wCancel = new Button( shell, SWT.PUSH );
- wCancel.setText( BaseMessages.getString( PKG, "System.Button.Cancel" ) );
-
- BaseTransformDialog.positionBottomButtons( shell, new Button[]{ wOK, wCancel }, margin, wCreateGroup );
-
- // Add listeners
- lsCancel = new Listener() {
- public void handleEvent( Event e ) {
- cancel();
- }
- };
- lsOK = new Listener() {
- public void handleEvent( Event e ) {
- ok();
- }
- };
+ int middle = props.getMiddlePct();
+ int margin = Const.MARGIN;
- wOK.addListener( SWT.Selection, lsOK );
- wCancel.addListener( SWT.Selection, lsCancel );
- wName.addListener(SWT.Modify, e -> warehouseManager.setChanged());
+ // Name line
+ Label wlName = new Label(shell, SWT.RIGHT);
+ wlName.setText(BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Name.Label"));
+ props.setLook(wlName);
+ FormData fdlName = new FormData();
+ fdlName.left = new FormAttachment(0, 0);
+ fdlName.top = new FormAttachment(0, 0);
+ fdlName.right = new FormAttachment(middle, 0);
+ wlName.setLayoutData(fdlName);
- // Detect [X] or ALT-F4 or something that kills this window...
- shell.addShellListener( new ShellAdapter() {
- public void shellClosed(
- ShellEvent e ) {
- cancel();
- }
- } );
-
- getData();
- setFlags();
+ wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wName);
+ FormData fdName = new FormData();
+ fdName.top = new FormAttachment(0, 0);
+ fdName.left = new FormAttachment(middle, margin);
+ fdName.right = new FormAttachment(100, 0);
+ wName.setLayoutData(fdName);
- BaseTransformDialog.setSize( shell );
+ // Connection line
+ wConnection = addConnectionLine(shell, wName, warehouseManager.getDatabaseMeta(), null);
+ if (warehouseManager.getDatabaseMeta() == null && workflowMeta.nrDatabases() == 1) {
+ wConnection.select(0);
+ }
- shell.open();
- props.setDialogSize( shell, "WarehouseManagerSize" );
- while ( !shell.isDisposed() ) {
- if ( !display.readAndDispatch() ) {
- display.sleep();
+ // Warehouse name line
+ //
+ Label wlWarehouseName = new Label(shell, SWT.RIGHT);
+ wlWarehouseName.setText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.WarehouseName.Label"));
+ props.setLook(wlWarehouseName);
+ FormData fdlWarehouseName = new FormData();
+ fdlWarehouseName.left = new FormAttachment(0, 0);
+ fdlWarehouseName.top = new FormAttachment(wConnection, margin * 2);
+ fdlWarehouseName.right = new FormAttachment(middle, -margin);
+ wlWarehouseName.setLayoutData(fdlWarehouseName);
+
+ wWarehouseName = new ComboVar(variables, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wWarehouseName);
+ FormData fdWarehouseName = new FormData();
+ fdWarehouseName.left = new FormAttachment(middle, 0);
+ fdWarehouseName.top = new FormAttachment(wConnection, margin * 2);
+ fdWarehouseName.right = new FormAttachment(100, 0);
+ wWarehouseName.setLayoutData(fdWarehouseName);
+ wWarehouseName.addFocusListener(
+ new FocusAdapter() {
+ /**
+ * Get the list of stages for the schema, and populate the stage name drop down.
+ *
+ * @param focusEvent The event
+ */
+ @Override
+ public void focusGained(FocusEvent focusEvent) {
+ DatabaseMeta databaseMeta = workflowMeta.findDatabase(wConnection.getText(), variables);
+ if (databaseMeta != null) {
+ String warehouseName = wWarehouseName.getText();
+ wWarehouseName.removeAll();
+ Database db = null;
+ try {
+ db = new Database(loggingObject, variables, databaseMeta);
+ db.connect();
+ ResultSet resultSet =
+ db.openQuery("show warehouses;", null, null, ResultSet.FETCH_FORWARD, false);
+ IRowMeta rowMeta = db.getReturnRowMeta();
+ Object[] row = db.getRow(resultSet);
+ int nameField = rowMeta.indexOfValue("NAME");
+ if (nameField >= 0) {
+ while (row != null) {
+ String name = rowMeta.getString(row, nameField);
+ wWarehouseName.add(name);
+ row = db.getRow(resultSet);
+ }
+ } else {
+ throw new HopException("Unable to find warehouse name field in result");
+ }
+ db.closeQuery(resultSet);
+ if (warehouseName != null) {
+ wWarehouseName.setText(warehouseName);
+ }
+ } catch (Exception ex) {
+ warehouseManager.logDebug("Error getting warehouses", ex);
+ } finally {
+ db.disconnect();
+ }
}
- }
-
- return warehouseManager;
+ }
+ });
+
+ // ///////////////////
+ // Action line
+ // ///////////////////
+ Label wlAction = new Label(shell, SWT.RIGHT);
+ wlAction.setText(BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Action.Label"));
+ props.setLook(wlAction);
+ FormData fdlAction = new FormData();
+ fdlAction.left = new FormAttachment(0, 0);
+ fdlAction.right = new FormAttachment(middle, -margin);
+ fdlAction.top = new FormAttachment(wWarehouseName, margin);
+ wlAction.setLayoutData(fdlAction);
+
+ wAction = new CCombo(shell, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
+ wAction.setItems(MANAGEMENT_ACTION_DESCS);
+ props.setLook(wAction);
+ FormData fdAction = new FormData();
+ fdAction.left = new FormAttachment(middle, 0);
+ fdAction.top = new FormAttachment(wWarehouseName, margin);
+ fdAction.right = new FormAttachment(100, 0);
+ wAction.setLayoutData(fdAction);
+ wAction.addSelectionListener(
+ new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent selectionEvent) {
+ setFlags();
+ }
+ });
+
+ /////////////////////
+ // Start Create Warehouse Group
+ /////////////////////
+ wCreateGroup = new Group(shell, SWT.SHADOW_ETCHED_IN);
+ wCreateGroup.setText(
+ BaseMessages.getString(
+ PKG, "SnowflakeWarehouseManager.Dialog.Group.CreateWarehouse.Label"));
+ FormLayout createWarehouseLayout = new FormLayout();
+ createWarehouseLayout.marginWidth = 3;
+ createWarehouseLayout.marginHeight = 3;
+ wCreateGroup.setLayout(createWarehouseLayout);
+ props.setLook(wCreateGroup);
+
+ FormData fdgCreateGroup = new FormData();
+ fdgCreateGroup.left = new FormAttachment(0, 0);
+ fdgCreateGroup.right = new FormAttachment(100, 0);
+ fdgCreateGroup.top = new FormAttachment(wAction, margin * 2);
+ wCreateGroup.setLayoutData(fdgCreateGroup);
+
+ // //////////////////////
+ // Replace line
+ // /////////////////////
+ Label wlCreateReplace = new Label(wCreateGroup, SWT.RIGHT);
+ wlCreateReplace.setText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Create.Replace.Label"));
+ wlCreateReplace.setToolTipText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Create.Replace.Tooltip"));
+ props.setLook(wlCreateReplace);
+ FormData fdlCreateReplace = new FormData();
+ fdlCreateReplace.left = new FormAttachment(0, 0);
+ fdlCreateReplace.top = new FormAttachment(0, margin * 2);
+ fdlCreateReplace.right = new FormAttachment(middle, -margin);
+ wlCreateReplace.setLayoutData(fdlCreateReplace);
+
+ wCreateReplace = new Button(wCreateGroup, SWT.CHECK);
+ props.setLook(wCreateReplace);
+ FormData fdCreateReplace = new FormData();
+ fdCreateReplace.left = new FormAttachment(middle, 0);
+ fdCreateReplace.top = new FormAttachment(0, margin * 2);
+ fdCreateReplace.right = new FormAttachment(100, 0);
+ wCreateReplace.setLayoutData(fdCreateReplace);
+ wCreateReplace.addListener(SWT.Selection, e -> warehouseManager.setChanged());
+ wCreateReplace.addListener(SWT.Selection, e -> setFlags());
+
+ // /////////////////////
+ // Fail if exists line
+ // /////////////////////
+ Label wlCreateFailIfExists = new Label(wCreateGroup, SWT.RIGHT);
+ wlCreateFailIfExists.setText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Create.FailIfExists.Label"));
+ props.setLook(wlCreateFailIfExists);
+ FormData fdlCreateFailIfExists = new FormData();
+ fdlCreateFailIfExists.left = new FormAttachment(0, 0);
+ fdlCreateFailIfExists.top = new FormAttachment(wCreateReplace, margin * 2);
+ fdlCreateFailIfExists.right = new FormAttachment(middle, -margin);
+ wlCreateFailIfExists.setLayoutData(fdlCreateFailIfExists);
+
+ wCreateFailIfExists = new Button(wCreateGroup, SWT.CHECK);
+ props.setLook(wCreateFailIfExists);
+ FormData fdCreateFailIfExists = new FormData();
+ fdCreateFailIfExists.left = new FormAttachment(middle, 0);
+ fdCreateFailIfExists.top = new FormAttachment(wCreateReplace, margin * 2);
+ fdCreateFailIfExists.right = new FormAttachment(100, 0);
+ wCreateFailIfExists.setLayoutData(fdCreateFailIfExists);
+ wCreateFailIfExists.addListener(SWT.Selection, e -> warehouseManager.setChanged());
+
+ // Warehouse Size
+ //
+ Label wlCreateWarehouseSize = new Label(wCreateGroup, SWT.RIGHT);
+ wlCreateWarehouseSize.setText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.CreateWarehouseSize.Label"));
+ props.setLook(wlCreateWarehouseSize);
+ FormData fdlCreateWarehouseSize = new FormData();
+ fdlCreateWarehouseSize.left = new FormAttachment(0, 0);
+ fdlCreateWarehouseSize.top = new FormAttachment(wCreateFailIfExists, margin * 2);
+ fdlCreateWarehouseSize.right = new FormAttachment(middle, -margin);
+ wlCreateWarehouseSize.setLayoutData(fdlCreateWarehouseSize);
+
+ wCreateWarehouseSize =
+ new ComboVar(variables, wCreateGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wCreateWarehouseSize);
+ wCreateWarehouseSize.addListener(SWT.Modify, e -> warehouseManager.setChanged());
+ FormData fdCreateWarehouseSize = new FormData();
+ fdCreateWarehouseSize.left = new FormAttachment(middle, 0);
+ fdCreateWarehouseSize.top = new FormAttachment(wCreateFailIfExists, margin * 2);
+ fdCreateWarehouseSize.right = new FormAttachment(100, 0);
+ wCreateWarehouseSize.setLayoutData(fdCreateWarehouseSize);
+ wCreateWarehouseSize.setItems(WAREHOUSE_SIZE_DESCS);
+
+ // Warehouse Type
+ //
+ Label wlCreateWarehouseType = new Label(wCreateGroup, SWT.RIGHT);
+ wlCreateWarehouseType.setText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.CreateWarehouseType.Label"));
+ props.setLook(wlCreateWarehouseType);
+ FormData fdlCreateWarehouseType = new FormData();
+ fdlCreateWarehouseType.left = new FormAttachment(0, 0);
+ fdlCreateWarehouseType.top = new FormAttachment(wCreateWarehouseSize, margin * 2);
+ fdlCreateWarehouseType.right = new FormAttachment(middle, -margin);
+ wlCreateWarehouseType.setLayoutData(fdlCreateWarehouseType);
+
+ wCreateWarehouseType =
+ new ComboVar(variables, wCreateGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wCreateWarehouseType);
+ wCreateWarehouseType.addListener(SWT.Modify, e -> warehouseManager.setChanged());
+ FormData fdCreateWarehouseType = new FormData();
+ fdCreateWarehouseType.left = new FormAttachment(middle, 0);
+ fdCreateWarehouseType.top = new FormAttachment(wCreateWarehouseSize, margin * 2);
+ fdCreateWarehouseType.right = new FormAttachment(100, 0);
+ wCreateWarehouseType.setLayoutData(fdCreateWarehouseType);
+ wCreateWarehouseType.setItems(WAREHOUSE_TYPE_DESCS);
+
+ // /////////////////////
+ // Max Cluster Size
+ // /////////////////////
+ Label wlCreateMaxClusterSize = new Label(wCreateGroup, SWT.RIGHT);
+ wlCreateMaxClusterSize.setText(
+ BaseMessages.getString(
+ PKG, "SnowflakeWarehouseManager.Dialog.Create.MaxClusterSize.Label"));
+ props.setLook(wlCreateMaxClusterSize);
+ FormData fdlCreateMaxClusterSize = new FormData();
+ fdlCreateMaxClusterSize.left = new FormAttachment(0, 0);
+ fdlCreateMaxClusterSize.top = new FormAttachment(wCreateWarehouseType, margin * 2);
+ fdlCreateMaxClusterSize.right = new FormAttachment(middle, -margin);
+ wlCreateMaxClusterSize.setLayoutData(fdlCreateMaxClusterSize);
+
+ wCreateMaxClusterSize =
+ new TextVar(variables, wCreateGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wCreateGroup);
+ wCreateMaxClusterSize.addListener(SWT.Modify, e -> warehouseManager.setChanged());
+ FormData fdCreateMaxClusterSize = new FormData();
+ fdCreateMaxClusterSize.left = new FormAttachment(middle, 0);
+ fdCreateMaxClusterSize.right = new FormAttachment(100, 0);
+ fdCreateMaxClusterSize.top = new FormAttachment(wCreateWarehouseType, margin * 2);
+ wCreateMaxClusterSize.setLayoutData(fdCreateMaxClusterSize);
+
+ // /////////////////////
+ // Min Cluster Size
+ // /////////////////////
+ Label wlCreateMinClusterSize = new Label(wCreateGroup, SWT.RIGHT);
+ wlCreateMinClusterSize.setText(
+ BaseMessages.getString(
+ PKG, "SnowflakeWarehouseManager.Dialog.Create.MinClusterSize.Label"));
+ props.setLook(wlCreateMinClusterSize);
+ FormData fdlCreateMinClusterSize = new FormData();
+ fdlCreateMinClusterSize.left = new FormAttachment(0, 0);
+ fdlCreateMinClusterSize.top = new FormAttachment(wCreateMaxClusterSize, margin * 2);
+ fdlCreateMinClusterSize.right = new FormAttachment(middle, -margin);
+ wlCreateMinClusterSize.setLayoutData(fdlCreateMinClusterSize);
+
+ wCreateMinClusterSize =
+ new TextVar(variables, wCreateGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wCreateGroup);
+ wCreateMinClusterSize.addListener(SWT.Modify, e -> warehouseManager.setChanged());
+ FormData fdCreateMinClusterSize = new FormData();
+ fdCreateMinClusterSize.left = new FormAttachment(middle, 0);
+ fdCreateMinClusterSize.right = new FormAttachment(100, 0);
+ fdCreateMinClusterSize.top = new FormAttachment(wCreateMaxClusterSize, margin * 2);
+ wCreateMinClusterSize.setLayoutData(fdCreateMinClusterSize);
+
+ // /////////////////////
+ // Auto Suspend Size
+ // /////////////////////
+ Label wlCreateAutoSuspend = new Label(wCreateGroup, SWT.RIGHT);
+ wlCreateAutoSuspend.setText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Create.AutoSuspend.Label"));
+ wlCreateAutoSuspend.setToolTipText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Create.AutoSuspend.Tooltip"));
+ props.setLook(wlCreateAutoSuspend);
+ FormData fdlCreateAutoSuspend = new FormData();
+ fdlCreateAutoSuspend.left = new FormAttachment(0, 0);
+ fdlCreateAutoSuspend.top = new FormAttachment(wCreateMinClusterSize, margin * 2);
+ fdlCreateAutoSuspend.right = new FormAttachment(middle, -margin);
+ wlCreateAutoSuspend.setLayoutData(fdlCreateAutoSuspend);
+
+ wCreateAutoSuspend = new TextVar(variables, wCreateGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wCreateGroup);
+ wCreateAutoSuspend.addListener(SWT.Modify, e -> warehouseManager.setChanged());
+ FormData fdCreateAutoSuspend = new FormData();
+ fdCreateAutoSuspend.left = new FormAttachment(middle, 0);
+ fdCreateAutoSuspend.right = new FormAttachment(100, 0);
+ fdCreateAutoSuspend.top = new FormAttachment(wCreateMinClusterSize, margin * 2);
+ wCreateAutoSuspend.setLayoutData(fdCreateAutoSuspend);
+
+ // /////////////////////
+ // Auto-resume
+ // /////////////////////
+ Label wlCreateAutoResume = new Label(wCreateGroup, SWT.RIGHT);
+ wlCreateAutoResume.setText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Create.AutoResume.Label"));
+ props.setLook(wlCreateAutoResume);
+ FormData fdlCreateAutoResume = new FormData();
+ fdlCreateAutoResume.left = new FormAttachment(0, 0);
+ fdlCreateAutoResume.top = new FormAttachment(wCreateAutoSuspend, margin * 2);
+ fdlCreateAutoResume.right = new FormAttachment(middle, -margin);
+ wlCreateAutoResume.setLayoutData(fdlCreateAutoResume);
+
+ wCreateAutoResume = new Button(wCreateGroup, SWT.CHECK);
+ props.setLook(wCreateAutoResume);
+ FormData fdCreateAutoResume = new FormData();
+ fdCreateAutoResume.left = new FormAttachment(middle, 0);
+ fdCreateAutoResume.top = new FormAttachment(wCreateAutoSuspend, margin * 2);
+ fdCreateAutoResume.right = new FormAttachment(100, 0);
+ wCreateAutoResume.setLayoutData(fdCreateAutoResume);
+ wCreateAutoResume.addListener(SWT.Selection, e -> warehouseManager.setChanged());
+
+ // /////////////////////
+ // Auto-resume
+ // /////////////////////
+ Label wlCreateInitialSuspend = new Label(wCreateGroup, SWT.RIGHT);
+ wlCreateInitialSuspend.setText(
+ BaseMessages.getString(
+ PKG, "SnowflakeWarehouseManager.Dialog.Create.InitialSuspend.Label"));
+ wlCreateInitialSuspend.setToolTipText(
+ BaseMessages.getString(
+ PKG, "SnowflakeWarehouseManager.Dialog.Create.InitialSuspend.Tooltip"));
+ props.setLook(wlCreateInitialSuspend);
+ FormData fdlCreateInitialSuspend = new FormData();
+ fdlCreateInitialSuspend.left = new FormAttachment(0, 0);
+ fdlCreateInitialSuspend.top = new FormAttachment(wCreateAutoResume, margin * 2);
+ fdlCreateInitialSuspend.right = new FormAttachment(middle, -margin);
+ wlCreateInitialSuspend.setLayoutData(fdlCreateInitialSuspend);
+
+ wCreateInitialSuspend = new Button(wCreateGroup, SWT.CHECK);
+ props.setLook(wCreateInitialSuspend);
+ FormData fdCreateInitialSuspend = new FormData();
+ fdCreateInitialSuspend.left = new FormAttachment(middle, 0);
+ fdCreateInitialSuspend.top = new FormAttachment(wCreateAutoResume, margin * 2);
+ fdCreateInitialSuspend.right = new FormAttachment(100, 0);
+ wCreateInitialSuspend.setLayoutData(fdCreateInitialSuspend);
+ wCreateInitialSuspend.addListener(SWT.Selection, e -> warehouseManager.setChanged());
+
+ // Resource monitor line
+ //
+ Label wlCreateResourceMonitor = new Label(wCreateGroup, SWT.RIGHT);
+ wlCreateResourceMonitor.setText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.ResourceMonitor.Label"));
+ props.setLook(wlCreateResourceMonitor);
+ FormData fdlCreateResourceMonitor = new FormData();
+ fdlCreateResourceMonitor.left = new FormAttachment(0, 0);
+ fdlCreateResourceMonitor.top = new FormAttachment(wCreateInitialSuspend, margin * 2);
+ fdlCreateResourceMonitor.right = new FormAttachment(middle, -margin);
+ wlCreateResourceMonitor.setLayoutData(fdlCreateResourceMonitor);
+
+ wCreateResourceMonitor =
+ new ComboVar(variables, wCreateGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wCreateResourceMonitor);
+ wCreateResourceMonitor.addListener(SWT.Modify, e -> warehouseManager.setChanged());
+ FormData fdCreateResourceMonitor = new FormData();
+ fdCreateResourceMonitor.left = new FormAttachment(middle, 0);
+ fdCreateResourceMonitor.top = new FormAttachment(wCreateInitialSuspend, margin * 2);
+ fdCreateResourceMonitor.right = new FormAttachment(100, 0);
+ wCreateResourceMonitor.setLayoutData(fdCreateResourceMonitor);
+ wCreateResourceMonitor.addFocusListener(
+ new FocusAdapter() {
+ /**
+ * Get the list of stages for the schema, and populate the stage name drop down.
+ *
+ * @param focusEvent The event
+ */
+ @SuppressWarnings("Duplicates")
+ @Override
+ public void focusGained(FocusEvent focusEvent) {
+ getResourceMonitors();
+ }
+ });
+
+ // /////////////////////
+ // Comment Line
+ // /////////////////////
+ Label wlCreateComment = new Label(wCreateGroup, SWT.RIGHT);
+ wlCreateComment.setText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Create.Comment.Label"));
+ props.setLook(wlCreateComment);
+ FormData fdlCreateComment = new FormData();
+ fdlCreateComment.left = new FormAttachment(0, 0);
+ fdlCreateComment.top = new FormAttachment(wCreateResourceMonitor, margin * 2);
+ fdlCreateComment.right = new FormAttachment(middle, -margin);
+ wlCreateComment.setLayoutData(fdlCreateComment);
+
+ wCreateComment = new TextVar(variables, wCreateGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wCreateGroup);
+ wCreateComment.addListener(SWT.Modify, e -> warehouseManager.setChanged());
+ FormData fdCreateComment = new FormData();
+ fdCreateComment.left = new FormAttachment(middle, 0);
+ fdCreateComment.right = new FormAttachment(100, 0);
+ fdCreateComment.top = new FormAttachment(wCreateResourceMonitor, margin * 2);
+ wCreateComment.setLayoutData(fdCreateComment);
+
+ /////////////////////
+ // Start Drop Warehouse Group
+ /////////////////////
+ wDropGroup = new Group(shell, SWT.SHADOW_ETCHED_IN);
+ wDropGroup.setText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Group.DropWarehouse.Label"));
+ FormLayout dropWarehouseLayout = new FormLayout();
+ dropWarehouseLayout.marginWidth = 3;
+ dropWarehouseLayout.marginHeight = 3;
+ wDropGroup.setLayout(dropWarehouseLayout);
+ props.setLook(wDropGroup);
+
+ FormData fdgDropGroup = new FormData();
+ fdgDropGroup.left = new FormAttachment(0, 0);
+ fdgDropGroup.right = new FormAttachment(100, 0);
+ fdgDropGroup.top = new FormAttachment(wAction, margin * 2);
+ wDropGroup.setLayoutData(fdgDropGroup);
+
+ // //////////////////////
+ // Fail if Not exists line
+ // /////////////////////
+ Label wlDropFailIfNotExists = new Label(wDropGroup, SWT.RIGHT);
+ wlDropFailIfNotExists.setText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Drop.FailIfNotExists.Label"));
+ props.setLook(wlDropFailIfNotExists);
+ FormData fdlDropFailIfNotExists = new FormData();
+ fdlDropFailIfNotExists.left = new FormAttachment(0, 0);
+ fdlDropFailIfNotExists.top = new FormAttachment(0, margin);
+ fdlDropFailIfNotExists.right = new FormAttachment(middle, -margin);
+ wlDropFailIfNotExists.setLayoutData(fdlDropFailIfNotExists);
+
+ wDropFailIfNotExists = new Button(wDropGroup, SWT.CHECK);
+ props.setLook(wDropFailIfNotExists);
+ FormData fdDropFailIfNotExists = new FormData();
+ fdDropFailIfNotExists.left = new FormAttachment(middle, 0);
+ fdDropFailIfNotExists.top = new FormAttachment(0, margin);
+ fdDropFailIfNotExists.right = new FormAttachment(100, 0);
+ wDropFailIfNotExists.setLayoutData(fdDropFailIfNotExists);
+ wDropFailIfNotExists.addListener(SWT.Selection, e -> warehouseManager.setChanged());
+
+ /////////////////////
+ // Start Resume Warehouse Group
+ /////////////////////
+ wResumeGroup = new Group(shell, SWT.SHADOW_ETCHED_IN);
+ wResumeGroup.setText(
+ BaseMessages.getString(
+ PKG, "SnowflakeWarehouseManager.Dialog.Group.ResumeWarehouse.Label"));
+ FormLayout resumeWarehouseLayout = new FormLayout();
+ resumeWarehouseLayout.marginWidth = 3;
+ resumeWarehouseLayout.marginHeight = 3;
+ wResumeGroup.setLayout(resumeWarehouseLayout);
+ props.setLook(wResumeGroup);
+
+ FormData fdgResumeGroup = new FormData();
+ fdgResumeGroup.left = new FormAttachment(0, 0);
+ fdgResumeGroup.right = new FormAttachment(100, 0);
+ fdgResumeGroup.top = new FormAttachment(wAction, margin * 2);
+ wResumeGroup.setLayoutData(fdgResumeGroup);
+
+ // //////////////////////
+ // Fail if Not exists line
+ // /////////////////////
+ Label wlResumeFailIfNotExists = new Label(wResumeGroup, SWT.RIGHT);
+ wlResumeFailIfNotExists.setText(
+ BaseMessages.getString(
+ PKG, "SnowflakeWarehouseManager.Dialog.Resume.FailIfNotExists.Label"));
+ props.setLook(wlResumeFailIfNotExists);
+ FormData fdlResumeFailIfNotExists = new FormData();
+ fdlResumeFailIfNotExists.left = new FormAttachment(0, 0);
+ fdlResumeFailIfNotExists.top = new FormAttachment(0, margin);
+ fdlResumeFailIfNotExists.right = new FormAttachment(middle, -margin);
+ wlResumeFailIfNotExists.setLayoutData(fdlResumeFailIfNotExists);
+
+ wResumeFailIfNotExists = new Button(wResumeGroup, SWT.CHECK);
+ props.setLook(wResumeFailIfNotExists);
+ FormData fdResumeFailIfNotExists = new FormData();
+ fdResumeFailIfNotExists.left = new FormAttachment(middle, 0);
+ fdResumeFailIfNotExists.top = new FormAttachment(0, margin);
+ fdResumeFailIfNotExists.right = new FormAttachment(100, 0);
+ wResumeFailIfNotExists.setLayoutData(fdResumeFailIfNotExists);
+ wResumeFailIfNotExists.addListener(SWT.Selection, e -> warehouseManager.setChanged());
+
+ /////////////////////
+ // Start Suspend Warehouse Group
+ /////////////////////
+ wSuspendGroup = new Group(shell, SWT.SHADOW_ETCHED_IN);
+ wSuspendGroup.setText(
+ BaseMessages.getString(
+ PKG, "SnowflakeWarehouseManager.Dialog.Group.SuspendWarehouse.Label"));
+ FormLayout suspendWarehouseLayout = new FormLayout();
+ suspendWarehouseLayout.marginWidth = 3;
+ suspendWarehouseLayout.marginHeight = 3;
+ wSuspendGroup.setLayout(suspendWarehouseLayout);
+ props.setLook(wSuspendGroup);
+
+ FormData fdgSuspendGroup = new FormData();
+ fdgSuspendGroup.left = new FormAttachment(0, 0);
+ fdgSuspendGroup.right = new FormAttachment(100, 0);
+ fdgSuspendGroup.top = new FormAttachment(wAction, margin * 2);
+ wSuspendGroup.setLayoutData(fdgSuspendGroup);
+
+ // //////////////////////
+ // Fail if Not exists line
+ // /////////////////////
+ Label wlSuspendFailIfNotExists = new Label(wSuspendGroup, SWT.RIGHT);
+ wlSuspendFailIfNotExists.setText(
+ BaseMessages.getString(
+ PKG, "SnowflakeWarehouseManager.Dialog.Suspend.FailIfNotExists.Label"));
+ props.setLook(wlSuspendFailIfNotExists);
+ FormData fdlSuspendFailIfNotExists = new FormData();
+ fdlSuspendFailIfNotExists.left = new FormAttachment(0, 0);
+ fdlSuspendFailIfNotExists.top = new FormAttachment(0, margin);
+ fdlSuspendFailIfNotExists.right = new FormAttachment(middle, -margin);
+ wlSuspendFailIfNotExists.setLayoutData(fdlSuspendFailIfNotExists);
+
+ wSuspendFailIfNotExists = new Button(wSuspendGroup, SWT.CHECK);
+ props.setLook(wSuspendFailIfNotExists);
+ FormData fdSuspendFailIfNotExists = new FormData();
+ fdSuspendFailIfNotExists.left = new FormAttachment(middle, 0);
+ fdSuspendFailIfNotExists.top = new FormAttachment(0, margin);
+ fdSuspendFailIfNotExists.right = new FormAttachment(100, 0);
+ wSuspendFailIfNotExists.setLayoutData(fdSuspendFailIfNotExists);
+ wSuspendFailIfNotExists.addListener(SWT.Selection, e -> warehouseManager.setChanged());
+
+ /////////////////////
+ // Start Alter Warehouse Group
+ /////////////////////
+ wAlterGroup = new Group(shell, SWT.SHADOW_ETCHED_IN);
+ wAlterGroup.setText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Group.AlterWarehouse.Label"));
+ FormLayout alterWarehouseLayout = new FormLayout();
+ alterWarehouseLayout.marginWidth = 3;
+ alterWarehouseLayout.marginHeight = 3;
+ wAlterGroup.setLayout(alterWarehouseLayout);
+ props.setLook(wAlterGroup);
+
+ FormData fdgAlterGroup = new FormData();
+ fdgAlterGroup.left = new FormAttachment(0, 0);
+ fdgAlterGroup.right = new FormAttachment(100, 0);
+ fdgAlterGroup.top = new FormAttachment(wAction, margin * 2);
+ wAlterGroup.setLayoutData(fdgAlterGroup);
+
+ // //////////////////////
+ // Fail if Not exists line
+ // /////////////////////
+ Label wlAlterFailIfNotExists = new Label(wAlterGroup, SWT.RIGHT);
+ wlAlterFailIfNotExists.setText(
+ BaseMessages.getString(
+ PKG, "SnowflakeWarehouseManager.Dialog.Alter.FailIfNotExists.Label"));
+ props.setLook(wlAlterFailIfNotExists);
+ FormData fdlAlterFailIfNotExists = new FormData();
+ fdlAlterFailIfNotExists.left = new FormAttachment(0, 0);
+ fdlAlterFailIfNotExists.top = new FormAttachment(0, margin);
+ fdlAlterFailIfNotExists.right = new FormAttachment(middle, -margin);
+ wlAlterFailIfNotExists.setLayoutData(fdlAlterFailIfNotExists);
+
+ wAlterFailIfNotExists = new Button(wAlterGroup, SWT.CHECK);
+ props.setLook(wAlterFailIfNotExists);
+ FormData fdAlterFailIfNotExists = new FormData();
+ fdAlterFailIfNotExists.left = new FormAttachment(middle, 0);
+ fdAlterFailIfNotExists.top = new FormAttachment(0, margin);
+ fdAlterFailIfNotExists.right = new FormAttachment(100, 0);
+ wAlterFailIfNotExists.setLayoutData(fdAlterFailIfNotExists);
+ wAlterFailIfNotExists.addListener(SWT.Selection, e -> warehouseManager.setChanged());
+
+ // Warehouse Size
+ //
+ Label wlAlterWarehouseSize = new Label(wAlterGroup, SWT.RIGHT);
+ wlAlterWarehouseSize.setText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.AlterWarehouseSize.Label"));
+ props.setLook(wlAlterWarehouseSize);
+ FormData fdlAlterWarehouseSize = new FormData();
+ fdlAlterWarehouseSize.left = new FormAttachment(0, 0);
+ fdlAlterWarehouseSize.top = new FormAttachment(wAlterFailIfNotExists, margin);
+ fdlAlterWarehouseSize.right = new FormAttachment(middle, -margin);
+ wlAlterWarehouseSize.setLayoutData(fdlAlterWarehouseSize);
+
+ wAlterWarehouseSize = new ComboVar(variables, wAlterGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wAlterWarehouseSize);
+ wAlterWarehouseSize.addListener(SWT.Modify, e -> warehouseManager.setChanged());
+ FormData fdAlterWarehouseSize = new FormData();
+ fdAlterWarehouseSize.left = new FormAttachment(middle, 0);
+ fdAlterWarehouseSize.top = new FormAttachment(wAlterFailIfNotExists, margin);
+ fdAlterWarehouseSize.right = new FormAttachment(100, 0);
+ wAlterWarehouseSize.setLayoutData(fdAlterWarehouseSize);
+ wAlterWarehouseSize.setItems(WAREHOUSE_SIZE_DESCS);
+
+ // Warehouse Type
+ //
+ Label wlAlterWarehouseType = new Label(wAlterGroup, SWT.RIGHT);
+ wlAlterWarehouseType.setText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.AlterWarehouseType.Label"));
+ props.setLook(wlAlterWarehouseType);
+ FormData fdlAlterWarehouseType = new FormData();
+ fdlAlterWarehouseType.left = new FormAttachment(0, 0);
+ fdlAlterWarehouseType.top = new FormAttachment(wAlterWarehouseSize, margin);
+ fdlAlterWarehouseType.right = new FormAttachment(middle, -margin);
+ wlAlterWarehouseType.setLayoutData(fdlAlterWarehouseType);
+
+ wAlterWarehouseType = new ComboVar(variables, wAlterGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wAlterWarehouseType);
+ wAlterWarehouseType.addListener(SWT.Modify, e -> warehouseManager.setChanged());
+ FormData fdAlterWarehouseType = new FormData();
+ fdAlterWarehouseType.left = new FormAttachment(middle, 0);
+ fdAlterWarehouseType.top = new FormAttachment(wAlterWarehouseSize, margin);
+ fdAlterWarehouseType.right = new FormAttachment(100, 0);
+ wAlterWarehouseType.setLayoutData(fdAlterWarehouseType);
+ wAlterWarehouseType.setItems(WAREHOUSE_TYPE_DESCS);
+
+ // /////////////////////
+ // Max Cluster Size
+ // /////////////////////
+ Label wlAlterMaxClusterSize = new Label(wAlterGroup, SWT.RIGHT);
+ wlAlterMaxClusterSize.setText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Alter.MaxClusterSize.Label"));
+ props.setLook(wlAlterMaxClusterSize);
+ FormData fdlAlterMaxClusterSize = new FormData();
+ fdlAlterMaxClusterSize.left = new FormAttachment(0, 0);
+ fdlAlterMaxClusterSize.top = new FormAttachment(wAlterWarehouseType, margin);
+ fdlAlterMaxClusterSize.right = new FormAttachment(middle, -margin);
+ wlAlterMaxClusterSize.setLayoutData(fdlAlterMaxClusterSize);
+
+ wAlterMaxClusterSize = new TextVar(variables, wAlterGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wAlterGroup);
+ wAlterMaxClusterSize.addListener(SWT.Modify, e -> warehouseManager.setChanged());
+ FormData fdAlterMaxClusterSize = new FormData();
+ fdAlterMaxClusterSize.left = new FormAttachment(middle, 0);
+ fdAlterMaxClusterSize.right = new FormAttachment(100, 0);
+ fdAlterMaxClusterSize.top = new FormAttachment(wAlterWarehouseType, margin);
+ wAlterMaxClusterSize.setLayoutData(fdAlterMaxClusterSize);
+
+ // /////////////////////
+ // Min Cluster Size
+ // /////////////////////
+ Label wlAlterMinClusterSize = new Label(wAlterGroup, SWT.RIGHT);
+ wlAlterMinClusterSize.setText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Alter.MinClusterSize.Label"));
+ props.setLook(wlAlterMinClusterSize);
+ FormData fdlAlterMinClusterSize = new FormData();
+ fdlAlterMinClusterSize.left = new FormAttachment(0, 0);
+ fdlAlterMinClusterSize.top = new FormAttachment(wAlterMaxClusterSize, margin);
+ fdlAlterMinClusterSize.right = new FormAttachment(middle, -margin);
+ wlAlterMinClusterSize.setLayoutData(fdlAlterMinClusterSize);
+
+ wAlterMinClusterSize = new TextVar(variables, wAlterGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wAlterGroup);
+ wAlterMinClusterSize.addListener(SWT.Modify, e -> warehouseManager.setChanged());
+ FormData fdAlterMinClusterSize = new FormData();
+ fdAlterMinClusterSize.left = new FormAttachment(middle, 0);
+ fdAlterMinClusterSize.right = new FormAttachment(100, 0);
+ fdAlterMinClusterSize.top = new FormAttachment(wAlterMaxClusterSize, margin);
+ wAlterMinClusterSize.setLayoutData(fdAlterMinClusterSize);
+
+ // /////////////////////
+ // Auto Suspend Size
+ // /////////////////////
+ Label wlAlterAutoSuspend = new Label(wAlterGroup, SWT.RIGHT);
+ wlAlterAutoSuspend.setText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Alter.AutoSuspend.Label"));
+ wlAlterAutoSuspend.setToolTipText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Alter.AutoSuspend.Tooltip"));
+ props.setLook(wlAlterAutoSuspend);
+ FormData fdlAlterAutoSuspend = new FormData();
+ fdlAlterAutoSuspend.left = new FormAttachment(0, 0);
+ fdlAlterAutoSuspend.top = new FormAttachment(wAlterMinClusterSize, margin);
+ fdlAlterAutoSuspend.right = new FormAttachment(middle, -margin);
+ wlAlterAutoSuspend.setLayoutData(fdlAlterAutoSuspend);
+
+ wAlterAutoSuspend = new TextVar(variables, wAlterGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wAlterGroup);
+ wAlterAutoSuspend.addListener(SWT.Modify, e -> warehouseManager.setChanged());
+ FormData fdAlterAutoSuspend = new FormData();
+ fdAlterAutoSuspend.left = new FormAttachment(middle, 0);
+ fdAlterAutoSuspend.right = new FormAttachment(100, 0);
+ fdAlterAutoSuspend.top = new FormAttachment(wAlterMinClusterSize, margin);
+ wAlterAutoSuspend.setLayoutData(fdAlterAutoSuspend);
+
+ // /////////////////////
+ // Auto-resume
+ // /////////////////////
+ Label wlAlterAutoResume = new Label(wAlterGroup, SWT.RIGHT);
+ wlAlterAutoResume.setText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Alter.AutoResume.Label"));
+ props.setLook(wlAlterAutoResume);
+ FormData fdlAlterAutoResume = new FormData();
+ fdlAlterAutoResume.left = new FormAttachment(0, 0);
+ fdlAlterAutoResume.top = new FormAttachment(wAlterAutoSuspend, margin);
+ fdlAlterAutoResume.right = new FormAttachment(middle, -margin);
+ wlAlterAutoResume.setLayoutData(fdlAlterAutoResume);
+
+ wAlterAutoResume = new Button(wAlterGroup, SWT.CHECK);
+ props.setLook(wAlterAutoResume);
+ FormData fdAlterAutoResume = new FormData();
+ fdAlterAutoResume.left = new FormAttachment(middle, 0);
+ fdAlterAutoResume.top = new FormAttachment(wAlterAutoSuspend, margin);
+ fdAlterAutoResume.right = new FormAttachment(100, 0);
+ wAlterAutoResume.setLayoutData(fdAlterAutoResume);
+ wAlterAutoResume.addListener(SWT.Selection, e -> warehouseManager.setChanged());
+
+ // Resource monitor line
+ //
+ Label wlAlterResourceMonitor = new Label(wAlterGroup, SWT.RIGHT);
+ wlAlterResourceMonitor.setText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.ResourceMonitor.Label"));
+ props.setLook(wlAlterResourceMonitor);
+ FormData fdlAlterResourceMonitor = new FormData();
+ fdlAlterResourceMonitor.left = new FormAttachment(0, 0);
+ fdlAlterResourceMonitor.top = new FormAttachment(wAlterAutoResume, margin);
+ fdlAlterResourceMonitor.right = new FormAttachment(middle, -margin);
+ wlAlterResourceMonitor.setLayoutData(fdlAlterResourceMonitor);
+
+ wAlterResourceMonitor =
+ new ComboVar(variables, wAlterGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wAlterResourceMonitor);
+ wAlterResourceMonitor.addListener(SWT.Modify, e -> warehouseManager.setChanged());
+ FormData fdAlterResourceMonitor = new FormData();
+ fdAlterResourceMonitor.left = new FormAttachment(middle, 0);
+ fdAlterResourceMonitor.top = new FormAttachment(wAlterAutoResume, margin);
+ fdAlterResourceMonitor.right = new FormAttachment(100, 0);
+ wAlterResourceMonitor.setLayoutData(fdAlterResourceMonitor);
+ wAlterResourceMonitor.addFocusListener(
+ new FocusAdapter() {
+ /**
+ * Get the list of stages for the schema, and populate the stage name drop down.
+ *
+ * @param focusEvent The event
+ */
+ @SuppressWarnings("Duplicates")
+ @Override
+ public void focusGained(FocusEvent focusEvent) {
+ getResourceMonitors();
+ }
+ });
+
+ // /////////////////////
+ // Comment Line
+ // /////////////////////
+ Label wlAlterComment = new Label(wAlterGroup, SWT.RIGHT);
+ wlAlterComment.setText(
+ BaseMessages.getString(PKG, "SnowflakeWarehouseManager.Dialog.Alter.Comment.Label"));
+ props.setLook(wlAlterComment);
+ FormData fdlAlterComment = new FormData();
+ fdlAlterComment.left = new FormAttachment(0, 0);
+ fdlAlterComment.top = new FormAttachment(wAlterResourceMonitor, margin);
+ fdlAlterComment.right = new FormAttachment(middle, -margin);
+ wlAlterComment.setLayoutData(fdlAlterComment);
+
+ wAlterComment = new TextVar(variables, wAlterGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wAlterGroup);
+ wAlterComment.addListener(SWT.Modify, e -> warehouseManager.setChanged());
+ FormData fdAlterComment = new FormData();
+ fdAlterComment.left = new FormAttachment(middle, 0);
+ fdAlterComment.right = new FormAttachment(100, 0);
+ fdAlterComment.top = new FormAttachment(wAlterResourceMonitor, margin);
+ wAlterComment.setLayoutData(fdAlterComment);
+
+ // Some buttons
+ Button wOK = new Button(shell, SWT.PUSH);
+ wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
+ Button wCancel = new Button(shell, SWT.PUSH);
+ wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
+
+ BaseTransformDialog.positionBottomButtons(
+ shell, new Button[] {wOK, wCancel}, margin, wCreateGroup);
+
+ // Add listeners
+ Listener lsCancel = e -> cancel();
+ Listener lsOK = e -> ok();
+
+ wOK.addListener(SWT.Selection, lsOK);
+ wCancel.addListener(SWT.Selection, lsCancel);
+ wName.addListener(SWT.Modify, e -> warehouseManager.setChanged());
+
+ // Detect [X] or ALT-F4 or something that kills this window...
+ shell.addShellListener(
+ new ShellAdapter() {
+ @Override
+ public void shellClosed(ShellEvent e) {
+ cancel();
+ }
+ });
+
+ getData();
+ setFlags();
+ BaseTransformDialog.setSize(shell);
+
+ shell.open();
+ props.setDialogSize(shell, "WarehouseManagerSize");
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
}
- public void setFlags() {
- wCreateFailIfExists.setEnabled( !wCreateReplace.getSelection() );
- wCreateGroup.setVisible( wAction.getSelectionIndex() == WarehouseManager.MANAGEMENT_ACTION_CREATE );
- wDropGroup.setVisible( wAction.getSelectionIndex() == WarehouseManager.MANAGEMENT_ACTION_DROP );
- wResumeGroup.setVisible( wAction.getSelectionIndex() == WarehouseManager.MANAGEMENT_ACTION_RESUME );
- wSuspendGroup.setVisible( wAction.getSelectionIndex() == WarehouseManager.MANAGEMENT_ACTION_SUSPEND );
- wAlterGroup.setVisible( wAction.getSelectionIndex() == WarehouseManager.MANAGEMENT_ACTION_ALTER );
-
+ return warehouseManager;
+ }
+
+ public void setFlags() {
+ wCreateFailIfExists.setEnabled(!wCreateReplace.getSelection());
+ wCreateGroup.setVisible(
+ wAction.getSelectionIndex() == WarehouseManager.MANAGEMENT_ACTION_CREATE);
+ wDropGroup.setVisible(wAction.getSelectionIndex() == WarehouseManager.MANAGEMENT_ACTION_DROP);
+ wResumeGroup.setVisible(
+ wAction.getSelectionIndex() == WarehouseManager.MANAGEMENT_ACTION_RESUME);
+ wSuspendGroup.setVisible(
+ wAction.getSelectionIndex() == WarehouseManager.MANAGEMENT_ACTION_SUSPEND);
+ wAlterGroup.setVisible(wAction.getSelectionIndex() == WarehouseManager.MANAGEMENT_ACTION_ALTER);
+ }
+
+ public void dispose() {
+ WindowProperty winprop = new WindowProperty(shell);
+ props.setScreen(winprop);
+ shell.dispose();
+ }
+
+ public void getData() {
+ wName.setText(Const.NVL(warehouseManager.getName(), ""));
+ wConnection.setText(
+ warehouseManager.getDatabaseMeta() != null
+ ? warehouseManager.getDatabaseMeta().getName()
+ : "");
+ wWarehouseName.setText(Const.NVL(warehouseManager.getWarehouseName(), ""));
+ int actionId = warehouseManager.getManagementActionId();
+ if (actionId >= 0 && actionId < MANAGEMENT_ACTION_DESCS.length) {
+ wAction.setText(MANAGEMENT_ACTION_DESCS[actionId]);
}
-
- public void dispose() {
- WindowProperty winprop = new WindowProperty( shell );
- props.setScreen( winprop );
- shell.dispose();
+ wCreateReplace.setSelection(warehouseManager.isReplace());
+ wCreateFailIfExists.setSelection(warehouseManager.isFailIfExists());
+ int warehouseSizeId = warehouseManager.getWarehouseSizeId();
+ if (warehouseSizeId >= 0 && warehouseSizeId < WAREHOUSE_SIZE_DESCS.length) {
+ wCreateWarehouseSize.setText(WAREHOUSE_SIZE_DESCS[warehouseSizeId]);
+ } else {
+ wCreateWarehouseSize.setText(Const.NVL(warehouseManager.getWarehouseSize(), ""));
}
-
- public void getData() {
- wName.setText( Const.NVL( warehouseManager.getName(), "" ) );
- wConnection.setText( warehouseManager.getDatabaseMeta() != null ? warehouseManager.getDatabaseMeta().getName() : "" );
- wWarehouseName.setText( Const.NVL( warehouseManager.getWarehouseName(), "" ) );
- int actionId = warehouseManager.getManagementActionId();
- if ( actionId >= 0 && actionId < MANAGEMENT_ACTION_DESCS.length ) {
- wAction.setText( MANAGEMENT_ACTION_DESCS[actionId] );
- }
- wCreateReplace.setSelection( warehouseManager.isReplace() );
- wCreateFailIfExists.setSelection( warehouseManager.isFailIfExists() );
- int warehouseSizeId = warehouseManager.getWarehouseSizeId();
- if ( warehouseSizeId >= 0 && warehouseSizeId < WAREHOUSE_SIZE_DESCS.length ) {
- wCreateWarehouseSize.setText( WAREHOUSE_SIZE_DESCS[warehouseSizeId] );
- } else {
- wCreateWarehouseSize.setText( Const.NVL( warehouseManager.getWarehouseSize(), "" ) );
- }
- int warehouseTypeId = warehouseManager.getWarehouseTypeId();
- if ( warehouseTypeId >= 0 && warehouseTypeId < WAREHOUSE_TYPE_DESCS.length ) {
- wCreateWarehouseType.setText( WAREHOUSE_TYPE_DESCS[warehouseTypeId] );
- } else {
- wCreateWarehouseType.setText( Const.NVL( warehouseManager.getWarehouseType(), "" ) );
- }
- wCreateMaxClusterSize.setText( Const.NVL( warehouseManager.getMaxClusterCount(), "" ) );
- wCreateMinClusterSize.setText( Const.NVL( warehouseManager.getMinClusterCount(), "" ) );
- wCreateAutoSuspend.setText( Const.NVL( warehouseManager.getAutoSuspend(), "" ) );
- wCreateAutoResume.setSelection( warehouseManager.isAutoResume() );
- wCreateInitialSuspend.setSelection( warehouseManager.isInitiallySuspended() );
- wCreateResourceMonitor.setText( Const.NVL( warehouseManager.getResourceMonitor(), "" ) );
- wCreateComment.setText( Const.NVL( warehouseManager.getComment(), "" ) );
-
- wDropFailIfNotExists.setSelection( warehouseManager.isFailIfNotExists() );
- wResumeFailIfNotExists.setSelection( warehouseManager.isFailIfNotExists() );
- wSuspendFailIfNotExists.setSelection( warehouseManager.isFailIfNotExists() );
-
- wAlterFailIfNotExists.setSelection( warehouseManager.isFailIfNotExists() );
- if ( warehouseSizeId >= 0 && warehouseSizeId < WAREHOUSE_SIZE_DESCS.length ) {
- wAlterWarehouseSize.setText( WAREHOUSE_SIZE_DESCS[warehouseSizeId] );
- } else {
- wAlterWarehouseSize.setText( Const.NVL( warehouseManager.getWarehouseSize(), "" ) );
- }
- if ( warehouseTypeId >= 0 && warehouseTypeId < WAREHOUSE_TYPE_DESCS.length ) {
- wAlterWarehouseType.setText( WAREHOUSE_TYPE_DESCS[warehouseTypeId] );
- } else {
- wAlterWarehouseType.setText( Const.NVL( warehouseManager.getWarehouseType(), "" ) );
- }
- wAlterMaxClusterSize.setText( Const.NVL( warehouseManager.getMaxClusterCount(), "" ) );
- wAlterMinClusterSize.setText( Const.NVL( warehouseManager.getMinClusterCount(), "" ) );
- wAlterAutoSuspend.setText( Const.NVL( warehouseManager.getAutoSuspend(), "" ) );
- wAlterAutoResume.setSelection( warehouseManager.isAutoResume() );
- wAlterResourceMonitor.setText( Const.NVL( warehouseManager.getResourceMonitor(), "" ) );
- wAlterComment.setText( Const.NVL( warehouseManager.getComment(), "" ) );
-
- if ( StringUtil.isEmpty( wAction.getText() ) ) {
- wAction.setText( MANAGEMENT_ACTION_DESCS[0] );
- }
-
- wName.selectAll();
- wName.setFocus();
+ int warehouseTypeId = warehouseManager.getWarehouseTypeId();
+ if (warehouseTypeId >= 0 && warehouseTypeId < WAREHOUSE_TYPE_DESCS.length) {
+ wCreateWarehouseType.setText(WAREHOUSE_TYPE_DESCS[warehouseTypeId]);
+ } else {
+ wCreateWarehouseType.setText(Const.NVL(warehouseManager.getWarehouseType(), ""));
}
-
- private void cancel() {
- warehouseManager.setChanged( backupChanged );
-
- warehouseManager = null;
- dispose();
+ wCreateMaxClusterSize.setText(Const.NVL(warehouseManager.getMaxClusterCount(), ""));
+ wCreateMinClusterSize.setText(Const.NVL(warehouseManager.getMinClusterCount(), ""));
+ wCreateAutoSuspend.setText(Const.NVL(warehouseManager.getAutoSuspend(), ""));
+ wCreateAutoResume.setSelection(warehouseManager.isAutoResume());
+ wCreateInitialSuspend.setSelection(warehouseManager.isInitiallySuspended());
+ wCreateResourceMonitor.setText(Const.NVL(warehouseManager.getResourceMonitor(), ""));
+ wCreateComment.setText(Const.NVL(warehouseManager.getComment(), ""));
+
+ wDropFailIfNotExists.setSelection(warehouseManager.isFailIfNotExists());
+ wResumeFailIfNotExists.setSelection(warehouseManager.isFailIfNotExists());
+ wSuspendFailIfNotExists.setSelection(warehouseManager.isFailIfNotExists());
+
+ wAlterFailIfNotExists.setSelection(warehouseManager.isFailIfNotExists());
+ if (warehouseSizeId >= 0 && warehouseSizeId < WAREHOUSE_SIZE_DESCS.length) {
+ wAlterWarehouseSize.setText(WAREHOUSE_SIZE_DESCS[warehouseSizeId]);
+ } else {
+ wAlterWarehouseSize.setText(Const.NVL(warehouseManager.getWarehouseSize(), ""));
+ }
+ if (warehouseTypeId >= 0 && warehouseTypeId < WAREHOUSE_TYPE_DESCS.length) {
+ wAlterWarehouseType.setText(WAREHOUSE_TYPE_DESCS[warehouseTypeId]);
+ } else {
+ wAlterWarehouseType.setText(Const.NVL(warehouseManager.getWarehouseType(), ""));
+ }
+ wAlterMaxClusterSize.setText(Const.NVL(warehouseManager.getMaxClusterCount(), ""));
+ wAlterMinClusterSize.setText(Const.NVL(warehouseManager.getMinClusterCount(), ""));
+ wAlterAutoSuspend.setText(Const.NVL(warehouseManager.getAutoSuspend(), ""));
+ wAlterAutoResume.setSelection(warehouseManager.isAutoResume());
+ wAlterResourceMonitor.setText(Const.NVL(warehouseManager.getResourceMonitor(), ""));
+ wAlterComment.setText(Const.NVL(warehouseManager.getComment(), ""));
+
+ if (StringUtil.isEmpty(wAction.getText())) {
+ wAction.setText(MANAGEMENT_ACTION_DESCS[0]);
}
- private void ok() {
- if ( StringUtil.isEmpty( wName.getText() ) ) {
- MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
- mb.setText( BaseMessages.getString( PKG, "System.ActionNameMissing.Title" ) );
- mb.setMessage( BaseMessages.getString( PKG, "System.ActionNameMissing.Msg" ) );
- mb.open();
- return;
- }
- warehouseManager.setName( wName.getText() );
- warehouseManager.setDatabaseMeta( workflowMeta.findDatabase( Const.NVL( wConnection.getText(), "" ) ) );
- warehouseManager.setWarehouseName( wWarehouseName.getText() );
- warehouseManager.setManagementActionById( wAction.getSelectionIndex() );
- if ( wAction.getSelectionIndex() == WarehouseManager.MANAGEMENT_ACTION_CREATE ) {
- warehouseManager.setReplace( wCreateReplace.getSelection() );
- warehouseManager.setFailIfExists( wCreateFailIfExists.getSelection() );
- boolean warehouseSizeFound = false;
- for ( int i = 0; i < WAREHOUSE_SIZE_DESCS.length; i++ ) {
- if ( wCreateWarehouseSize.getText().equals( WAREHOUSE_SIZE_DESCS[i] ) ) {
- warehouseSizeFound = true;
- warehouseManager.setWarehouseSizeById( i );
- break;
- }
- }
- if ( !warehouseSizeFound ) {
- warehouseManager.setWarehouseSize( wCreateWarehouseSize.getText() );
- }
+ wName.selectAll();
+ wName.setFocus();
+ }
- boolean warehouseTypeFound = false;
- for ( int i = 0; i < WAREHOUSE_TYPE_DESCS.length; i++ ) {
- if ( wCreateWarehouseType.getText().equals( WAREHOUSE_TYPE_DESCS[i] ) ) {
- warehouseTypeFound = true;
- warehouseManager.setWarehouseTypeById( i );
- break;
- }
- }
- if ( !warehouseTypeFound ) {
- warehouseManager.setWarehouseType( wCreateWarehouseType.getText() );
- }
+ private void cancel() {
+ warehouseManager.setChanged(backupChanged);
- warehouseManager.setMaxClusterCount( wCreateMaxClusterSize.getText() );
- warehouseManager.setMinClusterCount( wCreateMinClusterSize.getText() );
- warehouseManager.setAutoResume( wCreateAutoResume.getSelection() );
- warehouseManager.setAutoSuspend( wCreateAutoSuspend.getText() );
- warehouseManager.setInitiallySuspended( wCreateInitialSuspend.getSelection() );
- warehouseManager.setResourceMonitor( wCreateResourceMonitor.getText() );
- warehouseManager.setComment( wCreateComment.getText() );
- } else if ( wAction.getSelectionIndex() == WarehouseManager.MANAGEMENT_ACTION_DROP ) {
- warehouseManager.setFailIfNotExists( wDropFailIfNotExists.getSelection() );
- } else if ( wAction.getSelectionIndex() == WarehouseManager.MANAGEMENT_ACTION_RESUME ) {
- warehouseManager.setFailIfNotExists( wResumeFailIfNotExists.getSelection() );
- } else if ( wAction.getSelectionIndex() == WarehouseManager.MANAGEMENT_ACTION_SUSPEND ) {
- warehouseManager.setFailIfNotExists( wSuspendFailIfNotExists.getSelection() );
- } else if ( wAction.getSelectionIndex() == WarehouseManager.MANAGEMENT_ACTION_ALTER ) {
- warehouseManager.setFailIfNotExists( wAlterFailIfNotExists.getSelection() );
- boolean warehouseSizeFound = false;
- for ( int i = 0; i < WAREHOUSE_SIZE_DESCS.length; i++ ) {
- if ( wAlterWarehouseSize.getText().equals( WAREHOUSE_SIZE_DESCS[i] ) ) {
- warehouseSizeFound = true;
- warehouseManager.setWarehouseSizeById( i );
- break;
- }
- }
- if ( !warehouseSizeFound ) {
- warehouseManager.setWarehouseSize( wAlterWarehouseSize.getText() );
- }
+ warehouseManager = null;
+ dispose();
+ }
- boolean warehouseTypeFound = false;
- for ( int i = 0; i < WAREHOUSE_TYPE_DESCS.length; i++ ) {
- if ( wAlterWarehouseType.getText().equals( WAREHOUSE_TYPE_DESCS[i] ) ) {
- warehouseTypeFound = true;
- warehouseManager.setWarehouseTypeById( i );
- break;
- }
- }
- if ( !warehouseTypeFound ) {
- warehouseManager.setWarehouseType( wAlterWarehouseType.getText() );
- }
-
- warehouseManager.setMaxClusterCount( wAlterMaxClusterSize.getText() );
- warehouseManager.setMinClusterCount( wAlterMinClusterSize.getText() );
- warehouseManager.setAutoResume( wAlterAutoResume.getSelection() );
- warehouseManager.setAutoSuspend( wAlterAutoSuspend.getText() );
- warehouseManager.setResourceMonitor( wAlterResourceMonitor.getText() );
- warehouseManager.setComment( wAlterComment.getText() );
+ private void ok() {
+ if (StringUtil.isEmpty(wName.getText())) {
+ MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
+ mb.setText(BaseMessages.getString(PKG, "System.ActionNameMissing.Title"));
+ mb.setMessage(BaseMessages.getString(PKG, "System.ActionNameMissing.Msg"));
+ mb.open();
+ return;
+ }
+ warehouseManager.setName(wName.getText());
+ warehouseManager.setDatabaseMeta(
+ workflowMeta.findDatabase(Const.NVL(wConnection.getText(), ""), variables));
+ warehouseManager.setWarehouseName(wWarehouseName.getText());
+ warehouseManager.setManagementActionById(wAction.getSelectionIndex());
+ if (wAction.getSelectionIndex() == WarehouseManager.MANAGEMENT_ACTION_CREATE) {
+ warehouseManager.setReplace(wCreateReplace.getSelection());
+ warehouseManager.setFailIfExists(wCreateFailIfExists.getSelection());
+ boolean warehouseSizeFound = false;
+ for (int i = 0; i < WAREHOUSE_SIZE_DESCS.length; i++) {
+ if (wCreateWarehouseSize.getText().equals(WAREHOUSE_SIZE_DESCS[i])) {
+ warehouseSizeFound = true;
+ warehouseManager.setWarehouseSizeById(i);
+ break;
}
-
- dispose();
+ }
+ if (!warehouseSizeFound) {
+ warehouseManager.setWarehouseSize(wCreateWarehouseSize.getText());
+ }
+
+ boolean warehouseTypeFound = false;
+ for (int i = 0; i < WAREHOUSE_TYPE_DESCS.length; i++) {
+ if (wCreateWarehouseType.getText().equals(WAREHOUSE_TYPE_DESCS[i])) {
+ warehouseTypeFound = true;
+ warehouseManager.setWarehouseTypeById(i);
+ break;
+ }
+ }
+ if (!warehouseTypeFound) {
+ warehouseManager.setWarehouseType(wCreateWarehouseType.getText());
+ }
+
+ warehouseManager.setMaxClusterCount(wCreateMaxClusterSize.getText());
+ warehouseManager.setMinClusterCount(wCreateMinClusterSize.getText());
+ warehouseManager.setAutoResume(wCreateAutoResume.getSelection());
+ warehouseManager.setAutoSuspend(wCreateAutoSuspend.getText());
+ warehouseManager.setInitiallySuspended(wCreateInitialSuspend.getSelection());
+ warehouseManager.setResourceMonitor(wCreateResourceMonitor.getText());
+ warehouseManager.setComment(wCreateComment.getText());
+ } else if (wAction.getSelectionIndex() == WarehouseManager.MANAGEMENT_ACTION_DROP) {
+ warehouseManager.setFailIfNotExists(wDropFailIfNotExists.getSelection());
+ } else if (wAction.getSelectionIndex() == WarehouseManager.MANAGEMENT_ACTION_RESUME) {
+ warehouseManager.setFailIfNotExists(wResumeFailIfNotExists.getSelection());
+ } else if (wAction.getSelectionIndex() == WarehouseManager.MANAGEMENT_ACTION_SUSPEND) {
+ warehouseManager.setFailIfNotExists(wSuspendFailIfNotExists.getSelection());
+ } else if (wAction.getSelectionIndex() == WarehouseManager.MANAGEMENT_ACTION_ALTER) {
+ warehouseManager.setFailIfNotExists(wAlterFailIfNotExists.getSelection());
+ boolean warehouseSizeFound = false;
+ for (int i = 0; i < WAREHOUSE_SIZE_DESCS.length; i++) {
+ if (wAlterWarehouseSize.getText().equals(WAREHOUSE_SIZE_DESCS[i])) {
+ warehouseSizeFound = true;
+ warehouseManager.setWarehouseSizeById(i);
+ break;
+ }
+ }
+ if (!warehouseSizeFound) {
+ warehouseManager.setWarehouseSize(wAlterWarehouseSize.getText());
+ }
+
+ boolean warehouseTypeFound = false;
+ for (int i = 0; i < WAREHOUSE_TYPE_DESCS.length; i++) {
+ if (wAlterWarehouseType.getText().equals(WAREHOUSE_TYPE_DESCS[i])) {
+ warehouseTypeFound = true;
+ warehouseManager.setWarehouseTypeById(i);
+ break;
+ }
+ }
+ if (!warehouseTypeFound) {
+ warehouseManager.setWarehouseType(wAlterWarehouseType.getText());
+ }
+
+ warehouseManager.setMaxClusterCount(wAlterMaxClusterSize.getText());
+ warehouseManager.setMinClusterCount(wAlterMinClusterSize.getText());
+ warehouseManager.setAutoResume(wAlterAutoResume.getSelection());
+ warehouseManager.setAutoSuspend(wAlterAutoSuspend.getText());
+ warehouseManager.setResourceMonitor(wAlterResourceMonitor.getText());
+ warehouseManager.setComment(wAlterComment.getText());
}
-
- public void getResourceMonitors() {
- DatabaseMeta databaseMeta = workflowMeta.findDatabase( wConnection.getText() );
- if ( databaseMeta != null ) {
- String warehouseName = wWarehouseName.getText();
- wWarehouseName.removeAll();
- Database db = null;
- try {
- db = new Database( loggingObject, variables, databaseMeta );
- db.connect();
- ResultSet resultSet = db.openQuery( "show resource monitors;", null, null, ResultSet.FETCH_FORWARD, false );
- IRowMeta rowMeta = db.getReturnRowMeta();
- Object[] row = db.getRow( resultSet );
- int nameField = rowMeta.indexOfValue( "NAME" );
- if ( nameField >= 0 ) {
- while ( row != null ) {
- String name = rowMeta.getString( row, nameField );
- wWarehouseName.add( name );
- row = db.getRow( resultSet );
- }
- } else {
- throw new HopException( "Unable to find resource monitor name field in result" );
- }
- db.closeQuery( resultSet );
- if ( warehouseName != null ) {
- wWarehouseName.setText( warehouseName );
- }
- } catch ( Exception ex ) {
- warehouseManager.logDebug( "Error getting resource monitors", ex );
- } finally {
- db.disconnect();
- }
+ dispose();
+ }
+
+ public void getResourceMonitors() {
+ DatabaseMeta databaseMeta = workflowMeta.findDatabase(wConnection.getText(), variables);
+ if (databaseMeta != null) {
+ String warehouseName = wWarehouseName.getText();
+ wWarehouseName.removeAll();
+ Database db = null;
+ try {
+ db = new Database(loggingObject, variables, databaseMeta);
+ db.connect();
+ ResultSet resultSet =
+ db.openQuery("show resource monitors;", null, null, ResultSet.FETCH_FORWARD, false);
+ IRowMeta rowMeta = db.getReturnRowMeta();
+ Object[] row = db.getRow(resultSet);
+ int nameField = rowMeta.indexOfValue("NAME");
+ if (nameField >= 0) {
+ while (row != null) {
+ String name = rowMeta.getString(row, nameField);
+ wWarehouseName.add(name);
+ row = db.getRow(resultSet);
+ }
+ } else {
+ throw new HopException("Unable to find resource monitor name field in result");
+ }
+ db.closeQuery(resultSet);
+ if (warehouseName != null) {
+ wWarehouseName.setText(warehouseName);
}
+ } catch (Exception ex) {
+ warehouseManager.logDebug("Error getting resource monitors", ex);
+ } finally {
+ db.disconnect();
+ }
}
+ }
}
diff --git a/plugins/transforms/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoader.java b/plugins/transforms/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoader.java
index 5bc8eee5a7..2ca70dfee7 100644
--- a/plugins/transforms/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoader.java
+++ b/plugins/transforms/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoader.java
@@ -39,819 +39,858 @@ import org.apache.hop.pipeline.transform.TransformMeta;
import java.io.BufferedOutputStream;
import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
-/**
- * Bulk loads data to Snowflake
- */
-@SuppressWarnings( { "UnusedAssignment", "ConstantConditions" } )
-public class SnowflakeBulkLoader extends BaseTransform<SnowflakeBulkLoaderMeta, SnowflakeBulkLoaderData> {
- private static Class<?> PKG = SnowflakeBulkLoaderMeta.class; // for i18n purposes, needed by Translator2!!
-
- public SnowflakeBulkLoader(TransformMeta transformMeta, SnowflakeBulkLoaderMeta meta, SnowflakeBulkLoaderData data,
- int copyNr, PipelineMeta pipelineMeta, Pipeline pipeline ) {
- super( transformMeta, meta, data, copyNr, pipelineMeta, pipeline );
- }
-
- /**
- * Receive an input row from the stream, and write it to a local temp file. After receiving the last row,
- * run the put and copy commands to copy the data into Snowflake.
- * @return Was the row successfully processed.
- * @throws HopException
- */
- @SuppressWarnings( "deprecation" )
- public synchronized boolean processRow() throws HopException {
-
- Object[] row = getRow(); // This also waits for a row to be finished.
-
- if ( row != null && first ) {
- first = false;
- data.outputRowMeta = getInputRowMeta().clone();
- meta.getFields( data.outputRowMeta, getTransformName(), null, null, this, metadataProvider );
-
- // Open a new file here
- //
- openNewFile( buildFilename() );
- data.oneFileOpened = true;
- initBinaryDataFields();
-
- if ( meta.isSpecifyFields() && meta.getDataType().equals(
- SnowflakeBulkLoaderMeta.DATA_TYPE_CODES[SnowflakeBulkLoaderMeta.DATA_TYPE_CSV] ) ) {
- // Get input field mapping
- data.fieldnrs = new HashMap<>();
- getDbFields();
- for ( int i = 0; i < meta.getSnowflakeBulkLoaderFields().size(); i++ ) {
- int streamFieldLocation = data.outputRowMeta.indexOfValue(
- meta.getSnowflakeBulkLoaderFields().get(i).getStreamField() );
- if ( streamFieldLocation < 0 ) {
- throw new HopTransformException( "Field [" + meta.getSnowflakeBulkLoaderFields().get(i).getStreamField()
- + "] couldn't be found in the input stream!" );
- }
-
- int dbFieldLocation = -1;
- for ( int e = 0; e < data.dbFields.size(); e++ ) {
- String[] field = data.dbFields.get( e );
- if ( field[0].equalsIgnoreCase( meta.getSnowflakeBulkLoaderFields().get(i).getTableField() ) ) {
- dbFieldLocation = e;
- break;
- }
- }
- if ( dbFieldLocation < 0 ) {
- throw new HopException( "Field [" + meta.getSnowflakeBulkLoaderFields().get(i).getTableField()
- + "] couldn't be found in the table!" );
- }
-
- data.fieldnrs.put( meta.getSnowflakeBulkLoaderFields().get(i).getTableField().toUpperCase(), streamFieldLocation );
- }
- } else if ( meta.getDataType().equals(
- SnowflakeBulkLoaderMeta.DATA_TYPE_CODES[SnowflakeBulkLoaderMeta.DATA_TYPE_JSON] ) ) {
- data.fieldnrs = new HashMap<>();
- int streamFieldLocation = data.outputRowMeta.indexOfValue( meta.getJsonField() );
- if ( streamFieldLocation < 0 ) {
- throw new HopTransformException( "Field [" + meta.getJsonField()
- + "] couldn't be found in the input stream!" );
- }
- data.fieldnrs.put( "json", streamFieldLocation );
- }
-
- }
-
- // Create a new split?
- if ( ( row != null && data.outputCount > 0 && Const.toInt( resolve( meta.getSplitSize() ), 0 ) > 0
- && ( data.outputCount % Const.toInt( resolve( meta.getSplitSize() ), 0 ) ) == 0 ) ) {
-
- // Done with this part or with everything.
- closeFile();
-
- // Not finished: open another file...
- openNewFile( buildFilename() );
+/** Bulk loads data to Snowflake */
+@SuppressWarnings({"UnusedAssignment", "ConstantConditions"})
+public class SnowflakeBulkLoader
+ extends BaseTransform<SnowflakeBulkLoaderMeta, SnowflakeBulkLoaderData> {
+ private static final Class<?> PKG =
+ SnowflakeBulkLoaderMeta.class; // for i18n purposes, needed by Translator2!!
+
+ public SnowflakeBulkLoader(
+ TransformMeta transformMeta,
+ SnowflakeBulkLoaderMeta meta,
+ SnowflakeBulkLoaderData data,
+ int copyNr,
+ PipelineMeta pipelineMeta,
+ Pipeline pipeline) {
+ super(transformMeta, meta, data, copyNr, pipelineMeta, pipeline);
+ }
+
+ /**
+ * Receive an input row from the stream, and write it to a local temp file. After receiving the
+ * last row, run the put and copy commands to copy the data into Snowflake.
+ *
+ * @return Was the row successfully processed.
+ * @throws HopException
+ */
+ @SuppressWarnings("deprecation")
+ @Override
+ public synchronized boolean processRow() throws HopException {
+
+ Object[] row = getRow(); // This also waits for a row to be finished.
+
+ if (row != null && first) {
+ first = false;
+ data.outputRowMeta = getInputRowMeta().clone();
+ meta.getFields(data.outputRowMeta, getTransformName(), null, null, this, metadataProvider);
+
+ // Open a new file here
+ //
+ openNewFile(buildFilename());
+ data.oneFileOpened = true;
+ initBinaryDataFields();
+
+ if (meta.isSpecifyFields()
+ && meta.getDataType()
+ .equals(
+ SnowflakeBulkLoaderMeta.DATA_TYPE_CODES[SnowflakeBulkLoaderMeta.DATA_TYPE_CSV])) {
+ // Get input field mapping
+ data.fieldnrs = new HashMap<>();
+ getDbFields();
+ for (int i = 0; i < meta.getSnowflakeBulkLoaderFields().size(); i++) {
+ int streamFieldLocation =
+ data.outputRowMeta.indexOfValue(
+ meta.getSnowflakeBulkLoaderFields().get(i).getStreamField());
+ if (streamFieldLocation < 0) {
+ throw new HopTransformException(
+ "Field ["
+ + meta.getSnowflakeBulkLoaderFields().get(i).getStreamField()
+ + "] couldn't be found in the input stream!");
+ }
+
+ int dbFieldLocation = -1;
+ for (int e = 0; e < data.dbFields.size(); e++) {
+ String[] field = data.dbFields.get(e);
+ if (field[0].equalsIgnoreCase(
+ meta.getSnowflakeBulkLoaderFields().get(i).getTableField())) {
+ dbFieldLocation = e;
+ break;
+ }
+ }
+ if (dbFieldLocation < 0) {
+ throw new HopException(
+ "Field ["
+ + meta.getSnowflakeBulkLoaderFields().get(i).getTableField()
+ + "] couldn't be found in the table!");
+ }
+
+ data.fieldnrs.put(
+ meta.getSnowflakeBulkLoaderFields().get(i).getTableField().toUpperCase(),
+ streamFieldLocation);
}
-
- if ( row == null ) {
- // no more input to be expected...
- closeFile();
- loadDatabase();
- setOutputDone();
- return false;
+ } else if (meta.getDataType()
+ .equals(
+ SnowflakeBulkLoaderMeta.DATA_TYPE_CODES[SnowflakeBulkLoaderMeta.DATA_TYPE_JSON])) {
+ data.fieldnrs = new HashMap<>();
+ int streamFieldLocation = data.outputRowMeta.indexOfValue(meta.getJsonField());
+ if (streamFieldLocation < 0) {
+ throw new HopTransformException(
+ "Field [" + meta.getJsonField() + "] couldn't be found in the input stream!");
}
+ data.fieldnrs.put("json", streamFieldLocation);
+ }
+ }
- writeRowToFile( data.outputRowMeta, row );
- putRow( data.outputRowMeta, row ); // in case we want it to go further...
+ // Create a new split?
+ if ((row != null
+ && data.outputCount > 0
+ && Const.toInt(resolve(meta.getSplitSize()), 0) > 0
+ && (data.outputCount % Const.toInt(resolve(meta.getSplitSize()), 0)) == 0)) {
- if ( checkFeedback( data.outputCount ) ) {
- logBasic( "linenr " + data.outputCount );
- }
+ // Done with this part or with everything.
+ closeFile();
- return true;
+ // Not finished: open another file...
+ openNewFile(buildFilename());
}
- /**
- * Runs a desc table to get the fields, and field types from the database. Uses a desc table as opposed
- * to the select * from table limit 0 that Hop normally uses to get the fields and types, due to the need
- * to handle the Time type. The select * method through Hop does not give us the ability to differentiate
- * time from timestamp.
- * @throws HopException
- */
- private void getDbFields() throws HopException {
- data.dbFields = new ArrayList<>();
- String SQL = "desc table ";
- if ( !StringUtils.isEmpty( resolve( meta.getTargetSchema() ) ) ) {
- SQL += resolve( meta.getTargetSchema() ) + ".";
- }
- SQL += resolve( meta.getTargetTable() );
- logDetailed( "Executing SQL " + SQL );
- try {
- ResultSet resultSet = data.db.openQuery( SQL, null, null, ResultSet.FETCH_FORWARD, false );
+ if (row == null) {
+ // no more input to be expected...
+ closeFile();
+ loadDatabase();
+ setOutputDone();
+ return false;
+ }
- IRowMeta rowMeta = data.db.getReturnRowMeta();
- int nameField = rowMeta.indexOfValue( "NAME" );
- int typeField = rowMeta.indexOfValue( "TYPE" );
- if ( nameField < 0 || typeField < 0 ) {
- throw new HopException( "Unable to get database fields" );
- }
+ writeRowToFile(data.outputRowMeta, row);
+ putRow(data.outputRowMeta, row); // in case we want it to go further...
- Object[] row = data.db.getRow( resultSet );
- if ( row == null ) {
- throw new HopException( "No fields found in table" );
- }
- while ( row != null ) {
- String[] field = new String[2];
- field[0] = rowMeta.getString( row, nameField ).toUpperCase();
- field[1] = rowMeta.getString( row, typeField );
- data.dbFields.add( field );
- row = data.db.getRow( resultSet );
- }
- data.db.closeQuery( resultSet );
- } catch ( Exception ex ) {
- throw new HopException( "Error getting database fields", ex );
- }
+ if (checkFeedback(data.outputCount)) {
+ logBasic("linenr " + data.outputCount);
}
- /**
- * Runs the commands to put the data to the Snowflake stage, the copy command to load the table, and finally
- * a commit to commit the transaction.
- * @throws HopDatabaseException
- * @throws HopFileException
- * @throws HopValueException
- */
- private void loadDatabase() throws HopDatabaseException, HopFileException, HopValueException {
- boolean filesUploaded = false;
- boolean endsWithSlash = resolve( meta.getWorkDirectory() ).endsWith( "\\" )
- || resolve( meta.getWorkDirectory() ).endsWith( "/" );
- String SQL = "PUT 'file://" + resolve( meta.getWorkDirectory() ).replaceAll( "\\\\", "/" )
- + ( endsWithSlash ? "" : "/" ) + resolve( meta.getTargetTable() ) + "_"
- + meta.getFileDate() + "_*' " + meta.getStage( this ) + ";";
-
- logDebug( "Executing SQL " + SQL );
- ResultSet putResultSet = data.db.openQuery( SQL, null, null, ResultSet.FETCH_FORWARD, false );
- IRowMeta putRowMeta = data.db.getReturnRowMeta();
- Object[] putRow = data.db.getRow( putResultSet );
- logDebug( "=========================Put File Results======================" );
- int fileNum = 0;
- while ( putRow != null ) {
- logDebug( "------------------------ File " + fileNum +"--------------------------" );
- for ( int i = 0; i < putRowMeta.getFieldNames().length; i++ ) {
- logDebug( putRowMeta.getFieldNames()[i] + " = " + putRowMeta.getString( putRow, i ) );
- if( putRowMeta.getFieldNames()[i].equalsIgnoreCase( "status" ) ) {
- if( putRowMeta.getString( putRow, i ).equalsIgnoreCase( "ERROR" ) ) {
- throw new HopDatabaseException( "Error putting file to Snowflake stage \n" + putRowMeta.getString( putRow, "message", "" ) );
- }
- }
- }
- fileNum++;
+ return true;
+ }
+
+ /**
+ * Runs a desc table to get the fields, and field types from the database. Uses a desc table as
+ * opposed to the select * from table limit 0 that Hop normally uses to get the fields and types,
+ * due to the need to handle the Time type. The select * method through Hop does not give us the
+ * ability to differentiate time from timestamp.
+ *
+ * @throws HopException
+ */
+ private void getDbFields() throws HopException {
+ data.dbFields = new ArrayList<>();
+ String sql = "desc table ";
+ if (!StringUtils.isEmpty(resolve(meta.getTargetSchema()))) {
+ sql += resolve(meta.getTargetSchema()) + ".";
+ }
+ sql += resolve(meta.getTargetTable());
+ logDetailed("Executing SQL " + sql);
+ try {
+ ResultSet resultSet = data.db.openQuery(sql, null, null, ResultSet.FETCH_FORWARD, false);
+
+ IRowMeta rowMeta = data.db.getReturnRowMeta();
+ int nameField = rowMeta.indexOfValue("NAME");
+ int typeField = rowMeta.indexOfValue("TYPE");
+ if (nameField < 0 || typeField < 0) {
+ throw new HopException("Unable to get database fields");
+ }
+
+ Object[] row = data.db.getRow(resultSet);
+ if (row == null) {
+ throw new HopException("No fields found in table");
+ }
+ while (row != null) {
+ String[] field = new String[2];
+ field[0] = rowMeta.getString(row, nameField).toUpperCase();
+ field[1] = rowMeta.getString(row, typeField);
+ data.dbFields.add(field);
+ row = data.db.getRow(resultSet);
+ }
+ data.db.closeQuery(resultSet);
+ } catch (Exception ex) {
+ throw new HopException("Error getting database fields", ex);
+ }
+ }
+
+ /**
+ * Runs the commands to put the data to the Snowflake stage, the copy command to load the table,
+ * and finally a commit to commit the transaction.
+ *
+ * @throws HopDatabaseException
+ * @throws HopFileException
+ * @throws HopValueException
+ */
+ private void loadDatabase() throws HopDatabaseException, HopFileException, HopValueException {
+ boolean endsWithSlash =
+ resolve(meta.getWorkDirectory()).endsWith("\\")
+ || resolve(meta.getWorkDirectory()).endsWith("/");
+ String sql =
+ "PUT 'file://"
+ + resolve(meta.getWorkDirectory()).replaceAll("\\\\", "/")
+ + (endsWithSlash ? "" : "/")
+ + resolve(meta.getTargetTable())
+ + "_"
+ + meta.getFileDate()
+ + "_*' "
+ + meta.getStage(this)
+ + ";";
+
+ logDebug("Executing SQL " + sql);
+ ResultSet putResultSet = data.db.openQuery(sql, null, null, ResultSet.FETCH_FORWARD, false);
+ IRowMeta putRowMeta = data.db.getReturnRowMeta();
+ Object[] putRow = data.db.getRow(putResultSet);
+ logDebug("=========================Put File Results======================");
+ int fileNum = 0;
+ while (putRow != null) {
+ logDebug("------------------------ File " + fileNum + "--------------------------");
+ for (int i = 0; i < putRowMeta.getFieldNames().length; i++) {
+ logDebug(putRowMeta.getFieldNames()[i] + " = " + putRowMeta.getString(putRow, i));
+ if (putRowMeta.getFieldNames()[i].equalsIgnoreCase("status")
+ && putRowMeta.getString(putRow, i).equalsIgnoreCase("ERROR")) {
+ throw new HopDatabaseException(
+ "Error putting file to Snowflake stage \n"
+ + putRowMeta.getString(putRow, "message", ""));
+ }
+ }
+ fileNum++;
- putRow = data.db.getRow( putResultSet );
+ putRow = data.db.getRow(putResultSet);
+ }
+ data.db.closeQuery(putResultSet);
+
+ String copySQL = meta.getCopyStatement(this, data.getPreviouslyOpenedFiles());
+ logDebug("Executing SQL " + copySQL);
+ ResultSet resultSet = data.db.openQuery(copySQL, null, null, ResultSet.FETCH_FORWARD, false);
+ IRowMeta rowMeta = data.db.getReturnRowMeta();
+
+ Object[] row = data.db.getRow(resultSet);
+ int rowsLoaded = 0;
+ int rowsLoadedField = rowMeta.indexOfValue("rows_loaded");
+ int rowsError = 0;
+ int errorField = rowMeta.indexOfValue("errors_seen");
+ logBasic("====================== Bulk Load Results======================");
+ int rowNum = 1;
+ while (row != null) {
+ logBasic("---------------------- Row " + rowNum + " ----------------------");
+ for (int i = 0; i < rowMeta.getFieldNames().length; i++) {
+ logBasic(rowMeta.getFieldNames()[i] + " = " + rowMeta.getString(row, i));
+ }
+
+ if (rowsLoadedField >= 0) {
+ rowsLoaded += rowMeta.getInteger(row, rowsLoadedField);
+ }
+
+ if (errorField >= 0) {
+ rowsError += rowMeta.getInteger(row, errorField);
+ }
+
+ rowNum++;
+ row = data.db.getRow(resultSet);
+ }
+ data.db.closeQuery(resultSet);
+ setLinesOutput(rowsLoaded);
+ setLinesRejected(rowsError);
+
+ data.db.execStatement("commit");
+ }
+
+ /**
+ * Writes an individual row of data to a temp file
+ *
+ * @param rowMeta The metadata about the row
+ * @param row The input row
+ * @throws HopTransformException
+ */
+ private void writeRowToFile(IRowMeta rowMeta, Object[] row) throws HopTransformException {
+ try {
+ if (meta.getDataTypeId() == SnowflakeBulkLoaderMeta.DATA_TYPE_CSV
+ && !meta.isSpecifyFields()) {
+ /*
+ * Write all values in stream to text file.
+ */
+ for (int i = 0; i < rowMeta.size(); i++) {
+ if (i > 0 && data.binarySeparator.length > 0) {
+ data.writer.write(data.binarySeparator);
+ }
+ IValueMeta v = rowMeta.getValueMeta(i);
+ Object valueData = row[i];
+
+ // no special null value default was specified since no fields are specified at all
+ // As such, we pass null
+ //
+ writeField(v, valueData, null);
}
- data.db.closeQuery( putResultSet );
-
- String copySQL = meta.getCopyStatement( this, data.getPreviouslyOpenedFiles() );
- logDebug( "Executing SQL " + copySQL );
- ResultSet resultSet = data.db.openQuery( copySQL, null, null, ResultSet.FETCH_FORWARD, false );
- IRowMeta rowMeta = data.db.getReturnRowMeta();
-
- Object[] row = data.db.getRow( resultSet );
- int rowsLoaded = 0;
- int rowsLoadedField = rowMeta.indexOfValue( "rows_loaded" );
- int rowsError = 0;
- int errorField = rowMeta.indexOfValue( "errors_seen" );
- logBasic( "====================== Bulk Load Results======================" );
- int rowNum = 1;
- while ( row != null ) {
- logBasic( "---------------------- Row " + rowNum + " ----------------------" );
- for ( int i = 0; i < rowMeta.getFieldNames().length; i++ ) {
- logBasic( rowMeta.getFieldNames()[i] + " = " + rowMeta.getString( row, i ) );
+ data.writer.write(data.binaryNewline);
+ } else if (meta.getDataTypeId() == SnowflakeBulkLoaderMeta.DATA_TYPE_CSV) {
+ /*
+ * Only write the fields specified!
+ */
+ for (int i = 0; i < data.dbFields.size(); i++) {
+ if (data.dbFields.get(i) != null) {
+ if (i > 0 && data.binarySeparator.length > 0) {
+ data.writer.write(data.binarySeparator);
+ }
+
+ String[] field = data.dbFields.get(i);
+ IValueMeta v;
+
+ if (field[1].toUpperCase().startsWith("TIMESTAMP")) {
+ v = new ValueMetaDate();
+ v.setConversionMask("yyyy-MM-dd HH:mm:ss.SSS");
+ } else if (field[1].toUpperCase().startsWith("DATE")) {
+ v = new ValueMetaDate();
+ v.setConversionMask("yyyy-MM-dd");
+ } else if (field[1].toUpperCase().startsWith("TIME")) {
+ v = new ValueMetaDate();
+ v.setConversionMask("HH:mm:ss.SSS");
+ } else if (field[1].toUpperCase().startsWith("NUMBER")
+ || field[1].toUpperCase().startsWith("FLOAT")) {
+ v = new ValueMetaBigNumber();
+ } else {
+ v = new ValueMetaString();
+ v.setLength(-1);
}
- if ( rowsLoadedField >= 0 ) {
- rowsLoaded += rowMeta.getInteger( row, rowsLoadedField );
+ int fieldIndex = -1;
+ if (data.fieldnrs.get(data.dbFields.get(i)[0]) != null) {
+ fieldIndex = data.fieldnrs.get(data.dbFields.get(i)[0]);
}
-
- if ( errorField >= 0 ) {
- rowsError += rowMeta.getInteger( row, errorField );
+ Object valueData = null;
+ if (fieldIndex >= 0) {
+ valueData = v.convertData(rowMeta.getValueMeta(fieldIndex), row[fieldIndex]);
+ } else if (meta.isErrorColumnMismatch()) {
+ throw new HopException(
+ "Error column mismatch: Database field "
+ + data.dbFields.get(i)[0]
+ + " not found on stream.");
}
-
- rowNum++;
- row = data.db.getRow( resultSet );
+ writeField(v, valueData, data.binaryNullValue);
+ }
}
- data.db.closeQuery( resultSet );
- setLinesOutput( rowsLoaded );
- setLinesRejected( rowsError );
-
- data.db.execStatement( "commit" );
-
+ data.writer.write(data.binaryNewline);
+ } else {
+ int jsonField = data.fieldnrs.get("json");
+ data.writer.write(
+ data.outputRowMeta.getString(row, jsonField).getBytes(StandardCharsets.UTF_8));
+ data.writer.write(data.binaryNewline);
+ }
+
+ data.outputCount++;
+ } catch (Exception e) {
+ throw new HopTransformException("Error writing line", e);
+ }
+ }
+
+ /**
+ * Takes an input field and converts it to bytes to be stored in the temp file.
+ *
+ * @param v The metadata about the column
+ * @param valueData The column data
+ * @return The bytes for the value
+ * @throws HopValueException
+ */
+ private byte[] formatField(IValueMeta v, Object valueData) throws HopValueException {
+ if (v.isString()) {
+ if (v.isStorageBinaryString()
+ && v.getTrimType() == IValueMeta.TRIM_TYPE_NONE
+ && v.getLength() < 0
+ && StringUtils.isEmpty(v.getStringEncoding())) {
+ return (byte[]) valueData;
+ } else {
+ String svalue = (valueData instanceof String) ? (String) valueData : v.getString(valueData);
+
+ // trim or cut to size if needed.
+ //
+ return convertStringToBinaryString(v, Const.trimToType(svalue, v.getTrimType()));
+ }
+ } else {
+ return v.getBinaryString(valueData);
+ }
+ }
+
+ /**
+ * Converts an input string to the bytes for the string
+ *
+ * @param v The metadata about the column
+ * @param string The column data
+ * @return The bytes for the value
+ * @throws HopValueException
+ */
+ private byte[] convertStringToBinaryString(IValueMeta v, String string) {
+ int length = v.getLength();
+
+ if (string == null) {
+ return new byte[] {};
}
- /**
- * Writes an individual row of data to a temp file
- * @param rowMeta The metadata about the row
- * @param row The input row
- * @throws HopTransformException
- */
- private void writeRowToFile( IRowMeta rowMeta, Object[] row ) throws HopTransformException {
- try {
- if ( meta.getDataTypeId() == SnowflakeBulkLoaderMeta.DATA_TYPE_CSV && !meta.isSpecifyFields() ) {
- /*
- * Write all values in stream to text file.
- */
- for ( int i = 0; i < rowMeta.size(); i++ ) {
- if ( i > 0 && data.binarySeparator.length > 0 ) {
- data.writer.write( data.binarySeparator );
- }
- IValueMeta v = rowMeta.getValueMeta( i );
- Object valueData = row[i];
-
- // no special null value default was specified since no fields are specified at all
- // As such, we pass null
- //
- writeField( v, valueData, null );
- }
- data.writer.write( data.binaryNewline );
- } else if ( meta.getDataTypeId() == SnowflakeBulkLoaderMeta.DATA_TYPE_CSV ) {
- /*
- * Only write the fields specified!
- */
- for ( int i = 0; i < data.dbFields.size(); i++ ) {
- if ( data.dbFields.get( i ) != null ) {
- if ( i > 0 && data.binarySeparator.length > 0 ) {
- data.writer.write( data.binarySeparator );
- }
-
- String[] field = data.dbFields.get( i );
- IValueMeta v;
-
- if ( field[1].toUpperCase().startsWith( "TIMESTAMP" ) ) {
- v = new ValueMetaDate();
- v.setConversionMask( "yyyy-MM-dd HH:mm:ss.SSS" );
- } else if ( field[1].toUpperCase().startsWith( "DATE" ) ) {
- v = new ValueMetaDate();
- v.setConversionMask( "yyyy-MM-dd" );
- } else if ( field[1].toUpperCase().startsWith( "TIME" ) ) {
- v = new ValueMetaDate();
- v.setConversionMask( "HH:mm:ss.SSS" );
- } else if ( field[1].toUpperCase().startsWith( "NUMBER" ) || field[1].toUpperCase().startsWith( "FLOAT" ) ) {
- v = new ValueMetaBigNumber();
- } else {
- v = new ValueMetaString();
- v.setLength( -1 );
- }
-
- int fieldIndex = -1;
- if ( data.fieldnrs.get( data.dbFields.get( i )[0] ) != null ) {
- fieldIndex = data.fieldnrs.get( data.dbFields.get( i )[0] );
- }
- Object valueData = null;
- if ( fieldIndex >= 0 ) {
- valueData = v.convertData( rowMeta.getValueMeta( fieldIndex ), row[fieldIndex] );
- } else if ( meta.isErrorColumnMismatch() ) {
- throw new HopException( "Error column mismatch: Database field " + data.dbFields.get( i )[0] + " not found on stream." );
- }
- writeField( v, valueData, data.binaryNullValue );
- }
- }
- data.writer.write( data.binaryNewline );
- } else {
- int jsonField = data.fieldnrs.get( "json" );
- data.writer.write( data.outputRowMeta.getString( row, jsonField ).getBytes( "UTF-8" ) );
- data.writer.write( data.binaryNewline );
- }
+ if (length > -1 && length < string.length()) {
+ // we need to truncate
+ String tmp = string.substring(0, length);
+ return tmp.getBytes(StandardCharsets.UTF_8);
- data.outputCount++;
+ } else {
+ byte[] text;
+ text = string.getBytes(StandardCharsets.UTF_8);
- // flush every 4k lines
- // if (linesOutput>0 && (linesOutput&0xFFF)==0) data.writer.flush();
- } catch ( Exception e ) {
- throw new HopTransformException( "Error writing line", e );
- }
- }
+ if (length > string.length()) {
+ // we need to pad this
- /**
- * Takes an input field and converts it to bytes to be stored in the temp file.
- * @param v The metadata about the column
- * @param valueData The column data
- * @return The bytes for the value
- * @throws HopValueException
- */
- private byte[] formatField( IValueMeta v, Object valueData ) throws HopValueException {
- if ( v.isString() ) {
- if ( v.isStorageBinaryString() && v.getTrimType() == IValueMeta.TRIM_TYPE_NONE && v.getLength() < 0
- && StringUtils.isEmpty( v.getStringEncoding() ) ) {
- return (byte[]) valueData;
- } else {
- String svalue = ( valueData instanceof String ) ? (String) valueData : v.getString( valueData );
+ int size = 0;
+ byte[] filler;
+ filler = " ".getBytes(StandardCharsets.UTF_8);
+ size = text.length + filler.length * (length - string.length());
- // trim or cut to size if needed.
- //
- return convertStringToBinaryString( v, Const.trimToType( svalue, v.getTrimType() ) );
- }
+ byte[] bytes = new byte[size];
+ System.arraycopy(text, 0, bytes, 0, text.length);
+ if (filler.length == 1) {
+ java.util.Arrays.fill(bytes, text.length, size, filler[0]);
} else {
- return v.getBinaryString( valueData );
+ int currIndex = text.length;
+ for (int i = 0; i < (length - string.length()); i++) {
+ for (byte aFiller : filler) {
+ bytes[currIndex++] = aFiller;
+ }
+ }
}
+ return bytes;
+ } else {
+ // do not need to pad or truncate
+ return text;
+ }
}
+ }
+
+ /**
+ * Writes an individual field to the temp file.
+ *
+ * @param v The metadata about the column
+ * @param valueData The data for the column
+ * @param nullString The bytes to put in the temp file if the value is null
+ * @throws HopTransformException
+ */
+ private void writeField(IValueMeta v, Object valueData, byte[] nullString)
+ throws HopTransformException {
+ try {
+ byte[] str;
+
+ // First check whether or not we have a null string set
+ // These values should be set when a null value passes
+ //
+ if (nullString != null && v.isNull(valueData)) {
+ str = nullString;
+ } else {
+ str = formatField(v, valueData);
+ }
+
+ if (str != null && str.length > 0) {
+ List<Integer> enclosures = null;
+ boolean writeEnclosures = false;
+
+ if (v.isString()) {
+ if (containsSeparatorOrEnclosure(
+ str, data.binarySeparator, data.binaryEnclosure, data.escapeCharacters)) {
+ writeEnclosures = true;
+ }
+ }
- /**
- * Converts an input string to the bytes for the string
- * @param v The metadata about the column
- * @param string The column data
- * @return The bytes for the value
- * @throws HopValueException
- */
- private byte[] convertStringToBinaryString( IValueMeta v, String string ) throws HopValueException {
- int length = v.getLength();
-
- if ( string == null ) {
- return new byte[]{};
+ if (writeEnclosures) {
+ data.writer.write(data.binaryEnclosure);
+ enclosures = getEnclosurePositions(str);
}
- if ( length > -1 && length < string.length() ) {
- // we need to truncate
- String tmp = string.substring( 0, length );
- try {
- return tmp.getBytes( "UTF-8" );
- } catch ( UnsupportedEncodingException e ) {
- throw new HopValueException( "Unable to convert String to Binary with specified string encoding ["
- + v.getStringEncoding() + "]", e );
- }
+ if (enclosures == null) {
+ data.writer.write(str);
} else {
- byte[] text;
- try {
- text = string.getBytes( "UTF-8" );
- } catch ( UnsupportedEncodingException e ) {
- throw new HopValueException( "Unable to convert String to Binary with specified string encoding ["
- + v.getStringEncoding() + "]", e );
- }
-
- if ( length > string.length() ) {
- // we need to pad this
-
- int size = 0;
- byte[] filler;
- try {
- filler = " ".getBytes( "UTF-8" );
- size = text.length + filler.length * ( length - string.length() );
- } catch ( UnsupportedEncodingException uee ) {
- throw new HopValueException( uee );
- }
- byte[] bytes = new byte[size];
- System.arraycopy( text, 0, bytes, 0, text.length );
- if ( filler.length == 1 ) {
- java.util.Arrays.fill( bytes, text.length, size, filler[0] );
- } else {
- int currIndex = text.length;
- for ( int i = 0; i < ( length - string.length() ); i++ ) {
- for ( byte aFiller : filler ) {
- bytes[currIndex++] = aFiller;
- }
- }
- }
- return bytes;
- } else {
- // do not need to pad or truncate
- return text;
- }
+ // Skip the enclosures, escape them instead...
+ int from = 0;
+ for (Integer enclosure : enclosures) {
+ // Minus one to write the escape before the enclosure
+ int position = enclosure;
+ data.writer.write(str, from, position - from);
+ data.writer.write(data.escapeCharacters); // write enclosure a second time
+ from = position;
+ }
+ if (from < str.length) {
+ data.writer.write(str, from, str.length - from);
+ }
}
- }
-
- /**
- * Writes an individual field to the temp file.
- * @param v The metadata about the column
- * @param valueData The data for the column
- * @param nullString The bytes to put in the temp file if the value is null
- * @throws HopTransformException
- */
- private void writeField( IValueMeta v, Object valueData, byte[] nullString ) throws HopTransformException {
- try {
- byte[] str;
-
- // First check whether or not we have a null string set
- // These values should be set when a null value passes
- //
- if ( nullString != null && v.isNull( valueData ) ) {
- str = nullString;
- } else {
- str = formatField( v, valueData );
- }
- if ( str != null && str.length > 0 ) {
- List<Integer> enclosures = null;
- boolean writeEnclosures = false;
-
- if ( v.isString() ) {
- if ( containsSeparatorOrEnclosure( str, data.binarySeparator, data.binaryEnclosure,
- data.escapeCharacters ) ) {
- writeEnclosures = true;
- }
- }
-
- if ( writeEnclosures ) {
- data.writer.write( data.binaryEnclosure );
- enclosures = getEnclosurePositions( str );
- }
-
- if ( enclosures == null ) {
- data.writer.write( str );
- } else {
- // Skip the enclosures, escape them instead...
- int from = 0;
- for ( Integer enclosure : enclosures ) {
- // Minus one to write the escape before the enclosure
- int position = enclosure;
- data.writer.write( str, from, position - from );
- data.writer.write( data.escapeCharacters ); // write enclosure a second time
- //data.writer.write( str, position, 1 );
- from = position;
-
- }
- if ( from < str.length ) {
- data.writer.write( str, from, str.length - from );
- }
- }
-
- if ( writeEnclosures ) {
- data.writer.write( data.binaryEnclosure );
- }
- }
- } catch ( Exception e ) {
- throw new HopTransformException( "Error writing field content to file", e );
+ if (writeEnclosures) {
+ data.writer.write(data.binaryEnclosure);
}
+ }
+ } catch (Exception e) {
+ throw new HopTransformException("Error writing field content to file", e);
}
+ }
+
+ /**
+ * Gets the positions of any double quotes or backslashes in the string
+ *
+ * @param str The string to check
+ * @return The positions within the string of double quotes and backslashes.
+ */
+ private List<Integer> getEnclosurePositions(byte[] str) {
+ List<Integer> positions = null;
+ // +1 because otherwise we will not find it at the end
+ for (int i = 0, len = str.length; i < len; i++) {
+ // verify if on position i there is an enclosure
+ //
+ boolean found = true;
+ for (int x = 0; found && x < data.binaryEnclosure.length; x++) {
+ if (str[i + x] != data.binaryEnclosure[x]) {
+ found = false;
+ }
+ }
+
+ if (!found) {
+ found = true;
+ for (int x = 0; found && x < data.escapeCharacters.length; x++) {
+ if (str[i + x] != data.escapeCharacters[x]) {
+ found = false;
+ }
+ }
+ }
- /**
- * Gets the positions of any double quotes or backslashes in the string
- * @param str The string to check
- * @return The positions within the string of double quotes and backslashes.
- */
- private List<Integer> getEnclosurePositions( byte[] str ) {
- List<Integer> positions = null;
- // +1 because otherwise we will not find it at the end
- for ( int i = 0, len = str.length; i < len; i++ ) {
- // verify if on position i there is an enclosure
- //
- boolean found = true;
- for ( int x = 0; found && x < data.binaryEnclosure.length; x++ ) {
- if ( str[i + x] != data.binaryEnclosure[x] ) {
- found = false;
- }
- }
-
- if ( !found ) {
- found = true;
- for ( int x = 0; found && x < data.escapeCharacters.length; x++ ) {
- if ( str[i + x] != data.escapeCharacters[x] ) {
- found = false;
- }
- }
- }
-
- if ( found ) {
- if ( positions == null ) {
- positions = new ArrayList<>();
- }
- positions.add( i );
- }
+ if (found) {
+ if (positions == null) {
+ positions = new ArrayList<>();
}
- return positions;
+ positions.add(i);
+ }
}
-
- /**
- * Get the filename to wrtie
- * @return The filename to use
- */
- private String buildFilename() {
- return meta.buildFilename( this, getCopy(), getPartitionId(), data.splitnr );
+ return positions;
+ }
+
+ /**
+ * Get the filename to wrtie
+ *
+ * @return The filename to use
+ */
+ private String buildFilename() {
+ return meta.buildFilename(this, getCopy(), getPartitionId(), data.splitnr);
+ }
+
+ /**
+ * Opens a file for writing
+ *
+ * @param baseFilename The filename to write to
+ * @throws HopException
+ */
+ private void openNewFile(String baseFilename) throws HopException {
+ if (baseFilename == null) {
+ throw new HopFileException(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Exception.FileNameNotSet"));
}
- /**
- * Opens a file for writing
- * @param baseFilename The filename to write to
- * @throws HopException
- */
- private void openNewFile( String baseFilename ) throws HopException {
- if ( baseFilename == null ) {
- throw new HopFileException( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Exception.FileNameNotSet" ) );
- }
-
- data.writer = null;
-
- String filename = resolve( baseFilename );
+ data.writer = null;
- try {
- ICompressionProvider compressionProvider =
- CompressionProviderFactory.getInstance().getCompressionProviderByName( "GZip" );
+ String filename = resolve(baseFilename);
- if ( compressionProvider == null ) {
- throw new HopException( "No compression provider found with name = GZip" );
- }
+ try {
+ ICompressionProvider compressionProvider =
+ CompressionProviderFactory.getInstance().getCompressionProviderByName("GZip");
- if ( !compressionProvider.supportsOutput() ) {
- throw new HopException( "Compression provider GZip does not support output streams!" );
- }
-
- if ( log.isDetailed() ) {
- logDetailed( "Opening output stream using provider: " + compressionProvider.getName() );
- }
+ if (compressionProvider == null) {
+ throw new HopException("No compression provider found with name = GZip");
+ }
- if ( checkPreviouslyOpened( filename ) ) {
- data.fos = getOutputStream( filename, variables, true );
- } else {
- data.fos = getOutputStream( filename, variables, false );
- data.previouslyOpenedFiles.add( filename );
- }
+ if (!compressionProvider.supportsOutput()) {
+ throw new HopException("Compression provider GZip does not support output streams!");
+ }
- data.out = compressionProvider.createOutputStream( data.fos );
+ if (log.isDetailed()) {
+ logDetailed("Opening output stream using provider: " + compressionProvider.getName());
+ }
- // The compression output stream may also archive entries. For this we create the filename
- // (with appropriate extension) and add it as an entry to the output stream. For providers
- // that do not archive entries, they should use the default no-op implementation.
- data.out.addEntry( filename, "gz" );
+ if (checkPreviouslyOpened(filename)) {
+ data.fos = getOutputStream(filename, variables, true);
+ } else {
+ data.fos = getOutputStream(filename, variables, false);
+ data.previouslyOpenedFiles.add(filename);
+ }
- data.writer = new BufferedOutputStream( data.out, 5000 );
+ data.out = compressionProvider.createOutputStream(data.fos);
- if ( log.isDetailed() ) {
- logDetailed( "Opened new file with name ["
- + HopVfs.getFriendlyURI( filename ) + "]" );
- }
+ // The compression output stream may also archive entries. For this we create the filename
+ // (with appropriate extension) and add it as an entry to the output stream. For providers
+ // that do not archive entries, they should use the default no-op implementation.
+ data.out.addEntry(filename, "gz");
- } catch ( Exception e ) {
- throw new HopException( "Error opening new file : " + e.toString() );
- }
+ data.writer = new BufferedOutputStream(data.out, 5000);
- data.splitnr++;
+ if (log.isDetailed()) {
+ logDetailed("Opened new file with name [" + HopVfs.getFriendlyURI(filename) + "]");
+ }
+ } catch (Exception e) {
+ throw new HopException("Error opening new file : " + e.toString());
}
- /**
- * Closes a file so that its file handle is no longer open
- * @return true if we successfully closed the file
- */
- private boolean closeFile() {
- boolean returnValue = false;
-
- try {
- if ( data.writer != null ) {
- data.writer.flush();
- }
- data.writer = null;
- if ( log.isDebug() ) {
- logDebug( "Closing normal file ..." );
- }
- if ( data.out != null ) {
- data.out.close();
- }
- if ( data.fos != null ) {
- data.fos.close();
- data.fos = null;
- }
- returnValue = true;
- } catch ( Exception e ) {
- logError( "Exception trying to close file: " + e.toString() );
- setErrors( 1 );
- returnValue = false;
- }
-
- return returnValue;
+ data.splitnr++;
+ }
+
+ /**
+ * Closes a file so that its file handle is no longer open
+ *
+ * @return true if we successfully closed the file
+ */
+ private boolean closeFile() {
+ boolean returnValue = false;
+
+ try {
+ if (data.writer != null) {
+ data.writer.flush();
+ }
+ data.writer = null;
+ if (log.isDebug()) {
+ logDebug("Closing normal file ...");
+ }
+ if (data.out != null) {
+ data.out.close();
+ }
+ if (data.fos != null) {
+ data.fos.close();
+ data.fos = null;
+ }
+ returnValue = true;
+ } catch (Exception e) {
+ logError("Exception trying to close file: " + e.toString());
+ setErrors(1);
+ returnValue = false;
}
- /**
- * Checks if a filename was previously opened by the transform
- * @param filename The filename to check
- * @return True if the transform had previously opened the file
- */
- private boolean checkPreviouslyOpened( String filename ) {
-
- return data.getPreviouslyOpenedFiles().contains( filename );
+ return returnValue;
+ }
- }
+ /**
+ * Checks if a filename was previously opened by the transform
+ *
+ * @param filename The filename to check
+ * @return True if the transform had previously opened the file
+ */
+ private boolean checkPreviouslyOpened(String filename) {
- /**
- * Initialize the transform by connecting to the database and calculating some constants that will be used.
- * @return True if successfully initialized
- */
- public boolean init() {
+ return data.getPreviouslyOpenedFiles().contains(filename);
+ }
- if ( super.init() ) {
- data.splitnr = 0;
+ /**
+ * Initialize the transform by connecting to the database and calculating some constants that will
+ * be used.
+ *
+ * @return True if successfully initialized
+ */
+ @Override
+ public boolean init() {
- try {
- data.databaseMeta = this.getPipelineMeta().findDatabase(meta.getConnection(), variables);
+ if (super.init()) {
+ data.splitnr = 0;
- data.db = new Database( this, variables, data.databaseMeta );
- data.db.connect();
+ try {
+ data.databaseMeta = this.getPipelineMeta().findDatabase(meta.getConnection(), variables);
- if ( log.isBasic() ) {
- logBasic( "Connected to database [" + meta.getConnection() + "]" );
- }
+ data.db = new Database(this, variables, data.databaseMeta);
+ data.db.connect();
- data.db.setCommit( Integer.MAX_VALUE );
+ if (log.isBasic()) {
+ logBasic("Connected to database [" + meta.getConnection() + "]");
+ }
- initBinaryDataFields();
- } catch ( Exception e ) {
- logError( "Couldn't initialize binary data fields", e );
- setErrors( 1L );
- stopAll();
- }
+ data.db.setCommit(Integer.MAX_VALUE);
- return true;
- }
+ initBinaryDataFields();
+ } catch (Exception e) {
+ logError("Couldn't initialize binary data fields", e);
+ setErrors(1L);
+ stopAll();
+ }
- return false;
+ return true;
}
- /**
- * Initialize the binary values of delimiters, enclosures, and escape characters
- * @throws HopException
- */
- private void initBinaryDataFields() throws HopException {
- try {
- data.binarySeparator = new byte[]{};
- data.binaryEnclosure = new byte[]{};
- data.binaryNewline = new byte[]{};
- data.escapeCharacters = new byte[]{};
-
- data.binarySeparator = resolve( SnowflakeBulkLoaderMeta.CSV_DELIMITER ).getBytes( "UTF-8" );
- data.binaryEnclosure = resolve( SnowflakeBulkLoaderMeta.ENCLOSURE ).getBytes( "UTF-8" );
- data.binaryNewline = SnowflakeBulkLoaderMeta.CSV_RECORD_DELIMITER.getBytes( "UTF-8" );
- data.escapeCharacters = SnowflakeBulkLoaderMeta.CSV_ESCAPE_CHAR.getBytes( "UTF-8" );
-
- data.binaryNullValue = "".getBytes( "UTF-8" );
- } catch ( Exception e ) {
- throw new HopException( "Unexpected error while encoding binary fields", e );
- }
+ return false;
+ }
+
+ /**
+ * Initialize the binary values of delimiters, enclosures, and escape characters
+ *
+ * @throws HopException
+ */
+ private void initBinaryDataFields() throws HopException {
+ try {
+ data.binarySeparator = new byte[] {};
+ data.binaryEnclosure = new byte[] {};
+ data.binaryNewline = new byte[] {};
+ data.escapeCharacters = new byte[] {};
+
+ data.binarySeparator =
+ resolve(SnowflakeBulkLoaderMeta.CSV_DELIMITER).getBytes(StandardCharsets.UTF_8);
+ data.binaryEnclosure =
+ resolve(SnowflakeBulkLoaderMeta.ENCLOSURE).getBytes(StandardCharsets.UTF_8);
+ data.binaryNewline =
+ SnowflakeBulkLoaderMeta.CSV_RECORD_DELIMITER.getBytes(StandardCharsets.UTF_8);
+ data.escapeCharacters =
+ SnowflakeBulkLoaderMeta.CSV_ESCAPE_CHAR.getBytes(StandardCharsets.UTF_8);
+
+ data.binaryNullValue = "".getBytes(StandardCharsets.UTF_8);
+ } catch (Exception e) {
+ throw new HopException("Unexpected error while encoding binary fields", e);
}
-
- /**
- * Clean up after the transform. Close any open files, remove temp files, close any database connections.
- */
- public void dispose() {
- if ( data.oneFileOpened ) {
- closeFile();
- }
-
- try {
- if ( data.fos != null ) {
- data.fos.close();
- }
- } catch ( Exception e ) {
- logError( "Unexpected error closing file", e );
- setErrors( 1 );
- }
-
- try {
- if ( data.db != null ) {
- data.db.disconnect();
- }
- } catch ( Exception e ) {
- logError( "Unable to close connection to database", e );
- setErrors( 1 );
- }
-
- if( ! Boolean.parseBoolean( resolve( SnowflakeBulkLoaderMeta.DEBUG_MODE_VAR ) ) ) {
- for (String filename : data.previouslyOpenedFiles) {
- try {
- HopVfs.getFileObject(filename).delete();
- logDetailed("Deleted temp file " + filename);
- } catch (Exception ex) {
- logMinimal("Unable to delete temp file", ex);
- }
- }
- }
-
- super.dispose();
+ }
+
+ /**
+ * Clean up after the transform. Close any open files, remove temp files, close any database
+ * connections.
+ */
+ @Override
+ public void dispose() {
+ if (data.oneFileOpened) {
+ closeFile();
}
- /**
- * Check if a string contains separators or enclosures. Can be used to determine if the string
- * needs enclosures around it or not.
- * @param source The string to check
- * @param separator The separator character(s)
- * @param enclosure The enclosure character(s)
- * @param escape The escape character(s)
- * @return True if the string contains separators or enclosures
- */
- @SuppressWarnings( "Duplicates" )
- private boolean containsSeparatorOrEnclosure( byte[] source, byte[] separator, byte[] enclosure, byte[] escape ) {
- boolean result = false;
-
- boolean enclosureExists = enclosure != null && enclosure.length > 0;
- boolean separatorExists = separator != null && separator.length > 0;
- boolean escapeExists = escape != null && escape.length > 0;
-
- // Skip entire test if neither separator nor enclosure exist
- if ( separatorExists || enclosureExists || escapeExists ) {
-
- // Search for the first occurrence of the separator or enclosure
- for ( int index = 0; !result && index < source.length; index++ ) {
- if ( enclosureExists && source[index] == enclosure[0] ) {
-
- // Potential match found, make sure there are enough bytes to support a full match
- if ( index + enclosure.length <= source.length ) {
- // First byte of enclosure found
- result = true; // Assume match
- for ( int i = 1; i < enclosure.length; i++ ) {
- if ( source[index + i] != enclosure[i] ) {
- // Enclosure match is proven false
- result = false;
- break;
- }
- }
- }
-
- } else if ( separatorExists && source[index] == separator[0] ) {
-
- // Potential match found, make sure there are enough bytes to support a full match
- if ( index + separator.length <= source.length ) {
- // First byte of separator found
- result = true; // Assume match
- for ( int i = 1; i < separator.length; i++ ) {
- if ( source[index + i] != separator[i] ) {
- // Separator match is proven false
- result = false;
- break;
- }
- }
- }
-
- } else if ( escapeExists && source[index] == escape[0] ) {
-
- // Potential match found, make sure there are enough bytes to support a full match
- if ( index + escape.length <= source.length ) {
- // First byte of separator found
- result = true; // Assume match
- for ( int i = 1; i < escape.length; i++ ) {
- if ( source[index + i] != escape[i] ) {
- // Separator match is proven false
- result = false;
- break;
- }
- }
- }
-
- }
- }
-
- }
-
- return result;
+ try {
+ if (data.fos != null) {
+ data.fos.close();
+ }
+ } catch (Exception e) {
+ logError("Unexpected error closing file", e);
+ setErrors(1);
}
-
- /**
- * Gets a file handle
- * @param vfsFilename The file name
- * @return The file handle
- * @throws HopFileException
- */
- @SuppressWarnings( "unused" )
- protected FileObject getFileObject(String vfsFilename ) throws HopFileException {
- return HopVfs.getFileObject( vfsFilename );
+ try {
+ if (data.db != null) {
+ data.db.disconnect();
+ }
+ } catch (Exception e) {
+ logError("Unable to close connection to database", e);
+ setErrors(1);
}
- /**
- * Gets a file handle
- * @param vfsFilename The file name
- * @param variables The variable space
- * @return The file handle
- * @throws HopFileException
- */
- @SuppressWarnings( "unused" )
- protected FileObject getFileObject( String vfsFilename, IVariables variables ) throws HopFileException {
- return HopVfs.getFileObject( vfsFilename );
+ if (!Boolean.parseBoolean(resolve(SnowflakeBulkLoaderMeta.DEBUG_MODE_VAR))) {
+ for (String filename : data.previouslyOpenedFiles) {
+ try {
+ HopVfs.getFileObject(filename).delete();
+ logDetailed("Deleted temp file " + filename);
+ } catch (Exception ex) {
+ logMinimal("Unable to delete temp file", ex);
+ }
+ }
}
- /**
- * Gets the output stream to write to
- * @param vfsFilename The file name
- * @param variables The variable space
- * @param append Should the file be appended
- * @return The output stream to write to
- * @throws HopFileException
- */
- private OutputStream getOutputStream(String vfsFilename, IVariables variables, boolean append ) throws
- HopFileException {
- return HopVfs.getOutputStream( vfsFilename, append );
+ super.dispose();
+ }
+
+ /**
+ * Check if a string contains separators or enclosures. Can be used to determine if the string
+ * needs enclosures around it or not.
+ *
+ * @param source The string to check
+ * @param separator The separator character(s)
+ * @param enclosure The enclosure character(s)
+ * @param escape The escape character(s)
+ * @return True if the string contains separators or enclosures
+ */
+ @SuppressWarnings("Duplicates")
+ private boolean containsSeparatorOrEnclosure(
+ byte[] source, byte[] separator, byte[] enclosure, byte[] escape) {
+ boolean result = false;
+
+ boolean enclosureExists = enclosure != null && enclosure.length > 0;
+ boolean separatorExists = separator != null && separator.length > 0;
+ boolean escapeExists = escape != null && escape.length > 0;
+
+ // Skip entire test if neither separator nor enclosure exist
+ if (separatorExists || enclosureExists || escapeExists) {
+
+ // Search for the first occurrence of the separator or enclosure
+ for (int index = 0; !result && index < source.length; index++) {
+ if (enclosureExists && source[index] == enclosure[0]) {
+
+ // Potential match found, make sure there are enough bytes to support a full match
+ if (index + enclosure.length <= source.length) {
+ // First byte of enclosure found
+ result = true; // Assume match
+ for (int i = 1; i < enclosure.length; i++) {
+ if (source[index + i] != enclosure[i]) {
+ // Enclosure match is proven false
+ result = false;
+ break;
+ }
+ }
+ }
+
+ } else if (separatorExists && source[index] == separator[0]) {
+
+ // Potential match found, make sure there are enough bytes to support a full match
+ if (index + separator.length <= source.length) {
+ // First byte of separator found
+ result = true; // Assume match
+ for (int i = 1; i < separator.length; i++) {
+ if (source[index + i] != separator[i]) {
+ // Separator match is proven false
+ result = false;
+ break;
+ }
+ }
+ }
+
+ } else if (escapeExists && source[index] == escape[0]) {
+
+ // Potential match found, make sure there are enough bytes to support a full match
+ if (index + escape.length <= source.length) {
+ // First byte of separator found
+ result = true; // Assume match
+ for (int i = 1; i < escape.length; i++) {
+ if (source[index + i] != escape[i]) {
+ // Separator match is proven false
+ result = false;
+ break;
+ }
+ }
+ }
+ }
+ }
}
+ return result;
+ }
+
+ /**
+ * Gets a file handle
+ *
+ * @param vfsFilename The file name
+ * @return The file handle
+ * @throws HopFileException
+ */
+ @SuppressWarnings("unused")
+ protected FileObject getFileObject(String vfsFilename) throws HopFileException {
+ return HopVfs.getFileObject(vfsFilename);
+ }
+
+ /**
+ * Gets a file handle
+ *
+ * @param vfsFilename The file name
+ * @param variables The variable space
+ * @return The file handle
+ * @throws HopFileException
+ */
+ @SuppressWarnings("unused")
+ protected FileObject getFileObject(String vfsFilename, IVariables variables)
+ throws HopFileException {
+ return HopVfs.getFileObject(vfsFilename);
+ }
+
+ /**
+ * Gets the output stream to write to
+ *
+ * @param vfsFilename The file name
+ * @param variables The variable space
+ * @param append Should the file be appended
+ * @return The output stream to write to
+ * @throws HopFileException
+ */
+ private OutputStream getOutputStream(String vfsFilename, IVariables variables, boolean append)
+ throws HopFileException {
+ return HopVfs.getOutputStream(vfsFilename, append);
+ }
}
diff --git a/plugins/transforms/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderData.java b/plugins/transforms/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderData.java
index 56c1cc0bbb..1ffb1dc2ca 100644
--- a/plugins/transforms/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderData.java
+++ b/plugins/transforms/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderData.java
@@ -29,69 +29,68 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-@SuppressWarnings( "WeakerAccess" )
+@SuppressWarnings("WeakerAccess")
public class SnowflakeBulkLoaderData extends BaseTransformData implements ITransformData {
+ // When the meta.splitSize is exceeded the file being written is closed and a new file is created.
+ // These new files
+ // are called splits. Every time a new file is created this is incremented so it will contain the
+ // latest split number
+ public int splitnr;
- // When the meta.splitSize is exceeded the file being written is closed and a new file is created. These new files
- // are called splits. Every time a new file is created this is incremented so it will contain the latest split number
- public int splitnr;
+ // Maps table fields to the location of the corresponding field on the input stream.
+ public Map<String, Integer> fieldnrs;
- // Maps table fields to the location of the corresponding field on the input stream.
- public Map<String, Integer> fieldnrs;
+ // The database being used
+ public Database db;
+ public DatabaseMeta databaseMeta;
- // The database being used
- public Database db;
- public DatabaseMeta databaseMeta;
+ // A list of table fields mapped to their data type. String[0] is the field name, String[1] is
+ // the Snowflake
+ // data type
+ public ArrayList<String[]> dbFields;
- // A list of table fields mapped to their data type. String[0] is the field name, String[1] is the Snowflake
- // data type
- public ArrayList<String[]> dbFields;
+ // The number of rows output to temp files. Incremented every time a new row is written.
+ public int outputCount;
- // The number of rows output to temp files. Incremented every time a new row is written.
- public int outputCount;
+ // The output stream being used to write files
+ public CompressionOutputStream out;
+ public OutputStream writer;
- // The output stream being used to write files
- public CompressionOutputStream out;
+ public OutputStream fos;
- public OutputStream writer;
+ // The metadata about the output row
+ public IRowMeta outputRowMeta;
- public OutputStream fos;
+ // Byte arrays for constant characters put into output files.
+ public byte[] binarySeparator;
+ public byte[] binaryEnclosure;
+ public byte[] escapeCharacters;
+ public byte[] binaryNewline;
- // The metadata about the output row
- public IRowMeta outputRowMeta;
+ public byte[] binaryNullValue;
- // Byte arrays for constant characters put into output files.
- public byte[] binarySeparator;
- public byte[] binaryEnclosure;
- public byte[] escapeCharacters;
- public byte[] binaryNewline;
+ // Indicates that at least one file has been opened by the transform
+ public boolean oneFileOpened;
- public byte[] binaryNullValue;
+ // A list of files that have been previous created by the transform
+ public List<String> previouslyOpenedFiles;
- // Indicates that at least one file has been opened by the transform
- public boolean oneFileOpened;
+ /** Sets the default values */
+ public SnowflakeBulkLoaderData() {
+ super();
- // A list of files that have been previous created by the transform
- public List<String> previouslyOpenedFiles;
+ previouslyOpenedFiles = new ArrayList<>();
- /**
- * Sets the default values
- */
- public SnowflakeBulkLoaderData() {
- super();
+ oneFileOpened = false;
+ outputCount = 0;
- previouslyOpenedFiles = new ArrayList<>();
+ dbFields = null;
+ db = null;
+ }
- oneFileOpened = false;
- outputCount = 0;
-
- dbFields = null;
- db = null;
- }
-
- List<String> getPreviouslyOpenedFiles() {
- return previouslyOpenedFiles;
- }
+ List<String> getPreviouslyOpenedFiles() {
+ return previouslyOpenedFiles;
+ }
}
diff --git a/plugins/transforms/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderDialog.java b/plugins/transforms/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderDialog.java
index 5aefd686d7..1f1fab6e85 100644
--- a/plugins/transforms/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderDialog.java
+++ b/plugins/transforms/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderDialog.java
@@ -35,7 +35,10 @@ import org.apache.hop.pipeline.transform.ITransformMeta;
import org.apache.hop.pipeline.transform.TransformMeta;
import org.apache.hop.ui.core.database.dialog.DatabaseExplorerDialog;
import org.apache.hop.ui.core.database.dialog.SqlEditor;
-import org.apache.hop.ui.core.dialog.*;
+import org.apache.hop.ui.core.dialog.BaseDialog;
+import org.apache.hop.ui.core.dialog.EnterMappingDialog;
+import org.apache.hop.ui.core.dialog.EnterSelectionDialog;
+import org.apache.hop.ui.core.dialog.ErrorDialog;
import org.apache.hop.ui.core.gui.GuiResource;
import org.apache.hop.ui.core.widget.*;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
@@ -54,1695 +57,1726 @@ import java.sql.ResultSet;
import java.util.List;
import java.util.*;
-@SuppressWarnings( { "FieldCanBeLocal", "WeakerAccess", "unused" } )
+@SuppressWarnings({"FieldCanBeLocal", "WeakerAccess", "unused"})
public class SnowflakeBulkLoaderDialog extends BaseTransformDialog implements ITransformDialog {
- private static Class<?> PKG = SnowflakeBulkLoaderMeta.class; // for i18n purposes, needed by Translator2!!
+ private static final Class<?> PKG =
+ SnowflakeBulkLoaderMeta.class; // for i18n purposes, needed by Translator2!!
- /**
- * The descriptions for the location type drop down
- */
- private static final String[] LOCATION_TYPE_COMBO = new String[] {
- BaseMessages.getString( PKG, "SnowflakeBulkLoad.Dialog.LocationType.User" ),
- BaseMessages.getString( PKG, "SnowflakeBulkLoad.Dialog.LocationType.Table" ),
- BaseMessages.getString( PKG, "SnowflakeBulkLoad.Dialog.LocationType.InternalStage" ) };
+ /** The descriptions for the location type drop down */
+ private static final String[] LOCATION_TYPE_COMBO =
+ new String[] {
+ BaseMessages.getString(PKG, "SnowflakeBulkLoad.Dialog.LocationType.User"),
+ BaseMessages.getString(PKG, "SnowflakeBulkLoad.Dialog.LocationType.Table"),
+ BaseMessages.getString(PKG, "SnowflakeBulkLoad.Dialog.LocationType.InternalStage")
+ };
- /**
- * The descriptions for the on error drop down
- */
- private static final String[] ON_ERROR_COMBO = new String[] {
- BaseMessages.getString( PKG, "SnowflakeBulkLoad.Dialog.OnError.Continue" ),
- BaseMessages.getString( PKG, "SnowflakeBulkLoad.Dialog.OnError.SkipFile" ),
- BaseMessages.getString( PKG, "SnowflakeBulkLoad.Dialog.OnError.SkipFilePercent" ),
- BaseMessages.getString( PKG, "SnowflakeBulkLoad.Dialog.OnError.Abort" ) };
+ /** The descriptions for the on error drop down */
+ private static final String[] ON_ERROR_COMBO =
+ new String[] {
+ BaseMessages.getString(PKG, "SnowflakeBulkLoad.Dialog.OnError.Continue"),
+ BaseMessages.getString(PKG, "SnowflakeBulkLoad.Dialog.OnError.SkipFile"),
+ BaseMessages.getString(PKG, "SnowflakeBulkLoad.Dialog.OnError.SkipFilePercent"),
+ BaseMessages.getString(PKG, "SnowflakeBulkLoad.Dialog.OnError.Abort")
+ };
- /**
- * The descriptions for the data type drop down
- */
- private static final String[] DATA_TYPE_COMBO = new String[] {
- BaseMessages.getString( PKG, "SnowflakeBulkLoad.Dialog.DataType.CSV" ),
- BaseMessages.getString( PKG, "SnowflakeBulkLoad.Dialog.DataType.JSON" ) };
+ /** The descriptions for the data type drop down */
+ private static final String[] DATA_TYPE_COMBO =
+ new String[] {
+ BaseMessages.getString(PKG, "SnowflakeBulkLoad.Dialog.DataType.CSV"),
+ BaseMessages.getString(PKG, "SnowflakeBulkLoad.Dialog.DataType.JSON")
+ };
- //The tabs
- private CTabFolder wTabFolder;
- private FormData fdTabFolder;
+ /* ********************************************************
+ * Loader tab
+ * This tab is used to configure information about the
+ * database and bulk load method.
+ * ********************************************************/
- private CTabItem wLoaderTab, wDataTypeTab, wFieldsTab;
+ // Database connection line
+ private MetaSelectionLine<DatabaseMeta> wConnection;
- private FormData fdLoaderComp, fdDataTypeComp, fdFieldsComp;
+ private TextVar wSchema;
- /* ********************************************************
- * Loader tab
- * This tab is used to configure information about the
- * database and bulk load method.
- * ********************************************************/
+ private TextVar wTable;
- // Database connection line
- private MetaSelectionLine<DatabaseMeta> wConnection;
+ // Location Type line
- // Schema line
- private Label wlSchema;
- private TextVar wSchema;
- private FormData fdlSchema, fdSchema;
- private FormData fdbSchema;
- private Button wbSchema;
-
- // Table line
- private Label wlTable;
- private Button wbTable;
- private TextVar wTable;
- private FormData fdlTable, fdbTable, fdTable;
+ private CCombo wLocationType;
- // Location Type line
- private Label wlLocationType;
- private CCombo wLocationType;
- private FormData fdlLocationType, fdLocationType;
-
- // Stage Name line
- private Label wlStageName;
- private ComboVar wStageName;
- private FormData fdlStageName, fdStageName;
-
- // Work Directory Line
- private Label wlWorkDirectory;
- private TextVar wWorkDirectory;
- private Button wbWorkDirectory;
- private FormData fdlWorkDirectory, fdWorkDirectory, fdbWorkDirectory;
-
- // On Error Line
- private Label wlOnError;
- private CCombo wOnError;
- private FormData fdlOnError, fdOnError;
-
- // Error Limit Line
- private Label wlErrorLimit;
- private TextVar wErrorLimit;
- private FormData fdlErrorLimit, fdErrorLimit;
-
- // Split Size Line
- private Label wlSplitSize;
- private TextVar wSplitSize;
- private FormData fdlSplitSize, fdSplitSize;
+ // Stage Name line
- // Remove files line
- private Label wlRemoveFiles;
- private Button wRemoveFiles;
- private FormData fdlRemoveFiles, fdRemoveFiles;
+ private ComboVar wStageName;
- /* *************************************************************
- * End Loader Tab
- * *************************************************************/
+ // Work Directory Line
- /* *************************************************************
- * Begin Data Type tab
- * This tab is used to configure the specific loading parameters
- * for the data type selected.
- * *************************************************************/
+ private TextVar wWorkDirectory;
- // Data Type Line
- private Label wlDataType;
- private CCombo wDataType;
- private FormData fdlDataType, fdDataType;
+ // On Error Line
+ private CCombo wOnError;
+ // Error Limit Line
+ private Label wlErrorLimit;
+ private TextVar wErrorLimit;
- /* -------------------------------------------------------------
- * CSV Group
- * ------------------------------------------------------------*/
+ // Split Size Line
- private Group gCsvGroup;
- private FormData fdgCsvGroup;
+ private TextVar wSplitSize;
- // Trim Whitespace line
- private Label wlTrimWhitespace;
- private Button wTrimWhitespace;
- private FormData fdlTrimWhitespace, fdTrimWhitespace;
-
- // Null If line
- private Label wlNullIf;
- private TextVar wNullIf;
- private FormData fdlNullIf, fdNullIf;
-
- // Error on column mismatch line
- private Label wlColumnMismatch;
- private Button wColumnMismatch;
- private FormData fdlColumnMismatch, fdColumnMismatch;
-
- /* --------------------------------------------------
- * End CSV Group
- * -------------------------------------------------*/
-
- /* --------------------------------------------------
- * Start JSON Group
- * -------------------------------------------------*/
-
- private Group gJsonGroup;
- private FormData fdgJsonGroup;
-
- // Strip null line
- private Label wlStripNull;
- private Button wStripNull;
- private FormData fdlStripNull, fdStripNull;
-
- // Ignore UTF-8 Error line
- private Label wlIgnoreUtf8;
- private Button wIgnoreUtf8;
- private FormData fdlIgnoreUtf8, fdIgnoreUtf8;
-
- // Allow duplicate elements lines
- private Label wlAllowDuplicate;
- private Button wAllowDuplicate;
- private FormData fdlAllowDuplicate, fdAllowDuplicate;
+ // Remove files line
- // Enable Octal line
- private Label wlEnableOctal;
- private Button wEnableOctal;
- private FormData fdlEnableOctal, fdEnableOctal;
+ private Button wRemoveFiles;
- /* -------------------------------------------------
- * End JSON Group
- * ------------------------------------------------*/
+ /* *************************************************************
+ * End Loader Tab
+ * *************************************************************/
- /* ************************************************
- * End Data tab
- * ************************************************/
+ /* *************************************************************
+ * Begin Data Type tab
+ * This tab is used to configure the specific loading parameters
+ * for the data type selected.
+ * *************************************************************/
- /* ************************************************
- * Start fields tab
- * This tab is used to define the field mappings
- * from the stream field to the database
- * ************************************************/
+ // Data Type Line
+ private CCombo wDataType;
- // Specify Fields line
- private Label wlSpecifyFields;
- private Button wSpecifyFields;
- private FormData fdlSpecifyFields, fdSpecifyFields;
+ /* -------------------------------------------------------------
+ * CSV Group
+ * ------------------------------------------------------------*/
- // JSON Field Line
- private Label wlJsonField;
- private CCombo wJsonField;
- private FormData fdlJsonField, fdJsonField;
+ private Group gCsvGroup;
- // Field mapping table
- private TableView wFields;
- private FormData fdFields;
- private ColumnInfo[] colinf;
+ // Trim Whitespace line
+ private Button wTrimWhitespace;
- // Enter field mapping
- private Button wDoMapping;
- private FormData fdbDoMapping;
+ // Null If line
+ private TextVar wNullIf;
+ // Error on column mismatch line
+ private Button wColumnMismatch;
- /* ************************************************
- * End Fields tab
- * ************************************************/
+ /* --------------------------------------------------
+ * End CSV Group
+ * -------------------------------------------------*/
- private SnowflakeBulkLoaderMeta input;
+ /* --------------------------------------------------
+ * Start JSON Group
+ * -------------------------------------------------*/
- private Link wDevelopedBy;
- private FormData fdDevelopedBy;
+ private Group gJsonGroup;
- private Map<String, Integer> inputFields;
+ // Strip null line
+ private Button wStripNull;
- private Display display;
+ // Ignore UTF-8 Error line
+ private Button wIgnoreUtf8;
- /**
- * List of ColumnInfo that should have the field names of the selected database table
- */
- private List<ColumnInfo> tableFieldColumns = new ArrayList<>();
-
- private int margin = Const.MARGIN;
+ // Allow duplicate elements lines
+ private Button wAllowDuplicate;
- @SuppressWarnings( "unused" )
- public SnowflakeBulkLoaderDialog(Shell parent, IVariables variables, Object in, PipelineMeta pipelineMeta, String sname ) {
- super( parent, variables, (BaseTransformMeta) in, pipelineMeta, sname );
- input = (SnowflakeBulkLoaderMeta) in;
- inputFields = new HashMap<>();
- this.pipelineMeta = pipelineMeta;
- }
+ // Enable Octal line
+ private Button wEnableOctal;
- /**
- * Open the Bulk Loader dialog
- * @return The transform name
- */
- public String open() {
- Shell parent = getParent();
- display = parent.getDisplay();
-
- shell = new Shell( parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN );
- props.setLook( shell );
- setShellImage( shell, input );
-
- /* ************************************************
- * Modify Listeners
- * ************************************************/
-
- // Basic modify listener, sets if anything has changed. Hop's way to know the pipeline
- // needs saved
- ModifyListener lsMod = new ModifyListener() {
- public void modifyText( ModifyEvent e ) {
- input.setChanged();
- }
- };
+ /* -------------------------------------------------
+ * End JSON Group
+ * ------------------------------------------------*/
- SelectionAdapter bMod = new SelectionAdapter() {
- public void widgetSelected( SelectionEvent e ) {
- input.setChanged();
- }
- };
+ /* ************************************************
+ * End Data tab
+ * ************************************************/
- // Some settings have to modify what is or is not visible within the shell. This listener does this.
- SelectionAdapter lsFlags = new SelectionAdapter() {
- public void widgetSelected( SelectionEvent e ) {
- setFlags();
- }
- };
+ /* ************************************************
+ * Start fields tab
+ * This tab is used to define the field mappings
+ * from the stream field to the database
+ * ************************************************/
- changed = input.hasChanged();
-
- FormLayout formLayout = new FormLayout();
- formLayout.marginWidth = Const.FORM_MARGIN;
- formLayout.marginHeight = Const.FORM_MARGIN;
-
- shell.setLayout( formLayout );
- shell.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.Title" ) );
-
- int middle = props.getMiddlePct();
-
- // Transform name line
- wlTransformName = new Label( shell, SWT.RIGHT );
- wlTransformName.setText( BaseMessages.getString( PKG, "BaseTransform.TypeLongDesc.SnowflakeBulkLoaderMessage" ) );
- props.setLook( wlTransformName );
- fdlTransformName = new FormData();
- fdlTransformName.left = new FormAttachment( 0, 0 );
- fdlTransformName.top = new FormAttachment( 0, margin );
- fdlTransformName.right = new FormAttachment( middle, -margin );
- wlTransformName.setLayoutData( fdlTransformName );
- wTransformName = new Text( shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- wTransformName.setText( transformName );
- props.setLook( wTransformName );
- wTransformName.addModifyListener( lsMod );
- fdTransformName = new FormData();
- fdTransformName.left = new FormAttachment( middle, 0 );
- fdTransformName.top = new FormAttachment( 0, margin );
- fdTransformName.right = new FormAttachment( 100, 0 );
- wTransformName.setLayoutData( fdTransformName );
-
- wTabFolder = new CTabFolder( shell, SWT.BORDER );
- props.setLook( wTabFolder, Props.WIDGET_STYLE_TAB );
- wTabFolder.setSimple( false );
-
- /* *********************************************
- * Start of Loader tab
- * *********************************************/
-
- wLoaderTab = new CTabItem( wTabFolder, SWT.NONE );
- wLoaderTab.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.LoaderTab.TabTitle" ) );
-
- Composite wLoaderComp = new Composite( wTabFolder, SWT.NONE );
- props.setLook( wLoaderComp );
-
- FormLayout loaderLayout = new FormLayout();
- loaderLayout.marginWidth = 3;
- loaderLayout.marginHeight = 3;
- wLoaderComp.setLayout( loaderLayout );
-
- // Connection line
- DatabaseMeta dbm = pipelineMeta.findDatabase(input.getConnection(), variables);
- wConnection = addConnectionLine( wLoaderComp, wTransformName, dbm, lsMod );
- if ( input.getConnection() == null && pipelineMeta.nrDatabases() == 1 ) {
- wConnection.select( 0 );
- }
- wConnection.addModifyListener( lsMod );
-
- // Schema line
- wlSchema = new Label( wLoaderComp, SWT.RIGHT );
- wlSchema.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.Schema.Label" ) );
- wlSchema.setToolTipText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.Schema.Tooltip" ) );
- props.setLook( wlSchema );
- fdlSchema = new FormData();
- fdlSchema.left = new FormAttachment( 0, 0 );
- fdlSchema.top = new FormAttachment( wConnection, 2 * margin );
- fdlSchema.right = new FormAttachment( middle, -margin );
- wlSchema.setLayoutData( fdlSchema );
-
- wbSchema = new Button( wLoaderComp, SWT.PUSH | SWT.CENTER );
- props.setLook( wbSchema );
- wbSchema.setText( BaseMessages.getString( PKG, "System.Button.Browse" ) );
- fdbSchema = new FormData();
- fdbSchema.top = new FormAttachment( wConnection, 2 * margin );
- fdbSchema.right = new FormAttachment( 100, 0 );
- wbSchema.setLayoutData( fdbSchema );
-
- wSchema = new TextVar(variables, wLoaderComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- props.setLook( wSchema );
- wSchema.addModifyListener( lsMod );
- fdSchema = new FormData();
- fdSchema.left = new FormAttachment( middle, 0 );
- fdSchema.top = new FormAttachment( wConnection, margin * 2 );
- fdSchema.right = new FormAttachment( wbSchema, -margin );
- wSchema.setLayoutData( fdSchema );
- wSchema.addFocusListener( new FocusAdapter() {
- @Override
- public void focusLost( FocusEvent focusEvent ) {
- setTableFieldCombo();
- }
- } );
-
- // Table line...
- wlTable = new Label( wLoaderComp, SWT.RIGHT );
- wlTable.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.Table.Label" ) );
- props.setLook( wlTable );
- fdlTable = new FormData();
- fdlTable.left = new FormAttachment( 0, 0 );
- fdlTable.right = new FormAttachment( middle, -margin );
- fdlTable.top = new FormAttachment( wbSchema, margin );
- wlTable.setLayoutData( fdlTable );
-
- wbTable = new Button( wLoaderComp, SWT.PUSH | SWT.CENTER );
- props.setLook( wbTable );
- wbTable.setText( BaseMessages.getString( PKG, "System.Button.Browse" ) );
- fdbTable = new FormData();
- fdbTable.right = new FormAttachment( 100, 0 );
- fdbTable.top = new FormAttachment( wbSchema, margin );
- wbTable.setLayoutData( fdbTable );
-
- wTable = new TextVar(variables, wLoaderComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- props.setLook( wTable );
- wTable.addModifyListener( lsMod );
- fdTable = new FormData();
- fdTable.top = new FormAttachment( wbSchema, margin );
- fdTable.left = new FormAttachment( middle, 0 );
- fdTable.right = new FormAttachment( wbTable, -margin );
- wTable.setLayoutData( fdTable );
- wTable.addFocusListener( new FocusAdapter() {
- @Override
- public void focusLost( FocusEvent focusEvent ) {
- setTableFieldCombo();
- }
- } );
-
- // Location Type line
- //
- wlLocationType = new Label( wLoaderComp, SWT.RIGHT );
- wlLocationType.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.LocationType.Label" ) );
- wlLocationType.setToolTipText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.LocationType.Tooltip" ) );
- props.setLook( wlLocationType );
- fdlLocationType = new FormData();
- fdlLocationType.left = new FormAttachment( 0, 0 );
- fdlLocationType.top = new FormAttachment( wTable, margin * 2 );
- fdlLocationType.right = new FormAttachment( middle, -margin );
- wlLocationType.setLayoutData( fdlLocationType );
-
- wLocationType = new CCombo( wLoaderComp, SWT.BORDER | SWT.READ_ONLY );
- wLocationType.setEditable( false );
- props.setLook( wLocationType );
- wLocationType.addModifyListener( lsMod );
- wLocationType.addSelectionListener( lsFlags );
- fdLocationType = new FormData();
- fdLocationType.left = new FormAttachment( middle, 0 );
- fdLocationType.top = new FormAttachment( wTable, margin * 2 );
- fdLocationType.right = new FormAttachment( 100, 0 );
- wLocationType.setLayoutData( fdLocationType );
- for ( String locationType : LOCATION_TYPE_COMBO ) {
- wLocationType.add( locationType );
- }
+ // Specify Fields line
+ private Label wlSpecifyFields;
+ private Button wSpecifyFields;
- // Stage name line
- //
- wlStageName = new Label( wLoaderComp, SWT.RIGHT );
- wlStageName.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.StageName.Label" ) );
- props.setLook( wlStageName );
- fdlStageName = new FormData();
- fdlStageName.left = new FormAttachment( 0, 0 );
- fdlStageName.top = new FormAttachment( wLocationType, margin * 2 );
- fdlStageName.right = new FormAttachment( middle, -margin );
- wlStageName.setLayoutData( fdlStageName );
-
- wStageName = new ComboVar( variables, wLoaderComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- props.setLook( wStageName );
- wStageName.addModifyListener( lsMod );
- wStageName.addSelectionListener( lsFlags );
- fdStageName = new FormData();
- fdStageName.left = new FormAttachment( middle, 0 );
- fdStageName.top = new FormAttachment( wLocationType, margin * 2 );
- fdStageName.right = new FormAttachment( 100, 0 );
- wStageName.setLayoutData( fdStageName );
- wStageName.setEnabled( false );
- wStageName.addFocusListener( new FocusAdapter() {
- /**
- * Get the list of stages for the schema, and populate the stage name drop down.
- * @param focusEvent The event
- */
- @Override
- public void focusGained( FocusEvent focusEvent ) {
- String stageNameText = wStageName.getText();
- wStageName.removeAll();
-
- DatabaseMeta databaseMeta = pipelineMeta.findDatabase( wConnection.getText() );
- if ( databaseMeta != null ) {
- Database db = new Database( loggingObject, variables, databaseMeta );
- try {
- db.connect();
- String SQL = "show stages";
- if ( !StringUtils.isEmpty( variables.resolve( wSchema.getText() ) ) ) {
- SQL += " in " + variables.resolve( wSchema.getText() );
- }
-
- ResultSet resultSet = db.openQuery( SQL, null, null, ResultSet.FETCH_FORWARD, false );
- IRowMeta rowMeta = db.getReturnRowMeta();
- Object[] row = db.getRow( resultSet );
- int nameField = rowMeta.indexOfValue( "NAME" );
- if ( nameField >= 0 ) {
- while ( row != null ) {
- String stageName = rowMeta.getString( row, nameField );
- wStageName.add( stageName );
- row = db.getRow( resultSet );
- }
- } else {
- throw new HopException( "Unable to find stage name field in result" );
- }
- db.closeQuery( resultSet );
- if ( stageNameText != null ) {
- wStageName.setText( stageNameText );
- }
-
-
- } catch ( Exception ex ) {
- logDebug( "Error getting stages", ex );
- } finally {
- try {
-
- db.disconnect();
- } catch ( Exception ex ) {
- // Nothing more we can do
- }
- }
- }
- }
- } );
-
- // Work directory line
- wlWorkDirectory = new Label( wLoaderComp, SWT.RIGHT );
- wlWorkDirectory.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.WorkDirectory.Label" ) );
- wlWorkDirectory.setToolTipText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.WorkDirectory.Tooltip" ) );
- props.setLook( wlWorkDirectory );
- fdlWorkDirectory = new FormData();
- fdlWorkDirectory.left = new FormAttachment( 0, 0 );
- fdlWorkDirectory.top = new FormAttachment( wStageName, margin );
- fdlWorkDirectory.right = new FormAttachment( middle, -margin );
- wlWorkDirectory.setLayoutData( fdlWorkDirectory );
-
- wbWorkDirectory = new Button( wLoaderComp, SWT.PUSH | SWT.CENTER );
- props.setLook( wbWorkDirectory );
- wbWorkDirectory.setText( BaseMessages.getString( PKG, "System.Button.Browse" ) );
- fdbWorkDirectory = new FormData();
- fdbWorkDirectory.right = new FormAttachment( 100, 0 );
- fdbWorkDirectory.top = new FormAttachment( wStageName, margin );
- wbWorkDirectory.setLayoutData( fdbWorkDirectory );
-
- wWorkDirectory = new TextVar( variables, wLoaderComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- wWorkDirectory.setText( "temp" );
- props.setLook( wWorkDirectory );
- wWorkDirectory.addModifyListener( lsMod );
- fdWorkDirectory = new FormData();
- fdWorkDirectory.left = new FormAttachment( middle, 0 );
- fdWorkDirectory.top = new FormAttachment( wStageName, margin );
- fdWorkDirectory.right = new FormAttachment( wbWorkDirectory, -margin );
- wWorkDirectory.setLayoutData( fdWorkDirectory );
-
- wbWorkDirectory.addSelectionListener( new SelectionAdapter() {
- public void widgetSelected( SelectionEvent arg0 ) {
- DirectoryDialog dd = new DirectoryDialog( shell, SWT.NONE );
- dd.setFilterPath( wWorkDirectory.getText() );
- String dir = dd.open();
- if ( dir != null ) {
- wWorkDirectory.setText( dir );
- }
- }
- } );
+ // JSON Field Line
+ private Label wlJsonField;
+ private CCombo wJsonField;
- // Whenever something changes, set the tooltip to the expanded version:
- wWorkDirectory.addModifyListener( new ModifyListener() {
- public void modifyText( ModifyEvent e ) {
- wWorkDirectory.setToolTipText( variables.resolve( wWorkDirectory.getText() ) );
- }
- } );
-
- // On Error line
- //
- wlOnError = new Label( wLoaderComp, SWT.RIGHT );
- wlOnError.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.OnError.Label" ) );
- wlOnError.setToolTipText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.OnError.Tooltip" ) );
- props.setLook( wlOnError );
- fdlOnError = new FormData();
- fdlOnError.left = new FormAttachment( 0, 0 );
- fdlOnError.top = new FormAttachment( wWorkDirectory, margin * 2 );
- fdlOnError.right = new FormAttachment( middle, -margin );
- wlOnError.setLayoutData( fdlOnError );
-
- wOnError = new CCombo( wLoaderComp, SWT.BORDER | SWT.READ_ONLY );
- wOnError.setEditable( false );
- props.setLook( wOnError );
- wOnError.addModifyListener( lsMod );
- wOnError.addSelectionListener( lsFlags );
- fdOnError = new FormData();
- fdOnError.left = new FormAttachment( middle, 0 );
- fdOnError.top = new FormAttachment( wWorkDirectory, margin * 2 );
- fdOnError.right = new FormAttachment( 100, 0 );
- wOnError.setLayoutData( fdOnError );
- for ( String onError : ON_ERROR_COMBO ) {
- wOnError.add( onError );
- }
+ // Field mapping table
+ private TableView wFields;
+ private ColumnInfo[] colinf;
- // Error Limit line
- wlErrorLimit = new Label( wLoaderComp, SWT.RIGHT );
- wlErrorLimit.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.ErrorCountLimit.Label" ) );
- wlErrorLimit.setToolTipText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.ErrorCountLimit.Tooltip" ) );
- props.setLook( wlErrorLimit );
- fdlErrorLimit = new FormData();
- fdlErrorLimit.left = new FormAttachment( 0, 0 );
- fdlErrorLimit.top = new FormAttachment( wOnError, margin );
- fdlErrorLimit.right = new FormAttachment( middle, -margin );
- wlErrorLimit.setLayoutData( fdlErrorLimit );
-
-
- wErrorLimit = new TextVar( variables, wLoaderComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- props.setLook( wErrorLimit );
- wErrorLimit.addModifyListener( lsMod );
- fdErrorLimit = new FormData();
- fdErrorLimit.left = new FormAttachment( middle, 0 );
- fdErrorLimit.top = new FormAttachment( wOnError, margin );
- fdErrorLimit.right = new FormAttachment( 100, 0 );
- wErrorLimit.setLayoutData( fdErrorLimit );
-
- //Size limit line
- wlSplitSize = new Label( wLoaderComp, SWT.RIGHT );
- wlSplitSize.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.SplitSize.Label" ) );
- wlSplitSize.setToolTipText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.SplitSize.Tooltip" ) );
- props.setLook( wlSplitSize );
- fdlSplitSize = new FormData();
- fdlSplitSize.left = new FormAttachment( 0, 0 );
- fdlSplitSize.top = new FormAttachment( wErrorLimit, margin );
- fdlSplitSize.right = new FormAttachment( middle, -margin );
- wlSplitSize.setLayoutData( fdlSplitSize );
-
- wSplitSize = new TextVar( variables, wLoaderComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- props.setLook( wSplitSize );
- wSplitSize.addModifyListener( lsMod );
- fdSplitSize = new FormData();
- fdSplitSize.left = new FormAttachment( middle, 0 );
- fdSplitSize.top = new FormAttachment( wErrorLimit, margin );
- fdSplitSize.right = new FormAttachment( 100, 0 );
- wSplitSize.setLayoutData( fdSplitSize );
-
- // Remove files line
- //
- wlRemoveFiles = new Label( wLoaderComp, SWT.RIGHT );
- wlRemoveFiles.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.RemoveFiles.Label" ) );
- wlRemoveFiles.setToolTipText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.RemoveFiles.Tooltip" ) );
- props.setLook( wlRemoveFiles );
- fdlRemoveFiles = new FormData();
- fdlRemoveFiles.left = new FormAttachment( 0, 0 );
- fdlRemoveFiles.top = new FormAttachment( wSplitSize, margin );
- fdlRemoveFiles.right = new FormAttachment( middle, -margin );
- wlRemoveFiles.setLayoutData( fdlRemoveFiles );
-
- wRemoveFiles = new Button( wLoaderComp, SWT.CHECK );
- props.setLook( wRemoveFiles );
- fdRemoveFiles = new FormData();
- fdRemoveFiles.left = new FormAttachment( middle, 0 );
- fdRemoveFiles.top = new FormAttachment( wSplitSize, margin );
- fdRemoveFiles.right = new FormAttachment( 100, 0 );
- wRemoveFiles.setLayoutData( fdRemoveFiles );
- wRemoveFiles.addSelectionListener( bMod );
-
- fdLoaderComp = new FormData();
- fdLoaderComp.left = new FormAttachment( 0, 0 );
- fdLoaderComp.top = new FormAttachment( 0, 0 );
- fdLoaderComp.right = new FormAttachment( 100, 0 );
- fdLoaderComp.bottom = new FormAttachment( 100, 0 );
- wLoaderComp.setLayoutData( fdLoaderComp );
-
- wLoaderComp.layout();
- wLoaderTab.setControl( wLoaderComp );
-
- /* ********************************************************
- * End Loader tab
- * ********************************************************/
-
- /* ********************************************************
- * Start data type tab
- * ********************************************************/
-
- wDataTypeTab = new CTabItem( wTabFolder, SWT.NONE );
- wDataTypeTab.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.DataTypeTab.TabTitle" ) );
-
- Composite wDataTypeComp = new Composite( wTabFolder, SWT.NONE );
- props.setLook( wDataTypeComp );
-
- FormLayout dataTypeLayout = new FormLayout();
- dataTypeLayout.marginWidth = 3;
- dataTypeLayout.marginHeight = 3;
- wDataTypeComp.setLayout( dataTypeLayout );
-
- // Data Type Line
- //
- wlDataType = new Label( wDataTypeComp, SWT.RIGHT );
- wlDataType.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.DataType.Label" ) );
- props.setLook( wlDataType );
- fdlDataType = new FormData();
- fdlDataType.left = new FormAttachment( 0, 0 );
- fdlDataType.top = new FormAttachment( 0, margin );
- fdlDataType.right = new FormAttachment( middle, -margin );
- wlDataType.setLayoutData( fdlDataType );
-
- wDataType = new CCombo( wDataTypeComp, SWT.BORDER | SWT.READ_ONLY );
- wDataType.setEditable( false );
- props.setLook( wDataType );
- wDataType.addModifyListener( lsMod );
- wDataType.addSelectionListener( lsFlags );
- fdDataType = new FormData();
- fdDataType.left = new FormAttachment( middle, 0 );
- fdDataType.top = new FormAttachment( 0, margin );
- fdDataType.right = new FormAttachment( 100, 0 );
- wDataType.setLayoutData( fdDataType );
- for ( String dataType : DATA_TYPE_COMBO ) {
- wDataType.add( dataType );
- }
+ // Enter field mapping
+ private Button wDoMapping;
+ /* ************************************************
+ * End Fields tab
+ * ************************************************/
- /////////////////////
- // Start CSV Group
- /////////////////////
- gCsvGroup = new Group( wDataTypeComp, SWT.SHADOW_ETCHED_IN );
- gCsvGroup.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.CSVGroup.Label" ) );
- FormLayout csvLayout = new FormLayout();
- csvLayout.marginWidth = 3;
- csvLayout.marginHeight = 3;
- gCsvGroup.setLayout( csvLayout );
- props.setLook( gCsvGroup );
-
- fdgCsvGroup = new FormData();
- fdgCsvGroup.left = new FormAttachment( 0, 0 );
- fdgCsvGroup.right = new FormAttachment( 100, 0 );
- fdgCsvGroup.top = new FormAttachment( wDataType, margin * 2 );
- fdgCsvGroup.bottom = new FormAttachment( 100, -margin * 2 );
- gCsvGroup.setLayoutData( fdgCsvGroup );
-
- // Trim Whitespace line
- wlTrimWhitespace = new Label( gCsvGroup, SWT.RIGHT );
- wlTrimWhitespace.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.TrimWhitespace.Label" ) );
- wlTrimWhitespace.setToolTipText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.TrimWhitespace.Tooltip" ) );
- props.setLook( wlTrimWhitespace );
- fdlTrimWhitespace = new FormData();
- fdlTrimWhitespace.left = new FormAttachment( 0, 0 );
- fdlTrimWhitespace.top = new FormAttachment( 0, margin );
- fdlTrimWhitespace.right = new FormAttachment( middle, -margin );
- wlTrimWhitespace.setLayoutData( fdlTrimWhitespace );
-
- wTrimWhitespace = new Button( gCsvGroup, SWT.CHECK );
- props.setLook( wTrimWhitespace );
- fdTrimWhitespace = new FormData();
- fdTrimWhitespace.left = new FormAttachment( middle, 0 );
- fdTrimWhitespace.top = new FormAttachment( 0, margin );
- fdTrimWhitespace.right = new FormAttachment( 100, 0 );
- wTrimWhitespace.setLayoutData( fdTrimWhitespace );
- wTrimWhitespace.addSelectionListener( bMod );
-
- // Null if line
- wlNullIf = new Label( gCsvGroup, SWT.RIGHT );
- wlNullIf.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.NullIf.Label" ) );
- wlNullIf.setToolTipText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.NullIf.Tooltip" ) );
- props.setLook( wlNullIf );
- fdlNullIf = new FormData();
- fdlNullIf.left = new FormAttachment( 0, 0 );
- fdlNullIf.top = new FormAttachment( wTrimWhitespace, margin );
- fdlNullIf.right = new FormAttachment( middle, -margin );
- wlNullIf.setLayoutData( fdlNullIf );
-
- wNullIf = new TextVar( variables, gCsvGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
- props.setLook( wNullIf );
- wNullIf.addModifyListener( lsMod );
- fdNullIf = new FormData();
- fdNullIf.left = new FormAttachment( middle, 0 );
- fdNullIf.top = new FormAttachment( wTrimWhitespace, margin );
- fdNullIf.right = new FormAttachment( 100, 0 );
- wNullIf.setLayoutData( fdNullIf );
-
- // Error mismatch line
- wlColumnMismatch = new Label( gCsvGroup, SWT.RIGHT );
- wlColumnMismatch.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.ColumnMismatch.Label" ) );
- wlColumnMismatch.setToolTipText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.ColumnMismatch.Tooltip" ) );
- props.setLook( wlColumnMismatch );
- fdlColumnMismatch = new FormData();
- fdlColumnMismatch.left = new FormAttachment( 0, 0 );
- fdlColumnMismatch.top = new FormAttachment( wNullIf, margin );
- fdlColumnMismatch.right = new FormAttachment( middle, -margin );
- wlColumnMismatch.setLayoutData( fdlColumnMismatch );
-
- wColumnMismatch = new Button( gCsvGroup, SWT.CHECK );
- props.setLook( wColumnMismatch );
- fdColumnMismatch = new FormData();
- fdColumnMismatch.left = new FormAttachment( middle, 0 );
- fdColumnMismatch.top = new FormAttachment( wNullIf, margin );
- fdColumnMismatch.right = new FormAttachment( 100, 0 );
- wColumnMismatch.setLayoutData( fdColumnMismatch );
- wColumnMismatch.addSelectionListener( bMod );
-
- ///////////////////////////
- // End CSV Group
- ///////////////////////////
-
- ///////////////////////////
- // Start JSON Group
- ///////////////////////////
- gJsonGroup = new Group( wDataTypeComp, SWT.SHADOW_ETCHED_IN );
- gJsonGroup.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.JsonGroup.Label" ) );
- FormLayout jsonLayout = new FormLayout();
- jsonLayout.marginWidth = 3;
- jsonLayout.marginHeight = 3;
- gJsonGroup.setLayout( jsonLayout );
- props.setLook( gJsonGroup );
-
- fdgJsonGroup = new FormData();
- fdgJsonGroup.left = new FormAttachment( 0, 0 );
- fdgJsonGroup.right = new FormAttachment( 100, 0 );
- fdgJsonGroup.top = new FormAttachment( wDataType, margin * 2 );
- fdgJsonGroup.bottom = new FormAttachment( 100, -margin * 2 );
- gJsonGroup.setLayoutData( fdgJsonGroup );
-
- // Strip Null line
- wlStripNull = new Label( gJsonGroup, SWT.RIGHT );
- wlStripNull.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.StripNull.Label" ) );
- wlStripNull.setToolTipText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.StripNull.Tooltip" ) );
- props.setLook( wlStripNull );
- fdlStripNull = new FormData();
- fdlStripNull.left = new FormAttachment( 0, 0 );
- fdlStripNull.top = new FormAttachment( 0, margin );
- fdlStripNull.right = new FormAttachment( middle, -margin );
- wlStripNull.setLayoutData( fdlStripNull );
-
- wStripNull = new Button( gJsonGroup, SWT.CHECK );
- props.setLook( wStripNull );
- fdStripNull = new FormData();
- fdStripNull.left = new FormAttachment( middle, 0 );
- fdStripNull.top = new FormAttachment( 0, margin );
- fdStripNull.right = new FormAttachment( 100, 0 );
- wStripNull.setLayoutData( fdStripNull );
- wStripNull.addSelectionListener( bMod );
-
- // Ignore UTF8 line
- wlIgnoreUtf8 = new Label( gJsonGroup, SWT.RIGHT );
- wlIgnoreUtf8.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.IgnoreUtf8.Label" ) );
- wlIgnoreUtf8.setToolTipText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.IgnoreUtf8.Tooltip" ) );
- props.setLook( wlIgnoreUtf8 );
- fdlIgnoreUtf8 = new FormData();
- fdlIgnoreUtf8.left = new FormAttachment( 0, 0 );
- fdlIgnoreUtf8.top = new FormAttachment( wStripNull, margin );
- fdlIgnoreUtf8.right = new FormAttachment( middle, -margin );
- wlIgnoreUtf8.setLayoutData( fdlIgnoreUtf8 );
-
- wIgnoreUtf8 = new Button( gJsonGroup, SWT.CHECK );
- props.setLook( wIgnoreUtf8 );
- fdIgnoreUtf8 = new FormData();
- fdIgnoreUtf8.left = new FormAttachment( middle, 0 );
- fdIgnoreUtf8.top = new FormAttachment( wStripNull, margin );
- fdIgnoreUtf8.right = new FormAttachment( 100, 0 );
- wIgnoreUtf8.setLayoutData( fdIgnoreUtf8 );
- wIgnoreUtf8.addSelectionListener( bMod );
-
- // Allow duplicate elements line
- wlAllowDuplicate = new Label( gJsonGroup, SWT.RIGHT );
- wlAllowDuplicate.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.AllowDuplicate.Label" ) );
- wlAllowDuplicate.setToolTipText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.AllowDuplicate.Tooltip" ) );
- props.setLook( wlAllowDuplicate );
- fdlAllowDuplicate = new FormData();
- fdlAllowDuplicate.left = new FormAttachment( 0, 0 );
- fdlAllowDuplicate.top = new FormAttachment( wIgnoreUtf8, margin );
- fdlAllowDuplicate.right = new FormAttachment( middle, -margin );
- wlAllowDuplicate.setLayoutData( fdlAllowDuplicate );
-
- wAllowDuplicate = new Button( gJsonGroup, SWT.CHECK );
- props.setLook( wAllowDuplicate );
- fdAllowDuplicate = new FormData();
- fdAllowDuplicate.left = new FormAttachment( middle, 0 );
- fdAllowDuplicate.top = new FormAttachment( wIgnoreUtf8, margin );
- fdAllowDuplicate.right = new FormAttachment( 100, 0 );
- wAllowDuplicate.setLayoutData( fdAllowDuplicate );
- wAllowDuplicate.addSelectionListener( bMod );
-
- // Enable Octal line
- wlEnableOctal = new Label( gJsonGroup, SWT.RIGHT );
- wlEnableOctal.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.EnableOctal.Label" ) );
- wlEnableOctal.setToolTipText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.EnableOctal.Tooltip" ) );
- props.setLook( wlEnableOctal );
- fdlEnableOctal = new FormData();
- fdlEnableOctal.left = new FormAttachment( 0, 0 );
- fdlEnableOctal.top = new FormAttachment( wAllowDuplicate, margin );
- fdlEnableOctal.right = new FormAttachment( middle, -margin );
- wlEnableOctal.setLayoutData( fdlEnableOctal );
-
- wEnableOctal = new Button( gJsonGroup, SWT.CHECK );
- props.setLook( wEnableOctal );
- fdEnableOctal = new FormData();
- fdEnableOctal.left = new FormAttachment( middle, 0 );
- fdEnableOctal.top = new FormAttachment( wAllowDuplicate, margin );
- fdEnableOctal.right = new FormAttachment( 100, 0 );
- wEnableOctal.setLayoutData( fdEnableOctal );
- wEnableOctal.addSelectionListener( bMod );
-
- ////////////////////////
- // End JSON Group
- ////////////////////////
-
- fdDataTypeComp = new FormData();
- fdDataTypeComp.left = new FormAttachment( 0, 0 );
- fdDataTypeComp.top = new FormAttachment( 0, 0 );
- fdDataTypeComp.right = new FormAttachment( 100, 0 );
- fdDataTypeComp.bottom = new FormAttachment( 100, 0 );
- wDataTypeComp.setLayoutData( fdFieldsComp );
-
- wDataTypeComp.layout();
- wDataTypeTab.setControl( wDataTypeComp );
-
- /* ******************************************
- * End Data type tab
- * ******************************************/
-
- /* ******************************************
- * Start Fields tab
- * This tab is used to specify the field mapping
- * to the Snowflake table
- * ******************************************/
-
- wFieldsTab = new CTabItem( wTabFolder, SWT.NONE );
- wFieldsTab.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.FieldsTab.TabTitle" ) );
-
- Composite wFieldsComp = new Composite( wTabFolder, SWT.NONE );
- props.setLook( wFieldsComp );
-
- FormLayout fieldsLayout = new FormLayout();
- fieldsLayout.marginWidth = 3;
- fieldsLayout.marginHeight = 3;
- wFieldsComp.setLayout( fieldsLayout );
-
- // Specify Fields line
- wlSpecifyFields = new Label( wFieldsComp, SWT.RIGHT );
- wlSpecifyFields.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.SpecifyFields.Label" ) );
- wlSpecifyFields.setToolTipText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.SpecifyFields.Tooltip" ) );
- props.setLook( wlSpecifyFields );
- fdlSpecifyFields = new FormData();
- fdlSpecifyFields.left = new FormAttachment( 0, 0 );
- fdlSpecifyFields.top = new FormAttachment( 0, margin );
- fdlSpecifyFields.right = new FormAttachment( middle, -margin );
- wlSpecifyFields.setLayoutData( fdlSpecifyFields );
-
- wSpecifyFields = new Button( wFieldsComp, SWT.CHECK );
- props.setLook( wSpecifyFields );
- fdSpecifyFields = new FormData();
- fdSpecifyFields.left = new FormAttachment( middle, 0 );
- fdSpecifyFields.top = new FormAttachment( 0, margin );
- fdSpecifyFields.right = new FormAttachment( 100, 0 );
- wSpecifyFields.setLayoutData( fdSpecifyFields );
- wSpecifyFields.addSelectionListener( bMod );
- wSpecifyFields.addSelectionListener(
- new SelectionAdapter() {
- @Override
- public void widgetSelected( SelectionEvent selectionEvent ) {
- setFlags();
- }
- }
- );
-
- wGet = new Button( wFieldsComp, SWT.PUSH );
- wGet.setText( BaseMessages.getString( PKG, "System.Button.GetFields" ) );
- wGet.setToolTipText( BaseMessages.getString( PKG, "System.Tooltip.GetFields" ) );
- fdGet = new FormData();
- fdGet.right = new FormAttachment( 50, -margin );
- fdGet.bottom = new FormAttachment( 100, 0 );
- wGet.setLayoutData( fdGet );
-
- wDoMapping = new Button( wFieldsComp, SWT.PUSH );
- wDoMapping.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.DoMapping.Label" ) );
- wDoMapping.setToolTipText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.DoMapping.Tooltip" ) );
- fdbDoMapping = new FormData();
- fdbDoMapping.left = new FormAttachment( 50, margin );
- fdbDoMapping.bottom = new FormAttachment( 100, 0 );
- wDoMapping.setLayoutData( fdbDoMapping );
-
- final int FieldsCols = 2;
- final int FieldsRows = input.getSnowflakeBulkLoaderFields().size();
-
- colinf = new ColumnInfo[FieldsCols];
- colinf[0] =
- new ColumnInfo(
- BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.StreamField.Column" ),
- ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false );
- colinf[1] =
- new ColumnInfo(
- BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.TableField.Column" ),
- ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false );
- tableFieldColumns.add( colinf[1] );
-
- wFields =
- new TableView(
- variables, wFieldsComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, lsMod, props );
-
- fdFields = new FormData();
- fdFields.left = new FormAttachment( 0, 0 );
- fdFields.top = new FormAttachment( wSpecifyFields, margin * 3 );
- fdFields.right = new FormAttachment( 100, 0 );
- fdFields.bottom = new FormAttachment( wGet, -margin );
- wFields.setLayoutData( fdFields );
-
- // JSON Field Line
- //
- wlJsonField = new Label( wFieldsComp, SWT.RIGHT );
- wlJsonField.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.JsonField.Label" ) );
- props.setLook( wlJsonField );
- fdlJsonField = new FormData();
- fdlJsonField.left = new FormAttachment( 0, 0 );
- fdlJsonField.top = new FormAttachment( 0, margin );
- fdlJsonField.right = new FormAttachment( middle, -margin );
- wlJsonField.setLayoutData( fdlJsonField );
-
- wJsonField = new CCombo( wFieldsComp, SWT.BORDER | SWT.READ_ONLY );
- wJsonField.setEditable( false );
- props.setLook( wJsonField );
- wJsonField.addModifyListener( lsMod );
- fdJsonField = new FormData();
- fdJsonField.left = new FormAttachment( middle, 0 );
- fdJsonField.top = new FormAttachment( 0, margin );
- fdJsonField.right = new FormAttachment( 100, 0 );
- wJsonField.setLayoutData( fdJsonField );
- wJsonField.addFocusListener( new FocusAdapter() {
- /**
- * Get the fields from the previous transform and populate the JSON Field drop down
- * @param focusEvent The event
- */
- @Override
- public void focusGained( FocusEvent focusEvent ) {
- try {
- IRowMeta row = pipelineMeta.getPrevTransformFields(variables, transformName );
- String jsonField = wJsonField.getText();
- wJsonField.setItems( row.getFieldNames() );
- if ( jsonField != null ) {
- wJsonField.setText( jsonField );
- }
- } catch ( Exception ex ) {
- String jsonField = wJsonField.getText();
- wJsonField.setItems( new String[] {} );
- wJsonField.setText( jsonField );
- }
- }
- } );
-
- //
- // Search the fields in the background and populate the CSV Field mapping table's stream field column
- final Runnable runnable = new Runnable() {
- public void run() {
- TransformMeta transformMeta = pipelineMeta.findTransform( transformName );
- if ( transformMeta != null ) {
- try {
- IRowMeta row = pipelineMeta.getPrevTransformFields( variables, SnowflakeBulkLoaderDialog.this.transformMeta);
-
- // Remember these fields...
- for ( int i = 0; i < row.size(); i++ ) {
- inputFields.put( row.getValueMeta( i ).getName(), i );
- }
- setComboBoxes();
- } catch ( HopException e ) {
- logError( BaseMessages.getString( PKG, "System.Dialog.GetFieldsFailed.Message" ) );
- }
- }
- }
- };
- new Thread( runnable ).start();
-
- fdFieldsComp = new FormData();
- fdFieldsComp.left = new FormAttachment( 0, 0 );
- fdFieldsComp.top = new FormAttachment( 0, 0 );
- fdFieldsComp.right = new FormAttachment( 100, 0 );
- fdFieldsComp.bottom = new FormAttachment( 100, 0 );
- wFieldsComp.setLayoutData( fdFieldsComp );
-
- wFieldsComp.layout();
- wFieldsTab.setControl( wFieldsComp );
-
- fdTabFolder = new FormData();
- fdTabFolder.left = new FormAttachment( 0, 0 );
- fdTabFolder.top = new FormAttachment( wTransformName, margin );
- fdTabFolder.right = new FormAttachment( 100, 0 );
- fdTabFolder.bottom = new FormAttachment( 100, -50 );
- wTabFolder.setLayoutData( fdTabFolder );
-
- wOk = new Button( shell, SWT.PUSH );
- wOk.setText( BaseMessages.getString( PKG, "System.Button.OK" ) );
- wSql = new Button(shell, SWT.PUSH);
- wSql.setText(BaseMessages.getString(PKG, "SnowflakeBulkLoader.SQL.Button"));
- wCancel = new Button( shell, SWT.PUSH );
- wCancel.setText( BaseMessages.getString( PKG, "System.Button.Cancel" ) );
-
- setButtonPositions( new Button[] { wOk, wSql, wCancel }, margin, wTabFolder );
-
- wbTable.addSelectionListener( new SelectionAdapter() {
- public void widgetSelected( SelectionEvent e ) {
- getTableName();
- }
- } );
- wbSchema.addSelectionListener( new SelectionAdapter() {
- public void widgetSelected( SelectionEvent e ) {
- getSchemaNames();
- }
- } );
+ private SnowflakeBulkLoaderMeta input;
- // Whenever something changes, set the tooltip to the expanded version:
- wSchema.addModifyListener( new ModifyListener() {
- public void modifyText( ModifyEvent e ) {
- wSchema.setToolTipText( variables.resolve( wSchema.getText() ) );
- }
- } );
+ private Link wDevelopedBy;
+ private FormData fdDevelopedBy;
- // Detect X or ALT-F4 or something that kills this window...
- shell.addShellListener( new ShellAdapter() {
- public void shellClosed( ShellEvent e ) {
- cancel();
- }
- } );
- wSql.addListener(SWT.Selection, e -> create());
- wOk.addListener(SWT.Selection, e -> ok());
- wCancel.addListener(SWT.Selection, e -> cancel());
- wGet.addListener(SWT.Selection, e -> get());
- wDoMapping.addListener(SWT.Selection, e -> generateMappings());
-
- lsResize = new Listener() {
- public void handleEvent( Event event ) {
- Point size = shell.getSize();
- wFields.setSize( size.x - 10, size.y - 50 );
- wFields.table.setSize( size.x - 10, size.y - 50 );
- wFields.redraw();
- }
- };
- shell.addListener( SWT.Resize, lsResize );
+ private Map<String, Integer> inputFields;
- wTabFolder.setSelection( 0 );
+ private Display display;
- // Set the shell size, based upon previous time...
- setSize();
+ /** List of ColumnInfo that should have the field names of the selected database table */
+ private List<ColumnInfo> tableFieldColumns = new ArrayList<>();
- getData();
+ private final int margin = Const.MARGIN;
- setTableFieldCombo();
- setFlags();
+ @SuppressWarnings("unused")
+ public SnowflakeBulkLoaderDialog(
+ Shell parent, IVariables variables, Object in, PipelineMeta pipelineMeta, String sname) {
+ super(parent, variables, (BaseTransformMeta) in, pipelineMeta, sname);
+ input = (SnowflakeBulkLoaderMeta) in;
+ inputFields = new HashMap<>();
+ this.pipelineMeta = pipelineMeta;
+ }
- input.setChanged( changed );
+ /**
+ * Open the Bulk Loader dialog
+ *
+ * @return The transform name
+ */
+ public String open() {
+ Shell parent = getParent();
+ display = parent.getDisplay();
- shell.open();
- while ( !shell.isDisposed() ) {
- if ( !display.readAndDispatch() ) {
- display.sleep();
- }
- }
- return transformName;
- }
+ shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
+ props.setLook(shell);
+ setShellImage(shell, input);
- /**
- * Sets the input stream field names in the JSON field drop down, and the Stream field drop down in the field
- * mapping table.
- */
- private void setComboBoxes() {
- // Something was changed in the row.
- //
- final Map<String, Integer> fields = new HashMap<>();
+ /* ************************************************
+ * Modify Listeners
+ * ************************************************/
- // Add the currentMeta fields...
- fields.putAll( inputFields );
+ // Basic modify listener, sets if anything has changed. Hop's way to know the pipeline
+ // needs saved
+ ModifyListener lsMod = e -> input.setChanged();
- Set<String> keySet = fields.keySet();
- List<String> entries = new ArrayList<>( keySet );
+ SelectionAdapter bMod =
+ new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ input.setChanged();
+ }
+ };
- String[] fieldNames = entries.toArray( new String[entries.size()] );
+ // Some settings have to modify what is or is not visible within the shell. This listener does
+ // this.
+ SelectionAdapter lsFlags =
+ new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setFlags();
+ }
+ };
- Const.sortStrings( fieldNames );
- colinf[0].setComboValues( fieldNames );
+ changed = input.hasChanged();
+
+ FormLayout formLayout = new FormLayout();
+ formLayout.marginWidth = Const.FORM_MARGIN;
+ formLayout.marginHeight = Const.FORM_MARGIN;
+
+ shell.setLayout(formLayout);
+ shell.setText(BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.Title"));
+
+ int middle = props.getMiddlePct();
+
+ // Transform name line
+ wlTransformName = new Label(shell, SWT.RIGHT);
+ wlTransformName.setText(
+ BaseMessages.getString(PKG, "BaseTransform.TypeLongDesc.SnowflakeBulkLoaderMessage"));
+ props.setLook(wlTransformName);
+ fdlTransformName = new FormData();
+ fdlTransformName.left = new FormAttachment(0, 0);
+ fdlTransformName.top = new FormAttachment(0, margin);
+ fdlTransformName.right = new FormAttachment(middle, -margin);
+ wlTransformName.setLayoutData(fdlTransformName);
+ wTransformName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ wTransformName.setText(transformName);
+ props.setLook(wTransformName);
+ wTransformName.addModifyListener(lsMod);
+ fdTransformName = new FormData();
+ fdTransformName.left = new FormAttachment(middle, 0);
+ fdTransformName.top = new FormAttachment(0, margin);
+ fdTransformName.right = new FormAttachment(100, 0);
+ wTransformName.setLayoutData(fdTransformName);
+
+ CTabFolder wTabFolder = new CTabFolder(shell, SWT.BORDER);
+ props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
+ wTabFolder.setSimple(false);
+
+ /* *********************************************
+ * Start of Loader tab
+ * *********************************************/
+
+ CTabItem wLoaderTab = new CTabItem(wTabFolder, SWT.NONE);
+ wLoaderTab.setText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.LoaderTab.TabTitle"));
+
+ Composite wLoaderComp = new Composite(wTabFolder, SWT.NONE);
+ props.setLook(wLoaderComp);
+
+ FormLayout loaderLayout = new FormLayout();
+ loaderLayout.marginWidth = 3;
+ loaderLayout.marginHeight = 3;
+ wLoaderComp.setLayout(loaderLayout);
+
+ // Connection line
+ DatabaseMeta dbm = pipelineMeta.findDatabase(input.getConnection(), variables);
+ wConnection = addConnectionLine(wLoaderComp, wTransformName, dbm, lsMod);
+ if (input.getConnection() == null && pipelineMeta.nrDatabases() == 1) {
+ wConnection.select(0);
}
+ wConnection.addModifyListener(lsMod);
+ // Schema line
+ Label wlSchema = new Label(wLoaderComp, SWT.RIGHT);
+ wlSchema.setText(BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.Schema.Label"));
+ wlSchema.setToolTipText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.Schema.Tooltip"));
+ props.setLook(wlSchema);
+ FormData fdlSchema = new FormData();
+ fdlSchema.left = new FormAttachment(0, 0);
+ fdlSchema.top = new FormAttachment(wConnection, 2 * margin);
+ fdlSchema.right = new FormAttachment(middle, -margin);
+ wlSchema.setLayoutData(fdlSchema);
+
+ Button wbSchema = new Button(wLoaderComp, SWT.PUSH | SWT.CENTER);
+ props.setLook(wbSchema);
+ wbSchema.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
+ FormData fdbSchema = new FormData();
+ fdbSchema.top = new FormAttachment(wConnection, 2 * margin);
+ fdbSchema.right = new FormAttachment(100, 0);
+ wbSchema.setLayoutData(fdbSchema);
+
+ wSchema = new TextVar(variables, wLoaderComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wSchema);
+ wSchema.addModifyListener(lsMod);
+ FormData fdSchema = new FormData();
+ fdSchema.left = new FormAttachment(middle, 0);
+ fdSchema.top = new FormAttachment(wConnection, margin * 2);
+ fdSchema.right = new FormAttachment(wbSchema, -margin);
+ wSchema.setLayoutData(fdSchema);
+ wSchema.addFocusListener(
+ new FocusAdapter() {
+ @Override
+ public void focusLost(FocusEvent focusEvent) {
+ setTableFieldCombo();
+ }
+ });
+
+ // Table line...
+ Label wlTable = new Label(wLoaderComp, SWT.RIGHT);
+ wlTable.setText(BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.Table.Label"));
+ props.setLook(wlTable);
+ FormData fdlTable = new FormData();
+ fdlTable.left = new FormAttachment(0, 0);
+ fdlTable.right = new FormAttachment(middle, -margin);
+ fdlTable.top = new FormAttachment(wbSchema, margin);
+ wlTable.setLayoutData(fdlTable);
+
+ Button wbTable = new Button(wLoaderComp, SWT.PUSH | SWT.CENTER);
+ props.setLook(wbTable);
+ wbTable.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
+ FormData fdbTable = new FormData();
+ fdbTable.right = new FormAttachment(100, 0);
+ fdbTable.top = new FormAttachment(wbSchema, margin);
+ wbTable.setLayoutData(fdbTable);
+
+ wTable = new TextVar(variables, wLoaderComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wTable);
+ wTable.addModifyListener(lsMod);
+ FormData fdTable = new FormData();
+ fdTable.top = new FormAttachment(wbSchema, margin);
+ fdTable.left = new FormAttachment(middle, 0);
+ fdTable.right = new FormAttachment(wbTable, -margin);
+ wTable.setLayoutData(fdTable);
+ wTable.addFocusListener(
+ new FocusAdapter() {
+ @Override
+ public void focusLost(FocusEvent focusEvent) {
+ setTableFieldCombo();
+ }
+ });
+ // Location Type line
+ //
+ Label wlLocationType = new Label(wLoaderComp, SWT.RIGHT);
+ wlLocationType.setText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.LocationType.Label"));
+ wlLocationType.setToolTipText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.LocationType.Tooltip"));
+ props.setLook(wlLocationType);
+ FormData fdlLocationType = new FormData();
+ fdlLocationType.left = new FormAttachment(0, 0);
+ fdlLocationType.top = new FormAttachment(wTable, margin * 2);
+ fdlLocationType.right = new FormAttachment(middle, -margin);
+ wlLocationType.setLayoutData(fdlLocationType);
+
+ wLocationType = new CCombo(wLoaderComp, SWT.BORDER | SWT.READ_ONLY);
+ wLocationType.setEditable(false);
+ props.setLook(wLocationType);
+ wLocationType.addModifyListener(lsMod);
+ wLocationType.addSelectionListener(lsFlags);
+ FormData fdLocationType = new FormData();
+ fdLocationType.left = new FormAttachment(middle, 0);
+ fdLocationType.top = new FormAttachment(wTable, margin * 2);
+ fdLocationType.right = new FormAttachment(100, 0);
+ wLocationType.setLayoutData(fdLocationType);
+ for (String locationType : LOCATION_TYPE_COMBO) {
+ wLocationType.add(locationType);
+ }
- /**
- * Copy information from the meta-data input to the dialog fields.
- */
- private void getData() {
- if ( input.getConnection() != null ) {
- wConnection.setText( input.getConnection() );
- }
-
- if ( input.getTargetSchema() != null ) {
- wSchema.setText( input.getTargetSchema() );
- }
+ // Stage name line
+ //
+ Label wlStageName = new Label(wLoaderComp, SWT.RIGHT);
+ wlStageName.setText(BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.StageName.Label"));
+ props.setLook(wlStageName);
+ FormData fdlStageName = new FormData();
+ fdlStageName.left = new FormAttachment(0, 0);
+ fdlStageName.top = new FormAttachment(wLocationType, margin * 2);
+ fdlStageName.right = new FormAttachment(middle, -margin);
+ wlStageName.setLayoutData(fdlStageName);
+
+ wStageName = new ComboVar(variables, wLoaderComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wStageName);
+ wStageName.addModifyListener(lsMod);
+ wStageName.addSelectionListener(lsFlags);
+ FormData fdStageName = new FormData();
+ fdStageName.left = new FormAttachment(middle, 0);
+ fdStageName.top = new FormAttachment(wLocationType, margin * 2);
+ fdStageName.right = new FormAttachment(100, 0);
+ wStageName.setLayoutData(fdStageName);
+ wStageName.setEnabled(false);
+ wStageName.addFocusListener(
+ new FocusAdapter() {
+ /**
+ * Get the list of stages for the schema, and populate the stage name drop down.
+ *
+ * @param focusEvent The event
+ */
+ @Override
+ public void focusGained(FocusEvent focusEvent) {
+ String stageNameText = wStageName.getText();
+ wStageName.removeAll();
+
+ DatabaseMeta databaseMeta = pipelineMeta.findDatabase(wConnection.getText(), variables);
+ if (databaseMeta != null) {
+ Database db = new Database(loggingObject, variables, databaseMeta);
+ try {
+ db.connect();
+ String sql = "show stages";
+ if (!StringUtils.isEmpty(variables.resolve(wSchema.getText()))) {
+ sql += " in " + variables.resolve(wSchema.getText());
+ }
- if ( input.getTargetTable() != null ) {
- wTable.setText( input.getTargetTable() );
- }
+ ResultSet resultSet = db.openQuery(sql, null, null, ResultSet.FETCH_FORWARD, false);
+ IRowMeta rowMeta = db.getReturnRowMeta();
+ Object[] row = db.getRow(resultSet);
+ int nameField = rowMeta.indexOfValue("NAME");
+ if (nameField >= 0) {
+ while (row != null) {
+ String stageName = rowMeta.getString(row, nameField);
+ wStageName.add(stageName);
+ row = db.getRow(resultSet);
+ }
+ } else {
+ throw new HopException("Unable to find stage name field in result");
+ }
+ db.closeQuery(resultSet);
+ if (stageNameText != null) {
+ wStageName.setText(stageNameText);
+ }
- if ( input.getLocationType() != null ) {
- wLocationType.setText( LOCATION_TYPE_COMBO[input.getLocationTypeId()] );
- }
+ } catch (Exception ex) {
+ logDebug("Error getting stages", ex);
+ } finally {
+ try {
- if ( input.getStageName() != null ) {
- wStageName.setText( input.getStageName() );
- }
+ db.disconnect();
+ } catch (Exception ex) {
+ // Nothing more we can do
+ }
+ }
+ }
+ }
+ });
+
+ // Work directory line
+ Label wlWorkDirectory = new Label(wLoaderComp, SWT.RIGHT);
+ wlWorkDirectory.setText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.WorkDirectory.Label"));
+ wlWorkDirectory.setToolTipText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.WorkDirectory.Tooltip"));
+ props.setLook(wlWorkDirectory);
+ FormData fdlWorkDirectory = new FormData();
+ fdlWorkDirectory.left = new FormAttachment(0, 0);
+ fdlWorkDirectory.top = new FormAttachment(wStageName, margin);
+ fdlWorkDirectory.right = new FormAttachment(middle, -margin);
+ wlWorkDirectory.setLayoutData(fdlWorkDirectory);
+
+ Button wbWorkDirectory = new Button(wLoaderComp, SWT.PUSH | SWT.CENTER);
+ props.setLook(wbWorkDirectory);
+ wbWorkDirectory.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
+ FormData fdbWorkDirectory = new FormData();
+ fdbWorkDirectory.right = new FormAttachment(100, 0);
+ fdbWorkDirectory.top = new FormAttachment(wStageName, margin);
+ wbWorkDirectory.setLayoutData(fdbWorkDirectory);
+
+ wWorkDirectory = new TextVar(variables, wLoaderComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ wWorkDirectory.setText("temp");
+ props.setLook(wWorkDirectory);
+ wWorkDirectory.addModifyListener(lsMod);
+ FormData fdWorkDirectory = new FormData();
+ fdWorkDirectory.left = new FormAttachment(middle, 0);
+ fdWorkDirectory.top = new FormAttachment(wStageName, margin);
+ fdWorkDirectory.right = new FormAttachment(wbWorkDirectory, -margin);
+ wWorkDirectory.setLayoutData(fdWorkDirectory);
+
+ wbWorkDirectory.addSelectionListener(
+ new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent arg0) {
+ DirectoryDialog dd = new DirectoryDialog(shell, SWT.NONE);
+ dd.setFilterPath(wWorkDirectory.getText());
+ String dir = dd.open();
+ if (dir != null) {
+ wWorkDirectory.setText(dir);
+ }
+ }
+ });
+
+ // Whenever something changes, set the tooltip to the expanded version:
+ wWorkDirectory.addModifyListener(
+ e -> wWorkDirectory.setToolTipText(variables.resolve(wWorkDirectory.getText())));
+
+ // On Error line
+ //
+ Label wlOnError = new Label(wLoaderComp, SWT.RIGHT);
+ wlOnError.setText(BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.OnError.Label"));
+ wlOnError.setToolTipText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.OnError.Tooltip"));
+ props.setLook(wlOnError);
+ FormData fdlOnError = new FormData();
+ fdlOnError.left = new FormAttachment(0, 0);
+ fdlOnError.top = new FormAttachment(wWorkDirectory, margin * 2);
+ fdlOnError.right = new FormAttachment(middle, -margin);
+ wlOnError.setLayoutData(fdlOnError);
+
+ wOnError = new CCombo(wLoaderComp, SWT.BORDER | SWT.READ_ONLY);
+ wOnError.setEditable(false);
+ props.setLook(wOnError);
+ wOnError.addModifyListener(lsMod);
+ wOnError.addSelectionListener(lsFlags);
+ FormData fdOnError = new FormData();
+ fdOnError.left = new FormAttachment(middle, 0);
+ fdOnError.top = new FormAttachment(wWorkDirectory, margin * 2);
+ fdOnError.right = new FormAttachment(100, 0);
+ wOnError.setLayoutData(fdOnError);
+ for (String onError : ON_ERROR_COMBO) {
+ wOnError.add(onError);
+ }
- if ( input.getWorkDirectory() != null ) {
- wWorkDirectory.setText( input.getWorkDirectory() );
- }
+ // Error Limit line
+ wlErrorLimit = new Label(wLoaderComp, SWT.RIGHT);
+ wlErrorLimit.setText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.ErrorCountLimit.Label"));
+ wlErrorLimit.setToolTipText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.ErrorCountLimit.Tooltip"));
+ props.setLook(wlErrorLimit);
+ FormData fdlErrorLimit = new FormData();
+ fdlErrorLimit.left = new FormAttachment(0, 0);
+ fdlErrorLimit.top = new FormAttachment(wOnError, margin);
+ fdlErrorLimit.right = new FormAttachment(middle, -margin);
+ wlErrorLimit.setLayoutData(fdlErrorLimit);
+
+ wErrorLimit = new TextVar(variables, wLoaderComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wErrorLimit);
+ wErrorLimit.addModifyListener(lsMod);
+ FormData fdErrorLimit = new FormData();
+ fdErrorLimit.left = new FormAttachment(middle, 0);
+ fdErrorLimit.top = new FormAttachment(wOnError, margin);
+ fdErrorLimit.right = new FormAttachment(100, 0);
+ wErrorLimit.setLayoutData(fdErrorLimit);
+
+ // Size limit line
+ Label wlSplitSize = new Label(wLoaderComp, SWT.RIGHT);
+ wlSplitSize.setText(BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.SplitSize.Label"));
+ wlSplitSize.setToolTipText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.SplitSize.Tooltip"));
+ props.setLook(wlSplitSize);
+ FormData fdlSplitSize = new FormData();
+ fdlSplitSize.left = new FormAttachment(0, 0);
+ fdlSplitSize.top = new FormAttachment(wErrorLimit, margin);
+ fdlSplitSize.right = new FormAttachment(middle, -margin);
+ wlSplitSize.setLayoutData(fdlSplitSize);
+
+ wSplitSize = new TextVar(variables, wLoaderComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wSplitSize);
+ wSplitSize.addModifyListener(lsMod);
+ FormData fdSplitSize = new FormData();
+ fdSplitSize.left = new FormAttachment(middle, 0);
+ fdSplitSize.top = new FormAttachment(wErrorLimit, margin);
+ fdSplitSize.right = new FormAttachment(100, 0);
+ wSplitSize.setLayoutData(fdSplitSize);
- if ( input.getOnError() != null ) {
- wOnError.setText( ON_ERROR_COMBO[input.getOnErrorId()] );
- }
+ // Remove files line
+ //
+ Label wlRemoveFiles = new Label(wLoaderComp, SWT.RIGHT);
+ wlRemoveFiles.setText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.RemoveFiles.Label"));
+ wlRemoveFiles.setToolTipText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.RemoveFiles.Tooltip"));
+ props.setLook(wlRemoveFiles);
+ FormData fdlRemoveFiles = new FormData();
+ fdlRemoveFiles.left = new FormAttachment(0, 0);
+ fdlRemoveFiles.top = new FormAttachment(wSplitSize, margin);
+ fdlRemoveFiles.right = new FormAttachment(middle, -margin);
+ wlRemoveFiles.setLayoutData(fdlRemoveFiles);
+
+ wRemoveFiles = new Button(wLoaderComp, SWT.CHECK);
+ props.setLook(wRemoveFiles);
+ FormData fdRemoveFiles = new FormData();
+ fdRemoveFiles.left = new FormAttachment(middle, 0);
+ fdRemoveFiles.top = new FormAttachment(wSplitSize, margin);
+ fdRemoveFiles.right = new FormAttachment(100, 0);
+ wRemoveFiles.setLayoutData(fdRemoveFiles);
+ wRemoveFiles.addSelectionListener(bMod);
+
+ FormData fdLoaderComp = new FormData();
+ fdLoaderComp.left = new FormAttachment(0, 0);
+ fdLoaderComp.top = new FormAttachment(0, 0);
+ fdLoaderComp.right = new FormAttachment(100, 0);
+ fdLoaderComp.bottom = new FormAttachment(100, 0);
+ wLoaderComp.setLayoutData(fdLoaderComp);
+
+ wLoaderComp.layout();
+ wLoaderTab.setControl(wLoaderComp);
- if ( input.getErrorLimit() != null ) {
- wErrorLimit.setText( input.getErrorLimit() );
- }
+ /* ********************************************************
+ * End Loader tab
+ * ********************************************************/
- if ( input.getSplitSize() != null ) {
- wSplitSize.setText( input.getSplitSize() );
- }
+ /* ********************************************************
+ * Start data type tab
+ * ********************************************************/
- wRemoveFiles.setSelection( input.isRemoveFiles() );
+ CTabItem wDataTypeTab = new CTabItem(wTabFolder, SWT.NONE);
+ wDataTypeTab.setText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.DataTypeTab.TabTitle"));
- if ( input.getDataType() != null ) {
- wDataType.setText( DATA_TYPE_COMBO[input.getDataTypeId()] );
- }
+ Composite wDataTypeComp = new Composite(wTabFolder, SWT.NONE);
+ props.setLook(wDataTypeComp);
- wTrimWhitespace.setSelection( input.isTrimWhitespace() );
+ FormLayout dataTypeLayout = new FormLayout();
+ dataTypeLayout.marginWidth = 3;
+ dataTypeLayout.marginHeight = 3;
+ wDataTypeComp.setLayout(dataTypeLayout);
- if ( input.getNullIf() != null ) {
- wNullIf.setText( input.getNullIf() );
- }
+ // Data Type Line
+ //
+ Label wlDataType = new Label(wDataTypeComp, SWT.RIGHT);
+ wlDataType.setText(BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.DataType.Label"));
+ props.setLook(wlDataType);
+ FormData fdlDataType = new FormData();
+ fdlDataType.left = new FormAttachment(0, 0);
+ fdlDataType.top = new FormAttachment(0, margin);
+ fdlDataType.right = new FormAttachment(middle, -margin);
+ wlDataType.setLayoutData(fdlDataType);
+
+ wDataType = new CCombo(wDataTypeComp, SWT.BORDER | SWT.READ_ONLY);
+ wDataType.setEditable(false);
+ props.setLook(wDataType);
+ wDataType.addModifyListener(lsMod);
+ wDataType.addSelectionListener(lsFlags);
+ FormData fdDataType = new FormData();
+ fdDataType.left = new FormAttachment(middle, 0);
+ fdDataType.top = new FormAttachment(0, margin);
+ fdDataType.right = new FormAttachment(100, 0);
+ wDataType.setLayoutData(fdDataType);
+ for (String dataType : DATA_TYPE_COMBO) {
+ wDataType.add(dataType);
+ }
- wColumnMismatch.setSelection( input.isErrorColumnMismatch() );
+ /////////////////////
+ // Start CSV Group
+ /////////////////////
+ gCsvGroup = new Group(wDataTypeComp, SWT.SHADOW_ETCHED_IN);
+ gCsvGroup.setText(BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.CSVGroup.Label"));
+ FormLayout csvLayout = new FormLayout();
+ csvLayout.marginWidth = 3;
+ csvLayout.marginHeight = 3;
+ gCsvGroup.setLayout(csvLayout);
+ props.setLook(gCsvGroup);
+
+ FormData fdgCsvGroup = new FormData();
+ fdgCsvGroup.left = new FormAttachment(0, 0);
+ fdgCsvGroup.right = new FormAttachment(100, 0);
+ fdgCsvGroup.top = new FormAttachment(wDataType, margin * 2);
+ fdgCsvGroup.bottom = new FormAttachment(100, -margin * 2);
+ gCsvGroup.setLayoutData(fdgCsvGroup);
- wStripNull.setSelection( input.isStripNull() );
+ // Trim Whitespace line
+ Label wlTrimWhitespace = new Label(gCsvGroup, SWT.RIGHT);
+ wlTrimWhitespace.setText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.TrimWhitespace.Label"));
+ wlTrimWhitespace.setToolTipText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.TrimWhitespace.Tooltip"));
+ props.setLook(wlTrimWhitespace);
+ FormData fdlTrimWhitespace = new FormData();
+ fdlTrimWhitespace.left = new FormAttachment(0, 0);
+ fdlTrimWhitespace.top = new FormAttachment(0, margin);
+ fdlTrimWhitespace.right = new FormAttachment(middle, -margin);
+ wlTrimWhitespace.setLayoutData(fdlTrimWhitespace);
+
+ wTrimWhitespace = new Button(gCsvGroup, SWT.CHECK);
+ props.setLook(wTrimWhitespace);
+ FormData fdTrimWhitespace = new FormData();
+ fdTrimWhitespace.left = new FormAttachment(middle, 0);
+ fdTrimWhitespace.top = new FormAttachment(0, margin);
+ fdTrimWhitespace.right = new FormAttachment(100, 0);
+ wTrimWhitespace.setLayoutData(fdTrimWhitespace);
+ wTrimWhitespace.addSelectionListener(bMod);
+
+ // Null if line
+ Label wlNullIf = new Label(gCsvGroup, SWT.RIGHT);
+ wlNullIf.setText(BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.NullIf.Label"));
+ wlNullIf.setToolTipText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.NullIf.Tooltip"));
+ props.setLook(wlNullIf);
+ FormData fdlNullIf = new FormData();
+ fdlNullIf.left = new FormAttachment(0, 0);
+ fdlNullIf.top = new FormAttachment(wTrimWhitespace, margin);
+ fdlNullIf.right = new FormAttachment(middle, -margin);
+ wlNullIf.setLayoutData(fdlNullIf);
+
+ wNullIf = new TextVar(variables, gCsvGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ props.setLook(wNullIf);
+ wNullIf.addModifyListener(lsMod);
+ FormData fdNullIf = new FormData();
+ fdNullIf.left = new FormAttachment(middle, 0);
+ fdNullIf.top = new FormAttachment(wTrimWhitespace, margin);
+ fdNullIf.right = new FormAttachment(100, 0);
+ wNullIf.setLayoutData(fdNullIf);
+
+ // Error mismatch line
+ Label wlColumnMismatch = new Label(gCsvGroup, SWT.RIGHT);
+ wlColumnMismatch.setText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.ColumnMismatch.Label"));
+ wlColumnMismatch.setToolTipText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.ColumnMismatch.Tooltip"));
+ props.setLook(wlColumnMismatch);
+ FormData fdlColumnMismatch = new FormData();
+ fdlColumnMismatch.left = new FormAttachment(0, 0);
+ fdlColumnMismatch.top = new FormAttachment(wNullIf, margin);
+ fdlColumnMismatch.right = new FormAttachment(middle, -margin);
+ wlColumnMismatch.setLayoutData(fdlColumnMismatch);
+
+ wColumnMismatch = new Button(gCsvGroup, SWT.CHECK);
+ props.setLook(wColumnMismatch);
+ FormData fdColumnMismatch = new FormData();
+ fdColumnMismatch.left = new FormAttachment(middle, 0);
+ fdColumnMismatch.top = new FormAttachment(wNullIf, margin);
+ fdColumnMismatch.right = new FormAttachment(100, 0);
+ wColumnMismatch.setLayoutData(fdColumnMismatch);
+ wColumnMismatch.addSelectionListener(bMod);
+
+ ///////////////////////////
+ // End CSV Group
+ ///////////////////////////
+
+ ///////////////////////////
+ // Start JSON Group
+ ///////////////////////////
+ gJsonGroup = new Group(wDataTypeComp, SWT.SHADOW_ETCHED_IN);
+ gJsonGroup.setText(BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.JsonGroup.Label"));
+ FormLayout jsonLayout = new FormLayout();
+ jsonLayout.marginWidth = 3;
+ jsonLayout.marginHeight = 3;
+ gJsonGroup.setLayout(jsonLayout);
+ props.setLook(gJsonGroup);
+
+ FormData fdgJsonGroup = new FormData();
+ fdgJsonGroup.left = new FormAttachment(0, 0);
+ fdgJsonGroup.right = new FormAttachment(100, 0);
+ fdgJsonGroup.top = new FormAttachment(wDataType, margin * 2);
+ fdgJsonGroup.bottom = new FormAttachment(100, -margin * 2);
+ gJsonGroup.setLayoutData(fdgJsonGroup);
+
+ // Strip Null line
+ Label wlStripNull = new Label(gJsonGroup, SWT.RIGHT);
+ wlStripNull.setText(BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.StripNull.Label"));
+ wlStripNull.setToolTipText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.StripNull.Tooltip"));
+ props.setLook(wlStripNull);
+ FormData fdlStripNull = new FormData();
+ fdlStripNull.left = new FormAttachment(0, 0);
+ fdlStripNull.top = new FormAttachment(0, margin);
+ fdlStripNull.right = new FormAttachment(middle, -margin);
+ wlStripNull.setLayoutData(fdlStripNull);
+
+ wStripNull = new Button(gJsonGroup, SWT.CHECK);
+ props.setLook(wStripNull);
+ FormData fdStripNull = new FormData();
+ fdStripNull.left = new FormAttachment(middle, 0);
+ fdStripNull.top = new FormAttachment(0, margin);
+ fdStripNull.right = new FormAttachment(100, 0);
+ wStripNull.setLayoutData(fdStripNull);
+ wStripNull.addSelectionListener(bMod);
+
+ // Ignore UTF8 line
+ Label wlIgnoreUtf8 = new Label(gJsonGroup, SWT.RIGHT);
+ wlIgnoreUtf8.setText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.IgnoreUtf8.Label"));
+ wlIgnoreUtf8.setToolTipText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.IgnoreUtf8.Tooltip"));
+ props.setLook(wlIgnoreUtf8);
+ FormData fdlIgnoreUtf8 = new FormData();
+ fdlIgnoreUtf8.left = new FormAttachment(0, 0);
+ fdlIgnoreUtf8.top = new FormAttachment(wStripNull, margin);
+ fdlIgnoreUtf8.right = new FormAttachment(middle, -margin);
+ wlIgnoreUtf8.setLayoutData(fdlIgnoreUtf8);
+
+ wIgnoreUtf8 = new Button(gJsonGroup, SWT.CHECK);
+ props.setLook(wIgnoreUtf8);
+ FormData fdIgnoreUtf8 = new FormData();
+ fdIgnoreUtf8.left = new FormAttachment(middle, 0);
+ fdIgnoreUtf8.top = new FormAttachment(wStripNull, margin);
+ fdIgnoreUtf8.right = new FormAttachment(100, 0);
+ wIgnoreUtf8.setLayoutData(fdIgnoreUtf8);
+ wIgnoreUtf8.addSelectionListener(bMod);
+
+ // Allow duplicate elements line
+ Label wlAllowDuplicate = new Label(gJsonGroup, SWT.RIGHT);
+ wlAllowDuplicate.setText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.AllowDuplicate.Label"));
+ wlAllowDuplicate.setToolTipText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.AllowDuplicate.Tooltip"));
+ props.setLook(wlAllowDuplicate);
+ FormData fdlAllowDuplicate = new FormData();
+ fdlAllowDuplicate.left = new FormAttachment(0, 0);
+ fdlAllowDuplicate.top = new FormAttachment(wIgnoreUtf8, margin);
+ fdlAllowDuplicate.right = new FormAttachment(middle, -margin);
+ wlAllowDuplicate.setLayoutData(fdlAllowDuplicate);
+
+ wAllowDuplicate = new Button(gJsonGroup, SWT.CHECK);
+ props.setLook(wAllowDuplicate);
+ FormData fdAllowDuplicate = new FormData();
+ fdAllowDuplicate.left = new FormAttachment(middle, 0);
+ fdAllowDuplicate.top = new FormAttachment(wIgnoreUtf8, margin);
+ fdAllowDuplicate.right = new FormAttachment(100, 0);
+ wAllowDuplicate.setLayoutData(fdAllowDuplicate);
+ wAllowDuplicate.addSelectionListener(bMod);
- wIgnoreUtf8.setSelection( input.isIgnoreUtf8() );
+ // Enable Octal line
+ Label wlEnableOctal = new Label(gJsonGroup, SWT.RIGHT);
+ wlEnableOctal.setText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.EnableOctal.Label"));
+ wlEnableOctal.setToolTipText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.EnableOctal.Tooltip"));
+ props.setLook(wlEnableOctal);
+ FormData fdlEnableOctal = new FormData();
+ fdlEnableOctal.left = new FormAttachment(0, 0);
+ fdlEnableOctal.top = new FormAttachment(wAllowDuplicate, margin);
+ fdlEnableOctal.right = new FormAttachment(middle, -margin);
+ wlEnableOctal.setLayoutData(fdlEnableOctal);
+
+ wEnableOctal = new Button(gJsonGroup, SWT.CHECK);
+ props.setLook(wEnableOctal);
+ FormData fdEnableOctal = new FormData();
+ fdEnableOctal.left = new FormAttachment(middle, 0);
+ fdEnableOctal.top = new FormAttachment(wAllowDuplicate, margin);
+ fdEnableOctal.right = new FormAttachment(100, 0);
+ wEnableOctal.setLayoutData(fdEnableOctal);
+ wEnableOctal.addSelectionListener(bMod);
+
+ ////////////////////////
+ // End JSON Group
+ ////////////////////////
+
+ FormData fdDataTypeComp = new FormData();
+ fdDataTypeComp.left = new FormAttachment(0, 0);
+ fdDataTypeComp.top = new FormAttachment(0, 0);
+ fdDataTypeComp.right = new FormAttachment(100, 0);
+ fdDataTypeComp.bottom = new FormAttachment(100, 0);
+ wDataTypeComp.setLayoutData(fdDataTypeComp);
+
+ wDataTypeComp.layout();
+ wDataTypeTab.setControl(wDataTypeComp);
+
+ /* ******************************************
+ * End Data type tab
+ * ******************************************/
+
+ /* ******************************************
+ * Start Fields tab
+ * This tab is used to specify the field mapping
+ * to the Snowflake table
+ * ******************************************/
+
+ CTabItem wFieldsTab = new CTabItem(wTabFolder, SWT.NONE);
+ wFieldsTab.setText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.FieldsTab.TabTitle"));
+
+ Composite wFieldsComp = new Composite(wTabFolder, SWT.NONE);
+ props.setLook(wFieldsComp);
+
+ FormLayout fieldsLayout = new FormLayout();
+ fieldsLayout.marginWidth = 3;
+ fieldsLayout.marginHeight = 3;
+ wFieldsComp.setLayout(fieldsLayout);
- wAllowDuplicate.setSelection( input.isAllowDuplicateElements() );
+ // Specify Fields line
+ wlSpecifyFields = new Label(wFieldsComp, SWT.RIGHT);
+ wlSpecifyFields.setText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.SpecifyFields.Label"));
+ wlSpecifyFields.setToolTipText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.SpecifyFields.Tooltip"));
+ props.setLook(wlSpecifyFields);
+ FormData fdlSpecifyFields = new FormData();
+ fdlSpecifyFields.left = new FormAttachment(0, 0);
+ fdlSpecifyFields.top = new FormAttachment(0, margin);
+ fdlSpecifyFields.right = new FormAttachment(middle, -margin);
+ wlSpecifyFields.setLayoutData(fdlSpecifyFields);
+
+ wSpecifyFields = new Button(wFieldsComp, SWT.CHECK);
+ props.setLook(wSpecifyFields);
+ FormData fdSpecifyFields = new FormData();
+ fdSpecifyFields.left = new FormAttachment(middle, 0);
+ fdSpecifyFields.top = new FormAttachment(0, margin);
+ fdSpecifyFields.right = new FormAttachment(100, 0);
+ wSpecifyFields.setLayoutData(fdSpecifyFields);
+ wSpecifyFields.addSelectionListener(bMod);
+ wSpecifyFields.addSelectionListener(
+ new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent selectionEvent) {
+ setFlags();
+ }
+ });
+
+ wGet = new Button(wFieldsComp, SWT.PUSH);
+ wGet.setText(BaseMessages.getString(PKG, "System.Button.GetFields"));
+ wGet.setToolTipText(BaseMessages.getString(PKG, "System.Tooltip.GetFields"));
+ fdGet = new FormData();
+ fdGet.right = new FormAttachment(50, -margin);
+ fdGet.bottom = new FormAttachment(100, 0);
+ wGet.setLayoutData(fdGet);
+
+ wDoMapping = new Button(wFieldsComp, SWT.PUSH);
+ wDoMapping.setText(BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.DoMapping.Label"));
+ wDoMapping.setToolTipText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.DoMapping.Tooltip"));
+ FormData fdbDoMapping = new FormData();
+ fdbDoMapping.left = new FormAttachment(50, margin);
+ fdbDoMapping.bottom = new FormAttachment(100, 0);
+ wDoMapping.setLayoutData(fdbDoMapping);
+
+ final int FieldsCols = 2;
+ final int FieldsRows = input.getSnowflakeBulkLoaderFields().size();
+
+ colinf = new ColumnInfo[FieldsCols];
+ colinf[0] =
+ new ColumnInfo(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.StreamField.Column"),
+ ColumnInfo.COLUMN_TYPE_CCOMBO,
+ new String[] {""},
+ false);
+ colinf[1] =
+ new ColumnInfo(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.TableField.Column"),
+ ColumnInfo.COLUMN_TYPE_CCOMBO,
+ new String[] {""},
+ false);
+ tableFieldColumns.add(colinf[1]);
+
+ wFields =
+ new TableView(
+ variables,
+ wFieldsComp,
+ SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI,
+ colinf,
+ FieldsRows,
+ lsMod,
+ props);
+
+ FormData fdFields = new FormData();
+ fdFields.left = new FormAttachment(0, 0);
+ fdFields.top = new FormAttachment(wSpecifyFields, margin * 3);
+ fdFields.right = new FormAttachment(100, 0);
+ fdFields.bottom = new FormAttachment(wGet, -margin);
+ wFields.setLayoutData(fdFields);
- wEnableOctal.setSelection( input.isEnableOctal() );
+ // JSON Field Line
+ //
+ wlJsonField = new Label(wFieldsComp, SWT.RIGHT);
+ wlJsonField.setText(BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.JsonField.Label"));
+ props.setLook(wlJsonField);
+ FormData fdlJsonField = new FormData();
+ fdlJsonField.left = new FormAttachment(0, 0);
+ fdlJsonField.top = new FormAttachment(0, margin);
+ fdlJsonField.right = new FormAttachment(middle, -margin);
+ wlJsonField.setLayoutData(fdlJsonField);
+
+ wJsonField = new CCombo(wFieldsComp, SWT.BORDER | SWT.READ_ONLY);
+ wJsonField.setEditable(false);
+ props.setLook(wJsonField);
+ wJsonField.addModifyListener(lsMod);
+ FormData fdJsonField = new FormData();
+ fdJsonField.left = new FormAttachment(middle, 0);
+ fdJsonField.top = new FormAttachment(0, margin);
+ fdJsonField.right = new FormAttachment(100, 0);
+ wJsonField.setLayoutData(fdJsonField);
+ wJsonField.addFocusListener(
+ new FocusAdapter() {
+ /**
+ * Get the fields from the previous transform and populate the JSON Field drop down
+ *
+ * @param focusEvent The event
+ */
+ @Override
+ public void focusGained(FocusEvent focusEvent) {
+ try {
+ IRowMeta row = pipelineMeta.getPrevTransformFields(variables, transformName);
+ String jsonField = wJsonField.getText();
+ wJsonField.setItems(row.getFieldNames());
+ if (jsonField != null) {
+ wJsonField.setText(jsonField);
+ }
+ } catch (Exception ex) {
+ String jsonField = wJsonField.getText();
+ wJsonField.setItems(new String[] {});
+ wJsonField.setText(jsonField);
+ }
+ }
+ });
+
+ //
+ // Search the fields in the background and populate the CSV Field mapping table's stream field
+ // column
+ final Runnable runnable =
+ () -> {
+ TransformMeta transformMeta = pipelineMeta.findTransform(transformName);
+ if (transformMeta != null) {
+ try {
+ IRowMeta row =
+ pipelineMeta.getPrevTransformFields(
+ variables, SnowflakeBulkLoaderDialog.this.transformMeta);
+
+ // Remember these fields...
+ for (int i = 0; i < row.size(); i++) {
+ inputFields.put(row.getValueMeta(i).getName(), i);
+ }
+ setComboBoxes();
+ } catch (HopException e) {
+ logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
+ }
+ }
+ };
+ new Thread(runnable).start();
+
+ FormData fdFieldsComp = new FormData();
+ fdFieldsComp.left = new FormAttachment(0, 0);
+ fdFieldsComp.top = new FormAttachment(0, 0);
+ fdFieldsComp.right = new FormAttachment(100, 0);
+ fdFieldsComp.bottom = new FormAttachment(100, 0);
+ wFieldsComp.setLayoutData(fdFieldsComp);
+
+ wFieldsComp.layout();
+ wFieldsTab.setControl(wFieldsComp);
+
+ FormData fdTabFolder = new FormData();
+ fdTabFolder.left = new FormAttachment(0, 0);
+ fdTabFolder.top = new FormAttachment(wTransformName, margin);
+ fdTabFolder.right = new FormAttachment(100, 0);
+ fdTabFolder.bottom = new FormAttachment(100, -50);
+ wTabFolder.setLayoutData(fdTabFolder);
+
+ wOk = new Button(shell, SWT.PUSH);
+ wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
+ wSql = new Button(shell, SWT.PUSH);
+ wSql.setText(BaseMessages.getString(PKG, "SnowflakeBulkLoader.SQL.Button"));
+ wCancel = new Button(shell, SWT.PUSH);
+ wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
+
+ setButtonPositions(new Button[] {wOk, wSql, wCancel}, margin, wTabFolder);
+
+ wbTable.addSelectionListener(
+ new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ getTableName();
+ }
+ });
+ wbSchema.addSelectionListener(
+ new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ getSchemaNames();
+ }
+ });
+
+ // Whenever something changes, set the tooltip to the expanded version:
+ wSchema.addModifyListener(e -> wSchema.setToolTipText(variables.resolve(wSchema.getText())));
+
+ // Detect X or ALT-F4 or something that kills this window...
+ shell.addShellListener(
+ new ShellAdapter() {
+ @Override
+ public void shellClosed(ShellEvent e) {
+ cancel();
+ }
+ });
+ wSql.addListener(SWT.Selection, e -> create());
+ wOk.addListener(SWT.Selection, e -> ok());
+ wCancel.addListener(SWT.Selection, e -> cancel());
+ wGet.addListener(SWT.Selection, e -> get());
+ wDoMapping.addListener(SWT.Selection, e -> generateMappings());
+
+ lsResize =
+ event -> {
+ Point size = shell.getSize();
+ wFields.setSize(size.x - 10, size.y - 50);
+ wFields.table.setSize(size.x - 10, size.y - 50);
+ wFields.redraw();
+ };
+ shell.addListener(SWT.Resize, lsResize);
- wSpecifyFields.setSelection( input.isSpecifyFields() );
+ wTabFolder.setSelection(0);
- if ( input.getJsonField() != null ) {
- wJsonField.setText( input.getJsonField() );
- }
+ // Set the shell size, based upon previous time...
+ setSize();
- logDebug( "getting fields info..." );
+ getData();
- for ( int i = 0; i < input.getSnowflakeBulkLoaderFields().size(); i++ ) {
- SnowflakeBulkLoaderField field = input.getSnowflakeBulkLoaderFields().get(i);
+ setTableFieldCombo();
+ setFlags();
- TableItem item = wFields.table.getItem( i );
- item.setText( 1, Const.NVL( field.getStreamField(), "" ) );
- item.setText( 2, Const.NVL( field.getTableField(), "" ) );
+ input.setChanged(changed);
- }
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ return transformName;
+ }
+
+ /**
+ * Sets the input stream field names in the JSON field drop down, and the Stream field drop down
+ * in the field mapping table.
+ */
+ private void setComboBoxes() {
+ // Something was changed in the row.
+ //
+ final Map<String, Integer> fields = new HashMap<>();
+
+ // Add the currentMeta fields...
+ fields.putAll(inputFields);
+
+ Set<String> keySet = fields.keySet();
+ List<String> entries = new ArrayList<>(keySet);
+
+ String[] fieldNames = entries.toArray(new String[entries.size()]);
+
+ Const.sortStrings(fieldNames);
+ colinf[0].setComboValues(fieldNames);
+ }
+
+ /** Copy information from the meta-data input to the dialog fields. */
+ private void getData() {
+ if (input.getConnection() != null) {
+ wConnection.setText(input.getConnection());
+ }
- wFields.optWidth( true );
+ if (input.getTargetSchema() != null) {
+ wSchema.setText(input.getTargetSchema());
+ }
- wTransformName.selectAll();
- wTransformName.setFocus();
+ if (input.getTargetTable() != null) {
+ wTable.setText(input.getTargetTable());
}
- /**
- * Cancel making changes. Do not save any of the changes and do not set the pipeline as changed.
- */
- private void cancel() {
- transformName = null;
+ if (input.getLocationType() != null) {
+ wLocationType.setText(LOCATION_TYPE_COMBO[input.getLocationTypeId()]);
+ }
- input.setChanged( backupChanged );
+ if (input.getStageName() != null) {
+ wStageName.setText(input.getStageName());
+ }
- dispose();
+ if (input.getWorkDirectory() != null) {
+ wWorkDirectory.setText(input.getWorkDirectory());
}
- /**
- * Save the transform settings to the transform metadata
- * @param sbl The transform metadata
- */
- private void getInfo(SnowflakeBulkLoaderMeta sbl ) {
- sbl.setConnection( wConnection.getText());
- sbl.setTargetSchema( wSchema.getText() );
- sbl.setTargetTable( wTable.getText() );
- sbl.setLocationTypeById( wLocationType.getSelectionIndex() );
- sbl.setStageName( wStageName.getText() );
- sbl.setWorkDirectory( wWorkDirectory.getText() );
- sbl.setOnErrorById( wOnError.getSelectionIndex() );
- sbl.setErrorLimit( wErrorLimit.getText() );
- sbl.setSplitSize( wSplitSize.getText() );
- sbl.setRemoveFiles( wRemoveFiles.getSelection() );
-
- sbl.setDataTypeById( wDataType.getSelectionIndex() );
- sbl.setTrimWhitespace( wTrimWhitespace.getSelection() );
- sbl.setNullIf( wNullIf.getText() );
- sbl.setErrorColumnMismatch( wColumnMismatch.getSelection() );
- sbl.setStripNull( wStripNull.getSelection() );
- sbl.setIgnoreUtf8( wIgnoreUtf8.getSelection() );
- sbl.setAllowDuplicateElements( wAllowDuplicate.getSelection() );
- sbl.setEnableOctal( wEnableOctal.getSelection() );
-
- sbl.setSpecifyFields( wSpecifyFields.getSelection() );
- sbl.setJsonField( wJsonField.getText() );
-
- // Table table = wFields.table;
-
- int nrfields = wFields.nrNonEmpty();
-
- List<SnowflakeBulkLoaderField> fields = new ArrayList();
-
- for ( int i = 0; i < nrfields; i++ ) {
- SnowflakeBulkLoaderField field = new SnowflakeBulkLoaderField();
-
- TableItem item = wFields.getNonEmpty( i );
- field.setStreamField( item.getText( 1 ) );
- field.setTableField( item.getText( 2 ) );
- fields.add(field);
- }
- sbl.setSnowflakeBulkLoaderFields(fields);
+ if (input.getOnError() != null) {
+ wOnError.setText(ON_ERROR_COMBO[input.getOnErrorId()]);
}
- /**
- * Save the transform settings and close the dialog
- */
- private void ok() {
- if ( StringUtils.isEmpty( wTransformName.getText() ) ) {
- return;
- }
+ if (input.getErrorLimit() != null) {
+ wErrorLimit.setText(input.getErrorLimit());
+ }
- transformName = wTransformName.getText(); // return value
+ if (input.getSplitSize() != null) {
+ wSplitSize.setText(input.getSplitSize());
+ }
- getInfo( input );
+ wRemoveFiles.setSelection(input.isRemoveFiles());
- dispose();
+ if (input.getDataType() != null) {
+ wDataType.setText(DATA_TYPE_COMBO[input.getDataTypeId()]);
}
- /**
- * Get the fields from the previous transform and load the field mapping table with a direct mapping of input fields to
- * table fields.
- */
- private void get() {
- try {
- IRowMeta r = pipelineMeta.getPrevTransformFields(variables, transformName );
- if ( r != null && !r.isEmpty() ) {
- BaseTransformDialog.getFieldsFromPrevious( r, wFields, 1, new int[] { 1, 2 }, new int[] {}, -1, -1, null );
- }
- } catch ( HopException ke ) {
- new ErrorDialog(
- shell, BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.FailedToGetFields.DialogTitle" ), BaseMessages
- .getString( PKG, "SnowflakeBulkLoader.Dialog.FailedToGetFields.DialogMessage" ), ke );
- }
+ wTrimWhitespace.setSelection(input.isTrimWhitespace());
+ if (input.getNullIf() != null) {
+ wNullIf.setText(input.getNullIf());
}
- /**
- * Reads in the fields from the previous transform and from the ONE next transform and opens an EnterMappingDialog with this
- * information. After the user did the mapping, those information is put into the Select/Rename table.
- */
- private void generateMappings() {
-
- // Determine the source and target fields...
- //
- IRowMeta sourceFields;
- IRowMeta targetFields;
-
- try {
- sourceFields = pipelineMeta.getPrevTransformFields(variables, transformName );
- } catch ( HopException e ) {
- new ErrorDialog( shell,
- BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.DoMapping.UnableToFindSourceFields.Title" ),
- BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.DoMapping.UnableToFindSourceFields.Message" ), e );
- return;
- }
+ wColumnMismatch.setSelection(input.isErrorColumnMismatch());
- // refresh data
- input.setConnection( wConnection.getText() );
- input.setTargetTable( variables.resolve( wTable.getText() ) );
- input.setTargetSchema( variables.resolve( wSchema.getText() ) );
- ITransformMeta iTransformMeta = transformMeta.getTransform();
- try {
- targetFields = iTransformMeta.getRequiredFields(variables);
- } catch ( HopException e ) {
- new ErrorDialog( shell,
- BaseMessages.getString( PKG, "SnowflakeBulkLoader.DoMapping.UnableToFindTargetFields.Title" ),
- BaseMessages.getString( PKG, "SnowflakeBulkLoader.DoMapping.UnableToFindTargetFields.Message" ), e );
- return;
- }
+ wStripNull.setSelection(input.isStripNull());
- // Create the existing mapping list...
- //
- List<SourceToTargetMapping> mappings = new ArrayList<>();
- StringBuilder missingSourceFields = new StringBuilder();
- StringBuilder missingTargetFields = new StringBuilder();
-
- int nrFields = wFields.nrNonEmpty();
- for ( int i = 0; i < nrFields; i++ ) {
- TableItem item = wFields.getNonEmpty( i );
- String source = item.getText( 1 );
- String target = item.getText( 2 );
-
- int sourceIndex = sourceFields.indexOfValue( source );
- if ( sourceIndex < 0 ) {
- missingSourceFields.append( Const.CR ).append( " " ).append( source ).append( " --> " ).append( target );
- }
- int targetIndex = targetFields.indexOfValue( target );
- if ( targetIndex < 0 ) {
- missingTargetFields.append( Const.CR ).append( " " ).append( source ).append( " --> " ).append( target );
- }
- if ( sourceIndex < 0 || targetIndex < 0 ) {
- continue;
- }
+ wIgnoreUtf8.setSelection(input.isIgnoreUtf8());
- SourceToTargetMapping mapping = new SourceToTargetMapping( sourceIndex, targetIndex );
- mappings.add( mapping );
- }
+ wAllowDuplicate.setSelection(input.isAllowDuplicateElements());
- // show a confirm dialog if some missing field was found
- //
- if ( missingSourceFields.length() > 0 || missingTargetFields.length() > 0 ) {
+ wEnableOctal.setSelection(input.isEnableOctal());
- String message = "";
- if ( missingSourceFields.length() > 0 ) {
- message += BaseMessages.getString( PKG, "SnowflakeBulkLoader.DoMapping.SomeSourceFieldsNotFound",
- missingSourceFields.toString() ) + Const.CR;
- }
- if ( missingTargetFields.length() > 0 ) {
- message += BaseMessages.getString( PKG, "SnowflakeBulkLoader.DoMapping.SomeTargetFieldsNotFound",
- missingTargetFields.toString() ) + Const.CR;
- }
- message += Const.CR;
- message +=
- BaseMessages.getString( PKG, "SnowflakeBulkLoader.DoMapping.SomeFieldsNotFoundContinue" ) + Const.CR;
- shell.setImage( GuiResource.getInstance().getImageHopUi() );
- int answer = BaseDialog.openMessageBox(
- shell,
- BaseMessages.getString(PKG, "SnowflakeBulkLoader.DoMapping.SomeFieldsNotFoundTitle"),
- message,
- SWT.ICON_QUESTION | SWT.YES | SWT.NO);
- boolean goOn = (answer & SWT.YES) != 0;
- if ( !goOn ) {
- return;
- }
- }
- EnterMappingDialog d =
- new EnterMappingDialog( SnowflakeBulkLoaderDialog.this.shell, sourceFields.getFieldNames(), targetFields
- .getFieldNames(), mappings );
- mappings = d.open();
-
- // mappings == null if the user pressed cancel
- //
- if ( mappings != null ) {
- // Clear and re-populate!
- //
- wFields.table.removeAll();
- wFields.table.setItemCount( mappings.size() );
- for ( int i = 0; i < mappings.size(); i++ ) {
- SourceToTargetMapping mapping = mappings.get( i );
- TableItem item = wFields.table.getItem( i );
- item.setText( 1, sourceFields.getValueMeta( mapping.getSourcePosition() ).getName() );
- item.setText( 2, targetFields.getValueMeta( mapping.getTargetPosition() ).getName() );
- }
- wFields.setRowNums();
- wFields.optWidth( true );
- }
+ wSpecifyFields.setSelection(input.isSpecifyFields());
+
+ if (input.getJsonField() != null) {
+ wJsonField.setText(input.getJsonField());
}
- /**
- * Presents a dialog box to select a schema from the database. Then sets the selected schema in the dialog
- */
- private void getSchemaNames() {
- DatabaseMeta databaseMeta = pipelineMeta.findDatabase( wConnection.getText() );
- if ( databaseMeta != null ) {
- Database database = new Database( loggingObject, variables, databaseMeta );
- try {
- database.connect();
- String[] schemas = database.getSchemas();
-
- if ( null != schemas && schemas.length > 0 ) {
- schemas = Const.sortStrings( schemas );
- EnterSelectionDialog dialog =
- new EnterSelectionDialog( shell, schemas, BaseMessages.getString(
- PKG, "SnowflakeBulkLoader.Dialog.AvailableSchemas.Title", wConnection.getText() ), BaseMessages
- .getString( PKG, "SnowflakeBulkLoader.Dialog.AvailableSchemas.Message", wConnection.getText() ) );
- String d = dialog.open();
- if ( d != null ) {
- wSchema.setText( Const.NVL( d, "" ) );
- setTableFieldCombo();
- }
+ logDebug("getting fields info...");
- } else {
- MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
- mb.setMessage( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.NoSchema.Error" ) );
- mb.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.GetSchemas.Error" ) );
- mb.open();
- }
- } catch ( Exception e ) {
- new ErrorDialog( shell, BaseMessages.getString( PKG, "System.Dialog.Error.Title" ), BaseMessages
- .getString( PKG, "SnowflakeBulkLoader.Dialog.ErrorGettingSchemas" ), e );
- } finally {
- database.disconnect();
- }
- }
+ for (int i = 0; i < input.getSnowflakeBulkLoaderFields().size(); i++) {
+ SnowflakeBulkLoaderField field = input.getSnowflakeBulkLoaderFields().get(i);
+
+ TableItem item = wFields.table.getItem(i);
+ item.setText(1, Const.NVL(field.getStreamField(), ""));
+ item.setText(2, Const.NVL(field.getTableField(), ""));
}
- /**
- * Opens a dialog to select a table name
- */
- private void getTableName() {
- // New class: SelectTableDialog
- int connr = wConnection.getSelectionIndex();
- if ( connr >= 0 ) {
- DatabaseMeta inf = pipelineMeta.getDatabases().get(connr);
-
- if ( log.isDebug() ) {
- logDebug( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog..Log.LookingAtConnection", inf.toString() ) );
- }
+ wFields.optWidth(true);
+
+ wTransformName.selectAll();
+ wTransformName.setFocus();
+ }
+
+ /**
+ * Cancel making changes. Do not save any of the changes and do not set the pipeline as changed.
+ */
+ private void cancel() {
+ transformName = null;
+
+ input.setChanged(backupChanged);
+
+ dispose();
+ }
+
+ /**
+ * Save the transform settings to the transform metadata
+ *
+ * @param sbl The transform metadata
+ */
+ private void getInfo(SnowflakeBulkLoaderMeta sbl) {
+ sbl.setConnection(wConnection.getText());
+ sbl.setTargetSchema(wSchema.getText());
+ sbl.setTargetTable(wTable.getText());
+ sbl.setLocationTypeById(wLocationType.getSelectionIndex());
+ sbl.setStageName(wStageName.getText());
+ sbl.setWorkDirectory(wWorkDirectory.getText());
+ sbl.setOnErrorById(wOnError.getSelectionIndex());
+ sbl.setErrorLimit(wErrorLimit.getText());
+ sbl.setSplitSize(wSplitSize.getText());
+ sbl.setRemoveFiles(wRemoveFiles.getSelection());
+
+ sbl.setDataTypeById(wDataType.getSelectionIndex());
+ sbl.setTrimWhitespace(wTrimWhitespace.getSelection());
+ sbl.setNullIf(wNullIf.getText());
+ sbl.setErrorColumnMismatch(wColumnMismatch.getSelection());
+ sbl.setStripNull(wStripNull.getSelection());
+ sbl.setIgnoreUtf8(wIgnoreUtf8.getSelection());
+ sbl.setAllowDuplicateElements(wAllowDuplicate.getSelection());
+ sbl.setEnableOctal(wEnableOctal.getSelection());
+
+ sbl.setSpecifyFields(wSpecifyFields.getSelection());
+ sbl.setJsonField(wJsonField.getText());
+
+ int nrfields = wFields.nrNonEmpty();
+
+ List<SnowflakeBulkLoaderField> fields = new ArrayList();
+
+ for (int i = 0; i < nrfields; i++) {
+ SnowflakeBulkLoaderField field = new SnowflakeBulkLoaderField();
+
+ TableItem item = wFields.getNonEmpty(i);
+ field.setStreamField(item.getText(1));
+ field.setTableField(item.getText(2));
+ fields.add(field);
+ }
+ sbl.setSnowflakeBulkLoaderFields(fields);
+ }
- DatabaseExplorerDialog std = new DatabaseExplorerDialog( shell, SWT.NONE, variables, inf, pipelineMeta.getDatabases() );
- std.setSelectedSchemaAndTable( wSchema.getText(), wTable.getText() );
- if ( std.open() ) {
- wSchema.setText( Const.NVL( std.getSchemaName(), "" ) );
- wTable.setText( Const.NVL( std.getTableName(), "" ) );
- setTableFieldCombo();
- }
- } else {
- MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
- mb.setMessage( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.ConnectionError2.DialogMessage" ) );
- mb.setText( BaseMessages.getString( PKG, "System.Dialog.Error.Title" ) );
- mb.open();
- }
+ /** Save the transform settings and close the dialog */
+ private void ok() {
+ if (StringUtils.isEmpty(wTransformName.getText())) {
+ return;
+ }
+ transformName = wTransformName.getText(); // return value
+
+ getInfo(input);
+
+ dispose();
+ }
+
+ /**
+ * Get the fields from the previous transform and load the field mapping table with a direct
+ * mapping of input fields to table fields.
+ */
+ private void get() {
+ try {
+ IRowMeta r = pipelineMeta.getPrevTransformFields(variables, transformName);
+ if (r != null && !r.isEmpty()) {
+ BaseTransformDialog.getFieldsFromPrevious(
+ r, wFields, 1, new int[] {1, 2}, new int[] {}, -1, -1, null);
+ }
+ } catch (HopException ke) {
+ new ErrorDialog(
+ shell,
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.FailedToGetFields.DialogTitle"),
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.FailedToGetFields.DialogMessage"),
+ ke);
+ }
+ }
+
+ /**
+ * Reads in the fields from the previous transform and from the ONE next transform and opens an
+ * EnterMappingDialog with this information. After the user did the mapping, those information is
+ * put into the Select/Rename table.
+ */
+ private void generateMappings() {
+
+ // Determine the source and target fields...
+ //
+ IRowMeta sourceFields;
+ IRowMeta targetFields;
+
+ try {
+ sourceFields = pipelineMeta.getPrevTransformFields(variables, transformName);
+ } catch (HopException e) {
+ new ErrorDialog(
+ shell,
+ BaseMessages.getString(
+ PKG, "SnowflakeBulkLoader.Dialog.DoMapping.UnableToFindSourceFields.Title"),
+ BaseMessages.getString(
+ PKG, "SnowflakeBulkLoader.Dialog.DoMapping.UnableToFindSourceFields.Message"),
+ e);
+ return;
}
- /**
- * Sets the values for the combo box in the table field on the fields tab
- */
- private void setTableFieldCombo() {
- Runnable fieldLoader = new Runnable() {
- public void run() {
- if ( !wTable.isDisposed() && !wConnection.isDisposed() && !wSchema.isDisposed() ) {
- final String tableName = wTable.getText(), connectionName = wConnection.getText(), schemaName =
- wSchema.getText();
-
- // clear
- for ( ColumnInfo tableField : tableFieldColumns ) {
- tableField.setComboValues( new String[]{} );
- }
- if ( !StringUtils.isEmpty( tableName ) ) {
- DatabaseMeta ci = pipelineMeta.findDatabase( connectionName );
- if ( ci != null ) {
- Database db = new Database( loggingObject, variables, ci );
- try {
- db.connect();
-
- String schemaTable =
- ci.getQuotedSchemaTableCombination( variables, variables.resolve( schemaName ), variables.resolve( tableName ) );
- IRowMeta r = db.getTableFields( schemaTable );
- if ( null != r ) {
- String[] fieldNames = r.getFieldNames();
- if ( null != fieldNames ) {
- for ( ColumnInfo tableField : tableFieldColumns ) {
- tableField.setComboValues( fieldNames );
- }
- }
- }
- } catch ( Exception e ) {
- for ( ColumnInfo tableField : tableFieldColumns ) {
- tableField.setComboValues( new String[]{} );
- }
- // ignore any errors here. drop downs will not be
- // filled, but no problem for the user
- } finally {
- try {
- //noinspection ConstantConditions
- if ( db != null ) {
- db.disconnect();
- }
- } catch ( Exception ignored ) {
- // ignore any errors here. Nothing we can do if
- // connection fails to close properly
- //noinspection UnusedAssignment
- db = null;
- }
- }
- }
- }
- }
- }
- };
- shell.getDisplay().asyncExec( fieldLoader );
+ // refresh data
+ input.setConnection(wConnection.getText());
+ input.setTargetTable(variables.resolve(wTable.getText()));
+ input.setTargetSchema(variables.resolve(wSchema.getText()));
+ ITransformMeta iTransformMeta = transformMeta.getTransform();
+ try {
+ targetFields = iTransformMeta.getRequiredFields(variables);
+ } catch (HopException e) {
+ new ErrorDialog(
+ shell,
+ BaseMessages.getString(
+ PKG, "SnowflakeBulkLoader.DoMapping.UnableToFindTargetFields.Title"),
+ BaseMessages.getString(
+ PKG, "SnowflakeBulkLoader.DoMapping.UnableToFindTargetFields.Message"),
+ e);
+ return;
}
- /**
- * Enable and disable fields based on selection changes
- */
- private void setFlags() {
- /////////////////////////////////
- // On Error
- ////////////////////////////////
- if ( wOnError.getSelectionIndex() == SnowflakeBulkLoaderMeta.ON_ERROR_SKIP_FILE ) {
- wlErrorLimit.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.ErrorCountLimit.Label" ) );
- wlErrorLimit.setToolTipText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.ErrorCountLimit.Tooltip" ) );
- wlErrorLimit.setEnabled( true );
- wErrorLimit.setEnabled( true );
- } else if ( wOnError.getSelectionIndex() == SnowflakeBulkLoaderMeta.ON_ERROR_SKIP_FILE_PERCENT ) {
- wlErrorLimit.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.ErrorPercentLimit.Label" ) );
- wlErrorLimit.setToolTipText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.ErrorPercentLimit.Tooltip" ) );
- wlErrorLimit.setEnabled( true );
- wErrorLimit.setEnabled( true );
- } else {
- wlErrorLimit.setEnabled( false );
- wErrorLimit.setEnabled( false );
- }
+ // Create the existing mapping list...
+ //
+ List<SourceToTargetMapping> mappings = new ArrayList<>();
+ StringBuilder missingSourceFields = new StringBuilder();
+ StringBuilder missingTargetFields = new StringBuilder();
+
+ int nrFields = wFields.nrNonEmpty();
+ for (int i = 0; i < nrFields; i++) {
+ TableItem item = wFields.getNonEmpty(i);
+ String source = item.getText(1);
+ String target = item.getText(2);
+
+ int sourceIndex = sourceFields.indexOfValue(source);
+ if (sourceIndex < 0) {
+ missingSourceFields
+ .append(Const.CR)
+ .append(" ")
+ .append(source)
+ .append(" --> ")
+ .append(target);
+ }
+ int targetIndex = targetFields.indexOfValue(target);
+ if (targetIndex < 0) {
+ missingTargetFields
+ .append(Const.CR)
+ .append(" ")
+ .append(source)
+ .append(" --> ")
+ .append(target);
+ }
+ if (sourceIndex < 0 || targetIndex < 0) {
+ continue;
+ }
+
+ SourceToTargetMapping mapping = new SourceToTargetMapping(sourceIndex, targetIndex);
+ mappings.add(mapping);
+ }
- ////////////////////////////
- // Location Type
- ////////////////////////////
- if ( wLocationType.getSelectionIndex() == SnowflakeBulkLoaderMeta.LOCATION_TYPE_INTERNAL_STAGE ) {
- wStageName.setEnabled( true );
- } else {
- wStageName.setEnabled( false );
- }
+ // show a confirm dialog if some missing field was found
+ //
+ if (missingSourceFields.length() > 0 || missingTargetFields.length() > 0) {
+
+ String message = "";
+ if (missingSourceFields.length() > 0) {
+ message +=
+ BaseMessages.getString(
+ PKG,
+ "SnowflakeBulkLoader.DoMapping.SomeSourceFieldsNotFound",
+ missingSourceFields.toString())
+ + Const.CR;
+ }
+ if (missingTargetFields.length() > 0) {
+ message +=
+ BaseMessages.getString(
+ PKG,
+ "SnowflakeBulkLoader.DoMapping.SomeTargetFieldsNotFound",
+ missingTargetFields.toString())
+ + Const.CR;
+ }
+ message += Const.CR;
+ message +=
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.DoMapping.SomeFieldsNotFoundContinue")
+ + Const.CR;
+ shell.setImage(GuiResource.getInstance().getImageHopUi());
+ int answer =
+ BaseDialog.openMessageBox(
+ shell,
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.DoMapping.SomeFieldsNotFoundTitle"),
+ message,
+ SWT.ICON_QUESTION | SWT.YES | SWT.NO);
+ boolean goOn = (answer & SWT.YES) != 0;
+ if (!goOn) {
+ return;
+ }
+ }
+ EnterMappingDialog d =
+ new EnterMappingDialog(
+ SnowflakeBulkLoaderDialog.this.shell,
+ sourceFields.getFieldNames(),
+ targetFields.getFieldNames(),
+ mappings);
+ mappings = d.open();
+
+ // mappings == null if the user pressed cancel
+ //
+ if (mappings != null) {
+ // Clear and re-populate!
+ //
+ wFields.table.removeAll();
+ wFields.table.setItemCount(mappings.size());
+ for (int i = 0; i < mappings.size(); i++) {
+ SourceToTargetMapping mapping = mappings.get(i);
+ TableItem item = wFields.table.getItem(i);
+ item.setText(1, sourceFields.getValueMeta(mapping.getSourcePosition()).getName());
+ item.setText(2, targetFields.getValueMeta(mapping.getTargetPosition()).getName());
+ }
+ wFields.setRowNums();
+ wFields.optWidth(true);
+ }
+ }
+
+ /**
+ * Presents a dialog box to select a schema from the database. Then sets the selected schema in
+ * the dialog
+ */
+ private void getSchemaNames() {
+ DatabaseMeta databaseMeta = pipelineMeta.findDatabase(wConnection.getText(), variables);
+ if (databaseMeta != null) {
+ Database database = new Database(loggingObject, variables, databaseMeta);
+ try {
+ database.connect();
+ String[] schemas = database.getSchemas();
+
+ if (null != schemas && schemas.length > 0) {
+ schemas = Const.sortStrings(schemas);
+ EnterSelectionDialog dialog =
+ new EnterSelectionDialog(
+ shell,
+ schemas,
+ BaseMessages.getString(
+ PKG,
+ "SnowflakeBulkLoader.Dialog.AvailableSchemas.Title",
+ wConnection.getText()),
+ BaseMessages.getString(
+ PKG,
+ "SnowflakeBulkLoader.Dialog.AvailableSchemas.Message",
+ wConnection.getText()));
+ String d = dialog.open();
+ if (d != null) {
+ wSchema.setText(Const.NVL(d, ""));
+ setTableFieldCombo();
+ }
- ////////////////////////////
- // Data Type
- ////////////////////////////
-
- if ( wDataType.getSelectionIndex() == SnowflakeBulkLoaderMeta.DATA_TYPE_JSON ) {
- gCsvGroup.setVisible( false );
- gJsonGroup.setVisible( true );
- wJsonField.setVisible( true );
- wlJsonField.setVisible( true );
- wSpecifyFields.setVisible( false );
- wlSpecifyFields.setVisible( false );
- wFields.setVisible( false );
- wGet.setVisible( false );
- wDoMapping.setVisible( false );
} else {
- gCsvGroup.setVisible( true );
- gJsonGroup.setVisible( false );
- wJsonField.setVisible( false );
- wlJsonField.setVisible( false );
- wSpecifyFields.setVisible( true );
- wlSpecifyFields.setVisible( true );
- wFields.setVisible( true );
- wFields.setEnabled( wSpecifyFields.getSelection() );
- wFields.table.setEnabled( wSpecifyFields.getSelection() );
- if ( wSpecifyFields.getSelection() ) {
- wFields.setForeground( display.getSystemColor( SWT.COLOR_GRAY ) );
- } else {
- wFields.setForeground( display.getSystemColor( SWT.COLOR_BLACK ) );
- }
- wGet.setVisible( true );
- wGet.setEnabled( wSpecifyFields.getSelection() );
- wDoMapping.setVisible( true );
- wDoMapping.setEnabled( wSpecifyFields.getSelection() );
+ MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
+ mb.setMessage(BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.NoSchema.Error"));
+ mb.setText(BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.GetSchemas.Error"));
+ mb.open();
}
-
+ } catch (Exception e) {
+ new ErrorDialog(
+ shell,
+ BaseMessages.getString(PKG, "System.Dialog.Error.Title"),
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.ErrorGettingSchemas"),
+ e);
+ } finally {
+ database.disconnect();
+ }
}
-
- // Generate code for create table...
- // Conversions done by Database
- private void create() {
- DatabaseMeta databaseMeta = pipelineMeta.findDatabase(wConnection.getText(), variables);
-
- try{
- SnowflakeBulkLoaderMeta info = new SnowflakeBulkLoaderMeta();
- getInfo(info);
- IRowMeta prev = pipelineMeta.getPrevTransformFields(variables, transformName);
- TransformMeta transformMeta = pipelineMeta.findTransform(transformName);
-
- if(info.isSpecifyFields()){
- // Only use the fields that were specified.
- IRowMeta prevNew = new RowMeta();
-
- for (int i = 0; i < info.getSnowflakeBulkLoaderFields().size(); i++) {
- SnowflakeBulkLoaderField sf = info.getSnowflakeBulkLoaderFields().get(i);
- IValueMeta insValue = prev.searchValueMeta(sf.getStreamField());
- if (insValue != null) {
- IValueMeta insertValue = insValue.clone();
- insertValue.setName(sf.getTableField());
- prevNew.addValueMeta(insertValue);
- } else {
- throw new HopTransformException(
- BaseMessages.getString(
- PKG, "TableOutputDialog.FailedToFindField.Message", sf.getStreamField()));
- }
- }
- prev = prevNew;
+ }
+
+ /** Opens a dialog to select a table name */
+ private void getTableName() {
+ // New class: SelectTableDialog
+ int connr = wConnection.getSelectionIndex();
+ if (connr >= 0) {
+ DatabaseMeta inf = pipelineMeta.getDatabases().get(connr);
+
+ if (log.isDebug()) {
+ logDebug(
+ BaseMessages.getString(
+ PKG, "SnowflakeBulkLoader.Dialog..Log.LookingAtConnection", inf.toString()));
+ }
+
+ DatabaseExplorerDialog std =
+ new DatabaseExplorerDialog(shell, SWT.NONE, variables, inf, pipelineMeta.getDatabases());
+ std.setSelectedSchemaAndTable(wSchema.getText(), wTable.getText());
+ if (std.open()) {
+ wSchema.setText(Const.NVL(std.getSchemaName(), ""));
+ wTable.setText(Const.NVL(std.getTableName(), ""));
+ setTableFieldCombo();
+ }
+ } else {
+ MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
+ mb.setMessage(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.ConnectionError2.DialogMessage"));
+ mb.setText(BaseMessages.getString(PKG, "System.Dialog.Error.Title"));
+ mb.open();
+ }
+ }
+
+ /** Sets the values for the combo box in the table field on the fields tab */
+ private void setTableFieldCombo() {
+ Runnable fieldLoader =
+ () -> {
+ if (!wTable.isDisposed() && !wConnection.isDisposed() && !wSchema.isDisposed()) {
+ final String tableName = wTable.getText(),
+ connectionName = wConnection.getText(),
+ schemaName = wSchema.getText();
+
+ // clear
+ for (ColumnInfo tableField : tableFieldColumns) {
+ tableField.setComboValues(new String[] {});
}
-
- if(isValidRowMeta(prev)){
- SqlStatement sql =
- info.getSqlStatements(variables, pipelineMeta, transformMeta, prev, metadataProvider);
- if (!sql.hasError()) {
- if (sql.hasSql()) {
- SqlEditor sqledit =
- new SqlEditor(
- shell,
- SWT.NONE,
- variables,
- databaseMeta,
- DbCache.getInstance(),
- sql.getSql());
- sqledit.open();
- } else {
- MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
- mb.setMessage(BaseMessages.getString(PKG, "SnowflakeBulkLoaderDialog.NoSQLNeeds.DialogMessage"));
- mb.setText(BaseMessages.getString(PKG, "SnowflakeBulkLoaderDialog.NoSQLNeeds.DialogTitle"));
- mb.open();
+ if (!StringUtils.isEmpty(tableName)) {
+ DatabaseMeta ci = pipelineMeta.findDatabase(connectionName, variables);
+ if (ci != null) {
+ Database db = new Database(loggingObject, variables, ci);
+ try {
+ db.connect();
+
+ String schemaTable =
+ ci.getQuotedSchemaTableCombination(
+ variables, variables.resolve(schemaName), variables.resolve(tableName));
+ IRowMeta r = db.getTableFields(schemaTable);
+ if (null != r) {
+ String[] fieldNames = r.getFieldNames();
+ if (null != fieldNames) {
+ for (ColumnInfo tableField : tableFieldColumns) {
+ tableField.setComboValues(fieldNames);
+ }
}
- } else {
- MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
- mb.setMessage(sql.getError());
- mb.setText(BaseMessages.getString(PKG, "SnowBulkLoaderDialog.SQLError.DialogTitle"));
- mb.open();
+ }
+ } catch (Exception e) {
+ for (ColumnInfo tableField : tableFieldColumns) {
+ tableField.setComboValues(new String[] {});
+ }
+ // ignore any errors here. drop downs will not be
+ // filled, but no problem for the user
+ } finally {
+ try {
+ //noinspection ConstantConditions
+ if (db != null) {
+ db.disconnect();
+ }
+ } catch (Exception ignored) {
+ // ignore any errors here. Nothing we can do if
+ // connection fails to close properly
+ //noinspection UnusedAssignment
+ db = null;
+ }
}
+ }
}
+ }
+ };
+ shell.getDisplay().asyncExec(fieldLoader);
+ }
+
+ /** Enable and disable fields based on selection changes */
+ private void setFlags() {
+ /////////////////////////////////
+ // On Error
+ ////////////////////////////////
+ if (wOnError.getSelectionIndex() == SnowflakeBulkLoaderMeta.ON_ERROR_SKIP_FILE) {
+ wlErrorLimit.setText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.ErrorCountLimit.Label"));
+ wlErrorLimit.setToolTipText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.ErrorCountLimit.Tooltip"));
+ wlErrorLimit.setEnabled(true);
+ wErrorLimit.setEnabled(true);
+ } else if (wOnError.getSelectionIndex() == SnowflakeBulkLoaderMeta.ON_ERROR_SKIP_FILE_PERCENT) {
+ wlErrorLimit.setText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.ErrorPercentLimit.Label"));
+ wlErrorLimit.setToolTipText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoader.Dialog.ErrorPercentLimit.Tooltip"));
+ wlErrorLimit.setEnabled(true);
+ wErrorLimit.setEnabled(true);
+ } else {
+ wlErrorLimit.setEnabled(false);
+ wErrorLimit.setEnabled(false);
+ }
- } catch (HopException ke) {
- new ErrorDialog(
- shell,
- BaseMessages.getString(PKG, "SnowBulkLoaderDialog.BuildSQLError.DialogTitle"),
- BaseMessages.getString(PKG, "SnowBulkLoaderDialog.BuildSQLError.DialogMessage"),
- ke);
- ke.printStackTrace();
- }
-
+ ////////////////////////////
+ // Location Type
+ ////////////////////////////
+ if (wLocationType.getSelectionIndex() == SnowflakeBulkLoaderMeta.LOCATION_TYPE_INTERNAL_STAGE) {
+ wStageName.setEnabled(true);
+ } else {
+ wStageName.setEnabled(false);
}
- private static boolean isValidRowMeta(IRowMeta rowMeta) {
- for (IValueMeta value : rowMeta.getValueMetaList()) {
- String name = value.getName();
- if (name == null || name.isEmpty()) {
- return false;
- }
+ ////////////////////////////
+ // Data Type
+ ////////////////////////////
+
+ if (wDataType.getSelectionIndex() == SnowflakeBulkLoaderMeta.DATA_TYPE_JSON) {
+ gCsvGroup.setVisible(false);
+ gJsonGroup.setVisible(true);
+ wJsonField.setVisible(true);
+ wlJsonField.setVisible(true);
+ wSpecifyFields.setVisible(false);
+ wlSpecifyFields.setVisible(false);
+ wFields.setVisible(false);
+ wGet.setVisible(false);
+ wDoMapping.setVisible(false);
+ } else {
+ gCsvGroup.setVisible(true);
+ gJsonGroup.setVisible(false);
+ wJsonField.setVisible(false);
+ wlJsonField.setVisible(false);
+ wSpecifyFields.setVisible(true);
+ wlSpecifyFields.setVisible(true);
+ wFields.setVisible(true);
+ wFields.setEnabled(wSpecifyFields.getSelection());
+ wFields.table.setEnabled(wSpecifyFields.getSelection());
+ if (wSpecifyFields.getSelection()) {
+ wFields.setForeground(display.getSystemColor(SWT.COLOR_GRAY));
+ } else {
+ wFields.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
+ }
+ wGet.setVisible(true);
+ wGet.setEnabled(wSpecifyFields.getSelection());
+ wDoMapping.setVisible(true);
+ wDoMapping.setEnabled(wSpecifyFields.getSelection());
+ }
+ }
+
+ // Generate code for create table...
+ // Conversions done by Database
+ private void create() {
+ DatabaseMeta databaseMeta = pipelineMeta.findDatabase(wConnection.getText(), variables);
+
+ try {
+ SnowflakeBulkLoaderMeta info = new SnowflakeBulkLoaderMeta();
+ getInfo(info);
+ IRowMeta prev = pipelineMeta.getPrevTransformFields(variables, transformName);
+ TransformMeta transformMeta = pipelineMeta.findTransform(transformName);
+
+ if (info.isSpecifyFields()) {
+ // Only use the fields that were specified.
+ IRowMeta prevNew = new RowMeta();
+
+ for (int i = 0; i < info.getSnowflakeBulkLoaderFields().size(); i++) {
+ SnowflakeBulkLoaderField sf = info.getSnowflakeBulkLoaderFields().get(i);
+ IValueMeta insValue = prev.searchValueMeta(sf.getStreamField());
+ if (insValue != null) {
+ IValueMeta insertValue = insValue.clone();
+ insertValue.setName(sf.getTableField());
+ prevNew.addValueMeta(insertValue);
+ } else {
+ throw new HopTransformException(
+ BaseMessages.getString(
+ PKG, "TableOutputDialog.FailedToFindField.Message", sf.getStreamField()));
+ }
}
- return true;
+ prev = prevNew;
+ }
+
+ if (isValidRowMeta(prev)) {
+ SqlStatement sql =
+ info.getSqlStatements(variables, pipelineMeta, transformMeta, prev, metadataProvider);
+ if (!sql.hasError()) {
+ if (sql.hasSql()) {
+ SqlEditor sqledit =
+ new SqlEditor(
+ shell, SWT.NONE, variables, databaseMeta, DbCache.getInstance(), sql.getSql());
+ sqledit.open();
+ } else {
+ MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
+ mb.setMessage(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoaderDialog.NoSQLNeeds.DialogMessage"));
+ mb.setText(
+ BaseMessages.getString(PKG, "SnowflakeBulkLoaderDialog.NoSQLNeeds.DialogTitle"));
+ mb.open();
+ }
+ } else {
+ MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
+ mb.setMessage(sql.getError());
+ mb.setText(BaseMessages.getString(PKG, "SnowBulkLoaderDialog.SQLError.DialogTitle"));
+ mb.open();
+ }
+ }
+
+ } catch (HopException ke) {
+ new ErrorDialog(
+ shell,
+ BaseMessages.getString(PKG, "SnowBulkLoaderDialog.BuildSQLError.DialogTitle"),
+ BaseMessages.getString(PKG, "SnowBulkLoaderDialog.BuildSQLError.DialogMessage"),
+ ke);
+ ke.printStackTrace();
+ }
+ }
+
+ private static boolean isValidRowMeta(IRowMeta rowMeta) {
+ for (IValueMeta value : rowMeta.getValueMetaList()) {
+ String name = value.getName();
+ if (name == null || name.isEmpty()) {
+ return false;
+ }
}
+ return true;
+ }
}
diff --git a/plugins/transforms/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderField.java b/plugins/transforms/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderField.java
index 3b37bb2eae..05aed45729 100644
--- a/plugins/transforms/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderField.java
+++ b/plugins/transforms/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderField.java
@@ -20,99 +20,92 @@ package org.apache.hop.pipeline.transforms.snowflake.bulkloader;
import org.apache.hop.core.exception.HopException;
import org.apache.hop.metadata.api.HopMetadataProperty;
-/**
- * Describes a single field mapping from the Hop stream to the Snowflake table
- */
-public class SnowflakeBulkLoaderField implements Cloneable{
-
- /** The field name on the stream */
- @HopMetadataProperty(
- key = "stream_field",
- injectionGroupKey = "OUTPUT_FIELDS" )
- private String streamField;
-
- /** The field name on the table */
- @HopMetadataProperty(
- key = "table_field",
- injectionGroupKey = "OUTPUT_FIELDS" )
- private String tableField;
-
- /**
- *
- * @param streamField The name of the stream field
- * @param tableField The name of the field on the table
- */
- public SnowflakeBulkLoaderField( String streamField, String tableField ) {
- this.streamField = streamField;
- this.tableField = tableField;
- }
-
- public SnowflakeBulkLoaderField() {
- }
-
- /**
- * Enables deep cloning
- * @return A new instance of SnowflakeBulkLoaderField
- */
- public Object clone() {
- try {
- return super.clone();
- } catch ( CloneNotSupportedException e ) {
- return null;
- }
- }
-
- /**
- * Validate that the SnowflakeBulkLoaderField is good
- * @return
- * @throws HopException
- */
- public boolean validate() throws HopException {
- if ( streamField == null || tableField == null ) {
- throw new HopException( "Validation error: Both stream field and database field must be populated." );
- }
-
- return true;
- }
-
- /**
- *
- * @return The name of the stream field
- */
- public String getStreamField() {
- return streamField;
- }
-
- /**
- * Set the stream field
- * @param streamField The name of the field on the Hop stream
- */
- public void setStreamField( String streamField ) {
- this.streamField = streamField;
+/** Describes a single field mapping from the Hop stream to the Snowflake table */
+public class SnowflakeBulkLoaderField implements Cloneable {
+
+ /** The field name on the stream */
+ @HopMetadataProperty(key = "stream_field", injectionGroupKey = "OUTPUT_FIELDS")
+ private String streamField;
+
+ /** The field name on the table */
+ @HopMetadataProperty(key = "table_field", injectionGroupKey = "OUTPUT_FIELDS")
+ private String tableField;
+
+ /**
+ * @param streamField The name of the stream field
+ * @param tableField The name of the field on the table
+ */
+ public SnowflakeBulkLoaderField(String streamField, String tableField) {
+ this.streamField = streamField;
+ this.tableField = tableField;
+ }
+
+ public SnowflakeBulkLoaderField() {}
+
+ /**
+ * Enables deep cloning
+ *
+ * @return A new instance of SnowflakeBulkLoaderField
+ */
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException e) {
+ return null;
}
-
- /**
- *
- * @return The name of the field in the Snowflake table
- */
- public String getTableField() {
- return tableField;
- }
-
- /**
- * Set the field in the Snowflake table
- * @param tableField The name of the field on the table
- */
- public void setTableField( String tableField ) {
- this.tableField = tableField;
- }
-
- /**
- *
- * @return A string in the "streamField -> tableField" format
- */
- public String toString() {
- return streamField + " -> " + tableField;
+ }
+
+ /**
+ * Validate that the SnowflakeBulkLoaderField is good
+ *
+ * @return
+ * @throws HopException
+ */
+ public boolean validate() throws HopException {
+ if (streamField == null || tableField == null) {
+ throw new HopException(
+ "Validation error: Both stream field and database field must be populated.");
}
+ return true;
+ }
+
+ /**
+ * @return The name of the stream field
+ */
+ public String getStreamField() {
+ return streamField;
+ }
+
+ /**
+ * Set the stream field
+ *
+ * @param streamField The name of the field on the Hop stream
+ */
+ public void setStreamField(String streamField) {
+ this.streamField = streamField;
+ }
+
+ /**
+ * @return The name of the field in the Snowflake table
+ */
+ public String getTableField() {
+ return tableField;
+ }
+
+ /**
+ * Set the field in the Snowflake table
+ *
+ * @param tableField The name of the field on the table
+ */
+ public void setTableField(String tableField) {
+ this.tableField = tableField;
+ }
+
+ /**
+ * @return A string in the "streamField -> tableField" format
+ */
+ public String toString() {
+ return streamField + " -> " + tableField;
+ }
}
diff --git a/plugins/transforms/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderMeta.java b/plugins/transforms/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderMeta.java
index 20ee5b2d66..8d8f16a656 100644
--- a/plugins/transforms/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderMeta.java
+++ b/plugins/transforms/snowflake/src/main/java/org/apache/hop/pipeline/transforms/snowflake/bulkloader/SnowflakeBulkLoaderMeta.java
@@ -56,7 +56,7 @@ import java.util.List;
)
public class SnowflakeBulkLoaderMeta extends BaseTransformMeta<SnowflakeBulkLoader, SnowflakeBulkLoaderData> {
- private static Class<?> PKG = SnowflakeBulkLoaderMeta.class; // for i18n purposes, needed by Translator2!!
+ private static final Class<?> PKG = SnowflakeBulkLoaderMeta.class; // for i18n purposes, needed by Translator2!!
protected static final String DEBUG_MODE_VAR = "${SNOWFLAKE_DEBUG_MODE}";
@@ -317,12 +317,12 @@ public class SnowflakeBulkLoaderMeta extends BaseTransformMeta<SnowflakeBulkLoad
return connection;
}
- /**
- * Set the database connection to use
- *
- * @param connection The database connection name
- */
- public void setConnection(String connection) {
+ /**
+ * Set the database connection to use
+ *
+ * @param connection The database connection name
+ */
+ public void setConnection(String connection) {
this.connection = connection;
}
@@ -791,19 +791,19 @@ public class SnowflakeBulkLoaderMeta extends BaseTransformMeta<SnowflakeBulkLoad
return fileDate;
}
- /**
- * Clones the transform so that it can be copied and used in clusters
- *
- * @return A copy of the transform
- */
- public Object clone() {
+ /**
+ * Clones the transform so that it can be copied and used in clusters
+ *
+ * @return A copy of the transform
+ */
+ @Override
+ public Object clone() {
return super.clone();
}
- /**
- * Sets the default values for all metadata attributes.
- */
- public void setDefault() {
+ /** Sets the default values for all metadata attributes. */
+ @Override
+ public void setDefault() {
locationType = LOCATION_TYPE_CODES[LOCATION_TYPE_USER];
workDirectory = "${java.io.tmpdir}";
onError = ON_ERROR_CODES[ON_ERROR_ABORT];
@@ -878,6 +878,7 @@ public class SnowflakeBulkLoaderMeta extends BaseTransformMeta<SnowflakeBulkLoad
* @param variables The variable space
* @param metadataProvider The metastore
*/
+ @Override
public void check(List<ICheckResult> remarks, PipelineMeta pipelineMeta, TransformMeta transformMeta,
IRowMeta prev, String[] input, String[] output, IRowMeta info, IVariables variables,
IHopMetadataProvider metadataProvider ) {
@@ -890,21 +891,21 @@ public class SnowflakeBulkLoaderMeta extends BaseTransformMeta<SnowflakeBulkLoad
PKG, "SnowflakeBulkLoadMeta.CheckResult.FieldsReceived", "" + prev.size() ), transformMeta );
remarks.add( cr );
- String error_message = "";
- boolean error_found = false;
+ String errorMessage = "";
+ boolean errorFound = false;
// Starting from selected fields in ...
for ( SnowflakeBulkLoaderField snowflakeBulkLoaderField : snowflakeBulkLoaderFields ) {
int idx = prev.indexOfValue( snowflakeBulkLoaderField.getStreamField() );
if ( idx < 0 ) {
- error_message += "\t\t" + snowflakeBulkLoaderField.getStreamField() + Const.CR;
- error_found = true;
+ errorMessage += "\t\t" + snowflakeBulkLoaderField.getStreamField() + Const.CR;
+ errorFound = true;
}
}
- if ( error_found ) {
- error_message =
- BaseMessages.getString( PKG, "SnowflakeBulkLoadMeta.CheckResult.FieldsNotFound", error_message );
- cr = new CheckResult( ICheckResult.TYPE_RESULT_ERROR, error_message, transformMeta );
+ if ( errorFound ) {
+ errorMessage =
+ BaseMessages.getString( PKG, "SnowflakeBulkLoadMeta.CheckResult.FieldsNotFound", errorMessage );
+ cr = new CheckResult( ICheckResult.TYPE_RESULT_ERROR, errorMessage, transformMeta );
remarks.add( cr );
} else {
cr =
@@ -943,13 +944,15 @@ public class SnowflakeBulkLoaderMeta extends BaseTransformMeta<SnowflakeBulkLoad
}
}
- /**
- * Gets a list of fields in the database table
- * @param variables The variable space
- * @return The metadata about the fields in the table.
- * @throws HopException
- */
- public IRowMeta getRequiredFields( IVariables variables ) throws HopException {
+ /**
+ * Gets a list of fields in the database table
+ *
+ * @param variables The variable space
+ * @return The metadata about the fields in the table.
+ * @throws HopException
+ */
+ @Override
+ public IRowMeta getRequiredFields(IVariables variables) throws HopException {
String realTableName = variables.resolve( targetTable );
String realSchemaName = variables.resolve( targetSchema );
@@ -984,20 +987,6 @@ public class SnowflakeBulkLoaderMeta extends BaseTransformMeta<SnowflakeBulkLoad
}
- /**
- * Gets the list of databases used by the transform
- * @return The list of databases used by the transform
- */
-/*
- public DatabaseMeta[] getUsedDatabaseConnections() {
- if ( connection != null ) {
- return new DatabaseMeta[]{connection};
- } else {
- return super.getUsedDatabaseConnections();
- }
- }
-*/
-
/**
* Gets the transform data
* @return The transform data
@@ -1173,52 +1162,6 @@ public class SnowflakeBulkLoaderMeta extends BaseTransformMeta<SnowflakeBulkLoad
} else {
retval.setError(BaseMessages.getString(PKG, "TableOutputMeta.Error.NoTable"));
}
-
- /*
- // Copy the row
- IRowMeta tableFields = new RowMeta();
-
-
-
- // Now change the field names
- for (int i = 0; i < snowflakeBulkLoaderFields.size(); i++) {
- IValueMeta v = prev.searchValueMeta(snowflakeBulkLoaderFields.get(i).getStreamField());
- if (v != null) {
- IValueMeta tableField = v.clone();
- tableField.setName(snowflakeBulkLoaderFields.get(i).getTableField());
- tableFields.addValueMeta(tableField);
- } else {
- throw new HopTransformException(
- "Unable to find field ["
- + snowflakeBulkLoaderFields.get(i).getStreamField()
- + "] in the input rows");
- }
- }
-
- if (!Utils.isEmpty(targetTable)) {
- Database db = new Database(loggingObject, variables, databaseMeta);
- try {
- db.connect();
-
- String schemaTable =
- databaseMeta.getQuotedSchemaTableCombination(variables, targetSchema, targetTable);
- String sql = db.getDDL(schemaTable, tableFields, null, false, null, true);
-
- if (sql.length() == 0) {
- retval.setSql(null);
- } else {
- retval.setSql(sql);
- }
- } catch (HopException e) {
- retval.setError(
- BaseMessages.getString(PKG, "SnowflakeBulkLoaderMeta.GetSQL.ErrorOccurred")
- + e.getMessage());
- }
- } else {
- retval.setError(
- BaseMessages.getString(PKG, "SnowflakeBulkLoaderMeta.GetSQL.NoTableDefinedOnConnection"));
- }
-*/
} else {
retval.setError(
BaseMessages.getString(PKG, "SnowflakeBulkLoaderMeta.GetSQL.NotReceivingAnyFields"));