Compare commits
116 Commits
patch/7.3.
...
patch/TPS-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6758a3424b | ||
|
|
11a41a331e | ||
|
|
e9fa81a1c8 | ||
|
|
9153d30f6e | ||
|
|
dd863cfd15 | ||
|
|
55d48cfe91 | ||
|
|
7b325e8707 | ||
|
|
7465b41a34 | ||
|
|
79fb201844 | ||
|
|
45edbf18a1 | ||
|
|
f347a16522 | ||
|
|
b9e4faf2bd | ||
|
|
1ab7eaeca6 | ||
|
|
069a7b26c3 | ||
|
|
6a3651d3b6 | ||
|
|
029c0ccb5c | ||
|
|
1382b4efb4 | ||
|
|
b0d3a70cf3 | ||
|
|
1f20471fbe | ||
|
|
d28ffc5736 | ||
|
|
146cf1dc0e | ||
|
|
6c03ca588a | ||
|
|
b528ca9a0d | ||
|
|
888765461c | ||
|
|
ae2f00f1a8 | ||
|
|
704b63d59c | ||
|
|
a92fedb9b4 | ||
|
|
f1a7d2f235 | ||
|
|
1702b27493 | ||
|
|
cf55315820 | ||
|
|
d25b125c08 | ||
|
|
290d9566ed | ||
|
|
0c85bdc4be | ||
|
|
a4cb0d13d2 | ||
|
|
502742bad2 | ||
|
|
83a64d3d2c | ||
|
|
30bbb27e87 | ||
|
|
b554d94736 | ||
|
|
13bbfcca1d | ||
|
|
6bebbba8ee | ||
|
|
37dc7ca816 | ||
|
|
242fa6c729 | ||
|
|
d1d4dcd7f6 | ||
|
|
885d14671a | ||
|
|
8fa189bd31 | ||
|
|
fe86a1ef43 | ||
|
|
8751efe56e | ||
|
|
236fb7fc65 | ||
|
|
c55409088f | ||
|
|
7ead0130ac | ||
|
|
562d3700b1 | ||
|
|
3d5fb83763 | ||
|
|
41f1df71d7 | ||
|
|
0f7596dcb8 | ||
|
|
520e379e48 | ||
|
|
28ae35dec6 | ||
|
|
21245a297a | ||
|
|
5131d00675 | ||
|
|
f256fc6f38 | ||
|
|
30fa41dd46 | ||
|
|
8a3a1a0289 | ||
|
|
b3468eba73 | ||
|
|
9d9d6b135b | ||
|
|
7cbcd2967b | ||
|
|
918ca363fa | ||
|
|
a473b624b7 | ||
|
|
1f6128dfd7 | ||
|
|
6fa4c42df1 | ||
|
|
1e61474fc0 | ||
|
|
d6242e11cd | ||
|
|
d007d3740a | ||
|
|
765accb8a3 | ||
|
|
b51c1282f7 | ||
|
|
c98e18a58c | ||
|
|
e576293e58 | ||
|
|
55812da6b6 | ||
|
|
074c13dd4e | ||
|
|
6088e2c2ca | ||
|
|
1637e6220c | ||
|
|
e96d2af073 | ||
|
|
a1e453e79a | ||
|
|
c8c4a586d0 | ||
|
|
89435124fe | ||
|
|
ae8e41f36b | ||
|
|
e6fd8b0614 | ||
|
|
f4223f7a2b | ||
|
|
64dcafb080 | ||
|
|
402fe1ffbc | ||
|
|
02c66a7e93 | ||
|
|
207d1c9635 | ||
|
|
a4d0adb671 | ||
|
|
0ce6a06f8e | ||
|
|
15cbbf362c | ||
|
|
c139b0893d | ||
|
|
4c2e419bc0 | ||
|
|
adc91e4169 | ||
|
|
09607ed581 | ||
|
|
0a5b925dc4 | ||
|
|
414ab39434 | ||
|
|
a269f74a30 | ||
|
|
530814c490 | ||
|
|
1da69fb285 | ||
|
|
3c00488dc8 | ||
|
|
17f54191cf | ||
|
|
ed99155812 | ||
|
|
2276f4b51a | ||
|
|
da5744d1e5 | ||
|
|
3c04002b5e | ||
|
|
8b67961ade | ||
|
|
ec914f50fe | ||
|
|
9ab7f01201 | ||
|
|
af79e71c25 | ||
|
|
c50e437c59 | ||
|
|
ca07dd16cf | ||
|
|
64794a596c | ||
|
|
ff595fd205 |
57
PATCH_RELEASE_NOTE.md
Normal file
57
PATCH_RELEASE_NOTE.md
Normal file
@@ -0,0 +1,57 @@
|
||||
---
|
||||
version: 7.3.1
|
||||
module: https://talend.poolparty.biz/coretaxonomy/42
|
||||
product:
|
||||
- https://talend.poolparty.biz/coretaxonomy/23
|
||||
---
|
||||
|
||||
# TPS-4723
|
||||
|
||||
| Info | Value |
|
||||
| ---------------- | ---------------- |
|
||||
| Patch Name | Patch\_20210304\_TPS-4723\_v1-7.3.1 |
|
||||
| Release Date | 2021-03-04 |
|
||||
| Target Version | 20200219_1130-V7.3.1 |
|
||||
| Product affected | Talend Studio |
|
||||
|
||||
## Introduction
|
||||
|
||||
This is a self-contained patch.
|
||||
|
||||
**NOTE**: For information on how to obtain this patch, reach out to your Support contact at Talend.
|
||||
|
||||
## Fixed issues
|
||||
|
||||
This patch contains the following fixes:
|
||||
|
||||
- TPS-4723 [7.3.1] Getting Permission denied error in tFileInputExcel in Talend (TDI-45561)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Consider the following requirements for your system:
|
||||
|
||||
- Talend Studio 7.3.1 and Patch_20200529_R2020-05_v1-7.3.1 must be installed.
|
||||
|
||||
## Installation
|
||||
|
||||
### Installing the patch using Software update
|
||||
|
||||
1) Logon TAC and switch to Configuration->Software Update, then enter the correct values and save referring to the documentation: https://help.talend.com/reader/f7Em9WV_cPm2RRywucSN0Q/j9x5iXV~vyxMlUafnDejaQ
|
||||
|
||||
2) Switch to Software update page, where the new patch will be listed. The patch can be downloaded from here into the nexus repository.
|
||||
|
||||
3) On Studio Side: Logon Studio with remote mode, on the logon page the Update button is displayed: click this button to install the patch.
|
||||
|
||||
### Installing the patch using Talend Studio
|
||||
|
||||
1) Create a folder named "patches" under your studio installer directory and copy the patch .zip file to this folder.
|
||||
|
||||
2) Restart your studio: a window pops up, then click OK to install the patch, or restart the commandline and the patch will be installed automatically.
|
||||
|
||||
### Installing the patch using Commandline
|
||||
|
||||
Execute the following commands:
|
||||
|
||||
1. Talend-Studio-win-x86_64.exe -nosplash -application org.talend.commandline.CommandLine -consoleLog -data commandline-workspace startServer -p 8002 --talendDebug
|
||||
2. initRemote {tac_url} -ul {TAC login username} -up {TAC login password}
|
||||
3. checkAndUpdate -tu {TAC login username} -tup {TAC login password}
|
||||
@@ -16,11 +16,9 @@
|
||||
</requires>
|
||||
<plugin id="org.talend.libraries.apache" download-size="0" install-size="0" version="0.0.0"/>
|
||||
<plugin id="org.talend.libraries.apache.axis2" download-size="0" install-size="0" version="0.0.0"/>
|
||||
<plugin id="org.talend.libraries.apache.batik" download-size="0" install-size="0" version="0.0.0"/>
|
||||
<plugin id="org.talend.libraries.apache.chemistry" download-size="0" install-size="0" version="0.0.0"/>
|
||||
<plugin id="org.talend.libraries.apache.common" download-size="0" install-size="0" version="0.0.0"/>
|
||||
<plugin id="org.talend.libraries.apache.cxf" download-size="0" install-size="0" version="0.0.0"/>
|
||||
<plugin id="org.talend.libraries.apache.google" download-size="0" install-size="0" version="0.0.0"/>
|
||||
<plugin id="org.talend.libraries.apache.http" download-size="0" install-size="0" version="0.0.0"/>
|
||||
<plugin id="org.talend.libraries.apache.lucene" download-size="0" install-size="0" version="0.0.0"/>
|
||||
<plugin id="org.talend.libraries.apache.xml" download-size="0" install-size="0" version="0.0.0"/>
|
||||
|
||||
@@ -91,10 +91,10 @@ if((codePart.equals(ECodePart.END))&&(stat || logstashCurrent)){
|
||||
String sourceNodeId = source.getUniqueName();
|
||||
|
||||
String sourceLabel = ElementParameterParser.getValue(source, "__LABEL__");
|
||||
String sourceNodeLabel = ((sourceLabel==null || "__UNIQUE_NAME__".equals(sourceLabel) || sourceLabel.contains("\"")) ? sourceNodeId : sourceLabel);
|
||||
String sourceNodeLabel = ((sourceLabel==null || "__UNIQUE_NAME__".equals(sourceLabel) || sourceLabel.contains("\"")) ? sourceNodeId : sourceLabel.trim());
|
||||
|
||||
String targetLabel = ElementParameterParser.getValue(node, "__LABEL__");
|
||||
String targetNodeLabel = ((targetLabel==null || "__UNIQUE_NAME__".equals(targetLabel) || targetLabel.contains("\"")) ? node.getUniqueName() : targetLabel);
|
||||
String targetNodeLabel = ((targetLabel==null || "__UNIQUE_NAME__".equals(targetLabel) || targetLabel.contains("\"")) ? node.getUniqueName() : targetLabel.trim());
|
||||
|
||||
String sourceNodeComponent = source.getComponent().getName();
|
||||
for (INode jobStructureCatcher : jobCatcherNodes) {
|
||||
@@ -125,10 +125,10 @@ if((codePart.equals(ECodePart.END))&&(stat || logstashCurrent)){
|
||||
String sourceNodeId = source.getUniqueName();
|
||||
|
||||
String sourceLabel = ElementParameterParser.getValue(source, "__LABEL__");
|
||||
String sourceNodeLabel = ((sourceLabel==null || "__UNIQUE_NAME__".equals(sourceLabel) || sourceLabel.contains("\"")) ? sourceNodeId : sourceLabel);
|
||||
String sourceNodeLabel = ((sourceLabel==null || "__UNIQUE_NAME__".equals(sourceLabel) || sourceLabel.contains("\"")) ? sourceNodeId : sourceLabel.trim());
|
||||
|
||||
String targetLabel = ElementParameterParser.getValue(node, "__LABEL__");
|
||||
String targetNodeLabel = ((targetLabel==null || "__UNIQUE_NAME__".equals(targetLabel) || targetLabel.contains("\"")) ? node.getUniqueName() : targetLabel);
|
||||
String targetNodeLabel = ((targetLabel==null || "__UNIQUE_NAME__".equals(targetLabel) || targetLabel.contains("\"")) ? node.getUniqueName() : targetLabel.trim());
|
||||
|
||||
String sourceNodeComponent = source.getComponent().getName();
|
||||
for (INode jobStructureCatcher : jobCatcherNodes) {
|
||||
|
||||
@@ -197,10 +197,10 @@
|
||||
String sourceNodeId = source.getUniqueName();
|
||||
|
||||
String sourceLabel = ElementParameterParser.getValue(source, "__LABEL__");
|
||||
String sourceNodeLabel = ((sourceLabel==null || "__UNIQUE_NAME__".equals(sourceLabel) || sourceLabel.contains("\"")) ? sourceNodeId : sourceLabel);
|
||||
String sourceNodeLabel = ((sourceLabel==null || "__UNIQUE_NAME__".equals(sourceLabel) || sourceLabel.contains("\"")) ? sourceNodeId : sourceLabel.trim());
|
||||
|
||||
String targetLabel = ElementParameterParser.getValue(node, "__LABEL__");
|
||||
String targetNodeLabel = ((targetLabel==null || "__UNIQUE_NAME__".equals(targetLabel) || targetLabel.contains("\"")) ? node.getUniqueName() : targetLabel);
|
||||
String targetNodeLabel = ((targetLabel==null || "__UNIQUE_NAME__".equals(targetLabel) || targetLabel.contains("\"")) ? node.getUniqueName() : targetLabel.trim());
|
||||
|
||||
String sourceNodeComponent = source.getComponent().getName();
|
||||
%>
|
||||
@@ -233,10 +233,10 @@
|
||||
String sourceNodeId = source.getUniqueName();
|
||||
|
||||
String sourceLabel = ElementParameterParser.getValue(source, "__LABEL__");
|
||||
String sourceNodeLabel = ((sourceLabel==null || "__UNIQUE_NAME__".equals(sourceLabel) || sourceLabel.contains("\"")) ? sourceNodeId : sourceLabel);
|
||||
String sourceNodeLabel = ((sourceLabel==null || "__UNIQUE_NAME__".equals(sourceLabel) || sourceLabel.contains("\"")) ? sourceNodeId : sourceLabel.trim());
|
||||
|
||||
String targetLabel = ElementParameterParser.getValue(node, "__LABEL__");
|
||||
String targetNodeLabel = ((targetLabel==null || "__UNIQUE_NAME__".equals(targetLabel) || targetLabel.contains("\"")) ? node.getUniqueName() : targetLabel);
|
||||
String targetNodeLabel = ((targetLabel==null || "__UNIQUE_NAME__".equals(targetLabel) || targetLabel.contains("\"")) ? node.getUniqueName() : targetLabel.trim());
|
||||
|
||||
String sourceNodeComponent = source.getComponent().getName();
|
||||
%>
|
||||
@@ -260,10 +260,10 @@
|
||||
String sourceNodeId = source.getUniqueName();
|
||||
|
||||
String sourceLabel = ElementParameterParser.getValue(source, "__LABEL__");
|
||||
String sourceNodeLabel = ((sourceLabel==null || "__UNIQUE_NAME__".equals(sourceLabel) || sourceLabel.contains("\"")) ? sourceNodeId : sourceLabel);
|
||||
String sourceNodeLabel = ((sourceLabel==null || "__UNIQUE_NAME__".equals(sourceLabel) || sourceLabel.contains("\"")) ? sourceNodeId : sourceLabel.trim());
|
||||
|
||||
String targetLabel = ElementParameterParser.getValue(node, "__LABEL__");
|
||||
String targetNodeLabel = ((targetLabel==null || "__UNIQUE_NAME__".equals(targetLabel) || targetLabel.contains("\"")) ? node.getUniqueName() : targetLabel);
|
||||
String targetNodeLabel = ((targetLabel==null || "__UNIQUE_NAME__".equals(targetLabel) || targetLabel.contains("\"")) ? node.getUniqueName() : targetLabel.trim());
|
||||
|
||||
String sourceNodeComponent = source.getComponent().getName();
|
||||
|
||||
@@ -296,10 +296,10 @@
|
||||
String sourceNodeId = source.getUniqueName();
|
||||
|
||||
String sourceLabel = ElementParameterParser.getValue(source, "__LABEL__");
|
||||
String sourceNodeLabel = ((sourceLabel==null || "__UNIQUE_NAME__".equals(sourceLabel) || sourceLabel.contains("\"")) ? sourceNodeId : sourceLabel);
|
||||
String sourceNodeLabel = ((sourceLabel==null || "__UNIQUE_NAME__".equals(sourceLabel) || sourceLabel.contains("\"")) ? sourceNodeId : sourceLabel.trim());
|
||||
|
||||
String targetLabel = ElementParameterParser.getValue(node, "__LABEL__");
|
||||
String targetNodeLabel = ((targetLabel==null || "__UNIQUE_NAME__".equals(targetLabel) || targetLabel.contains("\"")) ? node.getUniqueName() : targetLabel);
|
||||
String targetNodeLabel = ((targetLabel==null || "__UNIQUE_NAME__".equals(targetLabel) || targetLabel.contains("\"")) ? node.getUniqueName() : targetLabel.trim());
|
||||
|
||||
String sourceNodeComponent = source.getComponent().getName();
|
||||
|
||||
@@ -435,7 +435,7 @@
|
||||
if(logstashCurrent) {
|
||||
for (INode jobStructureCatcher : jobCatcherNodes) {
|
||||
String label = ElementParameterParser.getValue(node, "__LABEL__");
|
||||
String nodeLabel = ((label==null || "__UNIQUE_NAME__".equals(label) || label.contains("\"")) ? node.getUniqueName() : label);
|
||||
String nodeLabel = ((label==null || "__UNIQUE_NAME__".equals(label) || label.contains("\"")) ? node.getUniqueName() : label.trim());
|
||||
%>
|
||||
if(enableLogStash) {
|
||||
<%=jobStructureCatcher.getUniqueName() %>.addCM("<%=node.getUniqueName()%>", "<%=nodeLabel%>", "<%=node.getComponent().getName()%>");
|
||||
|
||||
@@ -642,6 +642,16 @@
|
||||
}
|
||||
%>
|
||||
|
||||
boolean inOSGi = routines.system.BundleUtils.inOSGi();
|
||||
|
||||
if (inOSGi) {
|
||||
java.util.Dictionary<String, Object> jobProperties = routines.system.BundleUtils.getJobProperties(jobName);
|
||||
|
||||
if (jobProperties != null) {
|
||||
contextStr = (String)jobProperties.get("context");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
//call job/subjob with an existing context, like: --context=production. if without this parameter, there will use the default context instead.
|
||||
java.io.InputStream inContext = <%=className%>.class.getClassLoader().getResourceAsStream("<%=jobClassPackageFolder%>/contexts/" + contextStr + ".properties");
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
INode startNode = subTree.getRootNode();
|
||||
String startNodeId = startNode.getUniqueName();
|
||||
|
||||
if(startNodeId!=null && startNodeId.startsWith("tCollector")) {
|
||||
if ("tCollector".equals( startNode.getComponent().getOriginalName() )) {
|
||||
List<? extends INode> departitioners = startNode.getProcess().getNodesOfType("tDepartitioner");
|
||||
if(departitioners!=null) {
|
||||
for(INode departitioner : departitioners) {
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.core.download.DownloadHelper;
|
||||
import org.talend.core.runtime.util.SharedStudioUtils;
|
||||
import org.talend.designer.components.exchange.i18n.Messages;
|
||||
import org.talend.designer.components.exchange.model.Category;
|
||||
import org.talend.designer.components.exchange.model.VersionRevision;
|
||||
@@ -105,7 +106,7 @@ public class ImportExchangeDialog extends Dialog {
|
||||
|
||||
@Override
|
||||
protected void okPressed() {
|
||||
IPath tempPath = new Path(System.getProperty("user.dir")).append("temp"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
IPath tempPath = SharedStudioUtils.getTempFolderPath();
|
||||
File pathFile = tempPath.toFile();
|
||||
if (downloadproperty.getFileName() == null || downloadproperty.getFileName() == null) {
|
||||
MessageBox box = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ICON_WARNING | SWT.OK);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.talend</groupId>
|
||||
<artifactId>talend-httputil</artifactId>
|
||||
<name>talend-httputil</name>
|
||||
<version>1.0.5</version>
|
||||
<version>1.0.6</version>
|
||||
|
||||
<properties>
|
||||
<talend.nexus.url>https://artifacts-oss.talend.com</talend.nexus.url>
|
||||
@@ -20,7 +20,7 @@
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.10.1</version>
|
||||
<version>2.11.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>org.talend.components</groupId>
|
||||
<artifactId>talendExcel</artifactId>
|
||||
<version>1.7-20201028</version>
|
||||
<version>1.9-20201223</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>talendExcel</name>
|
||||
|
||||
@@ -80,6 +80,8 @@ public class ExcelTool {
|
||||
private boolean isTrackAllColumns = false;
|
||||
|
||||
private String password = null;
|
||||
|
||||
private Map<CellStyle, CellStyle> existedOriginToClone;
|
||||
|
||||
public ExcelTool() {
|
||||
cellStylesMapping = new HashMap<>();
|
||||
@@ -264,6 +266,9 @@ public class ExcelTool {
|
||||
|
||||
private CellStyle getPreCellStyle() {
|
||||
if (preSheet != null && isAbsY && keepCellFormat) {
|
||||
if(existedOriginToClone==null) {
|
||||
existedOriginToClone = new HashMap<>();
|
||||
}
|
||||
CellStyle preCellStyle;
|
||||
if (preCell == null) {
|
||||
preCellStyle = preSheet.getColumnStyle(curCell.getColumnIndex());
|
||||
@@ -271,8 +276,12 @@ public class ExcelTool {
|
||||
preCellStyle = preCell.getCellStyle();
|
||||
}
|
||||
|
||||
CellStyle targetCellStyle = wb.createCellStyle();
|
||||
targetCellStyle.cloneStyleFrom(preCellStyle);
|
||||
CellStyle targetCellStyle = existedOriginToClone.get(preCellStyle);
|
||||
if(targetCellStyle==null) {
|
||||
targetCellStyle = wb.createCellStyle();
|
||||
targetCellStyle.cloneStyleFrom(preCellStyle);
|
||||
existedOriginToClone.put(preCellStyle, targetCellStyle);
|
||||
}
|
||||
|
||||
return targetCellStyle;
|
||||
|
||||
@@ -331,7 +340,13 @@ public class ExcelTool {
|
||||
try {
|
||||
wb.write(outputStream);
|
||||
wb.close();
|
||||
if(preWb != null){
|
||||
preWb.close();
|
||||
}
|
||||
} finally {
|
||||
if(existedOriginToClone!=null) {
|
||||
existedOriginToClone = null;
|
||||
}
|
||||
if (outputStream != null) {
|
||||
outputStream.close();
|
||||
}
|
||||
@@ -362,7 +377,13 @@ public class ExcelTool {
|
||||
fs.writeFilesystem(fileOutput);
|
||||
}
|
||||
} finally {
|
||||
if(existedOriginToClone!=null) {
|
||||
existedOriginToClone = null;
|
||||
}
|
||||
wb.close();
|
||||
if(preWb != null){
|
||||
preWb.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,21 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.talend.libraries</groupId>
|
||||
<groupId>org.talend.components</groupId>
|
||||
<artifactId>talendzip</artifactId>
|
||||
<version>1.0-20190917</version>
|
||||
<version>1.1-20201120</version>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.talend.compress.zip;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.lingala.zip4j.core.ZipFile;
|
||||
import net.lingala.zip4j.model.FileHeader;
|
||||
@@ -44,6 +45,8 @@ public class Unzip {
|
||||
this.useZip4jDecryption = useZip4jDecryption;
|
||||
}
|
||||
|
||||
public void setEncording(String encording){this.encording = encording;}
|
||||
|
||||
private boolean needPassword = false;
|
||||
private boolean useZip4jDecryption = false;
|
||||
|
||||
@@ -55,6 +58,8 @@ public class Unzip {
|
||||
|
||||
private String sourceZip;
|
||||
private String targetDir;
|
||||
private String encording;
|
||||
|
||||
|
||||
public Unzip(String sourceZip, String targetDir) {
|
||||
this.sourceZip = sourceZip;
|
||||
@@ -92,6 +97,9 @@ public class Unzip {
|
||||
}
|
||||
|
||||
ZipFile zipFile = new ZipFile(sourceZip);
|
||||
if(encording != null){
|
||||
zipFile.setFileNameCharset(encording);
|
||||
}
|
||||
|
||||
if (checkArchive) {
|
||||
if (!zipFile.isValidZipFile()) {
|
||||
@@ -152,9 +160,8 @@ public class Unzip {
|
||||
is = new javax.crypto.CipherInputStream(is,
|
||||
org.talend.archive.IntegrityUtil.createCipher(
|
||||
javax.crypto.Cipher.DECRYPT_MODE, password));
|
||||
|
||||
org.apache.commons.compress.archivers.zip.ZipArchiveInputStream input = new org.apache.commons.compress.archivers.zip.ZipArchiveInputStream(
|
||||
new java.io.BufferedInputStream(is));
|
||||
new java.io.BufferedInputStream(is),Optional.ofNullable(encording).orElse("UTF8"));
|
||||
org.apache.commons.compress.archivers.zip.ZipArchiveEntry entry;
|
||||
|
||||
while ((entry = input.getNextZipEntry()) != null) {
|
||||
@@ -190,7 +197,7 @@ public class Unzip {
|
||||
org.apache.commons.compress.archivers.zip.ZipFile zip = null;
|
||||
try {
|
||||
zip = new org.apache.commons.compress.archivers.zip.ZipFile(
|
||||
sourceZip);
|
||||
sourceZip,Optional.ofNullable(encording).orElse("UTF8"));
|
||||
java.util.Enumeration enuFiles = zip.getEntries();
|
||||
java.io.InputStream is = null;
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
<IMPORT NAME="Driver-JACKCESS" MODULE="jackcess-2.1.12.jar" MVN="mvn:com.healthmarketscience.jackcess/jackcess/2.1.12" REQUIRED="true"/>
|
||||
|
||||
<IMPORT NAME="jackcess-encrypt-2.1.4" MODULE="jackcess-encrypt-2.1.4.jar" MVN="mvn:com.healthmarketscience.jackcess/jackcess-encrypt/2.1.4" REQUIRED="true"/>
|
||||
<IMPORT NAME="bcprov-jdk15on-1.60" MODULE="bcprov-jdk15on-1.60.jar" MVN="mvn:org.bouncycastle/bcprov-jdk15on/1.60" REQUIRED="true"/>
|
||||
<IMPORT NAME="bcprov-jdk15on-1.68" MODULE="bcprov-jdk15on-1.68.jar" MVN="mvn:org.bouncycastle/bcprov-jdk15on/1.68" REQUIRED="true"/>
|
||||
<IMPORT NAME="talend-ucanaccess-utils-1.0.0" MODULE="talend-ucanaccess-utils-1.0.0.jar" MVN="mvn:org.talend.libraries/talend-ucanaccess-utils-1.0.0/6.4.0" UrlPath="platform:/plugin/org.talend.libraries.jdbc.access/lib/talend-ucanaccess-utils-1.0.0.jar" REQUIRED="true"/>
|
||||
|
||||
<IMPORT NAME="common2.6" MODULE="commons-lang-2.6.jar" MVN="mvn:commons-lang/commons-lang/2.6" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-lang-2.6.jar" REQUIRED="true"/>
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
<IMPORT NAME="Driver-JACKCESS" MODULE="jackcess-2.1.12.jar" MVN="mvn:com.healthmarketscience.jackcess/jackcess/2.1.12" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')"/>
|
||||
|
||||
<IMPORT NAME="jackcess-encrypt-2.1.4" MODULE="jackcess-encrypt-2.1.4.jar" MVN="mvn:com.healthmarketscience.jackcess/jackcess-encrypt/2.1.4" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')"/>
|
||||
<IMPORT NAME="bcprov-jdk15on-1.60" MODULE="bcprov-jdk15on-1.60.jar" MVN="mvn:org.bouncycastle/bcprov-jdk15on/1.60" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')"/>
|
||||
<IMPORT NAME="bcprov-jdk15on-1.68" MODULE="bcprov-jdk15on-1.68.jar" MVN="mvn:org.bouncycastle/bcprov-jdk15on/1.68" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')"/>
|
||||
<IMPORT NAME="talend-ucanaccess-utils-1.0.0" MODULE="talend-ucanaccess-utils-1.0.0.jar" MVN="mvn:org.talend.libraries/talend-ucanaccess-utils-1.0.0/6.4.0" UrlPath="platform:/plugin/org.talend.libraries.jdbc.access/lib/talend-ucanaccess-utils-1.0.0.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')"/>
|
||||
|
||||
<IMPORT NAME="common2.6" MODULE="commons-lang-2.6.jar" MVN="mvn:commons-lang/commons-lang/2.6" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-lang-2.6.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')"/>
|
||||
|
||||
@@ -207,7 +207,7 @@
|
||||
<IMPORT NAME="Driver-JACKCESS" MODULE="jackcess-2.1.12.jar" MVN="mvn:com.healthmarketscience.jackcess/jackcess/2.1.12" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')"/>
|
||||
|
||||
<IMPORT NAME="jackcess-encrypt-2.1.4" MODULE="jackcess-encrypt-2.1.4.jar" MVN="mvn:com.healthmarketscience.jackcess/jackcess-encrypt/2.1.4" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')"/>
|
||||
<IMPORT NAME="bcprov-jdk15on-1.60" MODULE="bcprov-jdk15on-1.60.jar" MVN="mvn:org.bouncycastle/bcprov-jdk15on/1.60" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')"/>
|
||||
<IMPORT NAME="bcprov-jdk15on-1.68" MODULE="bcprov-jdk15on-1.68.jar" MVN="mvn:org.bouncycastle/bcprov-jdk15on/1.68" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')"/>
|
||||
<IMPORT NAME="talend-ucanaccess-utils-1.0.0" MODULE="talend-ucanaccess-utils-1.0.0.jar" MVN="mvn:org.talend.libraries/talend-ucanaccess-utils-1.0.0/6.4.0" UrlPath="platform:/plugin/org.talend.libraries.jdbc.access/lib/talend-ucanaccess-utils-1.0.0.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')"/>
|
||||
|
||||
<IMPORT NAME="common2.6" MODULE="commons-lang-2.6.jar" MVN="mvn:commons-lang/commons-lang/2.6" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-lang-2.6.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')"/>
|
||||
|
||||
@@ -181,7 +181,7 @@
|
||||
<IMPORT NAME="Driver-JACKCESS" MODULE="jackcess-2.1.12.jar" MVN="mvn:com.healthmarketscience.jackcess/jackcess/2.1.12" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')"/>
|
||||
|
||||
<IMPORT NAME="jackcess-encrypt-2.1.4" MODULE="jackcess-encrypt-2.1.4.jar" MVN="mvn:com.healthmarketscience.jackcess/jackcess-encrypt/2.1.4" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')"/>
|
||||
<IMPORT NAME="bcprov-jdk15on-1.60" MODULE="bcprov-jdk15on-1.60.jar" MVN="mvn:org.bouncycastle/bcprov-jdk15on/1.60" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')"/>
|
||||
<IMPORT NAME="bcprov-jdk15on-1.68" MODULE="bcprov-jdk15on-1.68.jar" MVN="mvn:org.bouncycastle/bcprov-jdk15on/1.68" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')"/>
|
||||
<IMPORT NAME="talend-ucanaccess-utils-1.0.0" MODULE="talend-ucanaccess-utils-1.0.0.jar" MVN="mvn:org.talend.libraries/talend-ucanaccess-utils-1.0.0/6.4.0" UrlPath="platform:/plugin/org.talend.libraries.jdbc.access/lib/talend-ucanaccess-utils-1.0.0.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')"/>
|
||||
|
||||
<IMPORT NAME="common2.6" MODULE="commons-lang-2.6.jar" MVN="mvn:commons-lang/commons-lang/2.6" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-lang-2.6.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')"/>
|
||||
|
||||
@@ -231,14 +231,14 @@
|
||||
<IMPORT NAME="aws-java-sdk-1.11.848.jar" MODULE="aws-java-sdk-1.11.848.jar"
|
||||
MVN="mvn:com.amazonaws/aws-java-sdk/1.11.848"
|
||||
REQUIRED="true" />
|
||||
<IMPORT NAME="jackson-core-2.10.1.jar" MODULE="jackson-core-2.10.1.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.10.1"
|
||||
<IMPORT NAME="jackson-core-2.11.4.jar" MODULE="jackson-core-2.11.4.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.11.4"
|
||||
REQUIRED="true" />
|
||||
<IMPORT NAME="jackson-databind-2.10.1.jar" MODULE="jackson-databind-2.10.1.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-databind/2.10.1"
|
||||
<IMPORT NAME="jackson-databind-2.11.4.jar" MODULE="jackson-databind-2.11.4.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-databind/2.11.4"
|
||||
REQUIRED="true" />
|
||||
<IMPORT NAME="jackson-annotations-2.10.1.jar" MODULE="jackson-annotations-2.10.1.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-annotations/2.10.1"
|
||||
<IMPORT NAME="jackson-annotations-2.11.4.jar" MODULE="jackson-annotations-2.11.4.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-annotations/2.11.4"
|
||||
REQUIRED="true" />
|
||||
<IMPORT NAME="httpcore-4.4.13.jar" MODULE="httpcore-4.4.13.jar"
|
||||
MVN="mvn:org.apache.httpcomponents/httpcore/4.4.13"
|
||||
|
||||
@@ -558,14 +558,14 @@
|
||||
<IMPORT NAME="aws-java-sdk-1.11.848.jar" MODULE="aws-java-sdk-1.11.848.jar"
|
||||
MVN="mvn:com.amazonaws/aws-java-sdk/1.11.848"
|
||||
REQUIRED="true" />
|
||||
<IMPORT NAME="jackson-core-2.10.1.jar" MODULE="jackson-core-2.10.1.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.10.1"
|
||||
<IMPORT NAME="jackson-core-2.11.4.jar" MODULE="jackson-core-2.11.4.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.11.4"
|
||||
REQUIRED="true" />
|
||||
<IMPORT NAME="jackson-databind-2.10.1.jar" MODULE="jackson-databind-2.10.1.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-databind/2.10.1"
|
||||
<IMPORT NAME="jackson-databind-2.11.4.jar" MODULE="jackson-databind-2.11.4.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-databind/2.11.4"
|
||||
REQUIRED="true" />
|
||||
<IMPORT NAME="jackson-annotations-2.10.1.jar" MODULE="jackson-annotations-2.10.1.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-annotations/2.10.1"
|
||||
<IMPORT NAME="jackson-annotations-2.11.4.jar" MODULE="jackson-annotations-2.11.4.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-annotations/2.11.4"
|
||||
REQUIRED="true" />
|
||||
<IMPORT NAME="httpcore-4.4.13.jar" MODULE="httpcore-4.4.13.jar"
|
||||
MVN="mvn:org.apache.httpcomponents/httpcore/4.4.13"
|
||||
|
||||
@@ -288,14 +288,14 @@
|
||||
<IMPORT NAME="aws-java-sdk-1.11.848.jar" MODULE="aws-java-sdk-1.11.848.jar"
|
||||
MVN="mvn:com.amazonaws/aws-java-sdk/1.11.848"
|
||||
REQUIRED="true" />
|
||||
<IMPORT NAME="jackson-core-2.10.1.jar" MODULE="jackson-core-2.10.1.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.10.1"
|
||||
<IMPORT NAME="jackson-core-2.11.4.jar" MODULE="jackson-core-2.11.4.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.11.4"
|
||||
REQUIRED="true" />
|
||||
<IMPORT NAME="jackson-databind-2.10.1.jar" MODULE="jackson-databind-2.10.1.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-databind/2.10.1"
|
||||
<IMPORT NAME="jackson-databind-2.11.4.jar" MODULE="jackson-databind-2.11.4.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-databind/2.11.4"
|
||||
REQUIRED="true" />
|
||||
<IMPORT NAME="jackson-annotations-2.10.1.jar" MODULE="jackson-annotations-2.10.1.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-annotations/2.10.1"
|
||||
<IMPORT NAME="jackson-annotations-2.11.4.jar" MODULE="jackson-annotations-2.11.4.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-annotations/2.11.4"
|
||||
REQUIRED="true" />
|
||||
<IMPORT NAME="httpcore-4.4.13.jar" MODULE="httpcore-4.4.13.jar"
|
||||
MVN="mvn:org.apache.httpcomponents/httpcore/4.4.13"
|
||||
|
||||
@@ -348,14 +348,14 @@
|
||||
<IMPORT NAME="aws-java-sdk-1.11.848.jar" MODULE="aws-java-sdk-1.11.848.jar"
|
||||
MVN="mvn:com.amazonaws/aws-java-sdk/1.11.848"
|
||||
REQUIRED="true" />
|
||||
<IMPORT NAME="jackson-core-2.10.1.jar" MODULE="jackson-core-2.10.1.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.10.1"
|
||||
<IMPORT NAME="jackson-core-2.11.4.jar" MODULE="jackson-core-2.11.4.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.11.4"
|
||||
REQUIRED="true" />
|
||||
<IMPORT NAME="jackson-databind-2.10.1.jar" MODULE="jackson-databind-2.10.1.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-databind/2.10.1"
|
||||
<IMPORT NAME="jackson-databind-2.11.4.jar" MODULE="jackson-databind-2.11.4.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-databind/2.11.4"
|
||||
REQUIRED="true" />
|
||||
<IMPORT NAME="jackson-annotations-2.10.1.jar" MODULE="jackson-annotations-2.10.1.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-annotations/2.10.1"
|
||||
<IMPORT NAME="jackson-annotations-2.11.4.jar" MODULE="jackson-annotations-2.11.4.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-annotations/2.11.4"
|
||||
REQUIRED="true" />
|
||||
<IMPORT NAME="httpcore-4.4.13.jar" MODULE="httpcore-4.4.13.jar"
|
||||
MVN="mvn:org.apache.httpcomponents/httpcore/4.4.13"
|
||||
|
||||
@@ -149,7 +149,7 @@
|
||||
<IMPORTS>
|
||||
<IMPORT
|
||||
NAME="Talen File Enhanced"
|
||||
MODULE="talend_file_enhanced-1.0.jar" MVN="mvn:org.talend.components.lib/talend_file_enhanced/1.0" UrlPath="platform:/plugin/org.talend.libraries.custom/lib/talend_file_enhanced-1.0.jar"
|
||||
MODULE="talend_file_enhanced-1.1.jar" MVN="mvn:org.talend.components.lib/talend_file_enhanced/1.1" UrlPath="platform:/plugin/org.talend.libraries.custom/lib/talend_file_enhanced-1.1.jar"
|
||||
REQUIRED="true"
|
||||
/>
|
||||
</IMPORTS>
|
||||
|
||||
@@ -200,7 +200,7 @@
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="DATE_PATTERN" GROUP="LOAD_DETAILS" FIELD="TEXT" NUM_ROW="15" SHOW_IF="isShow[(DATE_FORMAT] AND (DATE_FORMAT == 'true')">
|
||||
<PARAMETER NAME="DATE_PATTERN" GROUP="LOAD_DETAILS" FIELD="TEXT" NUM_ROW="15" SHOW_IF="isShow[DATE_FORMAT] AND (DATE_FORMAT == 'true')">
|
||||
<DEFAULT>"yyyy-MM-dd"</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<%@ jet
|
||||
imports="
|
||||
org.talend.core.model.process.INode
|
||||
org.talend.core.model.process.ElementParameterParser
|
||||
org.talend.core.model.process.INode
|
||||
org.talend.core.model.process.ElementParameterParser
|
||||
org.talend.designer.codegen.config.CodeGeneratorArgument
|
||||
org.talend.core.model.metadata.IMetadataTable
|
||||
org.talend.core.model.metadata.IMetadataColumn
|
||||
org.talend.core.model.metadata.IMetadataTable
|
||||
org.talend.core.model.metadata.IMetadataColumn
|
||||
org.talend.core.model.process.IConnection
|
||||
java.util.List
|
||||
"
|
||||
@@ -37,7 +37,7 @@
|
||||
boolean useCustomNullMarker = ElementParameterParser.getBooleanValue(node, "__USE_CUSTOM_NULL_MARKER__");
|
||||
String nullMarker = useCustomNullMarker ? ElementParameterParser.getValue(node, "__CUSTOM_NULL_MARKER__") : "\"\\\\N\"";
|
||||
String passwordFieldName = "";
|
||||
|
||||
|
||||
IConnection incomingConnection = null;
|
||||
if(node.getUniqueName().startsWith("tBigQueryOutput_")) {
|
||||
List< ? extends IConnection> conns = node.getIncomingConnections();
|
||||
@@ -49,7 +49,7 @@
|
||||
incomingConnection = virtConnection.getSource().getIncomingConnections().get(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (authMode.equals("OAUTH")) {
|
||||
%>
|
||||
/* ----START-CREATING-CLIENT (OAuth 2.0)---- */
|
||||
@@ -58,22 +58,22 @@
|
||||
<%
|
||||
passwordFieldName = "__CLIENT_SECRET__";
|
||||
%>
|
||||
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/password.javajet"%>
|
||||
|
||||
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/password.javajet"%>
|
||||
|
||||
final String CLIENT_SECRET_<%=cid%> = "{\"web\": {\"client_id\": \""+<%=clientId%>+"\",\"client_secret\": \"" +decryptedPassword_<%=cid%>+ "\",\"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\"token_uri\": \"https://accounts.google.com/o/oauth2/token\"}}";
|
||||
final String PROJECT_ID_<%=cid %> = <%=projectId %>;
|
||||
|
||||
|
||||
// Static variables for API scope, callback URI, and HTTP/JSON functions
|
||||
final List<String> SCOPES_<%=cid%> = java.util.Arrays.asList("https://www.googleapis.com/auth/bigquery");
|
||||
final String REDIRECT_URI_<%=cid%> = "urn:ietf:wg:oauth:2.0:oob";
|
||||
final com.google.api.client.http.HttpTransport TRANSPORT_<%=cid %> = new com.google.api.client.http.javanet.NetHttpTransport();
|
||||
final com.google.api.client.json.JsonFactory JSON_FACTORY_<%=cid %> = new com.google.api.client.json.jackson2.JacksonFactory();
|
||||
|
||||
|
||||
com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets clientSecrets_<%=cid%> = com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets.load(
|
||||
new com.google.api.client.json.jackson2.JacksonFactory(), new java.io.InputStreamReader(new java.io.ByteArrayInputStream(
|
||||
CLIENT_SECRET_<%=cid%>.getBytes())));
|
||||
|
||||
|
||||
com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow flow_<%=cid%> = null;
|
||||
com.google.api.services.bigquery.Bigquery bigqueryclient_<%=cid%> = null;
|
||||
long nb_line_<%=cid%> = 0;
|
||||
@@ -111,7 +111,7 @@
|
||||
%>
|
||||
}
|
||||
String storedRefreshToken_<%=cid%> = (String) properties_<%=cid%>.get("refreshtoken");
|
||||
|
||||
|
||||
// Check to see if the an existing refresh token was loaded.
|
||||
// If so, create a credential and call refreshToken() to get a new
|
||||
// access token.
|
||||
@@ -120,7 +120,7 @@
|
||||
com.google.api.client.googleapis.auth.oauth2.GoogleCredential credential_<%=cid%> = new com.google.api.client.googleapis.auth.oauth2. GoogleCredential.Builder().setTransport(TRANSPORT_<%=cid%>)
|
||||
.setJsonFactory(JSON_FACTORY_<%=cid%>).setClientSecrets(clientSecrets_<%=cid%>)
|
||||
.build().setFromTokenResponse(new com.google.api.client.auth.oauth2.TokenResponse().setRefreshToken(storedRefreshToken_<%=cid%>));
|
||||
|
||||
|
||||
credential_<%=cid%>.refreshToken();
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
@@ -186,13 +186,13 @@
|
||||
if (outputStream_<%=cid%> != null) {
|
||||
outputStream_<%=cid%>.close();
|
||||
}
|
||||
|
||||
|
||||
bigqueryclient_<%=cid%> = new com.google.api.services.bigquery.Bigquery.Builder(new com.google.api.client.http.javanet.NetHttpTransport(),new com.google.api.client.json.jackson2.JacksonFactory(),credential_<%=cid%>).build();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ----END-CREATING-CLIENT (OAuth 2.0)---- */
|
||||
|
||||
|
||||
<%
|
||||
} else if (authMode.equals("SERVICEACCOUNT")) {
|
||||
%>
|
||||
@@ -213,9 +213,35 @@
|
||||
/* ----END-CREATING-CLIENT (Cloud API)---- */
|
||||
|
||||
long nb_line_<%=cid%> = 0;
|
||||
<%
|
||||
} else if (authMode.equals("TOKEN")) {
|
||||
if (ElementParameterParser.canEncrypt(node, "__ACCESS_TOKEN__")) {%>
|
||||
final String decryptedAccessToken_<%=cid%> = routines.system.PasswordEncryptUtil.decryptPassword(<%=ElementParameterParser.getEncryptedValue(node, "__ACCESS_TOKEN__")%>);
|
||||
<%} else {%>
|
||||
final String decryptedAccessToken_<%=cid%> = <%= ElementParameterParser.getValue(node, "__ACCESS_TOKEN__")%>;
|
||||
<%}%>
|
||||
/* ----START-CREATING-CLIENT (OAuth based Token)---- */
|
||||
final String PROJECT_ID_<%=cid %> = <%=projectId %>;
|
||||
|
||||
com.google.api.client.auth.oauth2.Credential cred_<%=cid%> =
|
||||
new com.google.api.client.auth.oauth2.Credential(com.google.api.client.auth.oauth2.BearerToken.authorizationHeaderAccessMethod()).setFromTokenResponse(
|
||||
(new com.google.api.client.auth.oauth2.TokenResponse()).setAccessToken(decryptedAccessToken_<%=cid%>));
|
||||
|
||||
com.google.api.services.bigquery.Bigquery bigqueryclient_<%=cid%> = null;
|
||||
long nb_line_<%=cid%> = 0;
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
log.info("<%=cid%> - Creating client.");
|
||||
<%
|
||||
}
|
||||
%>
|
||||
bigqueryclient_<%=cid%> =
|
||||
new com.google.api.services.bigquery.Bigquery.Builder(new com.google.api.client.http.javanet.NetHttpTransport(), new com.google.api.client.json.jackson2.JacksonFactory(), cred_<%=cid%>).setApplicationName("Talend").build();
|
||||
/* ----END-CREATING-CLIENT (OAuth based Token)---- */
|
||||
<%
|
||||
} else {
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\" or \"OAUTH\", but it is " + authMode);
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\", \"OAUTH\" or \"TOKEN\", but it is " + authMode);
|
||||
}
|
||||
boolean bulkFileAlreadyExists = ElementParameterParser.getBooleanValue(node, "__BULK_FILE_ALREADY_EXIST__");
|
||||
String accessKey = ElementParameterParser.getValue(node, "__GS_ACCESS_KEY__");
|
||||
@@ -227,17 +253,17 @@
|
||||
|
||||
|
||||
if(!bulkFileAlreadyExists) {
|
||||
if (!useServiceAccountForConnection){
|
||||
if ("USER_ACCOUNT_HMAC".equals(authType)){
|
||||
%>
|
||||
/* ----START-UPLOADING-FILE WITH HMAC ACCOUNT---- */
|
||||
<%
|
||||
passwordFieldName = "__GS_SECRET_KEY__";
|
||||
%>
|
||||
|
||||
<%if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {%>
|
||||
|
||||
<%if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {%>
|
||||
final String decryptedPwd_<%=cid%> = routines.system.PasswordEncryptUtil.decryptPassword(<%=ElementParameterParser.getEncryptedValue(node, passwordFieldName)%>);
|
||||
<%} else {%>
|
||||
final String decryptedPwd_<%=cid%> = <%= ElementParameterParser.getValue(node, passwordFieldName)%>;
|
||||
final String decryptedPwd_<%=cid%> = <%= ElementParameterParser.getValue(node, passwordFieldName)%>;
|
||||
<%}%>
|
||||
|
||||
|
||||
@@ -262,33 +288,12 @@
|
||||
log.info("<%=cid%> - Upload Done.");
|
||||
<%
|
||||
}
|
||||
} else {
|
||||
String pathToServerAccoutKeyFile = ElementParameterParser.getValue(node, "__GS_SERVICE_ACCOUNT_KEY__");
|
||||
%>
|
||||
/* ----START-UPLOADING-FILE WITH SERVICE ACCOUNT---- */
|
||||
com.google.cloud.storage.Storage storage_<%=cid%> = null;
|
||||
com.google.auth.Credentials credential_<%=cid%> = null;
|
||||
try {
|
||||
credential_<%=cid%> = com.google.auth.oauth2.GoogleCredentials
|
||||
.fromStream(new java.io.FileInputStream(<%=pathToServerAccoutKeyFile%>));
|
||||
} catch (IOException e_<%=cid%>) {
|
||||
<%
|
||||
if (("true").equals(dieOnError)) {
|
||||
%>
|
||||
throw(e_<%=cid%>);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
log.error("<%=cid%> - Exception in component <%=cid%>.", e_<%=cid%>);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
}
|
||||
com.google.cloud.storage.StorageOptions.Builder builder = com.google.cloud.storage.StorageOptions.newBuilder();
|
||||
storage_<%=cid%> = builder.setCredentials(credential_<%=cid%>).build().getService();
|
||||
} else {
|
||||
boolean useExistingConn = false;
|
||||
String gsProjectID = projectId;
|
||||
String connection = cid;
|
||||
%>
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/googleStorageConnection.javajet"%>
|
||||
|
||||
java.io.File file_<%=cid%> = new java.io.File(<%=localFilename%>);
|
||||
|
||||
@@ -302,6 +307,7 @@
|
||||
<%
|
||||
}
|
||||
%>
|
||||
/* ----END-UPLOADING-FILE---- */
|
||||
<%
|
||||
}
|
||||
}
|
||||
@@ -313,7 +319,7 @@
|
||||
int currIndex_<%=cid%> = 0;
|
||||
<%
|
||||
}
|
||||
if (authMode.equals("OAUTH")) {
|
||||
if (authMode.equals("OAUTH") || authMode.equals("TOKEN")) {
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
log.info("<%=cid%> - Starting build a job.");
|
||||
@@ -323,12 +329,15 @@
|
||||
/* ----START-CREATING-JOB (OAuth 2.0)---- */
|
||||
com.google.api.services.bigquery.model.Job job_<%=cid%> = new com.google.api.services.bigquery.model.Job();
|
||||
job_<%=cid%>.setJobReference(new com.google.api.services.bigquery.model.JobReference().setProjectId(PROJECT_ID_<%=cid%>));
|
||||
|
||||
|
||||
com.google.api.services.bigquery.model.JobConfiguration config_<%=cid%> = new com.google.api.services.bigquery.model.JobConfiguration();
|
||||
com.google.api.services.bigquery.model.JobConfigurationLoad queryLoad_<%=cid%> = new com.google.api.services.bigquery.model.JobConfigurationLoad();
|
||||
|
||||
|
||||
<%if (dropTable) {%>
|
||||
try {
|
||||
<% if(authMode.equals("TOKEN") && !ElementParameterParser.canEncrypt(node, "__ACCESS_TOKEN__")) { %>
|
||||
cred_<%=cid%>.setAccessToken(<%= ElementParameterParser.getValue(node, "__ACCESS_TOKEN__")%>);
|
||||
<% } %>
|
||||
bigqueryclient_<%=cid%>.tables().delete(PROJECT_ID_<%=cid%>, <%=dataset%>, <%=table%>).execute();
|
||||
} catch (com.google.api.client.googleapis.json.GoogleJsonResponseException e_<%=cid%>) {
|
||||
if (e_<%=cid%>.getDetails().getCode() != 404) {
|
||||
@@ -351,10 +360,13 @@
|
||||
}
|
||||
}
|
||||
<%}%>
|
||||
|
||||
|
||||
<%if (createTableIfNotExist) { %>
|
||||
|
||||
|
||||
try {
|
||||
<% if(authMode.equals("TOKEN") && !ElementParameterParser.canEncrypt(node, "__ACCESS_TOKEN__")) { %>
|
||||
cred_<%=cid%>.setAccessToken(<%= ElementParameterParser.getValue(node, "__ACCESS_TOKEN__")%>);
|
||||
<% } %>
|
||||
com.google.api.services.bigquery.model.Table getTable = bigqueryclient_<%=cid%>.tables().get(PROJECT_ID_<%=cid%>, <%=dataset%>, <%=table%>).execute();
|
||||
queryLoad_<%=cid%>.setCreateDisposition("CREATE_NEVER");
|
||||
} catch (com.google.api.client.googleapis.json.GoogleJsonResponseException e_<%=cid%>){
|
||||
@@ -497,15 +509,17 @@
|
||||
destinationTable_<%=cid%>.setProjectId(PROJECT_ID_<%=cid%>);
|
||||
destinationTable_<%=cid%>.setDatasetId(<%=dataset%>);
|
||||
destinationTable_<%=cid%>.setTableId(<%=table%>);
|
||||
|
||||
|
||||
queryLoad_<%=cid%>.setDestinationTable(destinationTable_<%=cid%>);
|
||||
queryLoad_<%=cid%>.setSourceUris(java.util.Arrays.asList(<%=gsFile%>));
|
||||
queryLoad_<%=cid%>.setSkipLeadingRows(<%=gsFileHeader%>);
|
||||
queryLoad_<%=cid%>.setNullMarker(<%= nullMarker %>);
|
||||
config_<%=cid%>.setLoad(queryLoad_<%=cid%>);
|
||||
|
||||
|
||||
job_<%=cid%>.setConfiguration(config_<%=cid%>);
|
||||
|
||||
<% if(authMode.equals("TOKEN") && !ElementParameterParser.canEncrypt(node, "__ACCESS_TOKEN__")) { %>
|
||||
cred_<%=cid%>.setAccessToken(<%= ElementParameterParser.getValue(node, "__ACCESS_TOKEN__")%>);
|
||||
<% } %>
|
||||
com.google.api.services.bigquery.Bigquery.Jobs.Insert insertReq_<%=cid%> = bigqueryclient_<%=cid%>.jobs().insert("", job_<%=cid%>);
|
||||
insertReq_<%=cid%>.setProjectId(PROJECT_ID_<%=cid%>);
|
||||
<%
|
||||
@@ -514,11 +528,17 @@
|
||||
log.info("<%=cid%> - Build a job successfully.");
|
||||
log.info("<%=cid%> - Starting load the job.");
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
System.out.println("Starting load job.");
|
||||
<%
|
||||
}
|
||||
%>
|
||||
System.out.println("Starting load job.");
|
||||
com.google.api.services.bigquery.model.Job jobExec_<%=cid%> = null;
|
||||
try {
|
||||
<% if(authMode.equals("TOKEN") && !ElementParameterParser.canEncrypt(node, "__ACCESS_TOKEN__")) { %>
|
||||
cred_<%=cid%>.setAccessToken(<%= ElementParameterParser.getValue(node, "__ACCESS_TOKEN__")%>);
|
||||
<% } %>
|
||||
jobExec_<%=cid%> = insertReq_<%=cid%>.execute();
|
||||
} catch (Exception ee_<%=cid%>) {
|
||||
<%
|
||||
@@ -540,9 +560,15 @@
|
||||
}
|
||||
if (jobExec_<%=cid%>.getStatus().getState().equals("RUNNING")
|
||||
|| jobExec_<%=cid%>.getStatus().getState().equals("PENDING")) {
|
||||
com.google.api.services.bigquery.model.Job pollJob_<%=cid%> = bigqueryclient_<%=cid%>.jobs().get(PROJECT_ID_<%=cid%>,jobExec_<%=cid%>.getJobReference().getJobId()).setLocation(jobExec_<%=cid%>.getJobReference().getLocation()).execute();
|
||||
<% if(authMode.equals("TOKEN") && !ElementParameterParser.canEncrypt(node, "__ACCESS_TOKEN__")) { %>
|
||||
cred_<%=cid%>.setAccessToken(<%= ElementParameterParser.getValue(node, "__ACCESS_TOKEN__")%>);
|
||||
<% } %>
|
||||
com.google.api.services.bigquery.model.Job pollJob_<%=cid%> = bigqueryclient_<%=cid%>.jobs().get(PROJECT_ID_<%=cid%>,jobExec_<%=cid%>.getJobReference().getJobId()).setLocation(jobExec_<%=cid%>.getJobReference().getLocation()).execute();
|
||||
while (pollJob_<%=cid%>.getStatus().getState().equals("RUNNING") || pollJob_<%=cid%>.getStatus().getState().equals("PENDING")) {
|
||||
Thread.sleep(1000);
|
||||
<% if(authMode.equals("TOKEN") && !ElementParameterParser.canEncrypt(node, "__ACCESS_TOKEN__")) { %>
|
||||
cred_<%=cid%>.setAccessToken(<%= ElementParameterParser.getValue(node, "__ACCESS_TOKEN__")%>);
|
||||
<% } %>
|
||||
pollJob_<%=cid%> = bigqueryclient_<%=cid%>.jobs().get(PROJECT_ID_<%=cid%>,jobExec_<%=cid%>.getJobReference().getJobId()).setLocation(jobExec_<%=cid%>.getJobReference().getLocation()).execute();
|
||||
System.out.println(String.format(
|
||||
"Waiting on job %s ... Current status: %s", jobExec_<%=cid%>
|
||||
@@ -556,14 +582,17 @@
|
||||
}
|
||||
%>
|
||||
}
|
||||
|
||||
|
||||
<% if(authMode.equals("TOKEN") && !ElementParameterParser.canEncrypt(node, "__ACCESS_TOKEN__")) { %>
|
||||
cred_<%=cid%>.setAccessToken(<%= ElementParameterParser.getValue(node, "__ACCESS_TOKEN__")%>);
|
||||
<% } %>
|
||||
com.google.api.services.bigquery.model.Job doneJob_<%=cid%> = pollJob_<%=cid%>;
|
||||
|
||||
|
||||
if ((doneJob_<%=cid%>.getStatus() != null) && (doneJob_<%=cid%>.getStatus().getErrors() != null)) {
|
||||
status = "failure";
|
||||
throw new Exception(doneJob_<%=cid%>.getStatus().getErrors().toString());
|
||||
}
|
||||
|
||||
|
||||
System.out.println("Done: " + doneJob_<%=cid%>.toString());
|
||||
com.google.api.services.bigquery.model.JobStatistics jobStatistics_<%=cid%>= doneJob_<%=cid%>.getStatistics();
|
||||
if(jobStatistics_<%=cid%>!=null && jobStatistics_<%=cid%>.getLoad() != null){
|
||||
@@ -605,11 +634,11 @@
|
||||
/* ----START-CREATING-JOB (Cloud API)---- */
|
||||
com.google.cloud.bigquery.TableId tableId_<%=cid%> = com.google.cloud.bigquery.TableId.of(<%=projectId%>, <%=dataset%>, <%=table%>);
|
||||
com.google.cloud.bigquery.LoadJobConfiguration.Builder loadJobBuilder_<%=cid%> = com.google.cloud.bigquery.LoadJobConfiguration.newBuilder(tableId_<%=cid%>, <%=gsFile%>);
|
||||
|
||||
|
||||
boolean dropTable_<%=cid%> = <%=dropTable%>;
|
||||
|
||||
if (dropTable_<%=cid%> && bigquery_<%=cid%>.getTable(tableId_<%=cid%>) != null) {
|
||||
boolean deleted = bigquery_<%=cid%>.delete(tableId_<%=cid%>);
|
||||
boolean deleted = bigquery_<%=cid%>.delete(tableId_<%=cid%>);
|
||||
if (deleted) {
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
@@ -645,10 +674,10 @@
|
||||
} else if ("id_Short".equals(column.getTalendType()) || "id_Integer".equals(column.getTalendType()) || "id_Long".equals(column.getTalendType())) {
|
||||
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.INTEGER";
|
||||
} else if ("id_BigDecimal".equals(column.getTalendType())) {
|
||||
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.NUMERIC";
|
||||
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.NUMERIC";
|
||||
} else if ("id_Boolean".equals(column.getTalendType())) {
|
||||
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.BOOLEAN";
|
||||
} else if ("id_Date".equals(column.getTalendType())) {
|
||||
} else if ("id_Date".equals(column.getTalendType())) {
|
||||
String pattern = column.getPattern();
|
||||
if(pattern.length() == 12 || pattern.isEmpty() || "\"\"".equals(pattern)) {
|
||||
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.DATE";
|
||||
@@ -660,11 +689,11 @@
|
||||
}
|
||||
String modeType = (!column.isNullable()) ? "REQUIRED" : "NULLABLE";
|
||||
%>
|
||||
|
||||
|
||||
com.google.cloud.bigquery.Field field_<%=i%> = com.google.cloud.bigquery.Field.newBuilder("<%=columnName%>", <%=typeToGenerate%>)
|
||||
.setMode(com.google.cloud.bigquery.Field.Mode.valueOf("<%=modeType%>"))
|
||||
.build();
|
||||
fields_<%=cid%>.add(field_<%=i%>);
|
||||
fields_<%=cid%>.add(field_<%=i%>);
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
@@ -753,32 +782,32 @@
|
||||
}
|
||||
}
|
||||
%>
|
||||
|
||||
|
||||
com.google.cloud.bigquery.Schema schema_<%=cid%> = com.google.cloud.bigquery.Schema.of(fields_<%=cid%>);
|
||||
com.google.cloud.bigquery.TableInfo tableInfo_<%=cid%> = com.google.cloud.bigquery.TableInfo.newBuilder(tableId_<%=cid%>, com.google.cloud.bigquery.StandardTableDefinition.of(schema_<%=cid%>)).build();
|
||||
com.google.cloud.bigquery.Table table_<%=cid%> = bigquery_<%=cid%>.create(tableInfo_<%=cid%>);
|
||||
loadJobBuilder_<%=cid%>.setSchema(schema_<%=cid%>);
|
||||
loadJobBuilder_<%=cid%>.setCreateDisposition(com.google.cloud.bigquery.JobInfo.CreateDisposition.CREATE_IF_NEEDED);
|
||||
|
||||
|
||||
} else {
|
||||
loadJobBuilder_<%=cid%>.setCreateDisposition(com.google.cloud.bigquery.JobInfo.CreateDisposition.CREATE_NEVER);
|
||||
}
|
||||
<%} else {%>
|
||||
loadJobBuilder_<%=cid%>.setCreateDisposition(com.google.cloud.bigquery.JobInfo.CreateDisposition.CREATE_NEVER);
|
||||
<%}%>
|
||||
|
||||
loadJobBuilder_<%=cid%>.setWriteDisposition(com.google.cloud.bigquery.JobInfo.WriteDisposition.WRITE_<%=actionOnData%>);
|
||||
|
||||
loadJobBuilder_<%=cid%>.setWriteDisposition(com.google.cloud.bigquery.JobInfo.WriteDisposition.WRITE_<%=actionOnData%>);
|
||||
loadJobBuilder_<%=cid%>.setDestinationTable(tableId_<%=cid%>);
|
||||
com.google.cloud.bigquery.CsvOptions.Builder csvOptions_<%=cid%> = com.google.cloud.bigquery.CsvOptions.newBuilder();
|
||||
csvOptions_<%=cid%>.setAllowQuotedNewLines(true);
|
||||
csvOptions_<%=cid%>.setSkipLeadingRows(<%=gsFileHeader%>);
|
||||
|
||||
|
||||
<%if(setFieldDelimiter) {
|
||||
%>
|
||||
csvOptions_<%=cid%>.setFieldDelimiter(<%=fieldDelimiter%>);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
%>
|
||||
loadJobBuilder_<%=cid%>.setFormatOptions(csvOptions_<%=cid%>.build());
|
||||
loadJobBuilder_<%=cid%>.setNullMarker(<%= nullMarker %>);
|
||||
com.google.cloud.bigquery.Job job_<%=cid%> = bigquery_<%=cid%>.create(com.google.cloud.bigquery.JobInfo.of(loadJobBuilder_<%=cid%>.build()));
|
||||
@@ -795,10 +824,10 @@
|
||||
List<com.google.cloud.bigquery.BigQueryError> errorList = job_<%=cid%>.getStatus().getExecutionErrors();
|
||||
throw new RuntimeException("Job failed: " + errorList.get(errorList.size() - 1));
|
||||
}
|
||||
|
||||
|
||||
/* ----END-CREATING-JOB (Cloud API)---- */
|
||||
<%
|
||||
} else {
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\" or \"OAUTH\", but it is " + authMode);
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\", \"OAUTH\" or \"TOKEN\", but it is " + authMode);
|
||||
}
|
||||
%>
|
||||
|
||||
@@ -39,8 +39,31 @@
|
||||
<ITEMS DEFAULT="SERVICEACCOUNT">
|
||||
<ITEM NAME="SERVICEACCOUNT" VALUE="SERVICEACCOUNT" />
|
||||
<ITEM NAME="OAUTH" VALUE="OAUTH" />
|
||||
<ITEM NAME="TOKEN" VALUE="TOKEN" />
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="ACCESS_TOKEN"
|
||||
FIELD="PASSWORD"
|
||||
NUM_ROW="10"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="AUTH_MODE == 'TOKEN'"
|
||||
GROUP="AUTHENTICATION"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="ACCESS_TOKEN_WARNING"
|
||||
FIELD="LABEL"
|
||||
NUM_ROW="11"
|
||||
REQUIRED="false"
|
||||
GROUP="AUTHENTICATION"
|
||||
SHOW_IF="AUTH_MODE == 'TOKEN'"
|
||||
>
|
||||
<DEFAULT>*Note: If the Access Token Expire we won't be able to refresh it!"</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="SERVICE_ACCOUNT_CREDENTIALS_FILE"
|
||||
@@ -144,6 +167,7 @@
|
||||
<ITEMS DEFAULT="GS_SERVICE_ACCOUNT">
|
||||
<ITEM NAME="USER_ACCOUNT_HMAC" VALUE="USER_ACCOUNT_HMAC"/>
|
||||
<ITEM NAME="GS_SERVICE_ACCOUNT" VALUE="GS_SERVICE_ACCOUNT"/>
|
||||
<ITEM NAME="TOKEN" VALUE="TOKEN" />
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
@@ -177,6 +201,28 @@
|
||||
<DEFAULT>"__COMP_DEFAULT_FILE_DIR__/key.json"</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="GS_ACCESS_TOKEN"
|
||||
FIELD="PASSWORD"
|
||||
NUM_ROW="60"
|
||||
REQUIRED_IF="(BULK_FILE_ALREADY_EXIST=='false') AND (AUTH_TYPE == 'TOKEN')"
|
||||
SHOW_IF="(BULK_FILE_ALREADY_EXIST=='false') AND (AUTH_TYPE == 'TOKEN')"
|
||||
GROUP="GS_CONF"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="GS_ACCESS_TOKEN_WARNING"
|
||||
FIELD="LABEL"
|
||||
NUM_ROW="61"
|
||||
REQUIRED="false"
|
||||
GROUP="GS_CONF"
|
||||
SHOW_IF="(BULK_FILE_ALREADY_EXIST=='false') AND (AUTH_TYPE == 'TOKEN')"
|
||||
>
|
||||
<DEFAULT>*Note: If the Access Token Expire we won't be able to refresh it!"</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="GS_LOCAL_FILE" FIELD="FILE" NUM_ROW="63" REQUIRED="true" GROUP="GS_CONF" SHOW_IF="BULK_FILE_ALREADY_EXIST=='false'">
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
@@ -233,47 +279,50 @@
|
||||
</ADVANCED_PARAMETERS>
|
||||
<CODEGENERATION>
|
||||
<IMPORTS>
|
||||
<IMPORT NAME="google-api-client-1.25.0.jar" MODULE="google-api-client-1.25.0.jar" MVN="mvn:com.google.api-client/google-api-client/1.25.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-api-services-oauth2-v2-rev151-1.25.0.jar" MODULE="google-api-services-oauth2-v2-rev151-1.25.0.jar" MVN="mvn:com.google.apis/google-api-services-oauth2/v2-rev151-1.25.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-api-services-bigquery-v2-rev454-1.25.0.jar" MODULE="google-api-services-bigquery-v2-rev454-1.25.0.jar" MVN="mvn:com.google.apis/google-api-services-bigquery/v2-rev454-1.25.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-http-client-1.25.0.jar" MODULE="google-http-client-1.25.0.jar" MVN="mvn:com.google.http-client/google-http-client/1.25.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-api-client-1.31.1.jar" MODULE="google-api-client-1.31.1.jar" MVN="mvn:com.google.api-client/google-api-client/1.31.1" REQUIRED="true" />
|
||||
<IMPORT NAME="google-api-services-oauth2-v2-rev20200213-1.31.0.jar" MODULE="google-api-services-oauth2-v2-rev20200213-1.31.0.jar" MVN="mvn:com.google.apis/google-api-services-oauth2/v2-rev20200213-1.31.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-api-services-bigquery-v2-rev20201030-1.31.0.jar" MODULE="google-api-services-bigquery-v2-rev20201030-1.31.0.jar" MVN="mvn:com.google.apis/google-api-services-bigquery/v2-rev20201030-1.31.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-http-client-1.38.0.jar" MODULE="google-http-client-1.38.0.jar" MVN="mvn:com.google.http-client/google-http-client/1.38.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-oauth-client-1.31.0.jar" MODULE="google-oauth-client-1.31.0.jar" MVN="mvn:com.google.oauth-client/google-oauth-client/1.31.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-http-client-jackson2-1.25.0.jar" MODULE="google-http-client-jackson2-1.25.0.jar" MVN="mvn:com.google.http-client/google-http-client-jackson2/1.25.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-http-client-jackson2-1.38.0.jar" MODULE="google-http-client-jackson2-1.38.0.jar" MVN="mvn:com.google.http-client/google-http-client-jackson2/1.38.0" REQUIRED="true" />
|
||||
<IMPORT NAME="guava-20.0.jar" MODULE="guava-20.0.jar" MVN="mvn:com.google.guava/guava/20.0" REQUIRED="true" />
|
||||
<IMPORT NAME="jackson-core-2.10.1.jar" MODULE="jackson-core-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.10.1" REQUIRED="true" />
|
||||
<IMPORT NAME="jackson-core-2.11.4.jar" MODULE="jackson-core-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.11.4" REQUIRED="true" />
|
||||
<!-- REQUIRED FOR GOOGLE STORAGE -->
|
||||
<IMPORT NAME="jets3t-0.9.1" MODULE="jets3t-0.9.1.jar" MVN="mvn:org.talend.libraries/jets3t-0.9.1/6.0.0" REQUIRED="true" />
|
||||
<IMPORT NAME="commons-logging-1.2" MODULE="commons-logging-1.2.jar" MVN="mvn:commons-logging/commons-logging/1.2" REQUIRED="true" />
|
||||
<IMPORT NAME="httpclient-4.5.12" MODULE="httpclient-4.5.12.jar" MVN="mvn:org.apache.httpcomponents/httpclient/4.5.12" REQUIRED="true" />
|
||||
<IMPORT NAME="httpcore-4.4.13" MODULE="httpcore-4.4.13.jar" MVN="mvn:org.apache.httpcomponents/httpcore/4.4.13" REQUIRED="true" />
|
||||
<IMPORT NAME="commons-codec-1.14" MODULE="commons-codec-1.14.jar" MVN="mvn:commons-codec/commons-codec/1.14" REQUIRED="true" />
|
||||
<IMPORT NAME="google-cloud-bigquery-1.60.0.jar" MODULE="google-cloud-bigquery-1.60.0.jar" MVN="mvn:com.google.cloud/google-cloud-bigquery/1.60.0" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="google-http-client-jackson-1.25.0.jar" MODULE="google-http-client-jackson-1.25.0.jar" MVN="mvn:com.google.http-client/google-http-client-jackson/1.25.0" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="threetenbp-1.3.3.jar" MODULE="threetenbp-1.3.3.jar" MVN="mvn:org.threeten/threetenbp/1.3.3" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="google-auth-library-credentials-0.20.0.jar" MODULE="google-auth-library-credentials-0.20.0.jar" MVN="mvn:com.google.auth/google-auth-library-credentials/0.20.0" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="gax-httpjson-0.44.0.jar" MODULE="gax-httpjson-0.44.0.jar" MVN="mvn:com.google.api/gax-httpjson/0.44.0" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="jackson-core-asl-1.9.13.jar" MODULE="jackson-core-asl-1.9.13.jar" MVN="mvn:org.codehaus.jackson/jackson-core-asl/1.9.13" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="google-auth-library-oauth2-http-0.20.0.jar" MODULE="google-auth-library-oauth2-http-0.20.0.jar" MVN="mvn:com.google.auth/google-auth-library-oauth2-http/0.20.0" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="google-cloud-core-1.93.4.jar" MODULE="google-cloud-core-1.93.4.jar" MVN="mvn:com.google.cloud/google-cloud-core/1.93.4" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="google-cloud-core-http-1.32.0.jar" MODULE="google-cloud-core-http-1.32.0.jar" MVN="mvn:com.google.cloud/google-cloud-core-http/1.32.0" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="gax-1.27.0.jar" MODULE="gax-1.27.0.jar" MVN="mvn:com.google.api/gax/1.27.0" REQUIRED_IF="(AUTH_MODE == 'SERVICEACCOUNT') OR (AUTH_TYPE == 'GS_SERVICE_ACCOUNT')" />
|
||||
<IMPORT NAME="google-http-client-appengine-1.25.0.jar" MODULE="google-http-client-appengine-1.25.0.jar" MVN="mvn:com.google.http-client/google-http-client-appengine/1.25.0" REQUIRED_IF="(AUTH_MODE == 'SERVICEACCOUNT') OR (AUTH_TYPE == 'GS_SERVICE_ACCOUNT')" />
|
||||
<IMPORT NAME="api-common-1.6.0.jar" MODULE="api-common-1.6.0.jar" MVN="mvn:com.google.api/api-common/1.6.0" REQUIRED_IF="(AUTH_MODE == 'SERVICEACCOUNT') OR (AUTH_TYPE == 'GS_SERVICE_ACCOUNT')" />
|
||||
<IMPORT NAME="google-cloud-bigquery-1.126.3.jar" MODULE="google-cloud-bigquery-1.126.3.jar" MVN="mvn:com.google.cloud/google-cloud-bigquery/1.126.3" REQUIRED_IF="(AUTH_MODE == 'SERVICEACCOUNT') OR (AUTH_TYPE == 'GS_SERVICE_ACCOUNT') OR (AUTH_TYPE == 'TOKEN')" />
|
||||
|
||||
<!-- TODO remove it -->
|
||||
<IMPORT NAME="google-http-client-jackson-1.25.0.jar" MODULE="google-http-client-jackson-1.25.0.jar" MVN="mvn:com.google.http-client/google-http-client-jackson/1.25.0" REQUIRED_IF="(AUTH_MODE == 'SERVICEACCOUNT') OR (AUTH_TYPE == 'GS_SERVICE_ACCOUNT') OR (AUTH_TYPE == 'TOKEN')" />
|
||||
|
||||
<IMPORT NAME="threetenbp-1.3.3.jar" MODULE="threetenbp-1.3.3.jar" MVN="mvn:org.threeten/threetenbp/1.3.3" REQUIRED_IF="(AUTH_MODE == 'SERVICEACCOUNT') OR (AUTH_TYPE == 'GS_SERVICE_ACCOUNT') OR (AUTH_TYPE == 'TOKEN')" />
|
||||
<IMPORT NAME="google-auth-library-credentials-0.20.0.jar" MODULE="google-auth-library-credentials-0.20.0.jar" MVN="mvn:com.google.auth/google-auth-library-credentials/0.20.0" REQUIRED_IF="(AUTH_MODE == 'SERVICEACCOUNT') OR (AUTH_TYPE == 'GS_SERVICE_ACCOUNT') OR (AUTH_TYPE == 'TOKEN')" />
|
||||
<IMPORT NAME="gax-httpjson-0.44.0.jar" MODULE="gax-httpjson-0.44.0.jar" MVN="mvn:com.google.api/gax-httpjson/0.44.0" REQUIRED_IF="(AUTH_MODE == 'SERVICEACCOUNT') OR (AUTH_TYPE == 'GS_SERVICE_ACCOUNT') OR (AUTH_TYPE == 'TOKEN')" />
|
||||
<IMPORT NAME="jackson-core-asl-1.9.13.jar" MODULE="jackson-core-asl-1.9.13.jar" MVN="mvn:org.codehaus.jackson/jackson-core-asl/1.9.13" REQUIRED_IF="(AUTH_MODE == 'SERVICEACCOUNT') OR (AUTH_TYPE == 'GS_SERVICE_ACCOUNT') OR (AUTH_TYPE == 'TOKEN')" />
|
||||
<IMPORT NAME="google-auth-library-oauth2-http-0.20.0.jar" MODULE="google-auth-library-oauth2-http-0.20.0.jar" MVN="mvn:com.google.auth/google-auth-library-oauth2-http/0.20.0" REQUIRED_IF="(AUTH_MODE == 'SERVICEACCOUNT') OR (AUTH_TYPE == 'GS_SERVICE_ACCOUNT') OR (AUTH_TYPE == 'TOKEN')" />
|
||||
<IMPORT NAME="google-cloud-core-1.93.4.jar" MODULE="google-cloud-core-1.93.4.jar" MVN="mvn:com.google.cloud/google-cloud-core/1.93.4" REQUIRED_IF="(AUTH_MODE == 'SERVICEACCOUNT') OR (AUTH_TYPE == 'GS_SERVICE_ACCOUNT') OR (AUTH_TYPE == 'TOKEN')" />
|
||||
<IMPORT NAME="google-cloud-core-http-1.32.0.jar" MODULE="google-cloud-core-http-1.32.0.jar" MVN="mvn:com.google.cloud/google-cloud-core-http/1.32.0" REQUIRED_IF="(AUTH_MODE == 'SERVICEACCOUNT') OR (AUTH_TYPE == 'GS_SERVICE_ACCOUNT') OR (AUTH_TYPE == 'TOKEN')" />
|
||||
<IMPORT NAME="gax-1.27.0.jar" MODULE="gax-1.27.0.jar" MVN="mvn:com.google.api/gax/1.27.0" REQUIRED_IF="(AUTH_MODE == 'SERVICEACCOUNT') OR (AUTH_TYPE == 'GS_SERVICE_ACCOUNT') OR (AUTH_TYPE == 'TOKEN')" />
|
||||
<IMPORT NAME="google-http-client-appengine-1.38.0.jar" MODULE="google-http-client-appengine-1.38.0.jar" MVN="mvn:com.google.http-client/google-http-client-appengine/1.38.0" REQUIRED_IF="(AUTH_MODE == 'SERVICEACCOUNT') OR (AUTH_TYPE == 'GS_SERVICE_ACCOUNT') OR (AUTH_TYPE == 'TOKEN')" />
|
||||
<IMPORT NAME="api-common-1.6.0.jar" MODULE="api-common-1.6.0.jar" MVN="mvn:com.google.api/api-common/1.6.0" REQUIRED_IF="(AUTH_MODE == 'SERVICEACCOUNT') OR (AUTH_TYPE == 'GS_SERVICE_ACCOUNT') OR (AUTH_TYPE == 'TOKEN')" />
|
||||
|
||||
<IMPORT NAME="google-cloud-storage-1.104.0" MODULE="google-cloud-storage-1.104.0.jar" MVN="mvn:com.google.cloud/google-cloud-storage/1.104.0" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT')" />
|
||||
<IMPORT NAME="google-cloud-storage-1.104.0" MODULE="google-cloud-storage-1.104.0.jar" MVN="mvn:com.google.cloud/google-cloud-storage/1.104.0" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT') OR (AUTH_TYPE == 'TOKEN')" />
|
||||
<!-- Transitive dependencies of google-cloud-storage -->
|
||||
<IMPORT NAME="google-api-services-storage-v1-rev20191011-1.30.3" MODULE="google-api-services-storage-v1-rev20191011-1.30.3.jar" MVN="mvn:com.google.apis/google-api-services-storage/v1-rev20191011-1.30.3" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT')" />
|
||||
<IMPORT NAME="gson-2.8.6" MODULE="gson-2.8.6.jar" MVN="mvn:com.google.code.gson/gson/2.8.6" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT')" />
|
||||
<IMPORT NAME="javax.annotation-api" MODULE="javax.annotation-api-1.3.jar" MVN="mvn:javax.annotation/javax.annotation-api/1.3" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT')" />
|
||||
<IMPORT NAME="protobuf-java-2.5.0" MODULE="protobuf-java-2.5.0.jar" MVN="mvn:com.google.protobuf/protobuf-java/2.5.0" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT')" />
|
||||
<IMPORT NAME="error_prone_annotation-2.1.3" MODULE="error_prone_annotation-2.1.3.jar" MVN="mvn:com.google.errorprone/error_prone_annotations/2.1.3" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT')" />
|
||||
<IMPORT NAME="opencensus-api-0.21.0" MODULE="opencensus-api-0.21.0.jar" MVN="mvn:io.opencensus/opencensus-api/0.21.0" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT')" />
|
||||
<IMPORT NAME="opencensus-contrib-http-util-0.21.0" MODULE="opencensus-contrib-http-util-0.21.0.jar" MVN="mvn:io.opencensus/opencensus-contrib-http-util/0.21.0" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT')" />
|
||||
<IMPORT NAME="grpc-context-1.19.0" MODULE="grpc-context-1.19.0.jar" MVN="mvn:io.grpc/grpc-context/1.19.0" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT')" />
|
||||
<IMPORT NAME="proto-google-common-protos-1.17.0" MODULE="proto-google-common-protos-1.17.0.jar" MVN="mvn:com.google.api.grpc/proto-google-common-protos/1.17.0" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT')" />
|
||||
<IMPORT NAME="proto-google-iam-v1-0.13.0" MODULE="proto-google-iam-v1-0.13.0.jar" MVN="mvn:com.google.api.grpc/proto-google-iam-v1/0.13.0" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT')" />
|
||||
<IMPORT NAME="protobuf-java-util-3.11.4" MODULE="protobuf-java-util-3.11.4.jar" MVN="mvn:com.google.protobuf/protobuf-java-util/3.11.4" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT')" />
|
||||
<IMPORT NAME="annotation-1.1.0" MODULE="annotation-1.1.0.jar" MVN="mvn:androidx.annotation/annotation/1.1.0" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT')" />
|
||||
<IMPORT NAME="google-api-services-storage-v1-rev20201112-1.31.0" MODULE="google-api-services-storage-v1-rev20201112-1.31.0.jar" MVN="mvn:com.google.apis/google-api-services-storage/v1-rev20201112-1.31.0" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT') OR (AUTH_TYPE == 'TOKEN')" />
|
||||
<IMPORT NAME="gson-2.8.6" MODULE="gson-2.8.6.jar" MVN="mvn:com.google.code.gson/gson/2.8.6" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT') OR (AUTH_TYPE == 'TOKEN')" />
|
||||
<IMPORT NAME="javax.annotation-api" MODULE="javax.annotation-api-1.3.jar" MVN="mvn:javax.annotation/javax.annotation-api/1.3" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT') OR (AUTH_TYPE == 'TOKEN')" />
|
||||
<IMPORT NAME="protobuf-java-2.5.0" MODULE="protobuf-java-2.5.0.jar" MVN="mvn:com.google.protobuf/protobuf-java/2.5.0" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT') OR (AUTH_TYPE == 'TOKEN')" />
|
||||
<IMPORT NAME="error_prone_annotation-2.1.3" MODULE="error_prone_annotation-2.1.3.jar" MVN="mvn:com.google.errorprone/error_prone_annotations/2.1.3" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT') OR (AUTH_TYPE == 'TOKEN')" />
|
||||
<IMPORT NAME="opencensus-api-0.24.0" MODULE="opencensus-api-0.24.0.jar" MVN="mvn:io.opencensus/opencensus-api/0.24.0" REQUIRED="true" />
|
||||
<IMPORT NAME="opencensus-contrib-http-util-0.24.0" MODULE="opencensus-contrib-http-util-0.24.0.jar" MVN="mvn:io.opencensus/opencensus-contrib-http-util/0.24.0" REQUIRED="true" />
|
||||
<IMPORT NAME="grpc-context-1.22.1" MODULE="grpc-context-1.22.1.jar" MVN="mvn:io.grpc/grpc-context/1.22.1" REQUIRED="true" />
|
||||
<IMPORT NAME="proto-google-common-protos-1.17.0" MODULE="proto-google-common-protos-1.17.0.jar" MVN="mvn:com.google.api.grpc/proto-google-common-protos/1.17.0" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT') OR (AUTH_TYPE == 'TOKEN')" />
|
||||
<IMPORT NAME="proto-google-iam-v1-0.13.0" MODULE="proto-google-iam-v1-0.13.0.jar" MVN="mvn:com.google.api.grpc/proto-google-iam-v1/0.13.0" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT') OR (AUTH_TYPE == 'TOKEN')" />
|
||||
<IMPORT NAME="protobuf-java-util-3.11.4" MODULE="protobuf-java-util-3.11.4.jar" MVN="mvn:com.google.protobuf/protobuf-java-util/3.11.4" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT') OR (AUTH_TYPE == 'TOKEN')" />
|
||||
<IMPORT NAME="annotation-1.1.0" MODULE="annotation-1.1.0.jar" MVN="mvn:androidx.annotation/annotation/1.1.0" REQUIRED_IF="(AUTH_TYPE == 'GS_SERVICE_ACCOUNT') OR (AUTH_TYPE == 'TOKEN')" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
<RETURNS>
|
||||
|
||||
@@ -8,11 +8,13 @@ SERVICE_ACCOUNT_CREDENTIALS_FILE.NAME=Service account credentials file
|
||||
AUTH_MODE.NAME=Authentication mode
|
||||
AUTH_MODE.ITEM.SERVICEACCOUNT=Service account
|
||||
AUTH_MODE.ITEM.OAUTH=OAuth 2.0
|
||||
AUTH_MODE.ITEM.TOKEN=OAuth Access Token
|
||||
|
||||
CLIENT_ID.NAME=Client Id
|
||||
CLIENT_SECRET.NAME=Client Secret
|
||||
PROJECT_ID.NAME=Project ID
|
||||
AUTHORIZATION_CODE.NAME=Authorization Code
|
||||
ACCESS_TOKEN.NAME=OAuth Access Token
|
||||
|
||||
SCHEMA.NAME=Schema
|
||||
|
||||
@@ -50,3 +52,6 @@ AUTH_TYPE.NAME=Credential type
|
||||
AUTH_TYPE.ITEM.USER_ACCOUNT_HMAC=HMAC key (deprecated)
|
||||
AUTH_TYPE.ITEM.GS_SERVICE_ACCOUNT=Service account
|
||||
GS_SERVICE_ACCOUNT_KEY.NAME=Service account key
|
||||
|
||||
GS_ACCESS_TOKEN.NAME=OAuth Access Token
|
||||
AUTH_TYPE.ITEM.TOKEN=OAuth Access Token
|
||||
@@ -6,24 +6,31 @@
|
||||
|
||||
class BigQueryUtil_<%=cid%> {
|
||||
String projectId;
|
||||
|
||||
|
||||
<%=basePackage%>com.google.api.services.bigquery.Bigquery bigqueryclient = null;
|
||||
<%=basePackage%>com.google.api.client.auth.oauth2.Credential credentials = null;
|
||||
String tokenFile;
|
||||
boolean useLargeResult = false;
|
||||
String tempDataset;
|
||||
String tempTable;
|
||||
final boolean isAutoGeneratedTemporaryDataset;
|
||||
|
||||
|
||||
public BigQueryUtil_<%=cid%>(String projectId, <%=basePackage%>com.google.api.services.bigquery.Bigquery bigqueryclient, String tokenFile) {
|
||||
this (projectId, bigqueryclient, tokenFile, null);
|
||||
this (projectId, bigqueryclient, tokenFile, null, null);
|
||||
}
|
||||
|
||||
public BigQueryUtil_<%=cid%>(String projectId, <%=basePackage%>com.google.api.services.bigquery.Bigquery bigqueryclient, String tokenFile, String tempDataset) {
|
||||
public BigQueryUtil_<%=cid%>(String projectId, <%=basePackage%>com.google.api.services.bigquery.Bigquery bigqueryclient, String tokenFile, String tempDataset) {
|
||||
this (projectId, bigqueryclient, tokenFile, tempDataset, null);
|
||||
}
|
||||
|
||||
public BigQueryUtil_<%=cid%>(String projectId, <%=basePackage%>com.google.api.services.bigquery.Bigquery bigqueryclient, String tokenFile, String tempDataset,
|
||||
<%=basePackage%>com.google.api.client.auth.oauth2.Credential credentials) {
|
||||
this.projectId = projectId;
|
||||
this.bigqueryclient = bigqueryclient;
|
||||
this.tokenFile = tokenFile;
|
||||
this.tempDataset = tempDataset;
|
||||
this.isAutoGeneratedTemporaryDataset = tempDataset == null;
|
||||
this.credentials = credentials;
|
||||
}
|
||||
|
||||
private String genTempName(String prefix){
|
||||
@@ -32,13 +39,21 @@ class BigQueryUtil_<%=cid%> {
|
||||
|
||||
public void cleanup() throws Exception{
|
||||
if(useLargeResult){
|
||||
<% if(authMode.equals("TOKEN") && !ElementParameterParser.canEncrypt(node, "__ACCESS_TOKEN__")) { %>
|
||||
if (credentials !=null)
|
||||
credentials.setAccessToken(<%= ElementParameterParser.getValue(node, "__ACCESS_TOKEN__")%>);
|
||||
<% } %>
|
||||
bigqueryclient.tables().delete(projectId, tempDataset, tempTable).execute();
|
||||
if (isAutoGeneratedTemporaryDataset) {
|
||||
<% if(authMode.equals("TOKEN") && !ElementParameterParser.canEncrypt(node, "__ACCESS_TOKEN__")) { %>
|
||||
if (credentials !=null)
|
||||
credentials.setAccessToken(<%= ElementParameterParser.getValue(node, "__ACCESS_TOKEN__")%>);
|
||||
<% } %>
|
||||
bigqueryclient.datasets().delete(projectId, tempDataset).execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String getLocation(<%=basePackage%>com.google.api.services.bigquery.model.JobConfigurationQuery queryConfig) throws Exception {
|
||||
String location = null;
|
||||
<%=basePackage%>com.google.api.services.bigquery.model.JobConfiguration config = new <%=basePackage%>com.google.api.services.bigquery.model.JobConfiguration();
|
||||
@@ -46,6 +61,10 @@ class BigQueryUtil_<%=cid%> {
|
||||
config.setDryRun(true);
|
||||
<%=basePackage%>com.google.api.services.bigquery.model.Job job = new <%=basePackage%>com.google.api.services.bigquery.model.Job();
|
||||
job.setConfiguration(config);
|
||||
<% if(authMode.equals("TOKEN") && !ElementParameterParser.canEncrypt(node, "__ACCESS_TOKEN__")) { %>
|
||||
if (credentials !=null)
|
||||
credentials.setAccessToken(<%= ElementParameterParser.getValue(node, "__ACCESS_TOKEN__")%>);
|
||||
<% } %>
|
||||
location = bigqueryclient.jobs().insert(projectId, job).execute().getJobReference().getLocation();
|
||||
location = location == null ? "US" : location;
|
||||
return location;
|
||||
@@ -59,13 +78,17 @@ class BigQueryUtil_<%=cid%> {
|
||||
String description = "Dataset for BigQuery query job temporary table";
|
||||
dataset.setFriendlyName(description);
|
||||
dataset.setDescription(description);
|
||||
<% if(authMode.equals("TOKEN") && !ElementParameterParser.canEncrypt(node, "__ACCESS_TOKEN__")) { %>
|
||||
if (credentials !=null)
|
||||
credentials.setAccessToken(<%= ElementParameterParser.getValue(node, "__ACCESS_TOKEN__")%>);
|
||||
<% } %>
|
||||
bigqueryclient.datasets().insert(projectId, dataset).execute();
|
||||
}
|
||||
|
||||
|
||||
public <%=basePackage%>com.google.api.services.bigquery.model.Job executeQuery(String query, boolean useLargeResult) throws Exception{
|
||||
return executeQuery(query, useLargeResult, true);
|
||||
}
|
||||
|
||||
|
||||
public <%=basePackage%>com.google.api.services.bigquery.model.Job executeQuery(String query, boolean useLargeResult, boolean useLegacySql) throws Exception{
|
||||
<%=basePackage%>com.google.api.services.bigquery.model.JobConfigurationQuery queryConfig = new <%=basePackage%>com.google.api.services.bigquery.model.JobConfigurationQuery();
|
||||
queryConfig.setQuery(query);
|
||||
@@ -84,16 +107,20 @@ class BigQueryUtil_<%=cid%> {
|
||||
.setDatasetId(tempDataset)
|
||||
.setTableId(tempTable));
|
||||
}
|
||||
|
||||
|
||||
<%=basePackage%>com.google.api.services.bigquery.model.JobConfiguration config = new <%=basePackage%>com.google.api.services.bigquery.model.JobConfiguration();
|
||||
config.setQuery(queryConfig);
|
||||
|
||||
|
||||
<%=basePackage%>com.google.api.services.bigquery.model.Job job = new <%=basePackage%>com.google.api.services.bigquery.model.Job();
|
||||
job.setConfiguration(config);
|
||||
|
||||
|
||||
<%=basePackage%>com.google.api.services.bigquery.model.Job insert = null;
|
||||
<%=basePackage%>com.google.api.services.bigquery.model.JobReference jobId = null;
|
||||
try {
|
||||
<% if(authMode.equals("TOKEN") && !ElementParameterParser.canEncrypt(node, "__ACCESS_TOKEN__")) { %>
|
||||
if (credentials !=null)
|
||||
credentials.setAccessToken(<%= ElementParameterParser.getValue(node, "__ACCESS_TOKEN__")%>);
|
||||
<% } %>
|
||||
insert = bigqueryclient.jobs().insert(projectId, job).execute();
|
||||
jobId = insert.getJobReference();
|
||||
} catch (<%=basePackage%>com.google.api.client.googleapis.json.GoogleJsonResponseException e) {
|
||||
@@ -142,7 +169,10 @@ class BigQueryUtil_<%=cid%> {
|
||||
%>
|
||||
// wait for query execution
|
||||
while (true) {
|
||||
|
||||
<% if(authMode.equals("TOKEN") && !ElementParameterParser.canEncrypt(node, "__ACCESS_TOKEN__")) { %>
|
||||
if (credentials !=null)
|
||||
credentials.setAccessToken(<%= ElementParameterParser.getValue(node, "__ACCESS_TOKEN__")%>);
|
||||
<% } %>
|
||||
<%
|
||||
if("".equals(basePackage)) {
|
||||
%>
|
||||
@@ -154,7 +184,7 @@ class BigQueryUtil_<%=cid%> {
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
|
||||
<%=basePackage%>com.google.api.services.bigquery.model.JobStatus status = pollJob.getStatus();
|
||||
if (status.getState().equals("DONE")) {
|
||||
<%=basePackage%>com.google.api.services.bigquery.model.ErrorProto errorProto = status.getErrorResult();
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
String basePackage = "";
|
||||
boolean isCustomTemporaryName = ElementParameterParser.getBooleanValue(node,"__USE_CUSTOM_TEMPORARY_DATASET__");
|
||||
String tempDataset = ElementParameterParser.getValue(node,"__TEMPORARY_DATASET_NAME__");
|
||||
|
||||
|
||||
String encoding = ElementParameterParser.getValue(node,"__ENCODING__");
|
||||
String advancedSeparatorStr = ElementParameterParser.getValue(node, "__ADVANCED_SEPARATOR__");
|
||||
boolean advancedSeparator = (advancedSeparatorStr!=null&&!("").equals(advancedSeparatorStr))?("true").equals(advancedSeparatorStr):false;
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
String tokenFile = ElementParameterParser.getValue(node,"__TOKEN_NAME__");
|
||||
boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
|
||||
|
||||
|
||||
//Dynamic start
|
||||
List<IMetadataTable> metadatas = node.getMetadataList();
|
||||
int sizeListColumns = 0;
|
||||
@@ -59,11 +59,20 @@
|
||||
}
|
||||
}
|
||||
int dynamic_index=-1;
|
||||
|
||||
|
||||
//Dynamic end
|
||||
|
||||
|
||||
if (authMode.equals("OAUTH")) {
|
||||
|
||||
|
||||
if (authMode.equals("OAUTH") || authMode.equals("TOKEN") ) {
|
||||
%>
|
||||
final String PROJECT_ID_<%=cid %> = <%=projectId %>;
|
||||
com.google.api.services.bigquery.Bigquery bigqueryclient_<%=cid%> = null;
|
||||
com.google.api.client.auth.oauth2.Credential credential_<%=cid%> = null;
|
||||
long nb_line_<%=cid%> = 0;
|
||||
final com.google.api.client.http.HttpTransport TRANSPORT_<%=cid %> = new com.google.api.client.http.javanet.NetHttpTransport();
|
||||
final com.google.api.client.json.JsonFactory JSON_FACTORY_<%=cid %> = new com.google.api.client.json.jackson2.JacksonFactory();
|
||||
<%
|
||||
if (authMode.equals("OAUTH")) {
|
||||
%>
|
||||
final String CLIENT_ID_<%=cid %> = <%=clientId %>;
|
||||
<%
|
||||
@@ -73,21 +82,17 @@
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/password.javajet"%>
|
||||
|
||||
final String CLIENT_SECRET_<%=cid%> = "{\"web\": {\"client_id\": \""+<%=clientId%>+"\",\"client_secret\": \"" +decryptedPassword_<%=cid%>+ "\",\"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\"token_uri\": \"https://accounts.google.com/o/oauth2/token\"}}";
|
||||
final String PROJECT_ID_<%=cid %> = <%=projectId %>;
|
||||
|
||||
// Static variables for API scope, callback URI, and HTTP/JSON functions
|
||||
final List<String> SCOPES_<%=cid%> = java.util.Arrays.asList("https://www.googleapis.com/auth/bigquery");
|
||||
final String REDIRECT_URI_<%=cid%> = "urn:ietf:wg:oauth:2.0:oob";
|
||||
final com.google.api.client.http.HttpTransport TRANSPORT_<%=cid %> = new com.google.api.client.http.javanet.NetHttpTransport();
|
||||
final com.google.api.client.json.JsonFactory JSON_FACTORY_<%=cid %> = new com.google.api.client.json.jackson2.JacksonFactory();
|
||||
|
||||
com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets clientSecrets_<%=cid%> = com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets.load(
|
||||
new com.google.api.client.json.jackson2.JacksonFactory(), new java.io.InputStreamReader(new java.io.ByteArrayInputStream(
|
||||
CLIENT_SECRET_<%=cid%>.getBytes())));
|
||||
|
||||
com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow flow_<%=cid%> = null;
|
||||
com.google.api.services.bigquery.Bigquery bigqueryclient_<%=cid%> = null;
|
||||
long nb_line_<%=cid%> = 0;
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
@@ -129,7 +134,7 @@
|
||||
// access token.
|
||||
if (storedRefreshToken_<%=cid%> != null) {
|
||||
// Request a new Access token using the refresh token.
|
||||
com.google.api.client.googleapis.auth.oauth2.GoogleCredential credential_<%=cid%> = new com.google.api.client.googleapis.auth.oauth2.GoogleCredential.Builder().setTransport(TRANSPORT_<%=cid%>)
|
||||
credential_<%=cid%> = new com.google.api.client.googleapis.auth.oauth2.GoogleCredential.Builder().setTransport(TRANSPORT_<%=cid%>)
|
||||
.setJsonFactory(JSON_FACTORY_<%=cid%>).setClientSecrets(clientSecrets_<%=cid%>)
|
||||
.build().setFromTokenResponse(new com.google.api.client.auth.oauth2.TokenResponse().setRefreshToken(storedRefreshToken_<%=cid%>));
|
||||
|
||||
@@ -141,7 +146,6 @@
|
||||
<%
|
||||
}
|
||||
%>
|
||||
bigqueryclient_<%=cid%> = new com.google.api.services.bigquery.Bigquery.Builder(new com.google.api.client.http.javanet.NetHttpTransport(),new com.google.api.client.json.jackson2.JacksonFactory(),credential_<%=cid%>).setApplicationName("Talend").build();
|
||||
} else {
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
@@ -183,7 +187,7 @@
|
||||
.build();
|
||||
}
|
||||
com.google.api.client.googleapis.auth.oauth2.GoogleTokenResponse response_<%=cid%> = flow_<%=cid%>.newTokenRequest(authorizationCode_<%=cid%>).setRedirectUri(REDIRECT_URI_<%=cid%>).execute();
|
||||
com.google.api.client.auth.oauth2.Credential credential_<%=cid%> = flow_<%=cid%>.createAndStoreCredential(response_<%=cid%>, null);
|
||||
credential_<%=cid%> = flow_<%=cid%>.createAndStoreCredential(response_<%=cid%>, null);
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
@@ -195,17 +199,25 @@
|
||||
// Store the refresh token for future use.
|
||||
java.util.Properties storeProperties_<%=cid%> = new java.util.Properties();
|
||||
storeProperties_<%=cid%>.setProperty("refreshtoken", credential_<%=cid%>.getRefreshToken());
|
||||
java.io.FileOutputStream outputStream_<%=cid%> = new java.io.FileOutputStream(tokenFile_<%=cid %>);
|
||||
storeProperties_<%=cid%>.store(outputStream_<%=cid%>,null);
|
||||
if (outputStream_<%=cid%> != null) {
|
||||
outputStream_<%=cid%>.close();
|
||||
}
|
||||
|
||||
bigqueryclient_<%=cid%> = new com.google.api.services.bigquery.Bigquery.Builder(new com.google.api.client.http.javanet.NetHttpTransport(),new com.google.api.client.json.jackson2.JacksonFactory(),credential_<%=cid%>).build();
|
||||
try (java.io.FileOutputStream outputStream_<%=cid%> = new java.io.FileOutputStream(tokenFile_<%=cid %>)) {
|
||||
storeProperties_<%=cid%>.store(outputStream_<%=cid%>,null);
|
||||
}
|
||||
}
|
||||
}
|
||||
<%} else {
|
||||
|
||||
|
||||
if (ElementParameterParser.canEncrypt(node, "__ACCESS_TOKEN__")) {%>
|
||||
final String decryptedAccessToken_<%=cid%> = routines.system.PasswordEncryptUtil.decryptPassword(<%=ElementParameterParser.getEncryptedValue(node, "__ACCESS_TOKEN__")%>);
|
||||
credential_<%=cid%> =
|
||||
new com.google.api.client.auth.oauth2.Credential(com.google.api.client.auth.oauth2.BearerToken.authorizationHeaderAccessMethod()).setFromTokenResponse(
|
||||
(new com.google.api.client.auth.oauth2.TokenResponse()).setAccessToken(decryptedAccessToken_<%=cid%>));
|
||||
<%} else {%>
|
||||
credential_<%=cid%> =
|
||||
new com.google.api.client.auth.oauth2.Credential(com.google.api.client.auth.oauth2.BearerToken.authorizationHeaderAccessMethod()).setFromTokenResponse(
|
||||
(new com.google.api.client.auth.oauth2.TokenResponse()).setAccessToken(<%= ElementParameterParser.getValue(node, "__ACCESS_TOKEN__")%>));
|
||||
<%}
|
||||
} %>
|
||||
bigqueryclient_<%=cid%> = new com.google.api.services.bigquery.Bigquery.Builder(TRANSPORT_<%=cid %>, JSON_FACTORY_<%=cid %>,credential_<%=cid%>).setApplicationName("Talend").build();
|
||||
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/tBigQueryInput/BigQueryInputQueryHelper.javajet"%>
|
||||
|
||||
@@ -218,11 +230,12 @@
|
||||
log.debug("<%=cid%> - Running Query: "+querySql_<%=cid %>);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
if (authMode.equals("OAUTH")) { %>
|
||||
BigQueryUtil_<%=cid%> bigQueryUtil_<%=cid%> = new BigQueryUtil_<%=cid%>(PROJECT_ID_<%=cid%>, bigqueryclient_<%=cid%>, tokenFile_<%=cid%><% if (isCustomTemporaryName) {%>, <%=tempDataset%> <%} %>);
|
||||
<%} else {%>
|
||||
BigQueryUtil_<%=cid%> bigQueryUtil_<%=cid%> = new BigQueryUtil_<%=cid%>(PROJECT_ID_<%=cid%>, bigqueryclient_<%=cid%>, null, <% if (isCustomTemporaryName) {%><%=tempDataset%> <%} else {%>null<% } %>, credential_<%=cid%>);
|
||||
<%}
|
||||
|
||||
BigQueryUtil_<%=cid%> bigQueryUtil_<%=cid%> = new BigQueryUtil_<%=cid%>(PROJECT_ID_<%=cid%>, bigqueryclient_<%=cid%>, tokenFile_<%=cid%><% if (isCustomTemporaryName) {%>, <%=tempDataset%> <%} %>);
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
log.info("<%=cid%> - Try <%="LARGE".equals(resultSizeType) ? "with" : "without"%> the allowLargeResults flag");
|
||||
@@ -242,15 +255,17 @@
|
||||
//Dynamic start
|
||||
|
||||
<%
|
||||
|
||||
if(isDynamic){
|
||||
%>
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/Input/BigQuery/BigQueryHelper_Oauth.javajet"%>
|
||||
BigQueryHelper_<%=cid%> helper_<%=cid%> = new BigQueryHelper_<%=cid%>();
|
||||
<% if(authMode.equals("TOKEN") && !ElementParameterParser.canEncrypt(node, "__ACCESS_TOKEN__")) { %>
|
||||
credential_<%=cid%>.setAccessToken(<%= ElementParameterParser.getValue(node, "__ACCESS_TOKEN__")%>);
|
||||
<% } %>
|
||||
com.google.api.services.bigquery.model.TableSchema schema_<%=cid%> = bigqueryclient_<%=cid%>
|
||||
.jobs().getQueryResults(PROJECT_ID_<%=cid%>, insert_<%=cid%>.getJobReference().getJobId()).execute().getSchema();
|
||||
routines.system.Dynamic dcg_<%=cid%> = new routines.system.Dynamic();
|
||||
|
||||
|
||||
<%
|
||||
|
||||
for(int i=0; i< columnList.size(); i++) {
|
||||
@@ -272,7 +287,7 @@
|
||||
dcg_<%=cid%>.metadatas.add(dynamicMetadata_<%=cid%>);
|
||||
}
|
||||
<%
|
||||
|
||||
|
||||
}
|
||||
%>
|
||||
//Dynamic end
|
||||
@@ -375,14 +390,14 @@
|
||||
//Dynamic start
|
||||
|
||||
<%
|
||||
|
||||
|
||||
if(isDynamic){
|
||||
%>
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/DB/Input/BigQuery/BigQueryHelper_ServiceAccount.javajet"%>
|
||||
BigQueryHelper_<%=cid%> helper_<%=cid%> = new BigQueryHelper_<%=cid%>();
|
||||
com.google.cloud.bigquery.Schema schema_<%=cid%> = result_<%=cid%>.getSchema();
|
||||
routines.system.Dynamic dcg_<%=cid%> = new routines.system.Dynamic();
|
||||
|
||||
|
||||
<%
|
||||
|
||||
for(int i=0; i< columnList.size(); i++) {
|
||||
@@ -411,21 +426,24 @@
|
||||
dcg_<%=cid%>.metadatas.add(dynamicMetadata_<%=cid%>);
|
||||
}
|
||||
<%
|
||||
|
||||
|
||||
}
|
||||
%>
|
||||
//Dynamic end
|
||||
long nb_line_<%=cid%> = 0;
|
||||
<%
|
||||
} else {
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\" or \"OAUTH\", but it is " + authMode);
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\", \"OAUTH\" or \"TOKEN\", but it is " + authMode);
|
||||
}
|
||||
|
||||
|
||||
if (authMode.equals("OAUTH")) {
|
||||
if (authMode.equals("OAUTH") || authMode.equals("TOKEN")) {
|
||||
%>
|
||||
while (true) {
|
||||
// Fetch Results
|
||||
<% if(authMode.equals("TOKEN") && !ElementParameterParser.canEncrypt(node, "__ACCESS_TOKEN__")) { %>
|
||||
credential_<%=cid%>.setAccessToken(<%= ElementParameterParser.getValue(node, "__ACCESS_TOKEN__")%>);
|
||||
<% } %>
|
||||
com.google.api.services.bigquery.model.TableDataList dataList_<%=cid %> = bigqueryclient_<%=cid%>.tabledata()
|
||||
.list(PROJECT_ID_<%=cid %>,
|
||||
insert_<%=cid %>.getConfiguration().getQuery()
|
||||
@@ -452,7 +470,7 @@
|
||||
nb_line_<%=cid%> ++;
|
||||
<%
|
||||
} else {
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\" or \"OAUTH\", but it is " + authMode);
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\", \"OAUTH\" or \"TOKEN\", but it is " + authMode);
|
||||
}
|
||||
%>
|
||||
int fieldsCount_<%=cid %> = field_<%=cid %>.size();
|
||||
@@ -466,8 +484,8 @@
|
||||
IConnection conn =conns.get(0);
|
||||
String connName = conn.getName();
|
||||
if (conn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
|
||||
|
||||
|
||||
|
||||
|
||||
if ((metadatas!=null) && (metadatas.size() > 0)) {
|
||||
IMetadataTable metadata = metadatas.get(0);
|
||||
if (metadata != null) {
|
||||
@@ -500,7 +518,7 @@
|
||||
<%=connName%>.<%=column.getLabel()%> = <%=defVal%>;
|
||||
} else {
|
||||
<%
|
||||
if (authMode.equals("OAUTH")) {
|
||||
if (authMode.equals("OAUTH") || authMode.equals("TOKEN")) {
|
||||
%>
|
||||
value_<%=cid%> = field_<%=cid %>.get(column_index_<%=cid%>).getV();
|
||||
<%
|
||||
@@ -509,7 +527,7 @@
|
||||
value_<%=cid%> = field_<%=cid %>.get(column_index_<%=cid%>).getValue();
|
||||
<%
|
||||
} else {
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\" or \"OAUTH\", but it is " + authMode);
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\", \"OAUTH\" or \"TOKEN\", but it is " + authMode);
|
||||
}
|
||||
%>
|
||||
if(com.google.api.client.util.Data.isNull(value_<%=cid%>)) value_<%=cid%> = null;
|
||||
|
||||
@@ -15,7 +15,7 @@ imports="
|
||||
String resultSizeType = ElementParameterParser.getValue(node,"__RESULT_SIZE__");
|
||||
boolean isCustomTemporaryName = ElementParameterParser.getBooleanValue(node,"__USE_CUSTOM_TEMPORARY_DATASET__");
|
||||
|
||||
if (authMode.equals("OAUTH")) {
|
||||
if (authMode.equals("OAUTH") || authMode.equals("TOKEN")) {
|
||||
%>
|
||||
}
|
||||
pageToken_<%=cid%> = dataList_<%=cid %>.getPageToken();
|
||||
@@ -41,7 +41,7 @@ imports="
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\" or \"OAUTH\", but it is " + authMode);
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\" or \"OAUTH\" or \"TOKEN\", but it is " + authMode);
|
||||
}
|
||||
log4jFileUtil.retrievedDataNumberInfo(node);
|
||||
%>
|
||||
|
||||
@@ -43,21 +43,43 @@
|
||||
REQUIRED="true"
|
||||
NUM_ROW="1"
|
||||
/>
|
||||
|
||||
|
||||
<PARAMETER NAME="AUTH_MODE" FIELD="CLOSED_LIST" NUM_ROW="3" REQUIRED="true" GROUP="AUTHENTICATION" REPOSITORY_VALUE="AUTH_MODE">
|
||||
<ITEMS DEFAULT="SERVICEACCOUNT">
|
||||
<ITEM NAME="SERVICEACCOUNT" VALUE="SERVICEACCOUNT" />
|
||||
<ITEM NAME="OAUTH" VALUE="OAUTH" />
|
||||
<ITEM NAME="TOKEN" VALUE="TOKEN" />
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="SERVICE_ACCOUNT_CREDENTIALS_FILE"
|
||||
|
||||
<PARAMETER
|
||||
NAME="ACCESS_TOKEN"
|
||||
FIELD="PASSWORD"
|
||||
NUM_ROW="10"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="AUTH_MODE == 'TOKEN'"
|
||||
GROUP="AUTHENTICATION"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="ACCESS_TOKEN_WARNING"
|
||||
FIELD="LABEL"
|
||||
NUM_ROW="11"
|
||||
REQUIRED="false"
|
||||
GROUP="AUTHENTICATION"
|
||||
SHOW_IF="AUTH_MODE == 'TOKEN'"
|
||||
>
|
||||
<DEFAULT>*Note: If the Access Token Expire we won't be able to refresh it!"</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER
|
||||
NAME="SERVICE_ACCOUNT_CREDENTIALS_FILE"
|
||||
REPOSITORY_VALUE="SERVICE_ACCOUNT_CREDENTIALS_FILE"
|
||||
GROUP="AUTHENTICATION"
|
||||
FIELD="FILE"
|
||||
NUM_ROW="10"
|
||||
REQUIRED="true"
|
||||
FIELD="FILE"
|
||||
NUM_ROW="10"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="AUTH_MODE == 'SERVICEACCOUNT'"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
@@ -104,7 +126,7 @@
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
|
||||
<PARAMETER
|
||||
NAME="USE_LEGACY_SQL"
|
||||
FIELD="CHECK"
|
||||
@@ -113,7 +135,7 @@
|
||||
>
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
|
||||
<PARAMETER
|
||||
NAME="QUERY"
|
||||
FIELD="MEMO_SQL"
|
||||
@@ -122,13 +144,13 @@
|
||||
>
|
||||
<DEFAULT>"select id, name from employee"</DEFAULT>
|
||||
</PARAMETER>
|
||||
<!--
|
||||
https://cloud.google.com/bigquery/querying-data#large-results
|
||||
<!--
|
||||
https://cloud.google.com/bigquery/querying-data#large-results
|
||||
SMALL: allowLargeResult is false
|
||||
LARGE: allowLargeResult is true and auto create/clean temp dataset/table
|
||||
AUTO: try SMALL first, if get responseTooLarge error then try LARGE
|
||||
-->
|
||||
<PARAMETER
|
||||
<PARAMETER
|
||||
NAME="RESULT_SIZE"
|
||||
FIELD="CLOSED_LIST"
|
||||
NUM_ROW="60"
|
||||
@@ -179,16 +201,19 @@
|
||||
</ADVANCED_PARAMETERS>
|
||||
<CODEGENERATION>
|
||||
<IMPORTS>
|
||||
<IMPORT NAME="google-api-client-1.25.0.jar" MODULE="google-api-client-1.25.0.jar" MVN="mvn:com.google.api-client/google-api-client/1.25.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-api-services-oauth2-v2-rev151-1.25.0.jar" MODULE="google-api-services-oauth2-v2-rev151-1.25.0.jar" MVN="mvn:com.google.apis/google-api-services-oauth2/v2-rev151-1.25.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-api-services-bigquery-v2-rev454-1.25.0.jar" MODULE="google-api-services-bigquery-v2-rev454-1.25.0.jar" MVN="mvn:com.google.apis/google-api-services-bigquery/v2-rev454-1.25.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-http-client-1.25.0.jar" MODULE="google-http-client-1.25.0.jar" MVN="mvn:com.google.http-client/google-http-client/1.25.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-api-client-1.31.1.jar" MODULE="google-api-client-1.31.1.jar" MVN="mvn:com.google.api-client/google-api-client/1.31.1" REQUIRED="true" />
|
||||
<IMPORT NAME="google-api-services-oauth2-v2-rev20200213-1.31.0.jar" MODULE="google-api-services-oauth2-v2-rev20200213-1.31.0.jar" MVN="mvn:com.google.apis/google-api-services-oauth2/v2-rev20200213-1.31.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-api-services-bigquery-v2-rev20201030-1.31.0.jar" MODULE="google-api-services-bigquery-v2-rev20201030-1.31.0.jar" MVN="mvn:com.google.apis/google-api-services-bigquery/v2-rev20201030-1.31.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-http-client-1.38.0.jar" MODULE="google-http-client-1.38.0.jar" MVN="mvn:com.google.http-client/google-http-client/1.38.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-oauth-client-1.31.0.jar" MODULE="google-oauth-client-1.31.0.jar" MVN="mvn:com.google.oauth-client/google-oauth-client/1.31.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-http-client-jackson2-1.25.0.jar" MODULE="google-http-client-jackson2-1.25.0.jar" MVN="mvn:com.google.http-client/google-http-client-jackson2/1.25.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-http-client-jackson2-1.38.0.jar" MODULE="google-http-client-jackson2-1.38.0.jar" MVN="mvn:com.google.http-client/google-http-client-jackson2/1.38.0" REQUIRED="true" />
|
||||
<IMPORT NAME="guava-20.0.jar" MODULE="guava-20.0.jar" MVN="mvn:com.google.guava/guava/20.0" REQUIRED="true" />
|
||||
<IMPORT NAME="jackson-core-2.10.1.jar" MODULE="jackson-core-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.10.1" REQUIRED="true" />
|
||||
<IMPORT NAME="google-cloud-bigquery-1.60.0.jar" MODULE="google-cloud-bigquery-1.60.0.jar" MVN="mvn:com.google.cloud/google-cloud-bigquery/1.60.0" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="jackson-core-2.11.4.jar" MODULE="jackson-core-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.11.4" REQUIRED="true" />
|
||||
<IMPORT NAME="google-cloud-bigquery-1.126.3.jar" MODULE="google-cloud-bigquery-1.126.3.jar" MVN="mvn:com.google.cloud/google-cloud-bigquery/1.126.3" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
|
||||
<!-- TODO remove it -->
|
||||
<IMPORT NAME="google-http-client-jackson-1.25.0.jar" MODULE="google-http-client-jackson-1.25.0.jar" MVN="mvn:com.google.http-client/google-http-client-jackson/1.25.0" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
|
||||
<IMPORT NAME="threetenbp-1.3.3.jar" MODULE="threetenbp-1.3.3.jar" MVN="mvn:org.threeten/threetenbp/1.3.3" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="google-auth-library-credentials-0.20.0.jar" MODULE="google-auth-library-credentials-0.20.0.jar" MVN="mvn:com.google.auth/google-auth-library-credentials/0.20.0" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="gax-httpjson-0.44.0.jar" MODULE="gax-httpjson-0.44.0.jar" MVN="mvn:com.google.api/gax-httpjson/0.44.0" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
@@ -197,8 +222,11 @@
|
||||
<IMPORT NAME="google-cloud-core-1.93.4.jar" MODULE="google-cloud-core-1.93.4.jar" MVN="mvn:com.google.cloud/google-cloud-core/1.93.4" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="google-cloud-core-http-1.32.0.jar" MODULE="google-cloud-core-http-1.32.0.jar" MVN="mvn:com.google.cloud/google-cloud-core-http/1.32.0" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="gax-1.27.0.jar" MODULE="gax-1.27.0.jar" MVN="mvn:com.google.api/gax/1.27.0" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="google-http-client-appengine-1.25.0.jar" MODULE="google-http-client-appengine-1.25.0.jar" MVN="mvn:com.google.http-client/google-http-client-appengine/1.25.0" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="google-http-client-appengine-1.38.0.jar" MODULE="google-http-client-appengine-1.38.0.jar" MVN="mvn:com.google.http-client/google-http-client-appengine/1.38.0" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="api-common-1.6.0.jar" MODULE="api-common-1.6.0.jar" MVN="mvn:com.google.api/api-common/1.6.0" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="opencensus-api-0.24.0" MODULE="opencensus-api-0.24.0.jar" MVN="mvn:io.opencensus/opencensus-api/0.24.0" REQUIRED="true" />
|
||||
<IMPORT NAME="opencensus-contrib-http-util-0.24.0" MODULE="opencensus-contrib-http-util-0.24.0.jar" MVN="mvn:io.opencensus/opencensus-contrib-http-util/0.24.0" REQUIRED="true" />
|
||||
<IMPORT NAME="grpc-context-1.22.1" MODULE="grpc-context-1.22.1.jar" MVN="mvn:io.grpc/grpc-context/1.22.1" REQUIRED="true" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
<RETURNS>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#Created by JInto - www.guh-software.de
|
||||
#Wed Mar 19 09:39:53 CST 2008
|
||||
LONG_NAME=Connect and run a query on Google BigQuery
|
||||
LONG_NAME=Connect and run a query on Google BigQuery
|
||||
HELP=org.talend.help.tBigQueryInput
|
||||
|
||||
AUTHENTICATION.NAME=Authentication
|
||||
@@ -8,11 +8,14 @@ SERVICE_ACCOUNT_CREDENTIALS_FILE.NAME=Service account credentials file
|
||||
AUTH_MODE.NAME=Authentication mode
|
||||
AUTH_MODE.ITEM.SERVICEACCOUNT=Service account
|
||||
AUTH_MODE.ITEM.OAUTH=OAuth 2.0
|
||||
AUTH_MODE.ITEM.TOKEN=OAuth Access Token
|
||||
|
||||
CLIENT_ID.NAME=Client Id
|
||||
CLIENT_SECRET.NAME=Client Secret
|
||||
PROJECT_ID.NAME=Project ID
|
||||
AUTHORIZATION_CODE.NAME=Authorization Code
|
||||
ACCESS_TOKEN.NAME=OAuth Access Token
|
||||
|
||||
QUERY.NAME=Query
|
||||
SCHEMA.NAME=Schema
|
||||
|
||||
@@ -29,4 +32,4 @@ RESULT_SIZE.ITEM.LARGE=Large(with allowLargeResults)
|
||||
RESULT_SIZE.ITEM.AUTO=Auto
|
||||
USE_CUSTOM_TEMPORARY_DATASET.NAME=Use custom temporary Dataset name
|
||||
TEMPORARY_DATASET_NAME.NAME=Temporary Dataset name
|
||||
USE_LEGACY_SQL.NAME=Use Legacy SQL
|
||||
USE_LEGACY_SQL.NAME=Use Legacy SQL
|
||||
@@ -54,20 +54,43 @@
|
||||
<PARAMETER NAME="SCHEMA" FIELD="SCHEMA_TYPE" REQUIRED="true" NUM_ROW="13">
|
||||
<DEFAULT/>
|
||||
</PARAMETER>
|
||||
|
||||
|
||||
<PARAMETER NAME="AUTH_MODE" FIELD="CLOSED_LIST" NUM_ROW="15" REQUIRED="true" GROUP="AUTHENTICATION" REPOSITORY_VALUE="AUTH_MODE">
|
||||
<ITEMS DEFAULT="SERVICEACCOUNT">
|
||||
<ITEM NAME="SERVICEACCOUNT" VALUE="SERVICEACCOUNT" />
|
||||
<ITEM NAME="OAUTH" VALUE="OAUTH" />
|
||||
<ITEM NAME="TOKEN" VALUE="TOKEN" />
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="SERVICE_ACCOUNT_CREDENTIALS_FILE"
|
||||
<PARAMETER
|
||||
NAME="ACCESS_TOKEN"
|
||||
FIELD="PASSWORD"
|
||||
NUM_ROW="18"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="AUTH_MODE == 'TOKEN'"
|
||||
GROUP="AUTHENTICATION"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="ACCESS_TOKEN_WARNING"
|
||||
FIELD="LABEL"
|
||||
NUM_ROW="20"
|
||||
REQUIRED="false"
|
||||
GROUP="AUTHENTICATION"
|
||||
SHOW_IF="AUTH_MODE == 'TOKEN'"
|
||||
>
|
||||
<DEFAULT>*Note: If the Access Token Expire we won't be able to refresh it!"</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="SERVICE_ACCOUNT_CREDENTIALS_FILE"
|
||||
REPOSITORY_VALUE="SERVICE_ACCOUNT_CREDENTIALS_FILE"
|
||||
FIELD="FILE"
|
||||
NUM_ROW="18"
|
||||
REQUIRED="true"
|
||||
FIELD="FILE"
|
||||
NUM_ROW="18"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="AUTH_MODE == 'SERVICEACCOUNT'"
|
||||
GROUP="AUTHENTICATION"
|
||||
>
|
||||
@@ -162,25 +185,26 @@
|
||||
<ITEMS DEFAULT="GS_SERVICE_ACCOUNT">
|
||||
<ITEM NAME="USER_ACCOUNT_HMAC" VALUE="USER_ACCOUNT_HMAC"/>
|
||||
<ITEM NAME="GS_SERVICE_ACCOUNT" VALUE="GS_SERVICE_ACCOUNT"/>
|
||||
<ITEM NAME="TOKEN" VALUE="TOKEN" />
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="GS_ACCESS_KEY"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="60"
|
||||
REQUIRED="true"
|
||||
GROUP="GS_CONF"
|
||||
<PARAMETER
|
||||
NAME="GS_ACCESS_KEY"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="60"
|
||||
REQUIRED="true"
|
||||
GROUP="GS_CONF"
|
||||
SHOW_IF="(BULK_FILE_ALREADY_EXIST=='false') AND (AUTH_TYPE == 'USER_ACCOUNT_HMAC')">
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="GS_SECRET_KEY"
|
||||
FIELD="PASSWORD"
|
||||
NUM_ROW="61"
|
||||
REQUIRED="true"
|
||||
GROUP="GS_CONF"
|
||||
<PARAMETER
|
||||
NAME="GS_SECRET_KEY"
|
||||
FIELD="PASSWORD"
|
||||
NUM_ROW="61"
|
||||
REQUIRED="true"
|
||||
GROUP="GS_CONF"
|
||||
SHOW_IF="(BULK_FILE_ALREADY_EXIST=='false') AND (AUTH_TYPE == 'USER_ACCOUNT_HMAC')">
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
@@ -195,6 +219,28 @@
|
||||
<DEFAULT>"__COMP_DEFAULT_FILE_DIR__/key.json"</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="GS_ACCESS_TOKEN"
|
||||
FIELD="PASSWORD"
|
||||
NUM_ROW="60"
|
||||
REQUIRED_IF="(BULK_FILE_ALREADY_EXIST=='false') AND (AUTH_TYPE == 'TOKEN')"
|
||||
SHOW_IF="(BULK_FILE_ALREADY_EXIST=='false') AND (AUTH_TYPE == 'TOKEN')"
|
||||
GROUP="GS_CONF"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="GS_ACCESS_TOKEN_WARNING"
|
||||
FIELD="LABEL"
|
||||
NUM_ROW="61"
|
||||
REQUIRED="false"
|
||||
GROUP="GS_CONF"
|
||||
SHOW_IF="(BULK_FILE_ALREADY_EXIST=='false') AND (AUTH_TYPE == 'TOKEN')"
|
||||
>
|
||||
<DEFAULT>*Note: If the Access Token Expire we won't be able to refresh it!"</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="BUCKET_NAME" FIELD="TEXT" NUM_ROW="63" REQUIRED="true" GROUP="GS_CONF" SHOW_IF="BULK_FILE_ALREADY_EXIST=='false'">
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
@@ -303,6 +349,8 @@
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.AUTH_MODE" TARGET="tBQBE.AUTH_MODE" />
|
||||
<TEMPLATE_PARAM SOURCE="self.SERVICE_ACCOUNT_CREDENTIALS_FILE" TARGET="tBQBE.SERVICE_ACCOUNT_CREDENTIALS_FILE" />
|
||||
<TEMPLATE_PARAM SOURCE="self.ACCESS_TOKEN" TARGET="tBQBE.ACCESS_TOKEN" />
|
||||
<TEMPLATE_PARAM SOURCE="self.ACCESS_TOKEN_WARNING" TARGET="tBQBE.ACCESS_TOKEN_WARNING" />
|
||||
<TEMPLATE_PARAM SOURCE="self.CLIENT_ID" TARGET="tBQBE.CLIENT_ID" />
|
||||
<TEMPLATE_PARAM SOURCE="self.CLIENT_SECRET" TARGET="tBQBE.CLIENT_SECRET" />
|
||||
<TEMPLATE_PARAM SOURCE="self.PROJECT_ID" TARGET="tBQBE.PROJECT_ID" />
|
||||
@@ -313,6 +361,8 @@
|
||||
<TEMPLATE_PARAM SOURCE="self.ACTION_ON_DATA" TARGET="tBQBE.ACTION_ON_DATA" />
|
||||
<TEMPLATE_PARAM SOURCE="self.AUTH_TYPE" TARGET="tBQBE.AUTH_TYPE" />
|
||||
<TEMPLATE_PARAM SOURCE="self.GS_SERVICE_ACCOUNT_KEY" TARGET="tBQBE.GS_SERVICE_ACCOUNT_KEY" />
|
||||
<TEMPLATE_PARAM SOURCE="self.GS_ACCESS_TOKEN" TARGET="tBQBE.GS_ACCESS_TOKEN" />
|
||||
<TEMPLATE_PARAM SOURCE="self.GS_ACCESS_TOKEN_WARNING" TARGET="tBQBE.GS_ACCESS_TOKEN_WARNING" />
|
||||
<TEMPLATE_PARAM SOURCE="self.GS_ACCESS_KEY" TARGET="tBQBE.GS_ACCESS_KEY" />
|
||||
<TEMPLATE_PARAM SOURCE="self.GS_SECRET_KEY" TARGET="tBQBE.GS_SECRET_KEY" />
|
||||
<TEMPLATE_PARAM SOURCE="self.BUCKET_NAME" TARGET="tBQBE.BUCKET_NAME" />
|
||||
|
||||
@@ -22,11 +22,13 @@ SERVICE_ACCOUNT_CREDENTIALS_FILE.NAME=Service account credentials file
|
||||
AUTH_MODE.NAME=Authentication mode
|
||||
AUTH_MODE.ITEM.SERVICEACCOUNT=Service account
|
||||
AUTH_MODE.ITEM.OAUTH=OAuth 2.0
|
||||
AUTH_MODE.ITEM.TOKEN=OAuth Access Token
|
||||
|
||||
CLIENT_ID.NAME=Client Id
|
||||
CLIENT_SECRET.NAME=Client Secret
|
||||
PROJECT_ID.NAME=Project ID
|
||||
AUTHORIZATION_CODE.NAME=Authorization Code
|
||||
ACCESS_TOKEN.NAME=OAuth Access Token
|
||||
|
||||
SCHEMA.NAME=Schema
|
||||
|
||||
@@ -62,4 +64,6 @@ DIE_ON_ERROR.NAME=Die on error
|
||||
AUTH_TYPE.NAME=Credential type
|
||||
AUTH_TYPE.ITEM.USER_ACCOUNT_HMAC=HMAC key (deprecated)
|
||||
AUTH_TYPE.ITEM.GS_SERVICE_ACCOUNT=Service account
|
||||
AUTH_TYPE.ITEM.TOKEN=OAuth Access Token
|
||||
GS_SERVICE_ACCOUNT_KEY.NAME=Service account key
|
||||
GS_ACCESS_TOKEN.NAME=OAuth Access Token
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<%@ jet
|
||||
imports="
|
||||
org.talend.core.model.process.INode
|
||||
org.talend.core.model.process.ElementParameterParser
|
||||
org.talend.core.model.process.INode
|
||||
org.talend.core.model.process.ElementParameterParser
|
||||
org.talend.designer.codegen.config.CodeGeneratorArgument
|
||||
java.util.List
|
||||
"
|
||||
@@ -23,33 +23,39 @@
|
||||
String query = ElementParameterParser.getValue(node,"__QUERY__");
|
||||
boolean useLegacySql = ElementParameterParser.getBooleanValue(node,"__USE_LEGACY_SQL__");
|
||||
String basePackage = "";
|
||||
|
||||
|
||||
query = query.replaceAll("\n"," ").replaceAll("\r", " ");
|
||||
|
||||
|
||||
String tokenFile = ElementParameterParser.getValue(node,"__TOKEN_NAME__");
|
||||
boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
|
||||
if (authMode.equals("OAUTH")) {
|
||||
if (authMode.equals("OAUTH") || authMode.equals("TOKEN")) {
|
||||
%>
|
||||
final String PROJECT_ID_<%=cid %> = <%=projectId %>;
|
||||
final com.google.api.client.http.HttpTransport TRANSPORT_<%=cid %> = new com.google.api.client.http.javanet.NetHttpTransport();
|
||||
final com.google.api.client.json.JsonFactory JSON_FACTORY_<%=cid %> = new com.google.api.client.json.jackson2.JacksonFactory();
|
||||
com.google.api.services.bigquery.Bigquery bigqueryclient_<%=cid%> = null;
|
||||
com.google.api.client.auth.oauth2.Credential credential_<%=cid%> = null;
|
||||
long nb_line_<%=cid%> = 0;
|
||||
<%
|
||||
if (authMode.equals("OAUTH")) {
|
||||
String passwordFieldName = "__CLIENT_SECRET__";
|
||||
%>
|
||||
|
||||
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/password.javajet"%>
|
||||
|
||||
|
||||
final String CLIENT_SECRET_<%=cid%> = "{\"web\": {\"client_id\": \""+<%=clientId%>+"\",\"client_secret\": \"" +decryptedPassword_<%=cid%>+ "\",\"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\"token_uri\": \"https://accounts.google.com/o/oauth2/token\"}}";
|
||||
final String PROJECT_ID_<%=cid %> = <%=projectId %>;
|
||||
|
||||
|
||||
|
||||
// Static variables for API scope, callback URI, and HTTP/JSON functions
|
||||
final List<String> SCOPES_<%=cid%> = java.util.Arrays.asList("https://www.googleapis.com/auth/bigquery");
|
||||
final String REDIRECT_URI_<%=cid%> = "urn:ietf:wg:oauth:2.0:oob";
|
||||
final com.google.api.client.http.HttpTransport TRANSPORT_<%=cid %> = new com.google.api.client.http.javanet.NetHttpTransport();
|
||||
final com.google.api.client.json.JsonFactory JSON_FACTORY_<%=cid %> = new com.google.api.client.json.jackson2.JacksonFactory();
|
||||
|
||||
|
||||
com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets clientSecrets_<%=cid%> = com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets.load(
|
||||
JSON_FACTORY_<%=cid %>, new java.io.InputStreamReader(new java.io.ByteArrayInputStream(
|
||||
CLIENT_SECRET_<%=cid%>.getBytes())));
|
||||
|
||||
|
||||
com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow flow_<%=cid%> = null;
|
||||
com.google.api.services.bigquery.Bigquery bigqueryclient_<%=cid%> = null;
|
||||
long nb_line_<%=cid%> = 0;
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
@@ -59,7 +65,7 @@
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
|
||||
// Attempt to load existing refresh token
|
||||
String tokenFile_<%=cid %> = <%=tokenFile%>;
|
||||
java.util.Properties properties_<%=cid%> = new java.util.Properties();
|
||||
@@ -75,16 +81,16 @@
|
||||
%>
|
||||
}
|
||||
String storedRefreshToken_<%=cid%> = (String) properties_<%=cid%>.get("refreshtoken");
|
||||
|
||||
|
||||
// Check to see if the an existing refresh token was loaded.
|
||||
// If so, create a credential and call refreshToken() to get a new
|
||||
// access token.
|
||||
if (storedRefreshToken_<%=cid%> != null) {
|
||||
// Request a new Access token using the refresh token.
|
||||
com.google.api.client.googleapis.auth.oauth2.GoogleCredential credential_<%=cid%> = new com.google.api.client.googleapis.auth.oauth2. GoogleCredential.Builder().setTransport(TRANSPORT_<%=cid%>)
|
||||
credential_<%=cid%> = new com.google.api.client.googleapis.auth.oauth2.GoogleCredential.Builder().setTransport(TRANSPORT_<%=cid%>)
|
||||
.setJsonFactory(JSON_FACTORY_<%=cid%>).setClientSecrets(clientSecrets_<%=cid%>)
|
||||
.build().setFromTokenResponse(new com.google.api.client.auth.oauth2.TokenResponse().setRefreshToken(storedRefreshToken_<%=cid%>));
|
||||
|
||||
|
||||
credential_<%=cid%>.refreshToken();
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
@@ -93,7 +99,6 @@
|
||||
<%
|
||||
}
|
||||
%>
|
||||
bigqueryclient_<%=cid%> = new com.google.api.services.bigquery.Bigquery.Builder(new com.google.api.client.http.javanet.NetHttpTransport(),new com.google.api.client.json.jackson2.JacksonFactory(),credential_<%=cid%>).setApplicationName("Talend").build();
|
||||
} else {
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
@@ -106,7 +111,7 @@
|
||||
if(authorizationCode_<%=cid%> == null || "".equals(authorizationCode_<%=cid%>) || "\"\"".equals(authorizationCode_<%=cid%>)) {
|
||||
String authorizeUrl_<%=cid%> = new com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl(
|
||||
clientSecrets_<%=cid%>, REDIRECT_URI_<%=cid%>, SCOPES_<%=cid%>).setState("").build();
|
||||
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
@@ -131,13 +136,12 @@
|
||||
}
|
||||
%>
|
||||
// Exchange the auth code for an access token and refesh token
|
||||
flow_<%=cid%> = new com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow.Builder(new com.google.api.client.http.javanet.NetHttpTransport(),
|
||||
new com.google.api.client.json.jackson2.JacksonFactory(), clientSecrets_<%=cid%>, SCOPES_<%=cid%>)
|
||||
flow_<%=cid%> = new com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow.Builder(TRANSPORT_<%=cid %>, JSON_FACTORY_<%=cid%>, clientSecrets_<%=cid%>, SCOPES_<%=cid%>)
|
||||
.setAccessType("offline").setApprovalPrompt("force")
|
||||
.build();
|
||||
com.google.api.client.googleapis.auth.oauth2.GoogleTokenResponse response_<%=cid%> = flow_<%=cid%>.newTokenRequest(authorizationCode_<%=cid%>).setRedirectUri(REDIRECT_URI_<%=cid%>).execute();
|
||||
com.google.api.client.auth.oauth2.Credential credential_<%=cid%> = flow_<%=cid%>.createAndStoreCredential(response_<%=cid%>, null);
|
||||
|
||||
credential_<%=cid%> = flow_<%=cid%>.createAndStoreCredential(response_<%=cid%>, null);
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
@@ -151,17 +155,28 @@
|
||||
try(java.io.FileOutputStream outputStream_<%=cid%> = new java.io.FileOutputStream(tokenFile_<%=cid %>)) {
|
||||
storeProperties_<%=cid%>.store(outputStream_<%=cid%>,null);
|
||||
}
|
||||
|
||||
bigqueryclient_<%=cid%> = new com.google.api.services.bigquery.Bigquery.Builder(new com.google.api.client.http.javanet.NetHttpTransport(),new com.google.api.client.json.jackson2.JacksonFactory(),credential_<%=cid%>).build();
|
||||
}
|
||||
}
|
||||
<% } else {
|
||||
if (ElementParameterParser.canEncrypt(node, "__ACCESS_TOKEN__")) {%>
|
||||
final String decryptedAccessToken_<%=cid%> = routines.system.PasswordEncryptUtil.decryptPassword(<%=ElementParameterParser.getEncryptedValue(node, "__ACCESS_TOKEN__")%>);
|
||||
credential_<%=cid%> =
|
||||
new com.google.api.client.auth.oauth2.Credential(com.google.api.client.auth.oauth2.BearerToken.authorizationHeaderAccessMethod()).setFromTokenResponse(
|
||||
(new com.google.api.client.auth.oauth2.TokenResponse()).setAccessToken(decryptedAccessToken_<%=cid%>));
|
||||
<%} else {%>
|
||||
credential_<%=cid%> =
|
||||
new com.google.api.client.auth.oauth2.Credential(com.google.api.client.auth.oauth2.BearerToken.authorizationHeaderAccessMethod()).setFromTokenResponse(
|
||||
(new com.google.api.client.auth.oauth2.TokenResponse()).setAccessToken(<%= ElementParameterParser.getValue(node, "__ACCESS_TOKEN__")%>));
|
||||
<%}
|
||||
} %>
|
||||
bigqueryclient_<%=cid%> = new com.google.api.services.bigquery.Bigquery.Builder(TRANSPORT_<%=cid %>, JSON_FACTORY_<%=cid%>, credential_<%=cid%>).setApplicationName("Talend").build();
|
||||
<%
|
||||
String resultSizeType = ElementParameterParser.getValue(node,"__RESULT_SIZE__");
|
||||
%>
|
||||
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/tBigQueryInput/BigQueryInputQueryHelper.javajet"%>
|
||||
|
||||
BigQueryUtil_<%=cid%> bigQueryUtil_<%=cid%> = new BigQueryUtil_<%=cid%>(PROJECT_ID_<%=cid%>, bigqueryclient_<%=cid%>, tokenFile_<%=cid%>);
|
||||
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/tBigQueryInput/BigQueryInputQueryHelper.javajet"%>
|
||||
|
||||
BigQueryUtil_<%=cid%> bigQueryUtil_<%=cid%> = new BigQueryUtil_<%=cid%>(PROJECT_ID_<%=cid%>, bigqueryclient_<%=cid%>, <% if (authMode.equals("OAUTH")) { %> tokenFile_<%=cid%> <% } else { %> null <%}%>);
|
||||
<%
|
||||
} else if (authMode.equals("SERVICEACCOUNT")) {
|
||||
%>
|
||||
@@ -176,7 +191,7 @@
|
||||
.setProjectId(<%=projectId%>)
|
||||
.build()
|
||||
.getService();
|
||||
|
||||
|
||||
<%
|
||||
} else {
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\" or \"OAUTH\", but it is " + authMode);
|
||||
|
||||
@@ -44,9 +44,31 @@
|
||||
<ITEMS DEFAULT="SERVICEACCOUNT">
|
||||
<ITEM NAME="SERVICEACCOUNT" VALUE="SERVICEACCOUNT"/>
|
||||
<ITEM NAME="OAUTH" VALUE="OAUTH"/>
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
<ITEM NAME="TOKEN" VALUE="TOKEN" />
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="ACCESS_TOKEN"
|
||||
FIELD="PASSWORD"
|
||||
NUM_ROW="10"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="AUTH_MODE == 'TOKEN'"
|
||||
GROUP="AUTHENTICATION"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="ACCESS_TOKEN_WARNING"
|
||||
FIELD="LABEL"
|
||||
NUM_ROW="11"
|
||||
REQUIRED="false"
|
||||
GROUP="AUTHENTICATION"
|
||||
SHOW_IF="AUTH_MODE == 'TOKEN'"
|
||||
>
|
||||
<DEFAULT>*Note: If the Access Token Expire we won't be able to refresh it!"</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER
|
||||
NAME="SERVICE_ACCOUNT_CREDENTIALS_FILE"
|
||||
REPOSITORY_VALUE="SERVICE_ACCOUNT_CREDENTIALS_FILE"
|
||||
@@ -166,21 +188,24 @@
|
||||
</ADVANCED_PARAMETERS>
|
||||
<CODEGENERATION>
|
||||
<IMPORTS>
|
||||
<IMPORT NAME="google-api-client-1.25.0.jar" MODULE="google-api-client-1.25.0.jar" MVN="mvn:com.google.api-client/google-api-client/1.25.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-api-services-oauth2-v2-rev151-1.25.0.jar" MODULE="google-api-services-oauth2-v2-rev151-1.25.0.jar" MVN="mvn:com.google.apis/google-api-services-oauth2/v2-rev151-1.25.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-api-services-bigquery-v2-rev454-1.25.0.jar" MODULE="google-api-services-bigquery-v2-rev454-1.25.0.jar" MVN="mvn:com.google.apis/google-api-services-bigquery/v2-rev454-1.25.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-http-client-1.25.0.jar" MODULE="google-http-client-1.25.0.jar" MVN="mvn:com.google.http-client/google-http-client/1.25.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-api-client-1.31.1.jar" MODULE="google-api-client-1.31.1.jar" MVN="mvn:com.google.api-client/google-api-client/1.31.1" REQUIRED="true" />
|
||||
<IMPORT NAME="google-api-services-oauth2-v2-rev20200213-1.31.0.jar" MODULE="google-api-services-oauth2-v2-rev20200213-1.31.0.jar" MVN="mvn:com.google.apis/google-api-services-oauth2/v2-rev20200213-1.31.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-api-services-bigquery-v2-rev20201030-1.31.0.jar" MODULE="google-api-services-bigquery-v2-rev20201030-1.31.0.jar" MVN="mvn:com.google.apis/google-api-services-bigquery/v2-rev20201030-1.31.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-http-client-1.38.0.jar" MODULE="google-http-client-1.38.0.jar" MVN="mvn:com.google.http-client/google-http-client/1.38.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-oauth-client-1.31.0.jar" MODULE="google-oauth-client-1.31.0.jar" MVN="mvn:com.google.oauth-client/google-oauth-client/1.31.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-http-client-jackson2-1.25.0.jar" MODULE="google-http-client-jackson2-1.25.0.jar" MVN="mvn:com.google.http-client/google-http-client-jackson2/1.25.0" REQUIRED="true" />
|
||||
<IMPORT NAME="google-http-client-jackson2-1.38.0.jar" MODULE="google-http-client-jackson2-1.38.0.jar" MVN="mvn:com.google.http-client/google-http-client-jackson2/1.38.0" REQUIRED="true" />
|
||||
<IMPORT NAME="guava-20.0.jar" MODULE="guava-20.0.jar" MVN="mvn:com.google.guava/guava/20.0" REQUIRED="true"/>
|
||||
<IMPORT NAME="jackson-core-2.10.1.jar" MODULE="jackson-core-2.10.1.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.10.1" REQUIRED="true"/>
|
||||
<IMPORT NAME="google-cloud-bigquery-1.60.0.jar" MODULE="google-cloud-bigquery-1.60.0.jar"
|
||||
MVN="mvn:com.google.cloud/google-cloud-bigquery/1.60.0"
|
||||
<IMPORT NAME="jackson-core-2.11.4.jar" MODULE="jackson-core-2.11.4.jar"
|
||||
MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.11.4" REQUIRED="true"/>
|
||||
<IMPORT NAME="google-cloud-bigquery-1.126.3.jar" MODULE="google-cloud-bigquery-1.126.3.jar"
|
||||
MVN="mvn:com.google.cloud/google-cloud-bigquery/1.126.3"
|
||||
REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'"/>
|
||||
|
||||
<!-- TODO remove it -->
|
||||
<IMPORT NAME="google-http-client-jackson-1.25.0.jar" MODULE="google-http-client-jackson-1.25.0.jar"
|
||||
MVN="mvn:com.google.http-client/google-http-client-jackson/1.25.0"
|
||||
REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'"/>
|
||||
|
||||
<IMPORT NAME="threetenbp-1.3.3.jar" MODULE="threetenbp-1.3.3.jar" MVN="mvn:org.threeten/threetenbp/1.3.3"
|
||||
REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'"/>
|
||||
<IMPORT NAME="google-auth-library-credentials-0.20.0.jar" MODULE="google-auth-library-credentials-0.20.0.jar"
|
||||
@@ -200,11 +225,14 @@
|
||||
REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'"/>
|
||||
<IMPORT NAME="gax-1.27.0.jar" MODULE="gax-1.27.0.jar" MVN="mvn:com.google.api/gax/1.27.0"
|
||||
REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'"/>
|
||||
<IMPORT NAME="google-http-client-appengine-1.25.0.jar" MODULE="google-http-client-appengine-1.25.0.jar"
|
||||
MVN="mvn:com.google.http-client/google-http-client-appengine/1.25.0"
|
||||
<IMPORT NAME="google-http-client-appengine-1.38.0.jar" MODULE="google-http-client-appengine-1.38.0.jar"
|
||||
MVN="mvn:com.google.http-client/google-http-client-appengine/1.38.0"
|
||||
REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'"/>
|
||||
<IMPORT NAME="api-common-1.6.0.jar" MODULE="api-common-1.6.0.jar" MVN="mvn:com.google.api/api-common/1.6.0"
|
||||
REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'"/>
|
||||
<IMPORT NAME="opencensus-api-0.24.0" MODULE="opencensus-api-0.24.0.jar" MVN="mvn:io.opencensus/opencensus-api/0.24.0" REQUIRED="true" />
|
||||
<IMPORT NAME="opencensus-contrib-http-util-0.24.0" MODULE="opencensus-contrib-http-util-0.24.0.jar" MVN="mvn:io.opencensus/opencensus-contrib-http-util/0.24.0" REQUIRED="true" />
|
||||
<IMPORT NAME="grpc-context-1.22.1" MODULE="grpc-context-1.22.1.jar" MVN="mvn:io.grpc/grpc-context/1.22.1" REQUIRED="true" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
<RETURNS>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<%@ jet
|
||||
imports="
|
||||
org.talend.core.model.process.INode
|
||||
org.talend.core.model.process.ElementParameterParser
|
||||
org.talend.core.model.process.INode
|
||||
org.talend.core.model.process.ElementParameterParser
|
||||
org.talend.designer.codegen.config.CodeGeneratorArgument
|
||||
org.talend.core.model.metadata.IMetadataTable
|
||||
org.talend.core.model.metadata.IMetadataColumn
|
||||
org.talend.core.model.metadata.IMetadataTable
|
||||
org.talend.core.model.metadata.IMetadataColumn
|
||||
org.talend.core.model.process.IConnection
|
||||
org.talend.core.model.process.IConnectionCategory
|
||||
org.talend.core.model.metadata.types.JavaTypesManager
|
||||
@@ -23,14 +23,14 @@
|
||||
String authMode = ElementParameterParser.getValue(node,"__AUTH_MODE__");
|
||||
String query = ElementParameterParser.getValue(node,"__QUERY__");
|
||||
boolean useLegacySql = ElementParameterParser.getBooleanValue(node,"__USE_LEGACY_SQL__");
|
||||
|
||||
|
||||
query = query.replaceAll("\n"," ").replaceAll("\r"," ");
|
||||
|
||||
|
||||
boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
|
||||
if (authMode.equals("OAUTH")) {
|
||||
if (authMode.equals("OAUTH") || authMode.equals("TOKEN")) {
|
||||
String resultSizeType = ElementParameterParser.getValue(node,"__RESULT_SIZE__");
|
||||
%>
|
||||
|
||||
|
||||
// Start a Query Job
|
||||
String querySql_<%=cid %> = <%=query %>;
|
||||
System.out.format("Running Query : %s\n", querySql_<%=cid %>);
|
||||
@@ -41,17 +41,20 @@
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
log.info("<%=cid%> - Try <%="LARGE".equals(resultSizeType) ? "with" : "without"%> allow large results flag");
|
||||
<%
|
||||
}
|
||||
%>
|
||||
if(authMode.equals("TOKEN") && !ElementParameterParser.canEncrypt(node, "__ACCESS_TOKEN__")) { %>
|
||||
credential_<%=cid%>.setAccessToken(<%= ElementParameterParser.getValue(node, "__ACCESS_TOKEN__")%>);
|
||||
<% } %>
|
||||
|
||||
com.google.api.services.bigquery.model.Job insert_<%=cid %> = bigQueryUtil_<%=cid%>.executeQuery(querySql_<%=cid%>, <%="LARGE".equals(resultSizeType) ? true : false%>, <%=useLegacySql%>);
|
||||
|
||||
<%
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
log.info("<%=cid%> - Executing query.");
|
||||
@@ -88,12 +91,12 @@
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
|
||||
<%
|
||||
} else {
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\" or \"OAUTH\", but it is " + authMode);
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\", \"OAUTH\" or \"TOKEN\", but it is " + authMode);
|
||||
}
|
||||
|
||||
|
||||
List< ? extends IConnection> conns = node.getOutgoingSortedConnections();
|
||||
if (conns != null){
|
||||
if (conns.size()>0){
|
||||
@@ -101,7 +104,7 @@
|
||||
String connName = conn.getName();
|
||||
if (conn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
|
||||
|
||||
if (authMode.equals("OAUTH")) {
|
||||
if (authMode.equals("OAUTH") || authMode.equals("TOKEN")) {
|
||||
%>
|
||||
while (true) {
|
||||
// Fetch Results
|
||||
@@ -112,14 +115,14 @@
|
||||
insert_<%=cid %>.getConfiguration().getQuery()
|
||||
.getDestinationTable().getTableId())
|
||||
.setPageToken(pageToken_<%=cid%>).execute();
|
||||
|
||||
|
||||
List<com.google.api.services.bigquery.model.TableRow> rows_<%=cid %> = dataList_<%=cid %>.getRows();
|
||||
|
||||
if(rows_<%=cid %> == null) {
|
||||
// Means there is no record.
|
||||
rows_<%=cid %> = new java.util.ArrayList<com.google.api.services.bigquery.model.TableRow>();
|
||||
}
|
||||
|
||||
|
||||
for (com.google.api.services.bigquery.model.TableRow row_<%=cid %> : rows_<%=cid %>) {
|
||||
java.util.List<com.google.api.services.bigquery.model.TableCell> field_<%=cid %> = row_<%=cid %>.getF();
|
||||
Object value_<%=cid%> = null;
|
||||
@@ -130,15 +133,15 @@
|
||||
com.google.cloud.bigquery.TableResult result_<%=cid%> = job_<%=cid%>.getQueryResults();
|
||||
|
||||
long nb_line_<%=cid%> = 0;
|
||||
|
||||
|
||||
for (com.google.cloud.bigquery.FieldValueList field_<%=cid %> : result_<%=cid%>.iterateAll()) {
|
||||
Object value_<%=cid%>;
|
||||
nb_line_<%=cid%> ++;
|
||||
<%
|
||||
} else {
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\" or \"OAUTH\", but it is " + authMode);
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\", \"OAUTH\" or \"TOKEN\", but it is " + authMode);
|
||||
}
|
||||
|
||||
|
||||
List<IMetadataTable> metadatas = node.getMetadataList();
|
||||
if ((metadatas!=null) && (metadatas.size() > 0)) {
|
||||
IMetadataTable metadata = metadatas.get(0);
|
||||
@@ -148,17 +151,17 @@
|
||||
boolean advancedSeparator = (advancedSeparatorStr!=null&&!("").equals(advancedSeparatorStr))?("true").equals(advancedSeparatorStr):false;
|
||||
String thousandsSeparator = ElementParameterParser.getValueWithJavaType(node, "__THOUSANDS_SEPARATOR__", JavaTypesManager.CHARACTER);
|
||||
String decimalSeparator = ElementParameterParser.getValueWithJavaType(node, "__DECIMAL_SEPARATOR__", JavaTypesManager.CHARACTER);
|
||||
|
||||
|
||||
List<IMetadataColumn> columns = metadata.getListColumns();
|
||||
int nbColumns = columns.size();
|
||||
for (int i = 0; i < nbColumns; i++ ) {
|
||||
IMetadataColumn column = columns.get(i);
|
||||
String columnName = column.getLabel();
|
||||
|
||||
|
||||
String typeToGenerate = JavaTypesManager.getTypeToGenerate(column.getTalendType(), column.isNullable());
|
||||
JavaType javaType = JavaTypesManager.getJavaTypeFromId(column.getTalendType());
|
||||
String patternValue = column.getPattern() == null || column.getPattern().trim().length() == 0 ? null : column.getPattern();
|
||||
if (authMode.equals("OAUTH")) {
|
||||
String patternValue = column.getPattern() == null || column.getPattern().trim().length() == 0 ? null : column.getPattern();
|
||||
if (authMode.equals("OAUTH") || authMode.equals("TOKEN")) {
|
||||
%>
|
||||
value_<%=cid%> = field_<%=cid %>.get(<%=i%>).getV();
|
||||
<%
|
||||
@@ -167,22 +170,22 @@
|
||||
value_<%=cid%> = field_<%=cid %>.get(<%=i%>).getValue();
|
||||
<%
|
||||
} else {
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\" or \"OAUTH\", but it is " + authMode);
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\", \"OAUTH\" or \"TOKEN\", but it is " + authMode);
|
||||
}
|
||||
%>
|
||||
if(com.google.api.client.util.Data.isNull(value_<%=cid%>)) value_<%=cid%> = null;
|
||||
if(value_<%=cid%> != null){
|
||||
|
||||
|
||||
<%
|
||||
if (javaType == JavaTypesManager.STRING) {
|
||||
%>
|
||||
<%=connName%>.<%=columnName%> = value_<%=cid%>.toString();
|
||||
<%
|
||||
} else if (javaType == JavaTypesManager.OBJECT) {
|
||||
%>
|
||||
%>
|
||||
<%=connName%>.<%=columnName%> = value_<%=cid%>;
|
||||
<%
|
||||
} else if(javaType == JavaTypesManager.DATE) {
|
||||
<%
|
||||
} else if(javaType == JavaTypesManager.DATE) {
|
||||
%>
|
||||
if (value_<%=cid%>.toString().contains("-")) {
|
||||
String sValue_<%=cid%> = value_<%=cid%>.toString();
|
||||
@@ -195,13 +198,13 @@
|
||||
} else{
|
||||
<%=connName%>.<%=columnName%>=ParserUtils.parseTo_Date(value_<%=cid%>.toString());
|
||||
}
|
||||
<%
|
||||
} else if(advancedSeparator && JavaTypesManager.isNumberType(javaType)) {
|
||||
<%
|
||||
} else if(advancedSeparator && JavaTypesManager.isNumberType(javaType)) {
|
||||
%>
|
||||
<%=connName%>.<%=columnName%> = ParserUtils.parseTo_<%= typeToGenerate %>(ParserUtils.parseTo_Number(value_<%=cid%>.toString(), <%= thousandsSeparator %>, <%= decimalSeparator %>));
|
||||
<%
|
||||
} else if(javaType == JavaTypesManager.BYTE_ARRAY) {
|
||||
%>
|
||||
} else if(javaType == JavaTypesManager.BYTE_ARRAY) {
|
||||
%>
|
||||
<%=connName%>.<%=columnName%> = value_<%=cid%>.toString().getBytes(<%=encoding %>);
|
||||
<%
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
LONG_NAME=Connect and run a query on Google BigQuery
|
||||
LONG_NAME=Connect and run a query on Google BigQuery
|
||||
HELP=org.talend.help.tBigQuerySQLRow
|
||||
|
||||
AUTHENTICATION.NAME=Authentication
|
||||
@@ -6,11 +6,14 @@ SERVICE_ACCOUNT_CREDENTIALS_FILE.NAME=Service account credentials file
|
||||
AUTH_MODE.NAME=Authentication mode
|
||||
AUTH_MODE.ITEM.SERVICEACCOUNT=Service account
|
||||
AUTH_MODE.ITEM.OAUTH=OAuth 2.0
|
||||
AUTH_MODE.ITEM.TOKEN=OAuth Access Token
|
||||
|
||||
CLIENT_ID.NAME=Client Id
|
||||
CLIENT_SECRET.NAME=Client Secret
|
||||
PROJECT_ID.NAME=Project ID
|
||||
AUTHORIZATION_CODE.NAME=Authorization Code
|
||||
ACCESS_TOKEN.NAME=OAuth Access Token
|
||||
|
||||
QUERY.NAME=Query
|
||||
SCHEMA.NAME=Schema
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<%@ jet
|
||||
<%@ jet
|
||||
imports="
|
||||
org.talend.core.model.process.INode
|
||||
org.talend.designer.codegen.config.CodeGeneratorArgument
|
||||
@@ -6,7 +6,7 @@ imports="
|
||||
org.talend.core.model.process.IConnection
|
||||
org.talend.core.model.process.IConnectionCategory
|
||||
java.util.List
|
||||
"
|
||||
"
|
||||
%>
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/Log4j/Log4jFileUtil.javajet"%>
|
||||
<%
|
||||
@@ -20,7 +20,7 @@ imports="
|
||||
IConnection conn =conns.get(0);
|
||||
String connName = conn.getName();
|
||||
if (conn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
|
||||
if (authMode.equals("OAUTH")) {
|
||||
if (authMode.equals("OAUTH") || authMode.equals("TOKEN")) {
|
||||
%>
|
||||
}
|
||||
pageToken_<%=cid%> = dataList_<%=cid %>.getPageToken();
|
||||
@@ -35,7 +35,7 @@ imports="
|
||||
}
|
||||
<%
|
||||
} else {
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\" or \"OAUTH\", but it is " + authMode);
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\" or \"OAUTH\"or \"TOKEN\", but it is " + authMode);
|
||||
}
|
||||
log4jFileUtil.retrievedDataNumberInfo(node);
|
||||
}
|
||||
|
||||
@@ -165,7 +165,9 @@
|
||||
|
||||
<CODEGENERATION>
|
||||
<IMPORTS>
|
||||
<IMPORT NAME="xstream-1.4.11.1.jar" MODULE="xstream-1.4.11.1.jar" MVN="mvn:com.thoughtworks.xstream/xstream/1.4.11.1" REQUIRED_IF="(DB_VERSION=='BONITA_523') OR (((DB_VERSION=='BONITA_652')OR(DB_VERSION=='BONITA_724')) AND (CLIENT_MODE=='JAVA_CLIENT'))" />
|
||||
|
||||
<IMPORT NAME="xstream-1.4.15.jar" MODULE="xstream-1.4.15.jar" MVN="mvn:com.thoughtworks.xstream/xstream/1.4.15" REQUIRED_IF="(DB_VERSION=='BONITA_523') OR (((DB_VERSION=='BONITA_652')OR(DB_VERSION=='BONITA_724')) AND (CLIENT_MODE=='JAVA_CLIENT'))" />
|
||||
|
||||
<!-- Bonita 5.2.3 -->
|
||||
<IMPORT NAME="bonita_client_523" MODULE="bonita-client-5.2.3.jar" MVN="mvn:org.talend.libraries/bonita-client-5.2.3/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.bonita/lib/bonita-client-5.2.3.jar" REQUIRED_IF="DB_VERSION=='BONITA_523'" />
|
||||
<IMPORT NAME="bonita_server_523" MODULE="bonita-server-5.2.3.jar" MVN="mvn:org.talend.libraries/bonita-server-5.2.3/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.bonita/lib/bonita-server-5.2.3.jar" REQUIRED_IF="DB_VERSION=='BONITA_523'" />
|
||||
@@ -181,7 +183,7 @@
|
||||
<IMPORT NAME="ehcache_123" MODULE="ehcache-1.2.3.jar" MVN="mvn:org.talend.libraries/ehcache-1.2.3/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.ehcache/lib/ehcache-1.2.3.jar" REQUIRED="false" />
|
||||
<IMPORT NAME="groovy_all_170" MODULE="groovy-all-1.7.0.jar" MVN="mvn:org.talend.libraries/groovy-all-1.7.0/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.groovy/lib/groovy-all-1.7.0.jar" REQUIRED="false" />
|
||||
|
||||
<IMPORT NAME="h2_12132" MODULE="h2-1.2.132.jar" MVN="mvn:org.talend.libraries/h2-1.2.132/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.jdbc.h2/lib/h2-1.2.132.jar" REQUIRED="false" />
|
||||
<IMPORT NAME="h2_12132" MODULE="h2-1.2.132.jar" MVN="mvn:com.h2database/h2/1.2.132" REQUIRED="false" />
|
||||
<IMPORT NAME="hibernate_326_ga" MODULE="hibernate-3.2.6.ga.jar" MVN="mvn:org.talend.libraries/hibernate-3.2.6.ga/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.hibernate/lib/hibernate-3.2.6.ga.jar" REQUIRED="false" />
|
||||
<IMPORT NAME="jline_0994" MODULE="jline-0.9.94.jar" MVN="mvn:org.talend.libraries/jline-0.9.94/6.0.0" REQUIRED="false" />
|
||||
<IMPORT NAME="jta_11" MODULE="jta-1.1.jar" MVN="mvn:javax.transaction/jta/1.1" REQUIRED_IF="DB_VERSION=='BONITA_561' OR DB_VERSION=='BONITA_5101'" />
|
||||
@@ -208,14 +210,14 @@
|
||||
<IMPORT NAME="bonita_server_561" MODULE="bonita-server-5.6.1.jar" MVN="mvn:org.talend.libraries/bonita-server-5.6.1/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.bonita/lib/bonita-server-5.6.1.jar" REQUIRED_IF="DB_VERSION=='BONITA_561'" />
|
||||
<IMPORT NAME="chemistry_opencmis_client_api_020_incubating" MODULE="chemistry-opencmis-client-api-0.2.0-incubating.jar" MVN="mvn:org.talend.libraries/chemistry-opencmis-client-api-0.2.0-incubating/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.chemistry/lib/chemistry-opencmis-client-api-0.2.0-incubating.jar" REQUIRED_IF="DB_VERSION=='BONITA_561'" />
|
||||
<IMPORT NAME="chemistry_opencmis_commons_api_020_incubating" MODULE="chemistry-opencmis-commons-api-0.2.0-incubating.jar" MVN="mvn:org.talend.libraries/chemistry-opencmis-commons-api-0.2.0-incubating/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.chemistry/lib/chemistry-opencmis-commons-api-0.2.0-incubating.jar" REQUIRED_IF="DB_VERSION=='BONITA_561'" />
|
||||
<IMPORT NAME="h2_12139" MODULE="h2-1.2.139.jar" MVN="mvn:org.talend.libraries/h2-1.2.139/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.jdbc.h2/lib/h2-1.2.139.jar" REQUIRED_IF="DB_VERSION=='BONITA_561' OR DB_VERSION=='BONITA_5101'" />
|
||||
<IMPORT NAME="h2_12139" MODULE="h2-1.2.139.jar" MVN="mvn:com.h2database/h2/1.2.139" REQUIRED_IF="DB_VERSION=='BONITA_561' OR DB_VERSION=='BONITA_5101'" />
|
||||
<IMPORT NAME="slf4j_api_161" MODULE="slf4j-api-1.6.1.jar" MVN="mvn:org.talend.libraries/slf4j-api-1.6.1/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.slf4j/lib/slf4j-api-1.6.1.jar" REQUIRED_IF="DB_VERSION=='BONITA_561' OR DB_VERSION=='BONITA_5101'" />
|
||||
<IMPORT NAME="slf4j_jdk14_161" MODULE="slf4j-jdk14-1.6.1.jar" MVN="mvn:org.talend.libraries/slf4j-jdk14-1.6.1/6.0.0" REQUIRED_IF="DB_VERSION=='BONITA_561' OR DB_VERSION=='BONITA_5101'" />
|
||||
|
||||
<!-- Bonita 5.10.1 -->
|
||||
<IMPORT NAME="bonita_server_5101" MODULE="bonita-server-5.10.1.jar" MVN="mvn:org.talend.libraries/bonita-server-5.10.1/6.0.0" REQUIRED_IF="DB_VERSION=='BONITA_5101'" />
|
||||
<IMPORT NAME="hibernate_search_330_Final" MODULE="hibernate-search-3.3.0.Final.jar" MVN="mvn:org.talend.libraries/hibernate-search-3.3.0.Final/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.hibernate/lib/hibernate-search-3.3.0.Final.jar" REQUIRED_IF="DB_VERSION=='BONITA_5101'" />
|
||||
<IMPORT NAME="hibernate_core_3_6_10_Final" MODULE="hibernate-core-3.6.10.Final.jar" MVN="mvn:org.talend.libraries/hibernate-core-3.6.10.Final/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.hibernate/lib/hibernate-core-3.6.10.Final.jar" REQUIRED_IF="DB_VERSION=='BONITA_5101'" />
|
||||
<IMPORT NAME="hibernate_core_3_6_10_Final" MODULE="hibernate-core-3.6.10.Final.jar" MVN="mvn:org.hibernate/hibernate-core/3.6.10.Final" REQUIRED_IF="DB_VERSION=='BONITA_5101'" />
|
||||
<IMPORT NAME="hibernate_jpa_2_0_api-1_0_1_Final" MODULE="hibernate-jpa-2.0-api-1.0.1.Final.jar" MVN="mvn:org.talend.libraries/hibernate-jpa-2.0-api-1.0.1.Final/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.hibernate/lib/hibernate-jpa-2.0-api-1.0.1.Final.jar" REQUIRED_IF="DB_VERSION=='BONITA_5101'" />
|
||||
<IMPORT NAME="lucene_core_303" MODULE="lucene-core-3.0.3.jar" MVN="mvn:org.talend.libraries/lucene-core-3.0.3/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.lucene/lib/lucene-core-3.0.3.jar" REQUIRED_IF="DB_VERSION=='BONITA_5101'" />
|
||||
<IMPORT NAME="javassist_3120_GA" MODULE="javassist-3.12.0.GA.jar" MVN="mvn:org.talend.libraries/javassist-3.12.0.GA/6.0.0" REQUIRED_IF="DB_VERSION=='BONITA_5101'" />
|
||||
|
||||
@@ -214,7 +214,8 @@
|
||||
|
||||
<CODEGENERATION>
|
||||
<IMPORTS>
|
||||
<IMPORT NAME="xstream-1.4.11.1.jar" MODULE="xstream-1.4.11.1.jar" MVN="mvn:com.thoughtworks.xstream/xstream/1.4.11.1" REQUIRED_IF="((DB_VERSION!='BONITA_652') AND (DB_VERSION!='BONITA_724')) OR (((DB_VERSION=='BONITA_652')OR(DB_VERSION=='BONITA_724')) AND (CLIENT_MODE=='JAVA_CLIENT'))" />
|
||||
|
||||
<IMPORT NAME="xstream-1.4.15.jar" MODULE="xstream-1.4.15.jar" MVN="mvn:com.thoughtworks.xstream/xstream/1.4.15" REQUIRED_IF="((DB_VERSION!='BONITA_652') AND (DB_VERSION!='BONITA_724')) OR (((DB_VERSION=='BONITA_652')OR(DB_VERSION=='BONITA_724')) AND (CLIENT_MODE=='JAVA_CLIENT'))" />
|
||||
<!-- Bonita 5.2.3 -->
|
||||
<IMPORT NAME="bonita_client_523" MODULE="bonita-client-5.2.3.jar" MVN="mvn:org.talend.libraries/bonita-client-5.2.3/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.bonita/lib/bonita-client-5.2.3.jar" REQUIRED_IF="DB_VERSION=='BONITA_523'" />
|
||||
<IMPORT NAME="bonita_server_523" MODULE="bonita-server-5.2.3.jar" MVN="mvn:org.talend.libraries/bonita-server-5.2.3/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.bonita/lib/bonita-server-5.2.3.jar" REQUIRED_IF="DB_VERSION=='BONITA_523'" />
|
||||
@@ -230,7 +231,7 @@
|
||||
<IMPORT NAME="ehcache_123" MODULE="ehcache-1.2.3.jar" MVN="mvn:org.talend.libraries/ehcache-1.2.3/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.ehcache/lib/ehcache-1.2.3.jar" REQUIRED="false" />
|
||||
<IMPORT NAME="groovy_all_170" MODULE="groovy-all-1.7.0.jar" MVN="mvn:org.talend.libraries/groovy-all-1.7.0/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.groovy/lib/groovy-all-1.7.0.jar" REQUIRED="false" />
|
||||
|
||||
<IMPORT NAME="h2_12132" MODULE="h2-1.2.132.jar" MVN="mvn:org.talend.libraries/h2-1.2.132/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.jdbc.h2/lib/h2-1.2.132.jar" REQUIRED="false" />
|
||||
<IMPORT NAME="h2_12132" MODULE="h2-1.2.132.jar" MVN="mvn:com.h2database/h2/1.2.132" REQUIRED="false" />
|
||||
<IMPORT NAME="hibernate_326_ga" MODULE="hibernate-3.2.6.ga.jar" MVN="mvn:org.talend.libraries/hibernate-3.2.6.ga/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.hibernate/lib/hibernate-3.2.6.ga.jar" REQUIRED="false" />
|
||||
<IMPORT NAME="jline_0994" MODULE="jline-0.9.94.jar" MVN="mvn:org.talend.libraries/jline-0.9.94/6.0.0" REQUIRED="false" />
|
||||
<IMPORT NAME="jta_11" MODULE="jta-1.1.jar" MVN="mvn:javax.transaction/jta/1.1" REQUIRED_IF="(CLIENT_MODE=='JAVA_CLIENT') AND (DB_VERSION=='BONITA_561' OR DB_VERSION=='BONITA_5101')" />
|
||||
@@ -257,13 +258,13 @@
|
||||
<IMPORT NAME="bonita_server_561" MODULE="bonita-server-5.6.1.jar" MVN="mvn:org.talend.libraries/bonita-server-5.6.1/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.bonita/lib/bonita-server-5.6.1.jar" REQUIRED_IF="(CLIENT_MODE=='JAVA_CLIENT') AND (DB_VERSION=='BONITA_561')" />
|
||||
<IMPORT NAME="chemistry_opencmis_client_api_020_incubating" MODULE="chemistry-opencmis-client-api-0.2.0-incubating.jar" MVN="mvn:org.talend.libraries/chemistry-opencmis-client-api-0.2.0-incubating/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.chemistry/lib/chemistry-opencmis-client-api-0.2.0-incubating.jar" REQUIRED_IF="(CLIENT_MODE=='JAVA_CLIENT') AND (DB_VERSION=='BONITA_561')" />
|
||||
<IMPORT NAME="chemistry_opencmis_commons_api_020_incubating" MODULE="chemistry-opencmis-commons-api-0.2.0-incubating.jar" MVN="mvn:org.talend.libraries/chemistry-opencmis-commons-api-0.2.0-incubating/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.chemistry/lib/chemistry-opencmis-commons-api-0.2.0-incubating.jar" REQUIRED_IF="(CLIENT_MODE=='JAVA_CLIENT') AND (DB_VERSION=='BONITA_561')" />
|
||||
<IMPORT NAME="h2_12139" MODULE="h2-1.2.139.jar" MVN="mvn:org.talend.libraries/h2-1.2.139/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.jdbc.h2/lib/h2-1.2.139.jar" REQUIRED_IF="(CLIENT_MODE=='JAVA_CLIENT') AND (DB_VERSION=='BONITA_561' OR DB_VERSION=='BONITA_5101')" />
|
||||
<IMPORT NAME="h2_12139" MODULE="h2-1.2.139.jar" MVN="mvn:com.h2database/h2/1.2.139" REQUIRED_IF="(CLIENT_MODE=='JAVA_CLIENT') AND (DB_VERSION=='BONITA_561' OR DB_VERSION=='BONITA_5101')" />
|
||||
<IMPORT NAME="slf4j_api_161" MODULE="slf4j-api-1.6.1.jar" MVN="mvn:org.talend.libraries/slf4j-api-1.6.1/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.slf4j/lib/slf4j-api-1.6.1.jar" REQUIRED_IF="(CLIENT_MODE=='JAVA_CLIENT') AND (DB_VERSION=='BONITA_561' OR DB_VERSION=='BONITA_5101')" />
|
||||
<IMPORT NAME="slf4j_jdk14_161" MODULE="slf4j-jdk14-1.6.1.jar" MVN="mvn:org.talend.libraries/slf4j-jdk14-1.6.1/6.0.0" REQUIRED_IF="(CLIENT_MODE=='JAVA_CLIENT') AND (DB_VERSION=='BONITA_561' OR DB_VERSION=='BONITA_5101')" />
|
||||
<!-- Bonita 5.10.1 -->
|
||||
<IMPORT NAME="bonita_server_510" MODULE="bonita-server-5.10.1.jar" MVN="mvn:org.talend.libraries/bonita-server-5.10.1/6.0.0" REQUIRED_IF="(CLIENT_MODE=='JAVA_CLIENT') AND (DB_VERSION=='BONITA_5101')" />
|
||||
<IMPORT NAME="hibernate_search_330_Final" MODULE="hibernate-search-3.3.0.Final.jar" MVN="mvn:org.talend.libraries/hibernate-search-3.3.0.Final/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.hibernate/lib/hibernate-search-3.3.0.Final.jar" REQUIRED_IF="(CLIENT_MODE=='JAVA_CLIENT') AND (DB_VERSION=='BONITA_5101')" />
|
||||
<IMPORT NAME="hibernate_core_3_6_10_Final" MODULE="hibernate-core-3.6.10.Final.jar" MVN="mvn:org.talend.libraries/hibernate-core-3.6.10.Final/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.hibernate/lib/hibernate-core-3.6.10.Final.jar" REQUIRED_IF="(CLIENT_MODE=='JAVA_CLIENT') AND (DB_VERSION=='BONITA_5101')" />
|
||||
<IMPORT NAME="hibernate_core_3_6_10_Final" MODULE="hibernate-core-3.6.10.Final.jar" MVN="mvn:org.hibernate/hibernate-core/3.6.10.Final" REQUIRED_IF="(CLIENT_MODE=='JAVA_CLIENT') AND (DB_VERSION=='BONITA_5101')" />
|
||||
<IMPORT NAME="hibernate_jpa_2_0_api-1_0_1_Final" MODULE="hibernate-jpa-2.0-api-1.0.1.Final.jar" MVN="mvn:org.talend.libraries/hibernate-jpa-2.0-api-1.0.1.Final/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.hibernate/lib/hibernate-jpa-2.0-api-1.0.1.Final.jar" REQUIRED_IF="(CLIENT_MODE=='JAVA_CLIENT') AND (DB_VERSION=='BONITA_5101')" />
|
||||
<IMPORT NAME="lucene_core_303" MODULE="lucene-core-3.0.3.jar" MVN="mvn:org.talend.libraries/lucene-core-3.0.3/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.lucene/lib/lucene-core-3.0.3.jar" REQUIRED_IF="(CLIENT_MODE=='JAVA_CLIENT') AND (DB_VERSION=='BONITA_5101')" />
|
||||
<IMPORT NAME="javassist_3120_GA" MODULE="javassist-3.12.0.GA.jar" MVN="mvn:org.talend.libraries/javassist-3.12.0.GA/6.0.0" REQUIRED_IF="(CLIENT_MODE=='JAVA_CLIENT') AND (DB_VERSION=='BONITA_5101')" />
|
||||
|
||||
@@ -72,13 +72,13 @@
|
||||
MODULE="boxjavalibv2-v3.0.10.jar" MVN="mvn:net.box/boxjavalibv2/v3.0.10"
|
||||
REQUIRED="true" />
|
||||
<IMPORT NAME="jackson-core"
|
||||
MODULE="jackson-core-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.10.1"
|
||||
MODULE="jackson-core-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.11.4"
|
||||
REQUIRED="true" />
|
||||
<IMPORT NAME="jackson-databind"
|
||||
MODULE="jackson-databind-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-databind/2.10.1"
|
||||
MODULE="jackson-databind-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-databind/2.11.4"
|
||||
REQUIRED="true" />
|
||||
<IMPORT NAME="jackson-annotations"
|
||||
MODULE="jackson-annotations-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-annotations/2.10.1"
|
||||
MODULE="jackson-annotations-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-annotations/2.11.4"
|
||||
REQUIRED="true" />
|
||||
<IMPORT NAME="apache-http-client"
|
||||
MODULE="httpclient-4.5.12.jar" MVN="mvn:org.apache.httpcomponents/httpclient/4.5.12"
|
||||
|
||||
@@ -127,13 +127,13 @@
|
||||
MODULE="boxjavalibv2-v3.0.10.jar" MVN="mvn:net.box/boxjavalibv2/v3.0.10"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="jackson-core"
|
||||
MODULE="jackson-core-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.10.1"
|
||||
MODULE="jackson-core-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.11.4"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="jackson-databind"
|
||||
MODULE="jackson-databind-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-databind/2.10.1"
|
||||
MODULE="jackson-databind-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-databind/2.11.4"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="jackson-annotations"
|
||||
MODULE="jackson-annotations-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-annotations/2.10.1"
|
||||
MODULE="jackson-annotations-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-annotations/2.11.4"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="apache-http-client"
|
||||
MODULE="httpclient-4.5.12.jar" MVN="mvn:org.apache.httpcomponents/httpclient/4.5.12"
|
||||
|
||||
@@ -88,13 +88,13 @@
|
||||
MODULE="boxjavalibv2-v3.0.10.jar" MVN="mvn:net.box/boxjavalibv2/v3.0.10"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="jackson-core"
|
||||
MODULE="jackson-core-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.10.1"
|
||||
MODULE="jackson-core-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.11.4"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="jackson-databind"
|
||||
MODULE="jackson-databind-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-databind/2.10.1"
|
||||
MODULE="jackson-databind-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-databind/2.11.4"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="jackson-annotations"
|
||||
MODULE="jackson-annotations-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-annotations/2.10.1"
|
||||
MODULE="jackson-annotations-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-annotations/2.11.4"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="apache-http-client"
|
||||
MODULE="httpclient-4.5.12.jar" MVN="mvn:org.apache.httpcomponents/httpclient/4.5.12"
|
||||
|
||||
@@ -98,13 +98,13 @@
|
||||
MODULE="boxjavalibv2-v3.0.10.jar" MVN="mvn:net.box/boxjavalibv2/v3.0.10"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="jackson-core"
|
||||
MODULE="jackson-core-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.10.1"
|
||||
MODULE="jackson-core-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.11.4"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="jackson-databind"
|
||||
MODULE="jackson-databind-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-databind/2.10.1"
|
||||
MODULE="jackson-databind-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-databind/2.11.4"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="jackson-annotations"
|
||||
MODULE="jackson-annotations-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-annotations/2.10.1"
|
||||
MODULE="jackson-annotations-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-annotations/2.11.4"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="apache-http-client"
|
||||
MODULE="httpclient-4.5.12.jar" MVN="mvn:org.apache.httpcomponents/httpclient/4.5.12"
|
||||
|
||||
@@ -106,13 +106,13 @@
|
||||
MODULE="boxjavalibv2-v3.0.10.jar" MVN="mvn:net.box/boxjavalibv2/v3.0.10"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="jackson-core"
|
||||
MODULE="jackson-core-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.10.1"
|
||||
MODULE="jackson-core-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.11.4"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="jackson-databind"
|
||||
MODULE="jackson-databind-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-databind/2.10.1"
|
||||
MODULE="jackson-databind-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-databind/2.11.4"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="jackson-annotations"
|
||||
MODULE="jackson-annotations-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-annotations/2.10.1"
|
||||
MODULE="jackson-annotations-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-annotations/2.11.4"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="apache-http-client"
|
||||
MODULE="httpclient-4.5.12.jar" MVN="mvn:org.apache.httpcomponents/httpclient/4.5.12"
|
||||
|
||||
@@ -109,13 +109,13 @@
|
||||
MODULE="boxjavalibv2-v3.0.10.jar" MVN="mvn:net.box/boxjavalibv2/v3.0.10"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="jackson-core"
|
||||
MODULE="jackson-core-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.10.1"
|
||||
MODULE="jackson-core-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.11.4"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="jackson-databind"
|
||||
MODULE="jackson-databind-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-databind/2.10.1"
|
||||
MODULE="jackson-databind-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-databind/2.11.4"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="jackson-annotations"
|
||||
MODULE="jackson-annotations-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-annotations/2.10.1"
|
||||
MODULE="jackson-annotations-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-annotations/2.11.4"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="apache-http-client"
|
||||
MODULE="httpclient-4.5.12.jar" MVN="mvn:org.apache.httpcomponents/httpclient/4.5.12"
|
||||
|
||||
@@ -56,7 +56,10 @@ COMPATIBILITY="ALL"
|
||||
REQUIRED="true">
|
||||
<DEFAULT>"ISO-8859-15"</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="BUFFERSIZE" FIELD="TEXT" REQUIRED="true"
|
||||
NUM_ROW="50">
|
||||
<DEFAULT>8192</DEFAULT>
|
||||
</PARAMETER>
|
||||
</PARAMETERS>
|
||||
|
||||
<ADVANCED_PARAMETERS>
|
||||
|
||||
@@ -19,6 +19,7 @@ String sOutEncoding = ElementParameterParser.getValue(node, "__ENCODING__");
|
||||
boolean bNeedEncode = "true".equals(ElementParameterParser.getValue(node, "__USE_INENCODING__"));
|
||||
boolean bCreateDir = "true".equals(ElementParameterParser.getValue(node, "__CREATE__"));
|
||||
String sTmpOutFileName = outFileName;
|
||||
final String bufferSizeExpression = ElementParameterParser.getValue(node, "__BUFFERSIZE__");
|
||||
|
||||
log4jFileUtil.componentStartInfo(node);
|
||||
if (outFileName.equals(inFileName)){
|
||||
@@ -37,15 +38,23 @@ java.io.File outFile_<%=cid%> = new java.io.File(sOutFileN_<%=cid%>);
|
||||
parentFile_<%=cid%>.mkdirs();
|
||||
}
|
||||
<%}%>
|
||||
|
||||
Integer bufferSize_<%=cid%> = <%= bufferSizeExpression %>;
|
||||
if (bufferSize_<%=cid%> == null) {
|
||||
bufferSize_<%=cid%> = 8192;
|
||||
}
|
||||
|
||||
final java.io.BufferedWriter out<%=cid %> = new java.io.BufferedWriter(
|
||||
new java.io.OutputStreamWriter(
|
||||
new java.io.FileOutputStream(sOutFileN_<%=cid%>, false), <%=sOutEncoding%>
|
||||
));
|
||||
),
|
||||
bufferSize_<%=cid%>);
|
||||
|
||||
java.io.BufferedReader in_<%=cid %> = new java.io.BufferedReader(
|
||||
new java.io.InputStreamReader(
|
||||
new java.io.FileInputStream(sOriFileN_<%=cid%>), <%=bNeedEncode ? sInEncoding : "System.getProperty(\"file.encoding\")"%>
|
||||
));
|
||||
),
|
||||
bufferSize_<%=cid%>);
|
||||
|
||||
//8192: the default buffer size of BufferedReader
|
||||
char[] cbuf_<%=cid %> = new char[8192];
|
||||
|
||||
@@ -10,3 +10,4 @@ INENCODING.NAME=Input Encoding
|
||||
INFILE_NAME.NAME=Input File Name
|
||||
OUTFILE_NAME.NAME=Output File Name
|
||||
CREATE.NAME=Create directory if not exists
|
||||
BUFFERSIZE.NAME=Buffer Size
|
||||
|
||||
@@ -165,7 +165,6 @@ COMPATIBILITY="ALL"
|
||||
<IMPORTS>
|
||||
<IMPORT NAME="aopalliance-1_0" MODULE="aopalliance-1.0.jar" MVN="mvn:aopalliance/aopalliance/1.0" UrlPath="platform:/plugin/org.talend.libraries.esb/lib/aopalliance-1.0.jar" REQUIRED_IF="PROVIDER=='AWS_EC2'"/>
|
||||
<IMPORT NAME="aws-ec2-2_0_2" MODULE="aws-ec2-2.0.2.jar" MVN="mvn:org.talend.libraries/aws-ec2-2.0.2/6.0.0" REQUIRED_IF="PROVIDER=='AWS_EC2'"/>
|
||||
<IMPORT NAME="bcprov-jdk16-1_46" MODULE="bcprov-jdk16-1.46.jar" MVN="mvn:org.talend.libraries/bcprov-jdk16-1.46/6.0.0" REQUIRED_IF="PROVIDER=='AWS_EC2'"/>
|
||||
<IMPORT NAME="commons-io-2_4" MODULE="commons-io-2.4.jar" MVN="mvn:commons-io/commons-io/2.4" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-io-2.4.jar" REQUIRED_IF="PROVIDER=='AWS_EC2'"/>
|
||||
<IMPORT NAME="ec2-2_0_2" MODULE="ec2-2.0.2.jar" MVN="mvn:org.talend.libraries/ec2-2.0.2/6.0.0" REQUIRED_IF="PROVIDER=='AWS_EC2'"/>
|
||||
<IMPORT NAME="gson-2_2" MODULE="gson-2.2.jar" MVN="mvn:org.talend.libraries/gson-2.2/6.0.0" REQUIRED_IF="PROVIDER=='AWS_EC2'"/>
|
||||
|
||||
@@ -74,7 +74,6 @@ COMPATIBILITY="ALL"
|
||||
<IMPORTS>
|
||||
<IMPORT NAME="aopalliance-1_0" MODULE="aopalliance-1.0.jar" MVN="mvn:aopalliance/aopalliance/1.0" UrlPath="platform:/plugin/org.talend.libraries.esb/lib/aopalliance-1.0.jar" REQUIRED_IF="PROVIDER=='AWS_EC2'"/>
|
||||
<IMPORT NAME="aws-ec2-2_0_2" MODULE="aws-ec2-2.0.2.jar" MVN="mvn:org.talend.libraries/aws-ec2-2.0.2/6.0.0" REQUIRED_IF="PROVIDER=='AWS_EC2'"/>
|
||||
<IMPORT NAME="bcprov-jdk16-1_46" MODULE="bcprov-jdk16-1.46.jar" MVN="mvn:org.talend.libraries/bcprov-jdk16-1.46/6.0.0" REQUIRED_IF="PROVIDER=='AWS_EC2'"/>
|
||||
<IMPORT NAME="commons-io-2_4" MODULE="commons-io-2.4.jar" MVN="mvn:commons-io/commons-io/2.4" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-io-2.4.jar" REQUIRED_IF="PROVIDER=='AWS_EC2'"/>
|
||||
<IMPORT NAME="ec2-2_0_2" MODULE="ec2-2.0.2.jar" MVN="mvn:org.talend.libraries/ec2-2.0.2/6.0.0" REQUIRED_IF="PROVIDER=='AWS_EC2'"/>
|
||||
<IMPORT NAME="gson-2_2" MODULE="gson-2.2.jar" MVN="mvn:org.talend.libraries/gson-2.2/6.0.0" REQUIRED_IF="PROVIDER=='AWS_EC2'"/>
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
MODULE="dropbox-core-sdk-2.1.2.jar" MVN="mvn:org.talend.libraries/dropbox-core-sdk-2.1.2/6.3.0"
|
||||
REQUIRED="true" />
|
||||
<IMPORT NAME="jackson-core"
|
||||
MODULE="jackson-core-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.10.1"
|
||||
MODULE="jackson-core-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.11.4"
|
||||
REQUIRED="true" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
MODULE="dropbox-core-sdk-2.1.2.jar" MVN="mvn:org.talend.libraries/dropbox-core-sdk-2.1.2/6.3.0"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="jackson-core"
|
||||
MODULE="jackson-core-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.10.1"
|
||||
MODULE="jackson-core-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.11.4"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
MODULE="dropbox-core-sdk-2.1.2.jar" MVN="mvn:org.talend.libraries/dropbox-core-sdk-2.1.2/6.3.0"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="jackson-core"
|
||||
MODULE="jackson-core-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.10.1"
|
||||
MODULE="jackson-core-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.11.4"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
MODULE="dropbox-core-sdk-2.1.2.jar" MVN="mvn:org.talend.libraries/dropbox-core-sdk-2.1.2/6.3.0"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="jackson-core"
|
||||
MODULE="jackson-core-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.10.1"
|
||||
MODULE="jackson-core-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.11.4"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
@@ -110,7 +110,7 @@
|
||||
MODULE="dropbox-core-sdk-2.1.2.jar" MVN="mvn:org.talend.libraries/dropbox-core-sdk-2.1.2/6.3.0"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
<IMPORT NAME="jackson-core"
|
||||
MODULE="jackson-core-2.10.1.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.10.1"
|
||||
MODULE="jackson-core-2.11.4.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.11.4"
|
||||
REQUIRED_IF="USE_EXISTING_CONNECTION == 'false'" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
@@ -170,7 +170,7 @@
|
||||
NUM_ROW="10"
|
||||
SHOW_IF="USE_EXISTING_CONNECTION == 'false'"
|
||||
>
|
||||
<ITEMS DEFAULT="POSTGRESQL">
|
||||
<ITEMS DEFAULT="GREENPLUM">
|
||||
<ITEM NAME="POSTGRESQL" VALUE="POSTGRESQL" />
|
||||
<ITEM NAME="GREENPLUM" VALUE="GREENPLUM"/>
|
||||
</ITEMS>
|
||||
@@ -182,7 +182,7 @@
|
||||
<IMPORT NAME="Postgres-Driver"
|
||||
MODULE="postgresql-8.4-703.jdbc4.jar" MVN="mvn:postgresql/postgresql/8.4-703.jdbc4" REQUIRED_IF="(DB_DRIVER =='POSTGRESQL') AND (USE_EXISTING_CONNECTION == 'false')"/>
|
||||
<IMPORT NAME="Greenplum-Driver"
|
||||
MODULE="greenplum.jar" MVN="mvn:com.pivotal/greenplum/5.8.1" REQUIRED_IF="(DB_DRIVER =='GREENPLUM') AND (USE_EXISTING_CONNECTION == 'false')"/>
|
||||
MODULE="greenplum-5.1.4.000275.jar" MVN="mvn:com.pivotal/greenplum/5.1.4.000275" REQUIRED_IF="(DB_DRIVER =='GREENPLUM') AND (USE_EXISTING_CONNECTION == 'false')"/>
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
|
||||
@@ -15,5 +15,5 @@ LINK_STYLE.ITEM.BEZIER_CURVE=Bezier curve
|
||||
LINK_STYLE.ITEM.LINE=Line (fastest)
|
||||
CONNECTION.NAME=Component List
|
||||
DB_DRIVER.NAME=DB driver
|
||||
DB_DRIVER.ITEM.POSTGRESQL=PostgreSQL
|
||||
DB_DRIVER.ITEM.POSTGRESQL=PostgreSQL (Deprecated)
|
||||
DB_DRIVER.ITEM.GREENPLUM=Greenplum
|
||||
@@ -55,10 +55,41 @@
|
||||
>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CLAUSE" FIELD="MEMO" NUM_ROW="8" SHOW_IF="(DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')"
|
||||
>
|
||||
<PARAMETER NAME="USE_WHERE_CONDITIONS_TABLE" FIELD="CHECK" NUM_ROW="8"
|
||||
SHOW_IF="(DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CLAUSE" FIELD="MEMO" NUM_ROW="10"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'false')">
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="NOTE" FIELD="LABEL" NUM_ROW="11"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'true')">
|
||||
<DEFAULT>WHERE conditions table
(for UPDATE and DELETE only)</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CONDITIONS_TABLE" FIELD="TABLE" NUM_ROW="12"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'true')">
|
||||
<ITEMS>
|
||||
<ITEM NAME="COLUMN" VALUE='""'/>
|
||||
<ITEM NAME="FUNCTION" FIELD="CLOSED_LIST">
|
||||
<ITEMS DEFAULT="EQUAL">
|
||||
<ITEM NAME="EQUAL" VALUE=""=""/>
|
||||
<ITEM NAME="GREATER" VALUE="">""/>
|
||||
<ITEM NAME="LESS" VALUE=""<""/>
|
||||
<ITEM NAME="GREATER_OR_EQUAL" VALUE="">=""/>
|
||||
<ITEM NAME="LESS_OR_EQUAL" VALUE=""<=""/>
|
||||
<ITEM NAME="NOT_EQUAL" VALUE=""<>""/>
|
||||
<ITEM NAME="BETWEEN" VALUE=""BETWEEN""/>
|
||||
<ITEM NAME="LIKE" VALUE=""LIKE""/>
|
||||
<ITEM NAME="IN" VALUE=""IN""/>
|
||||
</ITEMS>
|
||||
</ITEM>
|
||||
<ITEM NAME="VALUE_SQL" VALUE='""'/>
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="ELT_TABLE_NAME"
|
||||
|
||||
@@ -86,6 +86,8 @@ imports="
|
||||
}
|
||||
String whereClause = ElementParameterParser.getValue(node, "__WHERE_CLAUSE__");
|
||||
|
||||
boolean useWhereTable = ("true").equals(ElementParameterParser.getValue(node, "__USE_WHERE_CONDITIONS_TABLE__"));
|
||||
List<Map<String, String>> whereConditions = (List<Map<String,String>>)ElementParameterParser.getObjectValue(node, "__WHERE_CONDITIONS_TABLE__");
|
||||
%>
|
||||
|
||||
|
||||
@@ -284,39 +286,66 @@ for(Column colStmt:stmtStructure){
|
||||
<%
|
||||
}else if (("UPDATE").equals(dataAction)){
|
||||
%>
|
||||
String updateQuery_<%=cid %> = "UPDATE "+tableName_<%=cid%>+" SET <%=updateSetStmt.toString()%> " +select_query_<%=cid %>.substring(select_query_<%=cid %>.indexOf("FROM"));
|
||||
StringBuffer updateQuery_<%=cid %> = new StringBuffer("UPDATE "+tableName_<%=cid%>+" SET <%=updateSetStmt.toString()%> " +select_query_<%=cid %>.substring(select_query_<%=cid %>.indexOf("FROM")));
|
||||
<%
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
if((CodeGenerationUtils.hasAlphaNumericCharacter(whereClause) && (!useWhereTable)) || (useWhereTable && whereConditions.size() > 0)) {
|
||||
%>
|
||||
if(select_query_<%=cid %>.indexOf("WHERE")==-1){
|
||||
updateQuery_<%=cid %> +=" WHERE ";
|
||||
}else{
|
||||
updateQuery_<%=cid %> +=" AND ";
|
||||
}
|
||||
updateQuery_<%=cid %>+= <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>;
|
||||
if(select_query_<%=cid %>.indexOf("WHERE")==-1){
|
||||
updateQuery_<%=cid %>.append(" WHERE ");
|
||||
}else{
|
||||
updateQuery_<%=cid %>.append(" AND ");
|
||||
}
|
||||
<%
|
||||
if(!useWhereTable) {
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(<%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>);
|
||||
<%
|
||||
} else {
|
||||
String operator = "\"\"";
|
||||
for(Map<String, String> whereCondition : whereConditions) {
|
||||
String column_condition = whereCondition.get("COLUMN");
|
||||
String function_condition = whereCondition.get("FUNCTION");
|
||||
String value_condition = whereCondition.get("VALUE_SQL");
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(<%=operator %> + <%=column_condition %> + " " + <%=function_condition %> + " " + <%=value_condition %>);
|
||||
<%
|
||||
operator = "\" AND \"";
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>);
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>.toString());
|
||||
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
|
||||
String deleteQuery_<%=cid %> = "DELETE FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+select_query_<%=cid %>+") "
|
||||
<%
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
+" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
;
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>);
|
||||
StringBuffer deleteQuery_<%=cid %> = new StringBuffer("DELETE FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+select_query_<%=cid %>+") ");
|
||||
<%
|
||||
if(!useWhereTable) {
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
deleteQuery_<%=cid %>.append(" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>);
|
||||
<%
|
||||
}
|
||||
} else {
|
||||
if(whereConditions.size() > 0) {
|
||||
for(Map<String, String> whereCondition : whereConditions) {
|
||||
String column_condition = whereCondition.get("COLUMN");
|
||||
String function_condition = whereCondition.get("FUNCTION");
|
||||
String value_condition = whereCondition.get("VALUE_SQL");
|
||||
%>
|
||||
deleteQuery_<%=cid %>.append(" AND " + <%=column_condition %> + " " + <%=function_condition %> + " " + <%=value_condition %>);
|
||||
<%
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>.toString());
|
||||
|
||||
<%
|
||||
<%
|
||||
}
|
||||
%>
|
||||
%>
|
||||
int nb_line_<%=cid%> = 0;
|
||||
int nb_line_updated_<%=cid%> = 0;
|
||||
int nb_line_inserted_<%=cid%> = 0;
|
||||
@@ -339,7 +368,7 @@ System.out.println("--> " + nb_line_inserted_<%=cid%> + " rows inserted. \n");
|
||||
}else if(("UPDATE").equals(dataAction)){
|
||||
|
||||
%>
|
||||
System.out.println("Updating with : \n" + updateQuery_<%=cid %> +"\n");
|
||||
System.out.println("Updating with : \n" + updateQuery_<%=cid %>.toString() +"\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+updateQuery_"+ cid +"+\"");%>
|
||||
nb_line_updated_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
@@ -347,7 +376,7 @@ nb_line_updated_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Deleting with : \n" + deleteQuery_<%=cid %> +"\n");
|
||||
System.out.println("Deleting with : \n" + deleteQuery_<%=cid %>.toString() +"\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+deleteQuery_"+ cid +"+\"");%>
|
||||
nb_line_deleted_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
|
||||
@@ -15,3 +15,19 @@ NB_LINE_DELETED.NAME=Number Of Deleted Lines
|
||||
USE_DIFFERENT_TABLE.NAME=Use different table name
|
||||
DIFFERENT_TABLE_NAME.NAME=Table name
|
||||
IS_TABLE_NAME_VARIABLE.NAME=Table name from connection name is variable
|
||||
|
||||
USE_WHERE_CONDITIONS_TABLE.NAME=Use WHERE conditions table
|
||||
|
||||
WHERE_CONDITIONS_TABLE.NAME=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.COLUMN=Column
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION=Function
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.EQUAL==
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.GREATER=>
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LESS=<
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.GREATER_OR_EQUAL=>=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LESS_OR_EQUAL=<=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.NOT_EQUAL=<>
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.BETWEEN=BETWEEN
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LIKE=LIKE
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.IN=IN
|
||||
WHERE_CONDITIONS_TABLE.ITEM.VALUE_SQL=Value
|
||||
@@ -54,10 +54,41 @@
|
||||
>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CLAUSE" FIELD="MEMO" NUM_ROW="8" SHOW_IF="(DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')"
|
||||
>
|
||||
<PARAMETER NAME="USE_WHERE_CONDITIONS_TABLE" FIELD="CHECK" NUM_ROW="8"
|
||||
SHOW_IF="(DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CLAUSE" FIELD="MEMO" NUM_ROW="10"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'false')">
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="NOTE" FIELD="LABEL" NUM_ROW="11"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'true')">
|
||||
<DEFAULT>WHERE conditions table
(for UPDATE and DELETE only)</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CONDITIONS_TABLE" FIELD="TABLE" NUM_ROW="12"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'true')">
|
||||
<ITEMS>
|
||||
<ITEM NAME="COLUMN" VALUE='""'/>
|
||||
<ITEM NAME="FUNCTION" FIELD="CLOSED_LIST">
|
||||
<ITEMS DEFAULT="EQUAL">
|
||||
<ITEM NAME="EQUAL" VALUE=""=""/>
|
||||
<ITEM NAME="GREATER" VALUE="">""/>
|
||||
<ITEM NAME="LESS" VALUE=""<""/>
|
||||
<ITEM NAME="GREATER_OR_EQUAL" VALUE="">=""/>
|
||||
<ITEM NAME="LESS_OR_EQUAL" VALUE=""<=""/>
|
||||
<ITEM NAME="NOT_EQUAL" VALUE=""<>""/>
|
||||
<ITEM NAME="BETWEEN" VALUE=""BETWEEN""/>
|
||||
<ITEM NAME="LIKE" VALUE=""LIKE""/>
|
||||
<ITEM NAME="IN" VALUE=""IN""/>
|
||||
</ITEMS>
|
||||
</ITEM>
|
||||
<ITEM NAME="VALUE_SQL" VALUE='""'/>
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="ELT_TABLE_NAME"
|
||||
|
||||
@@ -1,146 +1,147 @@
|
||||
<%@ jet
|
||||
imports="
|
||||
org.talend.designer.codegen.config.CodeGeneratorArgument
|
||||
org.talend.core.model.process.INode
|
||||
org.talend.core.model.process.ElementParameterParser
|
||||
org.talend.core.model.metadata.IMetadataTable
|
||||
org.talend.core.model.metadata.IMetadataColumn
|
||||
org.talend.core.model.process.IConnection
|
||||
org.talend.commons.utils.generation.CodeGenerationUtils
|
||||
java.util.List
|
||||
java.util.ArrayList
|
||||
java.util.LinkedList
|
||||
java.util.Map
|
||||
"
|
||||
%>
|
||||
<%@ include file="../templates/Log4j/Log4jDBConnUtil.javajet"%>
|
||||
|
||||
<%
|
||||
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
|
||||
INode node = (INode)codeGenArgument.getArgument();
|
||||
|
||||
boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
|
||||
String cid = node.getUniqueName();
|
||||
|
||||
String dbtable = null;
|
||||
String dbschema = ElementParameterParser.getValue(node,"__ELT_SCHEMA_NAME__");
|
||||
String uniqueNameConnection = null;
|
||||
INode previousNode = null;
|
||||
|
||||
String differenttable = ElementParameterParser.getValue(node, "__DIFFERENT_TABLE_NAME__");
|
||||
boolean useDifferentTable = "true".equals(ElementParameterParser.getValue(node, "__USE_DIFFERENT_TABLE__"));
|
||||
boolean isTableNameVariable="true".equals(ElementParameterParser.getValue(node, "__IS_TABLE_NAME_VARIABLE__"));
|
||||
boolean useUpdateStatement="true".equals(ElementParameterParser.getValue(node, "__USE_UPDATE_STATEMENT__"));
|
||||
%>
|
||||
String select_query_<%=cid %> = null;
|
||||
String tableName_<%=cid%> = null;
|
||||
String selectQueryColumnsName_<%=cid %> = null;
|
||||
<%
|
||||
List<IConnection> connections = (List<IConnection>) node.getIncomingConnections();
|
||||
if(connections != null && connections.size() > 0 && connections.get(0) != null) {
|
||||
IConnection connection = connections.get(0);
|
||||
previousNode = connection.getSource();
|
||||
String previousComponentName = previousNode.getUniqueName();
|
||||
dbtable = connection.getName();
|
||||
uniqueNameConnection = connection.getUniqueName();
|
||||
|
||||
%>
|
||||
select_query_<%=cid %> = (String) globalMap.get("<%=previousComponentName%>"+"QUERY"+"<%=uniqueNameConnection%>");
|
||||
selectQueryColumnsName_<%=cid %> = (String) globalMap.get("<%=previousComponentName%>"+"QUERY_COLUMNS_NAME"+"<%=uniqueNameConnection%>");
|
||||
|
||||
<%
|
||||
}
|
||||
String tableName=null;
|
||||
if(useDifferentTable){
|
||||
tableName=differenttable;
|
||||
}else{
|
||||
if(isTableNameVariable){
|
||||
tableName=dbtable;
|
||||
}else{
|
||||
tableName="\""+dbtable +"\"";
|
||||
}
|
||||
}
|
||||
%>
|
||||
String dbschema_<%=cid%> = <%=dbschema%>;
|
||||
if(dbschema_<%=cid%> != null && dbschema_<%=cid%>.trim().length() > 0) {
|
||||
tableName_<%=cid%> = <%=dbschema%> + "." + <%=tableName%>;
|
||||
}else {
|
||||
tableName_<%=cid%> = <%=tableName%>;
|
||||
}
|
||||
<%
|
||||
String dataAction = ElementParameterParser.getValue(node,"__DATA_ACTION__");
|
||||
|
||||
String dbhost = null;
|
||||
String dbport = null;
|
||||
String dbname = null;
|
||||
String dbuser = null;
|
||||
boolean useExistingConn = false;
|
||||
String dbproperties = null;
|
||||
String driver = "JTDS";
|
||||
boolean useActiveDirectoryAuth = false;
|
||||
if(previousNode != null) {
|
||||
dbhost = ElementParameterParser.getValue(previousNode, "__HOST__");
|
||||
dbport = ElementParameterParser.getValue(previousNode, "__PORT__");
|
||||
dbname = ElementParameterParser.getValue(previousNode, "__DBNAME__");
|
||||
dbuser = ElementParameterParser.getValue(previousNode, "__USER__");
|
||||
useExistingConn = ("true").equals(ElementParameterParser.getValue(previousNode, "__USE_EXISTING_CONNECTION__"));
|
||||
dbproperties = ElementParameterParser.getValue(previousNode, "__PROPERTIES__");
|
||||
driver = ElementParameterParser.getValue(previousNode, "__DRIVER__");
|
||||
useActiveDirectoryAuth = "true".equals(ElementParameterParser.getValue(previousNode, "__ACTIVE_DIR_AUTH__"));
|
||||
}
|
||||
|
||||
String whereClause = ElementParameterParser.getValue(node, "__WHERE_CLAUSE__");
|
||||
|
||||
%>
|
||||
|
||||
|
||||
<%
|
||||
if(useExistingConn) {
|
||||
String connection = ElementParameterParser.getValue(previousNode, "__CONNECTION__");
|
||||
String conn = "conn_" + connection;
|
||||
%>
|
||||
java.sql.Connection conn_<%=cid%> = (java.sql.Connection)globalMap.get("<%=conn%>");
|
||||
<%
|
||||
log4jCodeGenerateUtil.useExistConnection(node);
|
||||
} else {
|
||||
if("JTDS".equals(driver)) {
|
||||
%>
|
||||
String driverClass_<%=cid%> = "net.sourceforge.jtds.jdbc.Driver";
|
||||
<%} else {%>
|
||||
String driverClass_<%=cid%> = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
|
||||
<%}%>
|
||||
java.lang.Class.forName(driverClass_<%=cid%>);
|
||||
String port_<%=cid%> = <%=dbport%>;
|
||||
String dbname_<%=cid%> = <%=dbname%> ;
|
||||
<%
|
||||
if("JTDS".equals(driver)) {
|
||||
%>
|
||||
String url_<%=cid %> = "jdbc:jtds:sqlserver://" + <%=dbhost%> ;
|
||||
<%} else {%>
|
||||
String url_<%=cid %> = "jdbc:sqlserver://" + <%=dbhost%> ;
|
||||
<%}%>
|
||||
if (!"".equals(port_<%=cid%>)) {
|
||||
url_<%=cid %> += ":" + <%=dbport%>;
|
||||
}
|
||||
if (!"".equals(dbname_<%=cid%>)) {
|
||||
<%
|
||||
if("JTDS".equals(driver)) {
|
||||
%>
|
||||
url_<%=cid%> += "//" + <%=dbname%>;
|
||||
<%} else {%>
|
||||
url_<%=cid%> += ";databaseName=" + <%=dbname%>;
|
||||
<%}%>
|
||||
}
|
||||
<%
|
||||
if (driver.equals("MSSQL_PROP") && useActiveDirectoryAuth) {
|
||||
%>
|
||||
url_<%=cid%> += ";encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;Authentication=ActiveDirectoryPassword";
|
||||
url_<%=cid%> += ";database=" + <%=dbname%>;
|
||||
<%
|
||||
}
|
||||
%>
|
||||
url_<%=cid%> += ";appName=" + projectName + ";" + <%=dbproperties%>;
|
||||
String dbUser_<%=cid %> = <%=dbuser%>;
|
||||
<%@ jet
|
||||
imports="
|
||||
org.talend.designer.codegen.config.CodeGeneratorArgument
|
||||
org.talend.core.model.process.INode
|
||||
org.talend.core.model.process.ElementParameterParser
|
||||
org.talend.core.model.metadata.IMetadataTable
|
||||
org.talend.core.model.metadata.IMetadataColumn
|
||||
org.talend.core.model.process.IConnection
|
||||
org.talend.commons.utils.generation.CodeGenerationUtils
|
||||
java.util.List
|
||||
java.util.ArrayList
|
||||
java.util.LinkedList
|
||||
java.util.Map
|
||||
"
|
||||
%>
|
||||
<%@ include file="../templates/Log4j/Log4jDBConnUtil.javajet"%>
|
||||
|
||||
<%
|
||||
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
|
||||
INode node = (INode)codeGenArgument.getArgument();
|
||||
|
||||
boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
|
||||
String cid = node.getUniqueName();
|
||||
|
||||
String dbtable = null;
|
||||
String dbschema = ElementParameterParser.getValue(node,"__ELT_SCHEMA_NAME__");
|
||||
String uniqueNameConnection = null;
|
||||
INode previousNode = null;
|
||||
|
||||
String differenttable = ElementParameterParser.getValue(node, "__DIFFERENT_TABLE_NAME__");
|
||||
boolean useDifferentTable = "true".equals(ElementParameterParser.getValue(node, "__USE_DIFFERENT_TABLE__"));
|
||||
boolean isTableNameVariable="true".equals(ElementParameterParser.getValue(node, "__IS_TABLE_NAME_VARIABLE__"));
|
||||
boolean useUpdateStatement="true".equals(ElementParameterParser.getValue(node, "__USE_UPDATE_STATEMENT__"));
|
||||
%>
|
||||
String select_query_<%=cid %> = null;
|
||||
String tableName_<%=cid%> = null;
|
||||
String selectQueryColumnsName_<%=cid %> = null;
|
||||
<%
|
||||
List<IConnection> connections = (List<IConnection>) node.getIncomingConnections();
|
||||
if(connections != null && connections.size() > 0 && connections.get(0) != null) {
|
||||
IConnection connection = connections.get(0);
|
||||
previousNode = connection.getSource();
|
||||
String previousComponentName = previousNode.getUniqueName();
|
||||
dbtable = connection.getName();
|
||||
uniqueNameConnection = connection.getUniqueName();
|
||||
|
||||
%>
|
||||
select_query_<%=cid %> = (String) globalMap.get("<%=previousComponentName%>"+"QUERY"+"<%=uniqueNameConnection%>");
|
||||
selectQueryColumnsName_<%=cid %> = (String) globalMap.get("<%=previousComponentName%>"+"QUERY_COLUMNS_NAME"+"<%=uniqueNameConnection%>");
|
||||
|
||||
<%
|
||||
}
|
||||
String tableName=null;
|
||||
if(useDifferentTable){
|
||||
tableName=differenttable;
|
||||
}else{
|
||||
if(isTableNameVariable){
|
||||
tableName=dbtable;
|
||||
}else{
|
||||
tableName="\""+dbtable +"\"";
|
||||
}
|
||||
}
|
||||
%>
|
||||
String dbschema_<%=cid%> = <%=dbschema%>;
|
||||
if(dbschema_<%=cid%> != null && dbschema_<%=cid%>.trim().length() > 0) {
|
||||
tableName_<%=cid%> = <%=dbschema%> + "." + <%=tableName%>;
|
||||
}else {
|
||||
tableName_<%=cid%> = <%=tableName%>;
|
||||
}
|
||||
<%
|
||||
String dataAction = ElementParameterParser.getValue(node,"__DATA_ACTION__");
|
||||
|
||||
String dbhost = null;
|
||||
String dbport = null;
|
||||
String dbname = null;
|
||||
String dbuser = null;
|
||||
boolean useExistingConn = false;
|
||||
String dbproperties = null;
|
||||
String driver = "JTDS";
|
||||
boolean useActiveDirectoryAuth = false;
|
||||
if(previousNode != null) {
|
||||
dbhost = ElementParameterParser.getValue(previousNode, "__HOST__");
|
||||
dbport = ElementParameterParser.getValue(previousNode, "__PORT__");
|
||||
dbname = ElementParameterParser.getValue(previousNode, "__DBNAME__");
|
||||
dbuser = ElementParameterParser.getValue(previousNode, "__USER__");
|
||||
useExistingConn = ("true").equals(ElementParameterParser.getValue(previousNode, "__USE_EXISTING_CONNECTION__"));
|
||||
dbproperties = ElementParameterParser.getValue(previousNode, "__PROPERTIES__");
|
||||
driver = ElementParameterParser.getValue(previousNode, "__DRIVER__");
|
||||
useActiveDirectoryAuth = "true".equals(ElementParameterParser.getValue(previousNode, "__ACTIVE_DIR_AUTH__"));
|
||||
}
|
||||
|
||||
String whereClause = ElementParameterParser.getValue(node, "__WHERE_CLAUSE__");
|
||||
boolean useWhereTable = ("true").equals(ElementParameterParser.getValue(node, "__USE_WHERE_CONDITIONS_TABLE__"));
|
||||
List<Map<String, String>> whereConditions = (List<Map<String,String>>)ElementParameterParser.getObjectValue(node, "__WHERE_CONDITIONS_TABLE__");
|
||||
%>
|
||||
|
||||
|
||||
<%
|
||||
if(useExistingConn) {
|
||||
String connection = ElementParameterParser.getValue(previousNode, "__CONNECTION__");
|
||||
String conn = "conn_" + connection;
|
||||
%>
|
||||
java.sql.Connection conn_<%=cid%> = (java.sql.Connection)globalMap.get("<%=conn%>");
|
||||
<%
|
||||
log4jCodeGenerateUtil.useExistConnection(node);
|
||||
} else {
|
||||
if("JTDS".equals(driver)) {
|
||||
%>
|
||||
String driverClass_<%=cid%> = "net.sourceforge.jtds.jdbc.Driver";
|
||||
<%} else {%>
|
||||
String driverClass_<%=cid%> = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
|
||||
<%}%>
|
||||
java.lang.Class.forName(driverClass_<%=cid%>);
|
||||
String port_<%=cid%> = <%=dbport%>;
|
||||
String dbname_<%=cid%> = <%=dbname%> ;
|
||||
<%
|
||||
if("JTDS".equals(driver)) {
|
||||
%>
|
||||
String url_<%=cid %> = "jdbc:jtds:sqlserver://" + <%=dbhost%> ;
|
||||
<%} else {%>
|
||||
String url_<%=cid %> = "jdbc:sqlserver://" + <%=dbhost%> ;
|
||||
<%}%>
|
||||
if (!"".equals(port_<%=cid%>)) {
|
||||
url_<%=cid %> += ":" + <%=dbport%>;
|
||||
}
|
||||
if (!"".equals(dbname_<%=cid%>)) {
|
||||
<%
|
||||
if("JTDS".equals(driver)) {
|
||||
%>
|
||||
url_<%=cid%> += "//" + <%=dbname%>;
|
||||
<%} else {%>
|
||||
url_<%=cid%> += ";databaseName=" + <%=dbname%>;
|
||||
<%}%>
|
||||
}
|
||||
<%
|
||||
if (driver.equals("MSSQL_PROP") && useActiveDirectoryAuth) {
|
||||
%>
|
||||
url_<%=cid%> += ";encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;Authentication=ActiveDirectoryPassword";
|
||||
url_<%=cid%> += ";database=" + <%=dbname%>;
|
||||
<%
|
||||
}
|
||||
%>
|
||||
url_<%=cid%> += ";appName=" + projectName + ";" + <%=dbproperties%>;
|
||||
String dbUser_<%=cid %> = <%=dbuser%>;
|
||||
|
||||
<%
|
||||
String passwordFieldName = "__PASS__";
|
||||
@@ -149,288 +150,315 @@ if(useExistingConn) {
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/eltpassword.javajet"%>
|
||||
|
||||
String dbPwd_<%=cid %> = decryptedPassword_<%=cid%>;
|
||||
|
||||
java.sql.Connection conn_<%=cid%> = null;
|
||||
<%
|
||||
log4jCodeGenerateUtil.debugConnectionParams(node);
|
||||
log4jCodeGenerateUtil.connect(node);
|
||||
}
|
||||
%>
|
||||
|
||||
<%
|
||||
List<IMetadataColumn> columnList = null;
|
||||
|
||||
List<IMetadataTable> metadatas = node.getMetadataList();
|
||||
if(metadatas !=null && metadatas.size()>0){
|
||||
IMetadataTable metadata = metadatas.get(0);
|
||||
if(metadata != null){
|
||||
columnList = metadata.getListColumns();
|
||||
}
|
||||
}
|
||||
%>
|
||||
|
||||
|
||||
java.sql.PreparedStatement pstmt_<%=cid %> =null;
|
||||
|
||||
<%
|
||||
|
||||
if(columnList != null && columnList.size()>0){
|
||||
|
||||
class Column{
|
||||
|
||||
IMetadataColumn column;
|
||||
|
||||
String name;
|
||||
|
||||
String sqlStmt;
|
||||
|
||||
String value;
|
||||
|
||||
boolean addCol;
|
||||
|
||||
List<Column> replacement = new ArrayList<Column>();
|
||||
|
||||
public Column(IMetadataColumn column){
|
||||
this.column = column;
|
||||
String columname = column.getOriginalDbColumnName();
|
||||
if(columname!=null && columname.trim().length()>0){
|
||||
this.name = columname;
|
||||
}else{
|
||||
this.name = column.getLabel();
|
||||
}
|
||||
this.sqlStmt = "=?";
|
||||
this.value = "?";
|
||||
this.addCol =false;
|
||||
}
|
||||
|
||||
public boolean isReplaced(){
|
||||
return replacement.size()>0;
|
||||
}
|
||||
|
||||
public List<Column> getReplacement(){
|
||||
return this.replacement;
|
||||
}
|
||||
|
||||
public IMetadataColumn getColumn(){
|
||||
return this.column;
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public boolean isAddCol(){
|
||||
return this.addCol;
|
||||
}
|
||||
|
||||
public String getSqlStmt(){
|
||||
return this.sqlStmt;
|
||||
}
|
||||
|
||||
public String getValue(){
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder insertColName = new StringBuilder();
|
||||
|
||||
StringBuilder insertValueStmt = new StringBuilder();
|
||||
|
||||
StringBuilder updateSetStmt = new StringBuilder();
|
||||
|
||||
StringBuilder updateWhereStmt = new StringBuilder();
|
||||
|
||||
StringBuilder mergeCondition = new StringBuilder ();
|
||||
|
||||
List<Column> stmtStructure = new LinkedList<Column>();
|
||||
|
||||
for(IMetadataColumn column:columnList){
|
||||
|
||||
stmtStructure.add(new Column(column));
|
||||
|
||||
}
|
||||
|
||||
|
||||
int counterOuter =0;
|
||||
boolean firstKey = true;
|
||||
boolean firstNoneKey = true;
|
||||
boolean isfirstKey = true;
|
||||
for(Column colStmt:stmtStructure){
|
||||
String suffix = ",";
|
||||
|
||||
if (colStmt.getColumn().isKey()){
|
||||
if (isfirstKey) {
|
||||
isfirstKey = false;
|
||||
}else {
|
||||
mergeCondition.append(" AND ");
|
||||
}
|
||||
mergeCondition.append("target." + colStmt.getColumn().getLabel() + "=source." + colStmt.getColumn().getLabel());
|
||||
}
|
||||
if(colStmt.isReplaced()){
|
||||
List<Column> replacedColumns = colStmt.getReplacement();
|
||||
int counterReplace = 0;
|
||||
if(counterOuter==(stmtStructure.size()-1) && counterReplace==(replacedColumns.size()-1) ){
|
||||
suffix = "";
|
||||
}
|
||||
for(Column replacement:replacedColumns){
|
||||
insertColName.append(replacement.getName()+suffix);
|
||||
insertValueStmt.append(replacement.getSqlStmt()+suffix);
|
||||
if(!colStmt.getColumn().isKey()){
|
||||
if(!firstNoneKey){
|
||||
updateSetStmt.append(",");
|
||||
}else{
|
||||
firstNoneKey = false;
|
||||
}
|
||||
updateSetStmt.append(replacement.getName());
|
||||
updateSetStmt.append(replacement.getSqlStmt());
|
||||
}else{
|
||||
if(!firstKey){
|
||||
updateWhereStmt.append(" AND ");
|
||||
}else{
|
||||
firstKey = false;
|
||||
}
|
||||
updateWhereStmt.append(replacement.getName());
|
||||
updateWhereStmt.append(replacement.getSqlStmt());
|
||||
}
|
||||
counterReplace++;
|
||||
}
|
||||
}else{
|
||||
if(counterOuter==(stmtStructure.size()-1)){
|
||||
suffix = "";
|
||||
}
|
||||
if(colStmt.isAddCol()){
|
||||
insertColName.append(colStmt.getName()+suffix);
|
||||
insertValueStmt.append(colStmt.getSqlStmt()+suffix);
|
||||
updateSetStmt.append(colStmt.getName());
|
||||
updateSetStmt.append(colStmt.getSqlStmt()+suffix);
|
||||
}else{
|
||||
insertColName.append(colStmt.getName()+suffix);
|
||||
insertValueStmt.append(colStmt.getValue()+suffix);
|
||||
updateSetStmt.append(colStmt.getName()+"=(\"+select_query_"+ cid +".replaceFirst(java.util.regex.Pattern.quote(selectQueryColumnsName_"+ cid +"),routines.system.StringUtils.splitSQLColumns(selectQueryColumnsName_"+ cid +")[ "+ counterOuter + "])+\")" +suffix);
|
||||
}
|
||||
}
|
||||
counterOuter ++;
|
||||
}
|
||||
|
||||
|
||||
if(("INSERT").equals(dataAction)){
|
||||
%>
|
||||
String insertQuery_<%=cid %> = "INSERT INTO "+tableName_<%=cid%>+"(<%=insertColName.toString()%>) ("+select_query_<%=cid %>+")";
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(insertQuery_<%=cid %>);
|
||||
|
||||
<%
|
||||
}else if (("UPDATE").equals(dataAction)){
|
||||
if(useUpdateStatement){
|
||||
%>
|
||||
String updateQuery_<%=cid %> = select_query_<%=cid %>;
|
||||
<%
|
||||
}else{
|
||||
%>
|
||||
String updateQuery_<%=cid %> = "UPDATE "+tableName_<%=cid%>+" SET <%=updateSetStmt.toString()%> ";
|
||||
<%
|
||||
}
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
if(useUpdateStatement){
|
||||
%>
|
||||
if(select_query_<%=cid %>.indexOf("WHERE")==-1){
|
||||
updateQuery_<%=cid %> +=" WHERE ";
|
||||
}else{
|
||||
updateQuery_<%=cid %> +=" AND ";
|
||||
}
|
||||
updateQuery_<%=cid %>+= <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>;
|
||||
<%
|
||||
}else{
|
||||
%>
|
||||
updateQuery_<%=cid %> += " WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>;
|
||||
<%
|
||||
}
|
||||
}
|
||||
%>
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>);
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
String deleteQuery_<%=cid %> = "DELETE FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+select_query_<%=cid %>+") "
|
||||
<%
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
+" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
;
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
int nb_line_<%=cid%> = 0;
|
||||
int nb_line_updated_<%=cid%> = 0;
|
||||
int nb_line_inserted_<%=cid%> = 0;
|
||||
int nb_line_deleted_<%=cid%> = 0;
|
||||
<%
|
||||
|
||||
}
|
||||
|
||||
if(dbtable != null && columnList != null){
|
||||
if(("INSERT").equals(dataAction)){
|
||||
%>
|
||||
|
||||
System.out.println("Inserting with : \n" + insertQuery_<%=cid %> + "\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+insertQuery_"+ cid +"+\"");%>
|
||||
nb_line_inserted_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
System.out.println("--> " + nb_line_inserted_<%=cid%> + " rows inserted. \n");
|
||||
|
||||
<%
|
||||
}else if(("UPDATE").equals(dataAction)){
|
||||
|
||||
%>
|
||||
System.out.println("Updating with : \n" + updateQuery_<%=cid %> +"\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+updateQuery_"+ cid +"+\"");%>
|
||||
nb_line_updated_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
System.out.println("--> " + nb_line_updated_<%=cid%> + " rows updated. \n");
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Deleting with : \n" + deleteQuery_<%=cid %> +"\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+deleteQuery_"+ cid +"+\"");%>
|
||||
nb_line_deleted_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
System.out.println("--> " + nb_line_deleted_<%=cid%> + " rows deleted. \n");
|
||||
<%
|
||||
}
|
||||
}
|
||||
|
||||
// END
|
||||
%>
|
||||
|
||||
pstmt_<%=cid %>.close();
|
||||
|
||||
<%
|
||||
if(!useExistingConn) {
|
||||
%>
|
||||
if(conn_<%=cid%> != null && !conn_<%=cid%>.isClosed()) {
|
||||
<%log4jCodeGenerateUtil.close(node);%>
|
||||
}
|
||||
<%
|
||||
}
|
||||
%>
|
||||
nb_line_<%=cid%> = nb_line_updated_<%=cid%> + nb_line_inserted_<%=cid%> + nb_line_deleted_<%=cid%>;
|
||||
|
||||
globalMap.put("<%=cid %>_NB_LINE",nb_line_<%=cid%>);
|
||||
globalMap.put("<%=cid %>_NB_LINE_UPDATED",nb_line_updated_<%=cid%>);
|
||||
globalMap.put("<%=cid %>_NB_LINE_INSERTED",nb_line_inserted_<%=cid%>);
|
||||
globalMap.put("<%=cid %>_NB_LINE_DELETED",nb_line_deleted_<%=cid%>);
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
Map<String,String> actionMap=new java.util.HashMap<String,String>();
|
||||
actionMap.put("INSERT","inserted");
|
||||
actionMap.put("UPDATE","updated");
|
||||
actionMap.put("DELETE","deleted");
|
||||
%>
|
||||
log.info("<%=cid%> - Has <%=actionMap.get(dataAction)%> records count: " + nb_line_<%=actionMap.get(dataAction)%>_<%=cid%> + ".");
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
java.sql.Connection conn_<%=cid%> = null;
|
||||
<%
|
||||
log4jCodeGenerateUtil.debugConnectionParams(node);
|
||||
log4jCodeGenerateUtil.connect(node);
|
||||
}
|
||||
%>
|
||||
|
||||
<%
|
||||
List<IMetadataColumn> columnList = null;
|
||||
|
||||
List<IMetadataTable> metadatas = node.getMetadataList();
|
||||
if(metadatas !=null && metadatas.size()>0){
|
||||
IMetadataTable metadata = metadatas.get(0);
|
||||
if(metadata != null){
|
||||
columnList = metadata.getListColumns();
|
||||
}
|
||||
}
|
||||
%>
|
||||
|
||||
|
||||
java.sql.PreparedStatement pstmt_<%=cid %> =null;
|
||||
|
||||
<%
|
||||
|
||||
if(columnList != null && columnList.size()>0){
|
||||
|
||||
class Column{
|
||||
|
||||
IMetadataColumn column;
|
||||
|
||||
String name;
|
||||
|
||||
String sqlStmt;
|
||||
|
||||
String value;
|
||||
|
||||
boolean addCol;
|
||||
|
||||
List<Column> replacement = new ArrayList<Column>();
|
||||
|
||||
public Column(IMetadataColumn column){
|
||||
this.column = column;
|
||||
String columname = column.getOriginalDbColumnName();
|
||||
if(columname!=null && columname.trim().length()>0){
|
||||
this.name = columname;
|
||||
}else{
|
||||
this.name = column.getLabel();
|
||||
}
|
||||
this.sqlStmt = "=?";
|
||||
this.value = "?";
|
||||
this.addCol =false;
|
||||
}
|
||||
|
||||
public boolean isReplaced(){
|
||||
return replacement.size()>0;
|
||||
}
|
||||
|
||||
public List<Column> getReplacement(){
|
||||
return this.replacement;
|
||||
}
|
||||
|
||||
public IMetadataColumn getColumn(){
|
||||
return this.column;
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public boolean isAddCol(){
|
||||
return this.addCol;
|
||||
}
|
||||
|
||||
public String getSqlStmt(){
|
||||
return this.sqlStmt;
|
||||
}
|
||||
|
||||
public String getValue(){
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder insertColName = new StringBuilder();
|
||||
|
||||
StringBuilder insertValueStmt = new StringBuilder();
|
||||
|
||||
StringBuilder updateSetStmt = new StringBuilder();
|
||||
|
||||
StringBuilder updateWhereStmt = new StringBuilder();
|
||||
|
||||
StringBuilder mergeCondition = new StringBuilder ();
|
||||
|
||||
List<Column> stmtStructure = new LinkedList<Column>();
|
||||
|
||||
for(IMetadataColumn column:columnList){
|
||||
|
||||
stmtStructure.add(new Column(column));
|
||||
|
||||
}
|
||||
|
||||
|
||||
int counterOuter =0;
|
||||
boolean firstKey = true;
|
||||
boolean firstNoneKey = true;
|
||||
boolean isfirstKey = true;
|
||||
for(Column colStmt:stmtStructure){
|
||||
String suffix = ",";
|
||||
|
||||
if (colStmt.getColumn().isKey()){
|
||||
if (isfirstKey) {
|
||||
isfirstKey = false;
|
||||
}else {
|
||||
mergeCondition.append(" AND ");
|
||||
}
|
||||
mergeCondition.append("target." + colStmt.getColumn().getLabel() + "=source." + colStmt.getColumn().getLabel());
|
||||
}
|
||||
if(colStmt.isReplaced()){
|
||||
List<Column> replacedColumns = colStmt.getReplacement();
|
||||
int counterReplace = 0;
|
||||
if(counterOuter==(stmtStructure.size()-1) && counterReplace==(replacedColumns.size()-1) ){
|
||||
suffix = "";
|
||||
}
|
||||
for(Column replacement:replacedColumns){
|
||||
insertColName.append(replacement.getName()+suffix);
|
||||
insertValueStmt.append(replacement.getSqlStmt()+suffix);
|
||||
if(!colStmt.getColumn().isKey()){
|
||||
if(!firstNoneKey){
|
||||
updateSetStmt.append(",");
|
||||
}else{
|
||||
firstNoneKey = false;
|
||||
}
|
||||
updateSetStmt.append(replacement.getName());
|
||||
updateSetStmt.append(replacement.getSqlStmt());
|
||||
}else{
|
||||
if(!firstKey){
|
||||
updateWhereStmt.append(" AND ");
|
||||
}else{
|
||||
firstKey = false;
|
||||
}
|
||||
updateWhereStmt.append(replacement.getName());
|
||||
updateWhereStmt.append(replacement.getSqlStmt());
|
||||
}
|
||||
counterReplace++;
|
||||
}
|
||||
}else{
|
||||
if(counterOuter==(stmtStructure.size()-1)){
|
||||
suffix = "";
|
||||
}
|
||||
if(colStmt.isAddCol()){
|
||||
insertColName.append(colStmt.getName()+suffix);
|
||||
insertValueStmt.append(colStmt.getSqlStmt()+suffix);
|
||||
updateSetStmt.append(colStmt.getName());
|
||||
updateSetStmt.append(colStmt.getSqlStmt()+suffix);
|
||||
}else{
|
||||
insertColName.append(colStmt.getName()+suffix);
|
||||
insertValueStmt.append(colStmt.getValue()+suffix);
|
||||
updateSetStmt.append(colStmt.getName()+"=(\"+select_query_"+ cid +".replaceFirst(java.util.regex.Pattern.quote(selectQueryColumnsName_"+ cid +"),routines.system.StringUtils.splitSQLColumns(selectQueryColumnsName_"+ cid +")[ "+ counterOuter + "])+\")" +suffix);
|
||||
}
|
||||
}
|
||||
counterOuter ++;
|
||||
}
|
||||
|
||||
|
||||
if(("INSERT").equals(dataAction)){
|
||||
%>
|
||||
String insertQuery_<%=cid %> = "INSERT INTO "+tableName_<%=cid%>+"(<%=insertColName.toString()%>) ("+select_query_<%=cid %>+")";
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(insertQuery_<%=cid %>);
|
||||
|
||||
<%
|
||||
}else if (("UPDATE").equals(dataAction)){
|
||||
if(useUpdateStatement){
|
||||
%>
|
||||
StringBuffer updateQuery_<%=cid %> = new StringBuffer(select_query_<%=cid %>);
|
||||
<%
|
||||
}else{
|
||||
%>
|
||||
StringBuffer updateQuery_<%=cid %> = new StringBuffer("UPDATE "+tableName_<%=cid%>+" SET <%=updateSetStmt.toString()%> ");
|
||||
<%
|
||||
}
|
||||
if((CodeGenerationUtils.hasAlphaNumericCharacter(whereClause) && (!useWhereTable)) || (useWhereTable && whereConditions.size() > 0)) {
|
||||
if(useUpdateStatement){
|
||||
%>
|
||||
if(select_query_<%=cid %>.indexOf("WHERE")==-1){
|
||||
updateQuery_<%=cid %>.append(" WHERE ");
|
||||
}else{
|
||||
updateQuery_<%=cid %>.append(" AND ");
|
||||
}
|
||||
<%
|
||||
}else{
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(" WHERE ");
|
||||
<%
|
||||
}
|
||||
if(!useWhereTable) {
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(<%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>);
|
||||
<%
|
||||
} else {
|
||||
String operator = "\"\"";
|
||||
for(Map<String, String> whereCondition : whereConditions) {
|
||||
String column_condition = whereCondition.get("COLUMN");
|
||||
String function_condition = whereCondition.get("FUNCTION");
|
||||
String value_condition = whereCondition.get("VALUE_SQL");
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(<%=operator %> + <%=column_condition %> + " " + <%=function_condition %> + " " + <%=value_condition %>);
|
||||
<%
|
||||
operator = "\" AND \"";
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>.toString());
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
StringBuffer deleteQuery_<%=cid %> = new StringBuffer("DELETE FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+select_query_<%=cid %>+") ");
|
||||
<%
|
||||
if(!useWhereTable) {
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
deleteQuery_<%=cid %>.append(" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>);
|
||||
<%
|
||||
}
|
||||
} else {
|
||||
if(whereConditions.size() > 0) {
|
||||
for(Map<String, String> whereCondition : whereConditions) {
|
||||
String column_condition = whereCondition.get("COLUMN");
|
||||
String function_condition = whereCondition.get("FUNCTION");
|
||||
String value_condition = whereCondition.get("VALUE_SQL");
|
||||
%>
|
||||
deleteQuery_<%=cid %>.append(" AND " + <%=column_condition %> + " " + <%=function_condition %> + " " + <%=value_condition %>);
|
||||
<%
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>.toString());
|
||||
<%
|
||||
}
|
||||
%>
|
||||
int nb_line_<%=cid%> = 0;
|
||||
int nb_line_updated_<%=cid%> = 0;
|
||||
int nb_line_inserted_<%=cid%> = 0;
|
||||
int nb_line_deleted_<%=cid%> = 0;
|
||||
<%
|
||||
|
||||
}
|
||||
|
||||
if(dbtable != null && columnList != null){
|
||||
if(("INSERT").equals(dataAction)){
|
||||
%>
|
||||
|
||||
System.out.println("Inserting with : \n" + insertQuery_<%=cid %> + "\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+insertQuery_"+ cid +"+\"");%>
|
||||
nb_line_inserted_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
System.out.println("--> " + nb_line_inserted_<%=cid%> + " rows inserted. \n");
|
||||
|
||||
<%
|
||||
}else if(("UPDATE").equals(dataAction)){
|
||||
|
||||
%>
|
||||
System.out.println("Updating with : \n" + updateQuery_<%=cid %>.toString() +"\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+updateQuery_"+ cid +"+\"");%>
|
||||
nb_line_updated_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
System.out.println("--> " + nb_line_updated_<%=cid%> + " rows updated. \n");
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Deleting with : \n" + deleteQuery_<%=cid %>.toString() +"\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+deleteQuery_"+ cid +"+\"");%>
|
||||
nb_line_deleted_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
System.out.println("--> " + nb_line_deleted_<%=cid%> + " rows deleted. \n");
|
||||
<%
|
||||
}
|
||||
}
|
||||
|
||||
// END
|
||||
%>
|
||||
|
||||
pstmt_<%=cid %>.close();
|
||||
|
||||
<%
|
||||
if(!useExistingConn) {
|
||||
%>
|
||||
if(conn_<%=cid%> != null && !conn_<%=cid%>.isClosed()) {
|
||||
<%log4jCodeGenerateUtil.close(node);%>
|
||||
}
|
||||
<%
|
||||
}
|
||||
%>
|
||||
nb_line_<%=cid%> = nb_line_updated_<%=cid%> + nb_line_inserted_<%=cid%> + nb_line_deleted_<%=cid%>;
|
||||
|
||||
globalMap.put("<%=cid %>_NB_LINE",nb_line_<%=cid%>);
|
||||
globalMap.put("<%=cid %>_NB_LINE_UPDATED",nb_line_updated_<%=cid%>);
|
||||
globalMap.put("<%=cid %>_NB_LINE_INSERTED",nb_line_inserted_<%=cid%>);
|
||||
globalMap.put("<%=cid %>_NB_LINE_DELETED",nb_line_deleted_<%=cid%>);
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
Map<String,String> actionMap=new java.util.HashMap<String,String>();
|
||||
actionMap.put("INSERT","inserted");
|
||||
actionMap.put("UPDATE","updated");
|
||||
actionMap.put("DELETE","deleted");
|
||||
%>
|
||||
log.info("<%=cid%> - Has <%=actionMap.get(dataAction)%> records count: " + nb_line_<%=actionMap.get(dataAction)%>_<%=cid%> + ".");
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
@@ -23,6 +23,22 @@ USER.NAME=Username
|
||||
COMMIT_EVERY.NAME=Commit every
|
||||
WHERE_CLAUSE.NAME=Where clauses \n(for UPDATE and DELETE only)
|
||||
|
||||
USE_WHERE_CONDITIONS_TABLE.NAME=Use WHERE conditions table
|
||||
|
||||
WHERE_CONDITIONS_TABLE.NAME=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.COLUMN=Column
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION=Function
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.EQUAL==
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.GREATER=>
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LESS=<
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.GREATER_OR_EQUAL=>=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LESS_OR_EQUAL=<=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.NOT_EQUAL=<>
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.BETWEEN=BETWEEN
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LIKE=LIKE
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.IN=IN
|
||||
WHERE_CONDITIONS_TABLE.ITEM.VALUE_SQL=Value
|
||||
|
||||
ELT_TABLE_NAME.NAME=Default Table Name
|
||||
ELT_SCHEMA_NAME.NAME=Default Schema Name
|
||||
NB_LINE_UPDATED.NAME=Number Of Updated Lines
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
<PARAMETER
|
||||
NAME="CONNECTION"
|
||||
FIELD="COMPONENT_LIST"
|
||||
REQUIRED="true" FILTER="REGEXP:^tJDBCConnection|tSnowflakeConnection|tSAPHanaConnection$"
|
||||
REQUIRED="true" FILTER="REGEXP:^tJDBCConnection|tSnowflakeConnection|tSAPHanaConnection|tDeltaLakeConnection$"
|
||||
NUM_ROW="2"
|
||||
SHOW_IF="(#LINK@CONNECTOR.OUT.TABLE_REF == '0') AND (USE_EXISTING_CONNECTION == 'true')"
|
||||
DYNAMIC_SETTINGS="true"/>
|
||||
|
||||
@@ -58,17 +58,44 @@
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="USE_WHERE_CONDITIONS_TABLE" FIELD="CHECK" NUM_ROW="8"
|
||||
SHOW_IF="(DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CLAUSE" FIELD="MEMO" NUM_ROW="8"
|
||||
SHOW_IF="(DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')">
|
||||
<PARAMETER NAME="WHERE_CLAUSE" FIELD="MEMO" NUM_ROW="10"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'false')">
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="NOTE" FIELD="LABEL" NUM_ROW="11"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'true')">
|
||||
<DEFAULT>WHERE conditions table
(for UPDATE and DELETE only)</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="WHERE_CONDITIONS_TABLE" FIELD="TABLE" NUM_ROW="12"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'true')">
|
||||
<ITEMS>
|
||||
<ITEM NAME="COLUMN" VALUE='""'/>
|
||||
<ITEM NAME="FUNCTION" FIELD="CLOSED_LIST">
|
||||
<ITEMS DEFAULT="EQUAL">
|
||||
<ITEM NAME="EQUAL" VALUE=""=""/>
|
||||
<ITEM NAME="GREATER" VALUE="">""/>
|
||||
<ITEM NAME="LESS" VALUE=""<""/>
|
||||
<ITEM NAME="GREATER_OR_EQUAL" VALUE="">=""/>
|
||||
<ITEM NAME="LESS_OR_EQUAL" VALUE=""<=""/>
|
||||
<ITEM NAME="NOT_EQUAL" VALUE=""<>""/>
|
||||
<ITEM NAME="BETWEEN" VALUE=""BETWEEN""/>
|
||||
<ITEM NAME="LIKE" VALUE=""LIKE""/>
|
||||
<ITEM NAME="IN" VALUE=""IN""/>
|
||||
</ITEMS>
|
||||
</ITEM>
|
||||
<ITEM NAME="VALUE_SQL" VALUE='""'/>
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="ELT_TABLE_NAME"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="10"
|
||||
NUM_ROW="13"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
@@ -65,7 +65,9 @@ imports="
|
||||
|
||||
String differenttable = ElementParameterParser.getValue(node, "__DIFFERENT_TABLE_NAME__");
|
||||
boolean useDifferentTable = "true".equals(ElementParameterParser.getValue(node, "__USE_DIFFERENT_TABLE__"));
|
||||
String whereClause = ElementParameterParser.getValue(node, "__WHERE_CLAUSE__");
|
||||
boolean useWhereTable = ("true").equals(ElementParameterParser.getValue(node, "__USE_WHERE_CONDITIONS_TABLE__"));
|
||||
String whereClause = ElementParameterParser.getValue(node, "__WHERE_CLAUSE__");
|
||||
List<Map<String, String>> whereConditions = (List<Map<String,String>>)ElementParameterParser.getObjectValue(node, "__WHERE_CONDITIONS_TABLE__");
|
||||
String tableName=null;
|
||||
if(useDifferentTable){
|
||||
tableName=differenttable;
|
||||
@@ -265,32 +267,59 @@ imports="
|
||||
<%
|
||||
} else if (("UPDATE").equals(dataAction)) {
|
||||
%>
|
||||
String updateQuery_<%=cid %> = "UPDATE "+<%=tableName%>;
|
||||
updateQuery_<%=cid %> +=" SET <%=updateSetStmt.toString()%> "
|
||||
StringBuffer updateQuery_<%=cid %> = new StringBuffer("UPDATE "+<%=tableName%>+" SET <%=updateSetStmt.toString()%> ");
|
||||
<%
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
if(!useWhereTable) {
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
+" WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
|
||||
updateQuery_<%=cid %>.append(" WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>);
|
||||
<%
|
||||
}
|
||||
} else {
|
||||
if(whereConditions.size() > 0) {
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(" WHERE ");
|
||||
<%
|
||||
String operator = "\"\"";
|
||||
for(Map<String, String> whereCondition : whereConditions) {
|
||||
String column_condition = whereCondition.get("COLUMN");
|
||||
String function_condition = whereCondition.get("FUNCTION");
|
||||
String value_condition = whereCondition.get("VALUE_SQL");
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(<%=operator %> + <%=column_condition %> + " " + <%=function_condition %> + " " + <%=value_condition %>);
|
||||
<%
|
||||
operator = "\" AND \"";
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
;
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>);
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>.toString());
|
||||
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
String deleteQuery_<%=cid %> = "DELETE FROM "+<%=tableName%>;
|
||||
deleteQuery_<%=cid %> += " WHERE EXISTS ("+select_query_<%=cid %>+")"
|
||||
StringBuffer deleteQuery_<%=cid %> = new StringBuffer("DELETE FROM "+<%=tableName%>+" WHERE EXISTS ("+select_query_<%=cid %>+")");
|
||||
<%
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
if(!useWhereTable) {
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
+" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
|
||||
deleteQuery_<%=cid %>.append(" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>);
|
||||
<%
|
||||
}
|
||||
} else {
|
||||
if(whereConditions.size() > 0) {
|
||||
for(Map<String, String> whereCondition : whereConditions) {
|
||||
String column_condition = whereCondition.get("COLUMN");
|
||||
String function_condition = whereCondition.get("FUNCTION");
|
||||
String value_condition = whereCondition.get("VALUE_SQL");
|
||||
%>
|
||||
deleteQuery_<%=cid %>.append(" AND " + <%=column_condition %> + " " + <%=function_condition %> + " " + <%=value_condition %>);
|
||||
<%
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
;
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>);
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>.toString());
|
||||
<%
|
||||
}
|
||||
%>
|
||||
@@ -312,7 +341,7 @@ imports="
|
||||
<%
|
||||
}else if(("UPDATE").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Updating with : \n" + updateQuery_<%=cid %> +"\n");
|
||||
System.out.println("Updating with : \n" + updateQuery_<%=cid %>.toString() +"\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+updateQuery_"+ cid +"+\"");%>
|
||||
nb_line_<%=cid%> += nb_line_updated_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
@@ -320,7 +349,7 @@ imports="
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Deleting with : \n" + deleteQuery_<%=cid %> +"\n");
|
||||
System.out.println("Deleting with : \n" + deleteQuery_<%=cid %>.toString() +"\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+deleteQuery_"+ cid +"+\"");%>
|
||||
nb_line_<%=cid%> += nb_line_deleted_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
|
||||
@@ -40,6 +40,22 @@ USER.NAME=Username
|
||||
WHERE_CLAUSE.NAME=Where clauses \n(for UPDATE and DELETE only)
|
||||
ELT_TABLE_NAME.NAME=Default Table Name
|
||||
|
||||
USE_WHERE_CONDITIONS_TABLE.NAME=Use WHERE conditions table
|
||||
|
||||
WHERE_CONDITIONS_TABLE.NAME=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.COLUMN=Column
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION=Function
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.EQUAL==
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.GREATER=>
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LESS=<
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.GREATER_OR_EQUAL=>=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LESS_OR_EQUAL=<=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.NOT_EQUAL=<>
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.BETWEEN=BETWEEN
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LIKE=LIKE
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.IN=IN
|
||||
WHERE_CONDITIONS_TABLE.ITEM.VALUE_SQL=Value
|
||||
|
||||
USE_DIFFERENT_TABLE.NAME=Use different table name
|
||||
DIFFERENT_TABLE_NAME.NAME=Table name
|
||||
IS_TABLE_NAME_VARIABLE.NAME=Table name from connection name is variable
|
||||
|
||||
@@ -60,16 +60,47 @@
|
||||
</PARAMETER>
|
||||
|
||||
|
||||
<PARAMETER NAME="WHERE_CLAUSE" FIELD="MEMO" NUM_ROW="8"
|
||||
SHOW_IF="(DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')">
|
||||
<PARAMETER NAME="USE_WHERE_CONDITIONS_TABLE" FIELD="CHECK" NUM_ROW="8"
|
||||
SHOW_IF="(DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CLAUSE" FIELD="MEMO" NUM_ROW="10"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'false')">
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="NOTE" FIELD="LABEL" NUM_ROW="11"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'true')">
|
||||
<DEFAULT>WHERE conditions table
(for UPDATE and DELETE only)</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CONDITIONS_TABLE" FIELD="TABLE" NUM_ROW="12"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'true')">
|
||||
<ITEMS>
|
||||
<ITEM NAME="COLUMN" VALUE='""'/>
|
||||
<ITEM NAME="FUNCTION" FIELD="CLOSED_LIST">
|
||||
<ITEMS DEFAULT="EQUAL">
|
||||
<ITEM NAME="EQUAL" VALUE=""=""/>
|
||||
<ITEM NAME="GREATER" VALUE="">""/>
|
||||
<ITEM NAME="LESS" VALUE=""<""/>
|
||||
<ITEM NAME="GREATER_OR_EQUAL" VALUE="">=""/>
|
||||
<ITEM NAME="LESS_OR_EQUAL" VALUE=""<=""/>
|
||||
<ITEM NAME="NOT_EQUAL" VALUE=""<>""/>
|
||||
<ITEM NAME="BETWEEN" VALUE=""BETWEEN""/>
|
||||
<ITEM NAME="LIKE" VALUE=""LIKE""/>
|
||||
<ITEM NAME="IN" VALUE=""IN""/>
|
||||
</ITEMS>
|
||||
</ITEM>
|
||||
<ITEM NAME="VALUE_SQL" VALUE='""'/>
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
|
||||
<PARAMETER
|
||||
NAME="ELT_TABLE_NAME"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="10"
|
||||
NUM_ROW="13"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
@@ -1,101 +1,103 @@
|
||||
<%@ jet
|
||||
imports="
|
||||
org.talend.designer.codegen.config.CodeGeneratorArgument
|
||||
org.talend.core.model.process.INode
|
||||
org.talend.core.model.process.ElementParameterParser
|
||||
org.talend.core.model.metadata.IMetadataTable
|
||||
org.talend.core.model.metadata.IMetadataColumn
|
||||
org.talend.core.model.process.IConnection
|
||||
org.talend.commons.utils.generation.CodeGenerationUtils
|
||||
java.util.List
|
||||
java.util.ArrayList
|
||||
java.util.LinkedList
|
||||
java.util.Map
|
||||
"
|
||||
%>
|
||||
<%@ include file="../templates/Log4j/Log4jDBConnUtil.javajet"%>
|
||||
|
||||
<%
|
||||
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
|
||||
INode node = (INode)codeGenArgument.getArgument();
|
||||
|
||||
boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
|
||||
String cid = node.getUniqueName();
|
||||
|
||||
String dbtable = null;
|
||||
String uniqueNameConnection = null;
|
||||
INode previousNode = null;
|
||||
boolean isTableNameVariable="true".equals(ElementParameterParser.getValue(node, "__IS_TABLE_NAME_VARIABLE__"));
|
||||
%>
|
||||
String select_query_<%=cid %> = null;
|
||||
String selectQueryColumnsName_<%=cid %> = null;
|
||||
<%
|
||||
List<IConnection> connections = (List<IConnection>) node.getIncomingConnections();
|
||||
if(connections != null && connections.size() > 0 && connections.get(0) != null) {
|
||||
IConnection connection = connections.get(0);
|
||||
previousNode = connection.getSource();
|
||||
String previousComponentName = previousNode.getUniqueName();
|
||||
dbtable = connection.getName();
|
||||
uniqueNameConnection = connection.getUniqueName();
|
||||
%>
|
||||
select_query_<%=cid %> = (String) globalMap.get("<%=previousComponentName%>"+"QUERY"+"<%=uniqueNameConnection%>");
|
||||
selectQueryColumnsName_<%=cid %> = (String) globalMap.get("<%=previousComponentName%>"+"QUERY_COLUMNS_NAME"+"<%=uniqueNameConnection%>");
|
||||
<%
|
||||
}
|
||||
|
||||
String dataAction = ElementParameterParser.getValue(node,"__DATA_ACTION__");
|
||||
String dbproperties = ElementParameterParser.getValue(node, "__PROPERTIES__");
|
||||
String dbhost = null;
|
||||
String dbport = null;
|
||||
String dbname = null;
|
||||
String dbuser = null;
|
||||
boolean useExistingConn = false;
|
||||
if(previousNode != null) {
|
||||
dbhost = ElementParameterParser.getValue(previousNode, "__HOST__");
|
||||
dbport = ElementParameterParser.getValue(previousNode, "__PORT__");
|
||||
dbname = ElementParameterParser.getValue(previousNode, "__DBNAME__");
|
||||
dbuser = ElementParameterParser.getValue(previousNode, "__USER__");
|
||||
useExistingConn = ("true").equals(ElementParameterParser.getValue(previousNode, "__USE_EXISTING_CONNECTION__"));
|
||||
}
|
||||
String differenttable = ElementParameterParser.getValue(node, "__DIFFERENT_TABLE_NAME__");
|
||||
boolean useDifferentTable = "true".equals(ElementParameterParser.getValue(node, "__USE_DIFFERENT_TABLE__"));
|
||||
String whereClause = ElementParameterParser.getValue(node, "__WHERE_CLAUSE__");
|
||||
String tableName=null;
|
||||
if(useDifferentTable){
|
||||
tableName=differenttable;
|
||||
}else{
|
||||
if(isTableNameVariable){
|
||||
tableName=dbtable;
|
||||
}else{
|
||||
tableName="\""+dbtable +"\"";
|
||||
}
|
||||
}
|
||||
%>
|
||||
java.sql.Connection conn_<%=cid%> = null;
|
||||
<%
|
||||
if(useExistingConn) {
|
||||
String connection = ElementParameterParser.getValue(previousNode, "__CONNECTION__");
|
||||
String conn = "conn_" + connection;
|
||||
%>
|
||||
conn_<%=cid%> = (java.sql.Connection)globalMap.get("<%=conn%>");
|
||||
<%
|
||||
log4jCodeGenerateUtil.useExistConnection(node);
|
||||
} else {
|
||||
%>
|
||||
String driverClass_<%=cid%> = "org.netezza.Driver";
|
||||
java.lang.Class.forName(driverClass_<%=cid%>);
|
||||
<%
|
||||
if(dbproperties == null || ("\"\"").equals(dbproperties) || ("").equals(dbproperties)) {
|
||||
%>
|
||||
String url_<%=cid%> = "jdbc:netezza://" + <%=dbhost%> + ":" + <%=dbport%> + "/" + <%=dbname%>;
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
String url_<%=cid%> = "jdbc:netezza://" + <%=dbhost%> + ":" + <%=dbport%> + "/" + <%=dbname%> + "?" + <%=dbproperties%>;
|
||||
<%
|
||||
}
|
||||
%>
|
||||
String dbUser_<%=cid %> = <%=dbuser%>;
|
||||
<%@ jet
|
||||
imports="
|
||||
org.talend.designer.codegen.config.CodeGeneratorArgument
|
||||
org.talend.core.model.process.INode
|
||||
org.talend.core.model.process.ElementParameterParser
|
||||
org.talend.core.model.metadata.IMetadataTable
|
||||
org.talend.core.model.metadata.IMetadataColumn
|
||||
org.talend.core.model.process.IConnection
|
||||
org.talend.commons.utils.generation.CodeGenerationUtils
|
||||
java.util.List
|
||||
java.util.ArrayList
|
||||
java.util.LinkedList
|
||||
java.util.Map
|
||||
"
|
||||
%>
|
||||
<%@ include file="../templates/Log4j/Log4jDBConnUtil.javajet"%>
|
||||
|
||||
<%
|
||||
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
|
||||
INode node = (INode)codeGenArgument.getArgument();
|
||||
|
||||
boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
|
||||
String cid = node.getUniqueName();
|
||||
|
||||
String dbtable = null;
|
||||
String uniqueNameConnection = null;
|
||||
INode previousNode = null;
|
||||
boolean isTableNameVariable="true".equals(ElementParameterParser.getValue(node, "__IS_TABLE_NAME_VARIABLE__"));
|
||||
%>
|
||||
String select_query_<%=cid %> = null;
|
||||
String selectQueryColumnsName_<%=cid %> = null;
|
||||
<%
|
||||
List<IConnection> connections = (List<IConnection>) node.getIncomingConnections();
|
||||
if(connections != null && connections.size() > 0 && connections.get(0) != null) {
|
||||
IConnection connection = connections.get(0);
|
||||
previousNode = connection.getSource();
|
||||
String previousComponentName = previousNode.getUniqueName();
|
||||
dbtable = connection.getName();
|
||||
uniqueNameConnection = connection.getUniqueName();
|
||||
%>
|
||||
select_query_<%=cid %> = (String) globalMap.get("<%=previousComponentName%>"+"QUERY"+"<%=uniqueNameConnection%>");
|
||||
selectQueryColumnsName_<%=cid %> = (String) globalMap.get("<%=previousComponentName%>"+"QUERY_COLUMNS_NAME"+"<%=uniqueNameConnection%>");
|
||||
<%
|
||||
}
|
||||
|
||||
String dataAction = ElementParameterParser.getValue(node,"__DATA_ACTION__");
|
||||
String dbproperties = ElementParameterParser.getValue(node, "__PROPERTIES__");
|
||||
String dbhost = null;
|
||||
String dbport = null;
|
||||
String dbname = null;
|
||||
String dbuser = null;
|
||||
boolean useExistingConn = false;
|
||||
if(previousNode != null) {
|
||||
dbhost = ElementParameterParser.getValue(previousNode, "__HOST__");
|
||||
dbport = ElementParameterParser.getValue(previousNode, "__PORT__");
|
||||
dbname = ElementParameterParser.getValue(previousNode, "__DBNAME__");
|
||||
dbuser = ElementParameterParser.getValue(previousNode, "__USER__");
|
||||
useExistingConn = ("true").equals(ElementParameterParser.getValue(previousNode, "__USE_EXISTING_CONNECTION__"));
|
||||
}
|
||||
String differenttable = ElementParameterParser.getValue(node, "__DIFFERENT_TABLE_NAME__");
|
||||
boolean useDifferentTable = "true".equals(ElementParameterParser.getValue(node, "__USE_DIFFERENT_TABLE__"));
|
||||
String whereClause = ElementParameterParser.getValue(node, "__WHERE_CLAUSE__");
|
||||
boolean useWhereTable = ("true").equals(ElementParameterParser.getValue(node, "__USE_WHERE_CONDITIONS_TABLE__"));
|
||||
List<Map<String, String>> whereConditions = (List<Map<String,String>>)ElementParameterParser.getObjectValue(node, "__WHERE_CONDITIONS_TABLE__");
|
||||
String tableName=null;
|
||||
if(useDifferentTable){
|
||||
tableName=differenttable;
|
||||
}else{
|
||||
if(isTableNameVariable){
|
||||
tableName=dbtable;
|
||||
}else{
|
||||
tableName="\""+dbtable +"\"";
|
||||
}
|
||||
}
|
||||
%>
|
||||
java.sql.Connection conn_<%=cid%> = null;
|
||||
<%
|
||||
if(useExistingConn) {
|
||||
String connection = ElementParameterParser.getValue(previousNode, "__CONNECTION__");
|
||||
String conn = "conn_" + connection;
|
||||
%>
|
||||
conn_<%=cid%> = (java.sql.Connection)globalMap.get("<%=conn%>");
|
||||
<%
|
||||
log4jCodeGenerateUtil.useExistConnection(node);
|
||||
} else {
|
||||
%>
|
||||
String driverClass_<%=cid%> = "org.netezza.Driver";
|
||||
java.lang.Class.forName(driverClass_<%=cid%>);
|
||||
<%
|
||||
if(dbproperties == null || ("\"\"").equals(dbproperties) || ("").equals(dbproperties)) {
|
||||
%>
|
||||
String url_<%=cid%> = "jdbc:netezza://" + <%=dbhost%> + ":" + <%=dbport%> + "/" + <%=dbname%>;
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
String url_<%=cid%> = "jdbc:netezza://" + <%=dbhost%> + ":" + <%=dbport%> + "/" + <%=dbname%> + "?" + <%=dbproperties%>;
|
||||
<%
|
||||
}
|
||||
%>
|
||||
String dbUser_<%=cid %> = <%=dbuser%>;
|
||||
|
||||
<%
|
||||
String passwordFieldName = "__PASS__";
|
||||
@@ -104,247 +106,273 @@ java.sql.Connection conn_<%=cid%> = null;
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/eltpassword.javajet"%>
|
||||
|
||||
String dbPwd_<%=cid %> = decryptedPassword_<%=cid%>;
|
||||
|
||||
<%
|
||||
log4jCodeGenerateUtil.debugConnectionParams(node);
|
||||
log4jCodeGenerateUtil.connect(node);
|
||||
}
|
||||
%>
|
||||
|
||||
<%
|
||||
List<IMetadataColumn> columnList = null;
|
||||
List<IMetadataTable> metadatas = node.getMetadataList();
|
||||
if(metadatas !=null && metadatas.size()>0){
|
||||
IMetadataTable metadata = metadatas.get(0);
|
||||
if(metadata != null){
|
||||
columnList = metadata.getListColumns();
|
||||
}
|
||||
}
|
||||
%>
|
||||
|
||||
java.sql.PreparedStatement pstmt_<%=cid %> =null;
|
||||
<%
|
||||
if(columnList != null && columnList.size()>0){
|
||||
|
||||
class Column{
|
||||
|
||||
IMetadataColumn column;
|
||||
|
||||
String name;
|
||||
|
||||
String sqlStmt;
|
||||
|
||||
String value;
|
||||
|
||||
boolean addCol;
|
||||
|
||||
List<Column> replacement = new ArrayList<Column>();
|
||||
|
||||
public Column(IMetadataColumn column){
|
||||
this.column = column;
|
||||
String columname = column.getOriginalDbColumnName();
|
||||
if(columname!=null && columname.trim().length()>0){
|
||||
this.name = columname;
|
||||
}else{
|
||||
this.name = column.getLabel();
|
||||
}
|
||||
this.sqlStmt = "=?";
|
||||
this.value = "?";
|
||||
this.addCol =false;
|
||||
}
|
||||
|
||||
public boolean isReplaced(){
|
||||
return replacement.size()>0;
|
||||
}
|
||||
|
||||
public List<Column> getReplacement(){
|
||||
return this.replacement;
|
||||
}
|
||||
|
||||
public IMetadataColumn getColumn(){
|
||||
return this.column;
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public boolean isAddCol(){
|
||||
return this.addCol;
|
||||
}
|
||||
|
||||
public String getSqlStmt(){
|
||||
return this.sqlStmt;
|
||||
}
|
||||
|
||||
public String getValue(){
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder insertColName = new StringBuilder();
|
||||
StringBuilder insertValueStmt = new StringBuilder();
|
||||
StringBuilder updateSetStmt = new StringBuilder();
|
||||
StringBuilder updateWhereStmt = new StringBuilder();
|
||||
List<Column> stmtStructure = new LinkedList<Column>();
|
||||
|
||||
for(IMetadataColumn column:columnList){
|
||||
stmtStructure.add(new Column(column));
|
||||
}
|
||||
|
||||
int counterOuter =0;
|
||||
boolean firstKey = true;
|
||||
boolean firstNoneKey = true;
|
||||
for(Column colStmt:stmtStructure){
|
||||
String suffix = ",";
|
||||
|
||||
if(colStmt.isReplaced()){
|
||||
List<Column> replacedColumns = colStmt.getReplacement();
|
||||
int counterReplace = 0;
|
||||
if(counterOuter==(stmtStructure.size()-1) && counterReplace==(replacedColumns.size()-1) ){
|
||||
suffix = "";
|
||||
}
|
||||
for(Column replacement:replacedColumns){
|
||||
insertColName.append(replacement.getName()+suffix);
|
||||
insertValueStmt.append(replacement.getSqlStmt()+suffix);
|
||||
if(!colStmt.getColumn().isKey()){
|
||||
if(!firstNoneKey){
|
||||
updateSetStmt.append(",");
|
||||
}else{
|
||||
firstNoneKey = false;
|
||||
}
|
||||
updateSetStmt.append(replacement.getName());
|
||||
updateSetStmt.append(replacement.getSqlStmt());
|
||||
}else{
|
||||
if(!firstKey){
|
||||
updateWhereStmt.append(" AND ");
|
||||
}else{
|
||||
firstKey = false;
|
||||
}
|
||||
updateWhereStmt.append(replacement.getName());
|
||||
updateWhereStmt.append(replacement.getSqlStmt());
|
||||
}
|
||||
counterReplace++;
|
||||
}
|
||||
}else{
|
||||
if(counterOuter==(stmtStructure.size()-1)){
|
||||
suffix = "";
|
||||
}
|
||||
if(colStmt.isAddCol()){
|
||||
insertColName.append(colStmt.getName()+suffix);
|
||||
insertValueStmt.append(colStmt.getSqlStmt()+suffix);
|
||||
updateSetStmt.append(colStmt.getName());
|
||||
updateSetStmt.append(colStmt.getSqlStmt()+suffix);
|
||||
}else{
|
||||
insertColName.append(colStmt.getName()+suffix);
|
||||
insertValueStmt.append(colStmt.getValue()+suffix);
|
||||
updateSetStmt.append(colStmt.getName()+"=\"+routines.system.StringUtils.splitSQLColumns(selectQueryColumnsName_"+ cid +")[ "+ counterOuter + "]+\"" +suffix);
|
||||
}
|
||||
}
|
||||
counterOuter ++;
|
||||
}
|
||||
|
||||
if(("INSERT").equals(dataAction)){
|
||||
%>
|
||||
String insertQuery_<%=cid %> = "INSERT INTO "+<%=tableName%>+"(<%=insertColName.toString()%>) ("+select_query_<%=cid %>+")";
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(insertQuery_<%=cid %>);
|
||||
<%
|
||||
} else if (("UPDATE").equals(dataAction)) {
|
||||
%>
|
||||
String updateQuery_<%=cid %> = "UPDATE "+<%=tableName%>;
|
||||
updateQuery_<%=cid %> +=" SET <%=updateSetStmt.toString()%> " +select_query_<%=cid %>.substring(select_query_<%=cid %>.indexOf("FROM"));
|
||||
<%
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
if(select_query_<%=cid %>.indexOf("WHERE")==-1){
|
||||
updateQuery_<%=cid %> +=" WHERE ";
|
||||
}else{
|
||||
updateQuery_<%=cid %> +=" AND ";
|
||||
}
|
||||
updateQuery_<%=cid %>+= <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>;
|
||||
<%
|
||||
}
|
||||
%>
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>);
|
||||
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
String deleteQuery_<%=cid %> = "DELETE FROM "+<%=tableName%>;
|
||||
deleteQuery_<%=cid %> += " WHERE EXISTS ("+select_query_<%=cid %>+")"
|
||||
<%
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
+" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
;
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
int nb_line_<%=cid%> = 0;
|
||||
int nb_line_updated_<%=cid%> = 0;
|
||||
int nb_line_inserted_<%=cid%> = 0;
|
||||
int nb_line_deleted_<%=cid%> = 0;
|
||||
<%
|
||||
|
||||
}
|
||||
|
||||
if(dbtable != null && columnList != null){
|
||||
if(("INSERT").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Inserting with : \n" + insertQuery_<%=cid %> + "\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+insertQuery_"+ cid +"+\"");%>
|
||||
nb_line_<%=cid%> += nb_line_inserted_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
System.out.println("--> " + nb_line_inserted_<%=cid%> + " rows inserted. \n");
|
||||
<%
|
||||
}else if(("UPDATE").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Updating with : \n" + updateQuery_<%=cid %> +"\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+updateQuery_"+ cid +"+\"");%>
|
||||
nb_line_<%=cid%> += nb_line_updated_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
System.out.println("--> " + nb_line_updated_<%=cid%> + " rows updated. \n");
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Deleting with : \n" + deleteQuery_<%=cid %> +"\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+deleteQuery_"+ cid +"+\"");%>
|
||||
nb_line_<%=cid%> += nb_line_deleted_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
System.out.println("--> " + nb_line_deleted_<%=cid%> + " rows deleted. \n");
|
||||
<%
|
||||
}
|
||||
}
|
||||
%>
|
||||
|
||||
pstmt_<%=cid %>.close();
|
||||
<%
|
||||
if(!useExistingConn) {
|
||||
%>
|
||||
if(conn_<%=cid%> != null && !conn_<%=cid%>.isClosed()) {
|
||||
<%log4jCodeGenerateUtil.close(node);%>
|
||||
}
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
globalMap.put("<%=cid %>_NB_LINE",nb_line_<%=cid%>);
|
||||
globalMap.put("<%=cid %>_NB_LINE_UPDATED",nb_line_updated_<%=cid%>);
|
||||
globalMap.put("<%=cid %>_NB_LINE_INSERTED",nb_line_inserted_<%=cid%>);
|
||||
globalMap.put("<%=cid %>_NB_LINE_DELETED",nb_line_deleted_<%=cid%>);
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
Map<String,String> actionMap=new java.util.HashMap<String,String>();
|
||||
actionMap.put("INSERT","inserted");
|
||||
actionMap.put("UPDATE","updated");
|
||||
actionMap.put("DELETE","deleted");
|
||||
%>
|
||||
log.info("<%=cid%> - Has <%=actionMap.get(dataAction)%> records count: " + nb_line_<%=actionMap.get(dataAction)%>_<%=cid%> + ".");
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
<%
|
||||
log4jCodeGenerateUtil.debugConnectionParams(node);
|
||||
log4jCodeGenerateUtil.connect(node);
|
||||
}
|
||||
%>
|
||||
|
||||
<%
|
||||
List<IMetadataColumn> columnList = null;
|
||||
List<IMetadataTable> metadatas = node.getMetadataList();
|
||||
if(metadatas !=null && metadatas.size()>0){
|
||||
IMetadataTable metadata = metadatas.get(0);
|
||||
if(metadata != null){
|
||||
columnList = metadata.getListColumns();
|
||||
}
|
||||
}
|
||||
%>
|
||||
|
||||
java.sql.PreparedStatement pstmt_<%=cid %> =null;
|
||||
<%
|
||||
if(columnList != null && columnList.size()>0){
|
||||
|
||||
class Column{
|
||||
|
||||
IMetadataColumn column;
|
||||
|
||||
String name;
|
||||
|
||||
String sqlStmt;
|
||||
|
||||
String value;
|
||||
|
||||
boolean addCol;
|
||||
|
||||
List<Column> replacement = new ArrayList<Column>();
|
||||
|
||||
public Column(IMetadataColumn column){
|
||||
this.column = column;
|
||||
String columname = column.getOriginalDbColumnName();
|
||||
if(columname!=null && columname.trim().length()>0){
|
||||
this.name = columname;
|
||||
}else{
|
||||
this.name = column.getLabel();
|
||||
}
|
||||
this.sqlStmt = "=?";
|
||||
this.value = "?";
|
||||
this.addCol =false;
|
||||
}
|
||||
|
||||
public boolean isReplaced(){
|
||||
return replacement.size()>0;
|
||||
}
|
||||
|
||||
public List<Column> getReplacement(){
|
||||
return this.replacement;
|
||||
}
|
||||
|
||||
public IMetadataColumn getColumn(){
|
||||
return this.column;
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public boolean isAddCol(){
|
||||
return this.addCol;
|
||||
}
|
||||
|
||||
public String getSqlStmt(){
|
||||
return this.sqlStmt;
|
||||
}
|
||||
|
||||
public String getValue(){
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder insertColName = new StringBuilder();
|
||||
StringBuilder insertValueStmt = new StringBuilder();
|
||||
StringBuilder updateSetStmt = new StringBuilder();
|
||||
StringBuilder updateWhereStmt = new StringBuilder();
|
||||
List<Column> stmtStructure = new LinkedList<Column>();
|
||||
|
||||
for(IMetadataColumn column:columnList){
|
||||
stmtStructure.add(new Column(column));
|
||||
}
|
||||
|
||||
int counterOuter =0;
|
||||
boolean firstKey = true;
|
||||
boolean firstNoneKey = true;
|
||||
for(Column colStmt:stmtStructure){
|
||||
String suffix = ",";
|
||||
|
||||
if(colStmt.isReplaced()){
|
||||
List<Column> replacedColumns = colStmt.getReplacement();
|
||||
int counterReplace = 0;
|
||||
if(counterOuter==(stmtStructure.size()-1) && counterReplace==(replacedColumns.size()-1) ){
|
||||
suffix = "";
|
||||
}
|
||||
for(Column replacement:replacedColumns){
|
||||
insertColName.append(replacement.getName()+suffix);
|
||||
insertValueStmt.append(replacement.getSqlStmt()+suffix);
|
||||
if(!colStmt.getColumn().isKey()){
|
||||
if(!firstNoneKey){
|
||||
updateSetStmt.append(",");
|
||||
}else{
|
||||
firstNoneKey = false;
|
||||
}
|
||||
updateSetStmt.append(replacement.getName());
|
||||
updateSetStmt.append(replacement.getSqlStmt());
|
||||
}else{
|
||||
if(!firstKey){
|
||||
updateWhereStmt.append(" AND ");
|
||||
}else{
|
||||
firstKey = false;
|
||||
}
|
||||
updateWhereStmt.append(replacement.getName());
|
||||
updateWhereStmt.append(replacement.getSqlStmt());
|
||||
}
|
||||
counterReplace++;
|
||||
}
|
||||
}else{
|
||||
if(counterOuter==(stmtStructure.size()-1)){
|
||||
suffix = "";
|
||||
}
|
||||
if(colStmt.isAddCol()){
|
||||
insertColName.append(colStmt.getName()+suffix);
|
||||
insertValueStmt.append(colStmt.getSqlStmt()+suffix);
|
||||
updateSetStmt.append(colStmt.getName());
|
||||
updateSetStmt.append(colStmt.getSqlStmt()+suffix);
|
||||
}else{
|
||||
insertColName.append(colStmt.getName()+suffix);
|
||||
insertValueStmt.append(colStmt.getValue()+suffix);
|
||||
updateSetStmt.append(colStmt.getName()+"=\"+routines.system.StringUtils.splitSQLColumns(selectQueryColumnsName_"+ cid +")[ "+ counterOuter + "]+\"" +suffix);
|
||||
}
|
||||
}
|
||||
counterOuter ++;
|
||||
}
|
||||
|
||||
if(("INSERT").equals(dataAction)){
|
||||
%>
|
||||
String insertQuery_<%=cid %> = "INSERT INTO "+<%=tableName%>+"(<%=insertColName.toString()%>) ("+select_query_<%=cid %>+")";
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(insertQuery_<%=cid %>);
|
||||
<%
|
||||
} else if (("UPDATE").equals(dataAction)) {
|
||||
%>
|
||||
StringBuffer updateQuery_<%=cid %> = new StringBuffer("UPDATE "+<%=tableName%>);
|
||||
updateQuery_<%=cid %>.append(" SET <%=updateSetStmt.toString()%> " +select_query_<%=cid %>.substring(select_query_<%=cid %>.indexOf("FROM")));
|
||||
<%
|
||||
if((CodeGenerationUtils.hasAlphaNumericCharacter(whereClause) && (!useWhereTable)) || (useWhereTable && whereConditions.size() > 0)) {
|
||||
%>
|
||||
if(select_query_<%=cid %>.indexOf("WHERE")==-1){
|
||||
updateQuery_<%=cid %>.append(" WHERE ");
|
||||
}else{
|
||||
updateQuery_<%=cid %>.append(" AND ");
|
||||
}
|
||||
<%
|
||||
if(!useWhereTable) {
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(<%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>);
|
||||
<%
|
||||
} else {
|
||||
String operator = "\"\"";
|
||||
for(Map<String, String> whereCondition : whereConditions) {
|
||||
String column_condition = whereCondition.get("COLUMN");
|
||||
String function_condition = whereCondition.get("FUNCTION");
|
||||
String value_condition = whereCondition.get("VALUE_SQL");
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(<%=operator %> + <%=column_condition %> + " " + <%=function_condition %> + " " + <%=value_condition %>);
|
||||
<%
|
||||
operator = "\" AND \"";
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>.toString());
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
StringBuffer deleteQuery_<%=cid %> = new StringBuffer("DELETE FROM "+<%=tableName%>);
|
||||
deleteQuery_<%=cid %>.append(" WHERE EXISTS ("+select_query_<%=cid %>+")");
|
||||
<%
|
||||
if(!useWhereTable) {
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
deleteQuery_<%=cid %>.append(" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>);
|
||||
<%
|
||||
}
|
||||
} else {
|
||||
if(whereConditions.size() > 0) {
|
||||
for(Map<String, String> whereCondition : whereConditions) {
|
||||
String column_condition = whereCondition.get("COLUMN");
|
||||
String function_condition = whereCondition.get("FUNCTION");
|
||||
String value_condition = whereCondition.get("VALUE_SQL");
|
||||
%>
|
||||
deleteQuery_<%=cid %>.append(" AND " + <%=column_condition %> + " " + <%=function_condition %> + " " + <%=value_condition %>);
|
||||
<%
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>.toString());
|
||||
<%
|
||||
}
|
||||
%>
|
||||
int nb_line_<%=cid%> = 0;
|
||||
int nb_line_updated_<%=cid%> = 0;
|
||||
int nb_line_inserted_<%=cid%> = 0;
|
||||
int nb_line_deleted_<%=cid%> = 0;
|
||||
<%
|
||||
|
||||
}
|
||||
|
||||
if(dbtable != null && columnList != null){
|
||||
if(("INSERT").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Inserting with : \n" + insertQuery_<%=cid %> + "\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+insertQuery_"+ cid +"+\"");%>
|
||||
nb_line_<%=cid%> += nb_line_inserted_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
System.out.println("--> " + nb_line_inserted_<%=cid%> + " rows inserted. \n");
|
||||
<%
|
||||
}else if(("UPDATE").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Updating with : \n" + updateQuery_<%=cid %>.toString() +"\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+updateQuery_"+ cid +"+\"");%>
|
||||
nb_line_<%=cid%> += nb_line_updated_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
System.out.println("--> " + nb_line_updated_<%=cid%> + " rows updated. \n");
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Deleting with : \n" + deleteQuery_<%=cid %>.toString() +"\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+deleteQuery_"+ cid +"+\"");%>
|
||||
nb_line_<%=cid%> += nb_line_deleted_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
System.out.println("--> " + nb_line_deleted_<%=cid%> + " rows deleted. \n");
|
||||
<%
|
||||
}
|
||||
}
|
||||
%>
|
||||
|
||||
pstmt_<%=cid %>.close();
|
||||
<%
|
||||
if(!useExistingConn) {
|
||||
%>
|
||||
if(conn_<%=cid%> != null && !conn_<%=cid%>.isClosed()) {
|
||||
<%log4jCodeGenerateUtil.close(node);%>
|
||||
}
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
globalMap.put("<%=cid %>_NB_LINE",nb_line_<%=cid%>);
|
||||
globalMap.put("<%=cid %>_NB_LINE_UPDATED",nb_line_updated_<%=cid%>);
|
||||
globalMap.put("<%=cid %>_NB_LINE_INSERTED",nb_line_inserted_<%=cid%>);
|
||||
globalMap.put("<%=cid %>_NB_LINE_DELETED",nb_line_deleted_<%=cid%>);
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
Map<String,String> actionMap=new java.util.HashMap<String,String>();
|
||||
actionMap.put("INSERT","inserted");
|
||||
actionMap.put("UPDATE","updated");
|
||||
actionMap.put("DELETE","deleted");
|
||||
%>
|
||||
log.info("<%=cid%> - Has <%=actionMap.get(dataAction)%> records count: " + nb_line_<%=actionMap.get(dataAction)%>_<%=cid%> + ".");
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
@@ -14,3 +14,19 @@ NB_LINE.NAME=Number of line
|
||||
NB_LINE_UPDATED.NAME=Number Of Updated Lines
|
||||
NB_LINE_INSERTED.NAME=Number Of Inserted Lines
|
||||
NB_LINE_DELETED.NAME=Number Of Deleted Lines
|
||||
|
||||
USE_WHERE_CONDITIONS_TABLE.NAME=Use WHERE conditions table
|
||||
|
||||
WHERE_CONDITIONS_TABLE.NAME=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.COLUMN=Column
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION=Function
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.EQUAL==
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.GREATER=>
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LESS=<
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.GREATER_OR_EQUAL=>=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LESS_OR_EQUAL=<=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.NOT_EQUAL=<>
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.BETWEEN=BETWEEN
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LIKE=LIKE
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.IN=IN
|
||||
WHERE_CONDITIONS_TABLE.ITEM.VALUE_SQL=Value
|
||||
@@ -38,7 +38,7 @@
|
||||
<PARAMETER
|
||||
NAME="DATA_ACTION"
|
||||
FIELD="CLOSED_LIST"
|
||||
NUM_ROW="6"
|
||||
NUM_ROW="2"
|
||||
>
|
||||
<ITEMS DEFAULT="INSERT">
|
||||
<ITEM NAME="INSERT" VALUE="INSERT" />
|
||||
@@ -51,15 +51,45 @@
|
||||
<PARAMETER
|
||||
NAME="SCHEMA"
|
||||
FIELD="SCHEMA_TYPE"
|
||||
NUM_ROW="7"
|
||||
NUM_ROW="3"
|
||||
>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CLAUSE" FIELD="MEMO" NUM_ROW="8"
|
||||
NOT_SHOW_IF="(DATA_ACTION == 'MERGE') OR (DATA_ACTION == 'INSERT')"
|
||||
>
|
||||
|
||||
<PARAMETER NAME="USE_WHERE_CONDITIONS_TABLE" FIELD="CHECK" NUM_ROW="4"
|
||||
SHOW_IF="(DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CLAUSE" FIELD="MEMO" NUM_ROW="5"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'false')">
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="NOTE" FIELD="LABEL" NUM_ROW="6"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'true')">
|
||||
<DEFAULT>WHERE conditions table
(for UPDATE and DELETE only)</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CONDITIONS_TABLE" FIELD="TABLE" NUM_ROW="7"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'true')">
|
||||
<ITEMS>
|
||||
<ITEM NAME="COLUMN" VALUE='""'/>
|
||||
<ITEM NAME="FUNCTION" FIELD="CLOSED_LIST">
|
||||
<ITEMS DEFAULT="EQUAL">
|
||||
<ITEM NAME="EQUAL" VALUE=""=""/>
|
||||
<ITEM NAME="GREATER" VALUE="">""/>
|
||||
<ITEM NAME="LESS" VALUE=""<""/>
|
||||
<ITEM NAME="GREATER_OR_EQUAL" VALUE="">=""/>
|
||||
<ITEM NAME="LESS_OR_EQUAL" VALUE=""<=""/>
|
||||
<ITEM NAME="NOT_EQUAL" VALUE=""<>""/>
|
||||
<ITEM NAME="BETWEEN" VALUE=""BETWEEN""/>
|
||||
<ITEM NAME="LIKE" VALUE=""LIKE""/>
|
||||
<ITEM NAME="IN" VALUE=""IN""/>
|
||||
</ITEMS>
|
||||
</ITEM>
|
||||
<ITEM NAME="VALUE_SQL" VALUE='""'/>
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="USE_MERGE_UPDATE"
|
||||
|
||||
@@ -87,8 +87,9 @@ imports="
|
||||
dbproperties = ElementParameterParser.getValue(previousNode, "__PROPERTIES__");
|
||||
}
|
||||
|
||||
String whereClause = ElementParameterParser.getValue(node, "__WHERE_CLAUSE__");
|
||||
|
||||
boolean useWhereTable = ("true").equals(ElementParameterParser.getValue(node, "__USE_WHERE_CONDITIONS_TABLE__"));
|
||||
String whereClause = ElementParameterParser.getValue(node, "__WHERE_CLAUSE__");
|
||||
List<Map<String, String>> whereConditions = (List<Map<String,String>>)ElementParameterParser.getObjectValue(node, "__WHERE_CONDITIONS_TABLE__");
|
||||
%>
|
||||
|
||||
|
||||
@@ -412,43 +413,70 @@ if (useHintOptions) {
|
||||
<%
|
||||
}else if (("UPDATE").equals(dataAction)){
|
||||
%>
|
||||
String updateQuery_<%=cid %> = "UPDATE "+tableName_<%=cid%>+" SET (<%=insertColName.toString()%>) = ("+select_query_<%=cid %>+") "
|
||||
StringBuffer updateQuery_<%=cid %> = new StringBuffer("UPDATE "+tableName_<%=cid%>+" SET (<%=insertColName.toString()%>) = ("+select_query_<%=cid %>+") ");
|
||||
<%
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
if(!useWhereTable) {
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
+" WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
|
||||
updateQuery_<%=cid %>.append(" WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>);
|
||||
<%
|
||||
}
|
||||
} else {
|
||||
if(whereConditions.size() > 0) {
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(" WHERE ");
|
||||
<%
|
||||
String operator = "\"\"";
|
||||
for(Map<String, String> whereCondition : whereConditions) {
|
||||
String column_condition = whereCondition.get("COLUMN");
|
||||
String function_condition = whereCondition.get("FUNCTION");
|
||||
String value_condition = whereCondition.get("VALUE_SQL");
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(<%=operator %> + <%=column_condition %> + " " + <%=function_condition %> + " " + <%=value_condition %>);
|
||||
<%
|
||||
operator = "\" AND \"";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (useHintOptions && hintsValues.get("UPDATE") != null){
|
||||
%>
|
||||
updateQuery_<%=cid %>.insert(updateQuery_<%=cid %>.toString().indexOf("UPDATE")+ "UPDATE".length() +1 , <%=hintsValues.get("UPDATE")%> + " ");
|
||||
<%
|
||||
}
|
||||
%>
|
||||
;
|
||||
<% if (useHintOptions && hintsValues.get("UPDATE") != null){
|
||||
%>
|
||||
StringBuffer updateStringBuffer_<%=cid%> = new StringBuffer(updateQuery_<%=cid %>);
|
||||
updateStringBuffer_<%=cid%>.insert(updateQuery_<%=cid %>.indexOf("UPDATE")+ "UPDATE".length() +1 , <%=hintsValues.get("UPDATE")%> + " ");
|
||||
updateQuery_<%=cid %> =updateStringBuffer_<%=cid%>.toString();
|
||||
<%
|
||||
}
|
||||
%>
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>);
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>.toString());
|
||||
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
|
||||
String deleteQuery_<%=cid %> = "DELETE FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+select_query_<%=cid %>+") "
|
||||
<%if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {%>
|
||||
+" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
|
||||
<%}%>
|
||||
;
|
||||
<%
|
||||
if(useHintOptions && hintsValues.get("DELETE") != null) {
|
||||
StringBuffer deleteQuery_<%=cid %> = new StringBuffer("DELETE FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+select_query_<%=cid %>+") ");
|
||||
<%
|
||||
if(!useWhereTable) {
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
StringBuffer deleteStringBuffer_<%=cid%> = new StringBuffer(deleteQuery_<%=cid %>);
|
||||
deleteStringBuffer_<%=cid%>.insert(deleteQuery_<%=cid %>.indexOf("DELETE")+ "DELETE".length()+1 , <%=hintsValues.get("DELETE")%> + " " );
|
||||
deleteQuery_<%=cid %> =deleteStringBuffer_<%=cid%>.toString();
|
||||
<%
|
||||
}%>
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>);
|
||||
deleteQuery_<%=cid %>.append(" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>);
|
||||
<%
|
||||
}
|
||||
} else {
|
||||
if(whereConditions.size() > 0) {
|
||||
for(Map<String, String> whereCondition : whereConditions) {
|
||||
String column_condition = whereCondition.get("COLUMN");
|
||||
String function_condition = whereCondition.get("FUNCTION");
|
||||
String value_condition = whereCondition.get("VALUE_SQL");
|
||||
%>
|
||||
deleteQuery_<%=cid %>.append(" AND " + <%=column_condition %> + " " + <%=function_condition %> + " " + <%=value_condition %>);
|
||||
<%
|
||||
}
|
||||
}
|
||||
}
|
||||
if(useHintOptions && hintsValues.get("DELETE") != null) {
|
||||
%>
|
||||
deleteQuery_<%=cid %>.insert(deleteQuery_<%=cid %>.toString().indexOf("DELETE")+ "DELETE".length()+1 , <%=hintsValues.get("DELETE")%> + " " );
|
||||
<%
|
||||
}
|
||||
%>
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>.toString());
|
||||
|
||||
<%
|
||||
}else if ("MERGE".equals(dataAction)) {
|
||||
@@ -590,7 +618,7 @@ nb_line_inserted_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
}else if(("UPDATE").equals(dataAction)){
|
||||
|
||||
%>
|
||||
<%if(!isLog4jEnabled){%>System.out.println("Updating with : \n" + updateQuery_<%=cid %> +"\n");<%}%>
|
||||
<%if(!isLog4jEnabled){%>System.out.println("Updating with : \n" + updateQuery_<%=cid %>.toString() +"\n");<%}%>
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+updateQuery_"+ cid +"+\"");%>
|
||||
nb_line_updated_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
@@ -598,7 +626,7 @@ nb_line_updated_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
<%if(!isLog4jEnabled){%>System.out.println("Deleting with : \n" + deleteQuery_<%=cid %> +"\n");<%}%>
|
||||
<%if(!isLog4jEnabled){%>System.out.println("Deleting with : \n" + deleteQuery_<%=cid %>.toString() +"\n");<%}%>
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+deleteQuery_"+ cid +"+\"");%>
|
||||
nb_line_deleted_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
|
||||
@@ -35,6 +35,22 @@ USER.NAME=Username
|
||||
COMMIT_EVERY.NAME=Commit every
|
||||
WHERE_CLAUSE.NAME=Where clauses \n(for UPDATE and DELETE only)
|
||||
|
||||
USE_WHERE_CONDITIONS_TABLE.NAME=Use WHERE conditions table
|
||||
|
||||
WHERE_CONDITIONS_TABLE.NAME=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.COLUMN=Column
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION=Function
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.EQUAL==
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.GREATER=>
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LESS=<
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.GREATER_OR_EQUAL=>=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LESS_OR_EQUAL=<=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.NOT_EQUAL=<>
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.BETWEEN=BETWEEN
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LIKE=LIKE
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.IN=IN
|
||||
WHERE_CONDITIONS_TABLE.ITEM.VALUE_SQL=Value
|
||||
|
||||
ELT_TABLE_NAME.NAME=Default Table Name
|
||||
ELT_SCHEMA_NAME.NAME=Default Schema Name
|
||||
NB_LINE_UPDATED.NAME=Number Of Updated Lines
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
>
|
||||
<ITEMS DEFAULT="INSERT">
|
||||
<ITEM NAME="INSERT" VALUE="INSERT" />
|
||||
<ITEM NAME="UPDATE" VALUE="UPDATE"/>
|
||||
<ITEM NAME="UPDATE" VALUE="UPDATE" NOT_SHOW_IF="(MAPPING == 'databricks_delta_lake_id')"/>
|
||||
<ITEM NAME="DELETE" VALUE="DELETE"/>
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
@@ -83,10 +83,41 @@
|
||||
>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CLAUSE" FIELD="MEMO" NUM_ROW="8" SHOW_IF="(DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')"
|
||||
>
|
||||
<PARAMETER NAME="USE_WHERE_CONDITIONS_TABLE" FIELD="CHECK" NUM_ROW="8"
|
||||
SHOW_IF="(DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CLAUSE" FIELD="MEMO" NUM_ROW="10"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'false')">
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="NOTE" FIELD="LABEL" NUM_ROW="11"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'true')">
|
||||
<DEFAULT>WHERE conditions table
(for UPDATE and DELETE only)</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CONDITIONS_TABLE" FIELD="TABLE" NUM_ROW="12"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'true')">
|
||||
<ITEMS>
|
||||
<ITEM NAME="COLUMN" VALUE='""'/>
|
||||
<ITEM NAME="FUNCTION" FIELD="CLOSED_LIST">
|
||||
<ITEMS DEFAULT="EQUAL">
|
||||
<ITEM NAME="EQUAL" VALUE=""=""/>
|
||||
<ITEM NAME="GREATER" VALUE="">""/>
|
||||
<ITEM NAME="LESS" VALUE=""<""/>
|
||||
<ITEM NAME="GREATER_OR_EQUAL" VALUE="">=""/>
|
||||
<ITEM NAME="LESS_OR_EQUAL" VALUE=""<=""/>
|
||||
<ITEM NAME="NOT_EQUAL" VALUE=""<>""/>
|
||||
<ITEM NAME="BETWEEN" VALUE=""BETWEEN""/>
|
||||
<ITEM NAME="LIKE" VALUE=""LIKE""/>
|
||||
<ITEM NAME="IN" VALUE=""IN""/>
|
||||
</ITEMS>
|
||||
</ITEM>
|
||||
<ITEM NAME="VALUE_SQL" VALUE='""'/>
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="ELT_TABLE_NAME"
|
||||
@@ -129,6 +160,16 @@
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="PARTITION"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="35"
|
||||
SHOW_IF="(MAPPING == 'databricks_delta_lake_id') AND (DATA_ACTION == 'INSERT')"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
|
||||
<PARAMETER
|
||||
NAME="MAPPING"
|
||||
|
||||
@@ -1,90 +1,95 @@
|
||||
<%@ jet
|
||||
imports="
|
||||
org.talend.designer.codegen.config.CodeGeneratorArgument
|
||||
org.talend.core.model.process.INode
|
||||
org.talend.core.model.process.ElementParameterParser
|
||||
org.talend.core.model.metadata.IMetadataTable
|
||||
org.talend.core.model.metadata.IMetadataColumn
|
||||
org.talend.core.model.process.IConnection
|
||||
org.talend.core.model.metadata.MappingTypeRetriever
|
||||
org.talend.core.model.metadata.MetadataTalendType
|
||||
org.talend.commons.utils.generation.CodeGenerationUtils
|
||||
org.talend.core.model.utils.NodeUtil
|
||||
java.util.List
|
||||
java.util.ArrayList
|
||||
java.util.LinkedList
|
||||
org.talend.designer.codegen.config.CodeGeneratorArgument
|
||||
org.talend.core.model.process.INode
|
||||
org.talend.core.model.process.ElementParameterParser
|
||||
org.talend.core.model.metadata.IMetadataTable
|
||||
org.talend.core.model.metadata.IMetadataColumn
|
||||
org.talend.core.model.process.IConnection
|
||||
org.talend.core.model.metadata.MappingTypeRetriever
|
||||
org.talend.core.model.metadata.MetadataTalendType
|
||||
org.talend.commons.utils.generation.CodeGenerationUtils
|
||||
org.talend.core.model.utils.NodeUtil
|
||||
java.util.List
|
||||
java.util.ArrayList
|
||||
java.util.LinkedList
|
||||
java.util.StringJoiner
|
||||
java.util.Map
|
||||
java.util.HashMap
|
||||
java.util.Map
|
||||
java.util.HashMap
|
||||
"
|
||||
skeleton="../templates/db_output_bulk.skeleton"
|
||||
%>
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/Log4j/Log4jDBConnUtil.javajet"%>
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/Log4j/DBLogUtil.javajet"%>
|
||||
<%
|
||||
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
|
||||
INode node = (INode)codeGenArgument.getArgument();
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/Log4j/Log4jDBConnUtil.javajet"%>
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/Log4j/DBLogUtil.javajet"%>
|
||||
<%
|
||||
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
|
||||
INode node = (INode)codeGenArgument.getArgument();
|
||||
|
||||
boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
|
||||
String cid = node.getUniqueName();
|
||||
boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
|
||||
String cid = node.getUniqueName();
|
||||
|
||||
String dbtable = null;
|
||||
String dbschema = ElementParameterParser.getValue(node,"__ELT_SCHEMA_NAME__");
|
||||
String uniqueNameConnection = null;
|
||||
INode previousNode = null;
|
||||
String dbtable = null;
|
||||
String dbschema = ElementParameterParser.getValue(node,"__ELT_SCHEMA_NAME__");
|
||||
String uniqueNameConnection = null;
|
||||
INode previousNode = null;
|
||||
|
||||
String differenttable = ElementParameterParser.getValue(node, "__DIFFERENT_TABLE_NAME__");
|
||||
boolean useDifferentTable = "true".equals(ElementParameterParser.getValue(node, "__USE_DIFFERENT_TABLE__"));
|
||||
boolean isTableNameVariable="true".equals(ElementParameterParser.getValue(node, "__IS_TABLE_NAME_VARIABLE__"));
|
||||
boolean useUpdateStatement="true".equals(ElementParameterParser.getValue(node, "__USE_UPDATE_STATEMENT__"));
|
||||
%>
|
||||
String select_query_<%=cid %> = null;
|
||||
String tableName_<%=cid%> = null;
|
||||
String selectQueryColumnsName_<%=cid %> = null;
|
||||
<%
|
||||
List<IConnection> connections = (List<IConnection>) node.getIncomingConnections();
|
||||
if(connections != null && connections.size() > 0 && connections.get(0) != null) {
|
||||
IConnection connection = connections.get(0);
|
||||
previousNode = connection.getSource();
|
||||
String previousComponentName = previousNode.getUniqueName();
|
||||
dbtable = connection.getName();
|
||||
uniqueNameConnection = connection.getUniqueName();
|
||||
String differenttable = ElementParameterParser.getValue(node, "__DIFFERENT_TABLE_NAME__");
|
||||
boolean useDifferentTable = "true".equals(ElementParameterParser.getValue(node, "__USE_DIFFERENT_TABLE__"));
|
||||
boolean isTableNameVariable="true".equals(ElementParameterParser.getValue(node, "__IS_TABLE_NAME_VARIABLE__"));
|
||||
boolean useUpdateStatement="true".equals(ElementParameterParser.getValue(node, "__USE_UPDATE_STATEMENT__"));
|
||||
String dbmsId = ElementParameterParser.getValue(node,"__MAPPING__");
|
||||
boolean isDeltaLake = "databricks_delta_lake_id".equals(dbmsId);
|
||||
String partition = ElementParameterParser.getValue(node, "__PARTITION__");
|
||||
%>
|
||||
String select_query_<%=cid %> = null;
|
||||
String tableName_<%=cid%> = null;
|
||||
String selectQueryColumnsName_<%=cid %> = null;
|
||||
<%
|
||||
List<IConnection> connections = (List<IConnection>) node.getIncomingConnections();
|
||||
if(connections != null && connections.size() > 0 && connections.get(0) != null) {
|
||||
IConnection connection = connections.get(0);
|
||||
previousNode = connection.getSource();
|
||||
String previousComponentName = previousNode.getUniqueName();
|
||||
dbtable = connection.getName();
|
||||
uniqueNameConnection = connection.getUniqueName();
|
||||
|
||||
%>
|
||||
select_query_<%=cid %> = (String) globalMap.get("<%=previousComponentName%>"+"QUERY"+"<%=uniqueNameConnection%>");
|
||||
selectQueryColumnsName_<%=cid %> = (String) globalMap.get("<%=previousComponentName%>"+"QUERY_COLUMNS_NAME"+"<%=uniqueNameConnection%>");
|
||||
<%
|
||||
}
|
||||
String tableName=null;
|
||||
if(useDifferentTable){
|
||||
tableName=differenttable;
|
||||
}else{
|
||||
if(isTableNameVariable){
|
||||
tableName=dbtable;
|
||||
}else{
|
||||
tableName="\""+dbtable +"\"";
|
||||
}
|
||||
}
|
||||
%>
|
||||
String dbschema_<%=cid%> = <%=dbschema%>;
|
||||
if(dbschema_<%=cid%> != null && dbschema_<%=cid%>.trim().length() > 0) {
|
||||
tableName_<%=cid%> = <%=dbschema%> + "." + <%=tableName%>;
|
||||
}else {
|
||||
tableName_<%=cid%> = <%=tableName%>;
|
||||
}
|
||||
<%
|
||||
String dataAction = ElementParameterParser.getValue(node,"__DATA_ACTION__");
|
||||
%>
|
||||
select_query_<%=cid %> = (String) globalMap.get("<%=previousComponentName%>"+"QUERY"+"<%=uniqueNameConnection%>");
|
||||
selectQueryColumnsName_<%=cid %> = (String) globalMap.get("<%=previousComponentName%>"+"QUERY_COLUMNS_NAME"+"<%=uniqueNameConnection%>");
|
||||
<%
|
||||
}
|
||||
String tableName=null;
|
||||
if(useDifferentTable){
|
||||
tableName=differenttable;
|
||||
}else{
|
||||
if(isTableNameVariable){
|
||||
tableName=dbtable;
|
||||
}else{
|
||||
tableName="\""+dbtable +"\"";
|
||||
}
|
||||
}
|
||||
%>
|
||||
String dbschema_<%=cid%> = <%=dbschema%>;
|
||||
if(dbschema_<%=cid%> != null && dbschema_<%=cid%>.trim().length() > 0) {
|
||||
tableName_<%=cid%> = <%=dbschema%> + "." + <%=tableName%>;
|
||||
}else {
|
||||
tableName_<%=cid%> = <%=tableName%>;
|
||||
}
|
||||
<%
|
||||
String dataAction = ElementParameterParser.getValue(node,"__DATA_ACTION__");
|
||||
String driverClass = null;
|
||||
String jdbcUrl = null;
|
||||
String dbuser = null;
|
||||
boolean useExistingConn = false;
|
||||
if(previousNode != null) {
|
||||
driverClass = ElementParameterParser.getValue(previousNode, "__DRIVER_CLASS__");
|
||||
jdbcUrl = ElementParameterParser.getValue(previousNode, "__URL__");
|
||||
dbuser = ElementParameterParser.getValue(previousNode, "__USER__");
|
||||
useExistingConn = ("true").equals(ElementParameterParser.getValue(previousNode, "__USE_EXISTING_CONNECTION__"));
|
||||
driverClass = ElementParameterParser.getValue(previousNode, "__DRIVER_CLASS__");
|
||||
jdbcUrl = ElementParameterParser.getValue(previousNode, "__URL__");
|
||||
dbuser = ElementParameterParser.getValue(previousNode, "__USER__");
|
||||
useExistingConn = ("true").equals(ElementParameterParser.getValue(previousNode, "__USE_EXISTING_CONNECTION__"));
|
||||
}
|
||||
String whereClause = ElementParameterParser.getValue(node, "__WHERE_CLAUSE__");
|
||||
boolean useWhereTable = ("true").equals(ElementParameterParser.getValue(node, "__USE_WHERE_CONDITIONS_TABLE__"));
|
||||
String whereClause = ElementParameterParser.getValue(node, "__WHERE_CLAUSE__");
|
||||
List<Map<String, String>> whereConditions = (List<Map<String,String>>)ElementParameterParser.getObjectValue(node, "__WHERE_CONDITIONS_TABLE__");
|
||||
%>
|
||||
String dbUser_<%=cid %> = null;
|
||||
<%
|
||||
@@ -97,7 +102,7 @@ skeleton="../templates/db_output_bulk.skeleton"
|
||||
if("tSnowflakeConnection".equals(connNode.getComponent().getName())){
|
||||
connectionKey=connection+"_connection";
|
||||
}else{
|
||||
connectionKey=conn;
|
||||
connectionKey=conn;
|
||||
}
|
||||
%>
|
||||
java.sql.Connection conn_<%=cid%> = (java.sql.Connection)globalMap.get("<%=connectionKey%>");
|
||||
@@ -110,26 +115,27 @@ skeleton="../templates/db_output_bulk.skeleton"
|
||||
java.lang.Class.forName(driverClass_<%=cid%>);
|
||||
String url_<%=cid %> = <%=jdbcUrl %>;
|
||||
dbUser_<%=cid %> = <%=dbuser%>;
|
||||
<%
|
||||
String passwordFieldName = "__PASS__";
|
||||
%>
|
||||
<%
|
||||
String passwordFieldName = "__PASS__";
|
||||
%>
|
||||
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/eltpassword.javajet"%>
|
||||
String dbPwd_<%=cid %> = decryptedPassword_<%=cid%>;
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/eltpassword.javajet"%>
|
||||
String dbPwd_<%=cid %> = decryptedPassword_<%=cid%>;
|
||||
java.sql.Connection conn_<%=cid%> = null;
|
||||
<%
|
||||
log4jCodeGenerateUtil.debugConnectionParams(node);
|
||||
log4jCodeGenerateUtil.connect(node);
|
||||
log4jCodeGenerateUtil.debugConnectionParams(node);
|
||||
log4jCodeGenerateUtil.connect(node);
|
||||
|
||||
}
|
||||
|
||||
List<IMetadataColumn> columnList = null;
|
||||
|
||||
List<IMetadataTable> metadatas = node.getMetadataList();
|
||||
if(metadatas !=null && metadatas.size()>0){
|
||||
IMetadataTable metadata = metadatas.get(0);
|
||||
if(metadata != null){
|
||||
columnList = metadata.getListColumns();
|
||||
}
|
||||
IMetadataTable metadata = metadatas.get(0);
|
||||
if(metadata != null){
|
||||
columnList = metadata.getListColumns();
|
||||
}
|
||||
}
|
||||
|
||||
if(columnList != null && columnList.size()>0){
|
||||
@@ -140,16 +146,16 @@ skeleton="../templates/db_output_bulk.skeleton"
|
||||
List<Map<String, String>> setColumns = (List<Map<String,String>>)ElementParameterParser.getObjectValue(node, "__SET_COLUMN__");
|
||||
int counterOuter = 0;
|
||||
for(IMetadataColumn column : columnList){
|
||||
String suffix = ",";
|
||||
String suffix = ",";
|
||||
|
||||
if(counterOuter==(columnList.size()-1)){
|
||||
suffix = "";
|
||||
}
|
||||
if(counterOuter==(columnList.size()-1)){
|
||||
suffix = "";
|
||||
}
|
||||
|
||||
String columnName = column.getOriginalDbColumnName();
|
||||
if(columnName==null || columnName.trim().isEmpty()){
|
||||
columnName = column.getLabel();
|
||||
}
|
||||
String columnName = column.getOriginalDbColumnName();
|
||||
if(columnName==null || columnName.trim().isEmpty()){
|
||||
columnName = column.getLabel();
|
||||
}
|
||||
boolean isUpdateColumn = "true".equals(setColumns.get(counterOuter).get("UPDATE_COLUMN"));
|
||||
insertColName.append(columnName).append(suffix);
|
||||
if (isUpdate && isUpdateColumn) {
|
||||
@@ -159,50 +165,100 @@ skeleton="../templates/db_output_bulk.skeleton"
|
||||
}
|
||||
|
||||
if(("INSERT").equals(dataAction)){
|
||||
if(isDeltaLake){
|
||||
%>
|
||||
String insertQuery_<%=cid %> = "INSERT INTO "+tableName_<%=cid%> +
|
||||
<%
|
||||
if(partition != null && !"\"\"".equals(partition)){%> " PARTITION (" + <%=partition%> + ")" +<%}
|
||||
%>
|
||||
"("+select_query_<%=cid %>+")";
|
||||
<%}else{%>
|
||||
String insertQuery_<%=cid %> = "INSERT INTO "+tableName_<%=cid%>+"(<%=insertColName.toString()%>) ("+select_query_<%=cid %>+")";
|
||||
<%
|
||||
}
|
||||
} else if (("UPDATE").equals(dataAction)){
|
||||
if(useUpdateStatement){
|
||||
boolean useAnd = false;
|
||||
if(isDeltaLake){
|
||||
%>
|
||||
String updateQuery_<%=cid %> = null;
|
||||
if (true)
|
||||
throw new RuntimeException("UPDATE action is not supported by tELTOutput. Please use tDeltaLakeRow.");
|
||||
<%
|
||||
}else if(useUpdateStatement){
|
||||
%>
|
||||
String updateQuery_<%=cid %> = select_query_<%=cid %>;
|
||||
StringBuffer updateQuery_<%=cid %> = new StringBuffer(select_query_<%=cid %>);
|
||||
<%
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
if((CodeGenerationUtils.hasAlphaNumericCharacter(whereClause) && (!useWhereTable)) || (useWhereTable && whereConditions.size() > 0)) {
|
||||
%>
|
||||
if (updateQuery_<%=cid %>.toUpperCase().contains(" WHERE ")) {
|
||||
updateQuery_<%=cid %> += " AND (" + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%> + ")";
|
||||
if (updateQuery_<%=cid %>.toString().toUpperCase().contains(" WHERE ")) {
|
||||
<%
|
||||
useAnd = true;
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(" AND (");
|
||||
} else {
|
||||
updateQuery_<%=cid %> += " WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>;
|
||||
updateQuery_<%=cid %>.append(" WHERE ");
|
||||
}
|
||||
<%
|
||||
}
|
||||
} else {
|
||||
%>
|
||||
String updateQuery_<%=cid %> = "UPDATE "+tableName_<%=cid%>+" SET <%=updateSetStmt.toString()%> "
|
||||
StringBuffer updateQuery_<%=cid %> = new StringBuffer("UPDATE "+tableName_<%=cid%>+" SET <%=updateSetStmt.toString()%> ");
|
||||
<%
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
if((CodeGenerationUtils.hasAlphaNumericCharacter(whereClause) && (!useWhereTable)) || (useWhereTable && whereConditions.size() > 0)) {
|
||||
%>
|
||||
+" WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
|
||||
updateQuery_<%=cid %>.append(" WHERE ");
|
||||
<%
|
||||
}
|
||||
%>
|
||||
;
|
||||
<%
|
||||
}
|
||||
if(!useWhereTable) {
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(<%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>);
|
||||
<%
|
||||
}
|
||||
} else {
|
||||
if(whereConditions.size() > 0) {
|
||||
String operator = "\"\"";
|
||||
for(Map<String, String> whereCondition : whereConditions) {
|
||||
String column_condition = whereCondition.get("COLUMN");
|
||||
String function_condition = whereCondition.get("FUNCTION");
|
||||
String value_condition = whereCondition.get("VALUE_SQL");
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(<%=operator %> + <%=column_condition %> + " " + <%=function_condition %> + " " + <%=value_condition %>);
|
||||
<%
|
||||
operator = "\" AND \"";
|
||||
}
|
||||
}
|
||||
}
|
||||
if(useAnd) {
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(")");
|
||||
<%
|
||||
}
|
||||
} else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
String deleteQuery_<%=cid %> = "DELETE FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+select_query_<%=cid %>+") "
|
||||
<%
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
+" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
;
|
||||
<%
|
||||
%>
|
||||
StringBuffer deleteQuery_<%=cid %> = new StringBuffer("DELETE FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+select_query_<%=cid %>+") ");
|
||||
<%
|
||||
if(!useWhereTable) {
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
deleteQuery_<%=cid %>.append(" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>);
|
||||
<%
|
||||
}
|
||||
} else {
|
||||
if(whereConditions.size() > 0) {
|
||||
for(Map<String, String> whereCondition : whereConditions) {
|
||||
String column_condition = whereCondition.get("COLUMN");
|
||||
String function_condition = whereCondition.get("FUNCTION");
|
||||
String value_condition = whereCondition.get("VALUE_SQL");
|
||||
%>
|
||||
deleteQuery_<%=cid %>.append(" AND " + <%=column_condition %> + " " + <%=function_condition %> + " " + <%=value_condition %>);
|
||||
<%
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
%>
|
||||
|
||||
int nb_line_<%=cid%> = 0;
|
||||
int nb_line_updated_<%=cid%> = 0;
|
||||
@@ -211,24 +267,25 @@ skeleton="../templates/db_output_bulk.skeleton"
|
||||
<%
|
||||
}
|
||||
|
||||
if(dbtable != null && columnList != null){
|
||||
{//use the block to limit the code scope for table action
|
||||
Manager manager = null;
|
||||
String dbmsId = ElementParameterParser.getValue(node,"__MAPPING__");
|
||||
String tableAction = ElementParameterParser.getValue(node,"__TABLE_ACTION__");
|
||||
if(dbtable != null && columnList != null){
|
||||
|
||||
{//use the block to limit the code scope for table action
|
||||
Manager manager = null;
|
||||
|
||||
String tableAction = ElementParameterParser.getValue(node,"__TABLE_ACTION__");
|
||||
|
||||
List<Column> stmtStructure = getELTManager(dbmsId, cid, node).createColumnList(columnList, false, null, null);
|
||||
List<Column> stmtStructure = getELTManager(dbmsId, cid, node).createColumnList(columnList, false, null, null);
|
||||
|
||||
String table = useDifferentTable ? differenttable : ("\""+dbtable +"\"");
|
||||
String table = useDifferentTable ? differenttable : ("\""+dbtable +"\"");
|
||||
|
||||
dbLog = new DBLogUtil(node);
|
||||
%>
|
||||
<%@ include file="../templates/_tableActionForELT.javajet"%>
|
||||
<%
|
||||
}
|
||||
dbLog = new DBLogUtil(node);
|
||||
%>
|
||||
<%@ include file="../templates/_tableActionForELT.javajet"%>
|
||||
<%
|
||||
}
|
||||
|
||||
if(("INSERT").equals(dataAction)){
|
||||
%>
|
||||
if(("INSERT").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Inserting with : \n" + insertQuery_<%=cid %> + "\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+insertQuery_"+ cid +"+\"");%>
|
||||
java.sql.PreparedStatement pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(insertQuery_<%=cid %>);
|
||||
@@ -239,9 +296,9 @@ skeleton="../templates/db_output_bulk.skeleton"
|
||||
<%
|
||||
} else if(("UPDATE").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Updating with : \n" + updateQuery_<%=cid %> +"\n");
|
||||
System.out.println("Updating with : \n" + updateQuery_<%=cid %>.toString() +"\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+updateQuery_"+ cid +"+\"");%>
|
||||
java.sql.PreparedStatement pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>);
|
||||
java.sql.PreparedStatement pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>.toString());
|
||||
nb_line_updated_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
System.out.println("--> " + nb_line_updated_<%=cid%> + " rows updated. \n");
|
||||
@@ -249,9 +306,9 @@ skeleton="../templates/db_output_bulk.skeleton"
|
||||
<%
|
||||
} else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Deleting with : \n" + deleteQuery_<%=cid %> +"\n");
|
||||
System.out.println("Deleting with : \n" + deleteQuery_<%=cid %>.toString() +"\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+deleteQuery_"+ cid +"+\"");%>
|
||||
java.sql.PreparedStatement pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>);
|
||||
java.sql.PreparedStatement pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>.toString());
|
||||
nb_line_deleted_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
System.out.println("--> " + nb_line_deleted_<%=cid%> + " rows deleted. \n");
|
||||
@@ -266,7 +323,7 @@ skeleton="../templates/db_output_bulk.skeleton"
|
||||
if(!useExistingConn) {
|
||||
%>
|
||||
if(conn_<%=cid%> != null && !conn_<%=cid%>.isClosed()) {
|
||||
<%log4jCodeGenerateUtil.close(node);%>
|
||||
<%log4jCodeGenerateUtil.close(node);%>
|
||||
}
|
||||
<%
|
||||
}
|
||||
@@ -278,12 +335,12 @@ skeleton="../templates/db_output_bulk.skeleton"
|
||||
globalMap.put("<%=cid %>_NB_LINE_DELETED",nb_line_deleted_<%=cid%>);
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
Map<String,String> actionMap=new java.util.HashMap<String,String>();
|
||||
actionMap.put("INSERT","inserted");
|
||||
actionMap.put("UPDATE","updated");
|
||||
actionMap.put("DELETE","deleted");
|
||||
%>
|
||||
log.info("<%=cid%> - Has <%=actionMap.get(dataAction)%> records count: " + nb_line_<%=actionMap.get(dataAction)%>_<%=cid%> + ".");
|
||||
Map<String,String> actionMap=new java.util.HashMap<String,String>();
|
||||
actionMap.put("INSERT","inserted");
|
||||
actionMap.put("UPDATE","updated");
|
||||
actionMap.put("DELETE","deleted");
|
||||
%>
|
||||
log.info("<%=cid%> - Has <%=actionMap.get(dataAction)%> records count: " + nb_line_<%=actionMap.get(dataAction)%>_<%=cid%> + ".");
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
@@ -23,6 +23,22 @@ USER.NAME=Username
|
||||
COMMIT_EVERY.NAME=Commit every
|
||||
WHERE_CLAUSE.NAME=Where clauses \n(for UPDATE and DELETE only)
|
||||
|
||||
USE_WHERE_CONDITIONS_TABLE.NAME=Use WHERE conditions table
|
||||
|
||||
WHERE_CONDITIONS_TABLE.NAME=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.COLUMN=Column
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION=Function
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.EQUAL==
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.GREATER=>
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LESS=<
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.GREATER_OR_EQUAL=>=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LESS_OR_EQUAL=<=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.NOT_EQUAL=<>
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.BETWEEN=BETWEEN
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LIKE=LIKE
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.IN=IN
|
||||
WHERE_CONDITIONS_TABLE.ITEM.VALUE_SQL=Value
|
||||
|
||||
ELT_TABLE_NAME.NAME=Default Table Name
|
||||
ELT_SCHEMA_NAME.NAME=Default Schema Name
|
||||
NB_LINE_UPDATED.NAME=Number Of Updated Lines
|
||||
@@ -44,4 +60,6 @@ TABLE_ACTION.NAME=Action on table
|
||||
|
||||
USE_UPDATE_STATEMENT.NAME=Use update statement without subqueries
|
||||
SET_COLUMN.ITEM.UPDATE_COLUMN=Update column
|
||||
SET_COLUMN.NAME=Clause SET
|
||||
SET_COLUMN.NAME=Clause SET
|
||||
|
||||
PARTITION.NAME=Partition
|
||||
@@ -87,6 +87,19 @@
|
||||
REPOSITORY_VALUE="DATABASE:POSTGRESQL"
|
||||
/>
|
||||
|
||||
<PARAMETER
|
||||
NAME="DB_VERSION"
|
||||
FIELD="CLOSED_LIST"
|
||||
NUM_ROW="30"
|
||||
SHOW_IF="(#LINK@CONNECTOR.OUT.TABLE_REF == '0') AND (USE_EXISTING_CONNECTION == 'false')"
|
||||
REPOSITORY_VALUE="DB_VERSION"
|
||||
>
|
||||
<ITEMS DEFAULT="V9_X">
|
||||
<ITEM NAME="PRIOR_TO_V9" VALUE="PRIOR_TO_V9" />
|
||||
<ITEM NAME="V9_X" VALUE="V9_X" />
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
|
||||
<PARAMETER
|
||||
NAME="HOST"
|
||||
@@ -175,7 +188,11 @@
|
||||
</ADVANCED_PARAMETERS>
|
||||
|
||||
<CODEGENERATION>
|
||||
</CODEGENERATION>
|
||||
<IMPORTS>
|
||||
<IMPORT NAME="Driver-Postgres9" MODULE="postgresql-42.2.14.jar" MVN="mvn:org.postgresql/postgresql/42.2.14" REQUIRED_IF="DB_VERSION =='V9_X'" />
|
||||
<IMPORT NAME="Driver-Postgres" MODULE="postgresql-8.4-703.jdbc4.jar" MVN="mvn:postgresql/postgresql/8.4-703.jdbc4" REQUIRED_IF="DB_VERSION =='PRIOR_TO_V9'" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
<RETURNS>
|
||||
</RETURNS>
|
||||
|
||||
@@ -38,3 +38,7 @@ LINK_STYLE.ITEM.AUTO=Auto
|
||||
LINK_STYLE.ITEM.BEZIER_CURVE=Bezier curve
|
||||
LINK_STYLE.ITEM.LINE=Line (fastest)
|
||||
CONNECTION.NAME=Component List
|
||||
|
||||
DB_VERSION.NAME=DB Version
|
||||
DB_VERSION.ITEM.PRIOR_TO_V9=Prior to v9
|
||||
DB_VERSION.ITEM.V9_X=v9 and later
|
||||
|
||||
@@ -54,10 +54,41 @@
|
||||
>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CLAUSE" FIELD="MEMO" NUM_ROW="8" SHOW_IF="(DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')"
|
||||
>
|
||||
<PARAMETER NAME="USE_WHERE_CONDITIONS_TABLE" FIELD="CHECK" NUM_ROW="8"
|
||||
SHOW_IF="(DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CLAUSE" FIELD="MEMO" NUM_ROW="10"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'false')">
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="NOTE" FIELD="LABEL" NUM_ROW="11"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'true')">
|
||||
<DEFAULT>WHERE conditions table
(for UPDATE and DELETE only)</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CONDITIONS_TABLE" FIELD="TABLE" NUM_ROW="12"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'true')">
|
||||
<ITEMS>
|
||||
<ITEM NAME="COLUMN" VALUE='""'/>
|
||||
<ITEM NAME="FUNCTION" FIELD="CLOSED_LIST">
|
||||
<ITEMS DEFAULT="EQUAL">
|
||||
<ITEM NAME="EQUAL" VALUE=""=""/>
|
||||
<ITEM NAME="GREATER" VALUE="">""/>
|
||||
<ITEM NAME="LESS" VALUE=""<""/>
|
||||
<ITEM NAME="GREATER_OR_EQUAL" VALUE="">=""/>
|
||||
<ITEM NAME="LESS_OR_EQUAL" VALUE=""<=""/>
|
||||
<ITEM NAME="NOT_EQUAL" VALUE=""<>""/>
|
||||
<ITEM NAME="BETWEEN" VALUE=""BETWEEN""/>
|
||||
<ITEM NAME="LIKE" VALUE=""LIKE""/>
|
||||
<ITEM NAME="IN" VALUE=""IN""/>
|
||||
</ITEMS>
|
||||
</ITEM>
|
||||
<ITEM NAME="VALUE_SQL" VALUE='""'/>
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="ELT_TABLE_NAME"
|
||||
@@ -118,12 +149,8 @@
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
</ADVANCED_PARAMETERS>
|
||||
|
||||
<CODEGENERATION>
|
||||
<IMPORTS>
|
||||
<IMPORT NAME="Driver-Postgres" MODULE="postgresql-8.4-703.jdbc4.jar" MVN="mvn:postgresql/postgresql/8.4-703.jdbc4" REQUIRED="true" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
<CODEGENERATION/>
|
||||
|
||||
<RETURNS>
|
||||
<RETURN NAME="NB_LINE" TYPE="id_Integer" AVAILABILITY="AFTER"/>
|
||||
|
||||
@@ -84,6 +84,8 @@ imports="
|
||||
}
|
||||
|
||||
String whereClause = ElementParameterParser.getValue(node, "__WHERE_CLAUSE__");
|
||||
boolean useWhereTable = ("true").equals(ElementParameterParser.getValue(node, "__USE_WHERE_CONDITIONS_TABLE__"));
|
||||
List<Map<String, String>> whereConditions = (List<Map<String,String>>)ElementParameterParser.getObjectValue(node, "__WHERE_CONDITIONS_TABLE__");
|
||||
|
||||
%>
|
||||
|
||||
@@ -287,50 +289,76 @@ for(Column colStmt:stmtStructure){
|
||||
<%
|
||||
if(useUpdateStatement){
|
||||
%>
|
||||
String updateQuery_<%=cid %> = select_query_<%=cid %>;
|
||||
StringBuffer updateQuery_<%=cid %> = new StringBuffer(select_query_<%=cid %>);
|
||||
<%
|
||||
}else{
|
||||
%>
|
||||
String updateQuery_<%=cid %> = "UPDATE "+tableName_<%=cid%>+" SET <%=updateSetStmt.toString()%> ";
|
||||
StringBuffer updateQuery_<%=cid %> = new StringBuffer("UPDATE "+tableName_<%=cid%>+" SET <%=updateSetStmt.toString()%> ");
|
||||
<%
|
||||
}
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
if((CodeGenerationUtils.hasAlphaNumericCharacter(whereClause) && (!useWhereTable)) || (useWhereTable && whereConditions.size() > 0)) {
|
||||
if(useUpdateStatement){
|
||||
%>
|
||||
if(select_query_<%=cid %>.indexOf("WHERE")==-1){
|
||||
updateQuery_<%=cid %> +=" WHERE ";
|
||||
updateQuery_<%=cid %>.append(" WHERE ");
|
||||
}else{
|
||||
updateQuery_<%=cid %> +=" AND ";
|
||||
updateQuery_<%=cid %>.append(" AND ");
|
||||
}
|
||||
updateQuery_<%=cid %>+= <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>;
|
||||
<%
|
||||
}else{
|
||||
%>
|
||||
updateQuery_<%=cid %> += " WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>;
|
||||
updateQuery_<%=cid %>.append(" WHERE ");
|
||||
<%
|
||||
}
|
||||
if(!useWhereTable) {
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(<%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>);
|
||||
<%
|
||||
} else {
|
||||
String operator = "\"\"";
|
||||
for(Map<String, String> whereCondition : whereConditions) {
|
||||
String column_condition = whereCondition.get("COLUMN");
|
||||
String function_condition = whereCondition.get("FUNCTION");
|
||||
String value_condition = whereCondition.get("VALUE_SQL");
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(<%=operator %> + <%=column_condition %> + " " + <%=function_condition %> + " " + <%=value_condition %>);
|
||||
<%
|
||||
operator = "\" AND \"";
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>);
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>.toString());
|
||||
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
|
||||
String deleteQuery_<%=cid %> = "DELETE FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+select_query_<%=cid %>+") "
|
||||
<%
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
+" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
|
||||
<%
|
||||
StringBuffer deleteQuery_<%=cid %> = new StringBuffer("DELETE FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+select_query_<%=cid %>+") ");
|
||||
<%
|
||||
if(!useWhereTable) {
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
deleteQuery_<%=cid %>.append(" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>);
|
||||
<%
|
||||
}
|
||||
} else {
|
||||
if(whereConditions.size() > 0) {
|
||||
for(Map<String, String> whereCondition : whereConditions) {
|
||||
String column_condition = whereCondition.get("COLUMN");
|
||||
String function_condition = whereCondition.get("FUNCTION");
|
||||
String value_condition = whereCondition.get("VALUE_SQL");
|
||||
%>
|
||||
deleteQuery_<%=cid %>.append(" AND " + <%=column_condition %> + " " + <%=function_condition %> + " " + <%=value_condition %>);
|
||||
<%
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>.toString());
|
||||
<%
|
||||
}
|
||||
%>
|
||||
;
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>);
|
||||
|
||||
<%
|
||||
}
|
||||
%>
|
||||
%>
|
||||
int nb_line_<%=cid%> = 0;
|
||||
int nb_line_updated_<%=cid%> = 0;
|
||||
int nb_line_inserted_<%=cid%> = 0;
|
||||
@@ -353,7 +381,7 @@ System.out.println("--> " + nb_line_inserted_<%=cid%> + " rows inserted. \n");
|
||||
}else if(("UPDATE").equals(dataAction)){
|
||||
|
||||
%>
|
||||
System.out.println("Updating with : \n" + updateQuery_<%=cid %> +"\n");
|
||||
System.out.println("Updating with : \n" + updateQuery_<%=cid %>.toString() +"\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+updateQuery_"+ cid +"+\"");%>
|
||||
nb_line_updated_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
@@ -361,7 +389,7 @@ nb_line_updated_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Deleting with : \n" + deleteQuery_<%=cid %> +"\n");
|
||||
System.out.println("Deleting with : \n" + deleteQuery_<%=cid %>.toString() +"\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+deleteQuery_"+ cid +"+\"");%>
|
||||
nb_line_deleted_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
|
||||
@@ -23,6 +23,22 @@ USER.NAME=Username
|
||||
COMMIT_EVERY.NAME=Commit every
|
||||
WHERE_CLAUSE.NAME=Where clauses \n(for UPDATE and DELETE only)
|
||||
|
||||
USE_WHERE_CONDITIONS_TABLE.NAME=Use WHERE conditions table
|
||||
|
||||
WHERE_CONDITIONS_TABLE.NAME=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.COLUMN=Column
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION=Function
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.EQUAL==
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.GREATER=>
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LESS=<
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.GREATER_OR_EQUAL=>=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LESS_OR_EQUAL=<=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.NOT_EQUAL=<>
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.BETWEEN=BETWEEN
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LIKE=LIKE
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.IN=IN
|
||||
WHERE_CONDITIONS_TABLE.ITEM.VALUE_SQL=Value
|
||||
|
||||
ELT_TABLE_NAME.NAME=Default Table Name
|
||||
ELT_SCHEMA_NAME.NAME=Default Schema Name
|
||||
NB_LINE_UPDATED.NAME=Number Of Updated Lines
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<PARAMETER
|
||||
NAME="DATA_ACTION"
|
||||
FIELD="CLOSED_LIST"
|
||||
NUM_ROW="6"
|
||||
NUM_ROW="2"
|
||||
>
|
||||
<ITEMS DEFAULT="INSERT">
|
||||
<ITEM NAME="INSERT" VALUE="INSERT" />
|
||||
@@ -52,16 +52,47 @@
|
||||
<PARAMETER
|
||||
NAME="SCHEMA"
|
||||
FIELD="SCHEMA_TYPE"
|
||||
NUM_ROW="7"
|
||||
NUM_ROW="3"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CLAUSE" FIELD="MEMO" NUM_ROW="8"
|
||||
SHOW_IF="(DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')">
|
||||
<PARAMETER NAME="USE_WHERE_CONDITIONS_TABLE" FIELD="CHECK" NUM_ROW="4"
|
||||
SHOW_IF="(DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CLAUSE" FIELD="MEMO" NUM_ROW="5"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'false')">
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="NOTE" FIELD="LABEL" NUM_ROW="6"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'true')">
|
||||
<DEFAULT>WHERE conditions table
(for UPDATE and DELETE only)</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CONDITIONS_TABLE" FIELD="TABLE" NUM_ROW="7"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'true')">
|
||||
<ITEMS>
|
||||
<ITEM NAME="COLUMN" VALUE='""'/>
|
||||
<ITEM NAME="FUNCTION" FIELD="CLOSED_LIST">
|
||||
<ITEMS DEFAULT="EQUAL">
|
||||
<ITEM NAME="EQUAL" VALUE=""=""/>
|
||||
<ITEM NAME="GREATER" VALUE="">""/>
|
||||
<ITEM NAME="LESS" VALUE=""<""/>
|
||||
<ITEM NAME="GREATER_OR_EQUAL" VALUE="">=""/>
|
||||
<ITEM NAME="LESS_OR_EQUAL" VALUE=""<=""/>
|
||||
<ITEM NAME="NOT_EQUAL" VALUE=""<>""/>
|
||||
<ITEM NAME="BETWEEN" VALUE=""BETWEEN""/>
|
||||
<ITEM NAME="LIKE" VALUE=""LIKE""/>
|
||||
<ITEM NAME="IN" VALUE=""IN""/>
|
||||
</ITEMS>
|
||||
</ITEM>
|
||||
<ITEM NAME="VALUE_SQL" VALUE='""'/>
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="ELT_TABLE_NAME"
|
||||
FIELD="TEXT"
|
||||
|
||||
@@ -1,138 +1,140 @@
|
||||
<%@ jet
|
||||
imports="
|
||||
org.talend.designer.codegen.config.CodeGeneratorArgument
|
||||
org.talend.core.model.process.INode
|
||||
org.talend.core.model.process.ElementParameterParser
|
||||
org.talend.core.model.metadata.IMetadataTable
|
||||
org.talend.core.model.metadata.IMetadataColumn
|
||||
org.talend.core.model.process.IConnection
|
||||
org.talend.commons.utils.generation.CodeGenerationUtils
|
||||
java.util.List
|
||||
java.util.ArrayList
|
||||
java.util.LinkedList
|
||||
java.util.Map
|
||||
"
|
||||
%>
|
||||
<%@ include file="../templates/Log4j/Log4jDBConnUtil.javajet"%>
|
||||
|
||||
<%
|
||||
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
|
||||
INode node = (INode)codeGenArgument.getArgument();
|
||||
|
||||
boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
|
||||
String cid = node.getUniqueName();
|
||||
|
||||
String dbtable = null;
|
||||
String dbschema = ElementParameterParser.getValue(node,"__ELT_SCHEMA_NAME__");
|
||||
String uniqueNameConnection = null;
|
||||
INode previousNode = null;
|
||||
|
||||
String differenttable = ElementParameterParser.getValue(node, "__DIFFERENT_TABLE_NAME__");
|
||||
boolean useDifferentTable = "true".equals(ElementParameterParser.getValue(node, "__USE_DIFFERENT_TABLE__"));
|
||||
String dbVersion = ElementParameterParser.getValue(node, "__DB_VERSION__");
|
||||
boolean isTableNameVariable="true".equals(ElementParameterParser.getValue(node, "__IS_TABLE_NAME_VARIABLE__"));
|
||||
%>
|
||||
String select_query_<%=cid %> = null;
|
||||
String tableName_<%=cid%> = null;
|
||||
String selectQueryColumnsName_<%=cid %> = null;
|
||||
<%
|
||||
List<IConnection> connections = (List<IConnection>) node.getIncomingConnections();
|
||||
if(connections != null && connections.size() > 0 && connections.get(0) != null) {
|
||||
IConnection connection = connections.get(0);
|
||||
previousNode = connection.getSource();
|
||||
String previousComponentName = previousNode.getUniqueName();
|
||||
dbtable = connection.getName();
|
||||
uniqueNameConnection = connection.getUniqueName();
|
||||
%>
|
||||
select_query_<%=cid %> = (String) globalMap.get("<%=previousComponentName%>"+"QUERY"+"<%=uniqueNameConnection%>");
|
||||
selectQueryColumnsName_<%=cid %> = (String) globalMap.get("<%=previousComponentName%>"+"QUERY_COLUMNS_NAME"+"<%=uniqueNameConnection%>");
|
||||
<%
|
||||
}
|
||||
String tableName=null;
|
||||
if(useDifferentTable){
|
||||
tableName=differenttable;
|
||||
}else{
|
||||
if(isTableNameVariable){
|
||||
tableName=dbtable;
|
||||
}else{
|
||||
tableName="\""+dbtable +"\"";
|
||||
}
|
||||
}
|
||||
%>
|
||||
String dbschema_<%=cid%> = <%=dbschema%>;
|
||||
if(dbschema_<%=cid%> != null && dbschema_<%=cid%>.trim().length() > 0) {
|
||||
tableName_<%=cid%> = <%=dbschema%> + "." + <%=tableName%>;
|
||||
} else {
|
||||
tableName_<%=cid%> = <%=tableName%>;
|
||||
}
|
||||
<%
|
||||
String dataAction = ElementParameterParser.getValue(node,"__DATA_ACTION__");
|
||||
|
||||
String dbhost = null;
|
||||
String dbport = null;
|
||||
String dbname = null;
|
||||
String dbuser = null;
|
||||
boolean useExistingConn = false;
|
||||
String dbproperties = null;
|
||||
if(previousNode != null) {
|
||||
dbhost = ElementParameterParser.getValue(previousNode, "__HOST__");
|
||||
dbport = ElementParameterParser.getValue(previousNode, "__PORT__");
|
||||
dbname = ElementParameterParser.getValue(previousNode, "__DBNAME__");
|
||||
dbuser = ElementParameterParser.getValue(previousNode, "__USER__");
|
||||
useExistingConn = ("true").equals(ElementParameterParser.getValue(previousNode, "__USE_EXISTING_CONNECTION__"));
|
||||
dbproperties = ElementParameterParser.getValue(previousNode, "__PROPERTIES__");
|
||||
}
|
||||
|
||||
String whereClause = ElementParameterParser.getValue(node, "__WHERE_CLAUSE__");
|
||||
|
||||
%>
|
||||
|
||||
<%
|
||||
if(useExistingConn) {
|
||||
String connection = ElementParameterParser.getValue(previousNode, "__CONNECTION__");
|
||||
String conn = "conn_" + connection;
|
||||
%>
|
||||
java.sql.Connection conn_<%=cid%> = (java.sql.Connection)globalMap.get("<%=conn%>");
|
||||
<%
|
||||
log4jCodeGenerateUtil.useExistConnection(node);
|
||||
} else {
|
||||
if("SYBSEIQ_16_SA".equals(dbVersion)){
|
||||
%>
|
||||
String driverClass_<%=cid%> = "sap.jdbc4.sqlanywhere.IDriver";
|
||||
<%
|
||||
if(dbproperties == null || ("\"\"").equals(dbproperties) || ("").equals(dbproperties)) {
|
||||
%>
|
||||
String url_<%=cid%> = "jdbc:sqlanywhere:Host=" + <%=dbhost %> + ":" + <%=dbport %> + ";DatabaseName=" + <%=dbname %>;
|
||||
<%
|
||||
}
|
||||
else{
|
||||
%>
|
||||
String url_<%=cid%> = "jdbc:sqlanywhere:Host=" + <%=dbhost %> + ":" + <%=dbport %> + ";DatabaseName=" + <%=dbname %> + ";" + <%=dbproperties%>;
|
||||
<%
|
||||
}
|
||||
}
|
||||
else if("SYBSEIQ_16".equals(dbVersion)){%>
|
||||
String driverClass_<%=cid%> = "com.sybase.jdbc4.jdbc.SybDriver";
|
||||
<%}else{%>
|
||||
String driverClass_<%=cid%> = "com.sybase.jdbc3.jdbc.SybDriver";
|
||||
<%}%>
|
||||
java.lang.Class jdbcclazz_<%=cid%> = java.lang.Class.forName(driverClass_<%=cid%>);
|
||||
<%if("SYBSEIQ_16".equals(dbVersion)){%>
|
||||
jdbcclazz_<%=cid%>.newInstance();
|
||||
<%}%>
|
||||
|
||||
<%
|
||||
if(dbproperties == null || ("\"\"").equals(dbproperties) || ("").equals(dbproperties)) {
|
||||
%>
|
||||
String url_<%=cid %> = "jdbc:sybase:Tds:" + <%=dbhost %> + ":" + <%=dbport %> + "/" + <%=dbname %>;
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
String url_<%=cid %> = "jdbc:sybase:Tds:" + <%=dbhost %> + ":" + <%=dbport %> + "/" + <%=dbname %> + "?" + <%=dbproperties%>;
|
||||
<%
|
||||
}
|
||||
%>
|
||||
String dbUser_<%=cid %> = <%=dbuser%>;
|
||||
<%@ jet
|
||||
imports="
|
||||
org.talend.designer.codegen.config.CodeGeneratorArgument
|
||||
org.talend.core.model.process.INode
|
||||
org.talend.core.model.process.ElementParameterParser
|
||||
org.talend.core.model.metadata.IMetadataTable
|
||||
org.talend.core.model.metadata.IMetadataColumn
|
||||
org.talend.core.model.process.IConnection
|
||||
org.talend.commons.utils.generation.CodeGenerationUtils
|
||||
java.util.List
|
||||
java.util.ArrayList
|
||||
java.util.LinkedList
|
||||
java.util.Map
|
||||
"
|
||||
%>
|
||||
<%@ include file="../templates/Log4j/Log4jDBConnUtil.javajet"%>
|
||||
|
||||
<%
|
||||
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
|
||||
INode node = (INode)codeGenArgument.getArgument();
|
||||
|
||||
boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
|
||||
String cid = node.getUniqueName();
|
||||
|
||||
String dbtable = null;
|
||||
String dbschema = ElementParameterParser.getValue(node,"__ELT_SCHEMA_NAME__");
|
||||
String uniqueNameConnection = null;
|
||||
INode previousNode = null;
|
||||
|
||||
String differenttable = ElementParameterParser.getValue(node, "__DIFFERENT_TABLE_NAME__");
|
||||
boolean useDifferentTable = "true".equals(ElementParameterParser.getValue(node, "__USE_DIFFERENT_TABLE__"));
|
||||
String dbVersion = ElementParameterParser.getValue(node, "__DB_VERSION__");
|
||||
boolean isTableNameVariable="true".equals(ElementParameterParser.getValue(node, "__IS_TABLE_NAME_VARIABLE__"));
|
||||
%>
|
||||
String select_query_<%=cid %> = null;
|
||||
String tableName_<%=cid%> = null;
|
||||
String selectQueryColumnsName_<%=cid %> = null;
|
||||
<%
|
||||
List<IConnection> connections = (List<IConnection>) node.getIncomingConnections();
|
||||
if(connections != null && connections.size() > 0 && connections.get(0) != null) {
|
||||
IConnection connection = connections.get(0);
|
||||
previousNode = connection.getSource();
|
||||
String previousComponentName = previousNode.getUniqueName();
|
||||
dbtable = connection.getName();
|
||||
uniqueNameConnection = connection.getUniqueName();
|
||||
%>
|
||||
select_query_<%=cid %> = (String) globalMap.get("<%=previousComponentName%>"+"QUERY"+"<%=uniqueNameConnection%>");
|
||||
selectQueryColumnsName_<%=cid %> = (String) globalMap.get("<%=previousComponentName%>"+"QUERY_COLUMNS_NAME"+"<%=uniqueNameConnection%>");
|
||||
<%
|
||||
}
|
||||
String tableName=null;
|
||||
if(useDifferentTable){
|
||||
tableName=differenttable;
|
||||
}else{
|
||||
if(isTableNameVariable){
|
||||
tableName=dbtable;
|
||||
}else{
|
||||
tableName="\""+dbtable +"\"";
|
||||
}
|
||||
}
|
||||
%>
|
||||
String dbschema_<%=cid%> = <%=dbschema%>;
|
||||
if(dbschema_<%=cid%> != null && dbschema_<%=cid%>.trim().length() > 0) {
|
||||
tableName_<%=cid%> = <%=dbschema%> + "." + <%=tableName%>;
|
||||
} else {
|
||||
tableName_<%=cid%> = <%=tableName%>;
|
||||
}
|
||||
<%
|
||||
String dataAction = ElementParameterParser.getValue(node,"__DATA_ACTION__");
|
||||
|
||||
String dbhost = null;
|
||||
String dbport = null;
|
||||
String dbname = null;
|
||||
String dbuser = null;
|
||||
boolean useExistingConn = false;
|
||||
String dbproperties = null;
|
||||
if(previousNode != null) {
|
||||
dbhost = ElementParameterParser.getValue(previousNode, "__HOST__");
|
||||
dbport = ElementParameterParser.getValue(previousNode, "__PORT__");
|
||||
dbname = ElementParameterParser.getValue(previousNode, "__DBNAME__");
|
||||
dbuser = ElementParameterParser.getValue(previousNode, "__USER__");
|
||||
useExistingConn = ("true").equals(ElementParameterParser.getValue(previousNode, "__USE_EXISTING_CONNECTION__"));
|
||||
dbproperties = ElementParameterParser.getValue(previousNode, "__PROPERTIES__");
|
||||
}
|
||||
|
||||
boolean useWhereTable = ("true").equals(ElementParameterParser.getValue(node, "__USE_WHERE_CONDITIONS_TABLE__"));
|
||||
String whereClause = ElementParameterParser.getValue(node, "__WHERE_CLAUSE__");
|
||||
List<Map<String, String>> whereConditions = (List<Map<String,String>>)ElementParameterParser.getObjectValue(node, "__WHERE_CONDITIONS_TABLE__");
|
||||
|
||||
%>
|
||||
|
||||
<%
|
||||
if(useExistingConn) {
|
||||
String connection = ElementParameterParser.getValue(previousNode, "__CONNECTION__");
|
||||
String conn = "conn_" + connection;
|
||||
%>
|
||||
java.sql.Connection conn_<%=cid%> = (java.sql.Connection)globalMap.get("<%=conn%>");
|
||||
<%
|
||||
log4jCodeGenerateUtil.useExistConnection(node);
|
||||
} else {
|
||||
if("SYBSEIQ_16_SA".equals(dbVersion)){
|
||||
%>
|
||||
String driverClass_<%=cid%> = "sap.jdbc4.sqlanywhere.IDriver";
|
||||
<%
|
||||
if(dbproperties == null || ("\"\"").equals(dbproperties) || ("").equals(dbproperties)) {
|
||||
%>
|
||||
String url_<%=cid%> = "jdbc:sqlanywhere:Host=" + <%=dbhost %> + ":" + <%=dbport %> + ";DatabaseName=" + <%=dbname %>;
|
||||
<%
|
||||
}
|
||||
else{
|
||||
%>
|
||||
String url_<%=cid%> = "jdbc:sqlanywhere:Host=" + <%=dbhost %> + ":" + <%=dbport %> + ";DatabaseName=" + <%=dbname %> + ";" + <%=dbproperties%>;
|
||||
<%
|
||||
}
|
||||
}
|
||||
else if("SYBSEIQ_16".equals(dbVersion)){%>
|
||||
String driverClass_<%=cid%> = "com.sybase.jdbc4.jdbc.SybDriver";
|
||||
<%}else{%>
|
||||
String driverClass_<%=cid%> = "com.sybase.jdbc3.jdbc.SybDriver";
|
||||
<%}%>
|
||||
java.lang.Class jdbcclazz_<%=cid%> = java.lang.Class.forName(driverClass_<%=cid%>);
|
||||
<%if("SYBSEIQ_16".equals(dbVersion)){%>
|
||||
jdbcclazz_<%=cid%>.newInstance();
|
||||
<%}%>
|
||||
|
||||
<%
|
||||
if(dbproperties == null || ("\"\"").equals(dbproperties) || ("").equals(dbproperties)) {
|
||||
%>
|
||||
String url_<%=cid %> = "jdbc:sybase:Tds:" + <%=dbhost %> + ":" + <%=dbport %> + "/" + <%=dbname %>;
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
String url_<%=cid %> = "jdbc:sybase:Tds:" + <%=dbhost %> + ":" + <%=dbport %> + "/" + <%=dbname %> + "?" + <%=dbproperties%>;
|
||||
<%
|
||||
}
|
||||
%>
|
||||
String dbUser_<%=cid %> = <%=dbuser%>;
|
||||
|
||||
<%
|
||||
String passwordFieldName = "__PASS__";
|
||||
@@ -141,249 +143,278 @@ imports="
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/eltpassword.javajet"%>
|
||||
|
||||
String dbPwd_<%=cid %> = decryptedPassword_<%=cid%>;
|
||||
|
||||
java.sql.Connection conn_<%=cid%> = null;
|
||||
<%
|
||||
log4jCodeGenerateUtil.debugConnectionParams(node);
|
||||
log4jCodeGenerateUtil.connect(node);
|
||||
}
|
||||
%>
|
||||
|
||||
<%
|
||||
List<IMetadataColumn> columnList = null;
|
||||
List<IMetadataTable> metadatas = node.getMetadataList();
|
||||
if(metadatas !=null && metadatas.size()>0){
|
||||
IMetadataTable metadata = metadatas.get(0);
|
||||
if(metadata != null){
|
||||
columnList = metadata.getListColumns();
|
||||
}
|
||||
}
|
||||
%>
|
||||
|
||||
java.sql.PreparedStatement pstmt_<%=cid %> =null;
|
||||
|
||||
<%
|
||||
|
||||
if(columnList != null && columnList.size()>0){
|
||||
|
||||
class Column{
|
||||
|
||||
IMetadataColumn column;
|
||||
|
||||
String name;
|
||||
|
||||
String sqlStmt;
|
||||
|
||||
String value;
|
||||
|
||||
boolean addCol;
|
||||
|
||||
List<Column> replacement = new ArrayList<Column>();
|
||||
|
||||
public Column(IMetadataColumn column){
|
||||
this.column = column;
|
||||
String columname = column.getOriginalDbColumnName();
|
||||
if(columname!=null && columname.trim().length()>0){
|
||||
this.name = columname;
|
||||
}else{
|
||||
this.name = column.getLabel();
|
||||
}
|
||||
this.sqlStmt = "=?";
|
||||
this.value = "?";
|
||||
this.addCol =false;
|
||||
}
|
||||
|
||||
public boolean isReplaced(){
|
||||
return replacement.size()>0;
|
||||
}
|
||||
|
||||
public List<Column> getReplacement(){
|
||||
return this.replacement;
|
||||
}
|
||||
|
||||
public IMetadataColumn getColumn(){
|
||||
return this.column;
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public boolean isAddCol(){
|
||||
return this.addCol;
|
||||
}
|
||||
|
||||
public String getSqlStmt(){
|
||||
return this.sqlStmt;
|
||||
}
|
||||
|
||||
public String getValue(){
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder insertColName = new StringBuilder();
|
||||
StringBuilder insertValueStmt = new StringBuilder();
|
||||
StringBuilder updateSetStmt = new StringBuilder();
|
||||
StringBuilder updateWhereStmt = new StringBuilder();
|
||||
List<Column> stmtStructure = new LinkedList<Column>();
|
||||
|
||||
for(IMetadataColumn column:columnList){
|
||||
stmtStructure.add(new Column(column));
|
||||
}
|
||||
|
||||
int counterOuter =0;
|
||||
boolean firstKey = true;
|
||||
boolean firstNoneKey = true;
|
||||
|
||||
for(Column colStmt:stmtStructure){
|
||||
String suffix = ",";
|
||||
|
||||
if(colStmt.isReplaced()){
|
||||
List<Column> replacedColumns = colStmt.getReplacement();
|
||||
int counterReplace = 0;
|
||||
if(counterOuter==(stmtStructure.size()-1) && counterReplace==(replacedColumns.size()-1) ){
|
||||
suffix = "";
|
||||
}
|
||||
for(Column replacement:replacedColumns){
|
||||
insertColName.append(replacement.getName()+suffix);
|
||||
insertValueStmt.append(replacement.getSqlStmt()+suffix);
|
||||
if(!colStmt.getColumn().isKey()){
|
||||
if(!firstNoneKey){
|
||||
updateSetStmt.append(",");
|
||||
}else{
|
||||
firstNoneKey = false;
|
||||
}
|
||||
updateSetStmt.append(replacement.getName());
|
||||
updateSetStmt.append(replacement.getSqlStmt());
|
||||
}else{
|
||||
if(!firstKey){
|
||||
updateWhereStmt.append(" AND ");
|
||||
}else{
|
||||
firstKey = false;
|
||||
}
|
||||
updateWhereStmt.append(replacement.getName());
|
||||
updateWhereStmt.append(replacement.getSqlStmt());
|
||||
}
|
||||
counterReplace++;
|
||||
}
|
||||
}else{
|
||||
if(counterOuter==(stmtStructure.size()-1)){
|
||||
suffix = "";
|
||||
}
|
||||
if(colStmt.isAddCol()){
|
||||
insertColName.append(colStmt.getName()+suffix);
|
||||
insertValueStmt.append(colStmt.getSqlStmt()+suffix);
|
||||
updateSetStmt.append(colStmt.getName());
|
||||
updateSetStmt.append(colStmt.getSqlStmt()+suffix);
|
||||
}else{
|
||||
insertColName.append(colStmt.getName()+suffix);
|
||||
insertValueStmt.append(colStmt.getValue()+suffix);
|
||||
updateSetStmt.append(colStmt.getName()+"=(\"+select_query_"+ cid +".replaceFirst(java.util.regex.Pattern.quote(selectQueryColumnsName_"+ cid +"),routines.system.StringUtils.splitSQLColumns(selectQueryColumnsName_"+ cid +")[ "+ counterOuter + "])+\")" +suffix);
|
||||
}
|
||||
}
|
||||
counterOuter ++;
|
||||
}
|
||||
|
||||
if(("INSERT").equals(dataAction)){
|
||||
%>
|
||||
String insertQuery_<%=cid %> = "INSERT INTO "+tableName_<%=cid%>+" (<%=insertColName.toString()%>) ("+select_query_<%=cid %>+")";
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(insertQuery_<%=cid %>);
|
||||
<%
|
||||
} else if (("UPDATE").equals(dataAction)) {
|
||||
%>
|
||||
String updateQuery_<%=cid %> = "UPDATE "+tableName_<%=cid%>+" SET <%=updateSetStmt.toString()%> "
|
||||
<%
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
+" WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
;
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>);
|
||||
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
String deleteQuery_<%=cid %> = "DELETE FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+ select_query_<%=cid %>.replaceAll(selectQueryColumnsName_<%=cid %>, "*")+") "
|
||||
<%
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
+" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
;
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
int nb_line_<%=cid%> = 0;
|
||||
int nb_line_updated_<%=cid%> = 0;
|
||||
int nb_line_inserted_<%=cid%> = 0;
|
||||
int nb_line_deleted_<%=cid%> = 0;
|
||||
<%
|
||||
|
||||
}
|
||||
|
||||
if(dbtable != null && columnList != null){
|
||||
if(("INSERT").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Inserting with : \n" + insertQuery_<%=cid %> + "\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+insertQuery_"+ cid +"+\"");%>
|
||||
nb_line_<%=cid%> += nb_line_inserted_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
System.out.println("--> " + nb_line_inserted_<%=cid%> + " rows inserted. \n");
|
||||
<%
|
||||
}else if(("UPDATE").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Updating with : \n" + updateQuery_<%=cid %> +"\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+updateQuery_"+ cid +"+\"");%>
|
||||
nb_line_<%=cid%> += nb_line_updated_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
System.out.println("--> " + nb_line_updated_<%=cid%> + " rows updated. \n");
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Deleting with : \n" + deleteQuery_<%=cid %> +"\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+deleteQuery_"+ cid +"+\"");%>
|
||||
nb_line_<%=cid%> += nb_line_deleted_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
System.out.println("--> " + nb_line_deleted_<%=cid%> + " rows deleted. \n");
|
||||
<%
|
||||
}
|
||||
}
|
||||
|
||||
// END
|
||||
|
||||
|
||||
%>
|
||||
pstmt_<%=cid %>.close();
|
||||
|
||||
<%
|
||||
if(!useExistingConn) {
|
||||
%>
|
||||
if(conn_<%=cid%> != null && !conn_<%=cid%>.isClosed()) {
|
||||
<%log4jCodeGenerateUtil.close(node);%>
|
||||
}
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
globalMap.put("<%=cid %>_NB_LINE",nb_line_<%=cid%>);
|
||||
globalMap.put("<%=cid %>_NB_LINE_UPDATED",nb_line_updated_<%=cid%>);
|
||||
globalMap.put("<%=cid %>_NB_LINE_INSERTED",nb_line_inserted_<%=cid%>);
|
||||
globalMap.put("<%=cid %>_NB_LINE_DELETED",nb_line_deleted_<%=cid%>);
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
Map<String,String> actionMap=new java.util.HashMap<String,String>();
|
||||
actionMap.put("INSERT","inserted");
|
||||
actionMap.put("UPDATE","updated");
|
||||
actionMap.put("DELETE","deleted");
|
||||
%>
|
||||
log.info("<%=cid%> - Has <%=actionMap.get(dataAction)%> records count: " + nb_line_<%=actionMap.get(dataAction)%>_<%=cid%> + ".");
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
java.sql.Connection conn_<%=cid%> = null;
|
||||
<%
|
||||
log4jCodeGenerateUtil.debugConnectionParams(node);
|
||||
log4jCodeGenerateUtil.connect(node);
|
||||
}
|
||||
%>
|
||||
|
||||
<%
|
||||
List<IMetadataColumn> columnList = null;
|
||||
List<IMetadataTable> metadatas = node.getMetadataList();
|
||||
if(metadatas !=null && metadatas.size()>0){
|
||||
IMetadataTable metadata = metadatas.get(0);
|
||||
if(metadata != null){
|
||||
columnList = metadata.getListColumns();
|
||||
}
|
||||
}
|
||||
%>
|
||||
|
||||
java.sql.PreparedStatement pstmt_<%=cid %> =null;
|
||||
|
||||
<%
|
||||
|
||||
if(columnList != null && columnList.size()>0){
|
||||
|
||||
class Column{
|
||||
|
||||
IMetadataColumn column;
|
||||
|
||||
String name;
|
||||
|
||||
String sqlStmt;
|
||||
|
||||
String value;
|
||||
|
||||
boolean addCol;
|
||||
|
||||
List<Column> replacement = new ArrayList<Column>();
|
||||
|
||||
public Column(IMetadataColumn column){
|
||||
this.column = column;
|
||||
String columname = column.getOriginalDbColumnName();
|
||||
if(columname!=null && columname.trim().length()>0){
|
||||
this.name = columname;
|
||||
}else{
|
||||
this.name = column.getLabel();
|
||||
}
|
||||
this.sqlStmt = "=?";
|
||||
this.value = "?";
|
||||
this.addCol =false;
|
||||
}
|
||||
|
||||
public boolean isReplaced(){
|
||||
return replacement.size()>0;
|
||||
}
|
||||
|
||||
public List<Column> getReplacement(){
|
||||
return this.replacement;
|
||||
}
|
||||
|
||||
public IMetadataColumn getColumn(){
|
||||
return this.column;
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public boolean isAddCol(){
|
||||
return this.addCol;
|
||||
}
|
||||
|
||||
public String getSqlStmt(){
|
||||
return this.sqlStmt;
|
||||
}
|
||||
|
||||
public String getValue(){
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder insertColName = new StringBuilder();
|
||||
StringBuilder insertValueStmt = new StringBuilder();
|
||||
StringBuilder updateSetStmt = new StringBuilder();
|
||||
StringBuilder updateWhereStmt = new StringBuilder();
|
||||
List<Column> stmtStructure = new LinkedList<Column>();
|
||||
|
||||
for(IMetadataColumn column:columnList){
|
||||
stmtStructure.add(new Column(column));
|
||||
}
|
||||
|
||||
int counterOuter =0;
|
||||
boolean firstKey = true;
|
||||
boolean firstNoneKey = true;
|
||||
|
||||
for(Column colStmt:stmtStructure){
|
||||
String suffix = ",";
|
||||
|
||||
if(colStmt.isReplaced()){
|
||||
List<Column> replacedColumns = colStmt.getReplacement();
|
||||
int counterReplace = 0;
|
||||
if(counterOuter==(stmtStructure.size()-1) && counterReplace==(replacedColumns.size()-1) ){
|
||||
suffix = "";
|
||||
}
|
||||
for(Column replacement:replacedColumns){
|
||||
insertColName.append(replacement.getName()+suffix);
|
||||
insertValueStmt.append(replacement.getSqlStmt()+suffix);
|
||||
if(!colStmt.getColumn().isKey()){
|
||||
if(!firstNoneKey){
|
||||
updateSetStmt.append(",");
|
||||
}else{
|
||||
firstNoneKey = false;
|
||||
}
|
||||
updateSetStmt.append(replacement.getName());
|
||||
updateSetStmt.append(replacement.getSqlStmt());
|
||||
}else{
|
||||
if(!firstKey){
|
||||
updateWhereStmt.append(" AND ");
|
||||
}else{
|
||||
firstKey = false;
|
||||
}
|
||||
updateWhereStmt.append(replacement.getName());
|
||||
updateWhereStmt.append(replacement.getSqlStmt());
|
||||
}
|
||||
counterReplace++;
|
||||
}
|
||||
}else{
|
||||
if(counterOuter==(stmtStructure.size()-1)){
|
||||
suffix = "";
|
||||
}
|
||||
if(colStmt.isAddCol()){
|
||||
insertColName.append(colStmt.getName()+suffix);
|
||||
insertValueStmt.append(colStmt.getSqlStmt()+suffix);
|
||||
updateSetStmt.append(colStmt.getName());
|
||||
updateSetStmt.append(colStmt.getSqlStmt()+suffix);
|
||||
}else{
|
||||
insertColName.append(colStmt.getName()+suffix);
|
||||
insertValueStmt.append(colStmt.getValue()+suffix);
|
||||
updateSetStmt.append(colStmt.getName()+"=(\"+select_query_"+ cid +".replaceFirst(java.util.regex.Pattern.quote(selectQueryColumnsName_"+ cid +"),routines.system.StringUtils.splitSQLColumns(selectQueryColumnsName_"+ cid +")[ "+ counterOuter + "])+\")" +suffix);
|
||||
}
|
||||
}
|
||||
counterOuter ++;
|
||||
}
|
||||
|
||||
if(("INSERT").equals(dataAction)){
|
||||
%>
|
||||
String insertQuery_<%=cid %> = "INSERT INTO "+tableName_<%=cid%>+" (<%=insertColName.toString()%>) ("+select_query_<%=cid %>+")";
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(insertQuery_<%=cid %>);
|
||||
<%
|
||||
} else if (("UPDATE").equals(dataAction)) {
|
||||
%>
|
||||
StringBuffer updateQuery_<%=cid %> = new StringBuffer("UPDATE "+tableName_<%=cid%>+" SET <%=updateSetStmt.toString()%> ");
|
||||
<%
|
||||
if(!useWhereTable) {
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(" WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>);
|
||||
<%
|
||||
}
|
||||
} else {
|
||||
if(whereConditions.size() > 0) {
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(" WHERE ");
|
||||
<%
|
||||
String operator = "\"\"";
|
||||
for(Map<String, String> whereCondition : whereConditions) {
|
||||
String column_condition = whereCondition.get("COLUMN");
|
||||
String function_condition = whereCondition.get("FUNCTION");
|
||||
String value_condition = whereCondition.get("VALUE_SQL");
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(<%=operator %> + <%=column_condition %> + " " + <%=function_condition %> + " " + <%=value_condition %>);
|
||||
<%
|
||||
operator = "\" AND \"";
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>.toString());
|
||||
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
StringBuffer deleteQuery_<%=cid %> = new StringBuffer("DELETE FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+ select_query_<%=cid %>.replaceAll(selectQueryColumnsName_<%=cid %>, "*")+") ");
|
||||
<%
|
||||
if(!useWhereTable) {
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
deleteQuery_<%=cid %>.append(" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>);
|
||||
<%
|
||||
}
|
||||
} else {
|
||||
if(whereConditions.size() > 0) {
|
||||
for(Map<String, String> whereCondition : whereConditions) {
|
||||
String column_condition = whereCondition.get("COLUMN");
|
||||
String function_condition = whereCondition.get("FUNCTION");
|
||||
String value_condition = whereCondition.get("VALUE_SQL");
|
||||
%>
|
||||
deleteQuery_<%=cid %>.append(" AND " + <%=column_condition %> + " " + <%=function_condition %> + " " + <%=value_condition %>);
|
||||
<%
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>.toString());
|
||||
<%
|
||||
}
|
||||
%>
|
||||
int nb_line_<%=cid%> = 0;
|
||||
int nb_line_updated_<%=cid%> = 0;
|
||||
int nb_line_inserted_<%=cid%> = 0;
|
||||
int nb_line_deleted_<%=cid%> = 0;
|
||||
<%
|
||||
|
||||
}
|
||||
|
||||
if(dbtable != null && columnList != null){
|
||||
if(("INSERT").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Inserting with : \n" + insertQuery_<%=cid %> + "\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+insertQuery_"+ cid +"+\"");%>
|
||||
nb_line_<%=cid%> += nb_line_inserted_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
System.out.println("--> " + nb_line_inserted_<%=cid%> + " rows inserted. \n");
|
||||
<%
|
||||
}else if(("UPDATE").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Updating with : \n" + updateQuery_<%=cid %>.toString() +"\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+updateQuery_"+ cid +"+\"");%>
|
||||
nb_line_<%=cid%> += nb_line_updated_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
System.out.println("--> " + nb_line_updated_<%=cid%> + " rows updated. \n");
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Deleting with : \n" + deleteQuery_<%=cid %>.toString() +"\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+deleteQuery_"+ cid +"+\"");%>
|
||||
nb_line_<%=cid%> += nb_line_deleted_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
System.out.println("--> " + nb_line_deleted_<%=cid%> + " rows deleted. \n");
|
||||
<%
|
||||
}
|
||||
}
|
||||
|
||||
// END
|
||||
|
||||
|
||||
%>
|
||||
pstmt_<%=cid %>.close();
|
||||
|
||||
<%
|
||||
if(!useExistingConn) {
|
||||
%>
|
||||
if(conn_<%=cid%> != null && !conn_<%=cid%>.isClosed()) {
|
||||
<%log4jCodeGenerateUtil.close(node);%>
|
||||
}
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
globalMap.put("<%=cid %>_NB_LINE",nb_line_<%=cid%>);
|
||||
globalMap.put("<%=cid %>_NB_LINE_UPDATED",nb_line_updated_<%=cid%>);
|
||||
globalMap.put("<%=cid %>_NB_LINE_INSERTED",nb_line_inserted_<%=cid%>);
|
||||
globalMap.put("<%=cid %>_NB_LINE_DELETED",nb_line_deleted_<%=cid%>);
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
Map<String,String> actionMap=new java.util.HashMap<String,String>();
|
||||
actionMap.put("INSERT","inserted");
|
||||
actionMap.put("UPDATE","updated");
|
||||
actionMap.put("DELETE","deleted");
|
||||
%>
|
||||
log.info("<%=cid%> - Has <%=actionMap.get(dataAction)%> records count: " + nb_line_<%=actionMap.get(dataAction)%>_<%=cid%> + ".");
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
@@ -41,6 +41,22 @@ WHERE_CLAUSE.NAME=Where clauses \n(for UPDATE and DELETE only)
|
||||
ELT_TABLE_NAME.NAME=Default Table Name
|
||||
ELT_SCHEMA_NAME.NAME=Default Schema Name
|
||||
|
||||
USE_WHERE_CONDITIONS_TABLE.NAME=Use WHERE conditions table
|
||||
|
||||
WHERE_CONDITIONS_TABLE.NAME=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.COLUMN=Column
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION=Function
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.EQUAL==
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.GREATER=>
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LESS=<
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.GREATER_OR_EQUAL=>=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LESS_OR_EQUAL=<=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.NOT_EQUAL=<>
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.BETWEEN=BETWEEN
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LIKE=LIKE
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.IN=IN
|
||||
WHERE_CONDITIONS_TABLE.ITEM.VALUE_SQL=Value
|
||||
|
||||
NB_LINE_UPDATED.NAME=Number Of Updated Lines
|
||||
NB_LINE_INSERTED.NAME=Number Of Inserted Lines
|
||||
NB_LINE_DELETED.NAME=Number Of Deleted Lines
|
||||
|
||||
@@ -126,7 +126,12 @@
|
||||
</PARAMETER>
|
||||
</ADVANCED_PARAMETERS>
|
||||
|
||||
<CODEGENERATION></CODEGENERATION>
|
||||
<CODEGENERATION>
|
||||
<IMPORTS>
|
||||
<IMPORT NAME="Driver-Teradata" MODULE="terajdbc4-16.20.00.02.jar" MVN="mvn:com.teradata/terajdbc4/16.20.00.02" REQUIRED="true" />
|
||||
<IMPORT NAME="Driver-Teradata" MODULE="tdgssconfig-16.20.00.02.jar" MVN="mvn:com.teradata/tdgssconfig/16.20.00.02" REQUIRED="true" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
<RETURNS></RETURNS>
|
||||
|
||||
|
||||
@@ -55,15 +55,46 @@
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CLAUSE" FIELD="MEMO" NUM_ROW="8"
|
||||
SHOW_IF="(DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')">
|
||||
<PARAMETER NAME="USE_WHERE_CONDITIONS_TABLE" FIELD="CHECK" NUM_ROW="8"
|
||||
SHOW_IF="(DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CLAUSE" FIELD="MEMO" NUM_ROW="10"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'false')">
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
|
||||
<PARAMETER NAME="NOTE" FIELD="LABEL" NUM_ROW="11"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'true')">
|
||||
<DEFAULT>WHERE conditions table
(for UPDATE and DELETE only)</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CONDITIONS_TABLE" FIELD="TABLE" NUM_ROW="12"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'true')">
|
||||
<ITEMS>
|
||||
<ITEM NAME="COLUMN" VALUE='""'/>
|
||||
<ITEM NAME="FUNCTION" FIELD="CLOSED_LIST">
|
||||
<ITEMS DEFAULT="EQUAL">
|
||||
<ITEM NAME="EQUAL" VALUE=""=""/>
|
||||
<ITEM NAME="GREATER" VALUE="">""/>
|
||||
<ITEM NAME="LESS" VALUE=""<""/>
|
||||
<ITEM NAME="GREATER_OR_EQUAL" VALUE="">=""/>
|
||||
<ITEM NAME="LESS_OR_EQUAL" VALUE=""<=""/>
|
||||
<ITEM NAME="NOT_EQUAL" VALUE=""<>""/>
|
||||
<ITEM NAME="BETWEEN" VALUE=""BETWEEN""/>
|
||||
<ITEM NAME="LIKE" VALUE=""LIKE""/>
|
||||
<ITEM NAME="IN" VALUE=""IN""/>
|
||||
</ITEMS>
|
||||
</ITEM>
|
||||
<ITEM NAME="VALUE_SQL" VALUE='""'/>
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="ELT_TABLE_NAME"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="10"
|
||||
NUM_ROW="13"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
@@ -119,10 +150,6 @@
|
||||
</ADVANCED_PARAMETERS>
|
||||
|
||||
<CODEGENERATION>
|
||||
<IMPORTS>
|
||||
<IMPORT NAME="Driver-Teradata" MODULE="terajdbc4-16.20.00.02.jar" MVN="mvn:com.teradata/terajdbc4/16.20.00.02" REQUIRED="true" />
|
||||
<IMPORT NAME="Driver-Teradata" MODULE="tdgssconfig-16.20.00.02.jar" MVN="mvn:com.teradata/tdgssconfig/16.20.00.02" REQUIRED="true" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
<RETURNS>
|
||||
|
||||
@@ -10,7 +10,7 @@ imports="
|
||||
org.talend.commons.utils.generation.CodeGenerationUtils
|
||||
java.util.List
|
||||
java.util.LinkedList
|
||||
java.util.StringJoiner
|
||||
java.util.StringJoiner
|
||||
java.util.Map;
|
||||
"
|
||||
%>
|
||||
@@ -19,6 +19,16 @@ imports="
|
||||
<%
|
||||
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
|
||||
INode node = (INode)codeGenArgument.getArgument();
|
||||
|
||||
boolean useAlias = false;
|
||||
List<IConnection> inConnections = (List<IConnection>) node.getIncomingConnections();
|
||||
if(inConnections != null && inConnections.size() > 0 && inConnections.get(0) != null) {
|
||||
IConnection inConnection = inConnections.get(0);
|
||||
INode sourceNode = inConnection.getSource();
|
||||
if(sourceNode!=null){
|
||||
useAlias = "true".equals(ElementParameterParser.getValue(sourceNode, "__USE_ALIAS_IN_OUTPUT_TABLE__"));
|
||||
}
|
||||
}
|
||||
|
||||
boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
|
||||
String cid = node.getUniqueName();
|
||||
@@ -27,19 +37,23 @@ imports="
|
||||
public String transform(String content){
|
||||
String result = null;
|
||||
content = content.trim();
|
||||
String[] splitArr = content.split("\\s");
|
||||
int lgth = splitArr.length;
|
||||
if(lgth > 1){// has expr alias
|
||||
result = "src." + splitArr[lgth - 1];
|
||||
}else{
|
||||
int index = content.indexOf(".");
|
||||
if(index != -1){
|
||||
result = "src" + content.substring(index);
|
||||
}else{
|
||||
result = content;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
<%if(!useAlias){%>
|
||||
String[] splitArr = content.split("\\s");
|
||||
int lgth = splitArr.length;
|
||||
if(lgth > 1){// has expr alias
|
||||
result = "src." + splitArr[lgth - 1];
|
||||
}else{
|
||||
int index = content.indexOf(".");
|
||||
if(index != -1){
|
||||
result = "src" + content.substring(index);
|
||||
}else{
|
||||
result = content;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
<%}else{%>
|
||||
return "src." + content;
|
||||
<%}%>
|
||||
}
|
||||
}
|
||||
StrUtils_<%= cid %> strUtil_<%= cid %> = new StrUtils_<%= cid %>();
|
||||
@@ -97,8 +111,9 @@ imports="
|
||||
queryBandList = (List<Map<String,String>>)ElementParameterParser.getObjectValue(previousNode, "__QUERY_BAND_PARAMETERS__");
|
||||
}
|
||||
|
||||
boolean useWhereTable = ("true").equals(ElementParameterParser.getValue(previousNode, "__USE_WHERE_CONDITIONS_TABLE__"));
|
||||
String whereClause = ElementParameterParser.getValue(node, "__WHERE_CLAUSE__");
|
||||
|
||||
List<Map<String, String>> whereConditions = (List<Map<String,String>>)ElementParameterParser.getObjectValue(node, "__WHERE_CONDITIONS_TABLE__");
|
||||
%>
|
||||
|
||||
<%
|
||||
@@ -233,31 +248,31 @@ for(IMetadataColumn column:columnList){
|
||||
}
|
||||
|
||||
int counterOuter =0;
|
||||
List<Map<String, String>> setColumns = (List<Map<String,String>>)ElementParameterParser.getObjectValue(node, "__SET_COLUMN__");
|
||||
boolean isUpdate = "UPDATE".equals(dataAction);
|
||||
String suffix = ",";
|
||||
StringJoiner updateSetStmt = new StringJoiner(suffix);
|
||||
List<Map<String, String>> setColumns = (List<Map<String,String>>)ElementParameterParser.getObjectValue(node, "__SET_COLUMN__");
|
||||
boolean isUpdate = "UPDATE".equals(dataAction);
|
||||
String suffix = ",";
|
||||
StringJoiner updateSetStmt = new StringJoiner(suffix);
|
||||
for(Column colStmt:stmtStructure){
|
||||
if(counterOuter==(stmtStructure.size()-1)){
|
||||
suffix = "";
|
||||
}
|
||||
boolean isUpdateColumn = "true".equals(setColumns.get(counterOuter).get("UPDATE_COLUMN"));
|
||||
boolean isUpdateColumn = "true".equals(setColumns.get(counterOuter).get("UPDATE_COLUMN"));
|
||||
if(colStmt.isAddCol()){
|
||||
insertColName.append(colStmt.getName()+suffix);
|
||||
insertValueStmt.append(colStmt.getSqlStmt()+suffix);
|
||||
if (isUpdate && isUpdateColumn) {
|
||||
updateSetStmt.add(colStmt.getName() + colStmt.getSqlStmt());
|
||||
}
|
||||
if (isUpdate && isUpdateColumn) {
|
||||
updateSetStmt.add(colStmt.getName() + colStmt.getSqlStmt());
|
||||
}
|
||||
}else{
|
||||
insertColName.append(colStmt.getName()+suffix);
|
||||
insertValueStmt.append(colStmt.getValue()+suffix);
|
||||
if (isUpdate && isUpdateColumn) {
|
||||
updateSetStmt.add(
|
||||
if (isUpdate && isUpdateColumn) {
|
||||
updateSetStmt.add(
|
||||
colStmt.getName()
|
||||
+ "= \"+ strUtil_"
|
||||
+ cid
|
||||
+ ".transform(routines.system.StringUtils.splitSQLColumns(selectQueryColumnsName_"+ cid +")[" + counterOuter + "]) +\"");
|
||||
}
|
||||
+ ".transform(routines.system.StringUtils.splitSQLColumns(selectQueryColumnsName_"+ cid +")[" + counterOuter + "]) +\"");
|
||||
}
|
||||
}
|
||||
counterOuter ++;
|
||||
}
|
||||
@@ -276,38 +291,72 @@ try{
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"error",cid+" - Fail to create PreparedStatement with SQL: \"+insertQuery_"+ cid +"+\"");%>
|
||||
throw e;
|
||||
}
|
||||
<%
|
||||
<%
|
||||
}else if (("UPDATE").equals(dataAction)){
|
||||
%>
|
||||
%>
|
||||
StringBuffer updateQuery_<%=cid %> = new StringBuffer("UPDATE "+tableName_<%=cid%>+" FROM (" + select_query_<%=cid %> + ") src SET <%=updateSetStmt.toString()%>");
|
||||
<%
|
||||
if(!useWhereTable) {
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(" WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>);
|
||||
<%
|
||||
}
|
||||
} else {
|
||||
if(whereConditions.size() > 0) {
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(" WHERE ");
|
||||
<%
|
||||
String operator = "\"\"";
|
||||
for(Map<String, String> whereCondition : whereConditions) {
|
||||
String column_condition = whereCondition.get("COLUMN");
|
||||
String function_condition = whereCondition.get("FUNCTION");
|
||||
String value_condition = whereCondition.get("VALUE_SQL");
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(<%=operator %> + <%=column_condition %> + " " + <%=function_condition %> + " " + <%=value_condition %>);
|
||||
<%
|
||||
operator = "\" AND \"";
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
try{
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>.toString());
|
||||
} catch (Exception e){
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"error",cid+" - Fail to create PreparedStatement with SQL: \"+updateQuery_"+ cid +"+\"");%>
|
||||
throw e;
|
||||
}
|
||||
|
||||
String updateQuery_<%=cid %> = "UPDATE "+tableName_<%=cid%>+" FROM (" + select_query_<%=cid %> + ") src SET <%=updateSetStmt.toString()%>"
|
||||
<%if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {%>
|
||||
+" WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
|
||||
<%}%>
|
||||
;
|
||||
try{
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>);
|
||||
} catch (Exception e){
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"error",cid+" - Fail to create PreparedStatement with SQL: \"+updateQuery_"+ cid +"+\"");%>
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
||||
<%
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
|
||||
String deleteQuery_<%=cid %> = "DELETE FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+select_query_<%=cid %>+") "
|
||||
<%if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {%>
|
||||
+" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
|
||||
<%}%>
|
||||
;
|
||||
try {
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>);
|
||||
} catch (Exception e){
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"error",cid+" - Fail to create PreparedStatement with SQL: \"+deleteQuery_"+ cid +"+\"");%>
|
||||
throw e;
|
||||
}
|
||||
%>
|
||||
StringBuffer deleteQuery_<%=cid %> = new StringBuffer("DELETE FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+select_query_<%=cid %>+") ");
|
||||
<%
|
||||
if(!useWhereTable) {
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
deleteQuery_<%=cid %>.append(" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>);
|
||||
<%
|
||||
}
|
||||
} else {
|
||||
if(whereConditions.size() > 0) {
|
||||
for(Map<String, String> whereCondition : whereConditions) {
|
||||
String column_condition = whereCondition.get("COLUMN");
|
||||
String function_condition = whereCondition.get("FUNCTION");
|
||||
String value_condition = whereCondition.get("VALUE_SQL");
|
||||
%>
|
||||
deleteQuery_<%=cid %>.append(" AND " + <%=column_condition %> + " " + <%=function_condition %> + " " + <%=value_condition %>);
|
||||
<%
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
try {
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>.toString());
|
||||
} catch (Exception e){
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"error",cid+" - Fail to create PreparedStatement with SQL: \"+deleteQuery_"+ cid +"+\"");%>
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
||||
<%
|
||||
@@ -339,7 +388,7 @@ if(dbtable != null && columnList != null){
|
||||
}else if(("UPDATE").equals(dataAction)){
|
||||
|
||||
%>
|
||||
System.out.println("Updating with : \n" + updateQuery_<%=cid %> +"\n");
|
||||
System.out.println("Updating with : \n" + updateQuery_<%=cid %>.toString() +"\n");
|
||||
try{
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL: \"+updateQuery_"+ cid +"+\"");%>
|
||||
nb_line_updated_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
@@ -353,7 +402,7 @@ if(dbtable != null && columnList != null){
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Deleting with : \n" + deleteQuery_<%=cid %> +"\n");
|
||||
System.out.println("Deleting with : \n" + deleteQuery_<%=cid %>.toString() +"\n");
|
||||
try{
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL: \"+deleteQuery_"+ cid +"+\"");%>
|
||||
nb_line_deleted_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
|
||||
@@ -41,6 +41,22 @@ USER.NAME=Username
|
||||
WHERE_CLAUSE.NAME=Where clauses \n(for UPDATE and DELETE only)
|
||||
ELT_TABLE_NAME.NAME=Default Table Name
|
||||
|
||||
USE_WHERE_CONDITIONS_TABLE.NAME=Use WHERE conditions table
|
||||
|
||||
WHERE_CONDITIONS_TABLE.NAME=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.COLUMN=Column
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION=Function
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.EQUAL==
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.GREATER=>
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LESS=<
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.GREATER_OR_EQUAL=>=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LESS_OR_EQUAL=<=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.NOT_EQUAL=<>
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.BETWEEN=BETWEEN
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LIKE=LIKE
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.IN=IN
|
||||
WHERE_CONDITIONS_TABLE.ITEM.VALUE_SQL=Value
|
||||
|
||||
SET_COLUMN.ITEM.UPDATE_COLUMN=Update column
|
||||
SET_COLUMN.NAME=Clause SET
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<PARAMETER
|
||||
NAME="DATA_ACTION"
|
||||
FIELD="CLOSED_LIST"
|
||||
NUM_ROW="6"
|
||||
NUM_ROW="2"
|
||||
>
|
||||
<ITEMS DEFAULT="INSERT">
|
||||
<ITEM NAME="INSERT" VALUE="INSERT" />
|
||||
@@ -52,15 +52,46 @@
|
||||
<PARAMETER
|
||||
NAME="SCHEMA"
|
||||
FIELD="SCHEMA_TYPE"
|
||||
NUM_ROW="7"
|
||||
NUM_ROW="3"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CLAUSE" FIELD="MEMO" NUM_ROW="8"
|
||||
SHOW_IF="(DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')">
|
||||
<PARAMETER NAME="USE_WHERE_CONDITIONS_TABLE" FIELD="CHECK" NUM_ROW="4"
|
||||
SHOW_IF="(DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CLAUSE" FIELD="MEMO" NUM_ROW="5"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'false')">
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="NOTE" FIELD="LABEL" NUM_ROW="6"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'true')">
|
||||
<DEFAULT>WHERE conditions table
(for UPDATE and DELETE only)</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="WHERE_CONDITIONS_TABLE" FIELD="TABLE" NUM_ROW="8"
|
||||
SHOW_IF="((DATA_ACTION == 'UPDATE') OR (DATA_ACTION == 'DELETE')) AND (USE_WHERE_CONDITIONS_TABLE == 'true')">
|
||||
<ITEMS>
|
||||
<ITEM NAME="COLUMN" VALUE='""'/>
|
||||
<ITEM NAME="FUNCTION" FIELD="CLOSED_LIST">
|
||||
<ITEMS DEFAULT="EQUAL">
|
||||
<ITEM NAME="EQUAL" VALUE=""=""/>
|
||||
<ITEM NAME="GREATER" VALUE="">""/>
|
||||
<ITEM NAME="LESS" VALUE=""<""/>
|
||||
<ITEM NAME="GREATER_OR_EQUAL" VALUE="">=""/>
|
||||
<ITEM NAME="LESS_OR_EQUAL" VALUE=""<=""/>
|
||||
<ITEM NAME="NOT_EQUAL" VALUE=""<>""/>
|
||||
<ITEM NAME="BETWEEN" VALUE=""BETWEEN""/>
|
||||
<ITEM NAME="LIKE" VALUE=""LIKE""/>
|
||||
<ITEM NAME="IN" VALUE=""IN""/>
|
||||
</ITEMS>
|
||||
</ITEM>
|
||||
<ITEM NAME="VALUE_SQL" VALUE='""'/>
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="ELT_TABLE_NAME"
|
||||
|
||||
@@ -81,7 +81,9 @@ imports="
|
||||
dbproperties = ElementParameterParser.getValue(previousNode, "__PROPERTIES__");
|
||||
}
|
||||
|
||||
String whereClause = ElementParameterParser.getValue(node, "__WHERE_CLAUSE__");
|
||||
boolean useWhereTable = ("true").equals(ElementParameterParser.getValue(node, "__USE_WHERE_CONDITIONS_TABLE__"));
|
||||
String whereClause = ElementParameterParser.getValue(node, "__WHERE_CLAUSE__");
|
||||
List<Map<String, String>> whereConditions = (List<Map<String,String>>)ElementParameterParser.getObjectValue(node, "__WHERE_CONDITIONS_TABLE__");
|
||||
|
||||
if(useExistingConn) {
|
||||
String connection = ElementParameterParser.getValue(previousNode, "__CONNECTION__");
|
||||
@@ -293,30 +295,59 @@ imports="
|
||||
<%
|
||||
} else if (("UPDATE").equals(dataAction)) {
|
||||
%>
|
||||
String updateQuery_<%=cid %> = "UPDATE " + info_<%=cid%> + " "+tableName_<%=cid%>+" SET <%=updateSetStmt.toString()%> "
|
||||
StringBuffer updateQuery_<%=cid %> = new StringBuffer("UPDATE " + info_<%=cid%> + " "+tableName_<%=cid%>+" SET <%=updateSetStmt.toString()%> ");
|
||||
<%
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
if(!useWhereTable) {
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
+" WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
|
||||
updateQuery_<%=cid %>.append(" WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>);
|
||||
<%
|
||||
}
|
||||
} else {
|
||||
if(whereConditions.size() > 0) {
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(" WHERE ");
|
||||
<%
|
||||
String operator = "\"\"";
|
||||
for(Map<String, String> whereCondition : whereConditions) {
|
||||
String column_condition = whereCondition.get("COLUMN");
|
||||
String function_condition = whereCondition.get("FUNCTION");
|
||||
String value_condition = whereCondition.get("VALUE_SQL");
|
||||
%>
|
||||
updateQuery_<%=cid %>.append(<%=operator %> + <%=column_condition %> + " " + <%=function_condition %> + " " + <%=value_condition %>);
|
||||
<%
|
||||
operator = "\" AND \"";
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
;
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>);
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>.toString());
|
||||
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
String deleteQuery_<%=cid %> = "DELETE " + info_<%=cid%> + " FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+ select_query_<%=cid %>.replaceAll(selectQueryColumnsName_<%=cid %>, "*")+") "
|
||||
StringBuffer deleteQuery_<%=cid %> = new StringBuffer("DELETE " + info_<%=cid%> + " FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+ select_query_<%=cid %>.replaceAll(selectQueryColumnsName_<%=cid %>, "*")+") ");
|
||||
<%
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
if(!useWhereTable) {
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
+" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
|
||||
deleteQuery_<%=cid %>.append(" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>);
|
||||
<%
|
||||
}
|
||||
} else {
|
||||
if(whereConditions.size() > 0) {
|
||||
for(Map<String, String> whereCondition : whereConditions) {
|
||||
String column_condition = whereCondition.get("COLUMN");
|
||||
String function_condition = whereCondition.get("FUNCTION");
|
||||
String value_condition = whereCondition.get("VALUE_SQL");
|
||||
%>
|
||||
deleteQuery_<%=cid %>.append(" AND " + <%=column_condition %> + " " + <%=function_condition %> + " " + <%=value_condition %>);
|
||||
<%
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
;
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>);
|
||||
%>
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>.toString());
|
||||
<%
|
||||
}
|
||||
%>
|
||||
@@ -338,7 +369,7 @@ imports="
|
||||
<%
|
||||
}else if(("UPDATE").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Updating with : \n" + updateQuery_<%=cid %> +"\n");
|
||||
System.out.println("Updating with : \n" + updateQuery_<%=cid %>.toString() +"\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+updateQuery_"+ cid +"+\"");%>
|
||||
nb_line_<%=cid%> += nb_line_updated_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
@@ -346,7 +377,7 @@ imports="
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
System.out.println("Deleting with : \n" + deleteQuery_<%=cid %> +"\n");
|
||||
System.out.println("Deleting with : \n" + deleteQuery_<%=cid %>.toString() +"\n");
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executing SQL:\"+deleteQuery_"+ cid +"+\"");%>
|
||||
nb_line_<%=cid%> += nb_line_deleted_<%=cid%> = pstmt_<%=cid %>.executeUpdate();
|
||||
<%log4jCodeGenerateUtil.logInfo(node,"info",cid+" - Executed successfully.");%>
|
||||
|
||||
@@ -41,6 +41,22 @@ WHERE_CLAUSE.NAME=Where clauses \n(for UPDATE and DELETE only)
|
||||
ELT_TABLE_NAME.NAME=Default Table Name
|
||||
ELT_SCHEMA_NAME.NAME=Default Schema Name
|
||||
|
||||
USE_WHERE_CONDITIONS_TABLE.NAME=Use WHERE conditions table
|
||||
|
||||
WHERE_CONDITIONS_TABLE.NAME=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.COLUMN=Column
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION=Function
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.EQUAL==
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.GREATER=>
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LESS=<
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.GREATER_OR_EQUAL=>=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LESS_OR_EQUAL=<=
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.NOT_EQUAL=<>
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.BETWEEN=BETWEEN
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.LIKE=LIKE
|
||||
WHERE_CONDITIONS_TABLE.ITEM.FUNCTION.ITEM.IN=IN
|
||||
WHERE_CONDITIONS_TABLE.ITEM.VALUE_SQL=Value
|
||||
|
||||
NB_LINE_UPDATED.NAME=Number Of Updated Lines
|
||||
NB_LINE_INSERTED.NAME=Number Of Inserted Lines
|
||||
NB_LINE_DELETED.NAME=Number Of Deleted Lines
|
||||
|
||||
@@ -149,7 +149,7 @@
|
||||
<CODEGENERATION>
|
||||
<IMPORTS>
|
||||
<IMPORT NAME="Talen File Enhanced"
|
||||
MODULE="talend_file_enhanced-1.0.jar" MVN="mvn:org.talend.components.lib/talend_file_enhanced/1.0" UrlPath="platform:/plugin/org.talend.libraries.custom/lib/talend_file_enhanced-1.0.jar" REQUIRED="true" />
|
||||
MODULE="talend_file_enhanced-1.1.jar" MVN="mvn:org.talend.components.lib/talend_file_enhanced/1.1" UrlPath="platform:/plugin/org.talend.libraries.custom/lib/talend_file_enhanced-1.1.jar" REQUIRED="true" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
|
||||
@@ -290,6 +290,7 @@ if (sftp) { // *** sftp *** //
|
||||
log.info("<%= cid %> - md5 message is : '"+ <%=outputConnName %>.md5 + "'.");
|
||||
<%}%>
|
||||
is_<%=cid %>.close();
|
||||
ftp_<%=cid%>.completePendingCommand();
|
||||
<%}%>
|
||||
}
|
||||
<%
|
||||
|
||||
@@ -250,16 +250,6 @@ int nb_file_<%=cid%> = 0;
|
||||
passwordFieldName = "__PASSWORD__";
|
||||
%>
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/FTP/ftp_connect.javajet"%>
|
||||
<%
|
||||
}
|
||||
|
||||
if("binary".equalsIgnoreCase(ElementParameterParser.getValue(node, "__MODE__"))){
|
||||
%>
|
||||
ftp_<%=cid %>.setFileType(org.apache.commons.net.ftp.FTP.BINARY_FILE_TYPE);
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
ftp_<%=cid %>.setFileType(org.apache.commons.net.ftp.FTP.ASCII_FILE_TYPE);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
@@ -288,6 +278,26 @@ int nb_file_<%=cid%> = 0;
|
||||
<%
|
||||
}
|
||||
} //common code for ftp and ftps:
|
||||
|
||||
|
||||
if("binary".equalsIgnoreCase(ElementParameterParser.getValue(node, "__MODE__"))){
|
||||
|
||||
%>
|
||||
|
||||
ftp_<%=cid %>.setFileType(org.apache.commons.net.ftp.FTP.BINARY_FILE_TYPE);
|
||||
|
||||
<%
|
||||
|
||||
} else {
|
||||
|
||||
%>
|
||||
|
||||
ftp_<%=cid %>.setFileType(org.apache.commons.net.ftp.FTP.ASCII_FILE_TYPE);
|
||||
|
||||
<%
|
||||
|
||||
}
|
||||
|
||||
%>
|
||||
String rootDir_<%=cid %> = ftp_<%=cid %>.printWorkingDirectory();
|
||||
String remotedir_<%=cid%> = (<%=remotedir%>).replaceAll("\\\\", "/");
|
||||
|
||||
@@ -189,7 +189,7 @@ COMPATIBILITY="ALL"
|
||||
<DEFAULT>"123456"</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="MODE" FIELD="CLOSED_LIST" NUM_ROW="7" SHOW_IF="((USE_EXISTING_CONNECTION == 'true') AND (#LINK@NODE.CONNECTION.SFTP == 'false') AND (#LINK@NODE.CONNECTION.FTPS == 'false')) OR ((USE_EXISTING_CONNECTION == 'false') AND (SFTP=='false') AND (FTPS == 'false'))">
|
||||
<PARAMETER NAME="MODE" FIELD="CLOSED_LIST" NUM_ROW="7" SHOW_IF="((USE_EXISTING_CONNECTION == 'true') AND (#LINK@NODE.CONNECTION.SFTP == 'false')) OR ((USE_EXISTING_CONNECTION == 'false') AND (SFTP=='false'))">
|
||||
<ITEMS DEFAULT="ascii">
|
||||
<ITEM NAME="ASCII" VALUE="ascii" />
|
||||
<ITEM NAME="BINARY" VALUE="binary" />
|
||||
|
||||
@@ -134,7 +134,7 @@
|
||||
<IMPORT NAME="commons-compress-1.19" MODULE="commons-compress-1.19.jar" MVN="mvn:org.apache.commons/commons-compress/1.19" REQUIRED="true" />
|
||||
<IMPORT NAME="Encrypt-Zip" MODULE="checkArchive-1.1-20190917.jar" MVN="mvn:org.talend.libraries/checkArchive-1.1-20190917/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.custom/lib/checkArchive-1.1-20190917.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="zip4j-1.3.3.jar" MODULE="zip4j-1.3.3.jar" MVN="mvn:net.lingala.zip4j/zip4j/1.3.3" REQUIRED="true" />
|
||||
<IMPORT NAME="talendzip-1.0-20190917.jar" MODULE="talendzip-1.0-20190917.jar" MVN="mvn:org.talend.libraries/talendzip/1.0-20190917" UrlPath="platform:/plugin/org.talend.libraries.custom/lib/talendzip-1.0-20190917.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="talendzip-1.1-20201120.jar" MODULE="talendzip-1.1-20201120.jar" MVN="mvn:org.talend.components/talendzip/1.1-20201120" UrlPath="platform:/plugin/org.talend.libraries.custom/lib/talendzip-1.1-20201120.jar" REQUIRED="true" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
|
||||
@@ -48,8 +48,6 @@ if ("http".equals(protocol) || "https".equals(protocol)) {
|
||||
boolean addHeader = "true".equals(ElementParameterParser.getValue(node, "__ADD_HEADER__"));
|
||||
boolean encodeURI = "true".equals(ElementParameterParser.getValue(node, "__ENCODE_URI__"));
|
||||
boolean trustAll = "true".equals(ElementParameterParser.getValue(node, "__TRUST_ALL_SERVER__"));
|
||||
|
||||
String scaccepted_uploadfile = ((uploadFile) ? " || status_"+cid+" == org.apache.commons.httpclient.HttpStatus.SC_ACCEPTED": "");
|
||||
%>
|
||||
java.net.URI uriToFetch_<%=cid %> = null;
|
||||
try {
|
||||
@@ -405,7 +403,7 @@ if ("http".equals(protocol) || "https".equals(protocol)) {
|
||||
|
||||
System.out.println("Redirect to: " + method_<%=cid%>.getURI());
|
||||
finalURL_<%=cid%> = method_<%=cid%>.getURI().toString();
|
||||
} else if (status_<%=cid%> == org.apache.commons.httpclient.HttpStatus.SC_OK<%= scaccepted_uploadfile%>) {
|
||||
} else if (status_<%=cid%> >= 200 && status_<%=cid%> < 300) { //Status code 2XX indicates success
|
||||
redirect_<%=cid%> = false;
|
||||
} else {
|
||||
throw new java.lang.Exception("Method failed: " + method_<%=cid%>.getStatusLine());
|
||||
@@ -418,7 +416,7 @@ if ("http".equals(protocol) || "https".equals(protocol)) {
|
||||
|
||||
if (!redirect) {
|
||||
%>
|
||||
if (!(status_<%=cid%> == org.apache.commons.httpclient.HttpStatus.SC_OK<%= scaccepted_uploadfile%>)) {
|
||||
if (!(status_<%=cid%> >= 200 && status_<%=cid%> < 300)){//Status code 2XX indicates success
|
||||
throw new java.lang.Exception("Method failed: " + method_<%=cid%>.getStatusLine());
|
||||
}
|
||||
<%
|
||||
|
||||
@@ -60,3 +60,5 @@ ADD_HEADER.NAME=Add header
|
||||
HEADERS.NAME=Headers
|
||||
HEADERS.ITEM.HEADER_NAME=Name
|
||||
HEADERS.ITEM.HEADER_VALUE=Value
|
||||
|
||||
INPUT_STREAM.NAME=Input stream
|
||||
@@ -37,6 +37,7 @@
|
||||
}
|
||||
int dynamic_index = -1;
|
||||
boolean hasDynamic = false;
|
||||
int dynamicColumnlength = 100;
|
||||
List<IMetadataColumn> columnList = null;
|
||||
List<IMetadataTable> metadatas = node.getMetadataList();
|
||||
IMetadataTable metadata = null;
|
||||
@@ -52,6 +53,9 @@
|
||||
if(columnList.get(i).getTalendType().equals("id_Dynamic")){
|
||||
dynamic_index = i+1;
|
||||
hasDynamic = true;
|
||||
if(columnList.get(i).getLength() != null){
|
||||
dynamicColumnlength = columnList.get(i).getLength();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -65,7 +69,7 @@
|
||||
class GenerateCode{
|
||||
public int dynamic_index = -1;
|
||||
public int colLen = 0; // the length of the column in the input schema
|
||||
public void generateDynamicSchemaCode(boolean isCsv){
|
||||
public void generateDynamicSchemaCode(boolean isCsv,int dynamicColumnlength){
|
||||
%>
|
||||
if(isFirstCheckDyn_<%=cid %>){// for the header line
|
||||
<%
|
||||
@@ -85,7 +89,7 @@
|
||||
dynamicMetadata_<%=cid%>.setDbName(dynamicMetadata_<%=cid%>.getName());
|
||||
dynamicMetadata_<%=cid%>.setType("id_String");
|
||||
dynamicMetadata_<%=cid%>.setDbType("VARCHAR");
|
||||
dynamicMetadata_<%=cid%>.setLength(100);
|
||||
dynamicMetadata_<%=cid%>.setLength(<%=dynamicColumnlength%>);
|
||||
dynamicMetadata_<%=cid%>.setPrecision(0);
|
||||
dynamicMetadata_<%=cid%>.setNullable(true);
|
||||
dynamicMetadata_<%=cid%>.setKey(false);
|
||||
@@ -227,18 +231,19 @@
|
||||
this.isBehindDynamic=true;
|
||||
dynamic_index = valueN;
|
||||
%>
|
||||
<%=dynamicName%>.clearColumnValues();
|
||||
|
||||
<%=targetConnName %>.<%=column.getLabel() %> = <%=dynamicName%>.copyMetadata();
|
||||
|
||||
int fieldCount = <%=sourceValueName%>.getColumnsCountOfCurrentRow();
|
||||
dynamic_column_count_<%=cid%> = <%=dynamicName%>.getColumnCount();
|
||||
for (int i = 0; i < dynamic_column_count_<%=cid%> ; i++) {
|
||||
if ((<%=dynamic_index%>+i) < fieldCount){
|
||||
<%=dynamicName%>.addColumnValue(<%=sourceValueName%>.get(<%=dynamic_index%>+i)<%=(isTrimAll || (!trimSelects.isEmpty() && ("true").equals(trimSelects.get(valueN).get("TRIM"))))?".trim()":"" %>);
|
||||
<%=targetConnName %>.<%=column.getLabel() %>.addColumnValue(<%=sourceValueName%>.get(<%=dynamic_index%>+i)<%=(isTrimAll || (!trimSelects.isEmpty() && ("true").equals(trimSelects.get(valueN).get("TRIM"))))?".trim()":"" %>);
|
||||
}
|
||||
else{
|
||||
<%=dynamicName%>.addColumnValue("");
|
||||
<%=targetConnName %>.<%=column.getLabel() %>.addColumnValue("");
|
||||
}
|
||||
}
|
||||
<%=targetConnName %>.<%=column.getLabel() %>=<%=dynamicName%>;
|
||||
<%
|
||||
}else{
|
||||
|
||||
@@ -564,7 +569,7 @@
|
||||
if(hasDynamic){// generate the dynamic schema code
|
||||
generateCode.colLen = sizeListColumns;
|
||||
generateCode.dynamic_index = dynamic_index;
|
||||
generateCode.generateDynamicSchemaCode(false); //false: delimited mode
|
||||
generateCode.generateDynamicSchemaCode(false,dynamicColumnlength); //false: delimited mode
|
||||
rowUtil.callValueToConnWithD("fid_"+cid, firstConnName, "dynamic_"+cid);
|
||||
}else{
|
||||
rowUtil.callValueToConn("fid_"+cid, firstConnName);
|
||||
@@ -704,8 +709,7 @@
|
||||
IMetadataColumn column1 =metadata.getListColumns().get(colNo);
|
||||
if("id_Dynamic".equals(column1.getTalendType())) {
|
||||
%>
|
||||
<%=dynamicName%>.clearColumnValues();
|
||||
<%=targetConnName %>.<%=column1.getLabel() %> = <%=dynamicName%>;
|
||||
<%=targetConnName %>.<%=column1.getLabel() %> = <%=dynamicName%>.copyMetadata();
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
@@ -873,17 +877,16 @@
|
||||
%>
|
||||
dynamic_column_count_<%=cid%> = <%=dynamicName%>.getColumnCount();
|
||||
if(dynamic_column_count_<%=cid%> > 0) {
|
||||
<%=dynamicName%>.clearColumnValues();
|
||||
<%=targetConnName %>.<%=column.getLabel() %> = <%=dynamicName%>.copyMetadata();
|
||||
}
|
||||
int fieldCount = <%=sourceValueName%>.length;
|
||||
for (int i = 0; i < dynamic_column_count_<%=cid%>; i++) {
|
||||
if ((<%=dynamic_index%>+i) < fieldCount) {
|
||||
<%=dynamicName%>.addColumnValue(<%=sourceValueName%>[<%=dynamic_index%>+i]);
|
||||
<%=targetConnName %>.<%=column.getLabel() %>.addColumnValue(<%=sourceValueName%>[<%=dynamic_index%>+i]);
|
||||
} else {
|
||||
<%=dynamicName%>.addColumnValue("");
|
||||
<%=targetConnName %>.<%=column.getLabel() %>.addColumnValue("");
|
||||
}
|
||||
}
|
||||
<%=targetConnName %>.<%=column.getLabel() %> = <%=dynamicName%>;
|
||||
<%
|
||||
}
|
||||
}
|
||||
@@ -1348,7 +1351,7 @@
|
||||
if(hasDynamic){// generate the dynamic schema code
|
||||
generateCode.colLen = columnSize;
|
||||
generateCode.dynamic_index = dynamic_index;
|
||||
generateCode.generateDynamicSchemaCode(true); //true: CSV mode
|
||||
generateCode.generateDynamicSchemaCode(true,dynamicColumnlength); //true: CSV mode
|
||||
rowUtil.callValueToConnWithD("row"+cid, firstConnName, "dynamic_"+cid);
|
||||
}else{
|
||||
rowUtil.callValueToConn("row"+cid, firstConnName);
|
||||
|
||||
@@ -213,7 +213,7 @@
|
||||
<CODEGENERATION>
|
||||
<IMPORTS>
|
||||
<IMPORT NAME="Talen File Enhanced"
|
||||
MODULE="talend_file_enhanced-1.0.jar" MVN="mvn:org.talend.components.lib/talend_file_enhanced/1.0" UrlPath="platform:/plugin/org.talend.libraries.custom/lib/talend_file_enhanced-1.0.jar" REQUIRED="true" />
|
||||
MODULE="talend_file_enhanced-1.1.jar" MVN="mvn:org.talend.components.lib/talend_file_enhanced/1.1" UrlPath="platform:/plugin/org.talend.libraries.custom/lib/talend_file_enhanced-1.1.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="Talend_CSV" MODULE="talendcsv.jar" MVN="mvn:org.talend.libraries/talendcsv/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.csv/lib/talendcsv.jar"
|
||||
REQUIRED="true" />
|
||||
</IMPORTS>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user