Compare commits
81 Commits
dsergent/f
...
patch/TPS-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad2181551e | ||
|
|
25b4724de6 | ||
|
|
f6d7c55c06 | ||
|
|
4fa889ddfd | ||
|
|
1b0b5b9c4b | ||
|
|
4fa291afa5 | ||
|
|
2410d7c81b | ||
|
|
a6dac58827 | ||
|
|
d1ce25465c | ||
|
|
1f31ea1c4f | ||
|
|
4a28c50b04 | ||
|
|
6beef70589 | ||
|
|
06be524b5c | ||
|
|
139acb8b90 | ||
|
|
e1a8dfc24b | ||
|
|
6782042783 | ||
|
|
c54af4b1e2 | ||
|
|
71e572da23 | ||
|
|
d46c202e6b | ||
|
|
f536ed47ae | ||
|
|
de82c16af4 | ||
|
|
c5eac4ef90 | ||
|
|
1fa26e95ed | ||
|
|
4d4040de42 | ||
|
|
2fa1c9c6c0 | ||
|
|
d69f83c3bd | ||
|
|
2ad55908cd | ||
|
|
f6209cee95 | ||
|
|
fe032a359c | ||
|
|
dec8461335 | ||
|
|
46eae3db6a | ||
|
|
0b2496cca6 | ||
|
|
24c2e1bbb3 | ||
|
|
dd18017695 | ||
|
|
af1d09968b | ||
|
|
4a0e546f9a | ||
|
|
9142b137de | ||
|
|
96d9b2c8a2 | ||
|
|
96a52cea5a | ||
|
|
af6792732a | ||
|
|
48571e54bc | ||
|
|
dc64a893c6 | ||
|
|
78d8d901b6 | ||
|
|
6947ccdf9d | ||
|
|
91bd64ec32 | ||
|
|
d96a383857 | ||
|
|
85581b5d25 | ||
|
|
32e02c0bbd | ||
|
|
f0251625b4 | ||
|
|
cb3b7a5b37 | ||
|
|
4388a3d154 | ||
|
|
271428b447 | ||
|
|
1efa27abdb | ||
|
|
e8e74bfc74 | ||
|
|
86a8bf705b | ||
|
|
cc4b7b663a | ||
|
|
04102e6eb6 | ||
|
|
d8dc2ad6b6 | ||
|
|
d008f5463b | ||
|
|
c967457a21 | ||
|
|
b2eb5593c3 | ||
|
|
5c416a92af | ||
|
|
a61b3dc917 | ||
|
|
f7d6fb76ea | ||
|
|
2c57e7ddab | ||
|
|
63d6e72165 | ||
|
|
e76641d9c6 | ||
|
|
8909d17589 | ||
|
|
9b474c2b77 | ||
|
|
85cef87bb7 | ||
|
|
5de0ba36f9 | ||
|
|
e403bf0794 | ||
|
|
24d0328283 | ||
|
|
f099632878 | ||
|
|
33cdb3caf4 | ||
|
|
03faf7d8ee | ||
|
|
9cb25d527f | ||
|
|
93c22330ad | ||
|
|
733f8c5703 | ||
|
|
22fcba6407 | ||
|
|
166d51a407 |
57
PATCH_RELEASE_NOTE.md
Normal file
57
PATCH_RELEASE_NOTE.md
Normal file
@@ -0,0 +1,57 @@
|
||||
---
|
||||
version: 7.1.1
|
||||
module: https://talend.poolparty.biz/coretaxonomy/42
|
||||
product:
|
||||
- https://talend.poolparty.biz/coretaxonomy/23
|
||||
---
|
||||
|
||||
# TPS-4052
|
||||
|
||||
| Info | Value |
|
||||
| ---------------- | ---------------- |
|
||||
| Patch Name | Patch\_20200528\_TPS-4052\_v1-7.1.1 |
|
||||
| Release Date | 2020-05-28 |
|
||||
| Target Version | 20181026_1147-V7.1.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-4052 [7.1.1] S3/SQS Components Inherit Role Issue in AWS Fargate (TDI-43410, TDI-43409, TDI-42687)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Consider the following requirements for your system:
|
||||
|
||||
- Talend Studio 7.1.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}
|
||||
@@ -69,145 +69,140 @@ if(hasInput){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boolean hasValidInput = inputConn!=null;
|
||||
|
||||
IMetadataTable metadata = null;
|
||||
List<IMetadataTable> metadatas = node.getMetadataList();
|
||||
boolean haveValidNodeMetadata = ((metadatas != null) && (metadatas.size() > 0) && (metadata = metadatas.get(0)) != null);
|
||||
|
||||
if (hasValidInput && haveValidNodeMetadata) {
|
||||
if (hasValidInput) {
|
||||
List<IMetadataColumn> input_columnList = inputConn.getMetadataTable().getListColumns();
|
||||
if(input_columnList == null) {
|
||||
input_columnList = new ArrayList<IMetadataColumn>();
|
||||
}
|
||||
// add incoming (not present) columns to enforcer for this comps
|
||||
if (cid.contains("tDataStewardship") || cid.contains("tMarkLogic")){
|
||||
%>
|
||||
boolean shouldCreateRuntimeSchemaForIncomingNode = false;
|
||||
<%
|
||||
for (int i = 0; i < input_columnList.size(); i++) {
|
||||
if(!input_columnList.get(i).getTalendType().equals("id_Dynamic")) {
|
||||
%>
|
||||
if (incomingEnforcer_<%=cid%>.getDesignSchema().getField("<%=input_columnList.get(i)%>") == null){
|
||||
incomingEnforcer_<%=cid%>.addIncomingNodeField("<%=input_columnList.get(i)%>", ((Object) <%=inputConn.getName()%>.<%=input_columnList.get(i)%>).getClass().getCanonicalName());
|
||||
shouldCreateRuntimeSchemaForIncomingNode = true;
|
||||
}
|
||||
<%
|
||||
}
|
||||
}
|
||||
%>
|
||||
if (shouldCreateRuntimeSchemaForIncomingNode){
|
||||
incomingEnforcer_<%=cid%>.createRuntimeSchema();
|
||||
}
|
||||
<%
|
||||
}
|
||||
// If there are dynamic columns in the schema, they need to be
|
||||
// initialized into the runtime schema of the actual IndexedRecord
|
||||
// provided to the component.
|
||||
|
||||
int dynamicPos = -1;
|
||||
for (int i = 0; i < input_columnList.size(); i++) {
|
||||
if (input_columnList.get(i).getTalendType().equals("id_Dynamic")) {
|
||||
dynamicPos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (dynamicPos != -1) {
|
||||
%>
|
||||
if (!incomingEnforcer_<%=cid%>.areDynamicFieldsInitialized()) {
|
||||
// Initialize the dynamic columns when they are first encountered.
|
||||
for (routines.system.DynamicMetadata dm_<%=cid%> : <%=inputConn.getName()%>.<%=input_columnList.get(dynamicPos).getLabel()%>.metadatas) {
|
||||
incomingEnforcer_<%=cid%>.addDynamicField(
|
||||
dm_<%=cid%>.getName(),
|
||||
dm_<%=cid%>.getType(),
|
||||
dm_<%=cid%>.getLogicalType(),
|
||||
dm_<%=cid%>.getFormat(),
|
||||
dm_<%=cid%>.getDescription(),
|
||||
dm_<%=cid%>.isNullable());
|
||||
}
|
||||
incomingEnforcer_<%=cid%>.createRuntimeSchema();
|
||||
}
|
||||
<%
|
||||
}
|
||||
|
||||
%>
|
||||
incomingEnforcer_<%=cid%>.createNewRecord();
|
||||
<%
|
||||
for (int i = 0; i < input_columnList.size(); i++) { // column
|
||||
IMetadataColumn column = input_columnList.get(i);
|
||||
if (dynamicPos != i) {
|
||||
%>
|
||||
//skip the put action if the input column doesn't appear in component runtime schema
|
||||
if (incomingEnforcer_<%=cid%>.getRuntimeSchema().getField("<%=input_columnList.get(i)%>") != null){
|
||||
incomingEnforcer_<%=cid%>.put("<%=column.getLabel()%>", <%=inputConn.getName()%>.<%=column.getLabel()%>);
|
||||
}
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
for (int i = 0; i < <%=inputConn.getName()%>.<%=column.getLabel()%>.getColumnCount(); i++) {
|
||||
incomingEnforcer_<%=cid%>.put(<%=inputConn.getName()%>.<%=column.getLabel()%>.getColumnMetadata(i).getName(),
|
||||
<%=inputConn.getName()%>.<%=column.getLabel()%>.getColumnValue(i));
|
||||
}
|
||||
<%
|
||||
}
|
||||
} // column
|
||||
|
||||
// If necesary, generate the code to handle outgoing connections.
|
||||
// TODO: For now, this can only handle one outgoing record for
|
||||
// each incoming record. To handle multiple outgoing records, code
|
||||
// generation needs to occur in component_begin in order to open
|
||||
// a for() loop.
|
||||
|
||||
// There will be a ClassCastException if the output component does
|
||||
// not implement WriterWithFeedback, but permits outgoing
|
||||
// connections.
|
||||
|
||||
if (input_columnList!=null && !input_columnList.isEmpty()) {
|
||||
// add incoming (not present) columns to enforcer for this comps
|
||||
if (cid.contains("tDataStewardship") || cid.contains("tMarkLogic")){
|
||||
%>
|
||||
boolean shouldCreateRuntimeSchemaForIncomingNode = false;
|
||||
<%
|
||||
for (int i = 0; i < input_columnList.size(); i++) {
|
||||
if(!input_columnList.get(i).getTalendType().equals("id_Dynamic")) {
|
||||
%>
|
||||
if (incomingEnforcer_<%=cid%>.getDesignSchema().getField("<%=input_columnList.get(i)%>") == null){
|
||||
incomingEnforcer_<%=cid%>.addIncomingNodeField("<%=input_columnList.get(i)%>", ((Object) <%=inputConn.getName()%>.<%=input_columnList.get(i)%>).getClass().getCanonicalName());
|
||||
shouldCreateRuntimeSchemaForIncomingNode = true;
|
||||
}
|
||||
<%
|
||||
}
|
||||
}
|
||||
%>
|
||||
if (shouldCreateRuntimeSchemaForIncomingNode){
|
||||
incomingEnforcer_<%=cid%>.createRuntimeSchema();
|
||||
}
|
||||
<%
|
||||
}
|
||||
// If there are dynamic columns in the schema, they need to be
|
||||
// initialized into the runtime schema of the actual IndexedRecord
|
||||
// provided to the component.
|
||||
|
||||
int dynamicPos = -1;
|
||||
for (int i = 0; i < input_columnList.size(); i++) {
|
||||
if (input_columnList.get(i).getTalendType().equals("id_Dynamic")) {
|
||||
dynamicPos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (dynamicPos != -1) {
|
||||
%>
|
||||
if (!incomingEnforcer_<%=cid%>.areDynamicFieldsInitialized()) {
|
||||
// Initialize the dynamic columns when they are first encountered.
|
||||
for (routines.system.DynamicMetadata dm_<%=cid%> : <%=inputConn.getName()%>.<%=input_columnList.get(dynamicPos).getLabel()%>.metadatas) {
|
||||
incomingEnforcer_<%=cid%>.addDynamicField(
|
||||
dm_<%=cid%>.getName(),
|
||||
dm_<%=cid%>.getType(),
|
||||
dm_<%=cid%>.getLogicalType(),
|
||||
dm_<%=cid%>.getFormat(),
|
||||
dm_<%=cid%>.getDescription(),
|
||||
dm_<%=cid%>.isNullable());
|
||||
}
|
||||
incomingEnforcer_<%=cid%>.createRuntimeSchema();
|
||||
}
|
||||
<%
|
||||
}
|
||||
|
||||
%>
|
||||
incomingEnforcer_<%=cid%>.createNewRecord();
|
||||
<%
|
||||
for (int i = 0; i < input_columnList.size(); i++) { // column
|
||||
IMetadataColumn column = input_columnList.get(i);
|
||||
if (dynamicPos != i) {
|
||||
%>
|
||||
//skip the put action if the input column doesn't appear in component runtime schema
|
||||
if (incomingEnforcer_<%=cid%>.getRuntimeSchema().getField("<%=input_columnList.get(i)%>") != null){
|
||||
incomingEnforcer_<%=cid%>.put("<%=column.getLabel()%>", <%=inputConn.getName()%>.<%=column.getLabel()%>);
|
||||
}
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
for (int i = 0; i < <%=inputConn.getName()%>.<%=column.getLabel()%>.getColumnCount(); i++) {
|
||||
incomingEnforcer_<%=cid%>.put(<%=inputConn.getName()%>.<%=column.getLabel()%>.getColumnMetadata(i).getName(),
|
||||
<%=inputConn.getName()%>.<%=column.getLabel()%>.getColumnValue(i));
|
||||
}
|
||||
<%
|
||||
}
|
||||
} // column
|
||||
|
||||
// If necesary, generate the code to handle outgoing connections.
|
||||
// TODO: For now, this can only handle one outgoing record for
|
||||
// each incoming record. To handle multiple outgoing records, code
|
||||
// generation needs to occur in component_begin in order to open
|
||||
// a for() loop.
|
||||
|
||||
// There will be a ClassCastException if the output component does
|
||||
// not implement WriterWithFeedback, but permits outgoing
|
||||
// connections.
|
||||
|
||||
ComponentProperties componentProps = node.getComponentProperties();
|
||||
ProcessPropertiesGenerator generator = new ProcessPropertiesGenerator(cid, component);
|
||||
List<Component.CodegenPropInfo> propsToProcess = component.getCodegenPropInfos(componentProps);
|
||||
for (Component.CodegenPropInfo propInfo : propsToProcess) { // propInfo
|
||||
List<NamedThing> properties = propInfo.props.getProperties();
|
||||
for (NamedThing prop : properties) { // property
|
||||
if (prop instanceof Property) { // if, only deal with valued Properties
|
||||
Property property = (Property)prop;
|
||||
if (property.getFlags() != null && (property.getFlags().contains(Property.Flags.DESIGN_TIME_ONLY) || property.getFlags().contains(Property.Flags.HIDDEN)))
|
||||
continue;
|
||||
if(property.getTaggedValue(IGenericConstants.DYNAMIC_PROPERTY_VALUE)!=null && Boolean.valueOf(String.valueOf(property.getTaggedValue(IGenericConstants.DYNAMIC_PROPERTY_VALUE)))) {
|
||||
generator.setPropertyValues(property, propInfo, null, false, false);
|
||||
}
|
||||
ComponentProperties componentProps = node.getComponentProperties();
|
||||
ProcessPropertiesGenerator generator = new ProcessPropertiesGenerator(cid, component);
|
||||
List<Component.CodegenPropInfo> propsToProcess = component.getCodegenPropInfos(componentProps);
|
||||
for (Component.CodegenPropInfo propInfo : propsToProcess) { // propInfo
|
||||
List<NamedThing> properties = propInfo.props.getProperties();
|
||||
for (NamedThing prop : properties) { // property
|
||||
if (prop instanceof Property) { // if, only deal with valued Properties
|
||||
Property property = (Property)prop;
|
||||
if (property.getFlags() != null && (property.getFlags().contains(Property.Flags.DESIGN_TIME_ONLY) || property.getFlags().contains(Property.Flags.HIDDEN)))
|
||||
continue;
|
||||
if(property.getTaggedValue(IGenericConstants.DYNAMIC_PROPERTY_VALUE)!=null && Boolean.valueOf(String.valueOf(property.getTaggedValue(IGenericConstants.DYNAMIC_PROPERTY_VALUE)))) {
|
||||
generator.setPropertyValues(property, propInfo, null, false, false);
|
||||
}
|
||||
} // property
|
||||
} // propInfo
|
||||
|
||||
%>
|
||||
org.apache.avro.generic.IndexedRecord data_<%=cid%> = incomingEnforcer_<%=cid%>.getCurrentRecord();
|
||||
|
||||
<%
|
||||
boolean isParallelize ="true".equalsIgnoreCase(ElementParameterParser.getValue(node, "__PARALLELIZE__"));
|
||||
if (isParallelize) {
|
||||
String sourceComponentId = inputConn.getSource().getUniqueName();
|
||||
if(sourceComponentId!=null && sourceComponentId.contains("tAsyncIn")) {
|
||||
%>
|
||||
globalMap.put(buffersSizeKey_<%=cid%>, buffersSize_<%=sourceComponentId%>);
|
||||
<%
|
||||
}
|
||||
}
|
||||
%>
|
||||
}
|
||||
} // property
|
||||
} // propInfo
|
||||
|
||||
%>
|
||||
org.apache.avro.generic.IndexedRecord data_<%=cid%> = incomingEnforcer_<%=cid%>.getCurrentRecord();
|
||||
|
||||
<%
|
||||
boolean isParallelize ="true".equalsIgnoreCase(ElementParameterParser.getValue(node, "__PARALLELIZE__"));
|
||||
if (isParallelize) {
|
||||
String sourceComponentId = inputConn.getSource().getUniqueName();
|
||||
if(sourceComponentId!=null && sourceComponentId.contains("tAsyncIn")) {
|
||||
%>
|
||||
globalMap.put(buffersSizeKey_<%=cid%>, buffersSize_<%=sourceComponentId%>);
|
||||
<%
|
||||
}
|
||||
}
|
||||
%>
|
||||
|
||||
writer_<%=cid%>.write(data_<%=cid%>);
|
||||
|
||||
nb_line_<%=cid %>++;
|
||||
<%if(hasMainOutput){
|
||||
%>
|
||||
if(!(writer_<%=cid%> instanceof org.talend.components.api.component.runtime.WriterWithFeedback)) {
|
||||
// For no feedback writer,just pass the input record to the output
|
||||
if (data_<%=cid%>!=null) {
|
||||
outgoingMainRecordsList_<%=cid%> = java.util.Arrays.asList(data_<%=cid%>);
|
||||
}
|
||||
}
|
||||
<%
|
||||
}
|
||||
writer_<%=cid%>.write(data_<%=cid%>);
|
||||
|
||||
nb_line_<%=cid %>++;
|
||||
<%if(hasMainOutput){
|
||||
%>
|
||||
if(!(writer_<%=cid%> instanceof org.talend.components.api.component.runtime.WriterWithFeedback)) {
|
||||
// For no feedback writer,just pass the input record to the output
|
||||
if (data_<%=cid%>!=null) {
|
||||
outgoingMainRecordsList_<%=cid%> = java.util.Arrays.asList(data_<%=cid%>);
|
||||
}
|
||||
}
|
||||
<%
|
||||
}
|
||||
}
|
||||
} // canStart
|
||||
|
||||
@@ -48,6 +48,7 @@ ComponentsFactory.componentNotFound=Component folder not found\:
|
||||
ComponentsFactory.load.components=Load Components...
|
||||
ComponentsFactory.parentNotRecompiled=Warning\: parents of *.inc.javajet are not recompiled \!
|
||||
ComponentsFactory.loadComponents.missingFolder=The folder "{0}" is missing in the plugin "{1}".
|
||||
ComponentsFactory.init.waitForFinish.timeout=Can't initialise ComponentsFactory, please try again.
|
||||
ComponentsLocalProviderService.componentLoadError=Component load error
|
||||
ComponentsLocalProviderService.talendExchangeError=Talend Exchange Error
|
||||
ComponentsPreferencePage.ButtonLabel0=Ok
|
||||
|
||||
@@ -30,6 +30,11 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Level;
|
||||
@@ -139,66 +144,119 @@ public class ComponentsFactory implements IComponentsFactory {
|
||||
private static boolean cleanDone = false;
|
||||
|
||||
protected static Map<String, Map<String, Set<IComponent>>> componentNameMap;
|
||||
|
||||
private AtomicBoolean isInitialising;
|
||||
|
||||
private volatile Lock initialiseLock;
|
||||
|
||||
public ComponentsFactory() {
|
||||
isInitialising = new AtomicBoolean(false);
|
||||
initialiseLock = new ReentrantLock();
|
||||
}
|
||||
|
||||
private void init(boolean duringLogon) {
|
||||
removeOldComponentsUserFolder(); // not used anymore
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
// TimeMeasure.display = true;
|
||||
// TimeMeasure.displaySteps = true;
|
||||
// TimeMeasure.measureActive = true;
|
||||
// TimeMeasure.begin("initComponents");
|
||||
componentList = Collections.synchronizedSet(new HashSet<IComponent>());
|
||||
customComponentList = new HashSet<IComponent>();
|
||||
skeletonList = new ArrayList<String>();
|
||||
userComponentList = new HashSet<IComponent>();
|
||||
String installLocation = new Path(Platform.getConfigurationLocation().getURL().getPath()).toFile().getAbsolutePath();
|
||||
componentToProviderMap = new HashMap<IComponent, AbstractComponentsProvider>();
|
||||
boolean isNeedClean = !cleanDone && TalendCacheUtils.isSetCleanComponentCache();
|
||||
cleanDone = true; // only check this parameter one time, or it will reinitialize things all the time...
|
||||
isCreated = hasComponentFile(installLocation) && !isNeedClean;
|
||||
ComponentsCache cache = ComponentManager.getComponentCache();
|
||||
try {
|
||||
if (isCreated) {
|
||||
// if cache is created and empty, means we never loaded it before.
|
||||
// if it was already loaded, then no need to go again, since it's a static variable, it's still in
|
||||
// memory.
|
||||
// it avoids to reload from disk again even more for commandline at each logon, since it's no use.
|
||||
if (cache.getComponentEntryMap().isEmpty()) {
|
||||
ComponentsCache loadCache = loadComponentResource(installLocation);
|
||||
cache.getComponentEntryMap().putAll(loadCache.getComponentEntryMap());
|
||||
}
|
||||
} else {
|
||||
cache.getComponentEntryMap().clear();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
ExceptionHandler.process(e);
|
||||
cache.getComponentEntryMap().clear();
|
||||
isCreated = false;
|
||||
if (wait4InitialiseFinish()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
try {
|
||||
initialiseLock.lock();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
isInitialising.set(true);
|
||||
removeOldComponentsUserFolder(); // not used anymore
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
loadComponentsFromComponentsProviderExtension();
|
||||
// TimeMeasure.display = true;
|
||||
// TimeMeasure.displaySteps = true;
|
||||
// TimeMeasure.measureActive = true;
|
||||
// TimeMeasure.begin("initComponents");
|
||||
componentList = Collections.synchronizedSet(new HashSet<IComponent>());
|
||||
customComponentList = new HashSet<IComponent>();
|
||||
skeletonList = new ArrayList<String>();
|
||||
userComponentList = new HashSet<IComponent>();
|
||||
String installLocation = new Path(Platform.getConfigurationLocation().getURL().getPath()).toFile().getAbsolutePath();
|
||||
componentToProviderMap = new HashMap<IComponent, AbstractComponentsProvider>();
|
||||
boolean isNeedClean = !cleanDone && TalendCacheUtils.isSetCleanComponentCache();
|
||||
cleanDone = true; // only check this parameter one time, or it will reinitialize things all the time...
|
||||
isCreated = hasComponentFile(installLocation) && !isNeedClean;
|
||||
ComponentsCache cache = ComponentManager.getComponentCache();
|
||||
try {
|
||||
if (isCreated) {
|
||||
// if cache is created and empty, means we never loaded it before.
|
||||
// if it was already loaded, then no need to go again, since it's a static variable, it's still in
|
||||
// memory.
|
||||
// it avoids to reload from disk again even more for commandline at each logon, since it's no use.
|
||||
if (cache.getComponentEntryMap().isEmpty()) {
|
||||
ComponentsCache loadCache = loadComponentResource(installLocation);
|
||||
cache.getComponentEntryMap().putAll(loadCache.getComponentEntryMap());
|
||||
}
|
||||
} else {
|
||||
cache.getComponentEntryMap().clear();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
ExceptionHandler.process(e);
|
||||
cache.getComponentEntryMap().clear();
|
||||
isCreated = false;
|
||||
}
|
||||
|
||||
// TimeMeasure.step("initComponents", "loadComponentsFromProvider");
|
||||
// 2.Load Component from extension point: component_definition
|
||||
loadComponentsFromExtensions();
|
||||
// TimeMeasure.step("initComponents", "loadComponentsFromExtension[joblets?]");
|
||||
loadComponentsFromComponentsProviderExtension();
|
||||
|
||||
ComponentManager.saveResource(); // will save only if needed.
|
||||
// TimeMeasure.step("initComponents", "loadComponentsFromProvider");
|
||||
// 2.Load Component from extension point: component_definition
|
||||
loadComponentsFromExtensions();
|
||||
// TimeMeasure.step("initComponents", "loadComponentsFromExtension[joblets?]");
|
||||
|
||||
// init component name map, used to pick specified component immediately
|
||||
initComponentNameMap();
|
||||
ComponentManager.saveResource(); // will save only if needed.
|
||||
|
||||
// TimeMeasure.step("initComponents", "createCache");
|
||||
log.debug(componentList.size() + " components loaded in " + (System.currentTimeMillis() - startTime) + " ms"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// init component name map, used to pick specified component immediately
|
||||
initComponentNameMap();
|
||||
|
||||
// TimeMeasure.end("initComponents");
|
||||
// TimeMeasure.display = false;
|
||||
// TimeMeasure.displaySteps = false;
|
||||
// TimeMeasure.measureActive = false;
|
||||
// TimeMeasure.step("initComponents", "createCache");
|
||||
log.debug(componentList.size() + " components loaded in " + (System.currentTimeMillis() - startTime) + " ms"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
// TimeMeasure.end("initComponents");
|
||||
// TimeMeasure.display = false;
|
||||
// TimeMeasure.displaySteps = false;
|
||||
// TimeMeasure.measureActive = false;
|
||||
} finally {
|
||||
isInitialising.set(false);
|
||||
initialiseLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean wait4InitialiseFinish() {
|
||||
if (isInitialising.get()) {
|
||||
try {
|
||||
// wait for 10 min (10 * 60 seconds) by default
|
||||
long timeout = 600L;
|
||||
String timeoutStr = System.getProperty("studio.componentsFactory.init.timeout"); //$NON-NLS-1$
|
||||
if (!StringUtils.isBlank(timeoutStr)) {
|
||||
try {
|
||||
timeout = Long.valueOf(timeoutStr);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
if (initialiseLock.tryLock(timeout, TimeUnit.SECONDS)) {
|
||||
initialiseLock.unlock();
|
||||
} else {
|
||||
// may be track in dead lock, throw exception to try to break dead lock
|
||||
throw new RuntimeException(Messages.getString("ComponentsFactory.init.waitForFinish.timeout")); //$NON-NLS-1$
|
||||
}
|
||||
// initialise successfully or not
|
||||
return !isInitialising.get();
|
||||
} catch (RuntimeException e) {
|
||||
throw e;
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
// initialise failed, still need to initialise
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void initComponentNameMap() {
|
||||
@@ -729,7 +787,8 @@ public class ComponentsFactory implements IComponentsFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized int size() {
|
||||
public int size() {
|
||||
wait4InitialiseFinish();
|
||||
if (componentList == null) {
|
||||
init(false);
|
||||
}
|
||||
@@ -737,7 +796,8 @@ public class ComponentsFactory implements IComponentsFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized IComponent get(String name) {
|
||||
public IComponent get(String name) {
|
||||
wait4InitialiseFinish();
|
||||
if (componentList == null) {
|
||||
init(false);
|
||||
}
|
||||
@@ -757,7 +817,8 @@ public class ComponentsFactory implements IComponentsFactory {
|
||||
* @see org.talend.core.model.components.IComponentsFactory#get(java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized IComponent get(String name, String paletteType) {
|
||||
public IComponent get(String name, String paletteType) {
|
||||
wait4InitialiseFinish();
|
||||
if (componentList == null) {
|
||||
init(false);
|
||||
}
|
||||
@@ -772,6 +833,7 @@ public class ComponentsFactory implements IComponentsFactory {
|
||||
|
||||
@Override
|
||||
public IComponent getJobletComponent(String name, String paletteType) {
|
||||
wait4InitialiseFinish();
|
||||
if (componentList == null) {
|
||||
init(false);
|
||||
}
|
||||
@@ -799,6 +861,7 @@ public class ComponentsFactory implements IComponentsFactory {
|
||||
@Override
|
||||
public void initializeComponents(IProgressMonitor monitor) {
|
||||
this.monitor = monitor;
|
||||
wait4InitialiseFinish();
|
||||
if (componentList == null) {
|
||||
init(false);
|
||||
}
|
||||
@@ -809,6 +872,7 @@ public class ComponentsFactory implements IComponentsFactory {
|
||||
@Override
|
||||
public void initializeComponents(IProgressMonitor monitor, boolean duringLogon) {
|
||||
this.monitor = monitor;
|
||||
wait4InitialiseFinish();
|
||||
if (componentList == null) {
|
||||
init(duringLogon);
|
||||
}
|
||||
@@ -822,12 +886,18 @@ public class ComponentsFactory implements IComponentsFactory {
|
||||
* @see org.talend.core.model.components.IComponentsFactory#getComponents()
|
||||
*/
|
||||
@Override
|
||||
public synchronized Set<IComponent> getComponents() {
|
||||
public Set<IComponent> getComponents() {
|
||||
wait4InitialiseFinish();
|
||||
if (componentList == null) {
|
||||
init(false);
|
||||
}
|
||||
return componentList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitialising() {
|
||||
return isInitialising.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IComponent> readComponents() {
|
||||
@@ -840,7 +910,8 @@ public class ComponentsFactory implements IComponentsFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Map<String, Map<String, Set<IComponent>>> getComponentNameMap() {
|
||||
public Map<String, Map<String, Set<IComponent>>> getComponentNameMap() {
|
||||
wait4InitialiseFinish();
|
||||
if (componentNameMap == null) {
|
||||
init(false);
|
||||
}
|
||||
@@ -848,7 +919,8 @@ public class ComponentsFactory implements IComponentsFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<IComponent> getCustomComponents() {
|
||||
public List<IComponent> getCustomComponents() {
|
||||
wait4InitialiseFinish();
|
||||
if (customComponentList == null) {
|
||||
init(false);
|
||||
}
|
||||
@@ -862,6 +934,7 @@ public class ComponentsFactory implements IComponentsFactory {
|
||||
*/
|
||||
@Override
|
||||
public List<String> getSkeletons() {
|
||||
wait4InitialiseFinish();
|
||||
if (skeletonList == null) {
|
||||
init(false);
|
||||
}
|
||||
@@ -900,6 +973,7 @@ public class ComponentsFactory implements IComponentsFactory {
|
||||
jobletService.clearSparkStreamingJobletComponent();
|
||||
}
|
||||
}
|
||||
isInitialising.set(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
String dataset = ElementParameterParser.getValue(node, "__DATASET__");
|
||||
String table = ElementParameterParser.getValue(node, "__TABLE__");
|
||||
String gsFile = ElementParameterParser.getValue(node, "__GS_FILE__");
|
||||
|
||||
String fieldDelimiter = ElementParameterParser.getValue(node, "__FIELD_DELIMITER__");
|
||||
String actionOnData = ElementParameterParser.getValue(node, "__ACTION_ON_DATA__");
|
||||
boolean dieOnError = "true".equals(ElementParameterParser.getValue(node, "__DIE_ON_ERROR__"));
|
||||
|
||||
@@ -258,56 +258,80 @@
|
||||
|
||||
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();
|
||||
com.google.api.services.bigquery.model.TableSchema schema_<%=cid%> = new com.google.api.services.bigquery.model.TableSchema();
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
log.info("<%=cid%> - Table field schema:");
|
||||
<%
|
||||
}
|
||||
%>
|
||||
java.util.List<com.google.api.services.bigquery.model.TableFieldSchema> fields_<%=cid%> = new java.util.ArrayList<com.google.api.services.bigquery.model.TableFieldSchema>();
|
||||
<%
|
||||
List<IMetadataTable> metadatas = node.getMetadataList();
|
||||
if ((metadatas!=null) && (metadatas.size() > 0)) {
|
||||
IMetadataTable metadata = metadatas.get(0);
|
||||
if (metadata != null) {
|
||||
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 = "string";
|
||||
if("id_Float".equals(column.getTalendType())) {
|
||||
typeToGenerate = "float";
|
||||
} else if("id_Integer".equals(column.getTalendType())) {
|
||||
typeToGenerate = "integer";
|
||||
} else if("id_Boolean".equals(column.getTalendType())) {
|
||||
typeToGenerate = "boolean";
|
||||
} else if("id_Date".equals(column.getTalendType())) {
|
||||
typeToGenerate = "timestamp";
|
||||
}
|
||||
%>
|
||||
com.google.api.services.bigquery.model.TableFieldSchema <%=columnName%>_<%=cid%> = new com.google.api.services.bigquery.model.TableFieldSchema();
|
||||
<%=columnName%>_<%=cid%>.setName("<%=columnName%>");
|
||||
<%=columnName%>_<%=cid%>.setType("<%=typeToGenerate%>");
|
||||
fields_<%=cid%>.add(<%=columnName%>_<%=cid%>);
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
log.debug("<%=cid%> - Field index[<%=i%>] {\"name\":\"<%=columnName%>\",\"type\":\"<%=typeToGenerate%>\"}");
|
||||
<%
|
||||
|
||||
if (<%=ElementParameterParser.getBooleanValue(node, "__CREATE_TABLE_IF_NOT_EXIST__")%>) {
|
||||
com.google.api.services.bigquery.model.TableSchema schema_<%=cid%> = new com.google.api.services.bigquery.model.TableSchema();
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
log.info("<%=cid%> - Table field schema:");
|
||||
<%
|
||||
}
|
||||
%>
|
||||
java.util.List<com.google.api.services.bigquery.model.TableFieldSchema> fields_<%=cid%> = new java.util.ArrayList<com.google.api.services.bigquery.model.TableFieldSchema>();
|
||||
<%
|
||||
List<IMetadataTable> metadatas = node.getMetadataList();
|
||||
if ((metadatas!=null) && (metadatas.size() > 0)) {
|
||||
IMetadataTable metadata = metadatas.get(0);
|
||||
if (metadata != null) {
|
||||
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 = "string";
|
||||
if("id_Float".equals(column.getTalendType()) || "id_Double".equals(column.getTalendType())) {
|
||||
typeToGenerate = "float";
|
||||
}else if("id_Integer".equals(column.getTalendType()) || "id_Long".equals(column.getTalendType()) || "id_Short".equals(column.getTalendType())) {
|
||||
typeToGenerate = "integer";
|
||||
} else if("id_Character".equals(column.getTalendType())) {
|
||||
typeToGenerate = "string";
|
||||
} else if("id_BigDecimal".equals(column.getTalendType())) {
|
||||
typeToGenerate = "numeric";
|
||||
} else if("id_Boolean".equals(column.getTalendType())) {
|
||||
typeToGenerate = "boolean";
|
||||
} else if("id_Date".equals(column.getTalendType())) {
|
||||
String pattern = column.getPattern();
|
||||
if(pattern.length() == 12 || pattern.isEmpty() || "\"\"".equals(pattern)) {
|
||||
typeToGenerate = "date";
|
||||
}else if(pattern.length() > 12){
|
||||
typeToGenerate = "timestamp";
|
||||
}else{
|
||||
typeToGenerate = "string";
|
||||
}
|
||||
}
|
||||
%>
|
||||
<%
|
||||
String modeType = null;
|
||||
if (!column.isNullable()) {
|
||||
modeType = "REQUIRED";
|
||||
} else {
|
||||
modeType = "NULLABLE";
|
||||
}
|
||||
%>
|
||||
com.google.api.services.bigquery.model.TableFieldSchema <%=columnName%>_<%=cid%> = new com.google.api.services.bigquery.model.TableFieldSchema();
|
||||
<%=columnName%>_<%=cid%>.setName("<%=columnName%>");
|
||||
<%=columnName%>_<%=cid%>.setType("<%=typeToGenerate%>");
|
||||
<%=columnName%>_<%=cid%>.setMode("<%=modeType%>");
|
||||
fields_<%=cid%>.add(<%=columnName%>_<%=cid%>);
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
log.debug("<%=cid%> - Field index[<%=i%>] {\"name\":\"<%=columnName%>\",\"type\":\"<%=typeToGenerate%>\",\"mode\":\"<%=modeType%>\"}");
|
||||
<%
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
%>
|
||||
|
||||
|
||||
|
||||
schema_<%=cid%>.setFields(fields_<%=cid%>);
|
||||
|
||||
queryLoad_<%=cid%>.setSchema(schema_<%=cid%>);
|
||||
schema_<%=cid%>.setFields(fields_<%=cid%>);
|
||||
|
||||
queryLoad_<%=cid%>.setSchema(schema_<%=cid%>);
|
||||
|
||||
}
|
||||
<%
|
||||
if("true".equals(ElementParameterParser.getValue(node, "__CREATE_TABLE_IF_NOT_EXIST__"))) {
|
||||
%>
|
||||
@@ -321,7 +345,7 @@
|
||||
|
||||
if("true".equals(ElementParameterParser.getValue(node, "__SET_FIELD_DELIMITER__"))) {
|
||||
%>
|
||||
queryLoad_<%=cid%>.setFieldDelimiter(<%=ElementParameterParser.getValue(node, "__FIELD_DELIMITER__")%>);
|
||||
queryLoad_<%=cid%>.setFieldDelimiter(<%=fieldDelimiter%>);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
@@ -336,7 +360,7 @@
|
||||
queryLoad_<%=cid%>.setDestinationTable(destinationTable_<%=cid%>);
|
||||
queryLoad_<%=cid%>.setSourceUris(java.util.Arrays.asList(<%=ElementParameterParser.getValue(node, "__GS_FILE__")%>));
|
||||
queryLoad_<%=cid%>.setSkipLeadingRows(<%=ElementParameterParser.getValue(node, "__GS_FILE_HEADER__")%>);
|
||||
|
||||
queryLoad_<%=cid%>.setNullMarker("\\N");
|
||||
config_<%=cid%>.setLoad(queryLoad_<%=cid%>);
|
||||
|
||||
job_<%=cid%>.setConfiguration(config_<%=cid%>);
|
||||
@@ -375,10 +399,10 @@
|
||||
}
|
||||
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()).execute();
|
||||
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);
|
||||
pollJob_<%=cid%> = bigqueryclient_<%=cid%>.jobs().get(PROJECT_ID_<%=cid%>,jobExec_<%=cid%>.getJobReference().getJobId()).execute();
|
||||
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%>
|
||||
.getJobReference().getJobId(), pollJob_<%=cid%>
|
||||
@@ -440,6 +464,7 @@
|
||||
/* ----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.Table table_<%=cid%> = bigquery_<%=cid%>.getTable(tableId_<%=cid%>);
|
||||
com.google.cloud.bigquery.LoadJobConfiguration.Builder loadJobBuilder_<%=cid%> = com.google.cloud.bigquery.LoadJobConfiguration.newBuilder(tableId_<%=cid%>, <%=gsFile%>);
|
||||
if (<%=ElementParameterParser.getBooleanValue(node, "__DROP__")%> && table_<%=cid%> != null) {
|
||||
boolean deleted = bigquery_<%=cid%>.delete(tableId_<%=cid%>);
|
||||
if (deleted) {
|
||||
@@ -454,9 +479,7 @@
|
||||
throw new RuntimeException("Unable to delete table " + tableId_<%=cid%>);
|
||||
}
|
||||
}
|
||||
boolean tableNotExist = table_<%=cid%> == null;
|
||||
if (<%=ElementParameterParser.getBooleanValue(node, "__DROP__")%> || tableNotExist) {
|
||||
boolean typeSupported = true;
|
||||
if (<%=ElementParameterParser.getBooleanValue(node, "__DROP__")%> || <%=ElementParameterParser.getBooleanValue(node, "__CREATE_TABLE_IF_NOT_EXIST__")%>) {
|
||||
java.util.List<com.google.cloud.bigquery.Field> fields_<%=cid%> = new java.util.ArrayList<>();
|
||||
<%
|
||||
List<IMetadataTable> metadatas = node.getMetadataList();
|
||||
@@ -468,27 +491,37 @@
|
||||
for (int i = 0; i < nbColumns; i++ ) {
|
||||
IMetadataColumn column = columns.get(i);
|
||||
String columnName = column.getLabel();
|
||||
String typeToGenerate = null;
|
||||
if("id_String".equals(column.getTalendType())) {
|
||||
String typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.STRING";
|
||||
if("id_String".equals(column.getTalendType()) || "id_Character".equals(column.getTalendType())) {
|
||||
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.STRING";
|
||||
} else if ("id_Float".equals(column.getTalendType()) || "id_Double".equals(column.getTalendType())) {
|
||||
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.FLOAT";
|
||||
} 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";
|
||||
} else if ("id_Boolean".equals(column.getTalendType())) {
|
||||
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.BOOLEAN";
|
||||
} else if ("id_Date".equals(column.getTalendType())) {
|
||||
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.TIMESTAMP";
|
||||
} else {
|
||||
%>
|
||||
typeSupported = false;
|
||||
<%
|
||||
} 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";
|
||||
}else if(pattern.length() > 12){
|
||||
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.TIMESTAMP";
|
||||
}else{
|
||||
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.STRING";
|
||||
}
|
||||
}
|
||||
|
||||
String modeType = "NULLABLE";
|
||||
if (!column.isNullable()) {
|
||||
modeType = "REQUIRED";
|
||||
}
|
||||
%>
|
||||
if (!typeSupported) {
|
||||
throw new IllegalArgumentException("unsupported type for column [<%=columnName%>]: " + "<%=column.getTalendType()%>");
|
||||
}
|
||||
com.google.cloud.bigquery.Field field_<%=i%> = com.google.cloud.bigquery.Field.of("<%=columnName%>", <%=typeToGenerate%>);
|
||||
|
||||
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%>);
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
@@ -500,12 +533,59 @@
|
||||
}
|
||||
}
|
||||
%>
|
||||
|
||||
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();
|
||||
table_<%=cid%> = bigquery_<%=cid%>.create(tableInfo_<%=cid%>);
|
||||
loadJobBuilder_<%=cid%>.setSchema(schema_<%=cid%>);
|
||||
|
||||
}
|
||||
com.google.cloud.bigquery.Job job_<%=cid%> = table_<%=cid%>.load(com.google.cloud.bigquery.FormatOptions.csv(), <%=gsFile%>);
|
||||
job_<%=cid%> = job_<%=cid%>.waitFor(com.google.cloud.RetryOption.initialRetryDelay(org.threeten.bp.Duration.ofSeconds(1)), com.google.cloud.RetryOption.totalTimeout(org.threeten.bp.Duration.ofSeconds(30)));
|
||||
|
||||
<%
|
||||
if("true".equals(ElementParameterParser.getValue(node, "__CREATE_TABLE_IF_NOT_EXIST__"))) {
|
||||
%>
|
||||
loadJobBuilder_<%=cid%>.setCreateDisposition(com.google.cloud.bigquery.JobInfo.CreateDisposition.CREATE_IF_NEEDED);
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
loadJobBuilder_<%=cid%>.setCreateDisposition(com.google.cloud.bigquery.JobInfo.CreateDisposition.CREATE_NEVER);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
<%
|
||||
if("APPEND".equals(actionOnData)) {
|
||||
%>
|
||||
loadJobBuilder_<%=cid%>.setWriteDisposition(com.google.cloud.bigquery.JobInfo.WriteDisposition.WRITE_APPEND);
|
||||
<%
|
||||
} else if("TRUNCATE".equals(actionOnData)) {
|
||||
%>
|
||||
loadJobBuilder_<%=cid%>.setWriteDisposition(com.google.cloud.bigquery.JobInfo.WriteDisposition.WRITE_TRUNCATE);
|
||||
|
||||
<%
|
||||
}
|
||||
else {
|
||||
%>
|
||||
loadJobBuilder_<%=cid%>.setWriteDisposition(com.google.cloud.bigquery.JobInfo.WriteDisposition.WRITE_EMPTY);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
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(<%=ElementParameterParser.getValue(node, "__GS_FILE_HEADER__")%>);
|
||||
<%if("true".equals(ElementParameterParser.getValue(node, "__SET_FIELD_DELIMITER__"))) {
|
||||
%>
|
||||
csvOptions_<%=cid%>.setFieldDelimiter(<%=fieldDelimiter%>);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
loadJobBuilder_<%=cid%>.setNullMarker("\\N");
|
||||
loadJobBuilder_<%=cid%>.setFormatOptions(csvOptions_<%=cid%>.build());
|
||||
com.google.cloud.bigquery.Job job_<%=cid%> = bigquery_<%=cid%>.create(com.google.cloud.bigquery.JobInfo.of(loadJobBuilder_<%=cid%>.build()));
|
||||
job_<%=cid%> = job_<%=cid%>.waitFor(com.google.cloud.RetryOption.initialRetryDelay(org.threeten.bp.Duration.ofSeconds(1)));
|
||||
if (job_<%=cid%> != null && job_<%=cid%>.getStatus().getError() == null) {
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
@@ -515,7 +595,8 @@
|
||||
}
|
||||
%>
|
||||
} else {
|
||||
throw new RuntimeException("Job failed: " + job_<%=cid%>.getStatus().getError());
|
||||
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)---- */
|
||||
@@ -523,4 +604,4 @@
|
||||
} else {
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\" or \"OAUTH\", but it is " + authMode);
|
||||
}
|
||||
%>
|
||||
%>
|
||||
|
||||
@@ -1,218 +1,217 @@
|
||||
<COMPONENT>
|
||||
<HEADER
|
||||
PLATEFORM="ALL"
|
||||
SERIAL=""
|
||||
VERSION="0.102"
|
||||
STATUS="ALPHA"
|
||||
COMPATIBILITY="ALL"
|
||||
AUTHOR="Talend"
|
||||
RELEASE_DATE="20070312A"
|
||||
STARTABLE="true"
|
||||
LOG4J_ENABLED="true"
|
||||
>
|
||||
<SIGNATURE/>
|
||||
</HEADER>
|
||||
<FAMILIES>
|
||||
<FAMILY>Big Data/Google BigQuery</FAMILY>
|
||||
</FAMILIES>
|
||||
<DOCUMENTATION>
|
||||
<URL/>
|
||||
</DOCUMENTATION>
|
||||
<CONNECTORS>
|
||||
<CONNECTOR CTYPE="FLOW" MAX_INPUT="0" MAX_OUTPUT="0"/>
|
||||
<CONNECTOR CTYPE="ITERATE" MAX_OUTPUT="1" MAX_INPUT="1"/>
|
||||
<CONNECTOR CTYPE="SUBJOB_OK" MAX_INPUT="1" />
|
||||
<CONNECTOR CTYPE="SUBJOB_ERROR" MAX_INPUT="1" />
|
||||
<CONNECTOR CTYPE="COMPONENT_OK"/>
|
||||
<CONNECTOR CTYPE="COMPONENT_ERROR"/>
|
||||
<CONNECTOR CTYPE="RUN_IF"/>
|
||||
</CONNECTORS>
|
||||
<PARAMETERS>
|
||||
<PARAMETER
|
||||
NAME="SCHEMA"
|
||||
FIELD="SCHEMA_TYPE"
|
||||
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" />
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="SERVICE_ACCOUNT_CREDENTIALS_FILE"
|
||||
REPOSITORY_VALUE="SERVICE_ACCOUNT_CREDENTIALS_FILE"
|
||||
FIELD="FILE"
|
||||
NUM_ROW="10"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="AUTH_MODE == 'SERVICEACCOUNT'"
|
||||
GROUP="AUTHENTICATION"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="CLIENT_ID"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="10"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="AUTH_MODE == 'OAUTH'"
|
||||
GROUP="AUTHENTICATION"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER
|
||||
NAME="CLIENT_SECRET"
|
||||
FIELD="PASSWORD"
|
||||
NUM_ROW="20"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="AUTH_MODE == 'OAUTH'"
|
||||
GROUP="AUTHENTICATION"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER
|
||||
NAME="AUTHORIZATION_CODE"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="30"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="AUTH_MODE == 'OAUTH'"
|
||||
GROUP="AUTHENTICATION"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER
|
||||
NAME="PROJECT_ID"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="40"
|
||||
REQUIRED="true"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="DATASET"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="49"
|
||||
REQUIRED="true"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER
|
||||
NAME="TABLE"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="50"
|
||||
REQUIRED="true"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="CREATE_TABLE_IF_NOT_EXIST" FIELD="CHECK" NUM_ROW="50" REQUIRED="true" SHOW_IF="AUTH_MODE == 'OAUTH'">
|
||||
<DEFAULT>true</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER
|
||||
NAME="ACTION_ON_DATA"
|
||||
SHOW_IF="AUTH_MODE == 'OAUTH'"
|
||||
FIELD="CLOSED_LIST"
|
||||
NUM_ROW="51"
|
||||
REQUIRED="true"
|
||||
>
|
||||
<ITEMS DEFAULT="TRUNCATE">
|
||||
<ITEM NAME="TRUNCATE" VALUE="TRUNCATE" />
|
||||
<ITEM NAME="APPEND" VALUE="APPEND" />
|
||||
<ITEM NAME="EMPTY" VALUE="EMPTY" />
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="BULK_FILE_ALREADY_EXIST" FIELD="CHECK" NUM_ROW="59" REQUIRED="true" GROUP="GS_CONF">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="GS_ACCESS_KEY" FIELD="TEXT" NUM_ROW="60" REQUIRED="true" GROUP="GS_CONF" SHOW_IF="BULK_FILE_ALREADY_EXIST=='false'">
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="GS_SECRET_KEY" FIELD="PASSWORD" NUM_ROW="61" REQUIRED="true" GROUP="GS_CONF" SHOW_IF="BULK_FILE_ALREADY_EXIST=='false'">
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="GS_LOCAL_FILE" FIELD="FILE" NUM_ROW="62" REQUIRED="true" GROUP="GS_CONF" SHOW_IF="BULK_FILE_ALREADY_EXIST=='false'">
|
||||
<DEFAULT>""</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>
|
||||
<PARAMETER
|
||||
NAME="GS_FILE"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="70"
|
||||
REQUIRED="true"
|
||||
GROUP="GS_CONF"
|
||||
>
|
||||
<DEFAULT>"gs://"</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER
|
||||
NAME="GS_FILE_HEADER"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="71"
|
||||
REQUIRED="true"
|
||||
GROUP="GS_CONF"
|
||||
>
|
||||
<DEFAULT>0</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="DIE_ON_ERROR" FIELD="CHECK" NUM_ROW="80" REQUIRED="true">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
</PARAMETERS>
|
||||
<ADVANCED_PARAMETERS>
|
||||
<PARAMETER NAME="TOKEN_NAME" FIELD="FILE" NUM_ROW="10"
|
||||
REQUIRED="true" SHOW_IF="AUTH_MODE == 'OAUTH'">
|
||||
<DEFAULT>"__COMP_DEFAULT_FILE_DIR__/token.properties"</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="SET_FIELD_DELIMITER" FIELD="CHECK" REQUIRED="true" NUM_ROW="20" >
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="FIELD_DELIMITER" FIELD="TEXT" REQUIRED="true" NUM_ROW="20"
|
||||
SHOW_IF="(SET_FIELD_DELIMITER == 'true')">
|
||||
<DEFAULT>","</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="DROP" FIELD="CHECK" REQUIRED="true" NUM_ROW="25" SHOW_IF="AUTH_MODE == 'SERVICEACCOUNT'">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="ENCODING" FIELD="ENCODING_TYPE" NUM_ROW="30"
|
||||
REQUIRED="true" REPOSITORY_VALUE="ENCODING">
|
||||
<DEFAULT>"ISO-8859-15"</DEFAULT>
|
||||
</PARAMETER>
|
||||
</ADVANCED_PARAMETERS>
|
||||
<CODEGENERATION>
|
||||
<IMPORTS>
|
||||
<IMPORT NAME="google-api-client-1.19.0.jar" MODULE="google-api-client-1.19.0.jar" MVN="mvn:org.talend.libraries/google-api-client-1.19.0/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.google/lib/google-api-client-1.19.0.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="google-api-services-oauth2-v2-rev78-1.19.0.jar" MODULE="google-api-services-oauth2-v2-rev78-1.19.0.jar" MVN="mvn:org.talend.libraries/google-api-services-oauth2-v2-rev78-1.19.0/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.google/lib/google-api-services-oauth2-v2-rev78-1.19.0.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="google-api-services-bigquery-v2-rev391-1.21.0.jar" MODULE="google-api-services-bigquery-v2-rev391-1.21.0.jar" MVN="mvn:org.talend.libraries/google-api-services-bigquery-v2-rev391-1.21.0/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.google/lib/google-api-services-bigquery-v2-rev391-1.21.0.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="google-http-client-1.19.0.jar" MODULE="google-http-client-1.19.0.jar" MVN="mvn:org.talend.libraries/google-http-client-1.19.0/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.google/lib/google-http-client-1.19.0.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="google-oauth-client-1.19.0.jar" MODULE="google-oauth-client-1.19.0.jar" MVN="mvn:org.talend.libraries/google-oauth-client-1.19.0/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.google/lib/google-oauth-client-1.19.0.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="google-http-client-jackson2-1.19.0.jar" MODULE="google-http-client-jackson2-1.19.0.jar" MVN="mvn:org.talend.libraries/google-http-client-jackson2-1.19.0/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.google/lib/google-http-client-jackson2-1.19.0.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="guava-jdk5-13.0.jar" MODULE="guava-jdk5-13.0.jar" MVN="mvn:org.talend.libraries/guava-jdk5-13.0/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.guava/lib/guava-jdk5-13.0.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="jackson-core-2.9.5.jar" MODULE="jackson-core-2.9.5.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.9.5" 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.1.1" MODULE="commons-logging-1.1.1.jar" MVN="mvn:org.talend.libraries/commons-logging-1.1.1/6.0.0" UrlPath="platform:/base/plugins/org.apache.commons.logging_1.1.1.v201101211721.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="httpclient-4.5.5" MODULE="httpclient-4.5.5.jar" MVN="mvn:org.apache.httpcomponents/httpclient/4.5.5" REQUIRED="true" />
|
||||
<IMPORT NAME="httpcore-4.4.9" MODULE="httpcore-4.4.9.jar" MVN="mvn:org.apache.httpcomponents/httpcore/4.4.9" REQUIRED="true" />
|
||||
<IMPORT NAME="commons-codec-1.4" MODULE="commons-codec-1.4.jar" MVN="mvn:commons-codec/commons-codec/1.4" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.4.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="google-cloud-bigquery-1.32.0.jar" MODULE="google-cloud-bigquery-1.32.0.jar" MVN="mvn:com.google.cloud/google-cloud-bigquery/1.32.0" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="google-http-client-jackson-1.23.0.jar" MODULE="google-http-client-jackson-1.23.0.jar" MVN="mvn:com.google.http-client/google-http-client-jackson/1.23.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.9.1.jar" MODULE="google-auth-library-credentials-0.9.1.jar" MVN="mvn:com.google.auth/google-auth-library-credentials/0.9.1" 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.11.jar" MODULE="jackson-core-asl-1.9.11.jar" MVN="mvn:org.codehaus.jackson/jackson-core-asl/1.9.11" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="google-auth-library-oauth2-http-0.9.1.jar" MODULE="google-auth-library-oauth2-http-0.9.1.jar" MVN="mvn:com.google.auth/google-auth-library-oauth2-http/0.9.1" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="google-cloud-core-1.32.0.jar" MODULE="google-cloud-core-1.32.0.jar" MVN="mvn:com.google.cloud/google-cloud-core/1.32.0" 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="guava-20.0.jar" MODULE="guava-20.0.jar" MVN="mvn:com.google.guava/guava/20.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.23.0.jar" MODULE="google-http-client-appengine-1.23.0.jar" MVN="mvn:com.google.http-client/google-http-client-appengine/1.23.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'" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
<RETURNS>
|
||||
</RETURNS>
|
||||
</COMPONENT>
|
||||
<COMPONENT>
|
||||
<HEADER
|
||||
PLATEFORM="ALL"
|
||||
SERIAL=""
|
||||
VERSION="0.102"
|
||||
STATUS="ALPHA"
|
||||
COMPATIBILITY="ALL"
|
||||
AUTHOR="Talend"
|
||||
RELEASE_DATE="20070312A"
|
||||
STARTABLE="true"
|
||||
LOG4J_ENABLED="true"
|
||||
>
|
||||
<SIGNATURE/>
|
||||
</HEADER>
|
||||
<FAMILIES>
|
||||
<FAMILY>Big Data/Google BigQuery</FAMILY>
|
||||
</FAMILIES>
|
||||
<DOCUMENTATION>
|
||||
<URL/>
|
||||
</DOCUMENTATION>
|
||||
<CONNECTORS>
|
||||
<CONNECTOR CTYPE="FLOW" MAX_INPUT="0" MAX_OUTPUT="0"/>
|
||||
<CONNECTOR CTYPE="ITERATE" MAX_OUTPUT="1" MAX_INPUT="1"/>
|
||||
<CONNECTOR CTYPE="SUBJOB_OK" MAX_INPUT="1" />
|
||||
<CONNECTOR CTYPE="SUBJOB_ERROR" MAX_INPUT="1" />
|
||||
<CONNECTOR CTYPE="COMPONENT_OK"/>
|
||||
<CONNECTOR CTYPE="COMPONENT_ERROR"/>
|
||||
<CONNECTOR CTYPE="RUN_IF"/>
|
||||
</CONNECTORS>
|
||||
<PARAMETERS>
|
||||
<PARAMETER
|
||||
NAME="SCHEMA"
|
||||
FIELD="SCHEMA_TYPE"
|
||||
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" />
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="SERVICE_ACCOUNT_CREDENTIALS_FILE"
|
||||
REPOSITORY_VALUE="SERVICE_ACCOUNT_CREDENTIALS_FILE"
|
||||
FIELD="FILE"
|
||||
NUM_ROW="10"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="AUTH_MODE == 'SERVICEACCOUNT'"
|
||||
GROUP="AUTHENTICATION"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="CLIENT_ID"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="10"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="AUTH_MODE == 'OAUTH'"
|
||||
GROUP="AUTHENTICATION"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER
|
||||
NAME="CLIENT_SECRET"
|
||||
FIELD="PASSWORD"
|
||||
NUM_ROW="20"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="AUTH_MODE == 'OAUTH'"
|
||||
GROUP="AUTHENTICATION"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER
|
||||
NAME="AUTHORIZATION_CODE"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="30"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="AUTH_MODE == 'OAUTH'"
|
||||
GROUP="AUTHENTICATION"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER
|
||||
NAME="PROJECT_ID"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="40"
|
||||
REQUIRED="true"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="DATASET"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="49"
|
||||
REQUIRED="true"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER
|
||||
NAME="TABLE"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="50"
|
||||
REQUIRED="true"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="CREATE_TABLE_IF_NOT_EXIST" FIELD="CHECK" NUM_ROW="50" REQUIRED="true">
|
||||
<DEFAULT>true</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER
|
||||
NAME="ACTION_ON_DATA"
|
||||
FIELD="CLOSED_LIST"
|
||||
NUM_ROW="51"
|
||||
REQUIRED="true"
|
||||
>
|
||||
<ITEMS DEFAULT="TRUNCATE">
|
||||
<ITEM NAME="TRUNCATE" VALUE="TRUNCATE" />
|
||||
<ITEM NAME="APPEND" VALUE="APPEND" />
|
||||
<ITEM NAME="EMPTY" VALUE="EMPTY" />
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="BULK_FILE_ALREADY_EXIST" FIELD="CHECK" NUM_ROW="59" REQUIRED="true" GROUP="GS_CONF">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="GS_ACCESS_KEY" FIELD="TEXT" NUM_ROW="60" REQUIRED="true" GROUP="GS_CONF" SHOW_IF="BULK_FILE_ALREADY_EXIST=='false'">
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="GS_SECRET_KEY" FIELD="PASSWORD" NUM_ROW="61" REQUIRED="true" GROUP="GS_CONF" SHOW_IF="BULK_FILE_ALREADY_EXIST=='false'">
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="GS_LOCAL_FILE" FIELD="FILE" NUM_ROW="62" REQUIRED="true" GROUP="GS_CONF" SHOW_IF="BULK_FILE_ALREADY_EXIST=='false'">
|
||||
<DEFAULT>""</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>
|
||||
<PARAMETER
|
||||
NAME="GS_FILE"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="70"
|
||||
REQUIRED="true"
|
||||
GROUP="GS_CONF"
|
||||
>
|
||||
<DEFAULT>"gs://"</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER
|
||||
NAME="GS_FILE_HEADER"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="71"
|
||||
REQUIRED="true"
|
||||
GROUP="GS_CONF"
|
||||
>
|
||||
<DEFAULT>0</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="DIE_ON_ERROR" FIELD="CHECK" NUM_ROW="80" REQUIRED="true">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
</PARAMETERS>
|
||||
<ADVANCED_PARAMETERS>
|
||||
<PARAMETER NAME="TOKEN_NAME" FIELD="FILE" NUM_ROW="10"
|
||||
REQUIRED="true" SHOW_IF="AUTH_MODE == 'OAUTH'">
|
||||
<DEFAULT>"__COMP_DEFAULT_FILE_DIR__/token.properties"</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="SET_FIELD_DELIMITER" FIELD="CHECK" REQUIRED="true" NUM_ROW="20" >
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="FIELD_DELIMITER" FIELD="TEXT" REQUIRED="true" NUM_ROW="20"
|
||||
SHOW_IF="(SET_FIELD_DELIMITER == 'true')">
|
||||
<DEFAULT>","</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="DROP" FIELD="CHECK" REQUIRED="true" NUM_ROW="25" SHOW_IF="AUTH_MODE == 'SERVICEACCOUNT'">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="ENCODING" FIELD="ENCODING_TYPE" NUM_ROW="30"
|
||||
REQUIRED="true" REPOSITORY_VALUE="ENCODING">
|
||||
<DEFAULT>"ISO-8859-15"</DEFAULT>
|
||||
</PARAMETER>
|
||||
</ADVANCED_PARAMETERS>
|
||||
<CODEGENERATION>
|
||||
<IMPORTS>
|
||||
<IMPORT NAME="google-api-client-1.19.0.jar" MODULE="google-api-client-1.19.0.jar" MVN="mvn:org.talend.libraries/google-api-client-1.19.0/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.google/lib/google-api-client-1.19.0.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="google-api-services-oauth2-v2-rev78-1.19.0.jar" MODULE="google-api-services-oauth2-v2-rev78-1.19.0.jar" MVN="mvn:org.talend.libraries/google-api-services-oauth2-v2-rev78-1.19.0/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.google/lib/google-api-services-oauth2-v2-rev78-1.19.0.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="google-api-services-bigquery-v2-rev391-1.21.0.jar" MODULE="google-api-services-bigquery-v2-rev391-1.21.0.jar" MVN="mvn:org.talend.libraries/google-api-services-bigquery-v2-rev391-1.21.0/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.google/lib/google-api-services-bigquery-v2-rev391-1.21.0.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="google-http-client-1.19.0.jar" MODULE="google-http-client-1.19.0.jar" MVN="mvn:org.talend.libraries/google-http-client-1.19.0/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.google/lib/google-http-client-1.19.0.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="google-oauth-client-1.19.0.jar" MODULE="google-oauth-client-1.19.0.jar" MVN="mvn:org.talend.libraries/google-oauth-client-1.19.0/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.google/lib/google-oauth-client-1.19.0.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="google-http-client-jackson2-1.19.0.jar" MODULE="google-http-client-jackson2-1.19.0.jar" MVN="mvn:org.talend.libraries/google-http-client-jackson2-1.19.0/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.google/lib/google-http-client-jackson2-1.19.0.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="guava-jdk5-13.0.jar" MODULE="guava-jdk5-13.0.jar" MVN="mvn:org.talend.libraries/guava-jdk5-13.0/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.guava/lib/guava-jdk5-13.0.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="jackson-core-2.9.5.jar" MODULE="jackson-core-2.9.5.jar" MVN="mvn:com.fasterxml.jackson.core/jackson-core/2.9.5" 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.1.1" MODULE="commons-logging-1.1.1.jar" MVN="mvn:org.talend.libraries/commons-logging-1.1.1/6.0.0" UrlPath="platform:/base/plugins/org.apache.commons.logging_1.1.1.v201101211721.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="httpclient-4.5.5" MODULE="httpclient-4.5.5.jar" MVN="mvn:org.apache.httpcomponents/httpclient/4.5.5" REQUIRED="true" />
|
||||
<IMPORT NAME="httpcore-4.4.9" MODULE="httpcore-4.4.9.jar" MVN="mvn:org.apache.httpcomponents/httpcore/4.4.9" REQUIRED="true" />
|
||||
<IMPORT NAME="commons-codec-1.4" MODULE="commons-codec-1.4.jar" MVN="mvn:commons-codec/commons-codec/1.4" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.4.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="google-cloud-bigquery-1.32.0.jar" MODULE="google-cloud-bigquery-1.32.0.jar" MVN="mvn:com.google.cloud/google-cloud-bigquery/1.32.0" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="google-http-client-jackson-1.23.0.jar" MODULE="google-http-client-jackson-1.23.0.jar" MVN="mvn:com.google.http-client/google-http-client-jackson/1.23.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.9.1.jar" MODULE="google-auth-library-credentials-0.9.1.jar" MVN="mvn:com.google.auth/google-auth-library-credentials/0.9.1" 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.11.jar" MODULE="jackson-core-asl-1.9.11.jar" MVN="mvn:org.codehaus.jackson/jackson-core-asl/1.9.11" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="google-auth-library-oauth2-http-0.9.1.jar" MODULE="google-auth-library-oauth2-http-0.9.1.jar" MVN="mvn:com.google.auth/google-auth-library-oauth2-http/0.9.1" REQUIRED_IF="AUTH_MODE == 'SERVICEACCOUNT'" />
|
||||
<IMPORT NAME="google-cloud-core-1.32.0.jar" MODULE="google-cloud-core-1.32.0.jar" MVN="mvn:com.google.cloud/google-cloud-core/1.32.0" 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="guava-20.0.jar" MODULE="guava-20.0.jar" MVN="mvn:com.google.guava/guava/20.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.23.0.jar" MODULE="google-http-client-appengine-1.23.0.jar" MVN="mvn:com.google.http-client/google-http-client-appengine/1.23.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'" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
<RETURNS>
|
||||
</RETURNS>
|
||||
</COMPONENT>
|
||||
@@ -62,11 +62,12 @@ class BigQueryUtil_<%=cid%> {
|
||||
com.google.api.services.bigquery.model.JobConfigurationQuery queryConfig = new com.google.api.services.bigquery.model.JobConfigurationQuery();
|
||||
queryConfig.setQuery(query);
|
||||
queryConfig.setUseLegacySql(useLegacySql);
|
||||
String location = getLocation(queryConfig);
|
||||
if(useLargeResult){
|
||||
this.useLargeResult = true;
|
||||
tempDataset = genTempName("dataset");
|
||||
tempTable = genTempName("table");
|
||||
createDataset(getLocation(queryConfig));
|
||||
createDataset(location);
|
||||
queryConfig.setAllowLargeResults(true);
|
||||
queryConfig.setDestinationTable(new com.google.api.services.bigquery.model.TableReference()
|
||||
.setProjectId(projectId)
|
||||
@@ -131,7 +132,7 @@ class BigQueryUtil_<%=cid%> {
|
||||
%>
|
||||
// wait for query execution
|
||||
while (true) {
|
||||
com.google.api.services.bigquery.model.Job pollJob = bigqueryclient.jobs().get(projectId, jobId.getJobId()).execute();
|
||||
com.google.api.services.bigquery.model.Job pollJob = bigqueryclient.jobs().get(projectId, jobId.getJobId()).setLocation(location).execute();
|
||||
com.google.api.services.bigquery.model.JobStatus status = pollJob.getStatus();
|
||||
if (status.getState().equals("DONE")) {
|
||||
com.google.api.services.bigquery.model.ErrorProto errorProto = status.getErrorResult();
|
||||
|
||||
@@ -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
|
||||
@@ -28,10 +28,11 @@
|
||||
String authorizationCode = ElementParameterParser.getValue(node,"__AUTHORIZATION_CODE__");
|
||||
String query = ElementParameterParser.getValue(node,"__QUERY__");
|
||||
boolean useLegacySql = ElementParameterParser.getBooleanValue(node,"__USE_LEGACY_SQL__");
|
||||
|
||||
String resultSizeType = ElementParameterParser.getValue(node,"__RESULT_SIZE__");
|
||||
|
||||
query = query.replaceAll("\n"," ");
|
||||
query = query.replaceAll("\r"," ");
|
||||
|
||||
|
||||
String tokenFile = ElementParameterParser.getValue(node,"__TOKEN_NAME__");
|
||||
boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
|
||||
if (authMode.equals("OAUTH")) {
|
||||
@@ -40,22 +41,22 @@
|
||||
<%
|
||||
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(
|
||||
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;
|
||||
@@ -68,7 +69,7 @@
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
|
||||
// Attempt to load existing refresh token
|
||||
String tokenFile_<%=cid %> = <%=tokenFile%>;
|
||||
java.util.Properties properties_<%=cid%> = new java.util.Properties();
|
||||
@@ -94,7 +95,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.
|
||||
@@ -103,7 +104,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){
|
||||
@@ -125,7 +126,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();
|
||||
|
||||
|
||||
System.out
|
||||
.println("Paste this URL into a web browser to authorize BigQuery Access:\n"
|
||||
+ authorizeUrl_<%=cid%>);
|
||||
@@ -155,7 +156,7 @@
|
||||
}
|
||||
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);
|
||||
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
@@ -171,17 +172,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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
<%
|
||||
String resultSizeType = ElementParameterParser.getValue(node,"__RESULT_SIZE__");
|
||||
%>
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/tBigQueryInput/BigQueryInputQueryHelper.javajet"%>
|
||||
|
||||
|
||||
<%@ include file="@{org.talend.designer.components.localprovider}/components/tBigQueryInput/BigQueryInputQueryHelper.javajet"%>
|
||||
|
||||
// Start a Query Job
|
||||
String querySql_<%=cid %> = <%=query %>;
|
||||
System.out.format("Running Query : %s\n", querySql_<%=cid %>);
|
||||
@@ -192,18 +189,17 @@
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
|
||||
BigQueryUtil_<%=cid%> bigQueryUtil_<%=cid%> = new BigQueryUtil_<%=cid%>(PROJECT_ID_<%=cid%>, bigqueryclient_<%=cid%>, tokenFile_<%=cid%>);
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
log.info("<%=cid%> - Try <%="LARGE".equals(resultSizeType) ? "with" : "without"%> allow large results flag");
|
||||
log.info("<%=cid%> - Try <%="LARGE".equals(resultSizeType) ? "with" : "without"%> the allowLargeResults flag");
|
||||
<%
|
||||
}
|
||||
%>
|
||||
com.google.api.services.bigquery.model.Job insert_<%=cid %> = bigQueryUtil_<%=cid%>.executeQuery(querySql_<%=cid%>, <%="LARGE".equals(resultSizeType) ? true : false%>, <%=useLegacySql%>);
|
||||
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
@@ -221,15 +217,30 @@
|
||||
credentials_<%=cid%> = com.google.auth.oauth2.ServiceAccountCredentials.fromStream(credentialsStream_<%=cid%>);
|
||||
}
|
||||
|
||||
String query_<%=cid%> = <%=query%>;
|
||||
String dataset = query_<%=cid%>.substring(query_<%=cid%>.indexOf("from") + 4, query_<%=cid%>.indexOf(".")).trim();
|
||||
String temp_table = "temp_" + dataset + java.util.UUID.randomUUID().toString().replaceAll("-", "")
|
||||
+ "<%=cid%>".toLowerCase().replaceAll("[^a-z0-9]", "0").replaceAll("^[^a-z]", "a")
|
||||
+ Integer.toHexString(java.util.concurrent.ThreadLocalRandom.current().nextInt());
|
||||
|
||||
com.google.cloud.bigquery.BigQuery bigquery_<%=cid%> = com.google.cloud.bigquery.BigQueryOptions.newBuilder()
|
||||
.setCredentials(credentials_<%=cid%>)
|
||||
.setProjectId(<%=projectId%>)
|
||||
.build()
|
||||
.getService();
|
||||
|
||||
com.google.cloud.bigquery.QueryJobConfiguration queryConfiguration_<%=cid%> = com.google.cloud.bigquery.QueryJobConfiguration.newBuilder(<%=query%>).setUseLegacySql(<%=useLegacySql%>).build();
|
||||
com.google.cloud.bigquery.JobId jobId_tBigQueryInput_1 = com.google.cloud.bigquery.JobId.of(java.util.UUID.randomUUID().toString());
|
||||
com.google.cloud.bigquery.Job job_<%=cid%> = bigquery_<%=cid%>.create(com.google.cloud.bigquery.JobInfo.newBuilder(queryConfiguration_<%=cid%>).setJobId(jobId_<%=cid%>).build());
|
||||
|
||||
com.google.cloud.bigquery.QueryJobConfiguration.Builder queryConfiguration_<%=cid%> = com.google.cloud.bigquery.QueryJobConfiguration.newBuilder(<%=query%>).setUseLegacySql(<%=useLegacySql%>);
|
||||
|
||||
<%
|
||||
if (resultSizeType.equals("LARGE") || resultSizeType.equals("AUTO")) {
|
||||
%>
|
||||
queryConfiguration_<%=cid%>.setDestinationTable(com.google.cloud.bigquery.TableId.of(dataset, temp_table)).setAllowLargeResults(true);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
com.google.cloud.bigquery.JobId jobId_<%=cid%> = com.google.cloud.bigquery.JobId.of(java.util.UUID.randomUUID().toString());
|
||||
com.google.cloud.bigquery.Job job_<%=cid%> = bigquery_<%=cid%>.create(com.google.cloud.bigquery.JobInfo.newBuilder(queryConfiguration_<%=cid%>.build()).setJobId(jobId_<%=cid%>).build());
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
@@ -245,7 +256,6 @@
|
||||
} else if (job_<%=cid%>.getStatus().getError() != null) {
|
||||
throw new RuntimeException(job_<%=cid%>.getStatus().getError().toString());
|
||||
}
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
@@ -253,16 +263,14 @@
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
com.google.cloud.bigquery.TableResult result_<%=cid%> = job_<%=cid%>.getQueryResults();
|
||||
|
||||
long nb_line_<%=cid%> = 0;
|
||||
<%
|
||||
} else {
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\" or \"OAUTH\", but it is " + authMode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (authMode.equals("OAUTH")) {
|
||||
%>
|
||||
while (true) {
|
||||
@@ -274,14 +282,13 @@
|
||||
insert_<%=cid %>.getConfiguration().getQuery()
|
||||
.getDestinationTable().getTableId())
|
||||
.setPageToken(pageToken_<%=cid%>).execute();
|
||||
|
||||
List<com.google.api.services.bigquery.model.TableRow> rows_<%=cid %> = dataList_<%=cid %>.getRows();
|
||||
|
||||
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;
|
||||
@@ -311,16 +318,14 @@
|
||||
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();
|
||||
String patternValue = column.getPattern() == null || column.getPattern().trim().length() == 0 ? null : column.getPattern();
|
||||
if (authMode.equals("OAUTH")) {
|
||||
%>
|
||||
value_<%=cid%> = field_<%=cid %>.get(<%=i%>).getV();
|
||||
@@ -334,27 +339,34 @@
|
||||
}
|
||||
%>
|
||||
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) {
|
||||
%>
|
||||
<%=connName%>.<%=columnName%> = ParserUtils.parseTo_Date(value_<%=cid%>.toString());
|
||||
<%
|
||||
} else if(advancedSeparator && JavaTypesManager.isNumberType(javaType)) {
|
||||
<%
|
||||
} else if(javaType == JavaTypesManager.DATE) {
|
||||
%>
|
||||
|
||||
if (value_<%=cid%>.toString().contains("-")) {
|
||||
<%=connName%>.<%=columnName%> = ParserUtils.parseTo_Date(value_<%=cid%>.toString(),<%=patternValue%>);
|
||||
} else {
|
||||
<%=connName%>.<%=columnName%> = ParserUtils.parseTo_Date(value_<%=cid%>.toString());
|
||||
}
|
||||
|
||||
<%
|
||||
} 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,311 +1,310 @@
|
||||
<COMPONENT>
|
||||
<HEADER
|
||||
PLATEFORM="ALL"
|
||||
SERIAL=""
|
||||
VERSION="0.102"
|
||||
STATUS="ALPHA"
|
||||
|
||||
COMPATIBILITY="ALL"
|
||||
AUTHOR="Talend"
|
||||
RELEASE_DATE="20050320A"
|
||||
STARTABLE="false"
|
||||
PARTITIONING="NONE"
|
||||
>
|
||||
<SIGNATURE/>
|
||||
</HEADER>
|
||||
|
||||
<FAMILIES>
|
||||
<FAMILY>Big Data/Google BigQuery</FAMILY>
|
||||
</FAMILIES>
|
||||
|
||||
<DOCUMENTATION>
|
||||
<URL/>
|
||||
</DOCUMENTATION>
|
||||
|
||||
<CONNECTORS>
|
||||
<CONNECTOR CTYPE="FLOW" MAX_INPUT="1" MAX_OUTPUT="0"/>
|
||||
<CONNECTOR CTYPE="ITERATE" MAX_OUTPUT="1" MAX_INPUT="1"/>
|
||||
<CONNECTOR CTYPE="SUBJOB_OK" MAX_INPUT="1" />
|
||||
<CONNECTOR CTYPE="SUBJOB_ERROR" MAX_INPUT="1" />
|
||||
<CONNECTOR CTYPE="COMPONENT_OK"/>
|
||||
<CONNECTOR CTYPE="COMPONENT_ERROR"/>
|
||||
<CONNECTOR CTYPE="RUN_IF"/>
|
||||
</CONNECTORS>
|
||||
|
||||
<PARAMETERS>
|
||||
<PARAMETER NAME="PROPERTY" FIELD="PROPERTY_TYPE" SHOW="true" NUM_ROW="10" REPOSITORY_VALUE="DELIMITED" />
|
||||
|
||||
<PARAMETER NAME="FILENAME" FIELD="FILE" NUM_ROW="11" REQUIRED="true" REPOSITORY_VALUE="FILE_PATH">
|
||||
<DEFAULT>"__COMP_DEFAULT_FILE_DIR__/biquery_bulk.txt"</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="APPEND" FIELD="CHECK" REQUIRED="true" NUM_ROW="12" REPOSITORY_VALUE="APPEND">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<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" />
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="SERVICE_ACCOUNT_CREDENTIALS_FILE"
|
||||
REPOSITORY_VALUE="SERVICE_ACCOUNT_CREDENTIALS_FILE"
|
||||
FIELD="FILE"
|
||||
NUM_ROW="18"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="AUTH_MODE == 'SERVICEACCOUNT'"
|
||||
GROUP="AUTHENTICATION"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="CLIENT_ID"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="20"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="AUTH_MODE == 'OAUTH'"
|
||||
GROUP="AUTHENTICATION"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="CLIENT_SECRET"
|
||||
FIELD="PASSWORD"
|
||||
NUM_ROW="21"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="AUTH_MODE == 'OAUTH'"
|
||||
GROUP="AUTHENTICATION"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="AUTHORIZATION_CODE"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="30"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="AUTH_MODE == 'OAUTH'"
|
||||
GROUP="AUTHENTICATION"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="PROJECT_ID"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="40"
|
||||
REQUIRED="true"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="DATASET"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="49"
|
||||
REQUIRED="true"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER
|
||||
NAME="TABLE"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="50"
|
||||
REQUIRED="true"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="CREATE_TABLE_IF_NOT_EXIST" FIELD="CHECK" NUM_ROW="50" REQUIRED="true" SHOW_IF="AUTH_MODE == 'OAUTH'">
|
||||
<DEFAULT>true</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="ACTION_ON_DATA"
|
||||
SHOW_IF="AUTH_MODE == 'OAUTH'"
|
||||
FIELD="CLOSED_LIST"
|
||||
NUM_ROW="51"
|
||||
REQUIRED="true"
|
||||
>
|
||||
<ITEMS DEFAULT="TRUNCATE">
|
||||
<ITEM NAME="TRUNCATE" VALUE="TRUNCATE" />
|
||||
<ITEM NAME="APPEND" VALUE="APPEND" />
|
||||
<ITEM NAME="EMPTY" VALUE="EMPTY" />
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="BULK_FILE_ALREADY_EXIST" FIELD="CHECK" NUM_ROW="59" REQUIRED="true" SHOW="false">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="GS_ACCESS_KEY" FIELD="TEXT" NUM_ROW="60" REQUIRED="true" GROUP="GS_CONF" SHOW_IF="BULK_FILE_ALREADY_EXIST=='false'">
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="GS_SECRET_KEY" FIELD="PASSWORD" NUM_ROW="61" REQUIRED="true" GROUP="GS_CONF" SHOW_IF="BULK_FILE_ALREADY_EXIST=='false'">
|
||||
<DEFAULT>""</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>
|
||||
<PARAMETER
|
||||
NAME="GS_FILE"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="70"
|
||||
REQUIRED="true"
|
||||
GROUP="GS_CONF"
|
||||
>
|
||||
<DEFAULT>"gs://"</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER
|
||||
NAME="GS_FILE_HEADER"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="71"
|
||||
REQUIRED="true"
|
||||
GROUP="GS_CONF"
|
||||
>
|
||||
<DEFAULT>0</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="DIE_ON_ERROR" FIELD="CHECK" NUM_ROW="80" REQUIRED="true">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
</PARAMETERS>
|
||||
|
||||
<ADVANCED_PARAMETERS>
|
||||
<PARAMETER NAME="TOKEN_NAME" FIELD="FILE" NUM_ROW="10"
|
||||
REQUIRED="true" SHOW_IF="AUTH_MODE == 'OAUTH'">
|
||||
<DEFAULT>"__COMP_DEFAULT_FILE_DIR__/token.properties"</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="SET_FIELD_DELIMITER" FIELD="CHECK" REQUIRED="true" NUM_ROW="20" SHOW="false">
|
||||
<DEFAULT>true</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="FIELD_DELIMITER" FIELD="TEXT" REQUIRED="true" NUM_ROW="20"
|
||||
SHOW="false">
|
||||
<DEFAULT>","</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="ROWSEPARATOR" FIELD="TEXT" REQUIRED="true" NUM_ROW="30" REPOSITORY_VALUE="ROW_SEPARATOR" SHOW="false">
|
||||
<DEFAULT>"\n"</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="FIELDSEPARATOR" FIELD="TEXT" REQUIRED="true" NUM_ROW="30" REPOSITORY_VALUE="FIELD_SEPARATOR">
|
||||
<DEFAULT>","</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="DROP" FIELD="CHECK" REQUIRED="true" NUM_ROW="33" SHOW_IF="AUTH_MODE == 'SERVICEACCOUNT'">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="ESCAPE_CHAR" FIELD="TEXT" REQUIRED="true" NUM_ROW="30" MAX_LENGTH="1" REPOSITORY_VALUE="ESCAPE_CHAR" SHOW="false">
|
||||
<DEFAULT>"\\"</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="TEXT_ENCLOSURE" FIELD="TEXT" REQUIRED="true" NUM_ROW="30" MAX_LENGTH="1" REPOSITORY_VALUE="TEXT_ENCLOSURE" SHOW="false">
|
||||
<DEFAULT>"\""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="CREATE" FIELD="CHECK" REQUIRED="true" NUM_ROW="40">
|
||||
<DEFAULT>true</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="FLUSHONROW" FIELD="CHECK" REQUIRED="true" NUM_ROW="45">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="FLUSHONROW_NUM"
|
||||
FIELD="TEXT"
|
||||
REQUIRED="true"
|
||||
NUM_ROW="45"
|
||||
SHOW_IF="FLUSHONROW == 'true'"
|
||||
>
|
||||
<DEFAULT>1</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER
|
||||
NAME="RECORDS_CONTAIN_NULL_VALUE"
|
||||
FIELD="CHECK"
|
||||
SHOW="false"
|
||||
NUM_ROW="50"
|
||||
>
|
||||
<DEFAULT>true</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER
|
||||
NAME="CHECK_DISK_SPACE"
|
||||
FIELD="CHECK"
|
||||
SHOW="true"
|
||||
NUM_ROW="50"
|
||||
>
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="ENCODING" FIELD="ENCODING_TYPE" NUM_ROW="60" REQUIRED="true" REPOSITORY_VALUE="ENCODING">
|
||||
<DEFAULT>"ISO-8859-15"</DEFAULT>
|
||||
</PARAMETER>
|
||||
</ADVANCED_PARAMETERS>
|
||||
|
||||
<CODEGENERATION>
|
||||
<TEMPLATES INPUT="tBQOB" OUTPUT="tBQBE">
|
||||
|
||||
<TEMPLATE NAME="tBQOB" COMPONENT="tBigQueryOutputBulk">
|
||||
<LINK_TO NAME="tBQBE" CTYPE="ROWS_END"/>
|
||||
</TEMPLATE>
|
||||
|
||||
<TEMPLATE NAME="tBQBE" COMPONENT="tBigQueryBulkExec"/>
|
||||
|
||||
<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.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" />
|
||||
<TEMPLATE_PARAM SOURCE="self.AUTHORIZATION_CODE" TARGET="tBQBE.AUTHORIZATION_CODE"/>
|
||||
<TEMPLATE_PARAM SOURCE="self.DATASET" TARGET="tBQBE.DATASET" />
|
||||
<TEMPLATE_PARAM SOURCE="self.TABLE" TARGET="tBQBE.TABLE" />
|
||||
<TEMPLATE_PARAM SOURCE="self.CREATE_TABLE_IF_NOT_EXIST" TARGET="tBQBE.CREATE_TABLE_IF_NOT_EXIST" />
|
||||
<TEMPLATE_PARAM SOURCE="self.ACTION_ON_DATA" TARGET="tBQBE.ACTION_ON_DATA" />
|
||||
<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" />
|
||||
<TEMPLATE_PARAM SOURCE="self.GS_FILE" TARGET="tBQBE.GS_FILE" />
|
||||
<TEMPLATE_PARAM SOURCE="self.GS_FILE_HEADER" TARGET="tBQBE.GS_FILE_HEADER" />
|
||||
<TEMPLATE_PARAM SOURCE="self.TOKEN_NAME" TARGET="tBQBE.TOKEN_NAME" />
|
||||
<TEMPLATE_PARAM SOURCE="self.SET_FIELD_DELIMITER" TARGET="tBQBE.SET_FIELD_DELIMITER" />
|
||||
<TEMPLATE_PARAM SOURCE="self.FIELDSEPARATOR" TARGET="tBQBE.FIELD_DELIMITER" />
|
||||
<TEMPLATE_PARAM SOURCE="self.BULK_ALREADY_EXIST" TARGET="tBQBE.BULK_ALREADY_EXIST" />
|
||||
<TEMPLATE_PARAM SOURCE="self.DIE_ON_ERROR" TARGET="tBQBE.DIE_ON_ERROR" />
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.FILENAME" TARGET="tBQOB.FILENAME" />
|
||||
<TEMPLATE_PARAM SOURCE="self.FILENAME" TARGET="tBQBE.GS_LOCAL_FILE" />
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.ROWSEPARATOR" TARGET="tBQOB.ROWSEPARATOR" />
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.FIELDSEPARATOR" TARGET="tBQOB.FIELDSEPARATOR" />
|
||||
<TEMPLATE_PARAM SOURCE="self.DROP" TARGET="tBQBE.DROP" />
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.ESCAPE_CHAR" TARGET="tBQOB.ESCAPE_CHAR" />
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.TEXT_ENCLOSURE" TARGET="tBQOB.TEXT_ENCLOSURE" />
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.SCHEMA" TARGET="tBQOB.SCHEMA" />
|
||||
<TEMPLATE_PARAM SOURCE="self.SCHEMA" TARGET="tBQBE.SCHEMA" />
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.ENCODING" TARGET="tBQOB.ENCODING" />
|
||||
<TEMPLATE_PARAM SOURCE="self.ENCODING" TARGET="tBQBE.ENCODING" />
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.RECORDS_CONTAIN_NULL_VALUE" TARGET="tBQOB.RECORDS_CONTAIN_NULL_VALUE" />
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.APPEND" TARGET="tBQOB.APPEND" />
|
||||
<TEMPLATE_PARAM SOURCE="self.CREATE" TARGET="tBQOB.CREATE" />
|
||||
<TEMPLATE_PARAM SOURCE="self.FLUSHONROW" TARGET="tBQOB.FLUSHONROW" />
|
||||
<TEMPLATE_PARAM SOURCE="self.FLUSHONROW_NUM" TARGET="tBQOB.FLUSHONROW_NUM" />
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.DATA_ACTION" TARGET="tBQBE.DATA_ACTION" />
|
||||
</TEMPLATES>
|
||||
</CODEGENERATION>
|
||||
<RETURNS/>
|
||||
</COMPONENT>
|
||||
<COMPONENT>
|
||||
<HEADER
|
||||
PLATEFORM="ALL"
|
||||
SERIAL=""
|
||||
VERSION="0.102"
|
||||
STATUS="ALPHA"
|
||||
|
||||
COMPATIBILITY="ALL"
|
||||
AUTHOR="Talend"
|
||||
RELEASE_DATE="20050320A"
|
||||
STARTABLE="false"
|
||||
PARTITIONING="NONE"
|
||||
>
|
||||
<SIGNATURE/>
|
||||
</HEADER>
|
||||
|
||||
<FAMILIES>
|
||||
<FAMILY>Big Data/Google BigQuery</FAMILY>
|
||||
</FAMILIES>
|
||||
|
||||
<DOCUMENTATION>
|
||||
<URL/>
|
||||
</DOCUMENTATION>
|
||||
|
||||
<CONNECTORS>
|
||||
<CONNECTOR CTYPE="FLOW" MAX_INPUT="1" MAX_OUTPUT="0"/>
|
||||
<CONNECTOR CTYPE="ITERATE" MAX_OUTPUT="1" MAX_INPUT="1"/>
|
||||
<CONNECTOR CTYPE="SUBJOB_OK" MAX_INPUT="1" />
|
||||
<CONNECTOR CTYPE="SUBJOB_ERROR" MAX_INPUT="1" />
|
||||
<CONNECTOR CTYPE="COMPONENT_OK"/>
|
||||
<CONNECTOR CTYPE="COMPONENT_ERROR"/>
|
||||
<CONNECTOR CTYPE="RUN_IF"/>
|
||||
</CONNECTORS>
|
||||
|
||||
<PARAMETERS>
|
||||
<PARAMETER NAME="PROPERTY" FIELD="PROPERTY_TYPE" SHOW="true" NUM_ROW="10" REPOSITORY_VALUE="DELIMITED" />
|
||||
|
||||
<PARAMETER NAME="FILENAME" FIELD="FILE" NUM_ROW="11" REQUIRED="true" REPOSITORY_VALUE="FILE_PATH">
|
||||
<DEFAULT>"__COMP_DEFAULT_FILE_DIR__/biquery_bulk.txt"</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="APPEND" FIELD="CHECK" REQUIRED="true" NUM_ROW="12" REPOSITORY_VALUE="APPEND">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<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" />
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="SERVICE_ACCOUNT_CREDENTIALS_FILE"
|
||||
REPOSITORY_VALUE="SERVICE_ACCOUNT_CREDENTIALS_FILE"
|
||||
FIELD="FILE"
|
||||
NUM_ROW="18"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="AUTH_MODE == 'SERVICEACCOUNT'"
|
||||
GROUP="AUTHENTICATION"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="CLIENT_ID"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="20"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="AUTH_MODE == 'OAUTH'"
|
||||
GROUP="AUTHENTICATION"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="CLIENT_SECRET"
|
||||
FIELD="PASSWORD"
|
||||
NUM_ROW="21"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="AUTH_MODE == 'OAUTH'"
|
||||
GROUP="AUTHENTICATION"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="AUTHORIZATION_CODE"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="30"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="AUTH_MODE == 'OAUTH'"
|
||||
GROUP="AUTHENTICATION"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="PROJECT_ID"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="40"
|
||||
REQUIRED="true"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="DATASET"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="49"
|
||||
REQUIRED="true"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER
|
||||
NAME="TABLE"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="50"
|
||||
REQUIRED="true"
|
||||
>
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="CREATE_TABLE_IF_NOT_EXIST" FIELD="CHECK" NUM_ROW="50" REQUIRED="true">
|
||||
<DEFAULT>true</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="ACTION_ON_DATA"
|
||||
FIELD="CLOSED_LIST"
|
||||
NUM_ROW="51"
|
||||
REQUIRED="true"
|
||||
>
|
||||
<ITEMS DEFAULT="TRUNCATE">
|
||||
<ITEM NAME="TRUNCATE" VALUE="TRUNCATE" />
|
||||
<ITEM NAME="APPEND" VALUE="APPEND" />
|
||||
<ITEM NAME="EMPTY" VALUE="EMPTY" />
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="BULK_FILE_ALREADY_EXIST" FIELD="CHECK" NUM_ROW="59" REQUIRED="true" SHOW="false">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="GS_ACCESS_KEY" FIELD="TEXT" NUM_ROW="60" REQUIRED="true" GROUP="GS_CONF" SHOW_IF="BULK_FILE_ALREADY_EXIST=='false'">
|
||||
<DEFAULT>""</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="GS_SECRET_KEY" FIELD="PASSWORD" NUM_ROW="61" REQUIRED="true" GROUP="GS_CONF" SHOW_IF="BULK_FILE_ALREADY_EXIST=='false'">
|
||||
<DEFAULT>""</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>
|
||||
<PARAMETER
|
||||
NAME="GS_FILE"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="70"
|
||||
REQUIRED="true"
|
||||
GROUP="GS_CONF"
|
||||
>
|
||||
<DEFAULT>"gs://"</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER
|
||||
NAME="GS_FILE_HEADER"
|
||||
FIELD="TEXT"
|
||||
NUM_ROW="71"
|
||||
REQUIRED="true"
|
||||
GROUP="GS_CONF"
|
||||
>
|
||||
<DEFAULT>0</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="DIE_ON_ERROR" FIELD="CHECK" NUM_ROW="80" REQUIRED="true">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
</PARAMETERS>
|
||||
|
||||
<ADVANCED_PARAMETERS>
|
||||
<PARAMETER NAME="TOKEN_NAME" FIELD="FILE" NUM_ROW="10"
|
||||
REQUIRED="true" SHOW_IF="AUTH_MODE == 'OAUTH'">
|
||||
<DEFAULT>"__COMP_DEFAULT_FILE_DIR__/token.properties"</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="SET_FIELD_DELIMITER" FIELD="CHECK" REQUIRED="true" NUM_ROW="20" SHOW="false">
|
||||
<DEFAULT>true</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="FIELD_DELIMITER" FIELD="TEXT" REQUIRED="true" NUM_ROW="20"
|
||||
SHOW="false">
|
||||
<DEFAULT>","</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="ROWSEPARATOR" FIELD="TEXT" REQUIRED="true" NUM_ROW="30" REPOSITORY_VALUE="ROW_SEPARATOR" SHOW="false">
|
||||
<DEFAULT>"\n"</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="FIELDSEPARATOR" FIELD="TEXT" REQUIRED="true" NUM_ROW="30" REPOSITORY_VALUE="FIELD_SEPARATOR">
|
||||
<DEFAULT>","</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="DROP" FIELD="CHECK" REQUIRED="true" NUM_ROW="33" SHOW_IF="AUTH_MODE == 'SERVICEACCOUNT'">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="ESCAPE_CHAR" FIELD="TEXT" REQUIRED="true" NUM_ROW="30" MAX_LENGTH="1" REPOSITORY_VALUE="ESCAPE_CHAR" SHOW="false">
|
||||
<DEFAULT>"\\"</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="TEXT_ENCLOSURE" FIELD="TEXT" REQUIRED="true" NUM_ROW="30" MAX_LENGTH="1" REPOSITORY_VALUE="TEXT_ENCLOSURE" SHOW="false">
|
||||
<DEFAULT>"\""</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="CREATE" FIELD="CHECK" REQUIRED="true" NUM_ROW="40">
|
||||
<DEFAULT>true</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="FLUSHONROW" FIELD="CHECK" REQUIRED="true" NUM_ROW="45">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER
|
||||
NAME="FLUSHONROW_NUM"
|
||||
FIELD="TEXT"
|
||||
REQUIRED="true"
|
||||
NUM_ROW="45"
|
||||
SHOW_IF="FLUSHONROW == 'true'"
|
||||
>
|
||||
<DEFAULT>1</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER
|
||||
NAME="RECORDS_CONTAIN_NULL_VALUE"
|
||||
FIELD="CHECK"
|
||||
SHOW="false"
|
||||
NUM_ROW="50"
|
||||
>
|
||||
<DEFAULT>true</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER
|
||||
NAME="CHECK_DISK_SPACE"
|
||||
FIELD="CHECK"
|
||||
SHOW="true"
|
||||
NUM_ROW="50"
|
||||
>
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="ENCODING" FIELD="ENCODING_TYPE" NUM_ROW="60" REQUIRED="true" REPOSITORY_VALUE="ENCODING">
|
||||
<DEFAULT>"ISO-8859-15"</DEFAULT>
|
||||
</PARAMETER>
|
||||
</ADVANCED_PARAMETERS>
|
||||
|
||||
<CODEGENERATION>
|
||||
<TEMPLATES INPUT="tBQOB" OUTPUT="tBQBE">
|
||||
|
||||
<TEMPLATE NAME="tBQOB" COMPONENT="tBigQueryOutputBulk">
|
||||
<LINK_TO NAME="tBQBE" CTYPE="ROWS_END"/>
|
||||
</TEMPLATE>
|
||||
|
||||
<TEMPLATE NAME="tBQBE" COMPONENT="tBigQueryBulkExec"/>
|
||||
|
||||
<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.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" />
|
||||
<TEMPLATE_PARAM SOURCE="self.AUTHORIZATION_CODE" TARGET="tBQBE.AUTHORIZATION_CODE"/>
|
||||
<TEMPLATE_PARAM SOURCE="self.DATASET" TARGET="tBQBE.DATASET" />
|
||||
<TEMPLATE_PARAM SOURCE="self.TABLE" TARGET="tBQBE.TABLE" />
|
||||
<TEMPLATE_PARAM SOURCE="self.CREATE_TABLE_IF_NOT_EXIST" TARGET="tBQBE.CREATE_TABLE_IF_NOT_EXIST" />
|
||||
<TEMPLATE_PARAM SOURCE="self.ACTION_ON_DATA" TARGET="tBQBE.ACTION_ON_DATA" />
|
||||
<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" />
|
||||
<TEMPLATE_PARAM SOURCE="self.GS_FILE" TARGET="tBQBE.GS_FILE" />
|
||||
<TEMPLATE_PARAM SOURCE="self.GS_FILE_HEADER" TARGET="tBQBE.GS_FILE_HEADER" />
|
||||
<TEMPLATE_PARAM SOURCE="self.TOKEN_NAME" TARGET="tBQBE.TOKEN_NAME" />
|
||||
<TEMPLATE_PARAM SOURCE="self.SET_FIELD_DELIMITER" TARGET="tBQBE.SET_FIELD_DELIMITER" />
|
||||
<TEMPLATE_PARAM SOURCE="self.FIELDSEPARATOR" TARGET="tBQBE.FIELD_DELIMITER" />
|
||||
<TEMPLATE_PARAM SOURCE="self.BULK_ALREADY_EXIST" TARGET="tBQBE.BULK_ALREADY_EXIST" />
|
||||
<TEMPLATE_PARAM SOURCE="self.DIE_ON_ERROR" TARGET="tBQBE.DIE_ON_ERROR" />
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.FILENAME" TARGET="tBQOB.FILENAME" />
|
||||
<TEMPLATE_PARAM SOURCE="self.FILENAME" TARGET="tBQBE.GS_LOCAL_FILE" />
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.ROWSEPARATOR" TARGET="tBQOB.ROWSEPARATOR" />
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.FIELDSEPARATOR" TARGET="tBQOB.FIELDSEPARATOR" />
|
||||
<TEMPLATE_PARAM SOURCE="self.DROP" TARGET="tBQBE.DROP" />
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.ESCAPE_CHAR" TARGET="tBQOB.ESCAPE_CHAR" />
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.TEXT_ENCLOSURE" TARGET="tBQOB.TEXT_ENCLOSURE" />
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.SCHEMA" TARGET="tBQOB.SCHEMA" />
|
||||
<TEMPLATE_PARAM SOURCE="self.SCHEMA" TARGET="tBQBE.SCHEMA" />
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.ENCODING" TARGET="tBQOB.ENCODING" />
|
||||
<TEMPLATE_PARAM SOURCE="self.ENCODING" TARGET="tBQBE.ENCODING" />
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.RECORDS_CONTAIN_NULL_VALUE" TARGET="tBQOB.RECORDS_CONTAIN_NULL_VALUE" />
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.APPEND" TARGET="tBQOB.APPEND" />
|
||||
<TEMPLATE_PARAM SOURCE="self.CREATE" TARGET="tBQOB.CREATE" />
|
||||
<TEMPLATE_PARAM SOURCE="self.FLUSHONROW" TARGET="tBQOB.FLUSHONROW" />
|
||||
<TEMPLATE_PARAM SOURCE="self.FLUSHONROW_NUM" TARGET="tBQOB.FLUSHONROW_NUM" />
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.DATA_ACTION" TARGET="tBQBE.DATA_ACTION" />
|
||||
</TEMPLATES>
|
||||
</CODEGENERATION>
|
||||
<RETURNS/>
|
||||
</COMPONENT>
|
||||
@@ -43,10 +43,8 @@
|
||||
JavaType javaType = JavaTypesManager.getJavaTypeFromId(column.getTalendType());
|
||||
String pattern = column.getPattern() == null || column.getPattern().trim().length() == 0 ? null : column.getPattern();
|
||||
if(JavaTypesManager.isJavaPrimitiveType( column.getTalendType(), column.isNullable())){
|
||||
%>
|
||||
if(<%=conn.getName() %>.<%=column.getLabel() %> != null) {
|
||||
<%
|
||||
if(javaType == JavaTypesManager.BOOLEAN ){
|
||||
|
||||
if(javaType == JavaTypesManager.BOOLEAN ){
|
||||
%>
|
||||
row_<%=cid%>[<%=i%>] = String.valueOf(
|
||||
true == <%=conn.getName() %>.<%=column.getLabel() %> ?"1":"0"
|
||||
@@ -56,12 +54,8 @@
|
||||
%>
|
||||
row_<%=cid%>[<%=i%>] = String.valueOf(<%=conn.getName() %>.<%=column.getLabel() %>);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
} else {
|
||||
row_<%=cid%>[<%=i%>] = null;
|
||||
}
|
||||
<%
|
||||
}
|
||||
|
||||
}else {
|
||||
%>
|
||||
if(<%=conn.getName() %>.<%=column.getLabel() %> != null){
|
||||
@@ -70,10 +64,24 @@
|
||||
%>
|
||||
row_<%=cid%>[<%=i%>] = <%=conn.getName() %>.<%=column.getLabel() %>;
|
||||
<%
|
||||
}else if(javaType == JavaTypesManager.DATE && pattern != null){
|
||||
%>
|
||||
row_<%=cid%>[<%=i%>] = FormatterUtils.format_Date(<%=conn.getName() %>.<%=column.getLabel() %>, "yyyy-MM-dd HH:mm:ss");
|
||||
}else if(javaType == JavaTypesManager.DATE && pattern == null){
|
||||
%>
|
||||
row_<%=cid%>[<%=i%>] = FormatterUtils.format_Date(<%=conn.getName() %>.<%=column.getLabel() %>, "yyyy-MM-dd");
|
||||
<%
|
||||
}else if(javaType == JavaTypesManager.DATE && pattern != null){
|
||||
if(pattern.length() > 12){
|
||||
%>
|
||||
row_<%=cid%>[<%=i%>] = FormatterUtils.format_Date(<%=conn.getName() %>.<%=column.getLabel() %>, "yyyy-MM-dd HH:mm:ss");
|
||||
<%
|
||||
}else if(pattern.length() == 12 || "\"\"".equals(pattern)) {
|
||||
%>
|
||||
row_<%=cid%>[<%=i%>] = FormatterUtils.format_Date(<%=conn.getName() %>.<%=column.getLabel() %>, "yyyy-MM-dd");
|
||||
<%
|
||||
}else {
|
||||
%>
|
||||
row_<%=cid%>[<%=i%>] = FormatterUtils.format_Date(<%=conn.getName() %>.<%=column.getLabel() %>, <%=pattern%>);
|
||||
<%
|
||||
}
|
||||
}else if(javaType == JavaTypesManager.BYTE_ARRAY){
|
||||
%>
|
||||
row_<%=cid%>[<%=i%>] = java.nio.charset.Charset.forName(<%=encoding %>).decode(java.nio.ByteBuffer.wrap(<%=conn.getName() %>.<%=column.getLabel() %>)).toString();
|
||||
@@ -92,7 +100,7 @@
|
||||
}
|
||||
%>
|
||||
} else {
|
||||
row_<%=cid%>[<%=i%>] = null;
|
||||
row_<%=cid%>[<%=i%>] = "\\N";
|
||||
}
|
||||
<%
|
||||
}
|
||||
|
||||
@@ -152,8 +152,8 @@
|
||||
<IMPORTS>
|
||||
<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_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="commons-logging-1.1.3" MODULE="commons-logging-1.1.3.jar" MVN="mvn:commons-logging/commons-logging/1.1.3" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-logging-1.1.3.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpclient-4.3.6" MODULE="httpclient-4.3.6.jar" MVN="mvn:org.talend.libraries/httpclient-4.3.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpclient-4.3.6.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpcore-4.3.3" MODULE="httpcore-4.3.3.jar" MVN="mvn:org.talend.libraries/httpcore-4.3.3/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpcore-4.3.3.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpclient-4.5.5" MODULE="httpclient-4.5.5.jar" MVN="mvn:org.talend.libraries/httpclient-4.5.5/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpclient-4.5.5.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpcore-4.4.9" MODULE="httpcore-4.4.9.jar" MVN="mvn:org.talend.libraries/httpcore-4.4.9/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpcore-4.4.9.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="commons-codec-1.6" MODULE="commons-codec-1.6.jar" MVN="mvn:org.talend.libraries/commons-codec-1.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
@@ -99,8 +99,8 @@
|
||||
<IMPORTS>
|
||||
<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_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="commons-logging-1.1.3" MODULE="commons-logging-1.1.3.jar" MVN="mvn:commons-logging/commons-logging/1.1.3" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-logging-1.1.3.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpclient-4.3.6" MODULE="httpclient-4.3.6.jar" MVN="mvn:org.talend.libraries/httpclient-4.3.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpclient-4.3.6.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpcore-4.3.3" MODULE="httpcore-4.3.3.jar" MVN="mvn:org.talend.libraries/httpcore-4.3.3/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpcore-4.3.3.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpclient-4.5.5" MODULE="httpclient-4.5.5.jar" MVN="mvn:org.talend.libraries/httpclient-4.5.5/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpclient-4.5.5.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpcore-4.4.9" MODULE="httpcore-4.4.9.jar" MVN="mvn:org.talend.libraries/httpcore-4.4.9/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpcore-4.4.9.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="commons-codec-1.6" MODULE="commons-codec-1.6.jar" MVN="mvn:org.talend.libraries/commons-codec-1.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
@@ -99,8 +99,8 @@
|
||||
<IMPORTS>
|
||||
<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_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="commons-logging-1.1.3" MODULE="commons-logging-1.1.3.jar" MVN="mvn:commons-logging/commons-logging/1.1.3" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-logging-1.1.3.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpclient-4.3.6" MODULE="httpclient-4.3.6.jar" MVN="mvn:org.talend.libraries/httpclient-4.3.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpclient-4.3.6.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpcore-4.3.3" MODULE="httpcore-4.3.3.jar" MVN="mvn:org.talend.libraries/httpcore-4.3.3/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpcore-4.3.3.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpclient-4.5.5" MODULE="httpclient-4.5.5.jar" MVN="mvn:org.talend.libraries/httpclient-4.5.5/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpclient-4.5.5.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpcore-4.4.9" MODULE="httpcore-4.4.9.jar" MVN="mvn:org.talend.libraries/httpcore-4.4.9/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpcore-4.4.9.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="commons-codec-1.6" MODULE="commons-codec-1.6.jar" MVN="mvn:org.talend.libraries/commons-codec-1.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
@@ -102,8 +102,8 @@
|
||||
<IMPORTS>
|
||||
<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_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="commons-logging-1.1.3" MODULE="commons-logging-1.1.3.jar" MVN="mvn:commons-logging/commons-logging/1.1.3" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-logging-1.1.3.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpclient-4.3.6" MODULE="httpclient-4.3.6.jar" MVN="mvn:org.talend.libraries/httpclient-4.3.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpclient-4.3.6.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpcore-4.3.3" MODULE="httpcore-4.3.3.jar" MVN="mvn:org.talend.libraries/httpcore-4.3.3/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpcore-4.3.3.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpclient-4.5.5" MODULE="httpclient-4.5.5.jar" MVN="mvn:org.talend.libraries/httpclient-4.5.5/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpclient-4.5.5.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpcore-4.4.9" MODULE="httpcore-4.4.9.jar" MVN="mvn:org.talend.libraries/httpcore-4.4.9/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpcore-4.4.9.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="commons-codec-1.6" MODULE="commons-codec-1.6.jar" MVN="mvn:org.talend.libraries/commons-codec-1.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
@@ -62,8 +62,8 @@
|
||||
<IMPORTS>
|
||||
<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.1.3" MODULE="commons-logging-1.1.3.jar" MVN="mvn:commons-logging/commons-logging/1.1.3" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-logging-1.1.3.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="httpclient-4.3.6" MODULE="httpclient-4.3.6.jar" MVN="mvn:org.talend.libraries/httpclient-4.3.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpclient-4.3.6.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="httpcore-4.3.3" MODULE="httpcore-4.3.3.jar" MVN="mvn:org.talend.libraries/httpcore-4.3.3/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpcore-4.3.3.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="httpclient-4.5.5" MODULE="httpclient-4.5.5.jar" MVN="mvn:org.talend.libraries/httpclient-4.5.5/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpclient-4.5.5.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="httpcore-4.4.9" MODULE="httpcore-4.4.9.jar" MVN="mvn:org.talend.libraries/httpcore-4.4.9/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpcore-4.4.9.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="commons-codec-1.6" MODULE="commons-codec-1.6.jar" MVN="mvn:org.talend.libraries/commons-codec-1.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar" REQUIRED="true" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
@@ -169,8 +169,8 @@
|
||||
<IMPORTS>
|
||||
<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_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="commons-logging-1.1.3" MODULE="commons-logging-1.1.3.jar" MVN="mvn:commons-logging/commons-logging/1.1.3" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-logging-1.1.3.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpclient-4.3.6" MODULE="httpclient-4.3.6.jar" MVN="mvn:org.talend.libraries/httpclient-4.3.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpclient-4.3.6.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpcore-4.3.3" MODULE="httpcore-4.3.3.jar" MVN="mvn:org.talend.libraries/httpcore-4.3.3/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpcore-4.3.3.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpclient-4.5.5" MODULE="httpclient-4.5.5.jar" MVN="mvn:org.talend.libraries/httpclient-4.5.5/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpclient-4.5.5.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpcore-4.4.9" MODULE="httpcore-4.4.9.jar" MVN="mvn:org.talend.libraries/httpcore-4.4.9/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpcore-4.4.9.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="commons-codec-1.6" MODULE="commons-codec-1.6.jar" MVN="mvn:org.talend.libraries/commons-codec-1.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
@@ -161,8 +161,8 @@
|
||||
<IMPORTS>
|
||||
<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_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="commons-logging-1.1.3" MODULE="commons-logging-1.1.3.jar" MVN="mvn:commons-logging/commons-logging/1.1.3" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-logging-1.1.3.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpclient-4.3.6" MODULE="httpclient-4.3.6.jar" MVN="mvn:org.talend.libraries/httpclient-4.3.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpclient-4.3.6.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpcore-4.3.3" MODULE="httpcore-4.3.3.jar" MVN="mvn:org.talend.libraries/httpcore-4.3.3/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpcore-4.3.3.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpclient-4.5.5" MODULE="httpclient-4.5.5.jar" MVN="mvn:org.talend.libraries/httpclient-4.5.5/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpclient-4.5.5.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpcore-4.4.9" MODULE="httpcore-4.4.9.jar" MVN="mvn:org.talend.libraries/httpcore-4.4.9/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpcore-4.4.9.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="commons-codec-1.6" MODULE="commons-codec-1.6.jar" MVN="mvn:org.talend.libraries/commons-codec-1.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
@@ -198,8 +198,8 @@
|
||||
<IMPORTS>
|
||||
<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_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="commons-logging-1.1.3" MODULE="commons-logging-1.1.3.jar" MVN="mvn:commons-logging/commons-logging/1.1.3" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-logging-1.1.3.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpclient-4.3.6" MODULE="httpclient-4.3.6.jar" MVN="mvn:org.talend.libraries/httpclient-4.3.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpclient-4.3.6.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpcore-4.3.3" MODULE="httpcore-4.3.3.jar" MVN="mvn:org.talend.libraries/httpcore-4.3.3/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpcore-4.3.3.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpclient-4.5.5" MODULE="httpclient-4.5.5.jar" MVN="mvn:org.talend.libraries/httpclient-4.5.5/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpclient-4.5.5.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpcore-4.4.9" MODULE="httpcore-4.4.9.jar" MVN="mvn:org.talend.libraries/httpcore-4.4.9/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpcore-4.4.9.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="commons-codec-1.6" MODULE="commons-codec-1.6.jar" MVN="mvn:org.talend.libraries/commons-codec-1.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
@@ -161,8 +161,8 @@
|
||||
<IMPORTS>
|
||||
<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_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="commons-logging-1.1.3" MODULE="commons-logging-1.1.3.jar" MVN="mvn:commons-logging/commons-logging/1.1.3" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-logging-1.1.3.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpclient-4.3.6" MODULE="httpclient-4.3.6.jar" MVN="mvn:org.talend.libraries/httpclient-4.3.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpclient-4.3.6.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpcore-4.3.3" MODULE="httpcore-4.3.3.jar" MVN="mvn:org.talend.libraries/httpcore-4.3.3/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpcore-4.3.3.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpclient-4.5.5" MODULE="httpclient-4.5.5.jar" MVN="mvn:org.talend.libraries/httpclient-4.5.5/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpclient-4.5.5.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpcore-4.4.9" MODULE="httpcore-4.4.9.jar" MVN="mvn:org.talend.libraries/httpcore-4.4.9/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpcore-4.4.9.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="commons-codec-1.6" MODULE="commons-codec-1.6.jar" MVN="mvn:org.talend.libraries/commons-codec-1.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
@@ -142,8 +142,8 @@
|
||||
<IMPORT NAME="GoogleStorageUtils" MODULE="GoogleStorageUtils.jar" MVN="mvn:org.talend.libraries/GoogleStorageUtils/6.0.0" REQUIRED="true" />
|
||||
<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_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="commons-logging-1.1.3" MODULE="commons-logging-1.1.3.jar" MVN="mvn:commons-logging/commons-logging/1.1.3" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-logging-1.1.3.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpclient-4.3.6" MODULE="httpclient-4.3.6.jar" MVN="mvn:org.talend.libraries/httpclient-4.3.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpclient-4.3.6.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpcore-4.3.3" MODULE="httpcore-4.3.3.jar" MVN="mvn:org.talend.libraries/httpcore-4.3.3/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpcore-4.3.3.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpclient-4.5.5" MODULE="httpclient-4.5.5.jar" MVN="mvn:org.talend.libraries/httpclient-4.5.5/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpclient-4.5.5.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="httpcore-4.4.9" MODULE="httpcore-4.4.9.jar" MVN="mvn:org.talend.libraries/httpcore-4.4.9/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.http/lib/httpcore-4.4.9.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
<IMPORT NAME="commons-codec-1.6" MODULE="commons-codec-1.6.jar" MVN="mvn:org.talend.libraries/commons-codec-1.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar" REQUIRED_IF="(USE_EXISTING_CONNECTION == 'false')" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
@@ -266,7 +266,9 @@ if(hiveDistrib.isExecutedThroughWebHCat()) {
|
||||
}
|
||||
}
|
||||
%>
|
||||
log.info("Query sent to HiveServer2 to be executed with [Application Name(MapReduce)/DAG Name(Tez): " + queryIdentifier_<%=cid %> + "]");
|
||||
<%if(isLog4jEnabled){%>
|
||||
log.info("Query sent to HiveServer2 to be executed with [Application Name(MapReduce)/DAG Name(Tez): " + queryIdentifier_<%=cid%> + "]");
|
||||
<%}%>
|
||||
} catch (java.lang.Exception e) {
|
||||
whetherReject_<%=cid%> = true;
|
||||
<%
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
com.amazonaws.auth.AWSCredentialsProvider credentialsProvider_<%=cid%> = new com.amazonaws.auth.InstanceProfileCredentialsProvider();
|
||||
com.amazonaws.auth.AWSCredentialsProvider credentialsProvider_<%=cid%> = new com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper();
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
@@ -106,7 +106,12 @@
|
||||
REQUIRED="false" NUM_ROW="11">
|
||||
<DEFAULT>true</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
|
||||
<PARAMETER NAME="IGNORE_SERVICE_ATTRIBUTES_FOR_EMPTY" FIELD="CHECK" NUM_ROW="11"
|
||||
SHOW_IF="CREATE_EMPTY_ELEMENT=='false'">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="EXPAND_EMPTY_ELM" FIELD="CHECK" NUM_ROW="11"
|
||||
SHOW_IF="CREATE_EMPTY_ELEMENT=='true'">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
@@ -173,6 +178,8 @@
|
||||
TARGET="Out.CREATE" />
|
||||
<TEMPLATE_PARAM SOURCE="self.CREATE_EMPTY_ELEMENT"
|
||||
TARGET="Out.CREATE_EMPTY_ELEMENT" />
|
||||
<TEMPLATE_PARAM SOURCE="self.IGNORE_SERVICE_ATTRIBUTES_FOR_EMPTY"
|
||||
TARGET="Out.IGNORE_SERVICE_ATTRIBUTES_FOR_EMPTY" />
|
||||
<TEMPLATE_PARAM SOURCE="self.EXPAND_EMPTY_ELM"
|
||||
TARGET="Out.EXPAND_EMPTY_ELM" />
|
||||
<TEMPLATE_PARAM SOURCE="self.OUTPUT_AS_XSD"
|
||||
|
||||
@@ -43,4 +43,5 @@ SCHEMA.NAME=Schema
|
||||
THOUSANDS_SEPARATOR.NAME=Thousands separator
|
||||
XMLFIELD.NAME=Output Column
|
||||
XSD_FILE.NAME=XSD file path
|
||||
IGNORE_SERVICE_ATTRIBUTES_FOR_EMPTY.NAME = Ignore service attributes for empty elements
|
||||
EXPAND_EMPTY_ELM.NAME = Expand Empty Element if needed(for dom4j)
|
||||
@@ -45,6 +45,7 @@ if ((metadatas!=null)&&(metadatas.size()>0)) {
|
||||
String removeHeader = ElementParameterParser.getValue(node, "__REMOVE_HEADER__"); // add for feature7788
|
||||
String encoding = ElementParameterParser.getValue(node, "__ENCODING__");
|
||||
boolean isAllowEmpty = ("true").equals(ElementParameterParser.getValue(node, "__CREATE_EMPTY_ELEMENT__"));
|
||||
boolean ignoreServiceAttributes = ("true").equals(ElementParameterParser.getValue(node, "__IGNORE_SERVICE_ATTRIBUTES_FOR_EMPTY__"));
|
||||
boolean expandEmptyElm = ("true").equals(ElementParameterParser.getValue(node, "__EXPAND_EMPTY_ELM__"));
|
||||
String mode = ElementParameterParser.getValue(node, "__GENERATION_MODE__");
|
||||
List<Map<String, String>> rootTable =
|
||||
@@ -200,6 +201,18 @@ java.util.Map<String,String> arraysValueMap_<%=cid%> = new java.util.HashMap<Str
|
||||
%>
|
||||
|
||||
class NestXMLTool_<%=cid%>{
|
||||
<%
|
||||
if (!isAllowEmpty && ignoreServiceAttributes) {
|
||||
%>
|
||||
private java.util.Set<String> serviceAttributeNames = new java.util.HashSet<>();
|
||||
{
|
||||
serviceAttributeNames.add("type");
|
||||
serviceAttributeNames.add("class");
|
||||
serviceAttributeNames.add("array");
|
||||
}
|
||||
<%
|
||||
}
|
||||
%>
|
||||
public void parseAndAdd(org.dom4j.Element nestRoot, String value){
|
||||
try {
|
||||
org.dom4j.Document doc4Str = org.dom4j.DocumentHelper.parseText("<root>"+ value + "</root>");
|
||||
@@ -235,16 +248,25 @@ class NestXMLTool_<%=cid%>{
|
||||
for (org.dom4j.Element tmp: (java.util.List<org.dom4j.Element>) root.elements()) {
|
||||
removeEmptyElement(tmp);
|
||||
}
|
||||
if (root.content().size() == 0
|
||||
&& root.attributes().size() == 0
|
||||
&& root.declaredNamespaces().size() == 0) {
|
||||
if(root.getParent()!=null){
|
||||
root.getParent().remove(root);
|
||||
|
||||
boolean noSignificantDataAnnotationsExist = root.attributes().isEmpty() <%if (!isAllowEmpty && ignoreServiceAttributes) {%>|| isOnlyServiceAttributesDeclared(root.attributes()) <% } %>;
|
||||
if (root.content().isEmpty()
|
||||
&& noSignificantDataAnnotationsExist && root.declaredNamespaces().isEmpty()) {
|
||||
if(root.getParent()!=null){
|
||||
root.getParent().remove(root);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
<%
|
||||
if (!isAllowEmpty && ignoreServiceAttributes) {
|
||||
%>
|
||||
private boolean isOnlyServiceAttributesDeclared(List<org.dom4j.Attribute> attributes) {
|
||||
return attributes.stream().allMatch(a -> serviceAttributeNames.contains(a.getName().toLowerCase()));
|
||||
}
|
||||
<%
|
||||
}
|
||||
%>
|
||||
public String objectToString(Object value){
|
||||
if(value.getClass().isArray()){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -99,6 +99,11 @@
|
||||
<DEFAULT>true</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="IGNORE_SERVICE_ATTRIBUTES_FOR_EMPTY" FIELD="CHECK" NUM_ROW="11"
|
||||
SHOW_IF="CREATE_EMPTY_ELEMENT=='false'">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="EXPAND_EMPTY_ELM" FIELD="CHECK" NUM_ROW="11"
|
||||
SHOW_IF="CREATE_EMPTY_ELEMENT=='true'">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
|
||||
@@ -44,5 +44,6 @@ THOUSANDS_SEPARATOR.NAME=Thousands separator
|
||||
XMLFIELD.NAME=Output Column
|
||||
XML_FIELD.NAME=XML Field
|
||||
XSD_FILE.NAME=XSD file path
|
||||
IGNORE_SERVICE_ATTRIBUTES_FOR_EMPTY.NAME = Ignore service attributes for empty elements
|
||||
EXPAND_EMPTY_ELM.NAME = Expand Empty Element if needed(for dom4j)
|
||||
COMPACT_FORMAT.NAME = Compact Format
|
||||
@@ -30,7 +30,7 @@
|
||||
<%
|
||||
if(inheritCredentials) {
|
||||
%>
|
||||
credentialsProvider_<%=cid%> = new com.amazonaws.auth.InstanceProfileCredentialsProvider();
|
||||
credentialsProvider_<%=cid%> = new com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper();
|
||||
<%} else {%>
|
||||
|
||||
com.amazonaws.auth.AWSCredentials credentials_<%=cid%> = new com.amazonaws.auth.BasicAWSCredentials(<%=accesskey%>,decryptedPassword_<%=cid%>);
|
||||
|
||||
@@ -35,6 +35,7 @@ imports="
|
||||
%>
|
||||
String driverClass_<%=cid%> = "<%=this.getDirverClassName(node)%>";
|
||||
java.lang.Class.forName(driverClass_<%=cid%>);
|
||||
globalMap.put("driverClass_<%=cid%>", driverClass_<%=cid%>);
|
||||
<%
|
||||
}
|
||||
|
||||
|
||||
@@ -165,6 +165,12 @@ imports="
|
||||
close_begin();
|
||||
%>
|
||||
conn_<%=cid%>.close();
|
||||
<% /* TESB-24900 - graceful shutdown for MYSQL connection */ %>
|
||||
if("com.mysql.cj.jdbc.Driver".equals((String)globalMap.get("driverClass_<%=(connection!=null)?connection.replaceAll("'","").trim():""%>"))
|
||||
&& routines.system.BundleUtils.inOSGi()) {
|
||||
Class.forName("com.mysql.cj.jdbc.AbandonedConnectionCleanupThread").
|
||||
getMethod("checkedShutdown").invoke(null, (Object[]) null);
|
||||
}
|
||||
<%
|
||||
close_end();
|
||||
}
|
||||
|
||||
@@ -61,10 +61,10 @@ public class GenericTableUtils {
|
||||
List<String> valueList = new ArrayList<>();
|
||||
if(dbService != null){
|
||||
for(String v:values){
|
||||
if(v == null || v.length() <= 0){
|
||||
continue;
|
||||
}
|
||||
if(param.getName().equals(EConnectionParameterName.GENERIC_DRIVER_JAR.getDisplayName())){
|
||||
if(v == null || v.length() <= 0 || TalendQuoteUtils.removeQuotesIfExist(v).length() <= 0){
|
||||
continue;
|
||||
}
|
||||
v = dbService.getMVNPath(v);
|
||||
}
|
||||
valueList.add(v);
|
||||
|
||||
@@ -759,6 +759,15 @@
|
||||
name="ChangeOracleVersionForProjectSetting"
|
||||
version="5.2.1">
|
||||
</projecttask>
|
||||
<projecttask
|
||||
beforeLogon="false"
|
||||
breaks="7.1.0"
|
||||
class="org.talend.designer.core.utils.FillTRunJobReferenceParametersMigrationTask"
|
||||
description="Fix empty process id parameters for tRunjob node."
|
||||
id="org.talend.designer.core.utils.FillTRunJobReferenceParametersMigrationTask"
|
||||
name="Fix empty process id parameters for tRunjob node"
|
||||
version="7.1.1">
|
||||
</projecttask>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.talend.repository.projectsetting_page">
|
||||
|
||||
@@ -272,6 +272,7 @@ EParameterName.FunName=Function name
|
||||
EParameterName.IDocName=IDoc name
|
||||
EParameterName.fromDatabaseFlag=From Database
|
||||
EParameterName.fromFileFlag=From File
|
||||
EParameterName.OverrideEncodingFlag=Override Encoding
|
||||
EParameterName.generateCode=Generate Code
|
||||
EParameterName.help=Help
|
||||
EParameterName.host=Host
|
||||
@@ -733,6 +734,7 @@ PerformancePreferencePage.generateCode=Generate code when opening the job
|
||||
PerformancePreferencePage.checkVersion=Check only the last version when updating jobs or joblets
|
||||
PerformancePreferencePage.addOrDeleteVariable=Propagate add/delete variable changes in repository contexts
|
||||
PerformancePreferencePage.ActivedTimeoutSetting=Activate the timeout for database connection.
|
||||
PerformancePreferencePage.propagateContext=Propagate contexts added in repository context groups
|
||||
PerformancePreferencePage.ConnectionTimeout=Connection timeout (seconds)
|
||||
PerformancePreferencePage.HBaseOrMaprDBScanLimit=HBase/MapR-DB scan limit (for retrieving schema)
|
||||
PerformancePreferencePage.HBaseOrMaprDBScanLimitTip=If set it by zero, will be same as deactiving the limit.
|
||||
|
||||
@@ -226,6 +226,9 @@ public enum EParameterName {
|
||||
FIELDSEPARATOR(Messages.getString("EParameterName.FieldSeparator")), //$NON-NLS-1$
|
||||
ROWSEPARATOR(Messages.getString("EParameterName.RowSeparator")), //$NON-NLS-1$
|
||||
FROM_FILE_FLAG(Messages.getString("EParameterName.fromFileFlag")), //$NON-NLS-1$
|
||||
OVERRIDE_ENCODING_FLAG(Messages.getString("EParameterName.OverrideEncodingFlag")), //$NON-NLS-1$
|
||||
// for override encoding (name should be diff from the encoding of Stats&Logs)
|
||||
OVERRIDE_ENCODING_IN_EXTRA("OVERRIDE_ENCODING_IN_EXTRA"), //$NON-NLS-1$
|
||||
FROM_DATABASE_FLAG(Messages.getString("EParameterName.fromDatabaseFlag")), //$NON-NLS-1$
|
||||
// implict tConextLoad parameters.
|
||||
LOAD_NEW_VARIABLE(Messages.getString("EParameterName.LoadNewVariableLabel")), //$NON-NLS-1$
|
||||
|
||||
@@ -2248,6 +2248,9 @@ public class EmfComponent extends AbstractBasicComponent {
|
||||
readOnlyColumnPosition = EReadOnlyComlumnPosition.BOTTOM.toString();
|
||||
}
|
||||
defaultTable.setReadOnlyColumnPosition(readOnlyColumnPosition);
|
||||
|
||||
List<String> originalColumns = new ArrayList<>();
|
||||
|
||||
int nbCustom = 0;
|
||||
for (int i = 0; i < xmlColumnList.size(); i++) {
|
||||
xmlColumn = (COLUMNType) xmlColumnList.get(i);
|
||||
@@ -2283,9 +2286,11 @@ public class EmfComponent extends AbstractBasicComponent {
|
||||
talendColumn.setCustomId(-1);
|
||||
}
|
||||
talendColumnList.add(talendColumn);
|
||||
originalColumns.add(talendColumn.getLabel());
|
||||
}
|
||||
|
||||
defaultTable.setListColumns(talendColumnList);
|
||||
defaultTable.setOriginalColumns(originalColumns);
|
||||
|
||||
// store the default table in default value
|
||||
IElementParameterDefaultValue defaultValue = new ElementParameterDefaultValue();
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.gef.palette.PaletteEntry;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
import org.talend.core.model.process.INode;
|
||||
import org.talend.core.model.process.IProcess;
|
||||
@@ -31,6 +32,7 @@ import org.talend.core.model.process.IReplaceNodeInProcess;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.JobletProcessItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryEditorInput;
|
||||
import org.talend.core.model.update.UpdateResult;
|
||||
import org.talend.designer.core.ui.editor.process.Process;
|
||||
|
||||
@@ -143,7 +145,7 @@ public abstract class AbstractProcessProvider implements IReplaceNodeInProcess {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DOC qzhang Comment method "canDeleteNode".
|
||||
*
|
||||
@@ -257,5 +259,10 @@ public abstract class AbstractProcessProvider implements IReplaceNodeInProcess {
|
||||
public boolean canHandleNode(INode node) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public IRepositoryEditorInput createJobletEditorInput(JobletProcessItem processItem, boolean load, Boolean lastVersion, Boolean readonly,
|
||||
Boolean openedInJob) throws PersistenceException{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -808,6 +808,9 @@ public class ConnectionManager {
|
||||
if (list.contains(newTarget)) {
|
||||
return true;
|
||||
}
|
||||
if (source.equals(newTarget)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -256,6 +256,9 @@ public class JobContextLoadComponent implements IComponent {
|
||||
source = self + "IGNORE_ERROR_MESSAGE"; //$NON-NLS-1$
|
||||
multipleComponentManager.addParam(source, FILE_INPUT_REGEX + ".IGNORE_ERROR_MESSAGE"); //$NON-NLS-1$
|
||||
|
||||
source = self + "ENCODING";
|
||||
multipleComponentManager.addParam(source, FILE_INPUT_REGEX + ".ENCODING"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
} else {
|
||||
String source = self + JobSettingsConstants.getExtraParameterName(EParameterName.URL.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".URL");
|
||||
|
||||
@@ -96,6 +96,12 @@ public class JobSettingsManager {
|
||||
|
||||
private static final String CONNECTOR = TalendTextUtils.getStringConnect();
|
||||
|
||||
private static final String ENCODING_TYPE_UTF_8 = "UTF-8"; //$NON-NLS-1$
|
||||
|
||||
private static final String ENCODING_TYPE_ISO_8859_15 = "ISO-8859-15"; //$NON-NLS-1$
|
||||
|
||||
private static final String ENCODING_TYPE_CUSTOM = "CUSTOM"; //$NON-NLS-1$
|
||||
|
||||
private static List<IElementParameter> getHeaderFooterParameters(IProcess process) {
|
||||
// for headerFooter Code
|
||||
ElementParameter param;
|
||||
@@ -384,6 +390,51 @@ public class JobSettingsManager {
|
||||
param.setShowIf(condition);
|
||||
paramList.add(param);
|
||||
|
||||
// begin Override encoding checkbox
|
||||
param = new ElementParameter(process);
|
||||
param.setName(EParameterName.OVERRIDE_ENCODING_FLAG.getName());
|
||||
param.setDisplayName(EParameterName.OVERRIDE_ENCODING_FLAG.getDisplayName());
|
||||
param.setFieldType(EParameterFieldType.CHECK);
|
||||
param.setCategory(EComponentCategory.EXTRA);
|
||||
param.setGroup(IMPLICIT_GROUP);
|
||||
param.setNumRow(33);
|
||||
param.setValue(false);
|
||||
param.setShowIf(condition);
|
||||
paramList.add(param);
|
||||
// end Override encoding checkbox
|
||||
|
||||
// begin encoding select
|
||||
ElementParameter encodingParam = new ElementParameter(process);
|
||||
encodingParam.setName(EParameterName.OVERRIDE_ENCODING_IN_EXTRA.getName());
|
||||
encodingParam.setDisplayName(EParameterName.OVERRIDE_ENCODING_IN_EXTRA.getDisplayName());
|
||||
encodingParam.setCategory(EComponentCategory.EXTRA);
|
||||
encodingParam.setGroup(IMPLICIT_GROUP);
|
||||
encodingParam.setFieldType(EParameterFieldType.ENCODING_TYPE);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(JobSettingsConstants.getExtraParameterName(EParameterName.FROM_FILE_FLAG.getName())).append(" == 'true' and ")
|
||||
.append(EParameterName.OVERRIDE_ENCODING_FLAG.getName()).append(" == 'true' and ").append(CONTEXTLOAD_CONDITION);
|
||||
condition = JobSettingsConstants.addBrackets(sb.toString());
|
||||
encodingParam.setShowIf(condition); // $NON-NLS-1$
|
||||
encodingParam.setValue(ENCODING_TYPE_ISO_8859_15);
|
||||
encodingParam.setNumRow(34);
|
||||
paramList.add(encodingParam);
|
||||
|
||||
ElementParameter childParam = new ElementParameter(process);
|
||||
childParam.setName(EParameterName.ENCODING_TYPE.getName());
|
||||
childParam.setDisplayName(EParameterName.ENCODING_TYPE.getDisplayName());
|
||||
childParam.setFieldType(EParameterFieldType.TECHNICAL);
|
||||
childParam.setCategory(EComponentCategory.EXTRA);
|
||||
childParam.setGroup(IMPLICIT_GROUP);
|
||||
childParam.setListItemsDisplayName(new String[] { ENCODING_TYPE_ISO_8859_15, ENCODING_TYPE_UTF_8, ENCODING_TYPE_CUSTOM });
|
||||
childParam.setListItemsDisplayCodeName(
|
||||
new String[] { ENCODING_TYPE_ISO_8859_15, ENCODING_TYPE_UTF_8, ENCODING_TYPE_CUSTOM });
|
||||
childParam.setListItemsValue(new String[] { ENCODING_TYPE_ISO_8859_15, ENCODING_TYPE_UTF_8, ENCODING_TYPE_CUSTOM });
|
||||
childParam.setValue(ENCODING_TYPE_ISO_8859_15);
|
||||
childParam.setNumRow(34);
|
||||
childParam.setShow(true);
|
||||
childParam.setShowIf(condition); // $NON-NLS-1$
|
||||
childParam.setParentParameter(encodingParam);
|
||||
// end encoding select
|
||||
return paramList;
|
||||
}
|
||||
|
||||
@@ -952,6 +1003,25 @@ public class JobSettingsManager {
|
||||
tContextLoadNode.getElementParameter(EParameterName.IMPLICIT_TCONTEXTLOAD_FILE.getName()).setValue(inputFile);
|
||||
String regex = FileSeparator.getSeparatorsRegexp(fileSparator);
|
||||
tContextLoadNode.getElementParameter(JobSettingsConstants.IMPLICIT_TCONTEXTLOAD_REGEX).setValue(regex);
|
||||
|
||||
String encoding = (String) process.getElementParameter(EParameterName.OVERRIDE_ENCODING_IN_EXTRA.getName())
|
||||
.getValue();
|
||||
if (StringUtils.isNotEmpty(encoding) && !encoding.startsWith(TalendTextUtils.getQuoteChar())) {
|
||||
encoding = TalendTextUtils.addQuotes(encoding);
|
||||
}
|
||||
|
||||
// override encoding
|
||||
paramName = EParameterName.OVERRIDE_ENCODING_FLAG.getName();
|
||||
boolean overrideFlag = ((Boolean) process.getElementParameter(paramName).getValue())
|
||||
&& process.getElementParameter(paramName).isShow(process.getElementParameters());
|
||||
if (overrideFlag) {
|
||||
IElementParameter encodingParam = new ElementParameter(tContextLoadNode);
|
||||
encodingParam.setName(EParameterName.ENCODING.getName());
|
||||
encodingParam.setDisplayName(EParameterName.ENCODING.getDisplayName());
|
||||
encodingParam.setFieldType(EParameterFieldType.ENCODING_TYPE);
|
||||
encodingParam.setValue(encoding);
|
||||
tContextLoadNode.addElementParameter(encodingParam);
|
||||
}
|
||||
} else {
|
||||
// is db
|
||||
paramName = JobSettingsConstants.getExtraParameterName(EParameterName.URL.getName());
|
||||
|
||||
@@ -634,6 +634,7 @@ public class Node extends Element implements IGraphicalNode {
|
||||
if (param.getValue() instanceof IMetadataTable) {
|
||||
IMetadataTable paramTable = (IMetadataTable) param.getValue();
|
||||
table.getListColumns().addAll(paramTable.getListColumns());
|
||||
table.setOriginalColumns(paramTable.getOriginalColumns());
|
||||
table.setReadOnly(paramTable.isReadOnly());
|
||||
} else if (param.getFieldType().equals(EParameterFieldType.SCHEMA_REFERENCE)) {
|
||||
Schema schema = (Schema) componentProperties.getValuedProperty(param.getName()).getValue();
|
||||
|
||||
@@ -122,6 +122,7 @@ import org.talend.core.model.update.IUpdateManager;
|
||||
import org.talend.core.model.utils.TalendTextUtils;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.repository.utils.ConvertJobsUtil;
|
||||
import org.talend.core.repository.utils.ProjectHelper;
|
||||
import org.talend.core.repository.utils.XmiResourceManager;
|
||||
import org.talend.core.runtime.repository.item.ItemProductKeys;
|
||||
import org.talend.core.runtime.util.ItemDateParser;
|
||||
@@ -1914,12 +1915,25 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
}
|
||||
}
|
||||
|
||||
for (IRepositoryViewObject object : routines) {
|
||||
if (routinesToAdd.contains(object.getLabel()) && !routinesAlreadySetup.contains(object.getLabel())) {
|
||||
RoutinesParameterType routinesParameterType = TalendFileFactory.eINSTANCE.createRoutinesParameterType();
|
||||
routinesParameterType.setId(object.getId());
|
||||
routinesParameterType.setName(object.getLabel());
|
||||
routinesDependencies.add(routinesParameterType);
|
||||
//
|
||||
boolean isLimited = false;
|
||||
org.talend.core.model.properties.Project currProject = getProject().getEmfProject();
|
||||
org.talend.core.model.properties.Project project = ProjectManager.getInstance().getProject(this.property);
|
||||
if (currProject != null && project != null && !currProject.equals(project)) {
|
||||
int currOrdinal = ProjectHelper.getProjectTypeOrdinal(currProject);
|
||||
int ordinal = ProjectHelper.getProjectTypeOrdinal(project);
|
||||
if (currOrdinal > ordinal) {
|
||||
isLimited = true;
|
||||
}
|
||||
}
|
||||
if (!isLimited) {
|
||||
for (IRepositoryViewObject object : routines) {
|
||||
if (routinesToAdd.contains(object.getLabel()) && !routinesAlreadySetup.contains(object.getLabel())) {
|
||||
RoutinesParameterType routinesParameterType = TalendFileFactory.eINSTANCE.createRoutinesParameterType();
|
||||
routinesParameterType.setId(object.getId());
|
||||
routinesParameterType.setName(object.getLabel());
|
||||
routinesDependencies.add(routinesParameterType);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (PersistenceException e) {
|
||||
@@ -2777,9 +2791,14 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
continue;
|
||||
}
|
||||
}
|
||||
EConnectionType type = EConnectionType.getTypeFromId(lineStyleId);
|
||||
connec = new Connection(source, target, type, source.getConnectorFromType(type).getName(), metaname,
|
||||
cType.getLabel(), cType.getMetaname(), monitorConnection);
|
||||
if (!ConnectionManager.checkCircle(source, target)) {
|
||||
EConnectionType type = EConnectionType.getTypeFromId(lineStyleId);
|
||||
connec = new Connection(source, target, type, source.getConnectorFromType(type).getName(), metaname,
|
||||
cType.getLabel(), cType.getMetaname(), monitorConnection);
|
||||
} else {
|
||||
ExceptionHandler.process(new Exception(Messages.getString("Process.errorCircleConnectionDetected", //$NON-NLS-1$
|
||||
cType.getLabel(), source.getLabel(), target.getLabel())));
|
||||
}
|
||||
}
|
||||
if (connec == null) {
|
||||
continue;
|
||||
@@ -4533,6 +4552,9 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
}
|
||||
|
||||
private void saveJobletNode(AbstractJobletContainer jobletContainer) {
|
||||
if (CommonsPlugin.isHeadless()) {
|
||||
return;
|
||||
}
|
||||
INode jobletNode = jobletContainer.getNode();
|
||||
IProcess jobletProcess = jobletNode.getComponent().getProcess();
|
||||
if (jobletProcess == null) {
|
||||
|
||||
@@ -115,6 +115,7 @@ import org.talend.core.ui.ICDCProviderService;
|
||||
import org.talend.core.ui.IJobletProviderService;
|
||||
import org.talend.core.ui.component.ComponentsFactoryProvider;
|
||||
import org.talend.cwm.helper.SAPBWTableHelper;
|
||||
import org.talend.designer.core.DesignerPlugin;
|
||||
import org.talend.designer.core.i18n.Messages;
|
||||
import org.talend.designer.core.model.components.EParameterName;
|
||||
import org.talend.designer.core.model.components.ElementParameter;
|
||||
@@ -125,6 +126,7 @@ import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
import org.talend.designer.core.ui.editor.nodes.Node;
|
||||
import org.talend.designer.core.ui.editor.update.UpdateCheckResult;
|
||||
import org.talend.designer.core.ui.editor.update.UpdateManagerUtils;
|
||||
import org.talend.designer.core.ui.preferences.TalendDesignerPrefConstants;
|
||||
import org.talend.designer.core.utils.ConnectionUtil;
|
||||
import org.talend.designer.core.utils.SAPParametersUtils;
|
||||
import org.talend.metadata.managment.ui.utils.ConnectionContextHelper;
|
||||
@@ -307,6 +309,10 @@ public class ProcessUpdateManager extends AbstractUpdateManager {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Boolean propagate = DesignerPlugin.getDefault().getPreferenceStore().getBoolean(TalendDesignerPrefConstants.PROPAGATE_CONTEXT);
|
||||
if(!propagate) {
|
||||
return contextResults;
|
||||
}
|
||||
// only handle added groups
|
||||
Set<String> contextSourceChecked = new HashSet<String>();
|
||||
Set<String> processContextGroups = new HashSet<String>();
|
||||
|
||||
@@ -1113,9 +1113,13 @@ public abstract class AbstractSchemaController extends AbstractRepositoryControl
|
||||
for (IMetadataColumn column : metadataTable.getListColumns()) {
|
||||
columnNames.add(column.getLabel());
|
||||
}
|
||||
metadataTable.setOriginalColumns(columnNames);
|
||||
if(metadataTable.getOriginalColumns() == null || metadataTable.getOriginalColumns().isEmpty()){
|
||||
metadataTable.setOriginalColumns(columnNames);
|
||||
}
|
||||
}
|
||||
if(tableCopy.getOriginalColumns() == null || tableCopy.getOriginalColumns().isEmpty()){
|
||||
tableCopy.setOriginalColumns(metadataTable.getOriginalColumns());
|
||||
}
|
||||
tableCopy.setOriginalColumns(metadataTable.getOriginalColumns());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ public class DesignerPreferencePage extends FieldEditorPreferencePage implements
|
||||
Messages.getString("DesignerPreferencePage.duplicateTestCases"), getFieldEditorParent()); //$NON-NLS-1$
|
||||
addField(duplicateTestCases);
|
||||
}
|
||||
|
||||
|
||||
DirectoryFieldEditor compDefaultFileDir = new DirectoryFieldEditor(TalendDesignerPrefConstants.COMP_DEFAULT_FILE_DIR,
|
||||
Messages.getString("DesignerPreferencePage.defaultFilePathDirectory"), getFieldEditorParent()) {
|
||||
|
||||
|
||||
@@ -64,6 +64,9 @@ public class PerformancePreferencePage extends FieldEditorPreferencePage impleme
|
||||
addField(new BooleanFieldEditor(TalendDesignerPrefConstants.CHECK_ONLY_LAST_VERSION,
|
||||
Messages.getString("PerformancePreferencePage.checkVersion"), //$NON-NLS-1$
|
||||
getFieldEditorParent()));
|
||||
addField(new BooleanFieldEditor(TalendDesignerPrefConstants.PROPAGATE_CONTEXT,
|
||||
Messages.getString("PerformancePreferencePage.propagateContext"), //$NON-NLS-1$
|
||||
getFieldEditorParent()));
|
||||
addField(new BooleanFieldEditor(TalendDesignerPrefConstants.PROPAGATE_CONTEXT_VARIABLE,
|
||||
Messages.getString("PerformancePreferencePage.addOrDeleteVariable"), //$NON-NLS-1$
|
||||
getFieldEditorParent()));
|
||||
@@ -100,6 +103,9 @@ public class PerformancePreferencePage extends FieldEditorPreferencePage impleme
|
||||
addField(new BooleanFieldEditor(TalendDesignerPrefConstants.CHECK_ONLY_LAST_VERSION,
|
||||
Messages.getString("PerformancePreferencePage.checkVersion"), //$NON-NLS-1$
|
||||
getFieldEditorParent()));
|
||||
addField(new BooleanFieldEditor(TalendDesignerPrefConstants.PROPAGATE_CONTEXT,
|
||||
Messages.getString("PerformancePreferencePage.propagateContext"), //$NON-NLS-1$
|
||||
getFieldEditorParent()));
|
||||
addField(new BooleanFieldEditor(TalendDesignerPrefConstants.PROPAGATE_CONTEXT_VARIABLE,
|
||||
Messages.getString("PerformancePreferencePage.addOrDeleteVariable"), //$NON-NLS-1$
|
||||
getFieldEditorParent()));
|
||||
|
||||
@@ -67,6 +67,8 @@ public class TalendDesignerPrefConstants {
|
||||
public static final String EDITOR_LINESTYLE = "editorLineStyle "; //$NON-NLS-1$
|
||||
|
||||
public static final String DUPLICATE_TESTCASE = "duplicateTestCases "; //$NON-NLS-1$
|
||||
|
||||
public static final String PROPAGATE_CONTEXT = "propagateContext"; //$NON-NLS-1$
|
||||
|
||||
public static final String SCHEMA_OPTIONS = "schemaOptions"; //$NON-NLS-1$
|
||||
|
||||
|
||||
@@ -85,6 +85,12 @@ public class ProjectSettingManager extends Utils {
|
||||
|
||||
private static String languagePrefix = LanguageManager.getCurrentLanguage().toString() + "_"; //$NON-NLS-1$
|
||||
|
||||
private static final String ENCODING_TYPE_UTF_8 = "UTF-8"; //$NON-NLS-1$
|
||||
|
||||
private static final String ENCODING_TYPE_ISO_8859_15 = "ISO-8859-15"; //$NON-NLS-1$
|
||||
|
||||
private static final String ENCODING_TYPE_CUSTOM = "CUSTOM"; //$NON-NLS-1$
|
||||
|
||||
public static void saveProject() {
|
||||
RepositoryContext repositoryContext = (RepositoryContext) CorePlugin.getContext().getProperty(
|
||||
Context.REPOSITORY_CONTEXT_KEY);
|
||||
@@ -448,6 +454,51 @@ public class ProjectSettingManager extends Utils {
|
||||
param.setShowIf(condition);
|
||||
paramList.add(param);
|
||||
|
||||
// begin Override encoding checkbox
|
||||
param = new ElementParameter(elem);
|
||||
param.setName(EParameterName.OVERRIDE_ENCODING_FLAG.getName());
|
||||
param.setDisplayName(EParameterName.OVERRIDE_ENCODING_FLAG.getDisplayName());
|
||||
param.setFieldType(EParameterFieldType.CHECK);
|
||||
param.setCategory(EComponentCategory.EXTRA);
|
||||
param.setGroup(IMPLICIT_GROUP);
|
||||
param.setNumRow(33);
|
||||
param.setValue(false);
|
||||
param.setShowIf(condition);
|
||||
paramList.add(param);
|
||||
// end Override encoding checkbox
|
||||
|
||||
// begin encoding select
|
||||
ElementParameter encodingParam = new ElementParameter(elem);
|
||||
encodingParam.setName(EParameterName.OVERRIDE_ENCODING_IN_EXTRA.getName());
|
||||
encodingParam.setDisplayName(EParameterName.OVERRIDE_ENCODING_IN_EXTRA.getDisplayName());
|
||||
encodingParam.setCategory(EComponentCategory.EXTRA);
|
||||
encodingParam.setGroup(IMPLICIT_GROUP);
|
||||
encodingParam.setFieldType(EParameterFieldType.ENCODING_TYPE);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(JobSettingsConstants.getExtraParameterName(EParameterName.FROM_FILE_FLAG.getName())).append(" == 'true' and ")
|
||||
.append(EParameterName.OVERRIDE_ENCODING_FLAG.getName()).append(" == 'true' and ").append(CONTEXTLOAD_CONDITION);
|
||||
condition = JobSettingsConstants.addBrackets(sb.toString());
|
||||
encodingParam.setShowIf(condition); // $NON-NLS-1$
|
||||
encodingParam.setValue(ENCODING_TYPE_ISO_8859_15);
|
||||
encodingParam.setNumRow(34);
|
||||
paramList.add(encodingParam);
|
||||
|
||||
ElementParameter childParam = new ElementParameter(elem);
|
||||
childParam.setName(EParameterName.ENCODING_TYPE.getName());
|
||||
childParam.setDisplayName(EParameterName.ENCODING_TYPE.getDisplayName());
|
||||
childParam.setFieldType(EParameterFieldType.TECHNICAL);
|
||||
childParam.setCategory(EComponentCategory.EXTRA);
|
||||
childParam.setGroup(IMPLICIT_GROUP);
|
||||
childParam.setListItemsDisplayName(new String[] { ENCODING_TYPE_ISO_8859_15, ENCODING_TYPE_UTF_8, ENCODING_TYPE_CUSTOM });
|
||||
childParam.setListItemsDisplayCodeName(
|
||||
new String[] { ENCODING_TYPE_ISO_8859_15, ENCODING_TYPE_UTF_8, ENCODING_TYPE_CUSTOM });
|
||||
childParam.setListItemsValue(new String[] { ENCODING_TYPE_ISO_8859_15, ENCODING_TYPE_UTF_8, ENCODING_TYPE_CUSTOM });
|
||||
childParam.setValue(ENCODING_TYPE_ISO_8859_15);
|
||||
childParam.setNumRow(34);
|
||||
childParam.setShow(true);
|
||||
childParam.setShowIf(condition); // $NON-NLS-1$
|
||||
childParam.setParentParameter(encodingParam);
|
||||
// end encoding select
|
||||
}
|
||||
|
||||
private static void createExtraOnDBParameters(Element elem) {
|
||||
|
||||
@@ -587,6 +587,7 @@ public class MainComposite extends AbstractTabComposite {
|
||||
|| property == null) {
|
||||
return;
|
||||
}
|
||||
String oldVersion = repositoryObject.getVersion();
|
||||
String originalName = nameText.getText();
|
||||
String originalJobType = jobTypeCCombo.getText();
|
||||
String originalFramework = ConvertJobsUtil.convertFrameworkByJobType(originalJobType,
|
||||
@@ -779,6 +780,9 @@ public class MainComposite extends AbstractTabComposite {
|
||||
public void run(final IProgressMonitor monitor) throws CoreException {
|
||||
try {
|
||||
if (repositoryObject.getProperty() != null) {
|
||||
if (!originalversion.equals(StringUtils.trimToEmpty(oldVersion))) {
|
||||
RelationshipItemBuilder.getInstance().addOrUpdateItem(repositoryObject.getProperty().getItem());
|
||||
}
|
||||
proxyRepositoryFactory.save(ProjectManager.getInstance().getCurrentProject(),
|
||||
repositoryObject.getProperty().getItem(), false);
|
||||
if (needjobletRelateUpdate && GlobalServiceRegister.getDefault()
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.designer.core.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.model.components.ComponentUtilities;
|
||||
import org.talend.core.model.components.ModifyComponentsAction;
|
||||
import org.talend.core.model.components.conversions.IComponentConversion;
|
||||
import org.talend.core.model.components.filters.IComponentFilter;
|
||||
import org.talend.core.model.components.filters.NameComponentFilter;
|
||||
import org.talend.core.model.migration.AbstractItemMigrationTask;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.JobletProcessItem;
|
||||
import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.designer.core.DesignerPlugin;
|
||||
import org.talend.designer.core.model.components.EParameterName;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
|
||||
/**
|
||||
* Created by bhe on Nov 22, 2019
|
||||
*/
|
||||
public class FillTRunJobReferenceParametersMigrationTask extends AbstractItemMigrationTask {
|
||||
|
||||
@Override
|
||||
public List<ERepositoryObjectType> getTypes() {
|
||||
List<ERepositoryObjectType> toReturn = new ArrayList<ERepositoryObjectType>();
|
||||
toReturn.addAll(ERepositoryObjectType.getAllTypesOfProcess());
|
||||
toReturn.addAll(ERepositoryObjectType.getAllTypesOfProcess2());
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ExecutionResult execute(Item item) {
|
||||
ProcessType pt = null;
|
||||
if (item instanceof ProcessItem) {
|
||||
ProcessItem processItem = (ProcessItem) item;
|
||||
pt = processItem.getProcess();
|
||||
} else if (item instanceof JobletProcessItem) {
|
||||
JobletProcessItem jobletItem = (JobletProcessItem) item;
|
||||
pt = jobletItem.getJobletProcess();
|
||||
}
|
||||
|
||||
if (pt == null) {
|
||||
return ExecutionResult.NOTHING_TO_DO;
|
||||
}
|
||||
|
||||
IComponentFilter filter = new NameComponentFilter("tRunJob"); //$NON-NLS-1$
|
||||
try {
|
||||
ModifyComponentsAction.searchAndModify(item, pt, filter,
|
||||
Arrays.<IComponentConversion> asList(new IComponentConversion() {
|
||||
|
||||
@Override
|
||||
public void transform(NodeType node) {
|
||||
ElementParameterType jobId = ComponentUtilities.getNodeProperty(node,
|
||||
EParameterName.PROCESS.getName() + ":" + EParameterName.PROCESS_TYPE_PROCESS.getName()); //$NON-NLS-1$
|
||||
if (jobId.getValue() == null || jobId.getValue().isEmpty()) {
|
||||
ElementParameterType jobLabel = ComponentUtilities.getNodeProperty(node,
|
||||
EParameterName.PROCESS.getName()); // $NON-NLS-1$
|
||||
String id = getIdFormLabel(jobLabel.getValue());
|
||||
if (id != null && !id.isEmpty()) {
|
||||
jobId.setValue(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}));
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
return ExecutionResult.FAILURE;
|
||||
}
|
||||
|
||||
return ExecutionResult.SUCCESS_NO_ALERT;
|
||||
}
|
||||
|
||||
private static String getIdFormLabel(final String label) {
|
||||
if (label == null || label.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
final IProxyRepositoryFactory proxyRepositoryFactory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
|
||||
try {
|
||||
List<IRepositoryViewObject> allRepositoryObject = proxyRepositoryFactory.getAll(ERepositoryObjectType.PROCESS, true);
|
||||
for (IRepositoryViewObject repObject : allRepositoryObject) {
|
||||
Item item = repObject.getProperty().getItem();
|
||||
if (item != null && label.equals(item.getProperty().getLabel())) {
|
||||
return item.getProperty().getId();
|
||||
}
|
||||
}
|
||||
} catch (PersistenceException e) {
|
||||
//
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Date getOrder() {
|
||||
GregorianCalendar gc = new GregorianCalendar(2019, 11, 22, 12, 0, 0);
|
||||
return gc.getTime();
|
||||
}
|
||||
}
|
||||
@@ -27,8 +27,12 @@ import java.util.regex.PatternSyntaxException;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.StringUtils;
|
||||
import org.talend.commons.utils.data.text.StringHelper;
|
||||
import org.talend.core.database.EDatabaseTypeName;
|
||||
import org.talend.core.model.metadata.Dbms;
|
||||
import org.talend.core.model.metadata.IMetadataColumn;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
import org.talend.core.model.metadata.MappingTypeRetriever;
|
||||
import org.talend.core.model.metadata.MetadataTalendType;
|
||||
import org.talend.core.model.metadata.MetadataToolHelper;
|
||||
import org.talend.core.model.process.EConnectionType;
|
||||
import org.talend.core.model.process.IConnection;
|
||||
@@ -40,6 +44,7 @@ import org.talend.core.model.process.INode;
|
||||
import org.talend.core.model.process.IProcess;
|
||||
import org.talend.core.model.utils.ContextParameterUtils;
|
||||
import org.talend.core.model.utils.TalendTextUtils;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
import org.talend.designer.core.model.components.EParameterName;
|
||||
import org.talend.designer.dbmap.DbMapComponent;
|
||||
import org.talend.designer.dbmap.external.data.ExternalDbMapData;
|
||||
@@ -436,6 +441,7 @@ public abstract class DbGenerationManager {
|
||||
}
|
||||
|
||||
StringBuilder sbWhere = new StringBuilder();
|
||||
this.tabSpaceString = DEFAULT_TAB_SPACE_STRING;
|
||||
boolean isFirstClause = true;
|
||||
for (int i = 0; i < lstSizeInputTables; i++) {
|
||||
ExternalDbMapTable inputTable = inputTables.get(i);
|
||||
@@ -443,7 +449,6 @@ public abstract class DbGenerationManager {
|
||||
isFirstClause = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* for addition conditions
|
||||
*/
|
||||
@@ -481,16 +486,19 @@ public abstract class DbGenerationManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<ExternalDbMapEntry> customOtherConditionsEntries = outputTable.getCustomOtherConditionsEntries();
|
||||
if (customOtherConditionsEntries != null) {
|
||||
for (ExternalDbMapEntry entry : customOtherConditionsEntries) {
|
||||
String exp = initExpression(component, entry);
|
||||
if (exp != null && !DbMapSqlConstants.EMPTY.equals(exp.trim())) {
|
||||
exp = replaceVariablesForExpression(component, exp);
|
||||
otherAddition.add(exp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.tabSpaceString = tabString;
|
||||
|
||||
String whereClauses = sbWhere.toString();
|
||||
|
||||
@@ -669,7 +677,11 @@ public abstract class DbGenerationManager {
|
||||
query = query + " \""; //$NON-NLS-1$
|
||||
} else {
|
||||
if (query.trim().endsWith("+ \"")) { //$NON-NLS-1$
|
||||
query = query.substring(0, query.lastIndexOf("+ \"")); //$NON-NLS-1$
|
||||
if (DEFAULT_TAB_SPACE_STRING.equals(this.tabSpaceString)) {
|
||||
query = query.substring(0, query.lastIndexOf("+ \"")); //$NON-NLS-1$
|
||||
} else {
|
||||
query = query + "\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1016,6 +1028,8 @@ public abstract class DbGenerationManager {
|
||||
}
|
||||
|
||||
protected String initExpression(DbMapComponent component, ExternalDbMapEntry dbMapEntry) {
|
||||
String quote = getQuote(component);
|
||||
String quto_mark = TalendQuoteUtils.QUOTATION_MARK;
|
||||
String expression = dbMapEntry.getExpression();
|
||||
if (expression != null) {
|
||||
List<Map<String, String>> itemNameList = null;
|
||||
@@ -1040,7 +1054,7 @@ public abstract class DbGenerationManager {
|
||||
itemNameList = mapParser2.parseInTableEntryLocations(expression);
|
||||
}
|
||||
|
||||
String quoParser = "[\\\\]?\\\""; //$NON-NLS-1$
|
||||
String quto_markParser = "[\\\\]?\\" + quto_mark; //$NON-NLS-1$
|
||||
for (Map<String, String> itemNamemap : itemNameList) {
|
||||
Set<Entry<String, String>> set = itemNamemap.entrySet();
|
||||
Iterator<Entry<String, String>> ite = set.iterator();
|
||||
@@ -1105,13 +1119,13 @@ public abstract class DbGenerationManager {
|
||||
continue;
|
||||
}
|
||||
if (expression.trim().equals(tableValue + "." + oriName)) {
|
||||
expression = tableValue + "." + getColumnName(iconn, oriName);
|
||||
expression = expression.replaceAll(quoParser,"\\\\\""); //$NON-NLS-1$
|
||||
expression = tableValue + "." + getColumnName(iconn, oriName, quote);
|
||||
expression = expression.replaceAll(quto_markParser,"\\\\" +quto_mark); //$NON-NLS-1$
|
||||
continue;
|
||||
}
|
||||
if (expression.trim().equals(originaltableName + "." + oriName)) {
|
||||
expression = originaltableName + "." + getColumnName(iconn, oriName);
|
||||
expression = expression.replaceAll(quoParser,"\\\\\""); //$NON-NLS-1$
|
||||
expression = originaltableName + "." + getColumnName(iconn, oriName, quote);
|
||||
expression = expression.replaceAll(quto_markParser,"\\\\" +quto_mark); //$NON-NLS-1$
|
||||
continue;
|
||||
}
|
||||
// if it is temp delived table, use label to generate sql
|
||||
@@ -1119,13 +1133,13 @@ public abstract class DbGenerationManager {
|
||||
continue;
|
||||
}
|
||||
if (!isRefTableConnection(iconn) && isUseDelimitedIdentifiers()) {
|
||||
oriName = getColumnName(iconn, oriName);
|
||||
oriName = getColumnName(iconn, oriName, quote);
|
||||
} else {
|
||||
oriName = oriName.replaceAll("\\$", "\\\\\\$"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
expression = expression.replaceFirst("\\." + co.getLabel(), //$NON-NLS-1$
|
||||
"\\." + oriName); //$NON-NLS-1$
|
||||
expression = expression.replaceAll(quoParser,"\\\\\""); //$NON-NLS-1$
|
||||
expression = expression.replaceFirst(tableValue + "\\." + co.getLabel(), //$NON-NLS-1$
|
||||
tableValue + "\\." + oriName); //$NON-NLS-1$
|
||||
expression = replaceAuotes(expression, quto_markParser, quto_mark);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1139,6 +1153,63 @@ public abstract class DbGenerationManager {
|
||||
|
||||
return expression;
|
||||
}
|
||||
|
||||
protected String replaceAuotes(String expression, String quoParser, String quote){
|
||||
if(!expression.contains("'")){
|
||||
return expression.replaceAll(quoParser,"\\\\" +quote); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
List<Integer> indexs = new ArrayList<>();
|
||||
for(int i=0;i<expression.length();i++){
|
||||
if("'".equals(String.valueOf(expression.charAt(i)))){
|
||||
indexs.add(i);
|
||||
}
|
||||
}
|
||||
StringBuffer result = new StringBuffer();
|
||||
int start = 0;
|
||||
for(int i=0;i<indexs.size();i++){
|
||||
if(i == 0){
|
||||
if(indexs.size() == 1 && indexs.get(i) == 0){
|
||||
result.append(expression.substring(0, indexs.get(i)+1));
|
||||
}else{
|
||||
String exp = expression.substring(start, indexs.get(i));
|
||||
result.append(exp.replaceAll(quoParser,"\\\\" +quote)); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
if(i % 2 == 0 && i != indexs.size() - 1){
|
||||
result.append(expression.substring(indexs.get(i), indexs.get(i+1)+1));
|
||||
if (i < indexs.size() - 2) {
|
||||
String exp = expression.substring(indexs.get(i + 1) + 1, indexs.get(i + 2));
|
||||
result.append(exp.replaceAll(quoParser,"\\\\" +quote)); //$NON-NLS-1$
|
||||
}
|
||||
start = indexs.get(i+1)+1;
|
||||
}else if(i == indexs.size() - 1){
|
||||
String exp = expression.substring(indexs.get(i)+1, expression.length());
|
||||
result.append(exp.replaceAll(quoParser,"\\\\" +quote)); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private String getQuote(DbMapComponent component){
|
||||
String quote = TalendQuoteUtils.QUOTATION_MARK;
|
||||
IElementParameter mappingPara = component.getElementParameter(EParameterName.MAPPING.getName());
|
||||
if(mappingPara == null){
|
||||
return quote;
|
||||
}
|
||||
String mapping = (String) mappingPara.getValue();
|
||||
if(mapping == null){
|
||||
return quote;
|
||||
}
|
||||
MappingTypeRetriever mappingTypeRetriever = MetadataTalendType.getMappingTypeRetriever(mapping);
|
||||
if (mappingTypeRetriever == null) {
|
||||
return quote;
|
||||
}
|
||||
Dbms dbms = mappingTypeRetriever.getDbms();
|
||||
String product = dbms.getProduct();
|
||||
EDatabaseTypeName type = EDatabaseTypeName.getTypeFromProductName(product);
|
||||
return TalendQuoteUtils.getQuoteByDBType(type);
|
||||
}
|
||||
|
||||
private String getOriginalColumnName(String entryName, DbMapComponent component, ExternalDbMapTable table) {
|
||||
List<IConnection> inputConnections = (List<IConnection>) component.getIncomingConnections();
|
||||
@@ -1247,6 +1318,14 @@ public abstract class DbGenerationManager {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
protected String getColumnName(IConnection conn, String name, String quote) {
|
||||
if (!isRefTableConnection(conn) && isUseDelimitedIdentifiers()) {
|
||||
return getNameWithDelimitedIdentifier(name, quote);
|
||||
} else {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isRefTableConnection(IConnection conn) {
|
||||
return conn != null && conn.getLineStyle() == EConnectionType.TABLE_REF;
|
||||
@@ -1259,6 +1338,13 @@ public abstract class DbGenerationManager {
|
||||
newName = delimitedIdentifier + newName + delimitedIdentifier;
|
||||
return newName;
|
||||
}
|
||||
|
||||
protected String getNameWithDelimitedIdentifier(String name, String quote) {
|
||||
String newName = name;
|
||||
newName = newName.replaceAll("\"", "\"\"");
|
||||
newName = quote + newName + quote;
|
||||
return newName;
|
||||
}
|
||||
|
||||
protected String getDelimitedIdentifiers() {
|
||||
return "\""; //$NON-NLS-1$
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
// ============================================================================
|
||||
package org.talend.designer.dbmap.language.hive;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.talend.designer.dbmap.DbMapComponent;
|
||||
import org.talend.designer.dbmap.external.data.ExternalDbMapData;
|
||||
import org.talend.designer.dbmap.external.data.ExternalDbMapTable;
|
||||
@@ -53,4 +56,36 @@ public class HiveGenerationManager extends DbGenerationManager {
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String replaceVariablesForExpression(DbMapComponent component, String expression) {
|
||||
if (expression == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<String> contextList = getContextList(component);
|
||||
boolean haveReplace = false;
|
||||
for (String context : contextList) {
|
||||
if (expression.contains(context)) {
|
||||
expression = expression.replaceAll("\\b" + context + "\\b", "\" +" + context + "+ \""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
haveReplace = true;
|
||||
}
|
||||
}
|
||||
if (!haveReplace) {
|
||||
List<String> connContextList = getConnectionContextList(component);
|
||||
for (String context : connContextList) {
|
||||
if (expression.contains(context)) {
|
||||
expression = expression.replaceAll("\\b" + context + "\\b", "\" +" + context + "+ \""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
}
|
||||
}
|
||||
}
|
||||
Set<String> globalMapList = getGlobalMapList(component, expression);
|
||||
for (String globalMapStr : globalMapList) {
|
||||
String regex = parser.getGlobalMapExpressionRegex(globalMapStr);
|
||||
String replacement = parser.getGlobalMapReplacement(globalMapStr);
|
||||
expression = expression.replaceAll(regex, "\" +" + replacement + "+ \""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
return expression;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,6 +194,7 @@ public class OracleGenerationManager extends DbGenerationManager {
|
||||
}
|
||||
|
||||
StringBuilder sbWhere = new StringBuilder();
|
||||
this.tabSpaceString = DEFAULT_TAB_SPACE_STRING;
|
||||
boolean isFirstClause = true;
|
||||
for (int i = 0; i < lstSizeInputTables; i++) {
|
||||
ExternalDbMapTable inputTable = inputTables.get(i);
|
||||
@@ -201,6 +202,7 @@ public class OracleGenerationManager extends DbGenerationManager {
|
||||
isFirstClause = false;
|
||||
}
|
||||
}
|
||||
this.tabSpaceString = tabString;
|
||||
|
||||
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
|
||||
appendSqlQuery(sb, tabSpaceString);
|
||||
@@ -281,6 +283,7 @@ public class OracleGenerationManager extends DbGenerationManager {
|
||||
List<String> otherAddition = new ArrayList<String>();
|
||||
|
||||
if (outputTable != null) {
|
||||
this.tabSpaceString = DEFAULT_TAB_SPACE_STRING;
|
||||
List<ExternalDbMapEntry> customWhereConditionsEntries = outputTable.getCustomWhereConditionsEntries();
|
||||
if (customWhereConditionsEntries != null) {
|
||||
for (ExternalDbMapEntry entry : customWhereConditionsEntries) {
|
||||
@@ -308,10 +311,12 @@ public class OracleGenerationManager extends DbGenerationManager {
|
||||
for (ExternalDbMapEntry entry : customOtherConditionsEntries) {
|
||||
String exp = initExpression(component, entry);
|
||||
if (exp != null && !DbMapSqlConstants.EMPTY.equals(exp.trim())) {
|
||||
exp = replaceVariablesForExpression(component, exp);
|
||||
otherAddition.add(exp);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.tabSpaceString = tabString;
|
||||
}
|
||||
|
||||
String whereClauses = sbWhere.toString();
|
||||
|
||||
@@ -45,6 +45,7 @@ import org.talend.commons.ui.runtime.ws.WindowSystem;
|
||||
import org.talend.commons.ui.swt.drawing.background.BackgroundRefresher;
|
||||
import org.talend.commons.ui.swt.linking.BgDrawableComposite;
|
||||
import org.talend.commons.utils.threading.ExecutionLimiter;
|
||||
import org.talend.core.model.process.IConnection;
|
||||
import org.talend.designer.abstractmap.model.table.IDataMapTable;
|
||||
import org.talend.designer.abstractmap.ui.dnd.DraggingInfosPopup;
|
||||
import org.talend.designer.abstractmap.ui.listener.DropTargetOperationListener;
|
||||
@@ -230,6 +231,20 @@ public class MapperUI {
|
||||
dbmsId = input.getMetadataTable().getDbms();
|
||||
}
|
||||
}
|
||||
if(dbmsId == null && mapperModel.getOutputDataMapTables() != null && !mapperModel.getOutputDataMapTables().isEmpty()) {
|
||||
OutputTable output = mapperModel.getOutputDataMapTables().get(0);
|
||||
if (output.getMetadataTable() != null) {
|
||||
dbmsId = output.getMetadataTable().getDbms();
|
||||
}
|
||||
}
|
||||
if(dbmsId == null && mapperManager.getAbstractMapComponent() != null
|
||||
&& !mapperManager.getAbstractMapComponent().getIncomingConnections().isEmpty()){
|
||||
IConnection conn = mapperManager.getAbstractMapComponent().getIncomingConnections().get(0);
|
||||
if(conn.getMetadataTable() != null) {
|
||||
dbmsId = conn.getMetadataTable().getDbms();
|
||||
}
|
||||
}
|
||||
|
||||
tabFolderEditors = new TabFolderEditors(mainSashForm, SWT.BORDER, mapperManager, dbmsId);
|
||||
|
||||
createInputZoneWithTables(mapperModel, uiManager, display);
|
||||
|
||||
@@ -62,9 +62,11 @@ public class DataMapExpressionParser {
|
||||
|
||||
// ((String)globalMap.get("tableName")).columnName
|
||||
private final static String GLOBALMAP_EXPRESSION4 = "(" + GLOBALMAP_PATTERN + COLUMN_PATTERN + ")";
|
||||
|
||||
|
||||
private final static String GLOBALMAP_EXPRESSION5 = "\\s*(\\s*(\\w+)\\s*\\.\\\\\"\\s*(.+?)\\s*\\\\\")\\s*";
|
||||
|
||||
private final static String GLOBALMAP_EXPRESSION = GLOBALMAP_EXPRESSION1 + "|" + GLOBALMAP_EXPRESSION2 + "|"//$NON-NLS-1$//$NON-NLS-2$
|
||||
+ GLOBALMAP_EXPRESSION3 + "|" + GLOBALMAP_EXPRESSION4;//$NON-NLS-1$
|
||||
+ GLOBALMAP_EXPRESSION3 + "|" + GLOBALMAP_EXPRESSION4 + "|" + GLOBALMAP_EXPRESSION5;//$NON-NLS-1$
|
||||
|
||||
private final static String EXPRESSION_PATTERN = "(\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*)" //$NON-NLS-1$
|
||||
+ "|(\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*)" //$NON-NLS-1$
|
||||
@@ -143,6 +145,10 @@ public class DataMapExpressionParser {
|
||||
} else if (matchResult.group(35) != null) {
|
||||
// ((String)globalMap.get("tableName")).columnName
|
||||
location = new TableEntryLocation(matchResult.group(36), matchResult.group(38));
|
||||
}else if (matchResult.group(39) != null) {
|
||||
// table.\"column\"
|
||||
// Case NVL(Keys.\"ORG_SCD_ID\",-99) When -99 Then 'N' Else 'Y' End
|
||||
location = new TableEntryLocation(matchResult.group(40), matchResult.group(41));
|
||||
}
|
||||
if (location != null) {
|
||||
resultList.add(location);
|
||||
|
||||
@@ -478,12 +478,18 @@ public class MapperComponent extends AbstractMapComponent implements IHashableIn
|
||||
ExternalMapperData data = mapperMain.buildExternalData();
|
||||
if (mapperMain != null && data != null) {
|
||||
if (externalData != null) {
|
||||
this.externalData = data;// fwang fixed bug TDI-8027
|
||||
if(!isConnectionEmpty()) {
|
||||
this.externalData = data;// fwang fixed bug TDI-8027
|
||||
}
|
||||
MapperHelper.saveDataToEmf(data, emfMapperData);
|
||||
}
|
||||
}
|
||||
return emfMapperData;
|
||||
}
|
||||
|
||||
private boolean isConnectionEmpty() {
|
||||
return getIncomingConnections().isEmpty() && getOutgoingConnections().isEmpty();
|
||||
}
|
||||
|
||||
public void renameInputConnection(String oldConnectionName, String newConnectionName) {
|
||||
if (oldConnectionName == null || newConnectionName == null) {
|
||||
|
||||
@@ -507,6 +507,8 @@ public class CompleteDropTargetTableListener extends DefaultDropTargetListener {
|
||||
|
||||
uiManager.selectLinks(dataMapTableViewTarget, selectedEntries, true, false);
|
||||
dataMapTableViewTarget.checkChangementsAfterEntryModifiedOrAdded(false);
|
||||
// refresh for cell data disappear on MAC
|
||||
tableViewerCreatorTarget.getTableViewer().refresh();
|
||||
tableViewerCreatorTarget.getTable().setFocus();
|
||||
|
||||
uiManager.setDragging(false);
|
||||
|
||||
@@ -48,6 +48,9 @@ import org.talend.core.ui.metadata.editor.MetadataToolbarEditorView;
|
||||
import org.talend.designer.mapper.MapperMain;
|
||||
import org.talend.designer.mapper.i18n.Messages;
|
||||
import org.talend.designer.mapper.managers.MapperManager;
|
||||
import org.talend.designer.mapper.model.table.InputTable;
|
||||
import org.talend.designer.mapper.model.table.OutputTable;
|
||||
import org.talend.designer.mapper.ui.visualmap.table.DataMapTableView;
|
||||
|
||||
/**
|
||||
* DOC amaumont class global comment. Detailled comment <br/>
|
||||
@@ -158,8 +161,20 @@ public class TabFolderEditors extends CTabFolder {
|
||||
|
||||
};
|
||||
|
||||
IExtendedButtonListener afterCommandListener = new IExtendedButtonListener() {
|
||||
|
||||
public void handleEvent(ExtendedButtonEvent event) {
|
||||
List<InputTable> inputTablesList = mapperManager.getInputTables();
|
||||
for (InputTable inputTable : inputTablesList) {
|
||||
DataMapTableView view = mapperManager.retrieveAbstractDataMapTableView(inputTable);
|
||||
view.getTableViewerCreatorForColumns().getTableViewer().refresh();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (ExtendedPushButton extendedPushButton : inputToolBarButtons) {
|
||||
extendedPushButton.addListener(beforeCommandListenerForInputButtons, true);
|
||||
extendedPushButton.addListener(afterCommandListener, false);
|
||||
}
|
||||
|
||||
this.addDisposeListener(new DisposeListener() {
|
||||
@@ -197,8 +212,20 @@ public class TabFolderEditors extends CTabFolder {
|
||||
|
||||
};
|
||||
|
||||
IExtendedButtonListener afterCommandListener = new IExtendedButtonListener() {
|
||||
|
||||
public void handleEvent(ExtendedButtonEvent event) {
|
||||
List<OutputTable> outputTablesList = mapperManager.getOutputTables();
|
||||
for (OutputTable outputTable : outputTablesList) {
|
||||
DataMapTableView view = mapperManager.retrieveAbstractDataMapTableView(outputTable);
|
||||
view.getTableViewerCreatorForColumns().getTableViewer().refresh();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (ExtendedPushButton extendedPushButton : outputToolBarButtons) {
|
||||
extendedPushButton.addListener(beforeCommandListenerForOutputButtons, true);
|
||||
extendedPushButton.addListener(afterCommandListener, false);
|
||||
if (extendedPushButton instanceof RemovePushButton && !mapperManager.componentIsReadOnly()) {
|
||||
removeButton = (RemovePushButtonForExtendedTable) extendedPushButton;
|
||||
}
|
||||
|
||||
@@ -1399,7 +1399,7 @@ public abstract class DataMapTableView extends Composite implements IDataMapTabl
|
||||
if (mapperManager.componentIsReadOnly()) {
|
||||
metadataEditorView.setReadOnly(true);
|
||||
} else {
|
||||
metadataEditorView.setReadOnly(isRepository || metadataEditorView.isReadOnly());
|
||||
metadataEditorView.setReadOnly(isRepository);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
<directory>${project.build.outputDirectory}</directory>
|
||||
<outputDirectory>${file.separator}</outputDirectory>
|
||||
<includes>
|
||||
<include>${talend.job.path}/**</include>
|
||||
<include>${talend.job.path}/**/*.class</include>
|
||||
<include>${talend.job.path}/**/*.wsdl</include>
|
||||
<include>__tdm/**</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
<directory>${project.build.outputDirectory}</directory>
|
||||
<outputDirectory>${file.separator}</outputDirectory>
|
||||
<includes>
|
||||
<include>${talend.job.path}/**</include>
|
||||
<include>${talend.job.path}/**/*.class</include>
|
||||
<include>${talend.job.path}/**/*.wsdl</include>
|
||||
<include>__tdm/**</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
|
||||
@@ -112,6 +112,9 @@ public abstract class AbstractPublishJobAction implements IRunnableWithProgress
|
||||
// TDI-32861, because for publish job, so means, must be binaries
|
||||
exportChoiceMap.put(ExportChoice.binaries, true);
|
||||
exportChoiceMap.put(ExportChoice.includeLibs, true);
|
||||
|
||||
// TESB-26145/TESB-26086 adding context to published job
|
||||
exportChoiceMap.put(ExportChoice.needContext, true);
|
||||
|
||||
ProcessItem processItem = (ProcessItem) node.getObject().getProperty().getItem();
|
||||
exportItemForDQComponent(processItem);
|
||||
|
||||
@@ -712,7 +712,19 @@ public class DefaultRunProcessService implements IRunProcessService {
|
||||
|
||||
@Override
|
||||
public ITalendProcessJavaProject getTalendCodeJavaProject(ERepositoryObjectType type, String projectTechName) {
|
||||
return TalendJavaProjectManager.getTalendCodeJavaProject(type, projectTechName);
|
||||
ITalendProcessJavaProject codeProject = TalendJavaProjectManager.getTalendCodeJavaProject(type, projectTechName);
|
||||
if (codeProject == null) {
|
||||
// try to recover from any damage of pom.
|
||||
try {
|
||||
AggregatorPomsHelper helper = new AggregatorPomsHelper(projectTechName);
|
||||
IFile pomFile = helper.getCodeFolder(type).getFile(TalendMavenConstants.POM_FILE_NAME);
|
||||
helper.updateCodeProjectPom(new NullProgressMonitor(), type, pomFile);
|
||||
codeProject = TalendJavaProjectManager.getTalendCodeJavaProject(type, projectTechName);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
return codeProject;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -786,7 +798,7 @@ public class DefaultRunProcessService implements IRunProcessService {
|
||||
for (ProjectReference ref : references) {
|
||||
initRefPoms(new Project(ref.getReferencedProject()));
|
||||
}
|
||||
helper.updateRefProjectModules(references);
|
||||
helper.updateRefProjectModules(references, monitor);
|
||||
helper.updateCodeProjects(monitor, true);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
@@ -813,13 +825,17 @@ public class DefaultRunProcessService implements IRunProcessService {
|
||||
if (ProcessUtils.isRequiredBeans(null, refProject)) {
|
||||
installRefCodeProject(ERepositoryObjectType.valueOf("BEANS"), refHelper, monitor); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
deleteRefProjects(refProject, refHelper);
|
||||
|
||||
}
|
||||
|
||||
private void installRefCodeProject(ERepositoryObjectType codeType, AggregatorPomsHelper refHelper, IProgressMonitor monitor)
|
||||
throws Exception, CoreException {
|
||||
if (!refHelper.getProjectRootPom().exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String projectTechName = refHelper.getProjectTechName();
|
||||
ITalendProcessJavaProject codeProject = TalendJavaProjectManager.getExistingTalendCodeProject(codeType, projectTechName);
|
||||
if (codeProject != null) {
|
||||
@@ -828,6 +844,35 @@ public class DefaultRunProcessService implements IRunProcessService {
|
||||
argumentsMap.put(TalendProcessArgumentConstant.ARG_GOAL, TalendMavenConstants.GOAL_INSTALL);
|
||||
argumentsMap.put(TalendProcessArgumentConstant.ARG_PROGRAM_ARGUMENTS, TalendMavenConstants.ARG_MAIN_SKIP);
|
||||
codeProject.buildModules(monitor, null, argumentsMap);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteRefProjects(Project refProject, AggregatorPomsHelper refHelper) throws Exception {
|
||||
IProgressMonitor monitor = new NullProgressMonitor();
|
||||
|
||||
deleteRefProject(ERepositoryObjectType.ROUTINES, refHelper, monitor);
|
||||
|
||||
if (ProcessUtils.isRequiredPigUDFs(null, refProject)) {
|
||||
deleteRefProject(ERepositoryObjectType.PIG_UDF, refHelper, monitor);
|
||||
}
|
||||
|
||||
if (ProcessUtils.isRequiredBeans(null, refProject)) {
|
||||
deleteRefProject(ERepositoryObjectType.valueOf("BEANS"), refHelper, monitor); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void deleteRefProject(ERepositoryObjectType codeType, AggregatorPomsHelper refHelper, IProgressMonitor monitor)
|
||||
throws Exception, CoreException {
|
||||
|
||||
if (!refHelper.getProjectRootPom().exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String projectTechName = refHelper.getProjectTechName();
|
||||
ITalendProcessJavaProject codeProject = TalendJavaProjectManager.getExistingTalendCodeProject(codeType, projectTechName);
|
||||
|
||||
if (codeProject != null) {
|
||||
codeProject.getProject().delete(false, true, monitor);
|
||||
TalendJavaProjectManager.removeFromCodeJavaProjects(codeType, projectTechName);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ package org.talend.designer.runprocess;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -31,7 +32,6 @@ import org.talend.commons.exception.CommonExceptionHandler;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.exception.SystemException;
|
||||
import org.talend.commons.ui.runtime.exception.MessageBoxExceptionHandler;
|
||||
import org.talend.core.CorePlugin;
|
||||
import org.talend.core.model.process.IContainerEntry;
|
||||
import org.talend.core.model.process.IProcess;
|
||||
@@ -61,15 +61,17 @@ public class JobErrorsChecker {
|
||||
|
||||
public static List<IContainerEntry> getErrors() {
|
||||
List<IContainerEntry> input = new ArrayList<IContainerEntry>();
|
||||
|
||||
if(LastGenerationInfo.getInstance() == null ||
|
||||
LastGenerationInfo.getInstance().getLastMainJob() == null) {
|
||||
return input;
|
||||
}
|
||||
try {
|
||||
Item item = null;
|
||||
IProxyRepositoryFactory proxyRepositoryFactory = CorePlugin.getDefault().getRepositoryService()
|
||||
.getProxyRepositoryFactory();
|
||||
ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
|
||||
IProxyRepositoryFactory proxyRepositoryFactory =
|
||||
CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
|
||||
ITalendSynchronizer synchronizer =
|
||||
CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
|
||||
|
||||
Set<String> jobIds = new HashSet<String>();
|
||||
HashSet<JobInfo> jobInfos = new HashSet<>();
|
||||
@@ -94,14 +96,15 @@ public class JobErrorsChecker {
|
||||
}
|
||||
jobIds.add(item.getProperty().getId());
|
||||
|
||||
// Property property = process.getProperty();
|
||||
Problems.addJobRoutineFile(sourceFile, ProblemType.JOB, item, true);
|
||||
}
|
||||
if (!CommonsPlugin.isHeadless()) {
|
||||
List<IRepositoryViewObject> routinesObjects = proxyRepositoryFactory.getAll(ERepositoryObjectType.ROUTINES, false);
|
||||
Set<String> dependentRoutines = LastGenerationInfo.getInstance().getRoutinesNeededWithSubjobPerJob(
|
||||
LastGenerationInfo.getInstance().getLastMainJob().getJobId(),
|
||||
LastGenerationInfo.getInstance().getLastMainJob().getJobVersion());
|
||||
List<IRepositoryViewObject> routinesObjects =
|
||||
proxyRepositoryFactory.getAll(ERepositoryObjectType.ROUTINES, false);
|
||||
Set<String> dependentRoutines = LastGenerationInfo
|
||||
.getInstance()
|
||||
.getRoutinesNeededWithSubjobPerJob(LastGenerationInfo.getInstance().getLastMainJob().getJobId(),
|
||||
LastGenerationInfo.getInstance().getLastMainJob().getJobVersion());
|
||||
if (routinesObjects != null) {
|
||||
for (IRepositoryViewObject obj : routinesObjects) {
|
||||
Property property = obj.getProperty();
|
||||
@@ -110,7 +113,7 @@ public class JobErrorsChecker {
|
||||
IFile routineFile = synchronizer.getFile(routinesitem);
|
||||
Problems.addJobRoutineFile(routineFile, ProblemType.ROUTINE, routinesitem, true);
|
||||
} else {
|
||||
Problems.clearAllComliationError(property.getLabel());
|
||||
Problems.clearAllComliationError(property.getLabel());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,11 +156,11 @@ public class JobErrorsChecker {
|
||||
|
||||
public static boolean checkExportErrors(IStructuredSelection selection, boolean isJob) {
|
||||
if (!selection.isEmpty()) {
|
||||
final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService()
|
||||
.createRoutineSynchronizer();
|
||||
final ITalendSynchronizer synchronizer =
|
||||
CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
|
||||
Set<String> jobIds = new HashSet<String>();
|
||||
|
||||
List<RepositoryNode> nodes = selection.toList();
|
||||
List<RepositoryNode> nodes = extractNodes(selection);
|
||||
if (nodes.size() > 1) {
|
||||
// in case it's a multiple export, only check the status of the latest job to export
|
||||
for (RepositoryNode node : nodes) {
|
||||
@@ -189,22 +192,35 @@ public class JobErrorsChecker {
|
||||
}
|
||||
if (ret) {
|
||||
if (isJob) {
|
||||
throw new ProcessorException(Messages.getString("JobErrorsChecker_compile_errors") + '\n' + //$NON-NLS-1$
|
||||
Messages.getString("JobErrorsChecker_compile_error_content", item.getProperty() //$NON-NLS-1$
|
||||
.getLabel()) + '\n' + message);
|
||||
throw new ProcessorException(
|
||||
Messages.getString("JobErrorsChecker_compile_errors") + '\n' + //$NON-NLS-1$
|
||||
Messages
|
||||
.getString("JobErrorsChecker_compile_error_content", //$NON-NLS-1$
|
||||
item.getProperty().getLabel())
|
||||
+ '\n' + message);
|
||||
} else {
|
||||
throw new ProcessorException(Messages.getString("CamelJobErrorsChecker_compile_errors") + '\n' + //$NON-NLS-1$
|
||||
Messages.getString("CamelJobErrorsChecker_compile_error_content", item.getProperty() //$NON-NLS-1$
|
||||
.getLabel()) + '\n' + message);
|
||||
throw new ProcessorException(
|
||||
Messages.getString("CamelJobErrorsChecker_compile_errors") + '\n' + //$NON-NLS-1$
|
||||
Messages
|
||||
.getString("CamelJobErrorsChecker_compile_error_content", //$NON-NLS-1$
|
||||
item.getProperty().getLabel())
|
||||
+ '\n' + message);
|
||||
}
|
||||
}
|
||||
|
||||
jobIds.add(item.getProperty().getId());
|
||||
|
||||
Problems.addRoutineFile(sourceFile, ProblemType.JOB, item.getProperty().getLabel(), item.getProperty()
|
||||
.getVersion(), true);
|
||||
Problems
|
||||
.addRoutineFile(sourceFile, ProblemType.JOB, item.getProperty().getLabel(),
|
||||
item.getProperty().getVersion(), true);
|
||||
} catch (Exception e) {
|
||||
MessageBoxExceptionHandler.process(e);
|
||||
CommonExceptionHandler.process(e);
|
||||
if (CommonsPlugin.isHeadless()) {
|
||||
// [TESB-8953] avoid SWT invoked and also throw Exception let Command Executor to have
|
||||
// detailed
|
||||
// trace in command status.
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -214,13 +230,12 @@ public class JobErrorsChecker {
|
||||
try {
|
||||
checkLastGenerationHasCompilationError(true);
|
||||
} catch (Exception e) {
|
||||
CommonExceptionHandler.process(e);
|
||||
if (CommonsPlugin.isHeadless()) {
|
||||
CommonExceptionHandler.process(e);
|
||||
// [TESB-8953] avoid SWT invoked and also throw Exception let Command Executor to have detailed
|
||||
// trace in command status.
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
MessageBoxExceptionHandler.process(e);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -249,7 +264,12 @@ public class JobErrorsChecker {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MessageBoxExceptionHandler.process(e);
|
||||
CommonExceptionHandler.process(e);
|
||||
if (CommonsPlugin.isHeadless()) {
|
||||
// [TESB-8953] avoid SWT invoked and also throw Exception let Command Executor to have detailed
|
||||
// trace in command status.
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -264,9 +284,10 @@ public class JobErrorsChecker {
|
||||
boolean hasError = false;
|
||||
boolean isJob = true;
|
||||
Item item = null;
|
||||
final IProxyRepositoryFactory proxyRepositoryFactory = CorePlugin.getDefault().getRepositoryService()
|
||||
.getProxyRepositoryFactory();
|
||||
final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
|
||||
final IProxyRepositoryFactory proxyRepositoryFactory =
|
||||
CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
|
||||
final ITalendSynchronizer synchronizer =
|
||||
CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
|
||||
Integer line = null;
|
||||
String errorMessage = null;
|
||||
try {
|
||||
@@ -299,7 +320,7 @@ public class JobErrorsChecker {
|
||||
// one job
|
||||
final IResource[] members = file.getParent().members();
|
||||
for (IResource member : members) {
|
||||
if (member instanceof IFile && "java".equals(member.getFileExtension())) {
|
||||
if (member instanceof IFile && "java".equals(member.getFileExtension())) { //$NON-NLS-1$
|
||||
IMarker[] markers = ((IFile) member).findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ONE);
|
||||
for (IMarker marker : markers) {
|
||||
Integer lineNr = (Integer) marker.getAttribute(IMarker.LINE_NUMBER);
|
||||
@@ -322,8 +343,9 @@ public class JobErrorsChecker {
|
||||
}
|
||||
}
|
||||
if (updateProblemsView) {
|
||||
Problems.addRoutineFile(file, ProblemType.JOB, item.getProperty().getLabel(),
|
||||
item.getProperty().getVersion(), true);
|
||||
Problems
|
||||
.addRoutineFile(file, ProblemType.JOB, item.getProperty().getLabel(),
|
||||
item.getProperty().getVersion(), true);
|
||||
}
|
||||
if (hasError) {
|
||||
break;
|
||||
@@ -335,17 +357,17 @@ public class JobErrorsChecker {
|
||||
}
|
||||
if (hasError && item != null) {
|
||||
if (isJob) {
|
||||
throw new ProcessorException(Messages.getString("JobErrorsChecker_compile_errors") + " " + '\n' + //$NON-NLS-1$
|
||||
Messages.getString("JobErrorsChecker_compile_error_message", item.getProperty().getLabel()) + '\n' //$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + '\n' //$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage + '\n' //$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_jvmmessage")); //$NON-NLS-1$
|
||||
throw new ProcessorException(Messages.getString("JobErrorsChecker_compile_errors") + ' ' + '\n' + //$NON-NLS-1$
|
||||
Messages.getString("JobErrorsChecker_compile_error_message", item.getProperty().getLabel()) //$NON-NLS-1$
|
||||
+ '\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + '\n' //$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage //$NON-NLS-1$
|
||||
+ '\n' + Messages.getString("JobErrorsChecker_compile_error_jvmmessage")); //$NON-NLS-1$
|
||||
} else {
|
||||
throw new ProcessorException(Messages.getString("CamelJobErrorsChecker_compile_errors") + " " + '\n' + //$NON-NLS-1$
|
||||
Messages.getString("JobErrorsChecker_compile_error_message", item.getProperty().getLabel()) + '\n' //$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + '\n' //$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage + '\n' //$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_jvmmessage")); //$NON-NLS-1$
|
||||
throw new ProcessorException(Messages.getString("CamelJobErrorsChecker_compile_errors") + ' ' + '\n' + //$NON-NLS-1$
|
||||
Messages.getString("JobErrorsChecker_compile_error_message", item.getProperty().getLabel()) //$NON-NLS-1$
|
||||
+ '\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + '\n' //$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage //$NON-NLS-1$
|
||||
+ '\n' + Messages.getString("JobErrorsChecker_compile_error_jvmmessage")); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,6 +378,7 @@ public class JobErrorsChecker {
|
||||
}
|
||||
|
||||
private static void checkRoutinesCompilationError() throws ProcessorException {
|
||||
|
||||
if(LastGenerationInfo.getInstance() == null || LastGenerationInfo.getInstance().getLastMainJob() == null) {
|
||||
return;
|
||||
}
|
||||
@@ -368,32 +391,35 @@ public class JobErrorsChecker {
|
||||
for (Problem p : errors) {
|
||||
if (p instanceof TalendProblem) {
|
||||
TalendProblem talendProblem = (TalendProblem) p;
|
||||
if (talendProblem.getType() == ProblemType.ROUTINE && dependentRoutines.contains(talendProblem.getJavaUnitName())) {
|
||||
if (talendProblem.getType() == ProblemType.ROUTINE
|
||||
&& dependentRoutines.contains(talendProblem.getJavaUnitName())) {
|
||||
int line = talendProblem.getLineNumber();
|
||||
String errorMessage = talendProblem.getDescription();
|
||||
throw new ProcessorException(Messages.getString(
|
||||
"JobErrorsChecker_routines_compile_errors", talendProblem.getJavaUnitName()) + '\n'//$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + '\n' //$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage); //$NON-NLS-1$
|
||||
throw new ProcessorException(Messages
|
||||
.getString("JobErrorsChecker_routines_compile_errors", talendProblem.getJavaUnitName()) //$NON-NLS-1$
|
||||
+ '\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + '\n' //$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' //$NON-NLS-1$
|
||||
+ errorMessage);
|
||||
}
|
||||
} else {
|
||||
// for now not to check components errors when building jobs in studio/commandline
|
||||
// throw new ProcessorException(Messages.getString("JobErrorsChecker_jobDesign_errors", p.getType().getTypeName(), //$NON-NLS-1$
|
||||
// p.getJobInfo().getJobName(), p.getComponentName(), p.getDescription()));
|
||||
// throw new ProcessorException(Messages.getString("JobErrorsChecker_jobDesign_errors",
|
||||
// p.getType().getTypeName(), //$NON-NLS-1$
|
||||
// p.getJobInfo().getJobName(), p.getComponentName(), p.getDescription()));
|
||||
}
|
||||
}
|
||||
|
||||
// if can't find the routines problem, try to check the file directly(mainly for commandline)
|
||||
try {
|
||||
final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService()
|
||||
.createRoutineSynchronizer();
|
||||
final ITalendSynchronizer synchronizer =
|
||||
CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
|
||||
IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
|
||||
List<IRepositoryViewObject> routinesObjects = factory.getAll(ERepositoryObjectType.ROUTINES, false);
|
||||
if (routinesObjects != null) {
|
||||
for (IRepositoryViewObject obj : routinesObjects) {
|
||||
Property property = obj.getProperty();
|
||||
if (!dependentRoutines.contains(property.getLabel())) {
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
Item routinesitem = property.getItem();
|
||||
IFile routinesFile = synchronizer.getFile(routinesitem);
|
||||
@@ -407,10 +433,12 @@ public class JobErrorsChecker {
|
||||
if (lineNr != null && message != null && severity != null && start != null && end != null) {
|
||||
switch (severity) {
|
||||
case IMarker.SEVERITY_ERROR:
|
||||
throw new ProcessorException(
|
||||
Messages.getString("JobErrorsChecker_routines_compile_errors", property.getLabel()) + '\n'//$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + lineNr + '\n' //$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + message); //$NON-NLS-1$
|
||||
throw new ProcessorException(Messages
|
||||
.getString("JobErrorsChecker_routines_compile_errors", property.getLabel()) //$NON-NLS-1$
|
||||
+ '\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' //$NON-NLS-1$
|
||||
+ lineNr + '\n'
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") //$NON-NLS-1$
|
||||
+ ':' + ' ' + message);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -427,11 +455,11 @@ public class JobErrorsChecker {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected static void checkSubJobMultipleVersionsError() throws ProcessorException {
|
||||
if(LastGenerationInfo.getInstance() == null || LastGenerationInfo.getInstance().getLastGeneratedjobs() == null) {
|
||||
return;
|
||||
}
|
||||
if (LastGenerationInfo.getInstance() == null
|
||||
|| LastGenerationInfo.getInstance().getLastGeneratedjobs() == null) {
|
||||
return;
|
||||
}
|
||||
Set<JobInfo> jobInfos = LastGenerationInfo.getInstance().getLastGeneratedjobs();
|
||||
Map<String, Set<String>> jobInfoMap = new HashMap<>();
|
||||
for (JobInfo jobInfo : jobInfos) {
|
||||
@@ -458,4 +486,14 @@ public class JobErrorsChecker {
|
||||
}
|
||||
}
|
||||
|
||||
private static List<RepositoryNode> extractNodes(IStructuredSelection selection) {
|
||||
List<RepositoryNode> nodes = new ArrayList<>();
|
||||
for (Iterator<?> iterator = selection.iterator(); iterator.hasNext();) {
|
||||
Object o = iterator.next();
|
||||
if (o instanceof RepositoryNode)
|
||||
nodes.add((RepositoryNode) o);
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1401,10 +1401,12 @@ public class JavaProcessor extends AbstractJavaProcessor implements IJavaBreakpo
|
||||
} else {
|
||||
for (ModuleNeeded neededModule : neededModules) {
|
||||
MavenArtifact artifact = MavenUrlHelper.parseMvnUrl(neededModule.getMavenUri());
|
||||
if ("sapjco3".equals(artifact.getArtifactId())) { //$NON-NLS-1$
|
||||
String jarPath = JavaProcessorUtilities.getJavaProjectLibFolder2().getFile("sapjco3.jar").getLocation() //$NON-NLS-1$
|
||||
boolean isSapidoc3 = "sapidoc3".equals(artifact.getArtifactId());
|
||||
if ("sapjco3".equals(artifact.getArtifactId()) || isSapidoc3) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
String jarPath = JavaProcessorUtilities.getJavaProjectLibFolder2().getFile(artifact.getArtifactId() + ".jar") //$NON-NLS-1$
|
||||
.getLocation()
|
||||
.toPortableString();
|
||||
if (compareSapjco3Version(jarPath) > 0) {
|
||||
if (compareSapjco3Version(jarPath) > 0 || isSapidoc3) {
|
||||
libPath.append(jarPath).append(classPathSeparator);
|
||||
} else {
|
||||
libPath.append(PomUtil.getAbsArtifactPathAsCP(artifact)).append(classPathSeparator);
|
||||
|
||||
@@ -479,6 +479,11 @@ public class TalendJavaProjectManager {
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
|
||||
for (IProject project : projects) {
|
||||
if (project.hasNature("com.oaklandsw.transform.runtime.nature")) { //$NON-NLS-1$
|
||||
// never delete TDM Builtin, Examples and Examples EDI project ref
|
||||
// com.oaklandsw.data.transform.builtin
|
||||
continue;
|
||||
}
|
||||
if (project.getLocation() == null || !project.getLocation().toFile().exists()
|
||||
|| !project.getFile(IProjectDescription.DESCRIPTION_FILE_NAME).getLocation().toFile().exists()) {
|
||||
project.delete(false, true, monitor);
|
||||
@@ -563,6 +568,8 @@ public class TalendJavaProjectManager {
|
||||
if (processor instanceof MavenJavaProcessor) {
|
||||
LastGenerationInfo.getInstance().clearModulesNeededWithSubjobPerJob();
|
||||
LastGenerationInfo.getInstance().getHighPriorityModuleNeeded().clear();
|
||||
// Need to clear modules per job cache
|
||||
LastGenerationInfo.getInstance().clearModulesNeededPerJob();
|
||||
// Gen poms only
|
||||
((MavenJavaProcessor) processor).generatePom(option);
|
||||
}
|
||||
|
||||
@@ -349,7 +349,8 @@ public class MavenJavaProcessor extends JavaProcessor {
|
||||
if (!isMainJob && isGoalInstall) {
|
||||
if (!buildCacheManager.isJobBuild(getProperty())) {
|
||||
deleteExistedJobJarFile(talendJavaProject);
|
||||
if ("ROUTE".equalsIgnoreCase(getBuildType(getProperty())) && project != null &&
|
||||
String buildType = getBuildType(getProperty());
|
||||
if (("ROUTE".equalsIgnoreCase(buildType) || "OSGI".equalsIgnoreCase(buildType)) && project != null &&
|
||||
ERepositoryObjectType.PROCESS.equals(ERepositoryObjectType.getType(getProperty()))) {
|
||||
// TESB-23870
|
||||
// child routes job project must be compiled explicitly for
|
||||
|
||||
@@ -125,6 +125,8 @@ public class ProcessChangeListener implements PropertyChangeListener {
|
||||
// version change, will create new item
|
||||
// create new job project.
|
||||
TalendJavaProjectManager.generatePom(property.getItem());
|
||||
AggregatorPomsHelper helper = new AggregatorPomsHelper();
|
||||
helper.syncParentJobPomsForPropertyChange(property);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.Priority;
|
||||
import org.apache.oro.text.regex.MalformedPatternException;
|
||||
import org.apache.oro.text.regex.MatchResult;
|
||||
import org.apache.oro.text.regex.Pattern;
|
||||
@@ -54,8 +55,9 @@ import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.talend.commons.CommonsPlugin;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.commons.ui.swt.formtools.Form;
|
||||
import org.talend.commons.ui.swt.formtools.LabelledCombo;
|
||||
import org.talend.commons.ui.swt.formtools.LabelledFileField;
|
||||
@@ -79,6 +81,7 @@ import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.json.i18n.Messages;
|
||||
import org.talend.repository.json.util.JSONUtil;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.xml.TreePopulator;
|
||||
|
||||
import orgomg.cwm.resource.record.RecordFactory;
|
||||
import orgomg.cwm.resource.record.RecordFile;
|
||||
|
||||
@@ -151,7 +154,7 @@ public class JSONFileOutputStep1Form extends AbstractJSONFileStepForm {
|
||||
}
|
||||
if (JSONFileOutputStep1Form.this.tempPath == null) {
|
||||
if (jsonXmlPath != null && !jsonXmlPath.equals("")) {
|
||||
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(jsonXmlPath);
|
||||
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(jsonXmlPath, getConnection().getEncoding());
|
||||
} else {
|
||||
JSONFileOutputStep1Form.this.tempPath = "";
|
||||
}
|
||||
@@ -315,7 +318,7 @@ public class JSONFileOutputStep1Form extends AbstractJSONFileStepForm {
|
||||
|
||||
List<FOXTreeNode> rootFoxTreeNodes = null;
|
||||
if (JSONFileOutputStep1Form.this.tempPath == null) {
|
||||
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(text);
|
||||
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(text, getConnection().getEncoding());
|
||||
}
|
||||
if (treeNode == null) {
|
||||
rootFoxTreeNodes = TreeUtil.getFoxTreeNodes(JSONFileOutputStep1Form.this.tempPath);
|
||||
@@ -362,12 +365,12 @@ public class JSONFileOutputStep1Form extends AbstractJSONFileStepForm {
|
||||
}
|
||||
// getConnection().setJSONFilePath(PathUtils.getPortablePath(JSONXsdFilePath.getText()));
|
||||
if (JSONFileOutputStep1Form.this.tempPath == null) {
|
||||
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(text);
|
||||
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(text, getConnection().getEncoding());
|
||||
}
|
||||
File file = new File(text);
|
||||
if (file.exists()) {
|
||||
List<ATreeNode> treeNodes = new ArrayList<ATreeNode>();
|
||||
valid = treePopulator.populateTree(JSONUtil.changeJsonToXml(text), treeNode);
|
||||
valid = treePopulator.populateTree(JSONUtil.changeJsonToXml(text, getConnection().getEncoding()), treeNode);
|
||||
checkFieldsValue();
|
||||
if (!valid) {
|
||||
return;
|
||||
@@ -391,130 +394,7 @@ public class JSONFileOutputStep1Form extends AbstractJSONFileStepForm {
|
||||
|
||||
@Override
|
||||
public void modifyText(ModifyEvent event) {
|
||||
String text = jsonFilePath.getText();
|
||||
if (isContextMode()) {
|
||||
ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(
|
||||
connectionItem.getConnection(), true);
|
||||
text = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType, text));
|
||||
}
|
||||
|
||||
if (getConnection().getJSONFilePath() != null && !getConnection().getJSONFilePath().equals(text)) {
|
||||
getConnection().getLoop().clear();
|
||||
getConnection().getRoot().clear();
|
||||
getConnection().getGroup().clear();
|
||||
xsdPathChanged = true;
|
||||
} else {
|
||||
xsdPathChanged = false;
|
||||
}
|
||||
if (Path.fromOSString(jsonFilePath.getText()).toFile().isFile()) {
|
||||
getConnection().setJSONFilePath(PathUtils.getPortablePath(jsonFilePath.getText()));
|
||||
} else {
|
||||
getConnection().setJSONFilePath(jsonFilePath.getText());
|
||||
}
|
||||
|
||||
// updateConnection(text);
|
||||
|
||||
StringBuilder fileContent = new StringBuilder();
|
||||
BufferedReader in = null;
|
||||
File file = null;
|
||||
if (tempJSONPath != null && getConnection().getFileContent() != null
|
||||
&& getConnection().getFileContent().length > 0 && !isModifing) {
|
||||
file = new File(tempJSONPath);
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e2) {
|
||||
ExceptionHandler.process(e2);
|
||||
}
|
||||
FileOutputStream outStream;
|
||||
try {
|
||||
outStream = new FileOutputStream(file);
|
||||
outStream.write(getConnection().getFileContent());
|
||||
outStream.close();
|
||||
} catch (FileNotFoundException e1) {
|
||||
ExceptionHandler.process(e1);
|
||||
} catch (IOException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
file = new File(text);
|
||||
}
|
||||
String str;
|
||||
try {
|
||||
Charset guessCharset = CharsetToolkit.guessEncoding(file, 4096);
|
||||
in = new BufferedReader(new InputStreamReader(new FileInputStream(file), guessCharset.displayName()));
|
||||
|
||||
while ((str = in.readLine()) != null) {
|
||||
fileContent.append(str + "\n");
|
||||
// for encoding
|
||||
if (str.contains("encoding")) {
|
||||
String regex = "^<\\?JSON\\s*version=\\\"[^\\\"]*\\\"\\s*encoding=\\\"([^\\\"]*)\\\"\\?>$";
|
||||
Perl5Compiler compiler = new Perl5Compiler();
|
||||
Perl5Matcher matcher = new Perl5Matcher();
|
||||
Pattern pattern = null;
|
||||
try {
|
||||
pattern = compiler.compile(regex);
|
||||
if (matcher.contains(str, pattern)) {
|
||||
MatchResult matchResult = matcher.getMatch();
|
||||
if (matchResult != null) {
|
||||
encoding = matchResult.group(1);
|
||||
}
|
||||
}
|
||||
} catch (MalformedPatternException malE) {
|
||||
ExceptionHandler.process(malE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fileContentText.setText(new String(fileContent));
|
||||
|
||||
} catch (Exception e) {
|
||||
String msgError = "File" + " \"" + jsonFilePath.getText().replace("\\\\", "\\") + "\"\n";
|
||||
if (e instanceof FileNotFoundException) {
|
||||
msgError = msgError + "is not found";
|
||||
} else if (e instanceof EOFException) {
|
||||
msgError = msgError + "have an incorrect character EOF";
|
||||
} else if (e instanceof IOException) {
|
||||
msgError = msgError + "is locked by another soft";
|
||||
} else {
|
||||
msgError = msgError + "doesn't exist";
|
||||
}
|
||||
fileContentText.setText(msgError);
|
||||
if (!isReadOnly()) {
|
||||
updateStatus(IStatus.ERROR, msgError);
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
ExceptionHandler.process(exception);
|
||||
}
|
||||
}
|
||||
if (getConnection().getEncoding() == null || "".equals(getConnection().getEncoding())) {
|
||||
getConnection().setEncoding(encoding);
|
||||
if (encoding != null && !"".equals(encoding)) {
|
||||
encodingCombo.setText(encoding);
|
||||
} else {
|
||||
encodingCombo.setText("UTF-8");
|
||||
}
|
||||
}
|
||||
|
||||
// if (tempJSONXsdPath != null && getConnection().getFileContent() != null
|
||||
// && getConnection().getFileContent().length > 0 && !isModifing) {
|
||||
// valid = treePopulator.populateTree(tempJSONXsdPath, treeNode);
|
||||
// } else {
|
||||
// valid = treePopulator.populateTree(text, treeNode);
|
||||
// }
|
||||
if (file.exists()) {
|
||||
valid = treePopulator.populateTree(JSONUtil.changeJsonToXml(text), treeNode);
|
||||
updateConnection(text);
|
||||
}
|
||||
checkFieldsValue();
|
||||
isModifing = true;
|
||||
validateJsonFile();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -523,6 +403,16 @@ public class JSONFileOutputStep1Form extends AbstractJSONFileStepForm {
|
||||
@Override
|
||||
public void modifyText(ModifyEvent e) {
|
||||
getConnection().setEncoding(encodingCombo.getText());
|
||||
String encoding = getConnection().getEncoding();
|
||||
try {
|
||||
Charset charSet = Charset.forName(encoding);
|
||||
if (charSet != null) {
|
||||
validateJsonFile();
|
||||
return;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// ignore
|
||||
}
|
||||
checkFieldsValue();
|
||||
}
|
||||
});
|
||||
@@ -540,7 +430,8 @@ public class JSONFileOutputStep1Form extends AbstractJSONFileStepForm {
|
||||
labelLimitation.setToolTipText(MessageFormat.format(Messages.JSONLimitToolTip, str));
|
||||
}
|
||||
if (JSONFileOutputStep1Form.this.tempPath == null) {
|
||||
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(jsonFilePath.getText());
|
||||
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(jsonFilePath.getText(),
|
||||
getConnection().getEncoding());
|
||||
}
|
||||
|
||||
File file = new File(JSONFileOutputStep1Form.this.tempPath);
|
||||
@@ -779,4 +670,141 @@ public class JSONFileOutputStep1Form extends AbstractJSONFileStepForm {
|
||||
// valid = this.treePopulator.populateTree(tempJSONXsdPath, treeNode);
|
||||
|
||||
}
|
||||
|
||||
private void validateJsonFile() {
|
||||
String text = jsonFilePath.getText();
|
||||
if (isContextMode()) {
|
||||
ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(
|
||||
connectionItem.getConnection(), true);
|
||||
text = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType, text));
|
||||
}
|
||||
|
||||
if (getConnection().getJSONFilePath() != null && !getConnection().getJSONFilePath().equals(text)) {
|
||||
getConnection().getLoop().clear();
|
||||
getConnection().getRoot().clear();
|
||||
getConnection().getGroup().clear();
|
||||
xsdPathChanged = true;
|
||||
} else {
|
||||
xsdPathChanged = false;
|
||||
}
|
||||
if (Path.fromOSString(jsonFilePath.getText()).toFile().isFile()) {
|
||||
getConnection().setJSONFilePath(PathUtils.getPortablePath(jsonFilePath.getText()));
|
||||
} else {
|
||||
getConnection().setJSONFilePath(jsonFilePath.getText());
|
||||
}
|
||||
|
||||
// updateConnection(text);
|
||||
|
||||
StringBuilder fileContent = new StringBuilder();
|
||||
BufferedReader in = null;
|
||||
File file = null;
|
||||
if (tempJSONPath != null && getConnection().getFileContent() != null
|
||||
&& getConnection().getFileContent().length > 0 && !isModifing) {
|
||||
file = new File(tempJSONPath);
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e2) {
|
||||
ExceptionHandler.process(e2);
|
||||
}
|
||||
FileOutputStream outStream;
|
||||
try {
|
||||
outStream = new FileOutputStream(file);
|
||||
outStream.write(getConnection().getFileContent());
|
||||
outStream.close();
|
||||
} catch (FileNotFoundException e1) {
|
||||
ExceptionHandler.process(e1);
|
||||
} catch (IOException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
file = new File(text);
|
||||
}
|
||||
String str;
|
||||
try {
|
||||
Charset guessCharset = null;
|
||||
try {
|
||||
guessCharset = Charset.forName(getConnection().getEncoding());
|
||||
} catch (Exception e) {
|
||||
if (CommonsPlugin.isDebugMode()) {
|
||||
ExceptionHandler.process(e, Priority.INFO);
|
||||
}
|
||||
}
|
||||
if (guessCharset == null) {
|
||||
guessCharset = CharsetToolkit.guessEncoding(file, 4096);
|
||||
}
|
||||
in = new BufferedReader(new InputStreamReader(new FileInputStream(file), guessCharset.displayName()));
|
||||
|
||||
while ((str = in.readLine()) != null) {
|
||||
fileContent.append(str + "\n");
|
||||
// for encoding
|
||||
if (str.contains("encoding")) {
|
||||
String regex = "^<\\?JSON\\s*version=\\\"[^\\\"]*\\\"\\s*encoding=\\\"([^\\\"]*)\\\"\\?>$";
|
||||
Perl5Compiler compiler = new Perl5Compiler();
|
||||
Perl5Matcher matcher = new Perl5Matcher();
|
||||
Pattern pattern = null;
|
||||
try {
|
||||
pattern = compiler.compile(regex);
|
||||
if (matcher.contains(str, pattern)) {
|
||||
MatchResult matchResult = matcher.getMatch();
|
||||
if (matchResult != null) {
|
||||
encoding = matchResult.group(1);
|
||||
}
|
||||
}
|
||||
} catch (MalformedPatternException malE) {
|
||||
ExceptionHandler.process(malE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fileContentText.setText(new String(fileContent));
|
||||
|
||||
} catch (Exception e) {
|
||||
String msgError = "File" + " \"" + jsonFilePath.getText().replace("\\\\", "\\") + "\"\n";
|
||||
if (e instanceof FileNotFoundException) {
|
||||
msgError = msgError + "is not found";
|
||||
} else if (e instanceof EOFException) {
|
||||
msgError = msgError + "have an incorrect character EOF";
|
||||
} else if (e instanceof IOException) {
|
||||
msgError = msgError + "is locked by another soft";
|
||||
} else {
|
||||
msgError = msgError + "doesn't exist";
|
||||
}
|
||||
fileContentText.setText(msgError);
|
||||
if (!isReadOnly()) {
|
||||
updateStatus(IStatus.ERROR, msgError);
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
ExceptionHandler.process(exception);
|
||||
}
|
||||
}
|
||||
if (getConnection().getEncoding() == null || "".equals(getConnection().getEncoding())) {
|
||||
getConnection().setEncoding(encoding);
|
||||
if (encoding != null && !"".equals(encoding)) {
|
||||
encodingCombo.setText(encoding);
|
||||
} else {
|
||||
encodingCombo.setText("UTF-8");
|
||||
}
|
||||
}
|
||||
|
||||
// if (tempJSONXsdPath != null && getConnection().getFileContent() != null
|
||||
// && getConnection().getFileContent().length > 0 && !isModifing) {
|
||||
// valid = treePopulator.populateTree(tempJSONXsdPath, treeNode);
|
||||
// } else {
|
||||
// valid = treePopulator.populateTree(text, treeNode);
|
||||
// }
|
||||
if (file.exists()) {
|
||||
valid = treePopulator.populateTree(JSONUtil.changeJsonToXml(text, getConnection().getEncoding()), treeNode);
|
||||
updateConnection(text);
|
||||
}
|
||||
checkFieldsValue();
|
||||
isModifing = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ public class JSONFileStep1Form extends AbstractJSONFileStepForm {
|
||||
if (JSONFileStep1Form.this.wizard.getTempJsonPath() == null
|
||||
|| JSONFileStep1Form.this.wizard.getTempJsonPath().length() == 0) {
|
||||
if (EJsonReadbyMode.XPATH.getValue().equals(JSONFileStep1Form.this.wizard.getReadbyMode())) {
|
||||
tempxml = JSONUtil.changeJsonToXml(jsonFilePath);
|
||||
tempxml = JSONUtil.changeJsonToXml(jsonFilePath, getConnection().getEncoding());
|
||||
} else {
|
||||
tempxml = jsonFilePath;
|
||||
}
|
||||
@@ -271,6 +271,7 @@ public class JSONFileStep1Form extends AbstractJSONFileStepForm {
|
||||
treePopulator.setLimit(limit);
|
||||
this.treePopulator.configureDefaultTreeViewer();
|
||||
if (filePath != null && !filePath.isEmpty()) {
|
||||
this.treePopulator.setEncoding(getConnection().getEncoding());
|
||||
valid = this.treePopulator.populateTree(filePath, treeNode);
|
||||
}
|
||||
}
|
||||
@@ -506,7 +507,7 @@ public class JSONFileStep1Form extends AbstractJSONFileStepForm {
|
||||
if (EJsonReadbyMode.JSONPATH.getValue().equals(readbyMode)) {
|
||||
tempxml = text;
|
||||
} else {
|
||||
tempxml = JSONUtil.changeJsonToXml(text);
|
||||
tempxml = JSONUtil.changeJsonToXml(text, getConnection().getEncoding());
|
||||
}
|
||||
JSONFileStep1Form.this.wizard.setTempJsonPath(tempxml);
|
||||
switchPopulator(readbyMode, tempxml);
|
||||
@@ -518,170 +519,7 @@ public class JSONFileStep1Form extends AbstractJSONFileStepForm {
|
||||
|
||||
@Override
|
||||
public void modifyText(final ModifyEvent e) {
|
||||
String jsonPath = fileFieldJSON.getText();
|
||||
String _jsonPath = jsonPath;
|
||||
if (isContextMode()) {
|
||||
ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(
|
||||
connectionItem.getConnection(), connectionItem.getConnection().getContextName());
|
||||
jsonPath = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType,
|
||||
jsonPath));
|
||||
|
||||
}
|
||||
String text = validateJsonFilePath(jsonPath);
|
||||
if (text == null || text.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String tempxml = null;
|
||||
String readbyMode = JSONFileStep1Form.this.wizard.getReadbyMode();
|
||||
|
||||
if (EJsonReadbyMode.JSONPATH.getValue().equals(readbyMode)) {
|
||||
tempxml = text;
|
||||
} else {
|
||||
tempxml = JSONUtil.changeJsonToXml(text);
|
||||
}
|
||||
File file = new File(text);
|
||||
if (!file.exists()) {
|
||||
file = new File(JSONUtil.tempJSONXsdPath);
|
||||
}
|
||||
JSONFileStep1Form.this.wizard.setTempJsonPath(tempxml);
|
||||
String limitString = commonNodesLimitation.getText();
|
||||
try {
|
||||
limit = Integer.valueOf(limitString);
|
||||
labelLimitation.setToolTipText(MessageFormat.format(Messages.JSONLimitToolTip, limit));
|
||||
} catch (Exception excpt) {
|
||||
// nothing need to do
|
||||
}
|
||||
switchPopulator(readbyMode, tempxml);
|
||||
// }
|
||||
// add for bug TDI-20432
|
||||
checkFieldsValue();
|
||||
// }
|
||||
|
||||
// String text = fileFieldJSON.getText();
|
||||
// File temp = new File(text);
|
||||
// if (!temp.exists()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (getConnection().getJSONFilePath() != null && !getConnection().getJSONFilePath().equals(text)) {
|
||||
getConnection().getLoop().clear();
|
||||
xsdPathChanged = true;
|
||||
} else {
|
||||
xsdPathChanged = false;
|
||||
}
|
||||
|
||||
if (isContextMode()) {
|
||||
jsonPath = _jsonPath;
|
||||
}
|
||||
if (Path.fromOSString(jsonPath).toFile().isFile()) {
|
||||
getConnection().setJSONFilePath(PathUtils.getPortablePath(jsonPath));
|
||||
} else {
|
||||
getConnection().setJSONFilePath(jsonPath);
|
||||
}
|
||||
|
||||
JSONWizard wizard = ((JSONWizard) getPage().getWizard());
|
||||
wizard.setTreeRootNode(treeNode);
|
||||
|
||||
BufferedReader in = null;
|
||||
|
||||
// File file = null;
|
||||
//
|
||||
// if (tempJSONXsdPath != null && getConnection().getFileContent() != null
|
||||
// && getConnection().getFileContent().length > 0 && !isModifing) {
|
||||
// file = new File(tempJSONXsdPath);
|
||||
// if (!file.exists()) {
|
||||
// try {
|
||||
// file.createNewFile();
|
||||
// } catch (IOException e2) {
|
||||
// ExceptionHandler.process(e2);
|
||||
// }
|
||||
// FileOutputStream outStream;
|
||||
// try {
|
||||
// outStream = new FileOutputStream(file);
|
||||
// outStream.write(getConnection().getFileContent());
|
||||
// outStream.close();
|
||||
// } catch (FileNotFoundException e1) {
|
||||
// ExceptionHandler.process(e1);
|
||||
// } catch (IOException e3) {
|
||||
// ExceptionHandler.process(e3);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// } else {
|
||||
// file = new File(text);
|
||||
// }
|
||||
|
||||
// setFileContent(file);
|
||||
// }
|
||||
|
||||
try {
|
||||
|
||||
Charset guessedCharset = CharsetToolkit.guessEncoding(file, 4096);
|
||||
String str;
|
||||
in = new BufferedReader(new InputStreamReader(new FileInputStream(file), guessedCharset.displayName()));
|
||||
while ((str = in.readLine()) != null) {
|
||||
if (str.contains("encoding")) { //$NON-NLS-1$
|
||||
String regex = "^<\\?JSON\\s*version=\\\"[^\\\"]*\\\"\\s*encoding=\\\"([^\\\"]*)\\\"\\?>$"; //$NON-NLS-1$
|
||||
|
||||
Perl5Compiler compiler = new Perl5Compiler();
|
||||
Perl5Matcher matcher = new Perl5Matcher();
|
||||
Pattern pattern = null;
|
||||
try {
|
||||
pattern = compiler.compile(regex);
|
||||
if (matcher.contains(str, pattern)) {
|
||||
MatchResult matchResult = matcher.getMatch();
|
||||
if (matchResult != null) {
|
||||
encoding = matchResult.group(1);
|
||||
}
|
||||
}
|
||||
} catch (MalformedPatternException malE) {
|
||||
ExceptionHandler.process(malE);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
String fileStr = text;
|
||||
String msgError = "JSON" + " \"" + fileStr.replace("\\\\", "\\") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
+ "\"\n"; //$NON-NLS-1$
|
||||
if (ex instanceof FileNotFoundException) {
|
||||
msgError = msgError + "is not found";
|
||||
} else if (ex instanceof EOFException) {
|
||||
msgError = msgError + "have an incorrect character EOF";
|
||||
} else if (ex instanceof IOException) {
|
||||
msgError = msgError + "is locked by another soft";
|
||||
} else {
|
||||
msgError = msgError + "doesn't exist";
|
||||
}
|
||||
if (!isReadOnly()) {
|
||||
updateStatus(IStatus.ERROR, msgError);
|
||||
}
|
||||
// ExceptionHandler.process(ex);
|
||||
} finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (Exception ex2) {
|
||||
ExceptionHandler.process(ex2);
|
||||
}
|
||||
}
|
||||
if (getConnection().getEncoding() == null || "".equals(getConnection().getEncoding())) { //$NON-NLS-1$
|
||||
getConnection().setEncoding(encoding);
|
||||
if (encoding != null && !("").equals(encoding)) { //$NON-NLS-1$
|
||||
encodingCombo.setText(encoding);
|
||||
} else {
|
||||
encodingCombo.setText("UTF-8"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
// if (tempJSONXsdPath != null && getConnection().getFileContent() != null
|
||||
// && getConnection().getFileContent().length > 0 && !isModifing) {
|
||||
// valid = treePopulator.populateTree(tempJSONXsdPath, treeNode);
|
||||
// } else {
|
||||
// valid = treePopulator.populateTree(text, treeNode);
|
||||
// }
|
||||
checkFieldsValue();
|
||||
isModifing = true;
|
||||
validateJsonFile();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -691,6 +529,19 @@ public class JSONFileStep1Form extends AbstractJSONFileStepForm {
|
||||
@Override
|
||||
public void modifyText(final ModifyEvent e) {
|
||||
getConnection().setEncoding(encodingCombo.getText());
|
||||
String encoding = getConnection().getEncoding();
|
||||
if (treePopulator != null) {
|
||||
treePopulator.setEncoding(encoding);
|
||||
}
|
||||
try {
|
||||
Charset charSet = Charset.forName(encoding);
|
||||
if (charSet != null) {
|
||||
validateJsonFile();
|
||||
return;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// ignore
|
||||
}
|
||||
checkFieldsValue();
|
||||
}
|
||||
});
|
||||
@@ -883,4 +734,171 @@ public class JSONFileStep1Form extends AbstractJSONFileStepForm {
|
||||
// valid = this.treePopulator.populateTree(tempJSONXsdPath, treeNode);
|
||||
// temfile.delete();
|
||||
}
|
||||
|
||||
private void validateJsonFile() {
|
||||
String jsonPath = fileFieldJSON.getText();
|
||||
String _jsonPath = jsonPath;
|
||||
if (isContextMode()) {
|
||||
ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(
|
||||
connectionItem.getConnection(), connectionItem.getConnection().getContextName());
|
||||
jsonPath = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType,
|
||||
jsonPath));
|
||||
|
||||
}
|
||||
String text = validateJsonFilePath(jsonPath);
|
||||
if (text == null || text.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String tempxml = null;
|
||||
String readbyMode = JSONFileStep1Form.this.wizard.getReadbyMode();
|
||||
|
||||
if (EJsonReadbyMode.JSONPATH.getValue().equals(readbyMode)) {
|
||||
tempxml = text;
|
||||
} else {
|
||||
tempxml = JSONUtil.changeJsonToXml(text, getConnection().getEncoding());
|
||||
}
|
||||
File file = new File(text);
|
||||
if (!file.exists()) {
|
||||
file = new File(JSONUtil.tempJSONXsdPath);
|
||||
}
|
||||
JSONFileStep1Form.this.wizard.setTempJsonPath(tempxml);
|
||||
String limitString = commonNodesLimitation.getText();
|
||||
try {
|
||||
limit = Integer.valueOf(limitString);
|
||||
labelLimitation.setToolTipText(MessageFormat.format(Messages.JSONLimitToolTip, limit));
|
||||
} catch (Exception excpt) {
|
||||
// nothing need to do
|
||||
}
|
||||
switchPopulator(readbyMode, tempxml);
|
||||
// }
|
||||
// add for bug TDI-20432
|
||||
checkFieldsValue();
|
||||
// }
|
||||
|
||||
// String text = fileFieldJSON.getText();
|
||||
// File temp = new File(text);
|
||||
// if (!temp.exists()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (getConnection().getJSONFilePath() != null && !getConnection().getJSONFilePath().equals(text)) {
|
||||
getConnection().getLoop().clear();
|
||||
xsdPathChanged = true;
|
||||
} else {
|
||||
xsdPathChanged = false;
|
||||
}
|
||||
|
||||
if (isContextMode()) {
|
||||
jsonPath = _jsonPath;
|
||||
}
|
||||
if (Path.fromOSString(jsonPath).toFile().isFile()) {
|
||||
getConnection().setJSONFilePath(PathUtils.getPortablePath(jsonPath));
|
||||
} else {
|
||||
getConnection().setJSONFilePath(jsonPath);
|
||||
}
|
||||
|
||||
JSONWizard wizard = ((JSONWizard) getPage().getWizard());
|
||||
wizard.setTreeRootNode(treeNode);
|
||||
|
||||
BufferedReader in = null;
|
||||
|
||||
// File file = null;
|
||||
//
|
||||
// if (tempJSONXsdPath != null && getConnection().getFileContent() != null
|
||||
// && getConnection().getFileContent().length > 0 && !isModifing) {
|
||||
// file = new File(tempJSONXsdPath);
|
||||
// if (!file.exists()) {
|
||||
// try {
|
||||
// file.createNewFile();
|
||||
// } catch (IOException e2) {
|
||||
// ExceptionHandler.process(e2);
|
||||
// }
|
||||
// FileOutputStream outStream;
|
||||
// try {
|
||||
// outStream = new FileOutputStream(file);
|
||||
// outStream.write(getConnection().getFileContent());
|
||||
// outStream.close();
|
||||
// } catch (FileNotFoundException e1) {
|
||||
// ExceptionHandler.process(e1);
|
||||
// } catch (IOException e3) {
|
||||
// ExceptionHandler.process(e3);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// } else {
|
||||
// file = new File(text);
|
||||
// }
|
||||
|
||||
// setFileContent(file);
|
||||
// }
|
||||
|
||||
try {
|
||||
|
||||
Charset guessedCharset = CharsetToolkit.guessEncoding(file, 4096);
|
||||
String str;
|
||||
in = new BufferedReader(new InputStreamReader(new FileInputStream(file), guessedCharset.displayName()));
|
||||
while ((str = in.readLine()) != null) {
|
||||
if (str.contains("encoding")) { //$NON-NLS-1$
|
||||
String regex = "^<\\?JSON\\s*version=\\\"[^\\\"]*\\\"\\s*encoding=\\\"([^\\\"]*)\\\"\\?>$"; //$NON-NLS-1$
|
||||
|
||||
Perl5Compiler compiler = new Perl5Compiler();
|
||||
Perl5Matcher matcher = new Perl5Matcher();
|
||||
Pattern pattern = null;
|
||||
try {
|
||||
pattern = compiler.compile(regex);
|
||||
if (matcher.contains(str, pattern)) {
|
||||
MatchResult matchResult = matcher.getMatch();
|
||||
if (matchResult != null) {
|
||||
encoding = matchResult.group(1);
|
||||
}
|
||||
}
|
||||
} catch (MalformedPatternException malE) {
|
||||
ExceptionHandler.process(malE);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
String fileStr = text;
|
||||
String msgError = "JSON" + " \"" + fileStr.replace("\\\\", "\\") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
+ "\"\n"; //$NON-NLS-1$
|
||||
if (ex instanceof FileNotFoundException) {
|
||||
msgError = msgError + "is not found";
|
||||
} else if (ex instanceof EOFException) {
|
||||
msgError = msgError + "have an incorrect character EOF";
|
||||
} else if (ex instanceof IOException) {
|
||||
msgError = msgError + "is locked by another soft";
|
||||
} else {
|
||||
msgError = msgError + "doesn't exist";
|
||||
}
|
||||
if (!isReadOnly()) {
|
||||
updateStatus(IStatus.ERROR, msgError);
|
||||
}
|
||||
// ExceptionHandler.process(ex);
|
||||
} finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (Exception ex2) {
|
||||
ExceptionHandler.process(ex2);
|
||||
}
|
||||
}
|
||||
if (getConnection().getEncoding() == null || "".equals(getConnection().getEncoding())) { //$NON-NLS-1$
|
||||
getConnection().setEncoding(encoding);
|
||||
if (encoding != null && !("").equals(encoding)) { //$NON-NLS-1$
|
||||
encodingCombo.setText(encoding);
|
||||
} else {
|
||||
encodingCombo.setText("UTF-8"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
// if (tempJSONXsdPath != null && getConnection().getFileContent() != null
|
||||
// && getConnection().getFileContent().length > 0 && !isModifing) {
|
||||
// valid = treePopulator.populateTree(tempJSONXsdPath, treeNode);
|
||||
// } else {
|
||||
// valid = treePopulator.populateTree(text, treeNode);
|
||||
// }
|
||||
checkFieldsValue();
|
||||
isModifing = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.Priority;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
@@ -52,6 +53,7 @@ import org.eclipse.swt.widgets.ScrollBar;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
import org.talend.commons.CommonsPlugin;
|
||||
import org.talend.commons.ui.command.CommandStackForComposite;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.commons.ui.runtime.ws.WindowSystem;
|
||||
@@ -222,6 +224,7 @@ public class JSONFileStep2Form extends AbstractJSONFileStepForm implements IRefr
|
||||
jsonXPathLoopDescriptor.setLimitBoucle(XmlArray.getRowLimit());
|
||||
|
||||
}
|
||||
treePopulator.setEncoding(getConnection().getEncoding());
|
||||
treePopulator.populateTree(wizard.getTempJsonPath(), treeNode);
|
||||
fieldsModel.setJSONXPathLoopDescriptor(jsonXPathLoopDescriptor.getSchemaTargets());
|
||||
fieldsTableEditorView.getTableViewerCreator().layout();
|
||||
@@ -608,7 +611,22 @@ public class JSONFileStep2Form extends AbstractJSONFileStepForm implements IRefr
|
||||
}
|
||||
};
|
||||
|
||||
previewLoader.load(getProcessDescription(false));
|
||||
ProcessDescription processDescription = getProcessDescription(false);
|
||||
EJsonReadbyMode mode = null;
|
||||
String readbyMode = getConnection().getReadbyMode();
|
||||
if (StringUtils.isNotBlank(readbyMode)) {
|
||||
mode = EJsonReadbyMode.getEJsonReadbyModeByValue(readbyMode);
|
||||
}
|
||||
if (EJsonReadbyMode.XPATH.equals(mode)) {
|
||||
/**
|
||||
* JSON XPATH mode uses the temp generated xml file to execute the preview, the generated xml file is
|
||||
* encoded using UTF-8. <br/>
|
||||
* (The generated xml file can't be encoded using other charset, otherwise the converted xml file will be
|
||||
* empty)
|
||||
*/
|
||||
processDescription.setEncoding(TalendQuoteUtils.addQuotes("UTF-8"));
|
||||
}
|
||||
previewLoader.load(processDescription);
|
||||
|
||||
}
|
||||
|
||||
@@ -871,10 +889,20 @@ public class JSONFileStep2Form extends AbstractJSONFileStepForm implements IRefr
|
||||
}
|
||||
}
|
||||
|
||||
Charset guessedCharset = CharsetToolkit.guessEncoding(file, 4096);
|
||||
Charset guessedCharset = null;
|
||||
try {
|
||||
guessedCharset = Charset.forName(getConnection().getEncoding());
|
||||
} catch (Exception e) {
|
||||
if (CommonsPlugin.isDebugMode()) {
|
||||
ExceptionHandler.process(e, Priority.WARN);
|
||||
}
|
||||
}
|
||||
if (guessedCharset == null) {
|
||||
guessedCharset = CharsetToolkit.guessEncoding(file, 4096);
|
||||
}
|
||||
|
||||
String str;
|
||||
in = new BufferedReader(new InputStreamReader(new FileInputStream(pathStr), guessedCharset.displayName()));
|
||||
in = new BufferedReader(new InputStreamReader(new FileInputStream(pathStr), guessedCharset));
|
||||
|
||||
while ((str = in.readLine()) != null) {
|
||||
previewRows.append(str + "\n"); //$NON-NLS-1$
|
||||
@@ -947,6 +975,7 @@ public class JSONFileStep2Form extends AbstractJSONFileStepForm implements IRefr
|
||||
// fix bug: when the JSON file is changed, the linker doesn't work.
|
||||
resetStatusIfNecessary();
|
||||
String tempJson = this.wizard.getTempJsonPath();
|
||||
this.treePopulator.setEncoding(getConnection().getEncoding());
|
||||
this.treePopulator.populateTree(tempJson, treeNode);
|
||||
|
||||
ScrollBar verticalBar = availableJSONTree.getVerticalBar();
|
||||
|
||||
@@ -328,7 +328,7 @@ public class JSONFileStep3Form extends AbstractJSONFileStepForm {
|
||||
processDescription = JSONShadowProcessHelper.getProcessDescription(connection2, connection2.getJSONFilePath());
|
||||
} else {
|
||||
processDescription = JSONShadowProcessHelper.getProcessDescription(connection2,
|
||||
JSONUtil.changeJsonToXml(connection2.getJSONFilePath()));
|
||||
JSONUtil.changeJsonToXml(connection2.getJSONFilePath(), getConnection().getEncoding()));
|
||||
}
|
||||
}
|
||||
return processDescription;
|
||||
@@ -357,10 +357,18 @@ public class JSONFileStep3Form extends AbstractJSONFileStepForm {
|
||||
informationLabel.setText(" " + "Guess in progress...");
|
||||
|
||||
CsvArray csvArray = null;
|
||||
ProcessDescription processDescription = getProcessDescription(false);
|
||||
if (EJsonReadbyMode.JSONPATH.getValue().equals(connection2.getReadbyMode())) {
|
||||
csvArray = JSONShadowProcessHelper.getCsvArray(getProcessDescription(false), "FILE_JSON"); //$NON-NLS-1$
|
||||
csvArray = JSONShadowProcessHelper.getCsvArray(processDescription, "FILE_JSON"); //$NON-NLS-1$
|
||||
} else {
|
||||
csvArray = JSONShadowProcessHelper.getCsvArray(getProcessDescription(false), "FILE_XML"); //$NON-NLS-1$
|
||||
/**
|
||||
* JSON XPATH mode uses the temp generated xml file to execute the preview, the generated xml file is
|
||||
* encoded using UTF-8. <br/>
|
||||
* (The generated xml file can't be encoded using other charset, otherwise the converted xml file will
|
||||
* be empty)
|
||||
*/
|
||||
processDescription.setEncoding(TalendQuoteUtils.addQuotes("UTF-8"));
|
||||
csvArray = JSONShadowProcessHelper.getCsvArray(processDescription, "FILE_XML"); //$NON-NLS-1$
|
||||
}
|
||||
if (csvArray == null) {
|
||||
informationLabel.setText(" " + "Guess failure");
|
||||
|
||||
@@ -20,10 +20,13 @@ import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.swt.widgets.FileDialog;
|
||||
import org.eclipse.ui.actions.SelectionProviderAction;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.properties.ConnectionItem;
|
||||
import org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode;
|
||||
import org.talend.metadata.managment.ui.wizard.metadata.xml.utils.TreeUtil;
|
||||
import org.talend.repository.json.ui.wizards.AbstractJSONStepForm;
|
||||
import org.talend.repository.json.util.JSONUtil;
|
||||
import org.talend.repository.model.json.JSONFileConnection;
|
||||
|
||||
/**
|
||||
* hwang class global comment. Detailled comment
|
||||
@@ -56,7 +59,17 @@ public class ImportTreeFromJSONAction extends SelectionProviderAction {
|
||||
|
||||
boolean changed = true;
|
||||
try {
|
||||
newInput = TreeUtil.getFoxTreeNodes(JSONUtil.changeJsonToXml(filePath));
|
||||
String encoding = "UTF-8";
|
||||
if (this.form != null) {
|
||||
ConnectionItem connectionItem = this.form.getConnectionItem();
|
||||
if (connectionItem != null) {
|
||||
Connection connection = connectionItem.getConnection();
|
||||
if (connection instanceof JSONFileConnection) {
|
||||
encoding = ((JSONFileConnection) connection).getEncoding();
|
||||
}
|
||||
}
|
||||
}
|
||||
newInput = TreeUtil.getFoxTreeNodes(JSONUtil.changeJsonToXml(filePath, encoding));
|
||||
changed = true;
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
|
||||
@@ -272,6 +272,7 @@ public class JSONToXPathLinker extends TreeToTablesLinker<Object, Object> {
|
||||
}
|
||||
|
||||
if (originalValue != null) {
|
||||
loadItemDataForLazyLoad(loopTableEditorView);
|
||||
createLoopLinks(originalValue, tableItem, monitorWrap);
|
||||
}
|
||||
|
||||
@@ -311,6 +312,7 @@ public class JSONToXPathLinker extends TreeToTablesLinker<Object, Object> {
|
||||
List<SchemaTarget> schemaTargetList, int startTableItem, int tableItemLength) {
|
||||
monitorWrap.beginTask("Fields links creation ...", totalWork);
|
||||
|
||||
loadItemDataForLazyLoad(fieldsTableEditorView);
|
||||
TableItem[] fieldsTableItems = fieldsTableEditorView.getTable().getItems();
|
||||
for (int i = startTableItem, indexShemaTarget = 0; i < startTableItem + tableItemLength; i++, indexShemaTarget++) {
|
||||
|
||||
@@ -330,6 +332,7 @@ public class JSONToXPathLinker extends TreeToTablesLinker<Object, Object> {
|
||||
createFieldLinks(relativeXpathQuery, tableItem, monitorWrap, schemaTarget);
|
||||
monitorWrap.worked(1);
|
||||
}
|
||||
fieldsTableEditorView.getTableViewerCreator().getTableViewer().refresh();
|
||||
getLinksManager().sortLinks(getDrawingLinksComparator());
|
||||
getBackgroundRefresher().refreshBackground();
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class JSONUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String changeJsonToXml(String jsonPath) {
|
||||
public static String changeJsonToXml(String jsonPath, String encoding) {
|
||||
Project project = ProjectManager.getInstance().getCurrentProject();
|
||||
IProject fsProject = null;
|
||||
try {
|
||||
@@ -166,10 +166,9 @@ public class JSONUtil {
|
||||
}
|
||||
|
||||
try {
|
||||
String jsonStr = IOUtils.toString(input);
|
||||
String jsonStr = IOUtils.toString(input, encoding);
|
||||
|
||||
convertJSON.setJsonString(jsonStr);
|
||||
|
||||
convertJSON.generate();
|
||||
jsonStr = convertJSON.getJsonString4XML();
|
||||
inStream = new ByteArrayInputStream(jsonStr.getBytes());
|
||||
|
||||
@@ -3129,6 +3129,15 @@
|
||||
name="UseOracle11VersionInsteadOfRemoved"
|
||||
version="7.1.0">
|
||||
</projecttask>
|
||||
<projecttask
|
||||
beforeLogon="false"
|
||||
breaks="7.0.0"
|
||||
class="org.talend.repository.model.migration.changeDBVersionForMapROJAIOutputMigrationTask"
|
||||
description="Changed DB version in MapROJAI output component"
|
||||
id="org.talend.repository.model.migration.changeDBVersionForMapROJAIOutputMigrationTask"
|
||||
name="changeDBVersionForMapROJAIOutputMigrationTask"
|
||||
version="7.0.1">
|
||||
</projecttask>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
|
||||
@@ -389,6 +389,8 @@ JavaJobScriptsExportWSWizardPage.PETALSESB=Petals ESB (Deprecated)
|
||||
JavaJobScriptsExportWSWizardPage.OSGI=OSGI Bundle For ESB
|
||||
JavaJobScriptsExportWSWizardPage.MSESB=Microservice (Spring Boot) For ESB
|
||||
JavaJobScriptsExportWSWizardPage.IMAGE=Docker Image
|
||||
JavaJobScriptsExportWSWizardPage.ROUTE=ESB Route
|
||||
JavaJobScriptsExportWSWizardPage.SERVICE=Service
|
||||
JavaJobScriptsExportWSWizardPage.DOCKER.optionGroup=Docker Options
|
||||
JavaJobScriptsExportWSWizardPage.DOCKER.dockerHost=Docker host
|
||||
JavaJobScriptsExportWSWizardPage.DOCKER.localHost=Local
|
||||
@@ -407,7 +409,7 @@ JavaJobScriptsExportWSWizardPage.banServiceJob=Service Job can't build independe
|
||||
LimitRESTRequestJobChecker.limit_tRESTRequest=ESB Job contains "{0}" should only build using one of [OSGI Bundle For ESB],[Microservice For ESB].
|
||||
LimitRESTRequestJobChecker.limit_ESBJobForMS=Only ESB Job with "{0}" could build using [Microservice (Spring Boot) For ESB] type.
|
||||
LimitRESTRequestJobChecker.limit_ESBJobForOSGI=Job without ESB components could not build using [OSGI Bundle For ESB] type.
|
||||
LimitESBConsumerJobChecker.limit_tRESTClient_tESBConsumer=ESB Job contains "{0}" should only build using one of [Standalone Job],[OSGI Bundle For ESB].
|
||||
LimitESBConsumerJobChecker.limit_tRESTClient_tESBConsumer=ESB Job contains "{0}" should only build using one of [Standalone Job],[OSGI Bundle For ESB],[Docker Image].
|
||||
LimitESBConsumerJobChecker.limitFeaturesWithStandalone.locator=ESB Job contains "{0}" shouldn't specify feature Service Locator when build using [Standalone Job]
|
||||
LimitESBConsumerJobChecker.limitFeaturesWithStandalone.SAM=ESB Job contains "{0}" shouldn't specify feature Service Activity Monitor when build using [Standalone Job]
|
||||
LimitESBConsumerJobChecker.limitFeaturesWithStandalone.SR=ESB Job contains "{0}" shouldn't specify feature Service Registry when build using [Standalone Job]
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.repository.model.migration;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.core.language.ECodeLanguage;
|
||||
import org.talend.core.model.components.ComponentUtilities;
|
||||
import org.talend.core.model.components.ModifyComponentsAction;
|
||||
import org.talend.core.model.components.conversions.IComponentConversion;
|
||||
import org.talend.core.model.components.filters.IComponentFilter;
|
||||
import org.talend.core.model.components.filters.NameComponentFilter;
|
||||
import org.talend.core.model.migration.AbstractJobMigrationTask;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
|
||||
import org.talend.migration.IMigrationTask.ExecutionResult;
|
||||
|
||||
public class changeDBVersionForMapROJAIOutputMigrationTask extends AbstractJobMigrationTask {
|
||||
|
||||
@Override
|
||||
public Date getOrder() {
|
||||
GregorianCalendar gc = new GregorianCalendar(2019, 8, 12, 12, 0, 0);
|
||||
return gc.getTime();
|
||||
}
|
||||
@Override
|
||||
public ExecutionResult execute(Item item) {
|
||||
final ProcessType processType = getProcessType(item);
|
||||
String[] compNames = {"tMapROjaiOutput"};
|
||||
|
||||
IComponentConversion changeDBNVersion = new IComponentConversion() {
|
||||
|
||||
public void transform(NodeType node) {
|
||||
if(node == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ElementParameterType database = ComponentUtilities.getNodeProperty(node, "DB_VERSION"); //$NON-NLS-1$
|
||||
|
||||
if (database == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String dbname = database.getValue();
|
||||
|
||||
if("MAPROJAI_5_1".equals(dbname)) {
|
||||
database.setValue("MAPR510");
|
||||
} else if ("MAPROJAI_5_2".equals(dbname)) {
|
||||
database.setValue("MAPR520");
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
for (String name : compNames) {
|
||||
IComponentFilter filter = new NameComponentFilter(name);
|
||||
|
||||
try {
|
||||
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays
|
||||
.<IComponentConversion> asList(changeDBNVersion));
|
||||
} catch (PersistenceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
ExceptionHandler.process(e);
|
||||
return ExecutionResult.FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return ExecutionResult.SUCCESS_NO_ALERT;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -81,6 +81,7 @@ import org.talend.commons.ui.runtime.exception.ExceptionMessageDialog;
|
||||
import org.talend.commons.ui.runtime.exception.MessageBoxExceptionHandler;
|
||||
import org.talend.commons.ui.runtime.image.EImage;
|
||||
import org.talend.commons.ui.runtime.image.ImageProvider;
|
||||
import org.talend.commons.utils.network.TalendProxySelector;
|
||||
import org.talend.commons.utils.system.EclipseCommandLine;
|
||||
import org.talend.commons.utils.system.EnvironmentUtils;
|
||||
import org.talend.core.CorePlugin;
|
||||
@@ -694,6 +695,8 @@ public class LoginProjectPage extends AbstractLoginActionPage {
|
||||
CommonExceptionHandler.process(e);
|
||||
} catch (JSONException e) {
|
||||
CommonExceptionHandler.process(e);
|
||||
} finally {
|
||||
TalendProxySelector.getInstance();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,9 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
POJO(Messages.getString("JavaJobScriptsExportWSWizardPage.POJO"), false), //$NON-NLS-1$
|
||||
OSGI(Messages.getString("JavaJobScriptsExportWSWizardPage.OSGI"), false), //$NON-NLS-1$
|
||||
MSESB(Messages.getString("JavaJobScriptsExportWSWizardPage.MSESB"), false), //$NON-NLS-1$
|
||||
IMAGE(Messages.getString("JavaJobScriptsExportWSWizardPage.IMAGE"), false); //$NON-NLS-1$
|
||||
IMAGE(Messages.getString("JavaJobScriptsExportWSWizardPage.IMAGE"), false), //$NON-NLS-1$
|
||||
ROUTE(Messages.getString("JavaJobScriptsExportWSWizardPage.ROUTE"), false), //$NON-NLS-1$
|
||||
SERVICE(Messages.getString("JavaJobScriptsExportWSWizardPage.SERVICE"), false); //$NON-NLS-1$
|
||||
|
||||
public final String label;
|
||||
|
||||
@@ -129,6 +131,10 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isImageType(JobExportType type) {
|
||||
return type == IMAGE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static final String ESBTYPE_JBOSS_MQ = "JBoss MQ"; //$NON-NLS-1$
|
||||
@@ -203,6 +209,8 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
|
||||
private Label hostLabel, imageLabel, tagLabel;
|
||||
|
||||
private boolean isValid;
|
||||
|
||||
public JavaJobScriptsExportWSWizardPage(IStructuredSelection selection, String exportType) {
|
||||
super(selection);
|
||||
// there assign the manager again
|
||||
@@ -229,10 +237,11 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
// set default export type according to system properties
|
||||
String exportType = dialogSettings.get(STORE_EXPORTTYPE_ID);
|
||||
String defaultExportType = System.getProperty("talend.export.job.default.type"); //$NON-NLS-1$
|
||||
if ((exportType == null || exportType.equals("")) && defaultExportType != null && !defaultExportType.equals("")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if ((exportType == null || exportType.equals("")) && defaultExportType != null //$NON-NLS-1$
|
||||
&& !defaultExportType.equals("")) { //$NON-NLS-1$
|
||||
dialogSettings.put(STORE_EXPORTTYPE_ID, defaultExportType);
|
||||
}
|
||||
}// else ignors it
|
||||
} // else ignors it
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -243,7 +252,8 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.numColumns = 3;
|
||||
destinationSelectionGroup.setLayout(layout);
|
||||
destinationSelectionGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
|
||||
destinationSelectionGroup
|
||||
.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
|
||||
destinationSelectionGroup.setFont(font);
|
||||
|
||||
destinationLabel = new Label(destinationSelectionGroup, SWT.NONE);
|
||||
@@ -351,31 +361,30 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
|
||||
@Override
|
||||
public void createControl(Composite parent) {
|
||||
|
||||
|
||||
initializeDialogUnits(parent);
|
||||
SashForm sash = createExportTree(parent);
|
||||
|
||||
|
||||
// Added a scrolled composite by Marvin Wang on Feb. 27, 2012 for bug TDI-19198.
|
||||
scrolledComposite = new ScrolledComposite(sash, SWT.H_SCROLL | SWT.V_SCROLL);
|
||||
scrolledComposite.setExpandHorizontal(true);
|
||||
scrolledComposite.setExpandVertical(true);
|
||||
GridDataFactory.fillDefaults().grab(true, true).applyTo(scrolledComposite);
|
||||
|
||||
|
||||
pageComposite = new Composite(scrolledComposite, SWT.BORDER);
|
||||
GridDataFactory.fillDefaults().grab(true, true).applyTo(pageComposite);
|
||||
|
||||
|
||||
GridLayout gdlPageComposite = new GridLayout();
|
||||
pageComposite.setLayout(gdlPageComposite);
|
||||
pageComposite.setFont(parent.getFont());
|
||||
|
||||
|
||||
createDestinationGroup(pageComposite);
|
||||
|
||||
// this.getDestinationValue()
|
||||
// createExportTree(pageComposite);
|
||||
if (!isMultiNodes()) {
|
||||
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault()
|
||||
.getService(IBrandingService.class);
|
||||
IBrandingService brandingService =
|
||||
(IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
|
||||
boolean allowVerchange = brandingService.getBrandingConfiguration().isAllowChengeVersion();
|
||||
if (allowVerchange) {
|
||||
createJobVersionGroup(pageComposite);
|
||||
@@ -393,10 +402,9 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
updateWidgetEnablements();
|
||||
setPageComplete(determinePageCompletion());
|
||||
|
||||
|
||||
setControl(sash);
|
||||
sash.setWeights(new int[] { 0, 1, 23 });
|
||||
|
||||
|
||||
giveFocusToDestination();
|
||||
|
||||
pageComposite.setSize(pageComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
||||
@@ -407,7 +415,7 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
protected void createExportTypeGroup(Composite parent) {
|
||||
// options group
|
||||
Group optionsGroup = new Group(parent, SWT.NONE);
|
||||
|
||||
|
||||
GridLayout layout = new GridLayout();
|
||||
optionsGroup.setLayout(layout);
|
||||
optionsGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
|
||||
@@ -418,7 +426,7 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
|
||||
Composite left = new Composite(optionsGroup, SWT.NONE);
|
||||
left.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false));
|
||||
|
||||
|
||||
GridLayout gdlLeft = new GridLayout(3, false);
|
||||
gdlLeft.marginHeight = 0;
|
||||
gdlLeft.marginWidth = 0;
|
||||
@@ -459,8 +467,8 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
// if the build type was set, try to select by default
|
||||
if (nodes != null && nodes.length == 1) { // deal with one node only.
|
||||
ProcessItem item = getProcessItem();
|
||||
final Object buildType = item.getProperty().getAdditionalProperties()
|
||||
.get(TalendProcessArgumentConstant.ARG_BUILD_TYPE);
|
||||
final Object buildType =
|
||||
item.getProperty().getAdditionalProperties().get(TalendProcessArgumentConstant.ARG_BUILD_TYPE);
|
||||
if (buildType != null) {
|
||||
Map<JobExportType, String> map = BuildJobFactory.oldBuildTypeMap;
|
||||
for (JobExportType t : map.keySet()) {
|
||||
@@ -489,7 +497,7 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
chkButton.setVisible(true);
|
||||
zipOption = String.valueOf(chkButton.getSelection());
|
||||
}
|
||||
|
||||
|
||||
chkButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
@@ -498,7 +506,7 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
zipOption = String.valueOf(chkButton.getSelection());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
exportTypeCombo.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
@@ -537,10 +545,12 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
Map<ExportChoice, Object> exportChoiceMap = getExportChoiceMap();
|
||||
String log4jLevel = "";
|
||||
String launcher = (getCurrentExportType1() == JobExportType.POJO) ? launcherCombo.getText() : "all";
|
||||
String context = (contextCombo == null || contextCombo.isDisposed()) ? IContext.DEFAULT : contextCombo.getText();
|
||||
String context =
|
||||
(contextCombo == null || contextCombo.isDisposed()) ? IContext.DEFAULT : contextCombo.getText();
|
||||
|
||||
JobScriptsManager manager = JobScriptsManagerFactory.createManagerInstance(exportChoiceMap, context, launcher,
|
||||
IProcessor.NO_STATISTICS, IProcessor.NO_TRACES, getCurrentExportType1());
|
||||
JobScriptsManager manager = JobScriptsManagerFactory
|
||||
.createManagerInstance(exportChoiceMap, context, launcher, IProcessor.NO_STATISTICS,
|
||||
IProcessor.NO_TRACES, getCurrentExportType1());
|
||||
manager.setDestinationPath(getDestinationValue());
|
||||
if (log4jLevelCombo != null && !log4jLevelCombo.isDisposed()) {
|
||||
if (log4jLevelCombo.isEnabled()) {
|
||||
@@ -630,8 +640,8 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
|
||||
if (str.equals(s)) {
|
||||
if (getDefaultFileName().get(1) != null && !"".equals(getDefaultFileName().get(1))) {
|
||||
selectedFileName = b + ((JobExportType.OSGI.equals(jobExportType)) ? "-" : "_") + getDefaultFileName().get(1)
|
||||
+ idealSuffix;
|
||||
selectedFileName = b + ((JobExportType.OSGI.equals(jobExportType)) ? "-" : "_")
|
||||
+ getDefaultFileName().get(1) + idealSuffix;
|
||||
} else {
|
||||
selectedFileName = b + idealSuffix;
|
||||
}
|
||||
@@ -718,7 +728,8 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
// destination
|
||||
for (int i = 0; i < directoryNames.length; i++) {
|
||||
if (directoryNames[i].toLowerCase().endsWith(FileConstants.ZIP_FILE_SUFFIX)) {
|
||||
directoryNames[i] = (directoryNames[i].charAt(0) + "").toUpperCase() + directoryNames[i].substring(1);//$NON-NLS-1$
|
||||
directoryNames[i] =
|
||||
(directoryNames[i].charAt(0) + "").toUpperCase() + directoryNames[i].substring(1);//$NON-NLS-1$
|
||||
addDestinationItem(directoryNames[i]);
|
||||
}
|
||||
}
|
||||
@@ -753,7 +764,8 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
// destination
|
||||
for (int i = 0; i < directoryNames.length; i++) {
|
||||
if (directoryNames[i].toLowerCase().endsWith(FileConstants.ESB_FILE_SUFFIX)) {
|
||||
directoryNames[i] = (directoryNames[i].charAt(0) + "").toUpperCase() + directoryNames[i].substring(1);//$NON-NLS-1$
|
||||
directoryNames[i] =
|
||||
(directoryNames[i].charAt(0) + "").toUpperCase() + directoryNames[i].substring(1);//$NON-NLS-1$
|
||||
addDestinationItem(directoryNames[i]);
|
||||
}
|
||||
}
|
||||
@@ -796,8 +808,10 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
|
||||
if (getProcessItem() != null && contextCombo != null) {
|
||||
try {
|
||||
setProcessItem((ProcessItem) ProxyRepositoryFactory.getInstance()
|
||||
.getUptodateProperty(getProcessItem().getProperty()).getItem());
|
||||
setProcessItem((ProcessItem) ProxyRepositoryFactory
|
||||
.getInstance()
|
||||
.getUptodateProperty(getProcessItem().getProperty())
|
||||
.getItem());
|
||||
} catch (PersistenceException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -817,7 +831,8 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
String fileName = getDefaultFileNameWithType();
|
||||
for (int i = 0; i < directoryNames.length; i++) {
|
||||
if (directoryNames[i].toLowerCase().endsWith(FileConstants.JAR_FILE_SUFFIX)) {
|
||||
directoryNames[i] = (directoryNames[i].charAt(0) + "").toUpperCase() + directoryNames[i].substring(1);//$NON-NLS-1$
|
||||
directoryNames[i] =
|
||||
(directoryNames[i].charAt(0) + "").toUpperCase() + directoryNames[i].substring(1);//$NON-NLS-1$
|
||||
addDestinationItem(directoryNames[i]);
|
||||
}
|
||||
}
|
||||
@@ -851,11 +866,13 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
// destination = dirPath.append(fileName).toOSString();
|
||||
// }
|
||||
if (directoryNames[i].toLowerCase().endsWith(FileConstants.ZIP_FILE_SUFFIX)) {
|
||||
directoryNames[i] = (directoryNames[i].charAt(0) + "").toUpperCase() + directoryNames[i].substring(1);//$NON-NLS-1$
|
||||
directoryNames[i] =
|
||||
(directoryNames[i].charAt(0) + "").toUpperCase() + directoryNames[i].substring(1);//$NON-NLS-1$
|
||||
addDestinationItem(directoryNames[i]);
|
||||
}
|
||||
}
|
||||
setDestinationValue(directoryNames[0].substring(0, (directoryNames[0].lastIndexOf("\\") + 1)) + fileName);//$NON-NLS-1$
|
||||
setDestinationValue(
|
||||
directoryNames[0].substring(0, (directoryNames[0].lastIndexOf("\\") + 1)) + fileName);//$NON-NLS-1$
|
||||
} else {
|
||||
setDefaultDestination();
|
||||
}
|
||||
@@ -924,12 +941,14 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
if (directoryNames != null && directoryNames.length > 0) {
|
||||
for (int i = 0; i < directoryNames.length; i++) {
|
||||
if (directoryNames[i].toLowerCase().endsWith(FileConstants.ZIP_FILE_SUFFIX)) {
|
||||
directoryNames[i] = (directoryNames[i].charAt(0) + "").toUpperCase() + directoryNames[i].substring(1);//$NON-NLS-1$
|
||||
directoryNames[i] =
|
||||
(directoryNames[i].charAt(0) + "").toUpperCase() + directoryNames[i].substring(1);//$NON-NLS-1$
|
||||
addDestinationItem(directoryNames[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
setDestinationValue(directoryNames[0].substring(0, (directoryNames[0].lastIndexOf("\\") + 1)) + fileName);//$NON-NLS-1$
|
||||
setDestinationValue(
|
||||
directoryNames[0].substring(0, (directoryNames[0].lastIndexOf("\\") + 1)) + fileName);//$NON-NLS-1$
|
||||
} else {
|
||||
setDefaultDestination();
|
||||
}
|
||||
@@ -1054,9 +1073,9 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
exportChoiceMap.put(ExportChoice.needJobItem, false);
|
||||
exportChoiceMap.put(ExportChoice.needSourceCode, false);
|
||||
exportChoiceMap.put(ExportChoice.binaries, !isAddMavenScript());
|
||||
if(exportMSAsZipButton!=null) {
|
||||
if (exportMSAsZipButton != null) {
|
||||
exportChoiceMap.put(ExportChoice.needAssembly, exportMSAsZipButton.getSelection());
|
||||
exportChoiceMap.put(ExportChoice.needLauncher, exportMSAsZipButton.getSelection());
|
||||
exportChoiceMap.put(ExportChoice.needLauncher, exportMSAsZipButton.getSelection());
|
||||
}
|
||||
if (addBSButton != null) {
|
||||
exportChoiceMap.put(ExportChoice.needMavenScript, addBSButton.getSelection());
|
||||
@@ -1143,20 +1162,19 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
}
|
||||
|
||||
protected void createOptionsGroupButtons(Composite parent) {
|
||||
|
||||
|
||||
|
||||
optionsGroupComposite = new Composite(parent, SWT.NONE);
|
||||
GridDataFactory.fillDefaults().grab(true, false).applyTo(optionsGroupComposite);
|
||||
|
||||
|
||||
GridLayout gdlOptionsGroupComposite = new GridLayout();
|
||||
gdlOptionsGroupComposite.marginHeight = 0;
|
||||
gdlOptionsGroupComposite.marginWidth = 0;
|
||||
optionsGroupComposite.setLayout(gdlOptionsGroupComposite);
|
||||
|
||||
|
||||
// options group
|
||||
Group optionsGroup = new Group(optionsGroupComposite, SWT.NONE);
|
||||
GridDataFactory.fillDefaults().grab(true, false).applyTo(optionsGroup);
|
||||
|
||||
|
||||
optionsGroup.setText(Messages.getString("IDEWorkbenchMessages.WizardExportPage_options")); //$NON-NLS-1$
|
||||
optionsGroup.setFont(parent.getFont());
|
||||
|
||||
@@ -1219,7 +1237,7 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
@Override
|
||||
protected boolean validateOptionsGroup() {
|
||||
setErrorMessage(null);
|
||||
boolean isValid = super.validateOptionsGroup();
|
||||
isValid = super.validateOptionsGroup();
|
||||
|
||||
// TESB-13867 Export limitations for ESB 'Jobs'
|
||||
// add extra checks.
|
||||
@@ -1227,7 +1245,8 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
String errorMsg = presenter.extraCheck(getCurrentExportType1(), getCheckNodes());
|
||||
if (errorMsg != null) {
|
||||
setErrorMessage(errorMsg);
|
||||
return false;
|
||||
isValid = false;
|
||||
// return false;
|
||||
}
|
||||
}
|
||||
setPageComplete(isValid);
|
||||
@@ -1447,7 +1466,8 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
}
|
||||
|
||||
private String getDefaultImageName(ProcessItem procesItem) {
|
||||
IFile pomFile = AggregatorPomsHelper.getItemPomFolder(procesItem.getProperty())
|
||||
IFile pomFile = AggregatorPomsHelper
|
||||
.getItemPomFolder(procesItem.getProperty())
|
||||
.getFile(TalendMavenConstants.POM_FILE_NAME);
|
||||
String projectName = PomUtil.getPomProperty(pomFile, "talend.project.name.lowercase"); //$NON-NLS-1$
|
||||
String jobFolderPath = PomUtil.getPomProperty(pomFile, "talend.job.folder"); //$NON-NLS-1$
|
||||
@@ -1468,17 +1488,21 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
}
|
||||
|
||||
private boolean isOptionValid(Text text, String label) {
|
||||
boolean isValid = false;
|
||||
if (StringUtils.isBlank(text.getText())) {
|
||||
setErrorMessage(Messages.getString("JavaJobScriptsExportWSWizardPage.DOCKER.errorMsg", label)); //$NON-NLS-1$
|
||||
setPageComplete(false);
|
||||
isValid = false;
|
||||
} else {
|
||||
setErrorMessage(null);
|
||||
setPageComplete(true);
|
||||
isValid = true;
|
||||
boolean isDockerValid = false;
|
||||
|
||||
// If no error message is already displayed
|
||||
if (isValid) {
|
||||
if (StringUtils.isBlank(text.getText())) {
|
||||
setErrorMessage(Messages.getString("JavaJobScriptsExportWSWizardPage.DOCKER.errorMsg", label)); //$NON-NLS-1$
|
||||
setPageComplete(false);
|
||||
isDockerValid = false;
|
||||
} else {
|
||||
setErrorMessage(null);
|
||||
setPageComplete(true);
|
||||
isDockerValid = true;
|
||||
}
|
||||
}
|
||||
return isValid;
|
||||
return isDockerValid;
|
||||
}
|
||||
|
||||
protected void createOptionsForWS(Composite optionsGroup, Font font) {
|
||||
@@ -1611,7 +1635,7 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
String errorMsg = presenter.extraCheck(getCurrentExportType1(), getCheckNodes());
|
||||
if (errorMsg != null) {
|
||||
setErrorMessage(errorMsg);
|
||||
return false;
|
||||
noError = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1623,16 +1647,24 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
protected void updateOptionBySelection() {
|
||||
RepositoryNode[] selectedNodes = treeViewer.getCheckNodes();
|
||||
if (selectedNodes.length > 1) {
|
||||
imageText.setText(getDefaultImageNamePattern());
|
||||
imageText.setEnabled(false);
|
||||
tagText.setText(getDefaultImageTagPattern());
|
||||
tagText.setEnabled(false);
|
||||
if (imageText != null) {
|
||||
imageText.setText(getDefaultImageNamePattern());
|
||||
imageText.setEnabled(false);
|
||||
}
|
||||
if (tagText != null) {
|
||||
tagText.setText(getDefaultImageTagPattern());
|
||||
tagText.setEnabled(false);
|
||||
}
|
||||
} else if (selectedNodes.length == 1) {
|
||||
ProcessItem selectedProcessItem = ExportJobUtil.getProcessItem(Arrays.asList(selectedNodes));
|
||||
imageText.setText(getDefaultImageName(selectedProcessItem));
|
||||
imageText.setEnabled(true);
|
||||
tagText.setText(getDefaultImageTag(selectedProcessItem));
|
||||
tagText.setEnabled(true);
|
||||
if (imageText != null) {
|
||||
imageText.setText(getDefaultImageName(selectedProcessItem));
|
||||
imageText.setEnabled(true);
|
||||
}
|
||||
if (tagText != null) {
|
||||
tagText.setText(getDefaultImageTag(selectedProcessItem));
|
||||
tagText.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1643,5 +1675,4 @@ public class JavaJobScriptsExportWSWizardPage extends JavaJobScriptsExportWizard
|
||||
return super.finish();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class LimitESBConsumerJobChecker extends AbstractJobNodeChecker {
|
||||
}
|
||||
String componentName = nodeType.getComponentName();
|
||||
if (isESBConsumerComponent(componentName)) {
|
||||
if (exportType != JobExportType.POJO) {
|
||||
if (exportType != JobExportType.POJO && exportType != JobExportType.IMAGE) {
|
||||
return Messages.getString("LimitESBConsumerJobChecker.limit_tRESTClient_tESBConsumer", componentName);
|
||||
}
|
||||
return checkLimitFeaturesWhenBuildStandalone(nodeType);
|
||||
|
||||
@@ -104,6 +104,7 @@ public class BuildJobHandler extends AbstractBuildJobHandler {
|
||||
//
|
||||
argumentsMap.put(TalendProcessArgumentConstant.ARG_ENABLE_STATS, isOptionChoosed(ExportChoice.addStatistics));
|
||||
argumentsMap.put(TalendProcessArgumentConstant.ARG_ENABLE_TRACS, isOptionChoosed(ExportChoice.addTracs));
|
||||
argumentsMap.put(TalendProcessArgumentConstant.ARG_AVOID_BRANCH_NAME, isOptionChoosed(ExportChoice.avoidBranchName));
|
||||
Properties prop = (Properties) exportChoice.get(ExportChoice.properties);
|
||||
if (prop != null) { // add all properties for arugment map.
|
||||
Enumeration<Object> keys = prop.keys();
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
|
||||
import org.talend.repository.ui.wizards.exportjob.JavaJobScriptsExportWSWizardPage.JobExportType;
|
||||
import org.talend.repository.ui.wizards.exportjob.handler.BuildJobHandler;
|
||||
import org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice;
|
||||
import org.talend.repository.utils.EmfModelUtils;
|
||||
|
||||
/**
|
||||
* created by ycbai on 2015年5月15日 Detailled comment
|
||||
@@ -40,6 +41,7 @@ import org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManag
|
||||
public class BuildJobFactory {
|
||||
|
||||
public static final Map<JobExportType, String> oldBuildTypeMap = new HashMap<JobExportType, String>();
|
||||
private static final String T_REST_REQUEST = "tRESTRequest";
|
||||
private static final List<String> esbComponents;
|
||||
static {
|
||||
// from the extension point
|
||||
@@ -101,15 +103,22 @@ public class BuildJobFactory {
|
||||
if (StringUtils.isEmpty(buildType)) {
|
||||
final Object type = processItem.getProperty().getAdditionalProperties()
|
||||
.get(TalendProcessArgumentConstant.ARG_BUILD_TYPE);
|
||||
boolean esb = false;
|
||||
|
||||
boolean esb = false; //for esb consumer job and service
|
||||
if (processItem instanceof ProcessItem) {
|
||||
for (Object o : ((ProcessItem) processItem).getProcess().getNode()) {
|
||||
if (o instanceof NodeType) {
|
||||
NodeType currentNode = (NodeType) o;
|
||||
if(esbComponents.contains(currentNode.getComponentName())) {
|
||||
esb = true;
|
||||
break;
|
||||
if (null != EmfModelUtils.getComponentByName((ProcessItem) processItem, T_REST_REQUEST)) {
|
||||
if (type == null) {
|
||||
processItem.getProperty().getAdditionalProperties().put(TalendProcessArgumentConstant.ARG_BUILD_TYPE,
|
||||
oldBuildTypeMap.get(JobExportType.OSGI));
|
||||
}
|
||||
esb = true;
|
||||
} else {
|
||||
for (Object o : ((ProcessItem) processItem).getProcess().getNode()) {
|
||||
if (o instanceof NodeType) {
|
||||
NodeType node = (NodeType) o;
|
||||
if (esbComponents.contains(node.getComponentName())) {
|
||||
esb = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,7 +229,8 @@ public abstract class JobScriptsManager {
|
||||
imageTag,
|
||||
pushRegistry,
|
||||
registryUsername,
|
||||
registryPassword
|
||||
registryPassword,
|
||||
avoidBranchName
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,8 +30,10 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -65,6 +67,7 @@ import org.talend.core.runtime.process.ITalendProcessJavaProject;
|
||||
import org.talend.core.runtime.process.LastGenerationInfo;
|
||||
import org.talend.core.runtime.repository.build.BuildExportManager;
|
||||
import org.talend.core.ui.branding.IBrandingService;
|
||||
import org.talend.designer.core.ICamelDesignerCoreService;
|
||||
import org.talend.designer.core.IDesignerCoreService;
|
||||
import org.talend.designer.core.model.utils.emf.component.IMPORTType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
@@ -82,9 +85,14 @@ import org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobJavaScriptsM
|
||||
import org.talend.repository.utils.EmfModelUtils;
|
||||
import org.talend.repository.utils.TemplateProcessor;
|
||||
|
||||
import aQute.bnd.header.Attrs;
|
||||
import aQute.bnd.osgi.Analyzer;
|
||||
import aQute.bnd.osgi.Descriptors;
|
||||
import aQute.bnd.osgi.FileResource;
|
||||
import aQute.bnd.osgi.Jar;
|
||||
import aQute.bnd.service.AnalyzerPlugin;
|
||||
import aQute.bnd.service.Plugin;
|
||||
import aQute.service.reporter.Reporter;
|
||||
|
||||
/**
|
||||
* DOC ycbai class global comment. Detailled comment
|
||||
@@ -201,9 +209,40 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
|
||||
ExportFileResource libResource = getCompiledLibExportFileResource(processes);
|
||||
list.add(libResource);
|
||||
|
||||
|
||||
ExportFileResource libResourceSelected = new ExportFileResource(null, LIBRARY_FOLDER_NAME);
|
||||
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
|
||||
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(
|
||||
ICamelDesignerCoreService.class);
|
||||
|
||||
Collection<String> unselectList = camelService.getUnselectDependenciesBundle(processItem);
|
||||
List<URL> unselectListURLs = new ArrayList<>();
|
||||
|
||||
for(Set<URL> set:libResource.getAllResources()) {
|
||||
|
||||
for (URL url : set) {
|
||||
|
||||
boolean exist = false;
|
||||
for(String name: unselectList) {
|
||||
if (name.equals(new File(url.toURI()).getName())) {
|
||||
exist = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!exist) {
|
||||
unselectListURLs.add(url);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
libResourceSelected.addResources(unselectListURLs);
|
||||
}
|
||||
|
||||
// generate the META-INFO folder
|
||||
ExportFileResource metaInfoFolder = genMetaInfoFolder(libResource, processItem);
|
||||
ExportFileResource metaInfoFolder = genMetaInfoFolder(libResourceSelected, processItem);
|
||||
list.add(0, metaInfoFolder);
|
||||
|
||||
ExportFileResource providedLibResources = getProvidedLibExportFileResource(processes);
|
||||
@@ -709,6 +748,7 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
Manifest manifest = null;
|
||||
try {
|
||||
manifest = analyzer.calcManifest();
|
||||
filterImportPackages(manifest);
|
||||
} catch (IOException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
@@ -718,6 +758,38 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
}
|
||||
return manifest;
|
||||
}
|
||||
|
||||
private void filterImportPackages(Manifest manifest) {
|
||||
|
||||
// remove import packages which are present in private packages
|
||||
|
||||
List<String> privatePackages = new ArrayList<String>();
|
||||
String privatePackagesString = manifest.getMainAttributes().getValue(Analyzer.PRIVATE_PACKAGE);
|
||||
if (privatePackagesString != null) {
|
||||
String [] packages = privatePackagesString.split(",");
|
||||
for (String p : packages) {
|
||||
privatePackages.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder fileterdImportPackage = new StringBuilder();
|
||||
String importPackagesString = manifest.getMainAttributes().getValue(Analyzer.IMPORT_PACKAGE);
|
||||
if (importPackagesString != null) {
|
||||
String [] packages = importPackagesString.split(",");
|
||||
for (String p : packages) {
|
||||
String importPackage = p.split(";")[0];
|
||||
if (!privatePackages.contains(importPackage) || importPackage.startsWith("routines")) {
|
||||
fileterdImportPackage.append(p).append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String str = fileterdImportPackage.toString();
|
||||
if (str != null && str.length() > 0 && str.endsWith(",")) {
|
||||
str = str.substring(0, str.length() - 1);
|
||||
}
|
||||
manifest.getMainAttributes().putValue(Analyzer.IMPORT_PACKAGE, str);
|
||||
}
|
||||
|
||||
protected Analyzer createAnalyzer(ExportFileResource libResource, ProcessItem processItem) throws IOException {
|
||||
Analyzer analyzer = new Analyzer();
|
||||
@@ -751,7 +823,9 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
Set<URL> resources = libResource.getResourcesByRelativePath(path);
|
||||
for (URL url : resources) {
|
||||
// TESB-21804:Fail to deploy cMessagingEndpoint with quartz component in runtime for ClassCastException
|
||||
if (url.getPath().matches("(.*)camel-(.*)-alldep-(.*)$")) {
|
||||
if (url.getPath().matches("(.*)camel-(.*)-alldep-(.*)$")
|
||||
|| url.getPath().matches("(.*)activemq-all-[\\d\\.]*.jar$")
|
||||
|| url.getPath().matches("(.*)jms[\\d\\.-]*.jar$")) {
|
||||
continue;
|
||||
}
|
||||
File dependencyFile = new File(FilesUtils.getFileRealPath(url.getPath()));
|
||||
@@ -773,6 +847,11 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
bundleNativeCode.setLength(bundleNativeCode.length() - 1);
|
||||
analyzer.setProperty(Analyzer.BUNDLE_NATIVECODE, bundleNativeCode.toString());
|
||||
}
|
||||
|
||||
// TESB-24730 set specific version for "javax.annotation"
|
||||
ImportedPackageRangeReplacer r = new ImportedPackageRangeReplacer();
|
||||
r.addRange("javax.annotation", "[1.3,2)");
|
||||
analyzer.addBasicPlugin(r);
|
||||
|
||||
return analyzer;
|
||||
}
|
||||
@@ -967,4 +1046,116 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
}
|
||||
return imports;
|
||||
}
|
||||
|
||||
private class ImportedPackageRangeReplacer implements AnalyzerPlugin, Plugin {
|
||||
|
||||
private Set<Range> ranges = new TreeSet<>();
|
||||
|
||||
public void addRange(String packageName, String packageVersion) {
|
||||
ranges.add(new Range(packageName, packageVersion));
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyzes the jar and update the version range.
|
||||
*
|
||||
* @param analyzer the analyzer
|
||||
* @return {@code false}
|
||||
* @throws Exception if the analaysis fails.
|
||||
*/
|
||||
@Override
|
||||
public boolean analyzeJar(Analyzer analyzer) throws Exception {
|
||||
|
||||
if (analyzer.getReferred() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Map.Entry<Descriptors.PackageRef, Attrs> entry : analyzer.getReferred().entrySet()) {
|
||||
for (Range range : ranges) {
|
||||
if (range.matches(entry.getKey().getFQN())) {
|
||||
String value = range.getRange(analyzer);
|
||||
if (value != null) {
|
||||
entry.getValue().put("version", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private class Range implements Comparable<Range> {
|
||||
final String name;
|
||||
final String value;
|
||||
final Pattern regex;
|
||||
|
||||
private String foundRange;
|
||||
|
||||
private Range(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.regex = Pattern.compile(name.trim().replace(".", "\\.").replace("*", ".*"));
|
||||
}
|
||||
|
||||
private boolean matches(String pck) {
|
||||
return regex.matcher(pck).matches();
|
||||
}
|
||||
|
||||
private String getRange(Analyzer analyzer) throws Exception {
|
||||
if (foundRange != null) {
|
||||
return foundRange;
|
||||
}
|
||||
if (null == value || value.isEmpty()) {
|
||||
for (Jar jar : analyzer.getClasspath()) {
|
||||
if (isProvidedByJar(jar) && jar.getVersion() != null) {
|
||||
foundRange = jar.getVersion();
|
||||
return jar.getVersion();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isProvidedByJar(Jar jar) {
|
||||
for (String s : jar.getPackages()) {
|
||||
if (matches(s)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Range o) {
|
||||
return Integer.compare(this.regex.pattern().length(), o.regex.pattern().length());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Range range = (Range) o;
|
||||
return Objects.equals(name, range.name) &&
|
||||
Objects.equals(value, range.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(name + value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReporter(Reporter processor) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperties(Map<String, String> map) throws Exception {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,11 @@
|
||||
// ============================================================================
|
||||
package org.talend.designer.core.model.process;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.draw2d.geometry.Point;
|
||||
import org.junit.After;
|
||||
@@ -362,4 +366,61 @@ public class ConnectionManagerTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckCircle() {
|
||||
Process process = new Process(createProperty());
|
||||
IComponent component = ComponentsFactoryProvider.getInstance().get("tJava", ComponentCategory.CATEGORY_4_DI.getName());
|
||||
Node sourceNode = new Node(componentSource, process);
|
||||
Node targetNode = new Node(componentTarget, process);
|
||||
Node middleNode_1 = new Node(component, process);
|
||||
Node middleNode_2 = new Node(component, process);
|
||||
Node middleNode_3 = new Node(component, process);
|
||||
|
||||
// sourceNode -> middleNode_1 -> targetNode
|
||||
resetNodeConnection(sourceNode);
|
||||
resetNodeConnection(middleNode_1);
|
||||
resetNodeConnection(targetNode);
|
||||
((List<Connection>) middleNode_1.getIncomingConnections()).add(new Connection(sourceNode, middleNode_1,
|
||||
EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "testRow", "testRow", "testRow", false));
|
||||
((List<Connection>) targetNode.getIncomingConnections()).add(new Connection(middleNode_1, targetNode,
|
||||
EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "testRow", "testRow", "testRow", false));
|
||||
Assert.assertFalse(ConnectionManager.checkCircle(middleNode_1, targetNode));
|
||||
|
||||
// TUP-22620 source==target, no incomming connections
|
||||
Assert.assertTrue(ConnectionManager.checkCircle(sourceNode, sourceNode));
|
||||
|
||||
// for circle connection, test checkCircle by canConnectToTrget
|
||||
// sourceNode -> targetNode -> sourceNode
|
||||
resetNodeConnection(sourceNode);
|
||||
resetNodeConnection(middleNode_1);
|
||||
resetNodeConnection(targetNode);
|
||||
((List<Connection>) targetNode.getIncomingConnections()).add(new Connection(sourceNode, targetNode,
|
||||
EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "testRow", "testRow", "testRow", false));
|
||||
Assert.assertFalse(ConnectionManager.canConnectToTarget(targetNode, null, sourceNode, EConnectionType.FLOW_MAIN,
|
||||
EConnectionType.FLOW_MAIN.getName(), "testRow"));
|
||||
|
||||
// sourceNode -> middleNode_1 -> middleNode_2 -> middleNode_3 -> middleNode_1 -> targetNode
|
||||
resetNodeConnection(sourceNode);
|
||||
resetNodeConnection(targetNode);
|
||||
((List<Connection>) middleNode_1.getIncomingConnections()).add(new Connection(sourceNode, middleNode_1,
|
||||
EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "testRow", "testRow", "testRow", false));
|
||||
((List<Connection>) middleNode_2.getIncomingConnections()).add(new Connection(middleNode_1, middleNode_2,
|
||||
EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "testRow", "testRow", "testRow", false));
|
||||
|
||||
((List<Connection>) middleNode_1.getIncomingConnections()).add(new Connection(middleNode_3, middleNode_1,
|
||||
EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "testRow", "testRow", "testRow", false));
|
||||
((List<Connection>) targetNode.getIncomingConnections()).add(new Connection(middleNode_1, targetNode,
|
||||
EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "testRow", "testRow", "testRow", false));
|
||||
Assert.assertFalse(ConnectionManager.canConnectToTarget(middleNode_2, null, middleNode_3, EConnectionType.FLOW_MAIN,
|
||||
EConnectionType.FLOW_MAIN.getName(), "testRow"));
|
||||
|
||||
}
|
||||
|
||||
private static void resetNodeConnection(Node node) {
|
||||
List<Connection> inconnections = new ArrayList<Connection>();
|
||||
node.setIncomingConnections(inconnections);
|
||||
List<Connection> outconnections = new ArrayList<Connection>();
|
||||
node.setOutgoingConnections(outconnections);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package org.talend.designer.dbmap.language.generation;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,18 +19,22 @@ import org.talend.core.context.Context;
|
||||
import org.talend.core.context.RepositoryContext;
|
||||
import org.talend.core.model.components.ComponentCategory;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
import org.talend.core.model.context.JobContext;
|
||||
import org.talend.core.model.context.JobContextManager;
|
||||
import org.talend.core.model.context.JobContextParameter;
|
||||
import org.talend.core.model.metadata.IMetadataColumn;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
import org.talend.core.model.metadata.MetadataColumn;
|
||||
import org.talend.core.model.metadata.MetadataTable;
|
||||
import org.talend.core.model.process.EConnectionType;
|
||||
import org.talend.core.model.process.IConnection;
|
||||
import org.talend.core.model.process.IContextParameter;
|
||||
import org.talend.core.model.process.INodeConnector;
|
||||
import org.talend.core.model.properties.PropertiesFactory;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.utils.TalendTextUtils;
|
||||
import org.talend.core.ui.component.ComponentsFactoryProvider;
|
||||
import org.talend.designer.core.model.components.EParameterName;
|
||||
import org.talend.designer.core.model.components.ElementParameter;
|
||||
import org.talend.designer.core.model.components.NodeConnector;
|
||||
import org.talend.designer.core.ui.editor.connections.Connection;
|
||||
@@ -134,11 +140,85 @@ public class DbGenerationManagerTest extends DbGenerationManagerTestHelper {
|
||||
|
||||
@Test
|
||||
public void testInitExpression() {
|
||||
checkValue("t1.\\\"id\\\"", extMapEntry);
|
||||
checkValue("t1.\\\"id\\\"", extMapEntry);
|
||||
|
||||
ExternalDbMapEntry extMapEntry2 = new ExternalDbMapEntry("multiple", "t1.id + t1.name");
|
||||
tableEntries.add(extMapEntry2);
|
||||
checkValue("t1.\\\"id\\\" + t1.\\\"name\\\"", extMapEntry2);
|
||||
|
||||
testWithQuote();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplaceAuotes() {
|
||||
String quote = "\"";
|
||||
String quoParser = "[\\\\]?\\" + quote; //$NON-NLS-1$
|
||||
DbGenerationManager dbManager = new GenericDbGenerationManager();
|
||||
|
||||
String expression = "'\"" + "+" + "(String)globalMap.get(\"BusinessDateStr\")" + "+" + "\"' BETWEEN PROD_GRP_DA.EFF_FRM_DT AND PROD_GRP_DA.EFF_TO_DT";
|
||||
|
||||
assertEquals(expression.trim(), dbManager.replaceAuotes(expression, quoParser, quote).trim());
|
||||
|
||||
expression = "'\"" + "+" + "(String)globalMap.get(\"BusinessDateStr\")" + "+" + "\" BETWEEN PROD_GRP_DA.EFF_FRM_DT AND PROD_GRP_DA.EFF_TO_DT";
|
||||
String expect = "'\\\"" + "+" + "(String)globalMap.get(\\\"BusinessDateStr\\\")" + "+" + "\\\" BETWEEN PROD_GRP_DA.EFF_FRM_DT AND PROD_GRP_DA.EFF_TO_DT";
|
||||
|
||||
assertEquals(expect.trim(), dbManager.replaceAuotes(expression, quoParser, quote).trim());
|
||||
|
||||
expression = "BETWEEN PROD_GRP_DA.EFF_FRM_DT AND PROD_GRP_DA.EFF_TO_DT";
|
||||
expect = "BETWEEN PROD_GRP_DA.EFF_FRM_DT AND PROD_GRP_DA.EFF_TO_DT";
|
||||
assertEquals(expect.trim(), dbManager.replaceAuotes(expression, quoParser, quote).trim());
|
||||
|
||||
expression = "'" +"+"+"context.param1"+"+"+ "aaa";
|
||||
expect = "'" +"+"+"context.param1"+"+"+ "aaa";
|
||||
|
||||
assertEquals(expect.trim(), dbManager.replaceAuotes(expression, quoParser, quote).trim());
|
||||
|
||||
expression = "'\"" +"+"+"context.param1"+"+"+ "\"'aaa";
|
||||
expect = "'\"" +"+"+"context.param1"+"+"+ "\"'aaa";
|
||||
|
||||
assertEquals(expect.trim(), dbManager.replaceAuotes(expression, quoParser, quote).trim());
|
||||
|
||||
expression = "'context.param1'";
|
||||
assertEquals(expression, dbManager.replaceAuotes(expression, quoParser, quote).trim());
|
||||
|
||||
expression = "table1.name = 'context.param2'";
|
||||
assertEquals(expression, dbManager.replaceAuotes(expression, quoParser, quote).trim());
|
||||
|
||||
expression = "table1.name = 'context.param2' aa";
|
||||
assertEquals(expression, dbManager.replaceAuotes(expression, quoParser, quote).trim());
|
||||
}
|
||||
|
||||
private void testWithQuote(){
|
||||
dbManager.setUseDelimitedIdentifiers(true);
|
||||
List<IConnection> incomingConnections = new ArrayList<IConnection>();
|
||||
String[] columns = new String[] { "id", "name"};
|
||||
String[] labels = new String[] { "id", "name"};
|
||||
incomingConnections.add(createConnection("t1", "t1", labels, columns));
|
||||
dbMapComponent.setIncomingConnections(incomingConnections);
|
||||
|
||||
ElementParameter param = new ElementParameter(dbMapComponent);
|
||||
param.setName(EParameterName.MAPPING.getName());
|
||||
param.setValue("mysql_id");
|
||||
List<ElementParameter> list = new ArrayList<>();
|
||||
list.add(param);
|
||||
dbMapComponent.setElementParameters(list);
|
||||
checkValue("t1.`id`", extMapEntry);
|
||||
|
||||
ExternalDbMapEntry extMapEntry3 = new ExternalDbMapEntry("multiple", "if(t1.id<2500,\"<2500\",\">=2500\")");
|
||||
tableEntries.add(extMapEntry3);
|
||||
checkValue("if(t1.`id`<2500,\\\"<2500\\\",\\\">=2500\\\")", extMapEntry3);
|
||||
|
||||
ExternalDbMapEntry extMapEntry2 = new ExternalDbMapEntry("multiple", "t1.id + t1.name");
|
||||
tableEntries.add(extMapEntry2);
|
||||
checkValue("t1.`id` + t1.`name`", extMapEntry2);
|
||||
|
||||
param.setValue("oracle_id");
|
||||
checkValue("t1.\\\"id\\\"", extMapEntry);
|
||||
checkValue("t1.\\\"id\\\" + t1.\\\"name\\\"", extMapEntry2);
|
||||
|
||||
param.setValue("mssql_id");
|
||||
checkValue("t1.\\\"id\\\"", extMapEntry);
|
||||
checkValue("t1.\\\"id\\\" + t1.\\\"name\\\"", extMapEntry2);
|
||||
}
|
||||
|
||||
public void checkValue(String expression, ExternalDbMapEntry entry) {
|
||||
@@ -381,4 +461,313 @@ public class DbGenerationManagerTest extends DbGenerationManagerTestHelper {
|
||||
dbManager.appendSqlQuery(sb, "table1", false);
|
||||
Assert.assertTrue(dbManager.getQuerySegments().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildSqlSelect() {
|
||||
runBuildSql("","table1","table2","table3");
|
||||
|
||||
}
|
||||
|
||||
private void runBuildSql(String schema, String table1, String table2, String table3) {
|
||||
List<IConnection> incomingConnections = new ArrayList<IConnection>();
|
||||
String[] mainTableEntities = new String[] { "id", "name" };
|
||||
incomingConnections.add(mockConnection(schema, table1, mainTableEntities));
|
||||
dbMapComponent.setIncomingConnections(incomingConnections);
|
||||
|
||||
ExternalDbMapData externalData = new ExternalDbMapData();
|
||||
List<ExternalDbMapTable> inputs = new ArrayList<ExternalDbMapTable>();
|
||||
List<ExternalDbMapTable> outputs = new ArrayList<ExternalDbMapTable>();
|
||||
// main table
|
||||
ExternalDbMapTable inputTable = new ExternalDbMapTable();
|
||||
String mainTableName = "".equals(schema) ? table1 : schema + "." + table1;
|
||||
// quote will be removed in the ui for connections ,so we do the same for test
|
||||
String mainTableNameNoQuote = TalendTextUtils.removeQuotes(mainTableName);
|
||||
inputTable.setTableName(mainTableNameNoQuote);
|
||||
inputTable.setName(mainTableName);
|
||||
List<ExternalDbMapEntry> entities = getMetadataEntities(mainTableEntities, new String[3]);
|
||||
inputTable.setMetadataTableEntries(entities);
|
||||
inputs.add(inputTable);
|
||||
|
||||
// output
|
||||
ExternalDbMapTable outputTable = new ExternalDbMapTable();
|
||||
mainTableName = "".equals(schema) ? table2 : schema + "." + table2;
|
||||
// quote will be removed in the ui for connections ,so we do the same for test
|
||||
mainTableNameNoQuote = TalendTextUtils.removeQuotes(mainTableName);
|
||||
outputTable.setTableName(mainTableNameNoQuote);
|
||||
outputTable.setName("table2");
|
||||
String[] names = new String[] { "id", "name" };
|
||||
String mainTable = mainTableName;
|
||||
String[] expressions = new String[] { "table1.id", "table1.name"};
|
||||
outputTable.setMetadataTableEntries(getMetadataEntities(names, expressions));
|
||||
|
||||
String[] whereNames = new String[]{"whereFilter"};
|
||||
String[] whereExps = new String[]{"table1.name = " + "'context.param2'"};
|
||||
outputTable.setCustomWhereConditionsEntries(getMetadataEntities(whereNames, whereExps));
|
||||
|
||||
String[] otherNames = new String[]{"otherFilter"};
|
||||
String[] otherExps = new String[]{"table1.id = " + "'context.param1'"};
|
||||
outputTable.setCustomOtherConditionsEntries(getMetadataEntities(otherNames, otherExps));
|
||||
outputs.add(outputTable);
|
||||
|
||||
externalData.setInputTables(inputs);
|
||||
externalData.setOutputTables(outputs);
|
||||
dbMapComponent.setExternalData(externalData);
|
||||
List<IMetadataTable> metadataList = new ArrayList<IMetadataTable>();
|
||||
MetadataTable metadataTable = getMetadataTable(names);
|
||||
metadataTable.setLabel("table2");
|
||||
metadataList.add(metadataTable);
|
||||
dbMapComponent.setMetadataList(metadataList);
|
||||
JobContext newContext = new JobContext("Default");
|
||||
List<IContextParameter> newParamList = new ArrayList<IContextParameter>();
|
||||
newContext.setContextParameterList(newParamList);
|
||||
JobContextParameter param = new JobContextParameter();
|
||||
param.setName("schema");
|
||||
newParamList.add(param);
|
||||
process = mock(Process.class);
|
||||
JobContextManager contextManger = new JobContextManager();
|
||||
contextManger.setDefaultContext(newContext);
|
||||
when(process.getContextManager()).thenReturn(contextManger);
|
||||
dbMapComponent.setProcess(process);
|
||||
|
||||
ExternalDbMapData externalData2 = new ExternalDbMapData();
|
||||
DbMapComponent dbMapComponent2 = new DbMapComponent();
|
||||
dbMapComponent2.setExternalData(externalData2);
|
||||
mainTableEntities = new String[] {"id", "name"};
|
||||
|
||||
List<IConnection> outgoingConnections = new ArrayList<IConnection>();
|
||||
Node map1 = mockNode(dbMapComponent);
|
||||
outgoingConnections.add(mockConnection(map1, schema, table2, mainTableEntities));
|
||||
dbMapComponent.setOutgoingConnections(outgoingConnections);
|
||||
dbMapComponent2.setIncomingConnections(outgoingConnections);
|
||||
|
||||
inputs = new ArrayList<ExternalDbMapTable>();
|
||||
outputs = new ArrayList<ExternalDbMapTable>();
|
||||
// main table
|
||||
inputTable = new ExternalDbMapTable();
|
||||
mainTableName = "".equals(schema) ? table2 : schema + "." + table2;
|
||||
// quote will be removed in the ui for connections ,so we do the same for test
|
||||
mainTableNameNoQuote = TalendTextUtils.removeQuotes(mainTableName);
|
||||
inputTable.setTableName(mainTableNameNoQuote);
|
||||
inputTable.setName("table2");
|
||||
entities = getMetadataEntities(mainTableEntities, new String[3]);
|
||||
inputTable.setMetadataTableEntries(entities);
|
||||
inputs.add(inputTable);
|
||||
|
||||
// output
|
||||
outputTable = new ExternalDbMapTable();
|
||||
mainTableName = "".equals(schema) ? table3 : schema + "." + table3;
|
||||
// quote will be removed in the ui for connections ,so we do the same for test
|
||||
mainTableNameNoQuote = TalendTextUtils.removeQuotes(mainTableName);
|
||||
outputTable.setTableName(mainTableNameNoQuote);
|
||||
outputTable.setName("table3");
|
||||
names = new String[] { "id", "name"};
|
||||
mainTable = mainTableName;
|
||||
expressions = new String[] { "table2.id", "table2.name"};
|
||||
outputTable.setMetadataTableEntries(getMetadataEntities(names, expressions));
|
||||
outputs.add(outputTable);
|
||||
|
||||
externalData2.setInputTables(inputs);
|
||||
externalData2.setOutputTables(outputs);
|
||||
dbMapComponent2.setExternalData(externalData2);
|
||||
metadataList = new ArrayList<IMetadataTable>();
|
||||
metadataTable = getMetadataTable(names);
|
||||
metadataTable.setLabel("table3");
|
||||
metadataList.add(metadataTable);
|
||||
dbMapComponent2.setMetadataList(metadataList);
|
||||
if (dbMapComponent2.getElementParameters() == null) {
|
||||
dbMapComponent2.setElementParameters(Collections.EMPTY_LIST);
|
||||
}
|
||||
JobContextParameter param1 = new JobContextParameter();
|
||||
param1.setName("param1");
|
||||
newParamList.add(param1);
|
||||
|
||||
JobContextParameter param2 = new JobContextParameter();
|
||||
param2.setName("param2");
|
||||
newParamList.add(param2);
|
||||
dbMapComponent2.setProcess(process);
|
||||
outgoingConnections = new ArrayList<IConnection>();
|
||||
outgoingConnections.add(mockConnection(schema, table3, mainTableEntities));
|
||||
dbMapComponent2.setOutgoingConnections(outgoingConnections);
|
||||
|
||||
ElementParameter comName = new ElementParameter(dbMapComponent);
|
||||
comName.setName("COMPONENT_NAME");
|
||||
comName.setValue("tELTMap");
|
||||
List<ElementParameter> list = new ArrayList<>();
|
||||
list.add(comName);
|
||||
dbMapComponent.setElementParameters(list);
|
||||
|
||||
dbManager = new GenericDbGenerationManager();
|
||||
String query = dbManager.buildSqlSelect(dbMapComponent2, "table3").replaceAll("\n", "");
|
||||
String exceptQuery = "\"SELECT\n"
|
||||
+ "table2.id, table2.name\n"
|
||||
+ "FROM\n"
|
||||
+ " (\n"
|
||||
+" SELECT\n"
|
||||
+" table1.id AS id, table1.name AS name\n"
|
||||
+" FROM\n"
|
||||
+" table1\n"
|
||||
+" WHERE table1.name = '\" +context.param2+ \"'\n"
|
||||
+" table1.id = '\" +context.param1+ \"'\n"
|
||||
+" \n"
|
||||
+" ) table2\"";
|
||||
assertEquals(exceptQuery.replaceAll("\n", "").trim(), query.trim());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildSqlSelect_endWithContext() {
|
||||
|
||||
String schema = "";
|
||||
String table1 = "table1";
|
||||
String table2 = "table2";
|
||||
String table3 = "table3";
|
||||
List<IConnection> incomingConnections = new ArrayList<IConnection>();
|
||||
String[] mainTableEntities = new String[] { "id", "column1", "column2" };
|
||||
incomingConnections.add(mockConnection(schema, table1, mainTableEntities));
|
||||
dbMapComponent.setIncomingConnections(incomingConnections);
|
||||
|
||||
ExternalDbMapData externalData = new ExternalDbMapData();
|
||||
List<ExternalDbMapTable> inputs = new ArrayList<ExternalDbMapTable>();
|
||||
List<ExternalDbMapTable> outputs = new ArrayList<ExternalDbMapTable>();
|
||||
// main table
|
||||
ExternalDbMapTable inputTable = new ExternalDbMapTable();
|
||||
String mainTableName = "".equals(schema) ? table1 : schema + "." + table1;
|
||||
// quote will be removed in the ui for connections ,so we do the same for test
|
||||
String mainTableNameNoQuote = TalendTextUtils.removeQuotes(mainTableName);
|
||||
inputTable.setTableName(mainTableNameNoQuote);
|
||||
inputTable.setName(mainTableName);
|
||||
List<ExternalDbMapEntry> entities = getMetadataEntities(mainTableEntities, new String[3]);
|
||||
inputTable.setMetadataTableEntries(entities);
|
||||
inputs.add(inputTable);
|
||||
|
||||
// output
|
||||
ExternalDbMapTable outputTable = new ExternalDbMapTable();
|
||||
mainTableName = "".equals(schema) ? table2 : schema + "." + table2;
|
||||
// quote will be removed in the ui for connections ,so we do the same for test
|
||||
mainTableNameNoQuote = TalendTextUtils.removeQuotes(mainTableName);
|
||||
outputTable.setTableName(mainTableNameNoQuote);
|
||||
outputTable.setName("table2");
|
||||
String[] names = new String[] { "id", "column1", "column2" };
|
||||
String mainTable = mainTableName;
|
||||
String[] expressions = new String[] { "table1.id",
|
||||
"CASE WHEN table1.column1 IS NULL THEN context.param1 ELSE table1.column1 END", "table1.column2" };
|
||||
outputTable.setMetadataTableEntries(getMetadataEntities(names, expressions));
|
||||
|
||||
String[] whereNames = new String[] { "whereFilter" };
|
||||
String[] whereExps = new String[] { "t.column2 = context.param2" };
|
||||
outputTable.setCustomWhereConditionsEntries(getMetadataEntities(whereNames, whereExps));
|
||||
outputs.add(outputTable);
|
||||
externalData.setInputTables(inputs);
|
||||
externalData.setOutputTables(outputs);
|
||||
dbMapComponent.setExternalData(externalData);
|
||||
List<IMetadataTable> metadataList = new ArrayList<IMetadataTable>();
|
||||
MetadataTable metadataTable = getMetadataTable(names);
|
||||
metadataTable.setLabel("table2");
|
||||
metadataList.add(metadataTable);
|
||||
dbMapComponent.setMetadataList(metadataList);
|
||||
JobContext newContext = new JobContext("Default");
|
||||
List<IContextParameter> newParamList = new ArrayList<IContextParameter>();
|
||||
newContext.setContextParameterList(newParamList);
|
||||
JobContextParameter param = new JobContextParameter();
|
||||
param.setName("schema");
|
||||
newParamList.add(param);
|
||||
process = mock(Process.class);
|
||||
JobContextManager contextManger = new JobContextManager();
|
||||
contextManger.setDefaultContext(newContext);
|
||||
when(process.getContextManager()).thenReturn(contextManger);
|
||||
dbMapComponent.setProcess(process);
|
||||
|
||||
ExternalDbMapData externalData2 = new ExternalDbMapData();
|
||||
DbMapComponent dbMapComponent2 = new DbMapComponent();
|
||||
dbMapComponent2.setExternalData(externalData2);
|
||||
mainTableEntities = new String[] { "id", "column1", "column2" };
|
||||
|
||||
List<IConnection> outgoingConnections = new ArrayList<IConnection>();
|
||||
Node map1 = mockNode(dbMapComponent);
|
||||
outgoingConnections.add(mockConnection(map1, schema, table2, mainTableEntities));
|
||||
dbMapComponent.setOutgoingConnections(outgoingConnections);
|
||||
dbMapComponent2.setIncomingConnections(outgoingConnections);
|
||||
|
||||
inputs = new ArrayList<ExternalDbMapTable>();
|
||||
outputs = new ArrayList<ExternalDbMapTable>();
|
||||
// main table
|
||||
inputTable = new ExternalDbMapTable();
|
||||
mainTableName = "".equals(schema) ? table2 : schema + "." + table2;
|
||||
// quote will be removed in the ui for connections ,so we do the same for test
|
||||
mainTableNameNoQuote = TalendTextUtils.removeQuotes(mainTableName);
|
||||
inputTable.setTableName(mainTableNameNoQuote);
|
||||
inputTable.setName("table2");
|
||||
entities = getMetadataEntities(mainTableEntities, new String[3]);
|
||||
inputTable.setMetadataTableEntries(entities);
|
||||
inputs.add(inputTable);
|
||||
|
||||
// output
|
||||
outputTable = new ExternalDbMapTable();
|
||||
mainTableName = "".equals(schema) ? table3 : schema + "." + table3;
|
||||
// quote will be removed in the ui for connections ,so we do the same for test
|
||||
mainTableNameNoQuote = TalendTextUtils.removeQuotes(mainTableName);
|
||||
outputTable.setTableName(mainTableNameNoQuote);
|
||||
outputTable.setName("table3");
|
||||
names = new String[] { "id", "column1", "column2" };
|
||||
mainTable = mainTableName;
|
||||
expressions = new String[] { "table2.id", "table2.column1", "table2.column2" };
|
||||
outputTable.setMetadataTableEntries(getMetadataEntities(names, expressions));
|
||||
whereNames = new String[] { "whereFilter" };
|
||||
whereExps = new String[] { "t.column2A = context.param2A" };
|
||||
outputTable.setCustomWhereConditionsEntries(getMetadataEntities(whereNames, whereExps));
|
||||
outputs.add(outputTable);
|
||||
|
||||
externalData2.setInputTables(inputs);
|
||||
externalData2.setOutputTables(outputs);
|
||||
dbMapComponent2.setExternalData(externalData2);
|
||||
metadataList = new ArrayList<IMetadataTable>();
|
||||
metadataTable = getMetadataTable(names);
|
||||
metadataTable.setLabel("table3");
|
||||
metadataList.add(metadataTable);
|
||||
dbMapComponent2.setMetadataList(metadataList);
|
||||
if (dbMapComponent2.getElementParameters() == null) {
|
||||
dbMapComponent2.setElementParameters(Collections.EMPTY_LIST);
|
||||
}
|
||||
JobContextParameter param1 = new JobContextParameter();
|
||||
param1.setName("param1");
|
||||
newParamList.add(param1);
|
||||
|
||||
JobContextParameter param2 = new JobContextParameter();
|
||||
param2.setName("param2");
|
||||
newParamList.add(param2);
|
||||
dbMapComponent2.setProcess(process);
|
||||
outgoingConnections = new ArrayList<IConnection>();
|
||||
outgoingConnections.add(mockConnection(schema, table3, mainTableEntities));
|
||||
dbMapComponent2.setOutgoingConnections(outgoingConnections);
|
||||
|
||||
ElementParameter comName = new ElementParameter(dbMapComponent);
|
||||
comName.setName("COMPONENT_NAME");
|
||||
comName.setValue("tELTMap");
|
||||
List<ElementParameter> list = new ArrayList<>();
|
||||
list.add(comName);
|
||||
dbMapComponent.setElementParameters(list);
|
||||
|
||||
dbManager = new GenericDbGenerationManager() {
|
||||
|
||||
@Override
|
||||
protected java.util.List<String> getContextList(DbMapComponent component) {
|
||||
return Arrays.asList("context.param1", "context.param2", "context.param2A");
|
||||
};
|
||||
};
|
||||
|
||||
String query = dbManager.buildSqlSelect(dbMapComponent2, "table3");
|
||||
String exceptQuery = "\"SELECT\n" +
|
||||
"table2.id, table2.column1, table2.column2\n" +
|
||||
"FROM\n" +
|
||||
" (\n" +
|
||||
" SELECT\n" +
|
||||
" table1.id AS id, CASE WHEN table1.column1 IS NULL THEN \" +context.param1+ \" ELSE table1.column1 END AS column1, table1.column2 AS column2\n" +
|
||||
" FROM\n" +
|
||||
" table1\n" +
|
||||
" WHERE t.column2 = \" +context.param2+ \"\n" +
|
||||
" ) table2\n" +
|
||||
"WHERE t.column2A = \" +context.param2A";
|
||||
assertEquals(exceptQuery.trim(), query.trim());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ import static org.mockito.Mockito.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.talend.core.model.components.ComponentCategory;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
import org.talend.core.model.context.JobContext;
|
||||
import org.talend.core.model.context.JobContextManager;
|
||||
import org.talend.core.model.context.JobContextParameter;
|
||||
@@ -27,6 +29,7 @@ import org.talend.core.model.metadata.MetadataTable;
|
||||
import org.talend.core.model.process.IConnection;
|
||||
import org.talend.core.model.process.IContextParameter;
|
||||
import org.talend.core.model.utils.TalendTextUtils;
|
||||
import org.talend.core.ui.component.ComponentsFactoryProvider;
|
||||
import org.talend.designer.core.model.components.ElementParameter;
|
||||
import org.talend.designer.core.ui.editor.connections.Connection;
|
||||
import org.talend.designer.core.ui.editor.nodes.Node;
|
||||
@@ -43,6 +46,8 @@ import org.talend.designer.dbmap.external.data.ExternalDbMapTable;
|
||||
public class DbGenerationManagerTestHelper {
|
||||
|
||||
protected DbMapComponent dbMapComponent;
|
||||
|
||||
protected Process process;
|
||||
|
||||
protected void init(String schema, String main_table, String main_alias, String lookup_table, String lookup_alias) {
|
||||
List<IConnection> incomingConnections = new ArrayList<IConnection>();
|
||||
@@ -116,7 +121,7 @@ public class DbGenerationManagerTestHelper {
|
||||
param = new JobContextParameter();
|
||||
param.setName("lookup");
|
||||
newParamList.add(param);
|
||||
Process process = mock(Process.class);
|
||||
process = mock(Process.class);
|
||||
JobContextManager contextManger = new JobContextManager();
|
||||
contextManger.setDefaultContext(newContext);
|
||||
when(process.getContextManager()).thenReturn(contextManger);
|
||||
@@ -124,9 +129,15 @@ public class DbGenerationManagerTestHelper {
|
||||
|
||||
}
|
||||
|
||||
private IConnection mockConnection(String schemaName, String tableName, String[] columns) {
|
||||
protected IConnection mockConnection(String schemaName, String tableName, String[] columns) {
|
||||
return mockConnection(null, schemaName, tableName, columns);
|
||||
}
|
||||
|
||||
protected IConnection mockConnection(Node node, String schemaName, String tableName, String[] columns) {
|
||||
Connection connection = mock(Connection.class);
|
||||
Node node = mock(Node.class);
|
||||
if(node == null){
|
||||
node = mock(Node.class);
|
||||
}
|
||||
ElementParameter param = new ElementParameter(node);
|
||||
param.setName("ELT_SCHEMA_NAME");
|
||||
param.setValue(schemaName);
|
||||
@@ -155,6 +166,15 @@ public class DbGenerationManagerTestHelper {
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
protected Node mockNode(DbMapComponent mapCom) {
|
||||
Node node = mock(Node.class);
|
||||
when(node.isELTComponent()).thenReturn(true);
|
||||
IComponent component = ComponentsFactoryProvider.getInstance().get("tELTMap", ComponentCategory.CATEGORY_4_DI.getName());
|
||||
when(node.getComponent()).thenReturn(component);
|
||||
when(node.getExternalNode()).thenReturn(mapCom);
|
||||
return node;
|
||||
}
|
||||
|
||||
protected List<ExternalDbMapEntry> getMetadataEntities(String[] entitiesName, String[] expressions) {
|
||||
List<ExternalDbMapEntry> entities = new ArrayList<ExternalDbMapEntry>();
|
||||
|
||||
@@ -43,6 +43,17 @@ public class DataMapExpressionParserTest {
|
||||
verifyParseResult("schema. ((String)globalMap.get(\"main_table\")).column ");
|
||||
verifyParseResult("((String)globalMap.get(\"schema\")). table.column ");
|
||||
verifyParseResult("((String)globalMap.get(\"main_table\")).column ");
|
||||
|
||||
verifyIdentifiersResult("table.\\\"column\\\"");
|
||||
verifyIdentifiersResult("Case NVL(table.\\\"column\\\",-99) When -99 Then 'N' Else 'Y' End");
|
||||
}
|
||||
|
||||
private void verifyIdentifiersResult(String expression) {
|
||||
TableEntryLocation[] locations = parser.parseTableEntryLocations(expression);
|
||||
for (TableEntryLocation location : locations) {
|
||||
assertEquals("table", location.tableName);
|
||||
assertEquals("column", location.columnName);
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyParseResult(String expression) {
|
||||
|
||||
@@ -31,26 +31,47 @@ import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.language.ECodeLanguage;
|
||||
import org.talend.core.model.context.JobContextManager;
|
||||
import org.talend.core.model.process.IContext;
|
||||
import org.talend.core.model.process.IContextManager;
|
||||
import org.talend.core.model.process.IProcess;
|
||||
import org.talend.core.model.process.IProcess2;
|
||||
import org.talend.core.model.process.JobInfo;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.model.properties.PropertiesFactory;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.relationship.Relation;
|
||||
import org.talend.core.model.relationship.RelationshipItemBuilder;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.model.repository.RepositoryObject;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.runtime.process.ITalendProcessJavaProject;
|
||||
import org.talend.core.runtime.process.TalendProcessOptionConstants;
|
||||
import org.talend.designer.core.IDesignerCoreService;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ParametersType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory;
|
||||
import org.talend.designer.core.ui.editor.process.Process;
|
||||
import org.talend.designer.maven.model.TalendJavaProjectConstants;
|
||||
import org.talend.designer.maven.model.TalendMavenConstants;
|
||||
import org.talend.designer.maven.tools.AggregatorPomsHelper;
|
||||
import org.talend.designer.maven.utils.PomUtil;
|
||||
import org.talend.designer.runprocess.IProcessor;
|
||||
import org.talend.designer.runprocess.IRunProcessService;
|
||||
import org.talend.designer.runprocess.java.TalendJavaProjectManager;
|
||||
import org.talend.designer.runprocess.maven.MavenJavaProcessor;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.documentation.ERepositoryActionName;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
@@ -348,6 +369,145 @@ public class ProcessChangeListenerTest {
|
||||
checkRootPomModules(toRemove, toAdd);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSyncParentJobPomsForPropertyChange() throws Exception {
|
||||
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
Property maintestProp = createJobPropertyWithContext("maintest", "0.1");
|
||||
Property childtestProp = createJobPropertyWithContext("childtest", "0.1");
|
||||
|
||||
ProcessItem mainItem = (ProcessItem) maintestProp.getItem();
|
||||
mainItem.getProcess().setDefaultContext("Default");
|
||||
JobInfo mainJobInfo = new JobInfo(mainItem, mainItem.getProcess().getDefaultContext());
|
||||
ProcessItem childItem = (ProcessItem) childtestProp.getItem();
|
||||
JobInfo childJobInfo = new JobInfo(childItem, childItem.getProcess().getDefaultContext());
|
||||
childJobInfo.setJobId(childtestProp.getId());
|
||||
childJobInfo.setFatherJobInfo(mainJobInfo);
|
||||
|
||||
IProcessor mainProcessor = getProcessor(maintestProp.getItem());
|
||||
assertTrue(mainProcessor != null);
|
||||
mainProcessor.getBuildFirstChildrenJobs().add(childJobInfo);
|
||||
int option = 0;
|
||||
option |= TalendProcessOptionConstants.GENERATE_POM_ONLY;
|
||||
option |= TalendProcessOptionConstants.GENERATE_IS_MAINJOB;
|
||||
// ((MavenJavaProcessor) processor).generatePom(option);
|
||||
MavenJavaProcessor mavenProcessor = (MavenJavaProcessor) mainProcessor;
|
||||
mavenProcessor.generatePom(option);
|
||||
|
||||
// prepare relationship
|
||||
RelationshipItemBuilder relationBuilder = RelationshipItemBuilder
|
||||
.getInstance(ProjectManager.getInstance().getCurrentProject(), true);
|
||||
relationBuilder.load();
|
||||
Map<Relation, Set<Relation>> currentProjectItemsRelations = relationBuilder.getCurrentProjectItemsRelations();
|
||||
Relation baseItem = new Relation();
|
||||
baseItem.setId(maintestProp.getId());
|
||||
baseItem.setType(RelationshipItemBuilder.JOB_RELATION);
|
||||
baseItem.setVersion("0.1");
|
||||
Relation relatedItem = new Relation();
|
||||
relatedItem.setId(childtestProp.getId());
|
||||
relatedItem.setVersion(RelationshipItemBuilder.LATEST_VERSION);
|
||||
relatedItem.setType(RelationshipItemBuilder.JOB_RELATION);
|
||||
currentProjectItemsRelations.put(baseItem, new HashSet<Relation>());
|
||||
currentProjectItemsRelations.get(baseItem).add(relatedItem);
|
||||
relationBuilder.saveRelations();
|
||||
|
||||
IFile maintestPom = getJobPomFile(maintestProp);
|
||||
assertTrue(maintestPom.exists());
|
||||
// expect: parentJob pom exist childJob dependency
|
||||
assertTrue(PomUtil.checkIfJobDependencyExist(maintestPom, childtestProp));
|
||||
|
||||
// to upgrade child job version
|
||||
IRepositoryViewObject childObject = factory.getSpecificVersion(childtestProp.getId(), childtestProp.getVersion(), true);
|
||||
RepositoryObject upperChildObject = new RepositoryObject(childObject.getProperty());
|
||||
Property upperProperty = upperChildObject.getProperty();
|
||||
upperProperty.setVersion("0.2");
|
||||
factory.save(upperProperty, childtestProp.getLabel(), childtestProp.getVersion());
|
||||
RelationshipItemBuilder.getInstance().addOrUpdateItem(upperChildObject.getProperty().getItem());
|
||||
|
||||
// to moke the process of syncParentJobPomsForPropertyChange
|
||||
List<Relation> itemsHaveRelationWith = RelationshipItemBuilder.getInstance()
|
||||
.getItemsHaveRelationWith(upperProperty.getId(), upperProperty.getVersion());
|
||||
assertTrue(itemsHaveRelationWith.size() == 1);
|
||||
Relation relation = itemsHaveRelationWith.get(0);
|
||||
assertTrue(relation.getId().equals(maintestProp.getId()));
|
||||
assertTrue(relation.getVersion().equals(maintestProp.getVersion()));
|
||||
// will get latest version childJobInfo in ProcessorUtilities.getSubjobInfo
|
||||
mainProcessor.getBuildFirstChildrenJobs().clear();
|
||||
ProcessItem upperItem = (ProcessItem) upperChildObject.getProperty().getItem();
|
||||
JobInfo newChildJobInfo = new JobInfo(upperItem, upperItem.getProcess().getDefaultContext());
|
||||
newChildJobInfo.setJobId(upperProperty.getId());
|
||||
newChildJobInfo.setFatherJobInfo(mainJobInfo);
|
||||
mainProcessor.getBuildFirstChildrenJobs().add(newChildJobInfo);
|
||||
mavenProcessor.generatePom(option);
|
||||
|
||||
// expect: after childJob upgrade version, parentJob pom exist childJob dependency
|
||||
// dependency version should be new version
|
||||
assertTrue(PomUtil.checkIfJobDependencyExist(maintestPom, upperProperty));
|
||||
|
||||
}
|
||||
|
||||
private Property createJobPropertyWithContext(String label, String version) throws Exception {
|
||||
Property property = PropertiesFactory.eINSTANCE.createProperty();
|
||||
String id = ProxyRepositoryFactory.getInstance().getNextId();
|
||||
property.setId(id);
|
||||
property.setLabel(label);
|
||||
property.setVersion(version);
|
||||
|
||||
ProcessItem item = PropertiesFactory.eINSTANCE.createProcessItem();
|
||||
item.setProperty(property);
|
||||
Process process = new Process(property);
|
||||
|
||||
ProcessType processType = TalendFileFactory.eINSTANCE.createProcessType();
|
||||
ParametersType parameterType = TalendFileFactory.eINSTANCE.createParametersType();
|
||||
processType.setParameters(parameterType);
|
||||
item.setProcess(processType);
|
||||
IContextManager contextManager = process.getContextManager();
|
||||
if (contextManager == null) {
|
||||
contextManager = new JobContextManager();
|
||||
}
|
||||
|
||||
ProxyRepositoryFactory.getInstance().create(item, new Path(""));
|
||||
testJobs.add(property);
|
||||
|
||||
return property;
|
||||
}
|
||||
|
||||
private IProcessor getProcessor(Item item) {
|
||||
GlobalServiceRegister register = GlobalServiceRegister.getDefault();
|
||||
IProcessor processor = null;
|
||||
IProcess process = null;
|
||||
IContext context = null;
|
||||
Property curProperty = item.getProperty();
|
||||
|
||||
if (register.isServiceRegistered(IDesignerCoreService.class)) {
|
||||
IDesignerCoreService designerService = (IDesignerCoreService) register.getService(IDesignerCoreService.class);
|
||||
process = designerService.getProcessFromItem(item);
|
||||
if (item.getProperty() == null && process instanceof IProcess2) {
|
||||
curProperty = ((IProcess2) process).getProperty();
|
||||
}
|
||||
context = process.getContextManager().getDefaultContext();
|
||||
}
|
||||
|
||||
if (process != null && GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
|
||||
IRunProcessService runProcessservice = (IRunProcessService) GlobalServiceRegister.getDefault()
|
||||
.getService(IRunProcessService.class);
|
||||
processor = runProcessservice.createCodeProcessor(process, curProperty, ECodeLanguage.getCodeLanguage("java"), true);
|
||||
}
|
||||
processor.setContext(context);
|
||||
|
||||
return processor;
|
||||
}
|
||||
|
||||
private IFile getJobPomFile(Property property) {
|
||||
String projectTechName = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
final IProject project = root.getProject(projectTechName);
|
||||
IFolder pomsFolder = project.getFolder(TalendJavaProjectConstants.DIR_POMS);
|
||||
IFolder jobFolder = pomsFolder.getFolder("jobs").getFolder("process")
|
||||
.getFolder(property.getLabel() + "_" + property.getVersion());
|
||||
IFile jobPom = jobFolder.getFile("pom.xml");
|
||||
return jobPom;
|
||||
}
|
||||
|
||||
private Property createJobProperty(String label, String version, boolean create) throws Exception {
|
||||
String id = ProxyRepositoryFactory.getInstance().getNextId();
|
||||
return createJobProperty(id, label, version, new Path(""), create);
|
||||
|
||||
Reference in New Issue
Block a user