Browse Source
* task list: sgoop node params optimize * security.ts add alarm_instance params * 1 add SqoopTask params 2 add alert plugin aliyun-voice * add license header * commit sqhoop optimize * pnpm-locl.yaml supplement annotation * remove irrelevent commit. * Code specification optimization * optimize sqoop task ui * Merge Code * add the license header to pnpm-locl.yaml * format the code * format the code * Fix sqoop task echo error --------- Co-authored-by: xujiaqiang <xujiaqiang@aimatech.com> Co-authored-by: xujiaqiang <“xujiaqiangwz@163.com”> Co-authored-by: David Zollo <dailidong66@gmail.com>3.2.1-prepare
xujiaqiang
12 months ago
committed by
GitHub
40 changed files with 2899 additions and 1032 deletions
@ -0,0 +1,159 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.plugin.task.sqoop.generator.sources; |
||||
|
||||
import static org.apache.dolphinscheduler.plugin.datasource.api.utils.PasswordUtils.decodePassword; |
||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.COMMA; |
||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.DOUBLE_QUOTES; |
||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EQUAL_SIGN; |
||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SPACE; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.COLUMNS; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DB_CONNECT; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DB_PWD; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DB_USERNAME; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DRIVER; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.MAP_COLUMN_HIVE; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.MAP_COLUMN_JAVA; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.QUERY; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.QUERY_CONDITION; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.QUERY_WHERE; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.QUERY_WITHOUT_CONDITION; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.TABLE; |
||||
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
||||
import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; |
||||
import org.apache.dolphinscheduler.plugin.task.api.model.Property; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopQueryType; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopTaskExecutionContext; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.generator.ISourceGenerator; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.SqoopParameters; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.sources.SourceHanaParameter; |
||||
import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; |
||||
import org.apache.dolphinscheduler.spi.enums.DbType; |
||||
|
||||
import org.apache.commons.lang3.StringUtils; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
/** |
||||
* hana source generator |
||||
*/ |
||||
public class HanaSourceGenerator implements ISourceGenerator { |
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(HanaSourceGenerator.class); |
||||
|
||||
@Override |
||||
public String generate(SqoopParameters sqoopParameters, SqoopTaskExecutionContext sqoopTaskExecutionContext) { |
||||
|
||||
StringBuilder hanaSourceSb = new StringBuilder(); |
||||
|
||||
try { |
||||
SourceHanaParameter sourceHanaParameter = |
||||
JSONUtils.parseObject(sqoopParameters.getSourceParams(), SourceHanaParameter.class); |
||||
|
||||
if (null == sourceHanaParameter) |
||||
return hanaSourceSb.toString(); |
||||
BaseConnectionParam baseDataSource = (BaseConnectionParam) DataSourceUtils.buildConnectionParams( |
||||
sqoopTaskExecutionContext.getSourcetype(), |
||||
sqoopTaskExecutionContext.getSourceConnectionParams()); |
||||
|
||||
if (null == baseDataSource) |
||||
return hanaSourceSb.toString(); |
||||
|
||||
hanaSourceSb.append(SPACE).append(DB_CONNECT) |
||||
.append(SPACE).append(DOUBLE_QUOTES) |
||||
.append(DataSourceUtils.getJdbcUrl(DbType.HANA, baseDataSource)).append(DOUBLE_QUOTES) |
||||
.append(SPACE).append(DRIVER) |
||||
.append(SPACE).append(DataSourceUtils.getDatasourceDriver(DbType.HANA)) |
||||
.append(SPACE).append(DB_USERNAME) |
||||
.append(SPACE).append(baseDataSource.getUser()) |
||||
.append(SPACE).append(DB_PWD) |
||||
.append(SPACE).append(DOUBLE_QUOTES) |
||||
.append(decodePassword(baseDataSource.getPassword())).append(DOUBLE_QUOTES); |
||||
|
||||
// sqoop table & sql query
|
||||
if (sourceHanaParameter.getSrcQueryType() == SqoopQueryType.FORM.getCode()) { |
||||
if (StringUtils.isNotEmpty(sourceHanaParameter.getSrcTable())) { |
||||
hanaSourceSb.append(SPACE).append(TABLE) |
||||
.append(SPACE).append(sourceHanaParameter.getSrcTable()); |
||||
} |
||||
|
||||
if (StringUtils.isNotEmpty(sourceHanaParameter.getSrcColumns())) { |
||||
hanaSourceSb.append(SPACE).append(COLUMNS) |
||||
.append(SPACE).append(sourceHanaParameter.getSrcColumns()); |
||||
} |
||||
} else if (sourceHanaParameter.getSrcQueryType() == SqoopQueryType.SQL.getCode() |
||||
&& StringUtils.isNotEmpty(sourceHanaParameter.getSrcQuerySql())) { |
||||
|
||||
String srcQuery = sourceHanaParameter.getSrcQuerySql(); |
||||
hanaSourceSb.append(SPACE).append(QUERY) |
||||
.append(SPACE).append(DOUBLE_QUOTES).append(srcQuery); |
||||
|
||||
if (srcQuery.toLowerCase().contains(QUERY_WHERE)) { |
||||
hanaSourceSb.append(SPACE).append(QUERY_CONDITION).append(DOUBLE_QUOTES); |
||||
} else { |
||||
hanaSourceSb.append(SPACE).append(QUERY_WITHOUT_CONDITION).append(DOUBLE_QUOTES); |
||||
} |
||||
} |
||||
|
||||
// sqoop hive map column
|
||||
buildColumnMapToHIve(hanaSourceSb, sourceHanaParameter); |
||||
// sqoop map column java
|
||||
buildColumnMapToJava(hanaSourceSb, sourceHanaParameter); |
||||
} catch (Exception e) { |
||||
logger.error(String.format("Sqoop task hana source params build failed: [%s]", e.getMessage())); |
||||
} |
||||
|
||||
return hanaSourceSb.toString(); |
||||
} |
||||
|
||||
private static void buildColumnMapToJava(StringBuilder hanaSourceSb, SourceHanaParameter sourceHanaParameter) { |
||||
List<Property> mapColumnJava = sourceHanaParameter.getMapColumnJava(); |
||||
|
||||
if (null != mapColumnJava && !mapColumnJava.isEmpty()) { |
||||
StringBuilder columnMap = new StringBuilder(); |
||||
for (Property item : mapColumnJava) { |
||||
columnMap.append(item.getProp()).append(EQUAL_SIGN).append(item.getValue()).append(COMMA); |
||||
} |
||||
|
||||
if (StringUtils.isNotEmpty(columnMap.toString())) { |
||||
hanaSourceSb.append(SPACE).append(MAP_COLUMN_JAVA) |
||||
.append(SPACE).append(columnMap.substring(0, columnMap.length() - 1)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private static void buildColumnMapToHIve(StringBuilder hanaSourceSb, SourceHanaParameter sourceHanaParameter) { |
||||
List<Property> mapColumnHive = sourceHanaParameter.getMapColumnHive(); |
||||
|
||||
if (null != mapColumnHive && !mapColumnHive.isEmpty()) { |
||||
StringBuilder columnMap = new StringBuilder(); |
||||
for (Property item : mapColumnHive) { |
||||
columnMap.append(item.getProp()).append(EQUAL_SIGN).append(item.getValue()).append(COMMA); |
||||
} |
||||
|
||||
if (StringUtils.isNotEmpty(columnMap.toString())) { |
||||
hanaSourceSb.append(SPACE).append(MAP_COLUMN_HIVE) |
||||
.append(SPACE).append(columnMap.substring(0, columnMap.length() - 1)); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,157 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.plugin.task.sqoop.generator.sources; |
||||
|
||||
import static org.apache.dolphinscheduler.plugin.datasource.api.utils.PasswordUtils.decodePassword; |
||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.COMMA; |
||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.DOUBLE_QUOTES; |
||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EQUAL_SIGN; |
||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SPACE; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.COLUMNS; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DB_CONNECT; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DB_PWD; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DB_USERNAME; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.MAP_COLUMN_HIVE; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.MAP_COLUMN_JAVA; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.QUERY; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.QUERY_CONDITION; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.QUERY_WHERE; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.QUERY_WITHOUT_CONDITION; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.TABLE; |
||||
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
||||
import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; |
||||
import org.apache.dolphinscheduler.plugin.task.api.model.Property; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopQueryType; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopTaskExecutionContext; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.generator.ISourceGenerator; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.SqoopParameters; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.sources.SourceOracleParameter; |
||||
import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; |
||||
import org.apache.dolphinscheduler.spi.enums.DbType; |
||||
|
||||
import org.apache.commons.lang3.StringUtils; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
/** |
||||
* oracle source generator |
||||
*/ |
||||
public class OracleSourceGenerator implements ISourceGenerator { |
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OracleSourceGenerator.class); |
||||
|
||||
@Override |
||||
public String generate(SqoopParameters sqoopParameters, SqoopTaskExecutionContext sqoopTaskExecutionContext) { |
||||
|
||||
StringBuilder oracleSourceSb = new StringBuilder(); |
||||
|
||||
try { |
||||
SourceOracleParameter sourceOracleParameter = |
||||
JSONUtils.parseObject(sqoopParameters.getSourceParams(), SourceOracleParameter.class); |
||||
|
||||
if (null == sourceOracleParameter) |
||||
return oracleSourceSb.toString(); |
||||
BaseConnectionParam baseDataSource = (BaseConnectionParam) DataSourceUtils.buildConnectionParams( |
||||
sqoopTaskExecutionContext.getSourcetype(), |
||||
sqoopTaskExecutionContext.getSourceConnectionParams()); |
||||
|
||||
if (null == baseDataSource) |
||||
return oracleSourceSb.toString(); |
||||
|
||||
oracleSourceSb.append(SPACE).append(DB_CONNECT) |
||||
.append(SPACE).append(DOUBLE_QUOTES) |
||||
.append(DataSourceUtils.getJdbcUrl(DbType.ORACLE, baseDataSource)).append(DOUBLE_QUOTES) |
||||
.append(SPACE).append(DB_USERNAME) |
||||
.append(SPACE).append(baseDataSource.getUser()) |
||||
.append(SPACE).append(DB_PWD) |
||||
.append(SPACE).append(DOUBLE_QUOTES) |
||||
.append(decodePassword(baseDataSource.getPassword())).append(DOUBLE_QUOTES); |
||||
|
||||
// sqoop table & sql query
|
||||
if (sourceOracleParameter.getSrcQueryType() == SqoopQueryType.FORM.getCode()) { |
||||
if (StringUtils.isNotEmpty(sourceOracleParameter.getSrcTable())) { |
||||
oracleSourceSb.append(SPACE).append(TABLE) |
||||
.append(SPACE).append(sourceOracleParameter.getSrcTable()); |
||||
} |
||||
|
||||
if (StringUtils.isNotEmpty(sourceOracleParameter.getSrcColumns())) { |
||||
oracleSourceSb.append(SPACE).append(COLUMNS) |
||||
.append(SPACE).append(sourceOracleParameter.getSrcColumns()); |
||||
} |
||||
} else if (sourceOracleParameter.getSrcQueryType() == SqoopQueryType.SQL.getCode() |
||||
&& StringUtils.isNotEmpty(sourceOracleParameter.getSrcQuerySql())) { |
||||
|
||||
String srcQuery = sourceOracleParameter.getSrcQuerySql(); |
||||
oracleSourceSb.append(SPACE).append(QUERY) |
||||
.append(SPACE).append(DOUBLE_QUOTES).append(srcQuery); |
||||
|
||||
if (srcQuery.toLowerCase().contains(QUERY_WHERE)) { |
||||
oracleSourceSb.append(SPACE).append(QUERY_CONDITION).append(DOUBLE_QUOTES); |
||||
} else { |
||||
oracleSourceSb.append(SPACE).append(QUERY_WITHOUT_CONDITION).append(DOUBLE_QUOTES); |
||||
} |
||||
} |
||||
// sqoop hive map column
|
||||
buildColumnMapToHIve(oracleSourceSb, sourceOracleParameter); |
||||
// sqoop map column java
|
||||
buildColumnMapToJava(oracleSourceSb, sourceOracleParameter); |
||||
} catch (Exception e) { |
||||
logger.error(String.format("Sqoop task oracle source params build failed: [%s]", e.getMessage())); |
||||
} |
||||
|
||||
return oracleSourceSb.toString(); |
||||
} |
||||
|
||||
private static void buildColumnMapToJava(StringBuilder oracleSourceSb, |
||||
SourceOracleParameter sourceOracleParameter) { |
||||
List<Property> mapColumnJava = sourceOracleParameter.getMapColumnJava(); |
||||
|
||||
if (null != mapColumnJava && !mapColumnJava.isEmpty()) { |
||||
StringBuilder columnMap = new StringBuilder(); |
||||
for (Property item : mapColumnJava) { |
||||
columnMap.append(item.getProp()).append(EQUAL_SIGN).append(item.getValue()).append(COMMA); |
||||
} |
||||
|
||||
if (StringUtils.isNotEmpty(columnMap.toString())) { |
||||
oracleSourceSb.append(SPACE).append(MAP_COLUMN_JAVA) |
||||
.append(SPACE).append(columnMap.substring(0, columnMap.length() - 1)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private static void buildColumnMapToHIve(StringBuilder oracleSourceSb, |
||||
SourceOracleParameter sourceOracleParameter) { |
||||
List<Property> mapColumnHive = sourceOracleParameter.getMapColumnHive(); |
||||
|
||||
if (null != mapColumnHive && !mapColumnHive.isEmpty()) { |
||||
StringBuilder columnMap = new StringBuilder(); |
||||
for (Property item : mapColumnHive) { |
||||
columnMap.append(item.getProp()).append(EQUAL_SIGN).append(item.getValue()).append(COMMA); |
||||
} |
||||
|
||||
if (StringUtils.isNotEmpty(columnMap.toString())) { |
||||
oracleSourceSb.append(SPACE).append(MAP_COLUMN_HIVE) |
||||
.append(SPACE).append(columnMap.substring(0, columnMap.length() - 1)); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,163 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.plugin.task.sqoop.generator.sources; |
||||
|
||||
import static org.apache.dolphinscheduler.plugin.datasource.api.utils.PasswordUtils.decodePassword; |
||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.COMMA; |
||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.DOUBLE_QUOTES; |
||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EQUAL_SIGN; |
||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SPACE; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.COLUMNS; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DB_CONNECT; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DB_PWD; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DB_USERNAME; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DRIVER; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.MAP_COLUMN_HIVE; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.MAP_COLUMN_JAVA; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.QUERY; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.QUERY_CONDITION; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.QUERY_WHERE; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.QUERY_WITHOUT_CONDITION; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.TABLE; |
||||
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
||||
import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; |
||||
import org.apache.dolphinscheduler.plugin.task.api.model.Property; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopQueryType; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopTaskExecutionContext; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.generator.ISourceGenerator; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.SqoopParameters; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.sources.SourceSqlServerParameter; |
||||
import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; |
||||
import org.apache.dolphinscheduler.spi.enums.DbType; |
||||
|
||||
import org.apache.commons.lang3.StringUtils; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
/** |
||||
* sqlServer source generator |
||||
*/ |
||||
public class SqlServerSourceGenerator implements ISourceGenerator { |
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SqlServerSourceGenerator.class); |
||||
|
||||
@Override |
||||
public String generate(SqoopParameters sqoopParameters, SqoopTaskExecutionContext sqoopTaskExecutionContext) { |
||||
|
||||
StringBuilder sqlServerSourceSb = new StringBuilder(); |
||||
|
||||
try { |
||||
SourceSqlServerParameter sourceSqlServerParameter = |
||||
JSONUtils.parseObject(sqoopParameters.getSourceParams(), SourceSqlServerParameter.class); |
||||
|
||||
if (null == sourceSqlServerParameter) |
||||
return sqlServerSourceSb.toString(); |
||||
|
||||
BaseConnectionParam baseDataSource = (BaseConnectionParam) DataSourceUtils.buildConnectionParams( |
||||
sqoopTaskExecutionContext.getSourcetype(), |
||||
sqoopTaskExecutionContext.getSourceConnectionParams()); |
||||
|
||||
if (null == baseDataSource) |
||||
return sqlServerSourceSb.toString(); |
||||
|
||||
sqlServerSourceSb.append(SPACE).append(DB_CONNECT) |
||||
.append(SPACE).append(DOUBLE_QUOTES) |
||||
.append(DataSourceUtils.getJdbcUrl(DbType.SQLSERVER, baseDataSource)).append(DOUBLE_QUOTES) |
||||
.append(SPACE).append(DRIVER) |
||||
.append(SPACE).append(DataSourceUtils.getDatasourceDriver(DbType.SQLSERVER)) |
||||
.append(SPACE).append(DB_USERNAME) |
||||
.append(SPACE).append(baseDataSource.getUser()) |
||||
.append(SPACE).append(DB_PWD) |
||||
.append(SPACE).append(DOUBLE_QUOTES) |
||||
.append(decodePassword(baseDataSource.getPassword())).append(DOUBLE_QUOTES); |
||||
|
||||
// sqoop table & sql query
|
||||
if (sourceSqlServerParameter.getSrcQueryType() == SqoopQueryType.FORM.getCode()) { |
||||
if (StringUtils.isNotEmpty(sourceSqlServerParameter.getSrcTable())) { |
||||
sqlServerSourceSb.append(SPACE).append(TABLE) |
||||
.append(SPACE).append(sourceSqlServerParameter.getSrcTable()); |
||||
} |
||||
|
||||
if (StringUtils.isNotEmpty(sourceSqlServerParameter.getSrcColumns())) { |
||||
sqlServerSourceSb.append(SPACE).append(COLUMNS) |
||||
.append(SPACE).append(sourceSqlServerParameter.getSrcColumns()); |
||||
} |
||||
} else if (sourceSqlServerParameter.getSrcQueryType() == SqoopQueryType.SQL.getCode() |
||||
&& StringUtils.isNotEmpty(sourceSqlServerParameter.getSrcQuerySql())) { |
||||
|
||||
String srcQuery = sourceSqlServerParameter.getSrcQuerySql(); |
||||
sqlServerSourceSb.append(SPACE).append(QUERY) |
||||
.append(SPACE).append(DOUBLE_QUOTES).append(srcQuery); |
||||
|
||||
if (srcQuery.toLowerCase().contains(QUERY_WHERE)) { |
||||
sqlServerSourceSb.append(SPACE).append(QUERY_CONDITION).append(DOUBLE_QUOTES); |
||||
} else { |
||||
sqlServerSourceSb.append(SPACE).append(QUERY_WITHOUT_CONDITION).append(DOUBLE_QUOTES); |
||||
} |
||||
} |
||||
// sqoop hive map column
|
||||
buildColumnMapToHive(sqlServerSourceSb, sourceSqlServerParameter); |
||||
// sqoop map column java
|
||||
buildColumnMapToJava(sqlServerSourceSb, sourceSqlServerParameter); |
||||
|
||||
} catch (Exception e) { |
||||
logger.error(String.format("Sqoop task sqlServer source params build failed: [%s]", e.getMessage())); |
||||
} |
||||
|
||||
return sqlServerSourceSb.toString(); |
||||
} |
||||
|
||||
private static void buildColumnMapToHive(StringBuilder sqlServerSourceSb, |
||||
SourceSqlServerParameter sourceSqlServerParameter) { |
||||
List<Property> mapColumnHive = sourceSqlServerParameter.getMapColumnHive(); |
||||
|
||||
if (null != mapColumnHive && !mapColumnHive.isEmpty()) { |
||||
StringBuilder columnMap = new StringBuilder(); |
||||
for (Property item : mapColumnHive) { |
||||
columnMap.append(item.getProp()).append(EQUAL_SIGN).append(item.getValue()).append(COMMA); |
||||
} |
||||
|
||||
if (StringUtils.isNotEmpty(columnMap.toString())) { |
||||
sqlServerSourceSb.append(SPACE).append(MAP_COLUMN_HIVE) |
||||
.append(SPACE).append(columnMap.substring(0, columnMap.length() - 1)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private static void buildColumnMapToJava(StringBuilder sqlServerSourceSb, |
||||
SourceSqlServerParameter sourceSqlServerParameter) { |
||||
List<Property> mapColumnJava = sourceSqlServerParameter.getMapColumnJava(); |
||||
|
||||
if (null != mapColumnJava && !mapColumnJava.isEmpty()) { |
||||
StringBuilder columnMap = new StringBuilder(); |
||||
for (Property item : mapColumnJava) { |
||||
columnMap.append(item.getProp()).append(EQUAL_SIGN).append(item.getValue()).append(COMMA); |
||||
} |
||||
|
||||
if (StringUtils.isNotEmpty(columnMap.toString())) { |
||||
sqlServerSourceSb.append(SPACE).append(MAP_COLUMN_JAVA) |
||||
.append(SPACE).append(columnMap.substring(0, columnMap.length() - 1)); |
||||
} |
||||
|
||||
} |
||||
} |
||||
} |
@ -0,0 +1,128 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.plugin.task.sqoop.generator.targets; |
||||
|
||||
import static org.apache.dolphinscheduler.plugin.datasource.api.utils.PasswordUtils.decodePassword; |
||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.DOUBLE_QUOTES; |
||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_QUOTES; |
||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SPACE; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.COLUMNS; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DB_CONNECT; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DB_PWD; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DB_USERNAME; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DRIVER; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.FIELDS_TERMINATED_BY; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.LINES_TERMINATED_BY; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.TABLE; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.UPDATE_KEY; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.UPDATE_MODE; |
||||
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
||||
import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopTaskExecutionContext; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.generator.ITargetGenerator; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.SqoopParameters; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.targets.TargetHanaParameter; |
||||
import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; |
||||
import org.apache.dolphinscheduler.spi.enums.DbType; |
||||
|
||||
import org.apache.commons.lang3.StringUtils; |
||||
|
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
/** |
||||
* hana target generator |
||||
*/ |
||||
public class HanaTargetGenerator implements ITargetGenerator { |
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(HanaTargetGenerator.class); |
||||
|
||||
@Override |
||||
public String generate(SqoopParameters sqoopParameters, SqoopTaskExecutionContext sqoopTaskExecutionContext) { |
||||
|
||||
StringBuilder hanaTargetSb = new StringBuilder(); |
||||
|
||||
try { |
||||
TargetHanaParameter targetHanaParameter = |
||||
JSONUtils.parseObject(sqoopParameters.getTargetParams(), TargetHanaParameter.class); |
||||
if (null == targetHanaParameter || targetHanaParameter.getTargetDatasource() == 0) |
||||
return hanaTargetSb.toString(); |
||||
// get datasource
|
||||
BaseConnectionParam baseDataSource = (BaseConnectionParam) DataSourceUtils.buildConnectionParams( |
||||
sqoopTaskExecutionContext.getTargetType(), |
||||
sqoopTaskExecutionContext.getTargetConnectionParams()); |
||||
|
||||
if (null == baseDataSource) { |
||||
return hanaTargetSb.toString(); |
||||
} |
||||
hanaTargetSb.append(SPACE).append(DB_CONNECT) |
||||
.append(SPACE).append(DOUBLE_QUOTES) |
||||
.append(DataSourceUtils.getJdbcUrl(DbType.HANA, baseDataSource)).append(DOUBLE_QUOTES) |
||||
.append(SPACE).append(DRIVER) |
||||
.append(SPACE).append(DataSourceUtils.getDatasourceDriver(DbType.HANA)) |
||||
.append(SPACE).append(DB_USERNAME) |
||||
.append(SPACE).append(baseDataSource.getUser()) |
||||
.append(SPACE).append(DB_PWD) |
||||
.append(SPACE).append(DOUBLE_QUOTES) |
||||
.append(decodePassword(baseDataSource.getPassword())).append(DOUBLE_QUOTES) |
||||
.append(SPACE).append(TABLE) |
||||
.append(SPACE).append(targetHanaParameter.getTargetTable()); |
||||
|
||||
if (StringUtils.isNotEmpty(targetHanaParameter.getTargetColumns())) { |
||||
hanaTargetSb.append(SPACE).append(COLUMNS) |
||||
.append(SPACE).append(targetHanaParameter.getTargetColumns()); |
||||
} |
||||
|
||||
if (StringUtils.isNotEmpty(targetHanaParameter.getFieldsTerminated())) { |
||||
hanaTargetSb.append(SPACE).append(FIELDS_TERMINATED_BY); |
||||
if (targetHanaParameter.getFieldsTerminated().contains("'")) { |
||||
hanaTargetSb.append(SPACE).append(targetHanaParameter.getFieldsTerminated()); |
||||
|
||||
} else { |
||||
hanaTargetSb.append(SPACE).append(SINGLE_QUOTES) |
||||
.append(targetHanaParameter.getFieldsTerminated()).append(SINGLE_QUOTES); |
||||
} |
||||
} |
||||
|
||||
if (StringUtils.isNotEmpty(targetHanaParameter.getLinesTerminated())) { |
||||
hanaTargetSb.append(SPACE).append(LINES_TERMINATED_BY); |
||||
if (targetHanaParameter.getLinesTerminated().contains(SINGLE_QUOTES)) { |
||||
hanaTargetSb.append(SPACE).append(targetHanaParameter.getLinesTerminated()); |
||||
} else { |
||||
hanaTargetSb.append(SPACE).append(SINGLE_QUOTES) |
||||
.append(targetHanaParameter.getLinesTerminated()).append(SINGLE_QUOTES); |
||||
} |
||||
} |
||||
|
||||
if (targetHanaParameter.getIsUpdate() |
||||
&& StringUtils.isNotEmpty(targetHanaParameter.getTargetUpdateKey()) |
||||
&& StringUtils.isNotEmpty(targetHanaParameter.getTargetUpdateMode())) { |
||||
hanaTargetSb.append(SPACE).append(UPDATE_KEY) |
||||
.append(SPACE).append(targetHanaParameter.getTargetUpdateKey()) |
||||
.append(SPACE).append(UPDATE_MODE) |
||||
.append(SPACE).append(targetHanaParameter.getTargetUpdateMode()); |
||||
} |
||||
} catch (Exception e) { |
||||
logger.error(String.format("Sqoop hana target params build failed: [%s]", e.getMessage())); |
||||
} |
||||
|
||||
return hanaTargetSb.toString(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,128 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.plugin.task.sqoop.generator.targets; |
||||
|
||||
import static org.apache.dolphinscheduler.plugin.datasource.api.utils.PasswordUtils.decodePassword; |
||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.DOUBLE_QUOTES; |
||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_QUOTES; |
||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SPACE; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.COLUMNS; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DB_CONNECT; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DB_PWD; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DB_USERNAME; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.FIELDS_TERMINATED_BY; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.LINES_TERMINATED_BY; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.TABLE; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.UPDATE_KEY; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.UPDATE_MODE; |
||||
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
||||
import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopTaskExecutionContext; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.generator.ITargetGenerator; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.SqoopParameters; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.targets.TargetOracleParameter; |
||||
import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; |
||||
import org.apache.dolphinscheduler.spi.enums.DbType; |
||||
|
||||
import org.apache.commons.lang3.StringUtils; |
||||
|
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
/** |
||||
* oracle target generator |
||||
*/ |
||||
public class OracleTargetGenerator implements ITargetGenerator { |
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OracleTargetGenerator.class); |
||||
|
||||
@Override |
||||
public String generate(SqoopParameters sqoopParameters, SqoopTaskExecutionContext sqoopTaskExecutionContext) { |
||||
|
||||
StringBuilder oracleTargetSb = new StringBuilder(); |
||||
|
||||
try { |
||||
TargetOracleParameter targetOracleParameter = |
||||
JSONUtils.parseObject(sqoopParameters.getTargetParams(), TargetOracleParameter.class); |
||||
|
||||
if (null == targetOracleParameter || targetOracleParameter.getTargetDatasource() == 0) |
||||
return oracleTargetSb.toString(); |
||||
|
||||
// get datasource
|
||||
BaseConnectionParam baseDataSource = (BaseConnectionParam) DataSourceUtils.buildConnectionParams( |
||||
sqoopTaskExecutionContext.getTargetType(), |
||||
sqoopTaskExecutionContext.getTargetConnectionParams()); |
||||
|
||||
if (null == baseDataSource) { |
||||
return oracleTargetSb.toString(); |
||||
} |
||||
|
||||
oracleTargetSb.append(SPACE).append(DB_CONNECT) |
||||
.append(SPACE).append(DOUBLE_QUOTES) |
||||
.append(DataSourceUtils.getJdbcUrl(DbType.ORACLE, baseDataSource)).append(DOUBLE_QUOTES) |
||||
.append(SPACE).append(DB_USERNAME) |
||||
.append(SPACE).append(baseDataSource.getUser()) |
||||
.append(SPACE).append(DB_PWD) |
||||
.append(SPACE).append(DOUBLE_QUOTES) |
||||
.append(decodePassword(baseDataSource.getPassword())).append(DOUBLE_QUOTES) |
||||
.append(SPACE).append(TABLE) |
||||
.append(SPACE).append(targetOracleParameter.getTargetTable()); |
||||
|
||||
if (StringUtils.isNotEmpty(targetOracleParameter.getTargetColumns())) { |
||||
oracleTargetSb.append(SPACE).append(COLUMNS) |
||||
.append(SPACE).append(targetOracleParameter.getTargetColumns()); |
||||
} |
||||
|
||||
if (StringUtils.isNotEmpty(targetOracleParameter.getFieldsTerminated())) { |
||||
oracleTargetSb.append(SPACE).append(FIELDS_TERMINATED_BY); |
||||
if (targetOracleParameter.getFieldsTerminated().contains("'")) { |
||||
oracleTargetSb.append(SPACE).append(targetOracleParameter.getFieldsTerminated()); |
||||
|
||||
} else { |
||||
oracleTargetSb.append(SPACE).append(SINGLE_QUOTES) |
||||
.append(targetOracleParameter.getFieldsTerminated()).append(SINGLE_QUOTES); |
||||
} |
||||
} |
||||
|
||||
if (StringUtils.isNotEmpty(targetOracleParameter.getLinesTerminated())) { |
||||
oracleTargetSb.append(SPACE).append(LINES_TERMINATED_BY); |
||||
if (targetOracleParameter.getLinesTerminated().contains(SINGLE_QUOTES)) { |
||||
oracleTargetSb.append(SPACE).append(targetOracleParameter.getLinesTerminated()); |
||||
} else { |
||||
oracleTargetSb.append(SPACE).append(SINGLE_QUOTES) |
||||
.append(targetOracleParameter.getLinesTerminated()).append(SINGLE_QUOTES); |
||||
} |
||||
} |
||||
|
||||
if (targetOracleParameter.getIsUpdate() |
||||
&& StringUtils.isNotEmpty(targetOracleParameter.getTargetUpdateKey()) |
||||
&& StringUtils.isNotEmpty(targetOracleParameter.getTargetUpdateMode())) { |
||||
oracleTargetSb.append(SPACE).append(UPDATE_KEY) |
||||
.append(SPACE).append(targetOracleParameter.getTargetUpdateKey()) |
||||
.append(SPACE).append(UPDATE_MODE) |
||||
.append(SPACE).append(targetOracleParameter.getTargetUpdateMode()); |
||||
} |
||||
|
||||
} catch (Exception e) { |
||||
logger.error(String.format("Sqoop oracle target params build failed: [%s]", e.getMessage())); |
||||
} |
||||
|
||||
return oracleTargetSb.toString(); |
||||
} |
||||
} |
@ -0,0 +1,130 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.plugin.task.sqoop.generator.targets; |
||||
|
||||
import static org.apache.dolphinscheduler.plugin.datasource.api.utils.PasswordUtils.decodePassword; |
||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.DOUBLE_QUOTES; |
||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_QUOTES; |
||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SPACE; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.COLUMNS; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DB_CONNECT; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DB_PWD; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DB_USERNAME; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.FIELDS_TERMINATED_BY; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.LINES_TERMINATED_BY; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.TABLE; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.UPDATE_KEY; |
||||
import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.UPDATE_MODE; |
||||
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
||||
import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopTaskExecutionContext; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.generator.ITargetGenerator; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.SqoopParameters; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.targets.TargetSqlServerParameter; |
||||
import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; |
||||
import org.apache.dolphinscheduler.spi.enums.DbType; |
||||
|
||||
import org.apache.commons.lang3.StringUtils; |
||||
|
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
/** |
||||
* sqlServer target generator |
||||
*/ |
||||
public class SqlServerTargetGenerator implements ITargetGenerator { |
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SqlServerTargetGenerator.class); |
||||
|
||||
@Override |
||||
public String generate(SqoopParameters sqoopParameters, SqoopTaskExecutionContext sqoopTaskExecutionContext) { |
||||
|
||||
StringBuilder oracleTargetSb = new StringBuilder(); |
||||
|
||||
try { |
||||
TargetSqlServerParameter targetSqlServerParameter = |
||||
JSONUtils.parseObject(sqoopParameters.getTargetParams(), TargetSqlServerParameter.class); |
||||
|
||||
if (null == targetSqlServerParameter || targetSqlServerParameter.getTargetDatasource() == 0) |
||||
return oracleTargetSb.toString(); |
||||
|
||||
// get datasource
|
||||
BaseConnectionParam baseDataSource = (BaseConnectionParam) DataSourceUtils.buildConnectionParams( |
||||
sqoopTaskExecutionContext.getTargetType(), |
||||
sqoopTaskExecutionContext.getTargetConnectionParams()); |
||||
|
||||
if (null == baseDataSource) { |
||||
return oracleTargetSb.toString(); |
||||
} |
||||
|
||||
oracleTargetSb.append(SPACE).append(DB_CONNECT) |
||||
.append(SPACE).append(DOUBLE_QUOTES) |
||||
.append(DataSourceUtils.getJdbcUrl(DbType.SQLSERVER, baseDataSource)).append(DOUBLE_QUOTES) |
||||
// .append(SPACE).append(DRIVER)
|
||||
.append(SPACE).append(DataSourceUtils.getDatasourceDriver(DbType.SQLSERVER)) |
||||
.append(SPACE).append(DB_USERNAME) |
||||
.append(SPACE).append(baseDataSource.getUser()) |
||||
.append(SPACE).append(DB_PWD) |
||||
.append(SPACE).append(DOUBLE_QUOTES) |
||||
.append(decodePassword(baseDataSource.getPassword())).append(DOUBLE_QUOTES) |
||||
.append(SPACE).append(TABLE) |
||||
.append(SPACE).append(targetSqlServerParameter.getTargetTable()); |
||||
|
||||
if (StringUtils.isNotEmpty(targetSqlServerParameter.getTargetColumns())) { |
||||
oracleTargetSb.append(SPACE).append(COLUMNS) |
||||
.append(SPACE).append(targetSqlServerParameter.getTargetColumns()); |
||||
} |
||||
|
||||
if (StringUtils.isNotEmpty(targetSqlServerParameter.getFieldsTerminated())) { |
||||
oracleTargetSb.append(SPACE).append(FIELDS_TERMINATED_BY); |
||||
if (targetSqlServerParameter.getFieldsTerminated().contains("'")) { |
||||
oracleTargetSb.append(SPACE).append(targetSqlServerParameter.getFieldsTerminated()); |
||||
|
||||
} else { |
||||
oracleTargetSb.append(SPACE).append(SINGLE_QUOTES) |
||||
.append(targetSqlServerParameter.getFieldsTerminated()).append(SINGLE_QUOTES); |
||||
} |
||||
} |
||||
|
||||
if (StringUtils.isNotEmpty(targetSqlServerParameter.getLinesTerminated())) { |
||||
oracleTargetSb.append(SPACE).append(LINES_TERMINATED_BY); |
||||
if (targetSqlServerParameter.getLinesTerminated().contains(SINGLE_QUOTES)) { |
||||
oracleTargetSb.append(SPACE).append(targetSqlServerParameter.getLinesTerminated()); |
||||
} else { |
||||
oracleTargetSb.append(SPACE).append(SINGLE_QUOTES) |
||||
.append(targetSqlServerParameter.getLinesTerminated()).append(SINGLE_QUOTES); |
||||
} |
||||
} |
||||
|
||||
if (targetSqlServerParameter.getIsUpdate() |
||||
&& StringUtils.isNotEmpty(targetSqlServerParameter.getTargetUpdateKey()) |
||||
&& StringUtils.isNotEmpty(targetSqlServerParameter.getTargetUpdateMode())) { |
||||
oracleTargetSb.append(SPACE).append(UPDATE_KEY) |
||||
.append(SPACE).append(targetSqlServerParameter.getTargetUpdateKey()) |
||||
.append(SPACE).append(UPDATE_MODE) |
||||
.append(SPACE).append(targetSqlServerParameter.getTargetUpdateMode()); |
||||
} |
||||
|
||||
} catch (Exception e) { |
||||
logger.error(String.format("Sqoop oracle target params build failed: [%s]", e.getMessage())); |
||||
} |
||||
|
||||
return oracleTargetSb.toString(); |
||||
} |
||||
} |
@ -0,0 +1,38 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.plugin.task.sqoop.parameter; |
||||
|
||||
/** |
||||
* source common parameter |
||||
*/ |
||||
public class SourceCommonParameter { |
||||
|
||||
/** |
||||
* src datasource |
||||
*/ |
||||
protected int srcDatasource; |
||||
|
||||
public int getSrcDatasource() { |
||||
return srcDatasource; |
||||
} |
||||
|
||||
public void setSrcDatasource(int srcDatasource) { |
||||
this.srcDatasource = srcDatasource; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,38 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.plugin.task.sqoop.parameter; |
||||
|
||||
/** |
||||
* target common parameter |
||||
*/ |
||||
public class TargetCommonParameter { |
||||
|
||||
/** |
||||
* target datasource |
||||
*/ |
||||
protected int targetDatasource; |
||||
|
||||
public int getTargetDatasource() { |
||||
return targetDatasource; |
||||
} |
||||
|
||||
public void setTargetDatasource(int targetDatasource) { |
||||
this.targetDatasource = targetDatasource; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,126 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.plugin.task.sqoop.parameter.sources; |
||||
|
||||
import org.apache.dolphinscheduler.plugin.task.api.model.Property; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.SourceCommonParameter; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* source hana parameter |
||||
*/ |
||||
public class SourceHanaParameter extends SourceCommonParameter { |
||||
|
||||
/** |
||||
* src table |
||||
*/ |
||||
private String srcTable; |
||||
/** |
||||
* src query type |
||||
*/ |
||||
private int srcQueryType; |
||||
/** |
||||
* src query sql |
||||
*/ |
||||
private String srcQuerySql; |
||||
/** |
||||
* src column type |
||||
*/ |
||||
private int srcColumnType; |
||||
/** |
||||
* src columns |
||||
*/ |
||||
private String srcColumns; |
||||
/** |
||||
* src condition list |
||||
*/ |
||||
private List<Property> srcConditionList; |
||||
/** |
||||
* map column hive |
||||
*/ |
||||
private List<Property> mapColumnHive; |
||||
/** |
||||
* map column java |
||||
*/ |
||||
private List<Property> mapColumnJava; |
||||
|
||||
public String getSrcTable() { |
||||
return srcTable; |
||||
} |
||||
|
||||
public void setSrcTable(String srcTable) { |
||||
this.srcTable = srcTable; |
||||
} |
||||
|
||||
public int getSrcQueryType() { |
||||
return srcQueryType; |
||||
} |
||||
|
||||
public void setSrcQueryType(int srcQueryType) { |
||||
this.srcQueryType = srcQueryType; |
||||
} |
||||
|
||||
public String getSrcQuerySql() { |
||||
return srcQuerySql; |
||||
} |
||||
|
||||
public void setSrcQuerySql(String srcQuerySql) { |
||||
this.srcQuerySql = srcQuerySql; |
||||
} |
||||
|
||||
public int getSrcColumnType() { |
||||
return srcColumnType; |
||||
} |
||||
|
||||
public void setSrcColumnType(int srcColumnType) { |
||||
this.srcColumnType = srcColumnType; |
||||
} |
||||
|
||||
public String getSrcColumns() { |
||||
return srcColumns; |
||||
} |
||||
|
||||
public void setSrcColumns(String srcColumns) { |
||||
this.srcColumns = srcColumns; |
||||
} |
||||
|
||||
public List<Property> getSrcConditionList() { |
||||
return srcConditionList; |
||||
} |
||||
|
||||
public void setSrcConditionList(List<Property> srcConditionList) { |
||||
this.srcConditionList = srcConditionList; |
||||
} |
||||
|
||||
public List<Property> getMapColumnHive() { |
||||
return mapColumnHive; |
||||
} |
||||
|
||||
public void setMapColumnHive(List<Property> mapColumnHive) { |
||||
this.mapColumnHive = mapColumnHive; |
||||
} |
||||
|
||||
public List<Property> getMapColumnJava() { |
||||
return mapColumnJava; |
||||
} |
||||
|
||||
public void setMapColumnJava(List<Property> mapColumnJava) { |
||||
this.mapColumnJava = mapColumnJava; |
||||
} |
||||
} |
@ -0,0 +1,126 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.plugin.task.sqoop.parameter.sources; |
||||
|
||||
import org.apache.dolphinscheduler.plugin.task.api.model.Property; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.SourceCommonParameter; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* source oracle parameter |
||||
*/ |
||||
public class SourceOracleParameter extends SourceCommonParameter { |
||||
|
||||
/** |
||||
* src table |
||||
*/ |
||||
private String srcTable; |
||||
/** |
||||
* src query type |
||||
*/ |
||||
private int srcQueryType; |
||||
/** |
||||
* src query sql |
||||
*/ |
||||
private String srcQuerySql; |
||||
/** |
||||
* src column type |
||||
*/ |
||||
private int srcColumnType; |
||||
/** |
||||
* src columns |
||||
*/ |
||||
private String srcColumns; |
||||
/** |
||||
* src condition list |
||||
*/ |
||||
private List<Property> srcConditionList; |
||||
/** |
||||
* map column hive |
||||
*/ |
||||
private List<Property> mapColumnHive; |
||||
/** |
||||
* map column java |
||||
*/ |
||||
private List<Property> mapColumnJava; |
||||
|
||||
public String getSrcTable() { |
||||
return srcTable; |
||||
} |
||||
|
||||
public void setSrcTable(String srcTable) { |
||||
this.srcTable = srcTable; |
||||
} |
||||
|
||||
public int getSrcQueryType() { |
||||
return srcQueryType; |
||||
} |
||||
|
||||
public void setSrcQueryType(int srcQueryType) { |
||||
this.srcQueryType = srcQueryType; |
||||
} |
||||
|
||||
public String getSrcQuerySql() { |
||||
return srcQuerySql; |
||||
} |
||||
|
||||
public void setSrcQuerySql(String srcQuerySql) { |
||||
this.srcQuerySql = srcQuerySql; |
||||
} |
||||
|
||||
public int getSrcColumnType() { |
||||
return srcColumnType; |
||||
} |
||||
|
||||
public void setSrcColumnType(int srcColumnType) { |
||||
this.srcColumnType = srcColumnType; |
||||
} |
||||
|
||||
public String getSrcColumns() { |
||||
return srcColumns; |
||||
} |
||||
|
||||
public void setSrcColumns(String srcColumns) { |
||||
this.srcColumns = srcColumns; |
||||
} |
||||
|
||||
public List<Property> getSrcConditionList() { |
||||
return srcConditionList; |
||||
} |
||||
|
||||
public void setSrcConditionList(List<Property> srcConditionList) { |
||||
this.srcConditionList = srcConditionList; |
||||
} |
||||
|
||||
public List<Property> getMapColumnHive() { |
||||
return mapColumnHive; |
||||
} |
||||
|
||||
public void setMapColumnHive(List<Property> mapColumnHive) { |
||||
this.mapColumnHive = mapColumnHive; |
||||
} |
||||
|
||||
public List<Property> getMapColumnJava() { |
||||
return mapColumnJava; |
||||
} |
||||
|
||||
public void setMapColumnJava(List<Property> mapColumnJava) { |
||||
this.mapColumnJava = mapColumnJava; |
||||
} |
||||
} |
@ -0,0 +1,126 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.plugin.task.sqoop.parameter.sources; |
||||
|
||||
import org.apache.dolphinscheduler.plugin.task.api.model.Property; |
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.SourceCommonParameter; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* source sqlServer parameter |
||||
*/ |
||||
public class SourceSqlServerParameter extends SourceCommonParameter { |
||||
|
||||
/** |
||||
* src table |
||||
*/ |
||||
private String srcTable; |
||||
/** |
||||
* src query type |
||||
*/ |
||||
private int srcQueryType; |
||||
/** |
||||
* src query sql |
||||
*/ |
||||
private String srcQuerySql; |
||||
/** |
||||
* src column type |
||||
*/ |
||||
private int srcColumnType; |
||||
/** |
||||
* src columns |
||||
*/ |
||||
private String srcColumns; |
||||
/** |
||||
* src condition list |
||||
*/ |
||||
private List<Property> srcConditionList; |
||||
/** |
||||
* map column hive |
||||
*/ |
||||
private List<Property> mapColumnHive; |
||||
/** |
||||
* map column java |
||||
*/ |
||||
private List<Property> mapColumnJava; |
||||
|
||||
public String getSrcTable() { |
||||
return srcTable; |
||||
} |
||||
|
||||
public void setSrcTable(String srcTable) { |
||||
this.srcTable = srcTable; |
||||
} |
||||
|
||||
public int getSrcQueryType() { |
||||
return srcQueryType; |
||||
} |
||||
|
||||
public void setSrcQueryType(int srcQueryType) { |
||||
this.srcQueryType = srcQueryType; |
||||
} |
||||
|
||||
public String getSrcQuerySql() { |
||||
return srcQuerySql; |
||||
} |
||||
|
||||
public void setSrcQuerySql(String srcQuerySql) { |
||||
this.srcQuerySql = srcQuerySql; |
||||
} |
||||
|
||||
public int getSrcColumnType() { |
||||
return srcColumnType; |
||||
} |
||||
|
||||
public void setSrcColumnType(int srcColumnType) { |
||||
this.srcColumnType = srcColumnType; |
||||
} |
||||
|
||||
public String getSrcColumns() { |
||||
return srcColumns; |
||||
} |
||||
|
||||
public void setSrcColumns(String srcColumns) { |
||||
this.srcColumns = srcColumns; |
||||
} |
||||
|
||||
public List<Property> getSrcConditionList() { |
||||
return srcConditionList; |
||||
} |
||||
|
||||
public void setSrcConditionList(List<Property> srcConditionList) { |
||||
this.srcConditionList = srcConditionList; |
||||
} |
||||
|
||||
public List<Property> getMapColumnHive() { |
||||
return mapColumnHive; |
||||
} |
||||
|
||||
public void setMapColumnHive(List<Property> mapColumnHive) { |
||||
this.mapColumnHive = mapColumnHive; |
||||
} |
||||
|
||||
public List<Property> getMapColumnJava() { |
||||
return mapColumnJava; |
||||
} |
||||
|
||||
public void setMapColumnJava(List<Property> mapColumnJava) { |
||||
this.mapColumnJava = mapColumnJava; |
||||
} |
||||
} |
@ -0,0 +1,123 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.plugin.task.sqoop.parameter.targets; |
||||
|
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.TargetCommonParameter; |
||||
|
||||
/** |
||||
* target hana parameter |
||||
*/ |
||||
public class TargetHanaParameter extends TargetCommonParameter { |
||||
|
||||
/** |
||||
* target table |
||||
*/ |
||||
private String targetTable; |
||||
/** |
||||
* target columns |
||||
*/ |
||||
private String targetColumns; |
||||
/** |
||||
* fields terminated |
||||
*/ |
||||
private String fieldsTerminated; |
||||
/** |
||||
* lines terminated |
||||
*/ |
||||
private String linesTerminated; |
||||
/** |
||||
* pre query |
||||
*/ |
||||
private String preQuery; |
||||
/** |
||||
* is update |
||||
*/ |
||||
private boolean isUpdate; |
||||
/** |
||||
* target update key |
||||
*/ |
||||
private String targetUpdateKey; |
||||
/** |
||||
* target update mode |
||||
*/ |
||||
private String targetUpdateMode; |
||||
|
||||
public String getTargetTable() { |
||||
return targetTable; |
||||
} |
||||
|
||||
public void setTargetTable(String targetTable) { |
||||
this.targetTable = targetTable; |
||||
} |
||||
|
||||
public String getTargetColumns() { |
||||
return targetColumns; |
||||
} |
||||
|
||||
public void setTargetColumns(String targetColumns) { |
||||
this.targetColumns = targetColumns; |
||||
} |
||||
|
||||
public String getFieldsTerminated() { |
||||
return fieldsTerminated; |
||||
} |
||||
|
||||
public void setFieldsTerminated(String fieldsTerminated) { |
||||
this.fieldsTerminated = fieldsTerminated; |
||||
} |
||||
|
||||
public String getLinesTerminated() { |
||||
return linesTerminated; |
||||
} |
||||
|
||||
public void setLinesTerminated(String linesTerminated) { |
||||
this.linesTerminated = linesTerminated; |
||||
} |
||||
|
||||
public String getPreQuery() { |
||||
return preQuery; |
||||
} |
||||
|
||||
public void setPreQuery(String preQuery) { |
||||
this.preQuery = preQuery; |
||||
} |
||||
|
||||
public boolean getIsUpdate() { |
||||
return isUpdate; |
||||
} |
||||
|
||||
public void setUpdate(boolean update) { |
||||
isUpdate = update; |
||||
} |
||||
|
||||
public String getTargetUpdateKey() { |
||||
return targetUpdateKey; |
||||
} |
||||
|
||||
public void setTargetUpdateKey(String targetUpdateKey) { |
||||
this.targetUpdateKey = targetUpdateKey; |
||||
} |
||||
|
||||
public String getTargetUpdateMode() { |
||||
return targetUpdateMode; |
||||
} |
||||
|
||||
public void setTargetUpdateMode(String targetUpdateMode) { |
||||
this.targetUpdateMode = targetUpdateMode; |
||||
} |
||||
} |
@ -0,0 +1,123 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.plugin.task.sqoop.parameter.targets; |
||||
|
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.TargetCommonParameter; |
||||
|
||||
/** |
||||
* target oracle parameter |
||||
*/ |
||||
public class TargetOracleParameter extends TargetCommonParameter { |
||||
|
||||
/** |
||||
* target table |
||||
*/ |
||||
private String targetTable; |
||||
/** |
||||
* target columns |
||||
*/ |
||||
private String targetColumns; |
||||
/** |
||||
* fields terminated |
||||
*/ |
||||
private String fieldsTerminated; |
||||
/** |
||||
* lines terminated |
||||
*/ |
||||
private String linesTerminated; |
||||
/** |
||||
* pre query |
||||
*/ |
||||
private String preQuery; |
||||
/** |
||||
* is update |
||||
*/ |
||||
private boolean isUpdate; |
||||
/** |
||||
* target update key |
||||
*/ |
||||
private String targetUpdateKey; |
||||
/** |
||||
* target update mode |
||||
*/ |
||||
private String targetUpdateMode; |
||||
|
||||
public String getTargetTable() { |
||||
return targetTable; |
||||
} |
||||
|
||||
public void setTargetTable(String targetTable) { |
||||
this.targetTable = targetTable; |
||||
} |
||||
|
||||
public String getTargetColumns() { |
||||
return targetColumns; |
||||
} |
||||
|
||||
public void setTargetColumns(String targetColumns) { |
||||
this.targetColumns = targetColumns; |
||||
} |
||||
|
||||
public String getFieldsTerminated() { |
||||
return fieldsTerminated; |
||||
} |
||||
|
||||
public void setFieldsTerminated(String fieldsTerminated) { |
||||
this.fieldsTerminated = fieldsTerminated; |
||||
} |
||||
|
||||
public String getLinesTerminated() { |
||||
return linesTerminated; |
||||
} |
||||
|
||||
public void setLinesTerminated(String linesTerminated) { |
||||
this.linesTerminated = linesTerminated; |
||||
} |
||||
|
||||
public String getPreQuery() { |
||||
return preQuery; |
||||
} |
||||
|
||||
public void setPreQuery(String preQuery) { |
||||
this.preQuery = preQuery; |
||||
} |
||||
|
||||
public boolean getIsUpdate() { |
||||
return isUpdate; |
||||
} |
||||
|
||||
public void setUpdate(boolean update) { |
||||
isUpdate = update; |
||||
} |
||||
|
||||
public String getTargetUpdateKey() { |
||||
return targetUpdateKey; |
||||
} |
||||
|
||||
public void setTargetUpdateKey(String targetUpdateKey) { |
||||
this.targetUpdateKey = targetUpdateKey; |
||||
} |
||||
|
||||
public String getTargetUpdateMode() { |
||||
return targetUpdateMode; |
||||
} |
||||
|
||||
public void setTargetUpdateMode(String targetUpdateMode) { |
||||
this.targetUpdateMode = targetUpdateMode; |
||||
} |
||||
} |
@ -0,0 +1,123 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.plugin.task.sqoop.parameter.targets; |
||||
|
||||
import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.TargetCommonParameter; |
||||
|
||||
/** |
||||
* target sqlServer parameter |
||||
*/ |
||||
public class TargetSqlServerParameter extends TargetCommonParameter { |
||||
|
||||
/** |
||||
* target table |
||||
*/ |
||||
private String targetTable; |
||||
/** |
||||
* target columns |
||||
*/ |
||||
private String targetColumns; |
||||
/** |
||||
* fields terminated |
||||
*/ |
||||
private String fieldsTerminated; |
||||
/** |
||||
* lines terminated |
||||
*/ |
||||
private String linesTerminated; |
||||
/** |
||||
* pre query |
||||
*/ |
||||
private String preQuery; |
||||
/** |
||||
* is update |
||||
*/ |
||||
private boolean isUpdate; |
||||
/** |
||||
* target update key |
||||
*/ |
||||
private String targetUpdateKey; |
||||
/** |
||||
* target update mode |
||||
*/ |
||||
private String targetUpdateMode; |
||||
|
||||
public String getTargetTable() { |
||||
return targetTable; |
||||
} |
||||
|
||||
public void setTargetTable(String targetTable) { |
||||
this.targetTable = targetTable; |
||||
} |
||||
|
||||
public String getTargetColumns() { |
||||
return targetColumns; |
||||
} |
||||
|
||||
public void setTargetColumns(String targetColumns) { |
||||
this.targetColumns = targetColumns; |
||||
} |
||||
|
||||
public String getFieldsTerminated() { |
||||
return fieldsTerminated; |
||||
} |
||||
|
||||
public void setFieldsTerminated(String fieldsTerminated) { |
||||
this.fieldsTerminated = fieldsTerminated; |
||||
} |
||||
|
||||
public String getLinesTerminated() { |
||||
return linesTerminated; |
||||
} |
||||
|
||||
public void setLinesTerminated(String linesTerminated) { |
||||
this.linesTerminated = linesTerminated; |
||||
} |
||||
|
||||
public String getPreQuery() { |
||||
return preQuery; |
||||
} |
||||
|
||||
public void setPreQuery(String preQuery) { |
||||
this.preQuery = preQuery; |
||||
} |
||||
|
||||
public boolean getIsUpdate() { |
||||
return isUpdate; |
||||
} |
||||
|
||||
public void setUpdate(boolean update) { |
||||
isUpdate = update; |
||||
} |
||||
|
||||
public String getTargetUpdateKey() { |
||||
return targetUpdateKey; |
||||
} |
||||
|
||||
public void setTargetUpdateKey(String targetUpdateKey) { |
||||
this.targetUpdateKey = targetUpdateKey; |
||||
} |
||||
|
||||
public String getTargetUpdateMode() { |
||||
return targetUpdateMode; |
||||
} |
||||
|
||||
public void setTargetUpdateMode(String targetUpdateMode) { |
||||
this.targetUpdateMode = targetUpdateMode; |
||||
} |
||||
} |
Loading…
Reference in new issue