Compare commits
134 Commits
patch/TPS-
...
bugfix/pat
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78acebc15f | ||
|
|
bb0ee2a746 | ||
|
|
9478ce6a0b | ||
|
|
ba425ca2b8 | ||
|
|
d2983c5c19 | ||
|
|
afec35bce4 | ||
|
|
5ab73d73a2 | ||
|
|
7a2837b9d4 | ||
|
|
e18491a014 | ||
|
|
7577d3a038 | ||
|
|
747fe520be | ||
|
|
c8bbb07688 | ||
|
|
9a0fd741ce | ||
|
|
ff71365a17 | ||
|
|
8b6daa73e2 | ||
|
|
eeca56b820 | ||
|
|
9446ce6bad | ||
|
|
a35024deb3 | ||
|
|
f53601fb12 | ||
|
|
2d3e975d22 | ||
|
|
68aa2a03d5 | ||
|
|
5c1725b749 | ||
|
|
7f2c60fff4 | ||
|
|
2db98b7aa5 | ||
|
|
a9e3f1f4e9 | ||
|
|
bc69ecf45a | ||
|
|
0013d26860 | ||
|
|
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 | ||
|
|
8e6231e008 | ||
|
|
085af13fc4 | ||
|
|
a0488e2318 | ||
|
|
710fd4c47d | ||
|
|
3f95ec9a9a | ||
|
|
a8f63cf6a2 | ||
|
|
6eb4fee6fd | ||
|
|
48c888fbd4 | ||
|
|
1b38f3f40a | ||
|
|
1815b86e25 | ||
|
|
6288747ebf | ||
|
|
1e6c0002c9 | ||
|
|
52f565ce42 | ||
|
|
2c5e280c3d | ||
|
|
5cae20af15 | ||
|
|
7bbc06f153 | ||
|
|
7a709f3056 | ||
|
|
55cd1934c9 | ||
|
|
b05d01e4fe | ||
|
|
cb6334969d | ||
|
|
8c78159f7c | ||
|
|
edaebf6bd7 | ||
|
|
931bc1d107 | ||
|
|
f19a2f73ea | ||
|
|
fc68a47bbb | ||
|
|
947666d009 | ||
|
|
e5c864c8ba | ||
|
|
962c04b466 | ||
|
|
083f8b3ec7 |
@@ -506,7 +506,7 @@
|
||||
if (inContext == null) {
|
||||
inContext = <%=className%>.class.getClassLoader().getResourceAsStream("config/contexts/" + contextStr + ".properties");
|
||||
}
|
||||
if (inContext != null) {
|
||||
if (inContext != null && context != null && context.isEmpty()) {
|
||||
//defaultProps is in order to keep the original context value
|
||||
defaultProps.load(inContext);
|
||||
inContext.close();
|
||||
@@ -530,9 +530,19 @@
|
||||
String warningMessageFormat = "Null value will be used for context parameter %s: %s";
|
||||
for (IContextParameter ctxParam :params)
|
||||
{
|
||||
%>
|
||||
context.setContextType("<%=ctxParam.getName()%>", "<%=ctxParam.getType()%>");
|
||||
<%
|
||||
%>
|
||||
context.setContextType("<%=ctxParam.getName()%>", "<%=ctxParam.getType()%>");
|
||||
if(context.getStringValue("<%=ctxParam.getName()%>") == null) {
|
||||
context.<%=ctxParam.getName()%> = null;
|
||||
} else {
|
||||
<%//}B1 block%>
|
||||
|
||||
<%
|
||||
String typeToGenerate ="String";
|
||||
if(!(ctxParam.getType().equals("id_File") || ctxParam.getType().equals("id_Directory") ||ctxParam.getType().equals("id_List Of Value"))) {
|
||||
typeToGenerate=JavaTypesManager.getTypeToGenerate(ctxParam.getType(),true);
|
||||
}
|
||||
|
||||
if (ctxParam.getType().equals("id_Password")) {
|
||||
%>
|
||||
String pwd_<%=ctxParam.getName()%>_value = context.getProperty("<%=ctxParam.getName()%>");
|
||||
@@ -550,14 +560,7 @@
|
||||
}
|
||||
}
|
||||
<%
|
||||
continue;
|
||||
}
|
||||
String typeToGenerate ="String";
|
||||
if( !(ctxParam.getType().equals("id_File") || ctxParam.getType().equals("id_Directory") ||ctxParam.getType().equals("id_List Of Value")))
|
||||
{
|
||||
typeToGenerate=JavaTypesManager.getTypeToGenerate(ctxParam.getType(),true);
|
||||
}
|
||||
if(typeToGenerate.equals("java.util.Date"))
|
||||
} else if(typeToGenerate.equals("java.util.Date"))
|
||||
{
|
||||
|
||||
%>
|
||||
@@ -621,6 +624,10 @@
|
||||
}
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<%//{B1 block%>
|
||||
}
|
||||
<%
|
||||
}
|
||||
%>
|
||||
} catch (java.io.IOException ie) {
|
||||
@@ -1171,13 +1178,27 @@ if (execStat) {
|
||||
} else {
|
||||
type = "ftp";
|
||||
}
|
||||
if ("ftp".equals(type)) { %>
|
||||
((com.enterprisedt.net.ftp.FTPClient) obj_conn).quit();
|
||||
<%} else if ("sftp".equals(type)) { %>
|
||||
if ("sftp".equals(type)) { %>
|
||||
((com.jcraft.jsch.ChannelSftp) obj_conn).quit();
|
||||
<%} else { %>
|
||||
((org.apache.commons.net.ftp.FTPSClient) obj_conn).disconnect();
|
||||
<%}%>
|
||||
<%} else {
|
||||
String libImplementation = ElementParameterParser.getValue(ftpNode, "__LIB_IMPLEMENTATION__");
|
||||
if ("Apache".equalsIgnoreCase(libImplementation)) {
|
||||
%>
|
||||
((org.apache.commons.net.ftp.FTPClient) obj_conn).disconnect();
|
||||
<%
|
||||
} else {
|
||||
if ("ftp".equals(type)) {
|
||||
%>
|
||||
((com.enterprisedt.net.ftp.FTPClient) obj_conn).quit();
|
||||
<%
|
||||
}else{
|
||||
%>
|
||||
((org.apache.commons.net.ftp.FTPSClient) obj_conn).disconnect();
|
||||
<%
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
}
|
||||
<% } %>
|
||||
} catch (java.lang.Exception e) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -289,6 +289,15 @@ if(isRunInMultiThread){
|
||||
}
|
||||
<% } %>
|
||||
}
|
||||
|
||||
//if the stored or passed value is "<TALEND_NULL>" string, it mean null
|
||||
public String getStringValue(String key) {
|
||||
String origin_value = this.getProperty(key);
|
||||
if(NULL_VALUE_EXPRESSION_IN_COMMAND_STRING_FOR_CHILD_JOB_ONLY.equals(origin_value)) {
|
||||
return null;
|
||||
}
|
||||
return origin_value;
|
||||
}
|
||||
|
||||
<%
|
||||
for (IContextParameter ctxParam :params)
|
||||
@@ -312,7 +321,7 @@ public <%=JavaTypesManager.getTypeToGenerate(ctxParam.getType(),true)%> get<%=Ch
|
||||
}
|
||||
%>
|
||||
}
|
||||
private ContextProperties context = new ContextProperties();
|
||||
protected ContextProperties context = new ContextProperties(); // will be instanciated by MS.
|
||||
public ContextProperties getContext() {
|
||||
return this.context;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -92,7 +92,7 @@ public class JavaRoutineSynchronizer extends AbstractRoutineSynchronizer {
|
||||
|
||||
private void syncRoutineItems(Collection<RoutineItem> routineObjects, boolean forceUpdate) throws SystemException {
|
||||
for (RoutineItem routineItem : routineObjects) {
|
||||
syncRoutine(routineItem, true, true, forceUpdate);
|
||||
syncRoutine(routineItem, true, forceUpdate);
|
||||
}
|
||||
syncSystemRoutine(ProjectManager.getInstance().getCurrentProject());
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.talend.components.lib</groupId>
|
||||
<artifactId>talend_file_enhanced</artifactId>
|
||||
<name>talend_file_enhanced</name>
|
||||
<version>1.1-patch</version>
|
||||
|
||||
<properties>
|
||||
<talend.nexus.url>https://artifacts-oss.talend.com</talend.nexus.url>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.0</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>talend_nexus_deployment</id>
|
||||
<url>${talend.nexus.url}/nexus/content/repositories/TalendOpenSourceSnapshot/</url>
|
||||
<snapshots><enabled>true</enabled></snapshots>
|
||||
<releases><enabled>false</enabled></releases>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>talend_nexus_deployment</id>
|
||||
<url>${talend.nexus.url}/nexus/content/repositories/TalendOpenSourceRelease/</url>
|
||||
<snapshots><enabled>false</enabled></snapshots>
|
||||
<releases><enabled>true</enabled></releases>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,235 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Talend Community Edition
|
||||
//
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.fileprocess.delimited.patched;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* DelimitedDataReader is a stream based API for reading any size of delimited data whith any type of field and record
|
||||
* delimiters. If you want to get an instance of this type please use the DelimitedDataReaderFactory<br/>
|
||||
*
|
||||
* @author gke
|
||||
*/
|
||||
public abstract class DelimitedDataReader {
|
||||
|
||||
protected BufferedReader inputStream = null;
|
||||
|
||||
protected ColumnBuffer columnBuffer = new ColumnBuffer();
|
||||
|
||||
protected boolean startedRow = false;
|
||||
|
||||
protected int columnsCount = 0;
|
||||
|
||||
protected boolean hasReadRecord = false;
|
||||
|
||||
protected String[] values = new String[StaticSettings.INITIAL_COLUMN_COUNT];
|
||||
|
||||
protected boolean initialized = false;
|
||||
|
||||
protected boolean closed = false;
|
||||
|
||||
protected boolean skipEmptyRecord = true;
|
||||
|
||||
protected long currentRecord = 0;
|
||||
|
||||
protected boolean safetySwitch = true;
|
||||
|
||||
public DelimitedDataReader(BufferedReader inputStream, boolean skipEmptyRecord) {
|
||||
if (inputStream == null) {
|
||||
throw new IllegalArgumentException("Parameter inputStream can not be null.");
|
||||
}
|
||||
this.inputStream = inputStream;
|
||||
this.skipEmptyRecord = skipEmptyRecord;
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "checkClosed". This will be call before read new record or get content of the column
|
||||
*
|
||||
* @throws IOException Thrown if this object has already been closed.
|
||||
*/
|
||||
protected void checkClosed() throws IOException {
|
||||
if (closed) {
|
||||
throw new IOException("This instance of the DelimitedFileReader class has already been closed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads another record. If this returns true, a new row data will be available using get(columnIndex)
|
||||
*
|
||||
* @return Whether another record was successfully read or not.
|
||||
* @throws IOException Thrown if an error occurs while reading data from the source stream.
|
||||
*/
|
||||
public abstract boolean readRecord() throws IOException;
|
||||
|
||||
/**
|
||||
* Returns the current columns value for a given column index.
|
||||
*
|
||||
* @param columnIndex The index of the column.
|
||||
* @return The current column value.
|
||||
* @throws IOException Thrown if this object has already been closed.
|
||||
*/
|
||||
public String get(int columnIndex) throws IOException {
|
||||
checkClosed();
|
||||
|
||||
if (columnIndex > -1 && columnIndex < columnsCount) {
|
||||
return values[columnIndex];
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the count of the records that have been read.
|
||||
*
|
||||
* @throws the count of the records that have been read.
|
||||
*/
|
||||
public long getProcessedRecordCount() {
|
||||
return currentRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes and releases all related resources.
|
||||
*/
|
||||
public void close() {
|
||||
if (!closed) {
|
||||
close(true);
|
||||
closed = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If closing is true, close and release all related resources.
|
||||
*
|
||||
* @param closing
|
||||
*/
|
||||
protected abstract void close(boolean closing);
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "getAvailableRowCount".
|
||||
*
|
||||
* @param footer the record count that will not used, just as footer for the delimited data. It will also be skipped
|
||||
* @return the count of Available row count
|
||||
* @throws IOException
|
||||
*/
|
||||
public long getAvailableRowCount(int footer) throws IOException {
|
||||
checkClosed();
|
||||
boolean flag = true;
|
||||
do {
|
||||
flag = readRecord();
|
||||
} while (flag);
|
||||
return currentRecord - footer;
|
||||
}
|
||||
|
||||
public int getAvailableColumnsCount() throws IOException {
|
||||
return columnsCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "skipHeaders". This is used to skip headers in the delimited data
|
||||
*
|
||||
* @param header rows count that will be skipped as header
|
||||
* @throws IOException
|
||||
*/
|
||||
public void skipHeaders(int header) throws IOException {
|
||||
checkClosed();
|
||||
if (header <= 0) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < header; i++) {
|
||||
readRecord();
|
||||
}
|
||||
currentRecord = 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "isSafetySwitch".
|
||||
*
|
||||
* @return the state of the safetySwitch
|
||||
*/
|
||||
public boolean isSafetySwitch() {
|
||||
return safetySwitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "setSafetySwitch". When reading a delmited text, if safetySwitch is true, and if a column's
|
||||
* content length is larger than 100,000 or a row's column count is larger than 100,000, an Exception will be
|
||||
* thrown, and the process of reading delimited data will be terminated.
|
||||
*
|
||||
* @param safetySwitch
|
||||
*/
|
||||
public void setSafetySwitch(boolean safetySwitch) {
|
||||
this.safetySwitch = safetySwitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* @exception IOException Thrown if an error occurs while reading data from the source stream.
|
||||
*/
|
||||
protected void endRecord() throws IOException {
|
||||
// this flag is used as a loop exit condition
|
||||
// during parsing
|
||||
|
||||
hasReadRecord = true;
|
||||
|
||||
currentRecord++;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() {
|
||||
close(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* StaticSettings for the DelimitedDataReader. they can be changed in unit test.
|
||||
*/
|
||||
class StaticSettings {
|
||||
|
||||
public static final int MAX_BUFFER_SIZE = 1024;
|
||||
|
||||
public static final int INITIAL_COLUMN_COUNT = 10;
|
||||
|
||||
public static final int INITIAL_COLUMN_BUFFER_SIZE = 50;
|
||||
|
||||
public static final int MAX_SIZE_FOR_SAFTY = 100000;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is data buffer for storing the contents of a column. this is used in case that the size of a column's
|
||||
* content is bigger than MAX_BUFFER_SIZE
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
class ColumnBuffer {
|
||||
|
||||
char[] buffer;
|
||||
|
||||
int position;
|
||||
|
||||
public ColumnBuffer() {
|
||||
buffer = new char[StaticSettings.INITIAL_COLUMN_BUFFER_SIZE];
|
||||
position = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,482 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Talend Community Edition
|
||||
//
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.fileprocess.delimited.patched;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* DOC ibmuser class global comment. Detailled comment <br/>
|
||||
*
|
||||
*/
|
||||
public class RowParser extends DelimitedDataReader {
|
||||
|
||||
private char[] rowSeparator;
|
||||
|
||||
private StreamBuffer streamBuffer = null;
|
||||
|
||||
private ColumnBuffer rowBuffer = null;
|
||||
|
||||
private String rowRecord;
|
||||
|
||||
private int mode = 1;
|
||||
|
||||
private int rowLength = -1;
|
||||
|
||||
private char[] buffer;
|
||||
|
||||
private static final int BUFFER_SIZE = 8192;
|
||||
|
||||
boolean requireAdditionalReadFromSource = true;
|
||||
|
||||
private int separatorIndex;
|
||||
|
||||
private boolean foundCR = false;
|
||||
|
||||
private int extendedArrayStartIndex = 0;
|
||||
|
||||
private int readSymbols = 0;
|
||||
|
||||
private int length;
|
||||
|
||||
private Predicate<Character> characterVerifier;
|
||||
|
||||
/**
|
||||
* DOC ibmuser RowParser constructor comment.
|
||||
*
|
||||
* @param inputStream
|
||||
* @param rowSeparator
|
||||
* @param skipEmptyRecords
|
||||
* @throws IOException
|
||||
*/
|
||||
public RowParser(BufferedReader inputStream, String rowSeparator, boolean skipEmptyRecords) throws IOException {
|
||||
|
||||
super(inputStream, skipEmptyRecords);
|
||||
columnBuffer = null;
|
||||
values = null;
|
||||
if ("\n".equals(rowSeparator) || "\r\n".equals(rowSeparator)) {
|
||||
this.buffer = new char[BUFFER_SIZE];
|
||||
this.mode = 0;
|
||||
characterVerifier = "\n".equals(rowSeparator) ? c -> c == Character.LETTER_NUMBER : this::testCRLF;
|
||||
} else if(rowSeparator!=null) {
|
||||
streamBuffer = new StreamBuffer();
|
||||
this.rowSeparator = rowSeparator.toCharArray();
|
||||
rowBuffer = new ColumnBuffer();
|
||||
try {
|
||||
streamBuffer.count = inputStream.read(streamBuffer.buffer, 0, streamBuffer.buffer.length);
|
||||
} catch (IOException ex) {
|
||||
close();
|
||||
throw ex;
|
||||
}
|
||||
streamBuffer.currentPosition = 0;
|
||||
streamBuffer.rowStart = 0;
|
||||
streamBuffer.delimiterLength = rowSeparator.length();
|
||||
streamBuffer.lastIndexToRead = streamBuffer.count - streamBuffer.delimiterLength;
|
||||
streamBuffer.streamEndMeet = (streamBuffer.count < streamBuffer.buffer.length);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ibmuser RowParser constructor comment.
|
||||
*
|
||||
* @param inputStream
|
||||
* @param rowLength
|
||||
* @throws IOException
|
||||
*/
|
||||
public RowParser(BufferedReader inputStream, int rowLength) throws IOException {
|
||||
|
||||
super(inputStream, true);
|
||||
|
||||
columnBuffer = null;
|
||||
|
||||
values = null;
|
||||
|
||||
mode = 2;
|
||||
|
||||
this.rowLength = rowLength;
|
||||
|
||||
buffer = new char[rowLength];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void close(boolean closing) {
|
||||
if (!closed) {
|
||||
if (closing && mode == 1) {
|
||||
streamBuffer.buffer = null;
|
||||
rowBuffer.buffer = null;
|
||||
}
|
||||
|
||||
try {
|
||||
if(initialized && inputStream != null) {
|
||||
inputStream.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// just eat the exception
|
||||
}
|
||||
|
||||
inputStream = null;
|
||||
closed = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.fileprocess.delimited.DelimitedDataReader#readRecord()
|
||||
*/
|
||||
public boolean readRecord() throws IOException {
|
||||
checkClosed();
|
||||
if (mode == 0) {
|
||||
return hasNext();
|
||||
} else if (mode == 1) {
|
||||
hasReadRecord = false;
|
||||
if (streamBuffer.hasMoreData()) {
|
||||
while (streamBuffer.hasMoreData() && !hasReadRecord) {
|
||||
if (streamBuffer.noDataForDelimter()) {
|
||||
checkDataLength();
|
||||
} else {
|
||||
if (isStartRecordDelimited()) {
|
||||
if (!skipEmptyRecord) {
|
||||
endRecord();
|
||||
}
|
||||
streamBuffer.skipDelimiter();
|
||||
|
||||
} else {
|
||||
startedRow = true;
|
||||
streamBuffer.rowStart = streamBuffer.currentPosition;
|
||||
|
||||
boolean firstLoop = true;
|
||||
|
||||
while (streamBuffer.hasMoreData() && startedRow) {
|
||||
if (!firstLoop && streamBuffer.noDataForDelimter()) {
|
||||
checkDataLength();
|
||||
} else {
|
||||
if (!firstLoop) {
|
||||
if (isStartRecordDelimited()) {
|
||||
endRecord();
|
||||
streamBuffer.skipDelimiter();
|
||||
}
|
||||
} else {
|
||||
firstLoop = false;
|
||||
}
|
||||
|
||||
if (startedRow) {
|
||||
streamBuffer.currentPosition++;
|
||||
|
||||
if (safetySwitch
|
||||
&& streamBuffer.currentPosition - streamBuffer.rowStart
|
||||
+ rowBuffer.position > StaticSettings.MAX_SIZE_FOR_SAFTY) {
|
||||
close();
|
||||
|
||||
throw new IOException(
|
||||
"Maximum row record length of 100,000 exceeded in row in record "
|
||||
+ NumberFormat.getIntegerInstance().format(currentRecord)
|
||||
+ ". Set the safetySwitch property to false"
|
||||
+ " if you're expecting row record lengths greater than 100,000 characters to"
|
||||
+ " avoid this error.");
|
||||
}
|
||||
}
|
||||
} // end else
|
||||
}
|
||||
}
|
||||
} // end else
|
||||
}
|
||||
}
|
||||
if (!hasReadRecord) {
|
||||
if (!streamBuffer.noData()) {
|
||||
if (!startedRow) {
|
||||
startedRow = true;
|
||||
streamBuffer.rowStart = streamBuffer.currentPosition;
|
||||
streamBuffer.currentPosition = streamBuffer.count;
|
||||
endRecord();
|
||||
return true;
|
||||
}
|
||||
if (startedRow) {
|
||||
streamBuffer.currentPosition = streamBuffer.count;
|
||||
endRecord();
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// if (columnsCount > 0) {
|
||||
// endRecord();
|
||||
// return true;
|
||||
// } else {
|
||||
return false;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
return hasReadRecord;
|
||||
} else {
|
||||
int readNumber = inputStream.read(buffer, 0, rowLength);
|
||||
if (readNumber == -1) {
|
||||
return false;
|
||||
} else {
|
||||
this.rowRecord = new String(buffer, 0, readNumber);
|
||||
currentRecord++;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find available record from the source with specified separators.
|
||||
*
|
||||
* @return true if reader has a value, otherwise false.
|
||||
*/
|
||||
private boolean hasNext() throws IOException {
|
||||
while (hasMoreData()) {
|
||||
requireAdditionalReadFromSource = false;
|
||||
length = readSymbols + extendedArrayStartIndex;
|
||||
for (int j = Math.max(separatorIndex, extendedArrayStartIndex); j < length; j++){
|
||||
if (characterVerifier.test(buffer[j])) {
|
||||
rowRecord = new String(buffer, separatorIndex, j - separatorIndex);
|
||||
if (j == (length - 1)) {
|
||||
separatorIndex = 0;
|
||||
extendedArrayStartIndex = 0;
|
||||
buffer = new char[BUFFER_SIZE];
|
||||
if (!skipEmptyRecord || !"".equals(rowRecord)) {
|
||||
requireAdditionalReadFromSource = true;
|
||||
currentRecord++;
|
||||
return true;
|
||||
} else {
|
||||
// Reached the end of the buffer and the record is skipped.
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
separatorIndex = j + 1;
|
||||
if (!skipEmptyRecord || !"".equals(rowRecord)) {
|
||||
currentRecord++;
|
||||
return true;
|
||||
}
|
||||
// Skipped, find the next record in the buffer.
|
||||
}
|
||||
}
|
||||
if (j == buffer.length - 1) {
|
||||
//The end of the buffer is reached, copy unprocessed characters to a new buffer.
|
||||
ensureBufferCapacity();
|
||||
}
|
||||
}
|
||||
//Reached the last buffer character.
|
||||
requireAdditionalReadFromSource = true;
|
||||
if (readSymbols < BUFFER_SIZE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
//Last record in the end of the file is reached.
|
||||
if (readSymbols > 0 || separatorIndex != 0) {
|
||||
rowRecord = new String(buffer, separatorIndex, length - separatorIndex);
|
||||
separatorIndex = 0;
|
||||
if (!skipEmptyRecord || !"".equals(rowRecord)) {
|
||||
currentRecord++;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
buffer = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform read from source if <b>requireAdditionalReadFromSource</b> is true, otherwise proceed with current read characters.
|
||||
*
|
||||
* @return true if buffer contain values to be processed, otherwise source is exhausted.
|
||||
* @throws IOException exception from input stream read.
|
||||
*/
|
||||
private boolean hasMoreData() throws IOException {
|
||||
return requireAdditionalReadFromSource ? (readSymbols = inputStream.read(buffer, extendedArrayStartIndex, BUFFER_SIZE)) != -1 : true;
|
||||
}
|
||||
|
||||
private boolean testCRLF(Character c) {
|
||||
if (foundCR && c == Character.LETTER_NUMBER) {
|
||||
return true;
|
||||
}
|
||||
foundCR = c == Character.LINE_SEPARATOR;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The unprocessed characters has to be copied to a new extended buffer.<br>
|
||||
* Separator index is reset to 0 to include the unprocessed characters to the next record.
|
||||
*/
|
||||
private void ensureBufferCapacity() {
|
||||
char[] tempChars = buffer;
|
||||
extendedArrayStartIndex = tempChars.length - separatorIndex;
|
||||
buffer = new char[extendedArrayStartIndex + BUFFER_SIZE];
|
||||
System.arraycopy(tempChars, separatorIndex, buffer, 0, extendedArrayStartIndex);
|
||||
separatorIndex = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @exception IOException Thrown if an error occurs while reading data from the source stream.
|
||||
*/
|
||||
private void checkDataLength() throws IOException {
|
||||
updateCurrentValue();
|
||||
streamBuffer.moveTailToHead();
|
||||
int count = 0;
|
||||
try {
|
||||
count = inputStream.read(streamBuffer.buffer, streamBuffer.count, streamBuffer.buffer.length
|
||||
- streamBuffer.count);
|
||||
} catch (IOException ex) {
|
||||
close();
|
||||
|
||||
throw ex;
|
||||
}
|
||||
streamBuffer.count += count;
|
||||
streamBuffer.lastIndexToRead = streamBuffer.count - streamBuffer.delimiterLength;
|
||||
if (streamBuffer.count < streamBuffer.buffer.length) {
|
||||
streamBuffer.streamEndMeet = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCurrentValue() {
|
||||
if (startedRow && streamBuffer.rowStart < streamBuffer.currentPosition) {
|
||||
if (rowBuffer.buffer.length - rowBuffer.position < streamBuffer.currentPosition - streamBuffer.rowStart) {
|
||||
int newLength = rowBuffer.buffer.length
|
||||
+ Math.max(streamBuffer.currentPosition - streamBuffer.rowStart, rowBuffer.buffer.length);
|
||||
|
||||
char[] holder = new char[newLength];
|
||||
|
||||
System.arraycopy(rowBuffer.buffer, 0, holder, 0, rowBuffer.position);
|
||||
|
||||
rowBuffer.buffer = holder;
|
||||
}
|
||||
|
||||
System.arraycopy(streamBuffer.buffer, streamBuffer.rowStart, rowBuffer.buffer, rowBuffer.position,
|
||||
streamBuffer.currentPosition - streamBuffer.rowStart);
|
||||
|
||||
rowBuffer.position += streamBuffer.currentPosition - streamBuffer.rowStart;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isStartRecordDelimited() {
|
||||
for (int i = 0; i < rowSeparator.length; i++) {
|
||||
if (streamBuffer.buffer[streamBuffer.currentPosition + i] != rowSeparator[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void endRecord() throws IOException {
|
||||
|
||||
String currentValue = "";
|
||||
|
||||
// must be called before setting startedColumn = false
|
||||
if (startedRow) {
|
||||
if (rowBuffer.position == 0) {
|
||||
if (streamBuffer.rowStart < streamBuffer.currentPosition) {
|
||||
currentValue = new String(streamBuffer.buffer, streamBuffer.rowStart, streamBuffer.currentPosition
|
||||
- streamBuffer.rowStart);
|
||||
}
|
||||
} else {
|
||||
updateCurrentValue();
|
||||
currentValue = new String(rowBuffer.buffer, 0, rowBuffer.position);
|
||||
}
|
||||
}
|
||||
|
||||
rowBuffer.position = 0;
|
||||
|
||||
if (startedRow) {
|
||||
startedRow = false;
|
||||
}
|
||||
|
||||
rowRecord = currentValue;
|
||||
|
||||
super.endRecord();
|
||||
}
|
||||
|
||||
/**
|
||||
* A buffer structure that used to load data from stream for processing.
|
||||
*
|
||||
* @author gke
|
||||
*/
|
||||
private class StreamBuffer {
|
||||
|
||||
char[] buffer;
|
||||
|
||||
int currentPosition;
|
||||
|
||||
// lastIndexToRead is the last index of letter in the buffer for
|
||||
// processing, this will be equal to count - delimiterLegnth. This
|
||||
// is needed because evertime we process a letter, when we need to read
|
||||
// the proceeding letters in order to make sure if currentPosition is
|
||||
// the begin of field or record delmiter
|
||||
int lastIndexToRead;
|
||||
|
||||
int delimiterLength;
|
||||
|
||||
// count indicates how much usable data has been read into the stream,
|
||||
// which will not always be as long as Buffer.Length.
|
||||
int count;
|
||||
|
||||
// columnStart is the position in the buffer when the
|
||||
// current column was started or the last time data
|
||||
// was moved out to the column buffer.
|
||||
int rowStart;
|
||||
|
||||
// streamEndMeet is also very important, when we loag data from stream,
|
||||
// if the count is smaller than buffer.length, it indcates that there
|
||||
// must be no more data in the stream, the stream end is meet.
|
||||
boolean streamEndMeet = false;
|
||||
|
||||
public StreamBuffer() {
|
||||
buffer = new char[StaticSettings.MAX_BUFFER_SIZE];
|
||||
currentPosition = 0;
|
||||
count = 0;
|
||||
rowStart = 0;
|
||||
}
|
||||
|
||||
public void moveTailToHead() {
|
||||
count = count - currentPosition;
|
||||
for (int i = 0; i < count; i++) {
|
||||
buffer[i] = buffer[currentPosition + i];
|
||||
}
|
||||
lastIndexToRead = count - delimiterLength;
|
||||
currentPosition = 0;
|
||||
rowStart = 0;
|
||||
}
|
||||
|
||||
public void skipDelimiter() {
|
||||
currentPosition += delimiterLength;
|
||||
}
|
||||
|
||||
public boolean noDataForDelimter() {
|
||||
return currentPosition > lastIndexToRead;
|
||||
}
|
||||
|
||||
public boolean hasMoreData() {
|
||||
return (currentPosition <= lastIndexToRead) || (currentPosition > lastIndexToRead && !streamEndMeet);
|
||||
}
|
||||
|
||||
public boolean noData() {
|
||||
return currentPosition >= count;
|
||||
}
|
||||
}
|
||||
|
||||
public String getRowRecord() {
|
||||
return rowRecord;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
package org.talend.fileprocess.delimited.patched;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
public class RowParserByByte {
|
||||
private byte[] buffer;
|
||||
|
||||
private int row_length;
|
||||
|
||||
private BufferedInputStream in = null;
|
||||
|
||||
private boolean safetySwitch = false;
|
||||
|
||||
public final int MAX_SIZE_FOR_SAFTY = 100000;
|
||||
|
||||
private boolean closed = false;
|
||||
|
||||
private long currentRecord = 0;
|
||||
|
||||
private int header = 0;
|
||||
|
||||
public RowParserByByte(String filename, int row_length) throws FileNotFoundException {
|
||||
this.row_length = row_length;
|
||||
|
||||
File f = new File(filename);
|
||||
if (!f.exists()) {
|
||||
throw new FileNotFoundException(filename);
|
||||
}
|
||||
|
||||
in = new BufferedInputStream(new FileInputStream(f));
|
||||
}
|
||||
|
||||
public RowParserByByte(ZipInputStream zis, int row_length) throws FileNotFoundException {
|
||||
this.row_length = row_length;
|
||||
in = new BufferedInputStream(zis);
|
||||
}
|
||||
|
||||
public boolean readRecord() throws Exception {
|
||||
|
||||
return toByteArray();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "isSafetySwitch".
|
||||
*
|
||||
* @return the state of the safetySwitch
|
||||
*/
|
||||
public boolean isSafetySwitch() {
|
||||
return safetySwitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "setSafetySwitch". When reading a delmited text, if
|
||||
* safetySwitch is true, and if a column's content length is larger than
|
||||
* 100,000 or a row's column count is larger than 100,000, an Exception will
|
||||
* be thrown, and the process of reading delimited data will be terminated.
|
||||
*
|
||||
* @param safetySwitch
|
||||
*/
|
||||
public void setSafetySwitch(boolean safetySwitch) {
|
||||
this.safetySwitch = safetySwitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "checkClosed". This will be call before read new
|
||||
* record or get content of the column
|
||||
*
|
||||
* @throws IOException
|
||||
* Thrown if this object has already been closed.
|
||||
*/
|
||||
protected void checkClosed() throws IOException {
|
||||
if (closed) {
|
||||
throw new IOException("This instance of the RowRaeserByByte class has already been closed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "skipHeaders". This is used to skip headers in the
|
||||
* delimited data
|
||||
*
|
||||
* @param header
|
||||
* rows count that will be skipped as header
|
||||
* @throws IOException
|
||||
*/
|
||||
public void skipHeaders(int header) throws Exception {
|
||||
checkClosed();
|
||||
if (header <= 0) {
|
||||
return;
|
||||
}
|
||||
this.header = header;
|
||||
for (int i = 0; i < header; i++) {
|
||||
readRecord();
|
||||
}
|
||||
currentRecord = 0;
|
||||
|
||||
}
|
||||
|
||||
public byte[] getBuffer() {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public String getRowRecord() {
|
||||
return new String(buffer);
|
||||
}
|
||||
|
||||
public boolean toByteArray() throws IOException {
|
||||
|
||||
this.buffer = new byte[row_length];
|
||||
if (-1 != in.read(buffer, 0, row_length)) {
|
||||
|
||||
if (safetySwitch && currentRecord - header > this.MAX_SIZE_FOR_SAFTY) {
|
||||
close();
|
||||
|
||||
throw new IOException("Maximum row record length of 100,000 exceeded in row in record "
|
||||
+ NumberFormat.getIntegerInstance().format(currentRecord)
|
||||
+ ". Set the safetySwitch property to false"
|
||||
+ " if you're expecting row record lengths greater than 100,000 characters to"
|
||||
+ " avoid this error.");
|
||||
}
|
||||
|
||||
currentRecord++;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "getAvailableRowCount".
|
||||
*
|
||||
* @param footer
|
||||
* the record count that will not used, just as footer for the
|
||||
* delimited data. It will also be skipped
|
||||
* @return the count of Available row count
|
||||
* @throws Exception
|
||||
*/
|
||||
public long getAvailableRowCount(int footer) throws Exception {
|
||||
checkClosed();
|
||||
boolean flag = true;
|
||||
do {
|
||||
flag = readRecord();
|
||||
} while (flag);
|
||||
return currentRecord - footer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes and releases all related resources.
|
||||
*/
|
||||
|
||||
public void close() {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
// just eat the exception
|
||||
}
|
||||
|
||||
closed = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.talend.libraries</groupId>
|
||||
<groupId>org.talend.components.lib</groupId>
|
||||
<artifactId>talendsap</artifactId>
|
||||
<name>talendsap</name>
|
||||
<version>1.0.1</version>
|
||||
<version>1.0.2</version>
|
||||
|
||||
<properties>
|
||||
<talend.nexus.url>https://artifacts-oss.talend.com</talend.nexus.url>
|
||||
|
||||
@@ -90,6 +90,7 @@ public class DocumentExtractor {
|
||||
List<Element> tablesAndChangingElements = new ArrayList<Element>(3);
|
||||
tablesAndChangingElements.add(functionElement.element("TABLES"));
|
||||
tablesAndChangingElements.add(functionElement.element("CHANGING"));
|
||||
tablesAndChangingElements.add(functionElement.element("OUTPUT"));
|
||||
|
||||
for(Element tablesOrChangingElement : tablesAndChangingElements) {
|
||||
if (tablesOrChangingElement == null) {
|
||||
@@ -121,6 +122,10 @@ public class DocumentExtractor {
|
||||
}
|
||||
result.add(row);
|
||||
}
|
||||
|
||||
if(!result.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -49,11 +49,11 @@ public class DocumentHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public void addSingleParameter(String name, String value, boolean isChanging) {
|
||||
public void addSingleParameter(String name, String value, SAPParameterType parameter_type) {
|
||||
if(value == null) {
|
||||
value = "";
|
||||
}
|
||||
if (isChanging) {
|
||||
if (parameter_type == SAPParameterType.CHANGING) {
|
||||
correctChanging();
|
||||
changing.addElement(name).setText(value);
|
||||
} else {
|
||||
@@ -62,8 +62,8 @@ public class DocumentHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public void addStructParameter(String name, boolean isChanging) {
|
||||
if (isChanging) {
|
||||
public void addStructParameter(String name, SAPParameterType parameter_type) {
|
||||
if (parameter_type == SAPParameterType.CHANGING) {
|
||||
correctChanging();
|
||||
currentStruct = changing.addElement(name);
|
||||
} else {
|
||||
@@ -79,13 +79,16 @@ public class DocumentHelper {
|
||||
currentStruct.addElement(name).setText(value);
|
||||
}
|
||||
|
||||
public void addTableParameter(String name, boolean isChanging) {
|
||||
if (isChanging) {
|
||||
public void addTableParameter(String name, SAPParameterType parameter_type) {
|
||||
if (parameter_type == SAPParameterType.CHANGING) {
|
||||
correctChanging();
|
||||
currentTable = changing.addElement(name);
|
||||
} else {
|
||||
} else if(parameter_type == SAPParameterType.TABLES) {
|
||||
correctTables();
|
||||
currentTable = tables.addElement(name);
|
||||
} else {
|
||||
correctInput();
|
||||
currentTable = input.addElement(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,18 +111,18 @@ public class DocumentHelper {
|
||||
DocumentHelper helper = new DocumentHelper();
|
||||
helper.setFunctionName("READ_TABLE_FUNCTION");
|
||||
|
||||
helper.addSingleParameter("ID", "1", true);
|
||||
helper.addSingleParameter("NAME", "gaoyan", false);
|
||||
helper.addSingleParameter("ID", "1", SAPParameterType.CHANGING);
|
||||
helper.addSingleParameter("NAME", "gaoyan", SAPParameterType.IMPORT);
|
||||
|
||||
helper.addStructParameter("INFO", true);
|
||||
helper.addStructParameter("INFO", SAPParameterType.CHANGING);
|
||||
helper.addStructChildParameter("ID", "2");
|
||||
helper.addStructChildParameter("NAME", "wangwei");
|
||||
|
||||
helper.addStructParameter("INFO1", false);
|
||||
helper.addStructParameter("INFO1", SAPParameterType.IMPORT);
|
||||
helper.addStructChildParameter("ID1", "4");
|
||||
helper.addStructChildParameter("NAME1", "momo");
|
||||
|
||||
helper.addTableParameter("TABLE1", false);
|
||||
helper.addTableParameter("TABLE1", SAPParameterType.TABLES);
|
||||
for (int i = 0; i < 200000; i++) {
|
||||
helper.addTableRow();
|
||||
helper.addTableRowChildParameter("c1", i + "");
|
||||
@@ -132,7 +135,7 @@ public class DocumentHelper {
|
||||
helper.addTableRowChildParameter("c8", "wangwei" + i);
|
||||
}
|
||||
|
||||
helper.addTableParameter("TABLE2", false);
|
||||
helper.addTableParameter("TABLE2", SAPParameterType.TABLES);
|
||||
for (int i = 0; i < 2; i++) {
|
||||
helper.addTableRow();
|
||||
helper.addTableRowChildParameter("ID4", i + "");
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package org.talend.sap;
|
||||
|
||||
public enum SAPParameterType {
|
||||
IMPORT,
|
||||
CHANGING,
|
||||
TABLES,
|
||||
EXPORT
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
<%
|
||||
}
|
||||
|
||||
@@ -228,8 +228,8 @@ if (!sftp && !ftps) { // *** ftp *** //
|
||||
}
|
||||
|
||||
ftp_<%=cid %>.setFileType(org.apache.commons.net.ftp.FTP.BINARY_FILE_TYPE);
|
||||
ftp_<%=cid %>.execPROT(<%=protectionLevel %>);
|
||||
ftp_<%=cid %>.execPBSZ(<%=protectionBufferSize %>);
|
||||
ftp_<%=cid %>.execPROT(<%=protectionLevel %>);
|
||||
} catch (Exception e) {
|
||||
<%if(isLog4jEnabled){%>
|
||||
log.error("<%=cid%> - Can't create connection: " + e.getMessage());
|
||||
|
||||
@@ -249,8 +249,8 @@ int nb_file_<%=cid%> = 0;
|
||||
throw new RuntimeException("Login failed");
|
||||
}
|
||||
|
||||
ftp_<%=cid %>.execPROT(<%=protectionLevel %>);
|
||||
ftp_<%=cid %>.execPBSZ(<%=protectionBufferSize %>);
|
||||
ftp_<%=cid %>.execPROT(<%=protectionLevel %>);
|
||||
} catch (Exception e) {
|
||||
<%if(isLog4jEnabled){%>
|
||||
log.error("<%=cid%> - Can't create connection: " + e.getMessage());
|
||||
|
||||
@@ -235,8 +235,8 @@ if (sftp) { // *** sftp *** //
|
||||
throw new RuntimeException("Login failed");
|
||||
}
|
||||
|
||||
ftp_<%=cid %>.execPROT(<%=protectionLevel %>);
|
||||
ftp_<%=cid %>.execPBSZ(<%=protectionBufferSize %>);
|
||||
ftp_<%=cid %>.execPROT(<%=protectionLevel %>);
|
||||
} catch (Exception e) {
|
||||
<%if(isLog4jEnabled){%>
|
||||
log.error("<%=cid%> - Can't create connection: " + e.getMessage());
|
||||
|
||||
@@ -317,8 +317,8 @@ if (sftp) {// *** sftp *** //
|
||||
throw new RuntimeException("Login failed");
|
||||
}
|
||||
|
||||
ftp_<%=cid %>.execPROT(<%=protectionLevel %>);
|
||||
ftp_<%=cid %>.execPBSZ(<%=protectionBufferSize %>);
|
||||
ftp_<%=cid %>.execPROT(<%=protectionLevel %>);
|
||||
} catch (Exception e) {
|
||||
<%if(isLog4jEnabled){%>
|
||||
log.error("<%=cid%> - Can't create connection: " + e.getMessage());
|
||||
|
||||
@@ -284,8 +284,8 @@ if (sftp) { // *** sftp *** //
|
||||
}
|
||||
|
||||
ftp_<%=cid %>.setFileType(org.apache.commons.net.ftp.FTP.BINARY_FILE_TYPE); //to calculate md5 for binary files correctly
|
||||
ftp_<%=cid %>.execPROT(<%=protectionLevel %>);
|
||||
ftp_<%=cid %>.execPBSZ(<%=protectionBufferSize %>);
|
||||
ftp_<%=cid %>.execPROT(<%=protectionLevel %>);
|
||||
} catch (Exception e) {
|
||||
<%if(isLog4jEnabled){%>
|
||||
log.error("<%=cid%> - Can't create connection: " + e.getMessage());
|
||||
|
||||
@@ -732,8 +732,8 @@ if (sftp) { // *** sftp *** //
|
||||
}
|
||||
|
||||
ftp_<%=cid %>.setFileType(org.apache.commons.net.ftp.FTP.BINARY_FILE_TYPE);
|
||||
ftp_<%=cid %>.execPROT(<%=protectionLevel %>);
|
||||
ftp_<%=cid %>.execPBSZ(<%=protectionBufferSize %>);
|
||||
ftp_<%=cid %>.execPROT(<%=protectionLevel %>);
|
||||
} catch (Exception e) {
|
||||
<%if(isLog4jEnabled){%>
|
||||
log.error("<%=cid%> - Can't create connection: " + e.getMessage());
|
||||
|
||||
@@ -415,8 +415,8 @@ int nb_file_<%=cid%> = 0;
|
||||
}
|
||||
|
||||
ftp_<%=cid %>.setFileType(org.apache.commons.net.ftp.FTP.BINARY_FILE_TYPE);
|
||||
ftp_<%=cid %>.execPROT(<%=protectionLevel %>);
|
||||
ftp_<%=cid %>.execPBSZ(<%=protectionBufferSize %>);
|
||||
ftp_<%=cid %>.execPROT(<%=protectionLevel %>);
|
||||
} catch (Exception e) {
|
||||
<%if(isLog4jEnabled){%>
|
||||
log.error("<%=cid%> - Can't create connection: " + e.getMessage());
|
||||
|
||||
@@ -254,8 +254,8 @@ if (sftp) { // *** sftp *** //
|
||||
throw new RuntimeException("Login failed");
|
||||
}
|
||||
|
||||
ftp_<%=cid %>.execPROT(<%=protectionLevel %>);
|
||||
ftp_<%=cid %>.execPBSZ(<%=protectionBufferSize %>);
|
||||
ftp_<%=cid %>.execPROT(<%=protectionLevel %>);
|
||||
} catch (Exception e) {
|
||||
<%if(isLog4jEnabled){%>
|
||||
log.error("<%=cid%> - Can't create connection: " + e.getMessage());
|
||||
|
||||
@@ -252,8 +252,8 @@ if (sftp) {// *** sftp *** //
|
||||
throw new RuntimeException("Login failed");
|
||||
}
|
||||
|
||||
ftp_<%=cid %>.execPROT(<%=protectionLevel %>);
|
||||
ftp_<%=cid %>.execPBSZ(<%=protectionBufferSize %>);
|
||||
ftp_<%=cid %>.execPROT(<%=protectionLevel %>);
|
||||
} catch (Exception e) {
|
||||
<%if(isLog4jEnabled){%>
|
||||
log.error("<%=cid%> - Can't create connection: " + e.getMessage());
|
||||
|
||||
@@ -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;
|
||||
<%
|
||||
|
||||
@@ -398,10 +398,15 @@ skeleton="../templates/db_output_bulk.skeleton"
|
||||
|
||||
// added "print command" feature
|
||||
<% if (printCommand == true) { %>
|
||||
System.out.println("INFO: executing nzload command:");
|
||||
for( String cmd : cmds ) {
|
||||
System.out.print(cmd + " ");
|
||||
}
|
||||
System.out.println("INFO: executing nzload command:");
|
||||
for(int i = 0; i < cmds.length; i++) {
|
||||
if ("-pw".equals(cmds[i]) && decryptedPwd_<%=cid %>.equals(cmds[i+1])) {
|
||||
System.out.print(cmds[i] + " " + routines.system.PasswordEncryptUtil.PASSWORD_FOR_LOGS_VALUE + " ");
|
||||
i++;
|
||||
} else {
|
||||
System.out.print(cmds[i] + " ");
|
||||
}
|
||||
}
|
||||
<% } %>
|
||||
|
||||
Runtime rt = Runtime.getRuntime();
|
||||
|
||||
@@ -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
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
</projecttask>
|
||||
<projecttask
|
||||
beforeLogon="false"
|
||||
breaks="7.0.1"
|
||||
breaks="7.0.0"
|
||||
class="org.talend.designer.core.generic.model.migration.NewGoogleDriveMigrationTask"
|
||||
description="Migration task for jobs using Google Drive components to TCOMP"
|
||||
id="org.talend.designer.core.generic.model.migration.NewGoogleDriveMigrationTask"
|
||||
|
||||
@@ -1469,9 +1469,11 @@ public class Component extends AbstractBasicComponent {
|
||||
}
|
||||
if (GenericTypeUtils.isStringType(property)
|
||||
&& property.getTaggedValue(IGenericConstants.LINE_SEPARATOR_REPLACED_TO) != null) {
|
||||
String replacedTo = String.valueOf(property.getTaggedValue(IGenericConstants.LINE_SEPARATOR_REPLACED_TO));
|
||||
// "Win", "Linux/Unix", "Mac"
|
||||
return value.replaceAll("\r\n", replacedTo).replaceAll("\n", replacedTo).replaceAll("\r", replacedTo);
|
||||
//process for the sql field for jdbc, snowflake, salesforce, LINE_SEPARATOR_REPLACED_TO key can tell us which a sql type field,
|
||||
//as sql type value may have newline and return characters, which make compiler issue in java code,
|
||||
//so have to convert the newline characters to visible "\r", "\n" for pass the compiler issue and can't only convert them to white space as TDI-41898
|
||||
//jdbc drivers, salesforce driver can work like that sql : select * \nfrom Account, so it is ok
|
||||
return NodeUtil.replaceCRLFInMEMO_SQL(value);
|
||||
}
|
||||
if (GenericTypeUtils.isSchemaType(property)) {
|
||||
// Handles embedded escaped quotes which might occur
|
||||
|
||||
@@ -15,6 +15,7 @@ package org.talend.designer.core.generic.model;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.ProxySelector;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
@@ -28,9 +29,9 @@ import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.ui.gmf.util.DisplayUtils;
|
||||
import org.talend.commons.utils.network.TalendProxySelector;
|
||||
import org.talend.components.api.component.Connector;
|
||||
import org.talend.components.api.properties.ComponentProperties;
|
||||
import org.talend.components.api.properties.ComponentReferenceProperties;
|
||||
import org.talend.components.api.service.ComponentService;
|
||||
import org.talend.core.model.components.EComponentType;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
@@ -488,10 +489,26 @@ public class GenericElementParameter extends ElementParameter implements IGeneri
|
||||
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
||||
monitor.beginTask(taskName, IProgressMonitor.UNKNOWN);
|
||||
try {
|
||||
if (Boolean.getBoolean(TalendProxySelector.PROP_PRINT_LOGS)) {
|
||||
ExceptionHandler.log(
|
||||
"Before tcompv0 service call: ProxySelector.getDefault() -> " + ProxySelector.getDefault());
|
||||
ExceptionHandler.log("http.proxyHost -> " + System.getProperty("http.proxyHost"));
|
||||
}
|
||||
toDo();
|
||||
if (Boolean.getBoolean(TalendProxySelector.PROP_PRINT_LOGS)) {
|
||||
ExceptionHandler.log(
|
||||
"After tcompv0 service call: ProxySelector.getDefault() -> " + ProxySelector.getDefault());
|
||||
ExceptionHandler.log("http.proxyHost -> " + System.getProperty("http.proxyHost"));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
result.set(false);
|
||||
throw new InvocationTargetException(e);
|
||||
} finally {
|
||||
if (Boolean.getBoolean(TalendProxySelector.PROP_PRINT_LOGS)) {
|
||||
ExceptionHandler.log(
|
||||
"Finally tcompv0 service call: ProxySelector.getDefault() -> " + ProxySelector.getDefault());
|
||||
ExceptionHandler.log("http.proxyHost -> " + System.getProperty("http.proxyHost"));
|
||||
}
|
||||
}
|
||||
result.set(true);
|
||||
}
|
||||
|
||||
@@ -62,6 +62,9 @@ public class GenericTableUtils {
|
||||
if(dbService != null){
|
||||
for(String v:values){
|
||||
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);
|
||||
|
||||
@@ -6,12 +6,39 @@ import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
import org.talend.designer.core.generic.utils.ParameterUtilTool;
|
||||
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;
|
||||
|
||||
public class NewGoogleDriveMigrationTask extends org.talend.designer.core.generic.model.migration.NewComponentFrameworkMigrationTask {
|
||||
|
||||
public static final String GOOGLE_DRIVE_PREFIX = "tGoogleDrive";
|
||||
|
||||
public static final String JAVAJET_VERSION = "0.102";
|
||||
|
||||
@Override
|
||||
public ExecutionResult execute(Item item) {
|
||||
ProcessType processType = getProcessType(item);
|
||||
if (processType != null) {
|
||||
for (Object obj : processType.getNode()) {
|
||||
if (obj != null && obj instanceof NodeType) {
|
||||
String componentName = ((NodeType) obj).getComponentName();
|
||||
String version = ((NodeType) obj).getComponentVersion();
|
||||
if (componentName != null && componentName.startsWith(GOOGLE_DRIVE_PREFIX)) {
|
||||
if (!JAVAJET_VERSION.equals(version)) {
|
||||
// not a javajet component (tcompv0), we skip this migration for not corrupting comps.
|
||||
return ExecutionResult.NOTHING_TO_DO;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.execute(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getOrder() {
|
||||
return new GregorianCalendar(2017, 10, 23, 10, 15, 0).getTime();
|
||||
@@ -33,44 +60,43 @@ public class NewGoogleDriveMigrationTask extends org.talend.designer.core.generi
|
||||
|
||||
@Override
|
||||
protected ElementParameterType getParameterType(NodeType node, String paramName) {
|
||||
// sanitize inexistent props
|
||||
ElementParameterType oAuthMethod = ParameterUtilTool.findParameterType(node, "OAUTH_METHOD");
|
||||
if (oAuthMethod == null) {
|
||||
ParameterUtilTool.addParameterType(node, "TEXT", "OAUTH_METHOD", "AccessToken");
|
||||
}
|
||||
ElementParameterType dsPath = ParameterUtilTool.findParameterType(node, "DATASTORE_PATH");
|
||||
if (dsPath == null) {
|
||||
String datastorePath = (System.getProperty("user.home", ".") + "/.credentials/talend-googledrive")
|
||||
.replace("\\", "/");
|
||||
ParameterUtilTool.addParameterType(node, "TEXT", "DATASTORE_PATH",
|
||||
TalendQuoteUtils.addQuotesIfNotExist(datastorePath));
|
||||
}
|
||||
ElementParameterType paramType = ParameterUtilTool.findParameterType(node, paramName);
|
||||
if (node != null && paramType != null) {
|
||||
Object value = ParameterUtilTool.convertParameterValue(paramType);
|
||||
String componentName = node.getComponentName();
|
||||
//
|
||||
if ("tGoogleDriveCopy".equals(componentName)) {
|
||||
if ("FILE_MODE".equals(paramName)) {
|
||||
if ("true".equals(String.valueOf(value))) {
|
||||
paramType.setValue("File");
|
||||
} else {
|
||||
paramType.setValue("Folder");
|
||||
}
|
||||
}
|
||||
if ("FILE_NAME".equals(paramName)) {
|
||||
ElementParameterType fileMode = ParameterUtilTool.findParameterType(node, "FILE_MODE");
|
||||
Object fileModeValue = ParameterUtilTool.convertParameterValue(fileMode);
|
||||
if ("true".equals(String.valueOf(fileModeValue))) {
|
||||
paramType.setValue(String.valueOf(value));
|
||||
} else {
|
||||
ElementParameterType folderName = ParameterUtilTool.findParameterType(node, "FOLDER_NAME");
|
||||
Object folderNameValue = ParameterUtilTool.convertParameterValue(folderName);
|
||||
paramType.setValue(String.valueOf(folderNameValue));
|
||||
}
|
||||
Object copyModeParam = ParameterUtilTool.findParameterType(node, "COPY_MODE");
|
||||
if (copyModeParam == null) {
|
||||
Object fileMode = ParameterUtilTool.getParameterValue(node, "FILE_MODE");
|
||||
Object fileName = ParameterUtilTool.getParameterValue(node, "FILE_NAME");
|
||||
Object folderName = ParameterUtilTool.getParameterValue(node, "FOLDER_NAME");
|
||||
String copyMode = "true".equals(fileMode) ? "File" : "Folder";
|
||||
String source = "File".equals(copyMode) ? String.valueOf(fileName) : String.valueOf(folderName);
|
||||
ParameterUtilTool.addParameterType(node, "TEXT", "COPY_MODE", copyMode);
|
||||
ParameterUtilTool.addParameterType(node, "TEXT", "SOURCE", source);
|
||||
}
|
||||
}
|
||||
if ("tGoogleDrivePut".equals(componentName)) {
|
||||
if ("READ_CONTENT_FROM_INPUT".equals(paramName)) {
|
||||
if ("true".equals(String.valueOf(value))) {
|
||||
paramType.setValue("READ_CONTENT_FROM_INPUT");
|
||||
} else {
|
||||
ElementParameterType upl = ParameterUtilTool.findParameterType(node, "UPLOAD_LOCAL_FILE");
|
||||
Object uplv = ParameterUtilTool.convertParameterValue(upl);
|
||||
if ("true".equals(String.valueOf(uplv))) {
|
||||
paramType.setValue("UPLOAD_LOCAL_FILE");
|
||||
} else {
|
||||
paramType.setValue("EXPOSE_OUTPUT_STREAM");
|
||||
}
|
||||
Object uploadModeParam = ParameterUtilTool.findParameterType(node, "UPLOAD_MODE");
|
||||
if (uploadModeParam == null) {
|
||||
Object isReadContentFromInput = ParameterUtilTool.getParameterValue(node, "READ_CONTENT_FROM_INPUT");
|
||||
Object uploadLocalFile = ParameterUtilTool.getParameterValue(node, "UPLOAD_LOCAL_FILE");
|
||||
String uploadMode = "READ_CONTENT_FROM_INPUT";
|
||||
if (!"true".equals(isReadContentFromInput)) {
|
||||
uploadMode = "true".equals(uploadLocalFile) ? "UPLOAD_LOCAL_FILE" : "EXPOSE_OUTPUT_STREAM";
|
||||
}
|
||||
ParameterUtilTool.addParameterType(node, "TEXT", "UPLOAD_MODE", uploadMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,25 @@ tGoogleDriveConnection.useSSL=USE_SSL
|
||||
tGoogleDriveConnection.sslAlgorithm=SSL_ALGORITHM
|
||||
tGoogleDriveConnection.sslTrustStore=SSL_TRUST_STORE
|
||||
tGoogleDriveConnection.sslTrustStorePassword=SSL_TRUST_STORE_PASSWORD
|
||||
tGoogleDriveConnection.oAuthMethod=OAUTH_METHOD
|
||||
tGoogleDriveConnection.datastorePath=DATASTORE_PATH
|
||||
|
||||
# tGoogleDriveCopy
|
||||
tGoogleDriveCopy=tGoogleDriveCopy
|
||||
tGoogleDriveCopy.copyMode=FILE_MODE
|
||||
tGoogleDriveCopy.source=FILE_NAME
|
||||
tGoogleDriveCopy.connection.referencedComponent=CONNECTION
|
||||
tGoogleDriveCopy.connection.applicationName=APPLICATION_NAME
|
||||
tGoogleDriveCopy.connection.accessToken=ACCESS_TOKEN
|
||||
tGoogleDriveCopy.connection.useProxy=USE_PROXY
|
||||
tGoogleDriveCopy.connection.proxyHost=PROXY_HOST
|
||||
tGoogleDriveCopy.connection.proxyPort=PROXY_PORT
|
||||
tGoogleDriveCopy.connection.useSSL=USE_SSL
|
||||
tGoogleDriveCopy.connection.sslAlgorithm=SSL_ALGORITHM
|
||||
tGoogleDriveCopy.connection.sslTrustStore=SSL_TRUST_STORE
|
||||
tGoogleDriveCopy.connection.sslTrustStorePassword=SSL_TRUST_STORE_PASSWORD
|
||||
tGoogleDriveCopy.connection.oAuthMethod=OAUTH_METHOD
|
||||
tGoogleDriveCopy.connection.datastorePath=DATASTORE_PATH
|
||||
tGoogleDriveCopy.copyMode=COPY_MODE
|
||||
tGoogleDriveCopy.source=SOURCE
|
||||
tGoogleDriveCopy.destinationFolder=DESTINATION_FOLDER_NAME
|
||||
tGoogleDriveCopy.rename=RENAME
|
||||
tGoogleDriveCopy.newName=DESTINATION_FILE_NAME
|
||||
@@ -21,16 +35,52 @@ tGoogleDriveCopy.deleteSourceFile=REMOVE_SOURCE_FILE
|
||||
|
||||
# tGoogleDriveCreate
|
||||
tGoogleDriveCreate=tGoogleDriveCreate
|
||||
tGoogleDriveCreate.connection.referencedComponent=CONNECTION
|
||||
tGoogleDriveCreate.connection.applicationName=APPLICATION_NAME
|
||||
tGoogleDriveCreate.connection.accessToken=ACCESS_TOKEN
|
||||
tGoogleDriveCreate.connection.useProxy=USE_PROXY
|
||||
tGoogleDriveCreate.connection.proxyHost=PROXY_HOST
|
||||
tGoogleDriveCreate.connection.proxyPort=PROXY_PORT
|
||||
tGoogleDriveCreate.connection.useSSL=USE_SSL
|
||||
tGoogleDriveCreate.connection.sslAlgorithm=SSL_ALGORITHM
|
||||
tGoogleDriveCreate.connection.sslTrustStore=SSL_TRUST_STORE
|
||||
tGoogleDriveCreate.connection.sslTrustStorePassword=SSL_TRUST_STORE_PASSWORD
|
||||
tGoogleDriveCreate.connection.oAuthMethod=OAUTH_METHOD
|
||||
tGoogleDriveCreate.connection.datastorePath=DATASTORE_PATH
|
||||
tGoogleDriveCreate.parentFolder=FOLDER_NAME
|
||||
tGoogleDriveCreate.newFolder=NEW_FOLDER_NAME
|
||||
|
||||
# tGoogleDriveDelete
|
||||
tGoogleDriveDelete=tGoogleDriveDelete
|
||||
tGoogleDriveDelete.connection.referencedComponent=CONNECTION
|
||||
tGoogleDriveDelete.connection.applicationName=APPLICATION_NAME
|
||||
tGoogleDriveDelete.connection.accessToken=ACCESS_TOKEN
|
||||
tGoogleDriveDelete.connection.useProxy=USE_PROXY
|
||||
tGoogleDriveDelete.connection.proxyHost=PROXY_HOST
|
||||
tGoogleDriveDelete.connection.proxyPort=PROXY_PORT
|
||||
tGoogleDriveDelete.connection.useSSL=USE_SSL
|
||||
tGoogleDriveDelete.connection.sslAlgorithm=SSL_ALGORITHM
|
||||
tGoogleDriveDelete.connection.sslTrustStore=SSL_TRUST_STORE
|
||||
tGoogleDriveDelete.connection.sslTrustStorePassword=SSL_TRUST_STORE_PASSWORD
|
||||
tGoogleDriveDelete.connection.oAuthMethod=OAUTH_METHOD
|
||||
tGoogleDriveDelete.connection.datastorePath=DATASTORE_PATH
|
||||
tGoogleDriveDelete.file=FILE_NAME
|
||||
tGoogleDriveDelete.useTrash=USE_TRASH
|
||||
|
||||
# tGoogleDriveGet
|
||||
tGoogleDriveGet=tGoogleDriveGet
|
||||
tGoogleDriveGet.connection.referencedComponent=CONNECTION
|
||||
tGoogleDriveGet.connection.applicationName=APPLICATION_NAME
|
||||
tGoogleDriveGet.connection.accessToken=ACCESS_TOKEN
|
||||
tGoogleDriveGet.connection.useProxy=USE_PROXY
|
||||
tGoogleDriveGet.connection.proxyHost=PROXY_HOST
|
||||
tGoogleDriveGet.connection.proxyPort=PROXY_PORT
|
||||
tGoogleDriveGet.connection.useSSL=USE_SSL
|
||||
tGoogleDriveGet.connection.sslAlgorithm=SSL_ALGORITHM
|
||||
tGoogleDriveGet.connection.sslTrustStore=SSL_TRUST_STORE
|
||||
tGoogleDriveGet.connection.sslTrustStorePassword=SSL_TRUST_STORE_PASSWORD
|
||||
tGoogleDriveGet.connection.oAuthMethod=OAUTH_METHOD
|
||||
tGoogleDriveGet.connection.datastorePath=DATASTORE_PATH
|
||||
tGoogleDriveGet.file=FILE_NAME
|
||||
tGoogleDriveGet.storeToLocal=STORE_TO_LOCAL
|
||||
tGoogleDriveGet.outputFileName=OUTPUT
|
||||
@@ -43,6 +93,18 @@ tGoogleDriveGet.mainSchema.schema.connector=FLOW->FLOW
|
||||
|
||||
# tGoogleDriveList
|
||||
tGoogleDriveList=tGoogleDriveList
|
||||
tGoogleDriveList.connection.referencedComponent=CONNECTION
|
||||
tGoogleDriveList.connection.applicationName=APPLICATION_NAME
|
||||
tGoogleDriveList.connection.accessToken=ACCESS_TOKEN
|
||||
tGoogleDriveList.connection.useProxy=USE_PROXY
|
||||
tGoogleDriveList.connection.proxyHost=PROXY_HOST
|
||||
tGoogleDriveList.connection.proxyPort=PROXY_PORT
|
||||
tGoogleDriveList.connection.useSSL=USE_SSL
|
||||
tGoogleDriveList.connection.sslAlgorithm=SSL_ALGORITHM
|
||||
tGoogleDriveList.connection.sslTrustStore=SSL_TRUST_STORE
|
||||
tGoogleDriveList.connection.sslTrustStorePassword=SSL_TRUST_STORE_PASSWORD
|
||||
tGoogleDriveList.connection.oAuthMethod=OAUTH_METHOD
|
||||
tGoogleDriveList.connection.datastorePath=DATASTORE_PATH
|
||||
tGoogleDriveList.folder=FOLDER_NAME
|
||||
tGoogleDriveList.includeSubDirectories=INCLUDSUBDIR
|
||||
tGoogleDriveList.listMode=LIST_MODE
|
||||
@@ -50,7 +112,19 @@ tGoogleDriveList.includeTrashedFiles=INCLUDTRASHFILES
|
||||
|
||||
# tGoogleDrivePut
|
||||
tGoogleDrivePut=tGoogleDrivePut
|
||||
tGoogleDrivePut.uploadMode=READ_CONTENT_FROM_INPUT
|
||||
tGoogleDrivePut.connection.referencedComponent=CONNECTION
|
||||
tGoogleDrivePut.connection.applicationName=APPLICATION_NAME
|
||||
tGoogleDrivePut.connection.accessToken=ACCESS_TOKEN
|
||||
tGoogleDrivePut.connection.useProxy=USE_PROXY
|
||||
tGoogleDrivePut.connection.proxyHost=PROXY_HOST
|
||||
tGoogleDrivePut.connection.proxyPort=PROXY_PORT
|
||||
tGoogleDrivePut.connection.useSSL=USE_SSL
|
||||
tGoogleDrivePut.connection.sslAlgorithm=SSL_ALGORITHM
|
||||
tGoogleDrivePut.connection.sslTrustStore=SSL_TRUST_STORE
|
||||
tGoogleDrivePut.connection.sslTrustStorePassword=SSL_TRUST_STORE_PASSWORD
|
||||
tGoogleDrivePut.connection.oAuthMethod=OAUTH_METHOD
|
||||
tGoogleDrivePut.connection.datastorePath=DATASTORE_PATH
|
||||
tGoogleDrivePut.uploadMode=UPLOAD_MODE
|
||||
tGoogleDrivePut.fileName=FILE_TITLE
|
||||
tGoogleDrivePut.destinationFolder=DESTINATION_FOLDER_NAME
|
||||
tGoogleDrivePut.overwrite=OVERWRITE
|
||||
|
||||
@@ -19,8 +19,13 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.talend.components.api.component.ComponentDefinition;
|
||||
import org.talend.components.api.properties.ComponentProperties;
|
||||
import org.talend.components.api.properties.ComponentReferenceProperties;
|
||||
import org.talend.core.model.process.EParameterFieldType;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.core.model.process.INode;
|
||||
import org.talend.core.runtime.services.IGenericService;
|
||||
import org.talend.daikon.properties.Properties;
|
||||
import org.talend.designer.core.generic.model.GenericElementParameter;
|
||||
import org.talend.designer.core.generic.utils.ComponentsUtils;
|
||||
|
||||
@@ -52,5 +57,56 @@ public class GenericService implements IGenericService {
|
||||
}
|
||||
return genericComponents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetReferenceValue(INode curNode, String oldConnectionName, String newConnectionName) {
|
||||
ComponentReferenceProperties comPro = null;
|
||||
IElementParameter refPara = curNode.getElementParameterFromField(EParameterFieldType.COMPONENT_REFERENCE);
|
||||
if(refPara != null){
|
||||
comPro = ComponentsUtils.getReferencedComponent(refPara);
|
||||
}
|
||||
if(comPro != null){
|
||||
Object sValue = comPro.componentInstanceId.getStoredValue();
|
||||
if (oldConnectionName.equals(sValue)) {
|
||||
comPro.componentInstanceId.setValue(newConnectionName);
|
||||
return;
|
||||
}
|
||||
if (sValue != null && ((String)sValue).startsWith(oldConnectionName + "_")) { //$NON-NLS-1$
|
||||
comPro.componentInstanceId.setValue(((String)sValue).replaceFirst(oldConnectionName + "_", newConnectionName + "_")); //$NON-NLS-1$
|
||||
return;
|
||||
}
|
||||
}
|
||||
comPro = getComponentReferenceProperties(curNode);
|
||||
if(comPro == null){
|
||||
return;
|
||||
}
|
||||
Object sValue = comPro.componentInstanceId.getStoredValue();
|
||||
if (oldConnectionName.equals(sValue)) {
|
||||
comPro.componentInstanceId.setValue(newConnectionName);
|
||||
} else if (sValue != null && ((String)sValue).startsWith(oldConnectionName + "_")) { //$NON-NLS-1$
|
||||
comPro.componentInstanceId.setValue(((String)sValue).replaceFirst(oldConnectionName + "_", newConnectionName + "_")); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
private ComponentReferenceProperties getComponentReferenceProperties(INode curNode){
|
||||
ComponentProperties pros = curNode.getComponentProperties();
|
||||
if(pros == null){
|
||||
return null;
|
||||
}
|
||||
Properties ps = pros.getProperties("referencedComponent"); //$NON-NLS-1$
|
||||
if(ps == null){
|
||||
Properties conn = pros.getProperties("connection"); //$NON-NLS-1$
|
||||
if(conn != null){
|
||||
ps = conn.getProperties("referencedComponent"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
if(ps == null){
|
||||
return null;
|
||||
}
|
||||
if(ps instanceof ComponentReferenceProperties){
|
||||
return (ComponentReferenceProperties)ps;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -837,6 +837,20 @@ public class ComponentsUtils {
|
||||
}
|
||||
return nals;
|
||||
}
|
||||
|
||||
public static ComponentReferenceProperties getReferencedComponent(IElementParameter refPara){
|
||||
if (!(refPara instanceof GenericElementParameter)) {
|
||||
return null;
|
||||
}
|
||||
Widget widget = ((GenericElementParameter) refPara).getWidget();
|
||||
NamedThing widgetProperty = widget.getContent();
|
||||
if (widgetProperty instanceof ComponentReferenceProperties
|
||||
&& Widget.COMPONENT_REFERENCE_WIDGET_TYPE.equals(widget.getWidgetType())) {
|
||||
ComponentReferenceProperties props = (ComponentReferenceProperties) widgetProperty;
|
||||
return props;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void initReferencedComponent(IElementParameter refPara, String newValue) {
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -397,6 +398,7 @@ GuessSchemaController.connectionFailed=Database connection is failed.
|
||||
GuessSchemaController.connError=Connection error
|
||||
GuessSchemaController.setParameter=Please set connection parameters
|
||||
GuessSchemaController.waitOpenDatabase=Waiting for opening Database ...
|
||||
GuessSchemaController.emptyQuery=Empty query
|
||||
I18nPreferencePage.allTranslation=Import all translations
|
||||
I18nPreferencePage.completeInfo=Translations loaded from Babili, these translations will be only displayed to test, on next restart of the application, these texts for translations will be lost.
|
||||
I18nPreferencePage.importBabili=Import Translation from Babili
|
||||
@@ -733,6 +735,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();
|
||||
|
||||
@@ -76,6 +76,8 @@ public final class Expression {
|
||||
|
||||
private static final Pattern isShowFuncPattern = Pattern.compile("isShow\\[(\\w+)(\\.\\w+)*\\]"); //$NON-NLS-1$
|
||||
|
||||
private static final String CONTAINS = "CONTAINS"; //$NON-NLS-1$
|
||||
|
||||
private Expression(String expressionString) {
|
||||
this.expressionString = expressionString;
|
||||
}
|
||||
@@ -274,6 +276,10 @@ public final class Expression {
|
||||
if ((simpleExpression.contains("SPARK_VERSION["))) { //$NON-NLS-1$
|
||||
return evaluateSparkVersion(simpleExpression, listParam, currentParam);
|
||||
}
|
||||
|
||||
if ((simpleExpression.contains(CONTAINS))) { //$NON-NLS-1$
|
||||
return evaluateContains(simpleExpression, listParam);
|
||||
}
|
||||
|
||||
List<String> paraNames = getParaNamesFromIsShowFunc(simpleExpression);
|
||||
if (paraNames.size() > 0) {
|
||||
@@ -1030,5 +1036,28 @@ public final class Expression {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean evaluateContains(String simpleExpression, List<? extends IElementParameter> listParam) {
|
||||
//Split to get param name and param value to look after
|
||||
String[] splitted = simpleExpression.split(CONTAINS);
|
||||
if (splitted.length != 2) {
|
||||
return false;
|
||||
}
|
||||
String paramName = splitted[0].trim();
|
||||
String paramValue = splitted[1].trim();
|
||||
|
||||
//Look for the param name in list
|
||||
IElementParameter param = listParam.stream()
|
||||
.filter(p -> paramName.equals(p.getName()))
|
||||
.findAny()
|
||||
.orElse(null);
|
||||
if (param == null || ! EParameterFieldType.TABLE.equals(param.getFieldType())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if we can find paraValue among table lines
|
||||
return ((List<Map<String, Object>>) param.getValue()).stream()
|
||||
.anyMatch(line -> paramValue.equals(line.toString()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -737,6 +737,12 @@ public class StatsAndLogsManager {
|
||||
|
||||
if (isGeneric) {// reset the show if
|
||||
resetShowIf(connectionNode);
|
||||
if (checkUrlContainsAutoCommit(connectionNode)) {
|
||||
IElementParameter autoCommitParam = connectionNode.getElementParameter("autocommit");//$NON-NLS-1$
|
||||
if (autoCommitParam != null) {
|
||||
autoCommitParam.setValue(Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (connectionComponentName.contains("Oracle")) {//$NON-NLS-1$
|
||||
@@ -764,13 +770,44 @@ public class StatsAndLogsManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
DataConnection dataConnec = createDataConnectionForSubJobOK(dataNode, commitNode);
|
||||
((List<IConnection>) dataNode.getOutgoingConnections()).add(dataConnec);
|
||||
((List<IConnection>) commitNode.getIncomingConnections()).add(dataConnec);
|
||||
|
||||
boolean noCommitNode = false;
|
||||
if (checkUrlContainsAutoCommit(connectionNode)) {
|
||||
IElementParameter autoCommitParam = connectionNode.getElementParameter("autocommit");//$NON-NLS-1$
|
||||
if (autoCommitParam != null && autoCommitParam.getValue() != null) {
|
||||
noCommitNode = Boolean.parseBoolean(autoCommitParam.getValue().toString());
|
||||
if (noCommitNode && nodeList.contains(commitNode)) {
|
||||
nodeList.remove(commitNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!noCommitNode) {
|
||||
DataConnection dataConnec = createDataConnectionForSubJobOK(dataNode, commitNode);
|
||||
((List<IConnection>) dataNode.getOutgoingConnections()).add(dataConnec);
|
||||
((List<IConnection>) commitNode.getIncomingConnections()).add(dataConnec);
|
||||
}
|
||||
return connectionNode;
|
||||
}
|
||||
|
||||
private static boolean checkUrlContainsAutoCommit(DataNode connectionNode) {
|
||||
if (connectionNode != null) {
|
||||
boolean isGeneric = connectionNode.getComponent().getComponentType() == EComponentType.GENERIC;
|
||||
if (isGeneric) {
|
||||
IElementParameter urlParam = connectionNode
|
||||
.getElementParameter(EConnectionParameterName.GENERIC_URL.getDisplayName());
|
||||
if (urlParam != null) {
|
||||
Object obj = urlParam.getValue();
|
||||
if (obj != null && obj instanceof String) {
|
||||
String url = (String) obj;
|
||||
if (url != null && url.toLowerCase().contains("autocommit=true")) {//$NON-NLS-1$
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void resetShowIf(DataNode connectionNode) {
|
||||
ComponentProperties tcomp_properties = connectionNode.getComponentProperties();
|
||||
if (tcomp_properties != null) {
|
||||
|
||||
@@ -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();
|
||||
@@ -1883,7 +1884,15 @@ public class Node extends Element implements IGraphicalNode {
|
||||
|
||||
if (id.equals(EParameterName.CONNECTION_FORMAT.getName())) {
|
||||
connectionToParse = (String) value;
|
||||
setConnectionName(ElementParameterParser.parse(this, connectionToParse));
|
||||
boolean isTestCase = false;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
|
||||
ITestContainerProviderService testContainerService = (ITestContainerProviderService) GlobalServiceRegister
|
||||
.getDefault().getService(ITestContainerProviderService.class);
|
||||
isTestCase = getProcess() != null && testContainerService.isTestContainerProcess(getProcess());
|
||||
}
|
||||
if (!isTestCase) {
|
||||
setConnectionName(ElementParameterParser.parse(this, connectionToParse));
|
||||
}
|
||||
// to check
|
||||
// String newValue = ElementParameterParser.parse(this, connectionToParse);
|
||||
// setConnectionName(newValue);
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
@@ -122,7 +123,9 @@ 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.process.TalendProcessArgumentConstant;
|
||||
import org.talend.core.runtime.repository.item.ItemProductKeys;
|
||||
import org.talend.core.runtime.util.ItemDateParser;
|
||||
import org.talend.core.service.IScdComponentService;
|
||||
@@ -1813,23 +1816,36 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
routinesDependencies = new ArrayList<RoutinesParameterType>();
|
||||
}
|
||||
try {
|
||||
Project targetProject = new Project(ProjectManager.getInstance().getProject(getProperty()));
|
||||
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
Set<IRepositoryViewObject> routines = new HashSet<>();
|
||||
routines.addAll(factory.getAll(targetProject, ERepositoryObjectType.ROUTINES));
|
||||
List<Project> referenceProjects = ProjectManager.getInstance().getAllReferencedProjects(targetProject, false);
|
||||
referenceProjects.stream().forEach(p -> {
|
||||
try {
|
||||
routines.addAll(factory.getAll(p, ERepositoryObjectType.ROUTINES).stream()
|
||||
.filter(o -> !((RoutineItem) o.getProperty().getItem()).isBuiltIn()).collect(Collectors.toList()));
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
});
|
||||
Set<String> allRoutinesSet = routines.stream().map(o -> o.getProperty().getLabel()).collect(Collectors.toSet());
|
||||
Iterator<RoutinesParameterType> iterator = routinesDependencies.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
RoutinesParameterType routine = iterator.next();
|
||||
if (!allRoutinesSet.contains(routine.getName())) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
List<String> possibleRoutines = new ArrayList<String>();
|
||||
List<String> routinesToAdd = new ArrayList<String>();
|
||||
String additionalString = LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA ? "." : "";
|
||||
|
||||
List<String> routinesAlreadySetup = new ArrayList<String>();
|
||||
|
||||
for (RoutinesParameterType routine : routinesDependencies) {
|
||||
routinesAlreadySetup.add(routine.getName());
|
||||
}
|
||||
|
||||
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
List<IRepositoryViewObject> routines = factory.getAll(ProjectManager.getInstance().getCurrentProject(),
|
||||
ERepositoryObjectType.ROUTINES);
|
||||
routines.addAll(factory.getAll(ProjectManager.getInstance().getCurrentProject(), ERepositoryObjectType.PIG_UDF));
|
||||
for (Project project : ProjectManager.getInstance().getAllReferencedProjects()) {
|
||||
for (Project project : referenceProjects) {
|
||||
List<IRepositoryViewObject> refRoutines = factory.getAll(project, ERepositoryObjectType.ROUTINES);
|
||||
refRoutines.addAll(factory.getAll(project, ERepositoryObjectType.PIG_UDF));
|
||||
for (IRepositoryViewObject object : refRoutines) {
|
||||
if (!((RoutineItem) object.getProperty().getItem()).isBuiltIn()) {
|
||||
if (!possibleRoutines.contains(object.getLabel()) && !routinesAlreadySetup.contains(object.getLabel())) {
|
||||
@@ -1854,9 +1870,8 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
possibleRoutines.add(object.getLabel());
|
||||
}
|
||||
}
|
||||
for (Project project : ProjectManager.getInstance().getAllReferencedProjects()) {
|
||||
for (Project project : referenceProjects) {
|
||||
List<IRepositoryViewObject> refRoutines = factory.getAll(project, ERepositoryObjectType.ROUTINES);
|
||||
refRoutines.addAll(factory.getAll(project, ERepositoryObjectType.PIG_UDF));
|
||||
for (IRepositoryViewObject object : refRoutines) {
|
||||
if (!((RoutineItem) object.getProperty().getItem()).isBuiltIn()) {
|
||||
if (!possibleRoutines.contains(object.getLabel()) && !routinesAlreadySetup.contains(object.getLabel())) {
|
||||
@@ -1914,12 +1929,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 +2805,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;
|
||||
@@ -4402,6 +4435,19 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
private void loadAdditionalProperties() {
|
||||
if (additionalProperties == null) {
|
||||
additionalProperties = new HashMap<Object, Object>();
|
||||
|
||||
try {
|
||||
if (property.getItem() != null && ERepositoryObjectType.getType(property) != null) {
|
||||
boolean isRouteProcess = ERepositoryObjectType.getType(property).equals(ERepositoryObjectType.PROCESS_ROUTE);
|
||||
if (!isRouteProcess && "ROUTE"
|
||||
.equals(this.property.getAdditionalProperties().get(TalendProcessArgumentConstant.ARG_BUILD_TYPE))) {
|
||||
this.property.getAdditionalProperties().remove(TalendProcessArgumentConstant.ARG_BUILD_TYPE);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
for (Object key : this.property.getAdditionalProperties().keySet()) {
|
||||
additionalProperties.put(key, this.property.getAdditionalProperties().get(key));
|
||||
}
|
||||
@@ -4533,6 +4579,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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ import org.talend.core.model.process.IElement;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.core.model.process.INode;
|
||||
import org.talend.core.model.process.IProcess2;
|
||||
import org.talend.core.runtime.services.IGenericService;
|
||||
import org.talend.core.ui.IJobletProviderService;
|
||||
import org.talend.core.ui.process.IGraphicalNode;
|
||||
import org.talend.core.ui.properties.tab.IDynamicProperty;
|
||||
@@ -209,6 +210,20 @@ public class ComponentListController extends AbstractElementPropertySectionContr
|
||||
} else if (value != null && value.startsWith(oldConnectionName + "_")) {
|
||||
curParam.setValue(value.replaceFirst(oldConnectionName + "_", newConnectionName + "_"));
|
||||
}
|
||||
}else if(curParam.getFieldType().equals(EParameterFieldType.COMPONENT_REFERENCE)){
|
||||
String value = (String)curParam.getValue();
|
||||
if (oldConnectionName.equals(value)) {
|
||||
curParam.setValue(newConnectionName);
|
||||
} else if (value != null && value.startsWith(oldConnectionName + "_")) {
|
||||
curParam.setValue(value.replaceFirst(oldConnectionName + "_", newConnectionName + "_"));
|
||||
}
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericService.class)) {
|
||||
IGenericService genericService = (IGenericService) GlobalServiceRegister.getDefault().getService(
|
||||
IGenericService.class);
|
||||
if(genericService != null){
|
||||
genericService.resetReferenceValue(curNode, oldConnectionName, newConnectionName);
|
||||
}
|
||||
}
|
||||
} else if (curParam.getFieldType().equals(EParameterFieldType.TABLE)) {
|
||||
final Object[] itemsValue = curParam.getListItemsValue();
|
||||
for (Object element : itemsValue) {
|
||||
|
||||
@@ -86,6 +86,7 @@ import org.talend.core.ui.properties.tab.IDynamicProperty;
|
||||
import org.talend.core.ui.services.ISQLBuilderService;
|
||||
import org.talend.core.utils.CsvArray;
|
||||
import org.talend.core.utils.KeywordsValidator;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
import org.talend.designer.core.i18n.Messages;
|
||||
import org.talend.designer.core.model.components.EParameterName;
|
||||
import org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand;
|
||||
@@ -214,6 +215,11 @@ public class GuessSchemaController extends AbstractElementPropertySectionControl
|
||||
IElementParameter elementParameterFromField = elem.getElementParameterFromField(EParameterFieldType.MEMO_SQL);
|
||||
|
||||
memoSQL = (String) elementParameterFromField.getValue();
|
||||
if (memoSQL == null || TalendQuoteUtils.removeQuotes(memoSQL).trim().isEmpty()) {
|
||||
MessageDialog.open(MessageDialog.INFORMATION, this.btn.getShell(), "",
|
||||
Messages.getString("GuessSchemaController.emptyQuery"), SWT.NONE);
|
||||
return null;
|
||||
}
|
||||
initConnectionParameters();
|
||||
if (this.connParameters != null && memoSQL != null) {
|
||||
initConnectionParametersWithContext(elem, manager.getDefaultContext());
|
||||
|
||||
@@ -200,6 +200,12 @@ public class GuessSchemaProcess extends AbstractGuessSchemaProcess {
|
||||
|| EDatabaseTypeName.SAPHana.getXmlName().equals(info.getDbType())) {
|
||||
createStatament = "conn.createStatement()";
|
||||
}
|
||||
|
||||
if (EDatabaseTypeName.REDSHIFT.getXmlName().equals(info.getDbType())
|
||||
|| EDatabaseTypeName.REDSHIFT_SSO.getXmlName().equals(info.getDbType())) {
|
||||
createStatament = "conn.createStatement()";
|
||||
}
|
||||
|
||||
codeStart = systemProperty + getCodeStart(connectionNode, createStatament, fetchSize);
|
||||
|
||||
codeMain = "String[] dataOneRow = new String[numbOfColumn];\r\n" + "for (int i = 1; i <= numbOfColumn; i++) {\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
@@ -207,13 +213,8 @@ public class GuessSchemaProcess extends AbstractGuessSchemaProcess {
|
||||
+ "csvWriter.writeNext(dataOneRow);"; //$NON-NLS-1$
|
||||
|
||||
|
||||
if(EDatabaseTypeName.REDSHIFT.getXmlName().equals(info.getDbType())||EDatabaseTypeName.REDSHIFT_SSO.getXmlName().equals(info.getDbType())){
|
||||
codeEnd = "nbRows++;\r\n" + " if (nbRows > " + maximumRowsToPreview + ") break;\r\n" + "}\r\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
+ "conn.close();\r\n" + "csvWriter.close();\r\n"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}else{
|
||||
codeEnd = "nbRows++;\r\n" + " if (nbRows > " + maximumRowsToPreview + ") break;\r\n" + "}\r\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
+ "conn.close();\r\n" + "csvWriter.close();\r\n"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
codeEnd = "nbRows++;\r\n" + " if (nbRows > " + maximumRowsToPreview + ") break;\r\n" + "}\r\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
+ "conn.close();\r\n" + "csvWriter.close();\r\n"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
IComponent component = null;
|
||||
switch (LanguageManager.getCurrentLanguage()) {
|
||||
@@ -237,99 +238,34 @@ public class GuessSchemaProcess extends AbstractGuessSchemaProcess {
|
||||
|
||||
private String getCodeStart(INode connectionNode, String createStatament, int fetchSize){
|
||||
IPath temppath = getTemppath();
|
||||
String codeStart = null;
|
||||
if(EDatabaseTypeName.REDSHIFT.getXmlName().equals(info.getDbType())||EDatabaseTypeName.REDSHIFT_SSO.getXmlName().equals(info.getDbType())){
|
||||
INode node = getNode();
|
||||
String tableName = (String) node.getElementParameter("TABLE").getValue();
|
||||
String dbName = null;
|
||||
String schema = null;
|
||||
if(connectionNode!=null){
|
||||
if(connectionNode.getElementParameter("DBNAME")!=null){
|
||||
dbName = (String) connectionNode.getElementParameter("DBNAME").getValue();
|
||||
}
|
||||
if(connectionNode.getElementParameter("SCHEMA_DB")!=null){
|
||||
schema = (String) connectionNode.getElementParameter("SCHEMA_DB").getValue();
|
||||
}
|
||||
}else{
|
||||
if(node.getElementParameter("DBNAME")!=null){
|
||||
dbName = (String) node.getElementParameter("DBNAME").getValue();
|
||||
}
|
||||
if(node.getElementParameter("SCHEMA_DB")!=null){
|
||||
schema = (String) node.getElementParameter("SCHEMA_DB").getValue();
|
||||
}
|
||||
}
|
||||
String codeStart = "java.lang.Class.forName(\"" + info.getDriverClassName() + "\");\r\n" + "String url = \"" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
+ info.getUrl() + "\";\r\n" + "java.sql.Connection conn = java.sql.DriverManager.getConnection(url, \"" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ info.getUsername() + "\", \"" + info.getPwd() + "\");\r\n" + "java.sql.Statement stm = " + createStatament + ";\r\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
+ "try {\r\nstm.setFetchSize(" + fetchSize //$NON-NLS-1$
|
||||
+ ");\r\n} catch (Exception e) {\r\n// Exception is thrown if db don't support, no need to catch exception here\r\n} \r\n" //$NON-NLS-1$
|
||||
+ "java.sql.ResultSet rs = stm.executeQuery(" + memoSQL + ");\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "java.sql.ResultSetMetaData rsmd = rs.getMetaData();\r\n" + "int numbOfColumn = rsmd.getColumnCount();\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "\r\n" + "String fileName = (new java.io.File(\r\n" + " \"" + temppath //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
+ "\")).getAbsolutePath().replace(\r\n" + " \"\\\\\", \"/\");\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "com.talend.csv.CSVWriter csvWriter = new com.talend.csv.CSVWriter(\r\n" //$NON-NLS-1$
|
||||
+ " new java.io.BufferedWriter(new java.io.OutputStreamWriter(\r\n" //$NON-NLS-1$
|
||||
+ " new java.io.FileOutputStream(\r\n" //$NON-NLS-1$
|
||||
+ " fileName, false),\r\n" //$NON-NLS-1$
|
||||
+ " \"GBK\")));\r\n" + " \r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "csvWriter.setSeparator(';');\r\n" + "csvWriter.setQuoteStatus(com.talend.csv.CSVWriter.QuoteStatus.FORCE);\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "int nbRows = 0;\r\n" //$NON-NLS-1$
|
||||
+ "String[] columnNames = new String[numbOfColumn];\r\n" + "String[] nullables = new String[numbOfColumn];\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "String[] lengths = new String[numbOfColumn];\r\n" + "String[] precisions = new String[numbOfColumn];\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "String[] dbtypes = new String[numbOfColumn];\r\n" //$NON-NLS-1$
|
||||
+ "for(int i = 1;i<=numbOfColumn;i++){\r\n" + "columnNames[i-1] = rsmd.getColumnName(i);\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "nullables[i-1] = rsmd.isNullable(i) == 0? \"false\" : \"true\";\r\n" //$NON-NLS-1$
|
||||
+ "lengths[i-1] = Integer.toString(rsmd.getScale(i));\r\n" //$NON-NLS-1$
|
||||
+ "precisions[i-1] = Integer.toString(rsmd.getPrecision(i));" //$NON-NLS-1$
|
||||
+ "dbtypes[i-1] = rsmd.getColumnTypeName(i);\r\n" + "}\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
codeStart = "java.lang.Class.forName(\"" + info.getDriverClassName() + "\");\r\n" + "String url = \"" + info.getUrl() //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
+ "\";\r\n" + "java.sql.Connection conn = java.sql.DriverManager.getConnection(url, \"" + info.getUsername() //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "\", \"" + info.getPwd() + "\");\r\n" + "java.sql.DatabaseMetaData metaData = conn.getMetaData();\r\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
+ "java.sql.ResultSet rs = metaData.getColumns(" + dbName + "," + schema + "," + tableName + ",null);\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
+ "\r\n" + "String fileName = (new java.io.File(\r\n" + " \"" + temppath //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
+ "\")).getAbsolutePath().replace(\r\n" + " \"\\\\\", \"/\");\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "com.talend.csv.CSVWriter csvWriter = new com.talend.csv.CSVWriter(\r\n" //$NON-NLS-1$
|
||||
+ " new java.io.BufferedWriter(new java.io.OutputStreamWriter(\r\n" //$NON-NLS-1$
|
||||
+ " new java.io.FileOutputStream(\r\n" //$NON-NLS-1$
|
||||
+ " fileName, false),\r\n" //$NON-NLS-1$
|
||||
+ " \"GBK\")));\r\n" + " \r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "csvWriter.setSeparator(';');\r\n" + "csvWriter.setQuoteStatus(com.talend.csv.CSVWriter.QuoteStatus.FORCE);\r\n" + "int nbRows = 0;\r\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
|
||||
|
||||
|
||||
+ "java.util.List<String> columnNameList= new java.util.ArrayList<String>();\r\n" + "java.util.List<String> nullableList= new java.util.ArrayList<String>();\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "java.util.List<String> lengthList= new java.util.ArrayList<String>();\r\n" + "java.util.List<String> precisionList= new java.util.ArrayList<String>();\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "java.util.List<String> dbtypeList= new java.util.ArrayList<String>();\r\n" //$NON-NLS-1$
|
||||
|
||||
+"while (rs.next()) {\r\n" //$NON-NLS-1$
|
||||
+"columnNameList.add(rs.getString(\"COLUMN_NAME\"));\r\n" //$NON-NLS-1$
|
||||
+"nullableList.add(rs.getBoolean(\"NULLABLE\") ? \"true\" : \"false\");\r\n" //$NON-NLS-1$
|
||||
+"lengthList.add(Integer.toString(rs.getInt(\"COLUMN_SIZE\")));\r\n" //$NON-NLS-1$
|
||||
+"precisionList.add(Integer.toString(rs.getInt(\"NUM_PREC_RADIX\")));\r\n" //$NON-NLS-1$
|
||||
+"dbtypeList.add(rs.getString(\"TYPE_NAME\"));\r\n" //$NON-NLS-1$
|
||||
+"}\r\n" //$NON-NLS-1$
|
||||
|
||||
+"int numbOfColumn = columnNameList.size();" //$NON-NLS-1$
|
||||
+ "String[] columnNames = new String[numbOfColumn];\r\n" + "String[] nullables = new String[numbOfColumn];\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "String[] lengths = new String[numbOfColumn];\r\n" + "String[] precisions = new String[numbOfColumn];\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "String[] dbtypes = new String[numbOfColumn];\r\n" //$NON-NLS-1$
|
||||
|
||||
|
||||
+ "for(int i = 0;i<=numbOfColumn-1;i++){\r\n" + "columnNames[i] = columnNameList.get(i);\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "nullables[i] = nullableList.get(i);\r\n" //$NON-NLS-1$
|
||||
+ "lengths[i] = lengthList.get(i);\r\n" //$NON-NLS-1$
|
||||
+ "precisions[i] = precisionList.get(i);" //$NON-NLS-1$
|
||||
+ "dbtypes[i] = dbtypeList.get(i);\r\n" + "}\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
+ "csvWriter.writeNext(columnNames);\r\n" + "csvWriter.writeNext(nullables);\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "csvWriter.writeNext(lengths);\r\n" + "csvWriter.writeNext(precisions);\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "csvWriter.writeNext(dbtypes);\r\n" + "while (rs.next()) {"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}else{
|
||||
codeStart = "java.lang.Class.forName(\"" + info.getDriverClassName() + "\");\r\n" + "String url = \"" + info.getUrl() //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
+ "\";\r\n" + "java.sql.Connection conn = java.sql.DriverManager.getConnection(url, \"" + info.getUsername() //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "\", \"" + info.getPwd() + "\");\r\n" + "java.sql.Statement stm = " + createStatament + ";\r\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
+ "try {\r\nstm.setFetchSize(" + fetchSize + ");\r\n} catch (Exception e) {\r\n// Exception is thrown if db don't support, no need to catch exception here\r\n} \r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "java.sql.ResultSet rs = stm.executeQuery(" + memoSQL + ");\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "java.sql.ResultSetMetaData rsmd = rs.getMetaData();\r\n" + "int numbOfColumn = rsmd.getColumnCount();\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "\r\n" + "String fileName = (new java.io.File(\r\n" + " \"" + temppath //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
+ "\")).getAbsolutePath().replace(\r\n" + " \"\\\\\", \"/\");\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "com.talend.csv.CSVWriter csvWriter = new com.talend.csv.CSVWriter(\r\n" //$NON-NLS-1$
|
||||
+ " new java.io.BufferedWriter(new java.io.OutputStreamWriter(\r\n" //$NON-NLS-1$
|
||||
+ " new java.io.FileOutputStream(\r\n" //$NON-NLS-1$
|
||||
+ " fileName, false),\r\n" //$NON-NLS-1$
|
||||
+ " \"GBK\")));\r\n" + " \r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "csvWriter.setSeparator(';');\r\n" + "csvWriter.setQuoteStatus(com.talend.csv.CSVWriter.QuoteStatus.FORCE);\r\n" + "int nbRows = 0;\r\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
+ "String[] columnNames = new String[numbOfColumn];\r\n" + "String[] nullables = new String[numbOfColumn];\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "String[] lengths = new String[numbOfColumn];\r\n" + "String[] precisions = new String[numbOfColumn];\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "String[] dbtypes = new String[numbOfColumn];\r\n" //$NON-NLS-1$
|
||||
+ "for(int i = 1;i<=numbOfColumn;i++){\r\n" + "columnNames[i-1] = rsmd.getColumnName(i);\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "nullables[i-1] = rsmd.isNullable(i) == 0? \"false\" : \"true\";\r\n" //$NON-NLS-1$
|
||||
+ "lengths[i-1] = Integer.toString(rsmd.getScale(i));\r\n" //$NON-NLS-1$
|
||||
+ "precisions[i-1] = Integer.toString(rsmd.getPrecision(i));" //$NON-NLS-1$
|
||||
+ "dbtypes[i-1] = rsmd.getColumnTypeName(i);\r\n" + "}\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
+ "csvWriter.writeNext(columnNames);\r\n" + "csvWriter.writeNext(nullables);\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "csvWriter.writeNext(lengths);\r\n" + "csvWriter.writeNext(precisions);\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "csvWriter.writeNext(dbtypes);\r\n" + "while (rs.next()) {"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
+ "csvWriter.writeNext(columnNames);\r\n" + "csvWriter.writeNext(nullables);\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "csvWriter.writeNext(lengths);\r\n" + "csvWriter.writeNext(precisions);\r\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "csvWriter.writeNext(dbtypes);\r\n" + "while (rs.next()) {"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
return codeStart;
|
||||
}
|
||||
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -175,6 +175,8 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
|
||||
store.setDefault(ITalendCorePrefConstants.NEXUS_TIMEOUT, 20000);
|
||||
store.setDefault(ITalendCorePrefConstants.NEXUS_REFRESH_FREQUENCY, 0);
|
||||
|
||||
store.setDefault(ITalendCorePrefConstants.NEXUS_SHARE_LIBS, true);
|
||||
|
||||
if (!CommonUIPlugin.isFullyHeadless()) {
|
||||
Display display = Display.getDefault();
|
||||
if (display == null) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -115,6 +115,8 @@ public class DeploymentComposite extends AbstractTabComposite {
|
||||
|
||||
private boolean isDataServiceJob; // Is ESB SOAP Service Job
|
||||
|
||||
private boolean isChildJob;
|
||||
|
||||
public DeploymentComposite(Composite parent, int style, TabbedPropertySheetWidgetFactory widgetFactory,
|
||||
IRepositoryViewObject repositoryViewObject) {
|
||||
super(parent, style, widgetFactory, repositoryViewObject);
|
||||
@@ -139,6 +141,7 @@ public class DeploymentComposite extends AbstractTabComposite {
|
||||
defaultVersion = getDefaultVersion(process.getVersion());
|
||||
|
||||
isDataServiceJob = false;
|
||||
isChildJob = false;
|
||||
// Disable widgests in case of the job is for ESB data service
|
||||
if (!process.getComponentsType().equals(ComponentCategory.CATEGORY_4_CAMEL.getName())) {
|
||||
List<INode> nodes = (List<INode>) process.getGraphicalNodes();
|
||||
@@ -149,6 +152,13 @@ public class DeploymentComposite extends AbstractTabComposite {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (INode node : nodes) {
|
||||
if ("tRouteInput".equals(node.getComponent().getName())) {
|
||||
isChildJob = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
|
||||
@@ -211,6 +221,17 @@ public class DeploymentComposite extends AbstractTabComposite {
|
||||
widgetFactory.createLabel(messageComposite,
|
||||
"SOAP data service cannot be published, deployment setting is \naccording to the defined service.");
|
||||
}
|
||||
|
||||
if (isChildJob) {
|
||||
Composite messageComposite = new Composite(this, SWT.NONE);
|
||||
GridLayout layout = new GridLayout(1, false);
|
||||
layout.horizontalSpacing = 10;
|
||||
layout.verticalSpacing = 10;
|
||||
messageComposite.setLayout(layout);
|
||||
messageComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
widgetFactory.createLabel(messageComposite,
|
||||
"Deployment parameters will be inherited from parent route during publishing from Studio and Command Line");
|
||||
}
|
||||
Composite composite = new Composite(this, SWT.NONE);
|
||||
GridLayout layout = new GridLayout(2, false);
|
||||
layout.horizontalSpacing = 10;
|
||||
|
||||
@@ -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,8 +780,11 @@ 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);
|
||||
repositoryObject.getProperty(), oldName, oldVersion);
|
||||
if (needjobletRelateUpdate && GlobalServiceRegister.getDefault()
|
||||
.isServiceRegistered(IJobletProviderService.class)) {
|
||||
IJobletProviderService jobletService = (IJobletProviderService) GlobalServiceRegister
|
||||
|
||||
@@ -10,27 +10,29 @@
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.designer.runprocess.bigdata;
|
||||
package org.talend.designer.core.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.runtime.FileLocator;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.hadoop.HadoopConstants;
|
||||
import org.talend.core.hadoop.version.EHadoopDistributions;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.core.model.process.IProcess;
|
||||
import org.talend.core.model.process.IProcess2;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
|
||||
/**
|
||||
* created by nrousseau on Mar 24, 2018 Detailled comment
|
||||
@@ -38,10 +40,10 @@ import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
*/
|
||||
public class BigDataJobUtil {
|
||||
|
||||
private ProcessItem processItem;
|
||||
private IProcess process;
|
||||
|
||||
public BigDataJobUtil(ProcessItem processItem) {
|
||||
this.processItem = processItem;
|
||||
public BigDataJobUtil(IProcess process) {
|
||||
this.process = process;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,11 +70,10 @@ public class BigDataJobUtil {
|
||||
public boolean isSparkWithHDInsight() {
|
||||
boolean isSparkWithHDInsight = false;
|
||||
if (isBDJobWithFramework(ERepositoryObjectType.PROCESS_MR, HadoopConstants.FRAMEWORK_SPARK)
|
||||
|| isBDJobWithFramework(ERepositoryObjectType.PROCESS_STORM,
|
||||
HadoopConstants.FRAMEWORK_SPARKSTREAMING)) {
|
||||
EList<ElementParameterType> parameters = processItem.getProcess().getParameters().getElementParameter();
|
||||
|| isBDJobWithFramework(ERepositoryObjectType.PROCESS_STORM, HadoopConstants.FRAMEWORK_SPARKSTREAMING)) {
|
||||
List<? extends IElementParameter> parameters = process.getElementParametersWithChildrens();
|
||||
boolean modeParameterVisited = false;
|
||||
for (ElementParameterType pt : parameters) {
|
||||
for (IElementParameter pt : parameters) {
|
||||
if (pt.getName().equals("SPARK_LOCAL_MODE")) { //$NON-NLS-1$
|
||||
modeParameterVisited = true;
|
||||
if ("true".equals(pt.getValue())) { //$NON-NLS-1$
|
||||
@@ -96,11 +97,11 @@ public class BigDataJobUtil {
|
||||
|
||||
public boolean isMRWithHDInsight() {
|
||||
Boolean isMRWithHDInsight = false;
|
||||
if (processItem != null) {
|
||||
if (process != null) {
|
||||
isMRWithHDInsight = false;
|
||||
if (isBDJobWithFramework(ERepositoryObjectType.PROCESS_MR, HadoopConstants.FRAMEWORK_MAPREDUCE)) {
|
||||
EList<ElementParameterType> parameters = processItem.getProcess().getParameters().getElementParameter();
|
||||
for (ElementParameterType pt : parameters) {
|
||||
List<? extends IElementParameter> parameters = process.getElementParametersWithChildrens();
|
||||
for (IElementParameter pt : parameters) {
|
||||
if (pt.getName().equals("DISTRIBUTION") //$NON-NLS-1$
|
||||
&& EHadoopDistributions.MICROSOFT_HD_INSIGHT.getName().equals(pt.getValue())) {
|
||||
isMRWithHDInsight = true;
|
||||
@@ -119,11 +120,10 @@ public class BigDataJobUtil {
|
||||
Boolean isSparkInYarnClusterMode = false;
|
||||
// Test if we are in Spark or Spark streaming
|
||||
if (isBDJobWithFramework(ERepositoryObjectType.PROCESS_MR, HadoopConstants.FRAMEWORK_SPARK)
|
||||
|| isBDJobWithFramework(ERepositoryObjectType.PROCESS_STORM,
|
||||
HadoopConstants.FRAMEWORK_SPARKSTREAMING)) {
|
||||
|| isBDJobWithFramework(ERepositoryObjectType.PROCESS_STORM, HadoopConstants.FRAMEWORK_SPARKSTREAMING)) {
|
||||
|
||||
EList<ElementParameterType> parameters = processItem.getProcess().getParameters().getElementParameter();
|
||||
for (ElementParameterType pt : parameters) {
|
||||
List<? extends IElementParameter> parameters = process.getElementParametersWithChildrens();
|
||||
for (IElementParameter pt : parameters) {
|
||||
if (HadoopConstants.SPARK_MODE.equals(pt.getName())
|
||||
&& HadoopConstants.SPARK_MODE_YARN_CLUSTER.equals(pt.getValue())) {
|
||||
isSparkInYarnClusterMode = true;
|
||||
@@ -135,29 +135,26 @@ public class BigDataJobUtil {
|
||||
}
|
||||
|
||||
private boolean isBDJobWithFramework(ERepositoryObjectType objectType, String frameworkName) {
|
||||
if (processItem != null) {
|
||||
// Storm/SparkStreaming(PROCESS_STORM), MR/Spark(PROCESS_MR)
|
||||
if (ERepositoryObjectType.getItemType(processItem).equals(objectType)) { // have same type
|
||||
Property property = processItem.getProperty();
|
||||
if (property != null && property.getAdditionalProperties() != null
|
||||
&& frameworkName.equals(property.getAdditionalProperties().get(HadoopConstants.FRAMEWORK))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Storm/SparkStreaming(PROCESS_STORM), MR/Spark(PROCESS_MR)
|
||||
if (process != null && process instanceof IProcess2 && ((IProcess2) process).getAdditionalProperties() != null
|
||||
&& frameworkName.equals(((IProcess2) process).getAdditionalProperties().get(HadoopConstants.FRAMEWORK))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Find the distribution where the generated jar rquired to have the context files inside **/
|
||||
public boolean needsToHaveContextInsideJar() {
|
||||
if (processItem.getProcess() != null && processItem.getProcess().getParameters() != null) {
|
||||
EList<ElementParameterType> parameters = processItem.getProcess().getParameters().getElementParameter();
|
||||
for (ElementParameterType pt : parameters) {
|
||||
List<? extends IElementParameter> parameters = process.getElementParametersWithChildrens();
|
||||
|
||||
if (process != null && parameters != null) {
|
||||
|
||||
for (IElementParameter pt : parameters) {
|
||||
if (pt.getName().equals("DISTRIBUTION")) { //$NON-NLS-1$
|
||||
String value = pt.getValue();
|
||||
String value = String.valueOf(pt.getValue());
|
||||
if ("MICROSOFT_HD_INSIGHT".equals(value) //$NON-NLS-1$
|
||||
|| "GOOGLE_CLOUD_DATAPROC".equals(value) //$NON-NLS-1$
|
||||
|| "CLOUDERA_ALTUS".equals(value)) { //$NON-NLS-1$
|
||||
|| "CLOUDERA_ALTUS".equals(value) || "DATABRICKS".equals(value) || "QUBOLE".equals(value)) { //$NON-NLS-1$
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -169,6 +166,27 @@ public class BigDataJobUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setExcludedModules(Collection<ModuleNeeded> modulesNeeded) {
|
||||
if (isMRWithHDInsight() || isSparkWithHDInsight()) {
|
||||
// we need to exclude every non-MR Required jars.
|
||||
for (ModuleNeeded currentModule : modulesNeeded) {
|
||||
if (currentModule.isMrRequired()) {
|
||||
currentModule.setExcluded(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeExcludedModules(Collection<ModuleNeeded> modulesNeeded) {
|
||||
Iterator<ModuleNeeded> itModules = modulesNeeded.iterator();
|
||||
while (itModules.hasNext()) {
|
||||
ModuleNeeded module = itModules.next();
|
||||
if (module.isExcluded()) {
|
||||
itModules.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC nrousseau Comment method "getShadedModulesExclude".
|
||||
*
|
||||
@@ -182,6 +200,8 @@ public class BigDataJobUtil {
|
||||
for (ModuleNeeded currentModule : modulesNeeded) {
|
||||
if (!currentModule.isMrRequired()) {
|
||||
excludedModules.add(currentModule);
|
||||
} else {
|
||||
currentModule.setExcluded(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,12 +27,9 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.talend.core.CorePlugin;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.ILibraryManagerService;
|
||||
import org.talend.core.hadoop.IHadoopClusterService;
|
||||
import org.talend.core.hadoop.repository.HadoopRepositoryUtil;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.general.ModuleNeeded.ELibraryInstallStatus;
|
||||
import org.talend.core.model.process.EParameterFieldType;
|
||||
import org.talend.core.model.process.IContext;
|
||||
import org.talend.core.model.process.IContextParameter;
|
||||
@@ -106,6 +103,10 @@ public class JavaProcessUtil {
|
||||
}
|
||||
}
|
||||
|
||||
if (BitwiseOptionUtils.containOption(options, TalendProcessOptionConstants.MODULES_EXCLUDE_SHADED)) {
|
||||
new BigDataJobUtil(process).removeExcludedModules(modulesNeeded);
|
||||
}
|
||||
|
||||
return new HashSet<ModuleNeeded>(modulesNeeded);
|
||||
}
|
||||
|
||||
@@ -208,6 +209,7 @@ public class JavaProcessUtil {
|
||||
if (hadoopItemId != null) {
|
||||
useCustomConfsJarIfNeeded(modulesNeeded, hadoopItemId);
|
||||
}
|
||||
new BigDataJobUtil(process).setExcludedModules(modulesNeeded);
|
||||
}
|
||||
|
||||
public static String getHadoopClusterItemId(INode node) {
|
||||
|
||||
@@ -2,8 +2,10 @@ package org.talend.designer.core.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.talend.core.model.metadata.IMetadataColumn;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
@@ -386,7 +388,18 @@ public class ParallelExecutionUtils {
|
||||
}
|
||||
|
||||
public static boolean isExistPreviousParCon(Node previousNode) {
|
||||
Set<String> checkedNodeSet = new HashSet<String>();
|
||||
boolean existPreviousParCon = isExistPreviousParCon(previousNode, checkedNodeSet);
|
||||
return existPreviousParCon;
|
||||
}
|
||||
|
||||
private static boolean isExistPreviousParCon(Node previousNode, Set<String> checkedSet) {
|
||||
boolean hasParInPreviousCon = false;
|
||||
if (previousNode == null || checkedSet.contains(previousNode.getUniqueName())) {
|
||||
// already checked, return
|
||||
return hasParInPreviousCon;
|
||||
}
|
||||
checkedSet.add(previousNode.getUniqueName());
|
||||
if (previousNode.getIncomingConnections().size() > 0) {
|
||||
for (IConnection con : previousNode.getIncomingConnections()) {
|
||||
if (con.getElementParameter(EParameterName.PARTITIONER.getName()) != null
|
||||
@@ -396,7 +409,10 @@ public class ParallelExecutionUtils {
|
||||
hasParInPreviousCon = true;
|
||||
break;
|
||||
} else {
|
||||
hasParInPreviousCon = isExistPreviousParCon((Node) con.getSource());
|
||||
hasParInPreviousCon = isExistPreviousParCon((Node) con.getSource(), checkedSet);
|
||||
if (hasParInPreviousCon) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -74,6 +79,8 @@ public abstract class DbGenerationManager {
|
||||
|
||||
protected String tabSpaceString = DEFAULT_TAB_SPACE_STRING;
|
||||
|
||||
private final String DOT_STR = "."; //$NON-NLS-1$
|
||||
|
||||
protected static final String DEFAULT_TAB_SPACE_STRING = ""; //$NON-NLS-1$
|
||||
|
||||
protected List<String> queryColumnsSegments = new ArrayList<String>();
|
||||
@@ -86,6 +93,8 @@ public abstract class DbGenerationManager {
|
||||
|
||||
protected Set<String> subQueryTable = new HashSet<String>();
|
||||
|
||||
protected Set<String> inputSchemaContextSet = new HashSet<String>();
|
||||
|
||||
/**
|
||||
* DOC amaumont GenerationManager constructor comment.
|
||||
*
|
||||
@@ -271,6 +280,7 @@ public abstract class DbGenerationManager {
|
||||
queryColumnsSegments.clear();
|
||||
querySegments.clear();
|
||||
subQueryTable.clear();
|
||||
inputSchemaContextSet.clear();
|
||||
|
||||
this.tabSpaceString = tabString;
|
||||
DbMapComponent component = getDbMapComponent(dbMapComponent);
|
||||
@@ -283,7 +293,9 @@ public abstract class DbGenerationManager {
|
||||
}
|
||||
|
||||
ExternalDbMapData data = component.getExternalData();
|
||||
|
||||
List<ExternalDbMapTable> inputTables = data.getInputTables();
|
||||
List<String> contextList = getContextList(component);
|
||||
collectSchemaContextParam(dbMapComponent, inputTables, contextList);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
List<ExternalDbMapTable> outputTables = data.getOutputTables();
|
||||
@@ -356,8 +368,6 @@ public abstract class DbGenerationManager {
|
||||
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
|
||||
appendSqlQuery(sb, tabSpaceString);
|
||||
appendSqlQuery(sb, DbMapSqlConstants.FROM);
|
||||
List<ExternalDbMapTable> inputTables = data.getInputTables();
|
||||
|
||||
// load input table in hash
|
||||
boolean explicitJoin = false;
|
||||
int lstSizeInputTables = inputTables.size();
|
||||
@@ -436,6 +446,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 +454,6 @@ public abstract class DbGenerationManager {
|
||||
isFirstClause = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* for addition conditions
|
||||
*/
|
||||
@@ -481,16 +491,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();
|
||||
|
||||
@@ -543,6 +556,40 @@ public abstract class DbGenerationManager {
|
||||
return sqlQuery;
|
||||
}
|
||||
|
||||
protected void collectSchemaContextParam(DbMapComponent dbMapComponent, List<ExternalDbMapTable> inputTables,
|
||||
List<String> contextList) {
|
||||
List<IConnection> incomingConnections = (List<IConnection>) dbMapComponent.getIncomingConnections();
|
||||
if (incomingConnections != null) {
|
||||
for (IConnection connection : incomingConnections) {
|
||||
INode input = connection.getSource();
|
||||
if (input != null) {
|
||||
IElementParameter eltSchemaNameParam = input.getElementParameter("ELT_SCHEMA_NAME"); //$NON-NLS-1$
|
||||
if (eltSchemaNameParam != null && eltSchemaNameParam.getValue() != null) {
|
||||
String schema = String.valueOf(eltSchemaNameParam.getValue());
|
||||
if (schema != null && !inputSchemaContextSet.contains(schema) && contextList.contains(schema)) {
|
||||
inputSchemaContextSet.add(schema);
|
||||
}
|
||||
}
|
||||
IElementParameter eltTableNameParam = input.getElementParameter("ELT_TABLE_NAME"); //$NON-NLS-1$
|
||||
if (eltTableNameParam != null && eltTableNameParam.getValue() != null) {
|
||||
String table = String.valueOf(eltTableNameParam.getValue());
|
||||
if (table != null && !inputSchemaContextSet.contains(table) && contextList.contains(table)) {
|
||||
inputSchemaContextSet.add(table);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (inputTables != null) {
|
||||
for (ExternalDbMapTable table : inputTables) {
|
||||
if (table.getAlias() != null && !inputSchemaContextSet.contains(table.getAlias())
|
||||
&& contextList.contains(table.getAlias())) {
|
||||
inputSchemaContextSet.add(table.getAlias());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected DbMapComponent getDbMapComponent(DbMapComponent dbMapComponent) {
|
||||
DbMapComponent component = dbMapComponent;
|
||||
INode realGraphicalNode = dbMapComponent.getRealGraphicalNode();
|
||||
@@ -590,29 +637,27 @@ public abstract class DbGenerationManager {
|
||||
if (expression == null) {
|
||||
return null;
|
||||
}
|
||||
if (DEFAULT_TAB_SPACE_STRING.equals(tabSpaceString)) {
|
||||
List<String> contextList = getContextList(component);
|
||||
boolean haveReplace = false;
|
||||
for (String context : contextList) {
|
||||
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$
|
||||
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$
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
@@ -669,7 +714,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 + "\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -704,7 +753,7 @@ public abstract class DbGenerationManager {
|
||||
|
||||
return contextList;
|
||||
}
|
||||
|
||||
|
||||
protected Set<String> getGlobalMapList(DbMapComponent component, String sqlQuery) {
|
||||
return parser.getGlobalMapSet(sqlQuery);
|
||||
}
|
||||
@@ -776,8 +825,7 @@ public abstract class DbGenerationManager {
|
||||
*/
|
||||
private boolean buildCondition(DbMapComponent component, StringBuilder sbWhere, ExternalDbMapTable table,
|
||||
boolean isFirstClause, ExternalDbMapEntry dbMapEntry, boolean writeCr, boolean isSqlQuery) {
|
||||
String expression = dbMapEntry.getExpression();
|
||||
expression = initExpression(component, dbMapEntry);
|
||||
String expression = initExpression(component, dbMapEntry);
|
||||
IDbOperator dbOperator = getOperatorsManager().getOperatorFromValue(dbMapEntry.getOperator());
|
||||
boolean operatorIsSet = dbOperator != null;
|
||||
boolean expressionIsSet = expression != null && expression.trim().length() > 0;
|
||||
@@ -1016,6 +1064,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 +1090,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 +1155,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 +1169,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 +1189,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 +1354,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 +1374,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();
|
||||
|
||||
@@ -236,8 +236,8 @@ public class PostgresGenerationManager extends DbGenerationManager {
|
||||
}
|
||||
tableAndSchema = tableAndSchema + getHandledField(tableNoQuote);
|
||||
|
||||
if (isVariable(schemaNoQuote) || isVariable(tableNoQuote)) {
|
||||
tableAndSchema = replaceVariablesForExpression(component, tableAndSchema);
|
||||
if (isVariable(schemaNoQuote) || isVariable(tableNoQuote)) {
|
||||
tableAndSchema = replaceVariablesForExpression(component, tableAndSchema);
|
||||
}
|
||||
sb.append(tableAndSchema);
|
||||
} else {
|
||||
@@ -290,32 +290,39 @@ public class PostgresGenerationManager extends DbGenerationManager {
|
||||
if (expression == null) {
|
||||
return null;
|
||||
}
|
||||
if (DEFAULT_TAB_SPACE_STRING.equals(tabSpaceString)) {
|
||||
List<String> contextList = getContextList(component);
|
||||
boolean haveReplace = false;
|
||||
for (String context : contextList) {
|
||||
List<String> contextList = getContextList(component);
|
||||
boolean haveReplace = false;
|
||||
for (String context : contextList) {
|
||||
if (expression.contains(context)) {
|
||||
expression = replaceContextValue(expression, context);
|
||||
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$
|
||||
haveReplace = true;
|
||||
expression = replaceContextValue(expression, context);
|
||||
}
|
||||
}
|
||||
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 replacement = globalMapStr;
|
||||
if (globalMapStr.contains("\\\\")) {
|
||||
replacement = globalMapStr.replaceAll("\\\\", "\\\\\\\\");
|
||||
}
|
||||
String regex = parser.getGlobalMapExpressionRegex(globalMapStr);
|
||||
expression = expression.replaceAll(regex, "\\\\\"\"+" + replacement + "+\"\\\\\""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
Set<String> globalMapList = getGlobalMapList(component, expression);
|
||||
for (String globalMapStr : globalMapList) {
|
||||
String replacement = globalMapStr;
|
||||
if (globalMapStr.contains("\\\\")) {
|
||||
replacement = globalMapStr.replaceAll("\\\\", "\\\\\\\\");
|
||||
}
|
||||
String regex = parser.getGlobalMapExpressionRegex(globalMapStr);
|
||||
expression = expression.replaceAll(regex, "\\\\\"\"+" + replacement + "+\"\\\\\""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
return expression;
|
||||
}
|
||||
|
||||
private String replaceContextValue(String expression, String context) {
|
||||
if (inputSchemaContextSet.contains(context)) {
|
||||
expression = expression.replaceAll("\\b" + context + "\\b", "\\\\\"\"+" + context + "+\"\\\\\"");
|
||||
} else {
|
||||
expression = expression.replaceAll("\\b" + context + "\\b", "\" +" + context + "+ \"");
|
||||
}
|
||||
return expression;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -591,8 +591,8 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
|
||||
attri.setValue(IHTMLDocConstants.PICTUREFOLDERPATH + "pdf_" + jobName + IHTMLDocConstants.JOB_PREVIEW_PIC_SUFFIX); //$NON-NLS-1$
|
||||
|
||||
List attributeList = document.selectNodes("/project/job/externalNodeComponents/component/@preview"); //$NON-NLS-1$
|
||||
for (int i = 0; i < attributeList.size(); i++) {
|
||||
Attribute at = (Attribute) attributeList.get(i);
|
||||
for (Object element : attributeList) {
|
||||
Attribute at = (Attribute) element;
|
||||
String externalValue = at.getValue().substring(at.getValue().indexOf("/") + 1); //$NON-NLS-1$
|
||||
String value = IHTMLDocConstants.PICTUREFOLDERPATH + "pdf_" + externalValue; //$NON-NLS-1$
|
||||
at.setValue(value);
|
||||
@@ -665,8 +665,8 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
|
||||
// Check if generate Job Extra / Stats&Logs Setting Info
|
||||
if (item instanceof ProcessItem) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
|
||||
IMRProcessService mrProcessService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(
|
||||
IMRProcessService.class);
|
||||
IMRProcessService mrProcessService = (IMRProcessService) GlobalServiceRegister.getDefault()
|
||||
.getService(IMRProcessService.class);
|
||||
generateExtraSetting = !mrProcessService.isMapReduceItem(item);
|
||||
generateStatsLogsSetting = generateExtraSetting;
|
||||
} else if (isRouteProcess(item)) {
|
||||
@@ -847,8 +847,8 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
|
||||
|
||||
Map<String, String> nameValueMap = new HashMap<String, String>();
|
||||
|
||||
for (int i = 0; i < params.size(); i++) {
|
||||
ElementParameterType param = (ElementParameterType) params.get(i);
|
||||
for (Object param2 : params) {
|
||||
ElementParameterType param = (ElementParameterType) param2;
|
||||
nameValueMap.put(param.getName(), ParameterValueUtil.getValue4Doc(param));
|
||||
}
|
||||
// Main settinparam info
|
||||
@@ -1022,10 +1022,10 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
|
||||
|
||||
Element contextListElement = DocumentHelper.createElement("contextList"); // Context root //$NON-NLS-1$
|
||||
|
||||
for (int i = 0, n = contexts.size(); i < n; i++) {
|
||||
for (Object context2 : contexts) {
|
||||
// export single context infomation
|
||||
Element contextElement = DocumentHelper.createElement("context"); //$NON-NLS-1$
|
||||
ContextType context = (ContextType) contexts.get(i);
|
||||
ContextType context = (ContextType) context2;
|
||||
|
||||
// Attributes
|
||||
contextElement.addAttribute("name", HTMLDocUtils.checkString(context.getName())); //$NON-NLS-1$
|
||||
@@ -1034,13 +1034,13 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
|
||||
// Context parameters as children
|
||||
EList params = context.getContextParameter();
|
||||
if (params != null && !params.isEmpty()) {
|
||||
for (int j = 0, k = params.size(); j < k; j++) {
|
||||
for (Object param2 : params) {
|
||||
/*
|
||||
* <contextParameter comment="Give server name" name="server" prompt="Default Server "
|
||||
* promptNeeded="false" repositoryContextId="_crJMkCCQEd2Oweh7yRMWjQ" type=""
|
||||
* value="'192.168.0.109'"/>
|
||||
*/
|
||||
ContextParameterType param = (ContextParameterType) params.get(j);
|
||||
ContextParameterType param = (ContextParameterType) param2;
|
||||
Element contextParamElement = DocumentHelper.createElement("contextParameter"); //$NON-NLS-1$
|
||||
contextParamElement.addAttribute("name", HTMLDocUtils.checkString(param.getName())); //$NON-NLS-1$
|
||||
contextParamElement.addAttribute("prompt", HTMLDocUtils.checkString(param.getPrompt())); //$NON-NLS-1$
|
||||
@@ -1212,8 +1212,8 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
|
||||
*/
|
||||
private void generateConnectionsInfo(Element jobElement, EList connectionList) {
|
||||
Element connectionsElement = jobElement.addElement("connections"); //$NON-NLS-1$
|
||||
for (int j = 0; j < connectionList.size(); j++) {
|
||||
ConnectionType type = (ConnectionType) connectionList.get(j);
|
||||
for (Object element : connectionList) {
|
||||
ConnectionType type = (ConnectionType) element;
|
||||
Element connectionElement = connectionsElement.addElement("connection"); //$NON-NLS-1$
|
||||
connectionElement.addAttribute("label", HTMLDocUtils.checkString(type.getLabel())); //$NON-NLS-1$
|
||||
connectionElement.addAttribute("lineStyle", HTMLDocUtils.checkString(type.getLineStyle() + "")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
@@ -1251,8 +1251,8 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
|
||||
}
|
||||
if (isRouteProcess(item)) {
|
||||
jobElement.addAttribute("type", "route");//$NON-NLS-1$//$NON-NLS-2$
|
||||
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(
|
||||
ICamelDesignerCoreService.class);
|
||||
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault()
|
||||
.getService(ICamelDesignerCoreService.class);
|
||||
camelService.appendRouteInfo2Doc(item, jobElement);
|
||||
}
|
||||
if (generateExtraSetting) {
|
||||
@@ -1330,8 +1330,8 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
|
||||
*/
|
||||
protected boolean isRouteProcess(Item item) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
|
||||
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(
|
||||
ICamelDesignerCoreService.class);
|
||||
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault()
|
||||
.getService(ICamelDesignerCoreService.class);
|
||||
return camelService.isInstanceofCamel(item);
|
||||
}
|
||||
return false;
|
||||
@@ -1498,8 +1498,8 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
|
||||
protected void handleSourceAndTargetConnection(EList connectionList) {
|
||||
List<String> targetList = new ArrayList<String>();
|
||||
List<String> sourceList = new ArrayList<String>();
|
||||
for (int j = 0; j < connectionList.size(); j++) {
|
||||
ConnectionType type = (ConnectionType) connectionList.get(j);
|
||||
for (Object element : connectionList) {
|
||||
ConnectionType type = (ConnectionType) element;
|
||||
if (!targetConnectionMap.containsKey(type.getSource())) {
|
||||
targetList = new ArrayList<String>();
|
||||
}
|
||||
@@ -1509,10 +1509,13 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
|
||||
|
||||
targetConnectionMap.put(type.getSource(), targetList);
|
||||
|
||||
if (!sourceConnectionMap.containsKey(type.getTarget())) {
|
||||
sourceList = new ArrayList<String>();
|
||||
sourceList = new ArrayList<String>();
|
||||
if (sourceConnectionMap.containsKey(type.getTarget())) {
|
||||
sourceList = sourceConnectionMap.get(type.getTarget());
|
||||
}
|
||||
if (!sourceList.contains(type.getSource())) {
|
||||
sourceList.add(type.getSource());
|
||||
}
|
||||
sourceList.add(type.getSource());
|
||||
sourceConnectionMap.put(type.getTarget(), sourceList);
|
||||
}
|
||||
|
||||
@@ -1556,15 +1559,15 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
|
||||
* @return
|
||||
*/
|
||||
private String getFullProductName() {
|
||||
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(
|
||||
IBrandingService.class);
|
||||
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault()
|
||||
.getService(IBrandingService.class);
|
||||
|
||||
return brandingService.getFullProductName();
|
||||
}
|
||||
|
||||
private String getProductVersionName() {
|
||||
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(
|
||||
IBrandingService.class);
|
||||
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault()
|
||||
.getService(IBrandingService.class);
|
||||
|
||||
return brandingService.getShortProductName() + IHTMLDocConstants.VERSION;
|
||||
}
|
||||
@@ -1597,8 +1600,8 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
|
||||
}
|
||||
// if (result == null) {
|
||||
result = new ByteArrayOutputStream(3072);
|
||||
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(
|
||||
IBrandingService.class);
|
||||
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault()
|
||||
.getService(IBrandingService.class);
|
||||
ImageData imageData = brandingService.getLoginHImage().getImageData();
|
||||
new ByteArrayOutputStream();
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -55,15 +56,5 @@
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
<dependencySets>
|
||||
<!-- for all jobs -->
|
||||
<dependencySet>
|
||||
<includes>
|
||||
<!--@JobIncludes@-->
|
||||
</includes>
|
||||
<outputFileNameMapping>${artifact.build.finalName}.${artifact.extension}</outputFileNameMapping>
|
||||
<useProjectArtifact>true</useProjectArtifact>
|
||||
<unpack>true</unpack>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
<dependencySets></dependencySets>
|
||||
</assembly>
|
||||
|
||||
@@ -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>
|
||||
@@ -51,6 +52,14 @@
|
||||
<include>${talend.job.path}/**</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
|
||||
<fileSet><!-- add context resources -->
|
||||
<directory>${current.int-resources.dir}</directory>
|
||||
<outputDirectory>${file.separator}</outputDirectory>
|
||||
<includes>
|
||||
<include>${talend.job.path}/**</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
|
||||
<fileSet> <!-- add provided-lib -->
|
||||
<directory>${current.bundle.resources.dir}/provided-lib</directory>
|
||||
|
||||
@@ -209,32 +209,5 @@
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
<dependencySets>
|
||||
<dependencySet>
|
||||
<outputDirectory>lib</outputDirectory>
|
||||
<includes>
|
||||
<!--@TalendLibIncludes@-->
|
||||
</includes>
|
||||
<!-- without version for talend libraries -->
|
||||
<outputFileNameMapping>${artifact.artifactId}.${artifact.extension}
|
||||
</outputFileNameMapping>
|
||||
<useProjectArtifact>false</useProjectArtifact>
|
||||
</dependencySet>
|
||||
<dependencySet>
|
||||
<outputDirectory>lib</outputDirectory>
|
||||
<includes>
|
||||
<!--@3rdPartyLibIncludes@-->
|
||||
</includes>
|
||||
<useProjectArtifact>false</useProjectArtifact>
|
||||
</dependencySet>
|
||||
<!-- for all jobs -->
|
||||
<dependencySet>
|
||||
<outputDirectory>${talend.job.name}</outputDirectory>
|
||||
<includes>
|
||||
<!--@JobIncludes@-->
|
||||
</includes>
|
||||
<outputFileNameMapping>${artifact.build.finalName}.${artifact.extension}</outputFileNameMapping>
|
||||
<useProjectArtifact>true</useProjectArtifact>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
<dependencySets></dependencySets>
|
||||
</assembly>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -44,6 +44,7 @@ import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
import org.talend.core.CorePlugin;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.IESBService;
|
||||
@@ -712,7 +713,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
|
||||
@@ -720,6 +733,11 @@ public class DefaultRunProcessService implements IRunProcessService {
|
||||
return TalendJavaProjectManager.getTalendJobJavaProject(property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFolder getCodeSrcFolder(ERepositoryObjectType type, String projectTechName) {
|
||||
return new AggregatorPomsHelper(projectTechName).getCodeSrcFolder(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITalendProcessJavaProject getTempJavaProject() {
|
||||
return TalendJavaProjectManager.getTempJavaProject();
|
||||
@@ -742,6 +760,10 @@ public class DefaultRunProcessService implements IRunProcessService {
|
||||
return ProcessorUtilities.isExportConfig();
|
||||
}
|
||||
|
||||
public boolean isdebug() {
|
||||
return ProcessorUtilities.isdebug();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildCodesJavaProject(IProgressMonitor monitor) {
|
||||
try {
|
||||
@@ -782,7 +804,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);
|
||||
@@ -809,13 +831,16 @@ 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) {
|
||||
@@ -824,6 +849,30 @@ 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();
|
||||
for (ERepositoryObjectType codeType : ERepositoryObjectType.getAllTypesOfCodes()) {
|
||||
// use getAllTypesOfCodes to avoid NPE
|
||||
// the ERepositoryObjectType may not load on current license
|
||||
deleteRefProject(codeType, refHelper, monitor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -867,7 +916,7 @@ public class DefaultRunProcessService implements IRunProcessService {
|
||||
IPath refPath = codeFile.getProjectRelativePath();
|
||||
IFolder targetFolder = mainProject.getFolder(refPath.removeLastSegments(1));
|
||||
if (!targetFolder.exists()) {
|
||||
targetFolder.create(true, false, progressMonitor);
|
||||
ResourceUtils.createFolder(targetFolder);
|
||||
}
|
||||
FilesUtils.copyDirectory(new File(codeFile.getLocation().toPortableString()),
|
||||
new File(targetFolder.getLocation().toPortableString()));
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user