Compare commits

..

1 Commits

Author SHA1 Message Date
sponomarova
1f80c9ee0a patch(TPS-3225): removed too small total timeout for service account 2019-07-17 10:34:17 +03:00
58 changed files with 616 additions and 1915 deletions

View File

@@ -1,57 +0,0 @@
---
version: 7.1.1
module: https://talend.poolparty.biz/coretaxonomy/42
product:
- https://talend.poolparty.biz/coretaxonomy/23
---
# TPS-4052
| Info | Value |
| ---------------- | ---------------- |
| Patch Name | Patch\_20200528\_TPS-4052\_v1-7.1.1 |
| Release Date | 2020-05-28 |
| Target Version | 20181026_1147-V7.1.1 |
| Product affected | Talend Studio |
## Introduction
This is a self-contained patch.
**NOTE**: For information on how to obtain this patch, reach out to your Support contact at Talend.
## Fixed issues
This patch contains the following fixes:
- TPS-4052 [7.1.1] S3/SQS Components Inherit Role Issue in AWS Fargate (TDI-43410, TDI-43409, TDI-42687)
## Prerequisites
Consider the following requirements for your system:
- Talend Studio 7.1.1 must be installed.
## Installation
### Installing the patch using Software update
1) Logon TAC and switch to Configuration->Software Update, then enter the correct values and save referring to the documentation: https://help.talend.com/reader/f7Em9WV_cPm2RRywucSN0Q/j9x5iXV~vyxMlUafnDejaQ
2) Switch to Software update page, where the new patch will be listed. The patch can be downloaded from here into the nexus repository.
3) On Studio Side: Logon Studio with remote mode, on the logon page the Update button is displayed: click this button to install the patch.
### Installing the patch using Talend Studio
1) Create a folder named "patches" under your studio installer directory and copy the patch .zip file to this folder.
2) Restart your studio: a window pops up, then click OK to install the patch, or restart the commandline and the patch will be installed automatically.
### Installing the patch using Commandline
Execute the following commands:
1. Talend-Studio-win-x86_64.exe -nosplash -application org.talend.commandline.CommandLine -consoleLog -data commandline-workspace startServer -p 8002 --talendDebug
2. initRemote {tac_url} -ul {TAC login username} -up {TAC login password}
3. checkAndUpdate -tu {TAC login username} -tup {TAC login password}

View File

@@ -69,140 +69,145 @@ if(hasInput){
}
}
}
boolean hasValidInput = inputConn!=null;
if (hasValidInput) {
IMetadataTable metadata = null;
List<IMetadataTable> metadatas = node.getMetadataList();
boolean haveValidNodeMetadata = ((metadatas != null) && (metadatas.size() > 0) && (metadata = metadatas.get(0)) != null);
if (hasValidInput && haveValidNodeMetadata) {
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 (input_columnList!=null && !input_columnList.isEmpty()) {
// add incoming (not present) columns to enforcer for this comps
if (cid.contains("tDataStewardship") || cid.contains("tMarkLogic")){
%>
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;
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));
if (shouldCreateRuntimeSchemaForIncomingNode){
incomingEnforcer_<%=cid%>.createRuntimeSchema();
}
<%
}
} // column
// 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.
// 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.
int dynamicPos = -1;
for (int i = 0; i < input_columnList.size(); i++) {
if (input_columnList.get(i).getTalendType().equals("id_Dynamic")) {
dynamicPos = i;
break;
}
}
// 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);
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);
}
}
}
} // 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){
} // property
} // propInfo
%>
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%>);
}
}
<%
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%>);
}
}
<%
}
}
}
} // canStart

View File

@@ -258,80 +258,76 @@
com.google.api.services.bigquery.model.JobConfiguration config_<%=cid%> = new com.google.api.services.bigquery.model.JobConfiguration();
com.google.api.services.bigquery.model.JobConfigurationLoad queryLoad_<%=cid%> = new com.google.api.services.bigquery.model.JobConfigurationLoad();
if (<%=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%>\"}");
<%
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__"))) {
%>
@@ -538,7 +534,6 @@
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%>);
}
<%
@@ -574,16 +569,15 @@
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%>.setFormatOptions(csvOptions_<%=cid%>.setFieldDelimiter(<%=fieldDelimiter%>).build());
<%
}
%>
loadJobBuilder_<%=cid%>.setNullMarker("\\N");
loadJobBuilder_<%=cid%>.setFormatOptions(csvOptions_<%=cid%>.build());
loadJobBuilder_<%=cid%>.setNullMarker("\\N");
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) {
@@ -604,4 +598,4 @@
} else {
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\" or \"OAUTH\", but it is " + authMode);
}
%>
%>

View File

@@ -62,12 +62,11 @@ 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(location);
createDataset(getLocation(queryConfig));
queryConfig.setAllowLargeResults(true);
queryConfig.setDestinationTable(new com.google.api.services.bigquery.model.TableReference()
.setProjectId(projectId)
@@ -132,7 +131,7 @@ class BigQueryUtil_<%=cid%> {
%>
// wait for query execution
while (true) {
com.google.api.services.bigquery.model.Job pollJob = bigqueryclient.jobs().get(projectId, jobId.getJobId()).setLocation(location).execute();
com.google.api.services.bigquery.model.Job pollJob = bigqueryclient.jobs().get(projectId, jobId.getJobId()).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();

View File

@@ -43,8 +43,10 @@
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(javaType == JavaTypesManager.BOOLEAN ){
%>
if(<%=conn.getName() %>.<%=column.getLabel() %> != null) {
<%
if(javaType == JavaTypesManager.BOOLEAN ){
%>
row_<%=cid%>[<%=i%>] = String.valueOf(
true == <%=conn.getName() %>.<%=column.getLabel() %> ?"1":"0"
@@ -54,8 +56,12 @@
%>
row_<%=cid%>[<%=i%>] = String.valueOf(<%=conn.getName() %>.<%=column.getLabel() %>);
<%
}
}
%>
} else {
row_<%=cid%>[<%=i%>] = null;
}
<%
}else {
%>
if(<%=conn.getName() %>.<%=column.getLabel() %> != null){
@@ -64,24 +70,10 @@
%>
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");
<%
}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%>);
<%
}
%>
row_<%=cid%>[<%=i%>] = FormatterUtils.format_Date(<%=conn.getName() %>.<%=column.getLabel() %>, "yyyy-MM-dd HH:mm:ss");
<%
}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();
@@ -100,7 +92,7 @@
}
%>
} else {
row_<%=cid%>[<%=i%>] = "\\N";
row_<%=cid%>[<%=i%>] = null;
}
<%
}

View File

@@ -54,7 +54,7 @@
<%
} else {
%>
com.amazonaws.auth.AWSCredentialsProvider credentialsProvider_<%=cid%> = new com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper();
com.amazonaws.auth.AWSCredentialsProvider credentialsProvider_<%=cid%> = new com.amazonaws.auth.InstanceProfileCredentialsProvider();
<%
}
%>

View File

@@ -106,12 +106,7 @@
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>
@@ -178,8 +173,6 @@
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"

View File

@@ -43,5 +43,4 @@ 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)

View File

@@ -45,7 +45,6 @@ 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 =
@@ -201,18 +200,6 @@ 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>");
@@ -248,25 +235,16 @@ class NestXMLTool_<%=cid%>{
for (org.dom4j.Element tmp: (java.util.List<org.dom4j.Element>) root.elements()) {
removeEmptyElement(tmp);
}
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 (root.content().size() == 0
&& root.attributes().size() == 0
&& root.declaredNamespaces().size() == 0) {
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();

View File

@@ -99,11 +99,6 @@
<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>

View File

@@ -44,6 +44,5 @@ 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

View File

@@ -30,7 +30,7 @@
<%
if(inheritCredentials) {
%>
credentialsProvider_<%=cid%> = new com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper();
credentialsProvider_<%=cid%> = new com.amazonaws.auth.InstanceProfileCredentialsProvider();
<%} else {%>
com.amazonaws.auth.AWSCredentials credentials_<%=cid%> = new com.amazonaws.auth.BasicAWSCredentials(<%=accesskey%>,decryptedPassword_<%=cid%>);

View File

@@ -35,7 +35,6 @@ imports="
%>
String driverClass_<%=cid%> = "<%=this.getDirverClassName(node)%>";
java.lang.Class.forName(driverClass_<%=cid%>);
globalMap.put("driverClass_<%=cid%>", driverClass_<%=cid%>);
<%
}

View File

@@ -165,12 +165,6 @@ 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();
}

View File

@@ -759,15 +759,6 @@
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">

View File

@@ -272,7 +272,6 @@ 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
@@ -734,7 +733,6 @@ 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.

View File

@@ -226,9 +226,6 @@ 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$

View File

@@ -2248,9 +2248,6 @@ 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);
@@ -2286,11 +2283,9 @@ 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();

View File

@@ -23,7 +23,6 @@ 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;
@@ -32,7 +31,6 @@ 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;
@@ -145,7 +143,7 @@ public abstract class AbstractProcessProvider implements IReplaceNodeInProcess {
}
}
}
/**
* DOC qzhang Comment method "canDeleteNode".
*
@@ -259,10 +257,5 @@ 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;
}
}

View File

@@ -808,9 +808,6 @@ public class ConnectionManager {
if (list.contains(newTarget)) {
return true;
}
if (source.equals(newTarget)) {
return true;
}
return false;
}

View File

@@ -256,9 +256,6 @@ 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");

View File

@@ -96,12 +96,6 @@ 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;
@@ -390,51 +384,6 @@ 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;
}
@@ -1003,25 +952,6 @@ 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());

View File

@@ -634,7 +634,6 @@ 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();

View File

@@ -122,7 +122,6 @@ import org.talend.core.model.update.IUpdateManager;
import org.talend.core.model.utils.TalendTextUtils;
import org.talend.core.repository.model.ProxyRepositoryFactory;
import org.talend.core.repository.utils.ConvertJobsUtil;
import org.talend.core.repository.utils.ProjectHelper;
import org.talend.core.repository.utils.XmiResourceManager;
import org.talend.core.runtime.repository.item.ItemProductKeys;
import org.talend.core.runtime.util.ItemDateParser;
@@ -1915,25 +1914,12 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
}
}
//
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);
}
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) {
@@ -2791,14 +2777,9 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
continue;
}
}
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())));
}
EConnectionType type = EConnectionType.getTypeFromId(lineStyleId);
connec = new Connection(source, target, type, source.getConnectorFromType(type).getName(), metaname,
cType.getLabel(), cType.getMetaname(), monitorConnection);
}
if (connec == null) {
continue;
@@ -4552,9 +4533,6 @@ 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) {

View File

@@ -115,7 +115,6 @@ 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;
@@ -126,7 +125,6 @@ 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;
@@ -309,10 +307,6 @@ 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>();

View File

@@ -1113,13 +1113,9 @@ public abstract class AbstractSchemaController extends AbstractRepositoryControl
for (IMetadataColumn column : metadataTable.getListColumns()) {
columnNames.add(column.getLabel());
}
if(metadataTable.getOriginalColumns() == null || metadataTable.getOriginalColumns().isEmpty()){
metadataTable.setOriginalColumns(columnNames);
}
}
if(tableCopy.getOriginalColumns() == null || tableCopy.getOriginalColumns().isEmpty()){
tableCopy.setOriginalColumns(metadataTable.getOriginalColumns());
metadataTable.setOriginalColumns(columnNames);
}
tableCopy.setOriginalColumns(metadataTable.getOriginalColumns());
}
}

View File

@@ -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()) {

View File

@@ -64,9 +64,6 @@ 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()));
@@ -103,9 +100,6 @@ 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()));

View File

@@ -67,8 +67,6 @@ 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$

View File

@@ -85,12 +85,6 @@ 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);
@@ -454,51 +448,6 @@ 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) {

View File

@@ -587,7 +587,6 @@ 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,
@@ -780,9 +779,6 @@ public class MainComposite extends AbstractTabComposite {
public void run(final IProgressMonitor monitor) throws CoreException {
try {
if (repositoryObject.getProperty() != null) {
if (!originalversion.equals(StringUtils.trimToEmpty(oldVersion))) {
RelationshipItemBuilder.getInstance().addOrUpdateItem(repositoryObject.getProperty().getItem());
}
proxyRepositoryFactory.save(ProjectManager.getInstance().getCurrentProject(),
repositoryObject.getProperty().getItem(), false);
if (needjobletRelateUpdate && GlobalServiceRegister.getDefault()

View File

@@ -1,120 +0,0 @@
// ============================================================================
//
// 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();
}
}

View File

@@ -677,11 +677,7 @@ public abstract class DbGenerationManager {
query = query + " \""; //$NON-NLS-1$
} else {
if (query.trim().endsWith("+ \"")) { //$NON-NLS-1$
if (DEFAULT_TAB_SPACE_STRING.equals(this.tabSpaceString)) {
query = query.substring(0, query.lastIndexOf("+ \"")); //$NON-NLS-1$
} else {
query = query + "\"";
}
query = query.substring(0, query.lastIndexOf("+ \"")); //$NON-NLS-1$
}
}
}
@@ -1177,11 +1173,7 @@ public abstract class DbGenerationManager {
}
}
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$
}
result.append(expression.substring(indexs.get(i), indexs.get(i+1)+1));
start = indexs.get(i+1)+1;
}else if(i == indexs.size() - 1){
String exp = expression.substring(indexs.get(i)+1, expression.length());

View File

@@ -45,7 +45,6 @@ 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;
@@ -231,20 +230,6 @@ 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);

View File

@@ -507,8 +507,6 @@ 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);

View File

@@ -48,9 +48,6 @@ 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/>
@@ -161,20 +158,8 @@ 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() {
@@ -212,20 +197,8 @@ 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;
}

View File

@@ -14,7 +14,6 @@
<outputDirectory>${file.separator}</outputDirectory>
<includes>
<include>${talend.job.path}/**/*.class</include>
<include>${talend.job.path}/**/*.wsdl</include>
<include>__tdm/**</include>
</includes>
</fileSet>

View File

@@ -16,7 +16,6 @@
<outputDirectory>${file.separator}</outputDirectory>
<includes>
<include>${talend.job.path}/**/*.class</include>
<include>${talend.job.path}/**/*.wsdl</include>
<include>__tdm/**</include>
</includes>
</fileSet>

View File

@@ -798,7 +798,7 @@ public class DefaultRunProcessService implements IRunProcessService {
for (ProjectReference ref : references) {
initRefPoms(new Project(ref.getReferencedProject()));
}
helper.updateRefProjectModules(references, monitor);
helper.updateRefProjectModules(references);
helper.updateCodeProjects(monitor, true);
} catch (Exception e) {
ExceptionHandler.process(e);
@@ -825,17 +825,13 @@ 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) {
@@ -844,35 +840,6 @@ public class DefaultRunProcessService implements IRunProcessService {
argumentsMap.put(TalendProcessArgumentConstant.ARG_GOAL, TalendMavenConstants.GOAL_INSTALL);
argumentsMap.put(TalendProcessArgumentConstant.ARG_PROGRAM_ARGUMENTS, TalendMavenConstants.ARG_MAIN_SKIP);
codeProject.buildModules(monitor, null, argumentsMap);
}
}
private void deleteRefProjects(Project refProject, AggregatorPomsHelper refHelper) throws Exception {
IProgressMonitor monitor = new NullProgressMonitor();
deleteRefProject(ERepositoryObjectType.ROUTINES, refHelper, monitor);
if (ProcessUtils.isRequiredPigUDFs(null, refProject)) {
deleteRefProject(ERepositoryObjectType.PIG_UDF, refHelper, monitor);
}
if (ProcessUtils.isRequiredBeans(null, refProject)) {
deleteRefProject(ERepositoryObjectType.valueOf("BEANS"), refHelper, monitor); //$NON-NLS-1$
}
}
private void deleteRefProject(ERepositoryObjectType codeType, AggregatorPomsHelper refHelper, IProgressMonitor monitor)
throws Exception, CoreException {
if (!refHelper.getProjectRootPom().exists()) {
return;
}
String projectTechName = refHelper.getProjectTechName();
ITalendProcessJavaProject codeProject = TalendJavaProjectManager.getExistingTalendCodeProject(codeType, projectTechName);
if (codeProject != null) {
codeProject.getProject().delete(false, true, monitor);
TalendJavaProjectManager.removeFromCodeJavaProjects(codeType, projectTechName);
}

View File

@@ -15,7 +15,6 @@ package org.talend.designer.runprocess;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -32,6 +31,7 @@ import org.talend.commons.exception.CommonExceptionHandler;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.exception.PersistenceException;
import org.talend.commons.exception.SystemException;
import org.talend.commons.ui.runtime.exception.MessageBoxExceptionHandler;
import org.talend.core.CorePlugin;
import org.talend.core.model.process.IContainerEntry;
import org.talend.core.model.process.IProcess;
@@ -61,17 +61,15 @@ public class JobErrorsChecker {
public static List<IContainerEntry> getErrors() {
List<IContainerEntry> input = new ArrayList<IContainerEntry>();
if(LastGenerationInfo.getInstance() == null ||
LastGenerationInfo.getInstance().getLastMainJob() == null) {
return input;
}
try {
Item item = null;
IProxyRepositoryFactory proxyRepositoryFactory =
CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
ITalendSynchronizer synchronizer =
CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
IProxyRepositoryFactory proxyRepositoryFactory = CorePlugin.getDefault().getRepositoryService()
.getProxyRepositoryFactory();
ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
Set<String> jobIds = new HashSet<String>();
HashSet<JobInfo> jobInfos = new HashSet<>();
@@ -96,15 +94,14 @@ public class JobErrorsChecker {
}
jobIds.add(item.getProperty().getId());
// Property property = process.getProperty();
Problems.addJobRoutineFile(sourceFile, ProblemType.JOB, item, true);
}
if (!CommonsPlugin.isHeadless()) {
List<IRepositoryViewObject> routinesObjects =
proxyRepositoryFactory.getAll(ERepositoryObjectType.ROUTINES, false);
Set<String> dependentRoutines = LastGenerationInfo
.getInstance()
.getRoutinesNeededWithSubjobPerJob(LastGenerationInfo.getInstance().getLastMainJob().getJobId(),
LastGenerationInfo.getInstance().getLastMainJob().getJobVersion());
List<IRepositoryViewObject> routinesObjects = proxyRepositoryFactory.getAll(ERepositoryObjectType.ROUTINES, false);
Set<String> dependentRoutines = LastGenerationInfo.getInstance().getRoutinesNeededWithSubjobPerJob(
LastGenerationInfo.getInstance().getLastMainJob().getJobId(),
LastGenerationInfo.getInstance().getLastMainJob().getJobVersion());
if (routinesObjects != null) {
for (IRepositoryViewObject obj : routinesObjects) {
Property property = obj.getProperty();
@@ -113,7 +110,7 @@ public class JobErrorsChecker {
IFile routineFile = synchronizer.getFile(routinesitem);
Problems.addJobRoutineFile(routineFile, ProblemType.ROUTINE, routinesitem, true);
} else {
Problems.clearAllComliationError(property.getLabel());
Problems.clearAllComliationError(property.getLabel());
}
}
}
@@ -156,11 +153,11 @@ public class JobErrorsChecker {
public static boolean checkExportErrors(IStructuredSelection selection, boolean isJob) {
if (!selection.isEmpty()) {
final ITalendSynchronizer synchronizer =
CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService()
.createRoutineSynchronizer();
Set<String> jobIds = new HashSet<String>();
List<RepositoryNode> nodes = extractNodes(selection);
List<RepositoryNode> nodes = selection.toList();
if (nodes.size() > 1) {
// in case it's a multiple export, only check the status of the latest job to export
for (RepositoryNode node : nodes) {
@@ -192,35 +189,22 @@ public class JobErrorsChecker {
}
if (ret) {
if (isJob) {
throw new ProcessorException(
Messages.getString("JobErrorsChecker_compile_errors") + '\n' + //$NON-NLS-1$
Messages
.getString("JobErrorsChecker_compile_error_content", //$NON-NLS-1$
item.getProperty().getLabel())
+ '\n' + message);
throw new ProcessorException(Messages.getString("JobErrorsChecker_compile_errors") + '\n' + //$NON-NLS-1$
Messages.getString("JobErrorsChecker_compile_error_content", item.getProperty() //$NON-NLS-1$
.getLabel()) + '\n' + message);
} else {
throw new ProcessorException(
Messages.getString("CamelJobErrorsChecker_compile_errors") + '\n' + //$NON-NLS-1$
Messages
.getString("CamelJobErrorsChecker_compile_error_content", //$NON-NLS-1$
item.getProperty().getLabel())
+ '\n' + message);
throw new ProcessorException(Messages.getString("CamelJobErrorsChecker_compile_errors") + '\n' + //$NON-NLS-1$
Messages.getString("CamelJobErrorsChecker_compile_error_content", item.getProperty() //$NON-NLS-1$
.getLabel()) + '\n' + message);
}
}
jobIds.add(item.getProperty().getId());
Problems
.addRoutineFile(sourceFile, ProblemType.JOB, item.getProperty().getLabel(),
item.getProperty().getVersion(), true);
Problems.addRoutineFile(sourceFile, ProblemType.JOB, item.getProperty().getLabel(), item.getProperty()
.getVersion(), true);
} catch (Exception e) {
CommonExceptionHandler.process(e);
if (CommonsPlugin.isHeadless()) {
// [TESB-8953] avoid SWT invoked and also throw Exception let Command Executor to have
// detailed
// trace in command status.
throw new RuntimeException(e);
}
MessageBoxExceptionHandler.process(e);
return true;
}
@@ -230,12 +214,13 @@ public class JobErrorsChecker {
try {
checkLastGenerationHasCompilationError(true);
} catch (Exception e) {
CommonExceptionHandler.process(e);
if (CommonsPlugin.isHeadless()) {
CommonExceptionHandler.process(e);
// [TESB-8953] avoid SWT invoked and also throw Exception let Command Executor to have detailed
// trace in command status.
throw new RuntimeException(e);
}
MessageBoxExceptionHandler.process(e);
return true;
}
}
@@ -264,12 +249,7 @@ public class JobErrorsChecker {
}
}
} catch (Exception e) {
CommonExceptionHandler.process(e);
if (CommonsPlugin.isHeadless()) {
// [TESB-8953] avoid SWT invoked and also throw Exception let Command Executor to have detailed
// trace in command status.
throw new RuntimeException(e);
}
MessageBoxExceptionHandler.process(e);
return true;
}
@@ -284,10 +264,9 @@ public class JobErrorsChecker {
boolean hasError = false;
boolean isJob = true;
Item item = null;
final IProxyRepositoryFactory proxyRepositoryFactory =
CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
final ITalendSynchronizer synchronizer =
CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
final IProxyRepositoryFactory proxyRepositoryFactory = CorePlugin.getDefault().getRepositoryService()
.getProxyRepositoryFactory();
final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
Integer line = null;
String errorMessage = null;
try {
@@ -320,7 +299,7 @@ public class JobErrorsChecker {
// one job
final IResource[] members = file.getParent().members();
for (IResource member : members) {
if (member instanceof IFile && "java".equals(member.getFileExtension())) { //$NON-NLS-1$
if (member instanceof IFile && "java".equals(member.getFileExtension())) {
IMarker[] markers = ((IFile) member).findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ONE);
for (IMarker marker : markers) {
Integer lineNr = (Integer) marker.getAttribute(IMarker.LINE_NUMBER);
@@ -343,9 +322,8 @@ public class JobErrorsChecker {
}
}
if (updateProblemsView) {
Problems
.addRoutineFile(file, ProblemType.JOB, item.getProperty().getLabel(),
item.getProperty().getVersion(), true);
Problems.addRoutineFile(file, ProblemType.JOB, item.getProperty().getLabel(),
item.getProperty().getVersion(), true);
}
if (hasError) {
break;
@@ -357,17 +335,17 @@ public class JobErrorsChecker {
}
if (hasError && item != null) {
if (isJob) {
throw new ProcessorException(Messages.getString("JobErrorsChecker_compile_errors") + ' ' + '\n' + //$NON-NLS-1$
Messages.getString("JobErrorsChecker_compile_error_message", item.getProperty().getLabel()) //$NON-NLS-1$
+ '\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + '\n' //$NON-NLS-1$
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage //$NON-NLS-1$
+ '\n' + Messages.getString("JobErrorsChecker_compile_error_jvmmessage")); //$NON-NLS-1$
throw new ProcessorException(Messages.getString("JobErrorsChecker_compile_errors") + " " + '\n' + //$NON-NLS-1$
Messages.getString("JobErrorsChecker_compile_error_message", item.getProperty().getLabel()) + '\n' //$NON-NLS-1$
+ Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + '\n' //$NON-NLS-1$
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage + '\n' //$NON-NLS-1$
+ Messages.getString("JobErrorsChecker_compile_error_jvmmessage")); //$NON-NLS-1$
} else {
throw new ProcessorException(Messages.getString("CamelJobErrorsChecker_compile_errors") + ' ' + '\n' + //$NON-NLS-1$
Messages.getString("JobErrorsChecker_compile_error_message", item.getProperty().getLabel()) //$NON-NLS-1$
+ '\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + '\n' //$NON-NLS-1$
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage //$NON-NLS-1$
+ '\n' + Messages.getString("JobErrorsChecker_compile_error_jvmmessage")); //$NON-NLS-1$
throw new ProcessorException(Messages.getString("CamelJobErrorsChecker_compile_errors") + " " + '\n' + //$NON-NLS-1$
Messages.getString("JobErrorsChecker_compile_error_message", item.getProperty().getLabel()) + '\n' //$NON-NLS-1$
+ Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + '\n' //$NON-NLS-1$
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage + '\n' //$NON-NLS-1$
+ Messages.getString("JobErrorsChecker_compile_error_jvmmessage")); //$NON-NLS-1$
}
}
@@ -378,7 +356,6 @@ public class JobErrorsChecker {
}
private static void checkRoutinesCompilationError() throws ProcessorException {
if(LastGenerationInfo.getInstance() == null || LastGenerationInfo.getInstance().getLastMainJob() == null) {
return;
}
@@ -391,35 +368,32 @@ public class JobErrorsChecker {
for (Problem p : errors) {
if (p instanceof TalendProblem) {
TalendProblem talendProblem = (TalendProblem) p;
if (talendProblem.getType() == ProblemType.ROUTINE
&& dependentRoutines.contains(talendProblem.getJavaUnitName())) {
if (talendProblem.getType() == ProblemType.ROUTINE && dependentRoutines.contains(talendProblem.getJavaUnitName())) {
int line = talendProblem.getLineNumber();
String errorMessage = talendProblem.getDescription();
throw new ProcessorException(Messages
.getString("JobErrorsChecker_routines_compile_errors", talendProblem.getJavaUnitName()) //$NON-NLS-1$
+ '\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + '\n' //$NON-NLS-1$
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' //$NON-NLS-1$
+ errorMessage);
throw new ProcessorException(Messages.getString(
"JobErrorsChecker_routines_compile_errors", talendProblem.getJavaUnitName()) + '\n'//$NON-NLS-1$
+ Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + '\n' //$NON-NLS-1$
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage); //$NON-NLS-1$
}
} else {
// for now not to check components errors when building jobs in studio/commandline
// throw new ProcessorException(Messages.getString("JobErrorsChecker_jobDesign_errors",
// p.getType().getTypeName(), //$NON-NLS-1$
// p.getJobInfo().getJobName(), p.getComponentName(), p.getDescription()));
// throw new ProcessorException(Messages.getString("JobErrorsChecker_jobDesign_errors", p.getType().getTypeName(), //$NON-NLS-1$
// p.getJobInfo().getJobName(), p.getComponentName(), p.getDescription()));
}
}
// if can't find the routines problem, try to check the file directly(mainly for commandline)
try {
final ITalendSynchronizer synchronizer =
CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService()
.createRoutineSynchronizer();
IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
List<IRepositoryViewObject> routinesObjects = factory.getAll(ERepositoryObjectType.ROUTINES, false);
if (routinesObjects != null) {
for (IRepositoryViewObject obj : routinesObjects) {
Property property = obj.getProperty();
if (!dependentRoutines.contains(property.getLabel())) {
continue;
continue;
}
Item routinesitem = property.getItem();
IFile routinesFile = synchronizer.getFile(routinesitem);
@@ -433,12 +407,10 @@ public class JobErrorsChecker {
if (lineNr != null && message != null && severity != null && start != null && end != null) {
switch (severity) {
case IMarker.SEVERITY_ERROR:
throw new ProcessorException(Messages
.getString("JobErrorsChecker_routines_compile_errors", property.getLabel()) //$NON-NLS-1$
+ '\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' //$NON-NLS-1$
+ lineNr + '\n'
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") //$NON-NLS-1$
+ ':' + ' ' + message);
throw new ProcessorException(
Messages.getString("JobErrorsChecker_routines_compile_errors", property.getLabel()) + '\n'//$NON-NLS-1$
+ Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + lineNr + '\n' //$NON-NLS-1$
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + message); //$NON-NLS-1$
default:
break;
}
@@ -455,11 +427,11 @@ public class JobErrorsChecker {
}
}
protected static void checkSubJobMultipleVersionsError() throws ProcessorException {
if (LastGenerationInfo.getInstance() == null
|| LastGenerationInfo.getInstance().getLastGeneratedjobs() == null) {
return;
}
if(LastGenerationInfo.getInstance() == null || LastGenerationInfo.getInstance().getLastGeneratedjobs() == null) {
return;
}
Set<JobInfo> jobInfos = LastGenerationInfo.getInstance().getLastGeneratedjobs();
Map<String, Set<String>> jobInfoMap = new HashMap<>();
for (JobInfo jobInfo : jobInfos) {
@@ -486,14 +458,4 @@ public class JobErrorsChecker {
}
}
private static List<RepositoryNode> extractNodes(IStructuredSelection selection) {
List<RepositoryNode> nodes = new ArrayList<>();
for (Iterator<?> iterator = selection.iterator(); iterator.hasNext();) {
Object o = iterator.next();
if (o instanceof RepositoryNode)
nodes.add((RepositoryNode) o);
}
return nodes;
}
}

View File

@@ -568,8 +568,6 @@ public class TalendJavaProjectManager {
if (processor instanceof MavenJavaProcessor) {
LastGenerationInfo.getInstance().clearModulesNeededWithSubjobPerJob();
LastGenerationInfo.getInstance().getHighPriorityModuleNeeded().clear();
// Need to clear modules per job cache
LastGenerationInfo.getInstance().clearModulesNeededPerJob();
// Gen poms only
((MavenJavaProcessor) processor).generatePom(option);
}

View File

@@ -349,8 +349,7 @@ public class MavenJavaProcessor extends JavaProcessor {
if (!isMainJob && isGoalInstall) {
if (!buildCacheManager.isJobBuild(getProperty())) {
deleteExistedJobJarFile(talendJavaProject);
String buildType = getBuildType(getProperty());
if (("ROUTE".equalsIgnoreCase(buildType) || "OSGI".equalsIgnoreCase(buildType)) && project != null &&
if ("ROUTE".equalsIgnoreCase(getBuildType(getProperty())) && project != null &&
ERepositoryObjectType.PROCESS.equals(ERepositoryObjectType.getType(getProperty()))) {
// TESB-23870
// child routes job project must be compiled explicitly for

View File

@@ -125,8 +125,6 @@ public class ProcessChangeListener implements PropertyChangeListener {
// version change, will create new item
// create new job project.
TalendJavaProjectManager.generatePom(property.getItem());
AggregatorPomsHelper helper = new AggregatorPomsHelper();
helper.syncParentJobPomsForPropertyChange(property);
}
}
}

View File

@@ -28,7 +28,6 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.apache.log4j.Priority;
import org.apache.oro.text.regex.MalformedPatternException;
import org.apache.oro.text.regex.MatchResult;
import org.apache.oro.text.regex.Pattern;
@@ -55,9 +54,8 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.talend.commons.CommonsPlugin;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.exception.PersistenceException;
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
import org.talend.commons.ui.swt.formtools.Form;
import org.talend.commons.ui.swt.formtools.LabelledCombo;
import org.talend.commons.ui.swt.formtools.LabelledFileField;
@@ -81,7 +79,6 @@ import org.talend.repository.ProjectManager;
import org.talend.repository.json.i18n.Messages;
import org.talend.repository.json.util.JSONUtil;
import org.talend.repository.ui.wizards.metadata.connection.files.xml.TreePopulator;
import orgomg.cwm.resource.record.RecordFactory;
import orgomg.cwm.resource.record.RecordFile;
@@ -154,7 +151,7 @@ public class JSONFileOutputStep1Form extends AbstractJSONFileStepForm {
}
if (JSONFileOutputStep1Form.this.tempPath == null) {
if (jsonXmlPath != null && !jsonXmlPath.equals("")) {
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(jsonXmlPath, getConnection().getEncoding());
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(jsonXmlPath);
} else {
JSONFileOutputStep1Form.this.tempPath = "";
}
@@ -318,7 +315,7 @@ public class JSONFileOutputStep1Form extends AbstractJSONFileStepForm {
List<FOXTreeNode> rootFoxTreeNodes = null;
if (JSONFileOutputStep1Form.this.tempPath == null) {
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(text, getConnection().getEncoding());
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(text);
}
if (treeNode == null) {
rootFoxTreeNodes = TreeUtil.getFoxTreeNodes(JSONFileOutputStep1Form.this.tempPath);
@@ -365,12 +362,12 @@ public class JSONFileOutputStep1Form extends AbstractJSONFileStepForm {
}
// getConnection().setJSONFilePath(PathUtils.getPortablePath(JSONXsdFilePath.getText()));
if (JSONFileOutputStep1Form.this.tempPath == null) {
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(text, getConnection().getEncoding());
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(text);
}
File file = new File(text);
if (file.exists()) {
List<ATreeNode> treeNodes = new ArrayList<ATreeNode>();
valid = treePopulator.populateTree(JSONUtil.changeJsonToXml(text, getConnection().getEncoding()), treeNode);
valid = treePopulator.populateTree(JSONUtil.changeJsonToXml(text), treeNode);
checkFieldsValue();
if (!valid) {
return;
@@ -394,7 +391,130 @@ public class JSONFileOutputStep1Form extends AbstractJSONFileStepForm {
@Override
public void modifyText(ModifyEvent event) {
validateJsonFile();
String text = jsonFilePath.getText();
if (isContextMode()) {
ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(
connectionItem.getConnection(), true);
text = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType, text));
}
if (getConnection().getJSONFilePath() != null && !getConnection().getJSONFilePath().equals(text)) {
getConnection().getLoop().clear();
getConnection().getRoot().clear();
getConnection().getGroup().clear();
xsdPathChanged = true;
} else {
xsdPathChanged = false;
}
if (Path.fromOSString(jsonFilePath.getText()).toFile().isFile()) {
getConnection().setJSONFilePath(PathUtils.getPortablePath(jsonFilePath.getText()));
} else {
getConnection().setJSONFilePath(jsonFilePath.getText());
}
// updateConnection(text);
StringBuilder fileContent = new StringBuilder();
BufferedReader in = null;
File file = null;
if (tempJSONPath != null && getConnection().getFileContent() != null
&& getConnection().getFileContent().length > 0 && !isModifing) {
file = new File(tempJSONPath);
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e2) {
ExceptionHandler.process(e2);
}
FileOutputStream outStream;
try {
outStream = new FileOutputStream(file);
outStream.write(getConnection().getFileContent());
outStream.close();
} catch (FileNotFoundException e1) {
ExceptionHandler.process(e1);
} catch (IOException e) {
ExceptionHandler.process(e);
}
}
} else {
file = new File(text);
}
String str;
try {
Charset guessCharset = CharsetToolkit.guessEncoding(file, 4096);
in = new BufferedReader(new InputStreamReader(new FileInputStream(file), guessCharset.displayName()));
while ((str = in.readLine()) != null) {
fileContent.append(str + "\n");
// for encoding
if (str.contains("encoding")) {
String regex = "^<\\?JSON\\s*version=\\\"[^\\\"]*\\\"\\s*encoding=\\\"([^\\\"]*)\\\"\\?>$";
Perl5Compiler compiler = new Perl5Compiler();
Perl5Matcher matcher = new Perl5Matcher();
Pattern pattern = null;
try {
pattern = compiler.compile(regex);
if (matcher.contains(str, pattern)) {
MatchResult matchResult = matcher.getMatch();
if (matchResult != null) {
encoding = matchResult.group(1);
}
}
} catch (MalformedPatternException malE) {
ExceptionHandler.process(malE);
}
}
}
fileContentText.setText(new String(fileContent));
} catch (Exception e) {
String msgError = "File" + " \"" + jsonFilePath.getText().replace("\\\\", "\\") + "\"\n";
if (e instanceof FileNotFoundException) {
msgError = msgError + "is not found";
} else if (e instanceof EOFException) {
msgError = msgError + "have an incorrect character EOF";
} else if (e instanceof IOException) {
msgError = msgError + "is locked by another soft";
} else {
msgError = msgError + "doesn't exist";
}
fileContentText.setText(msgError);
if (!isReadOnly()) {
updateStatus(IStatus.ERROR, msgError);
}
} finally {
try {
if (in != null) {
in.close();
}
} catch (Exception exception) {
ExceptionHandler.process(exception);
}
}
if (getConnection().getEncoding() == null || "".equals(getConnection().getEncoding())) {
getConnection().setEncoding(encoding);
if (encoding != null && !"".equals(encoding)) {
encodingCombo.setText(encoding);
} else {
encodingCombo.setText("UTF-8");
}
}
// if (tempJSONXsdPath != null && getConnection().getFileContent() != null
// && getConnection().getFileContent().length > 0 && !isModifing) {
// valid = treePopulator.populateTree(tempJSONXsdPath, treeNode);
// } else {
// valid = treePopulator.populateTree(text, treeNode);
// }
if (file.exists()) {
valid = treePopulator.populateTree(JSONUtil.changeJsonToXml(text), treeNode);
updateConnection(text);
}
checkFieldsValue();
isModifing = true;
}
});
@@ -403,16 +523,6 @@ public class JSONFileOutputStep1Form extends AbstractJSONFileStepForm {
@Override
public void modifyText(ModifyEvent e) {
getConnection().setEncoding(encodingCombo.getText());
String encoding = getConnection().getEncoding();
try {
Charset charSet = Charset.forName(encoding);
if (charSet != null) {
validateJsonFile();
return;
}
} catch (Exception ex) {
// ignore
}
checkFieldsValue();
}
});
@@ -430,8 +540,7 @@ public class JSONFileOutputStep1Form extends AbstractJSONFileStepForm {
labelLimitation.setToolTipText(MessageFormat.format(Messages.JSONLimitToolTip, str));
}
if (JSONFileOutputStep1Form.this.tempPath == null) {
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(jsonFilePath.getText(),
getConnection().getEncoding());
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(jsonFilePath.getText());
}
File file = new File(JSONFileOutputStep1Form.this.tempPath);
@@ -670,141 +779,4 @@ public class JSONFileOutputStep1Form extends AbstractJSONFileStepForm {
// valid = this.treePopulator.populateTree(tempJSONXsdPath, treeNode);
}
private void validateJsonFile() {
String text = jsonFilePath.getText();
if (isContextMode()) {
ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(
connectionItem.getConnection(), true);
text = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType, text));
}
if (getConnection().getJSONFilePath() != null && !getConnection().getJSONFilePath().equals(text)) {
getConnection().getLoop().clear();
getConnection().getRoot().clear();
getConnection().getGroup().clear();
xsdPathChanged = true;
} else {
xsdPathChanged = false;
}
if (Path.fromOSString(jsonFilePath.getText()).toFile().isFile()) {
getConnection().setJSONFilePath(PathUtils.getPortablePath(jsonFilePath.getText()));
} else {
getConnection().setJSONFilePath(jsonFilePath.getText());
}
// updateConnection(text);
StringBuilder fileContent = new StringBuilder();
BufferedReader in = null;
File file = null;
if (tempJSONPath != null && getConnection().getFileContent() != null
&& getConnection().getFileContent().length > 0 && !isModifing) {
file = new File(tempJSONPath);
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e2) {
ExceptionHandler.process(e2);
}
FileOutputStream outStream;
try {
outStream = new FileOutputStream(file);
outStream.write(getConnection().getFileContent());
outStream.close();
} catch (FileNotFoundException e1) {
ExceptionHandler.process(e1);
} catch (IOException e) {
ExceptionHandler.process(e);
}
}
} else {
file = new File(text);
}
String str;
try {
Charset guessCharset = null;
try {
guessCharset = Charset.forName(getConnection().getEncoding());
} catch (Exception e) {
if (CommonsPlugin.isDebugMode()) {
ExceptionHandler.process(e, Priority.INFO);
}
}
if (guessCharset == null) {
guessCharset = CharsetToolkit.guessEncoding(file, 4096);
}
in = new BufferedReader(new InputStreamReader(new FileInputStream(file), guessCharset.displayName()));
while ((str = in.readLine()) != null) {
fileContent.append(str + "\n");
// for encoding
if (str.contains("encoding")) {
String regex = "^<\\?JSON\\s*version=\\\"[^\\\"]*\\\"\\s*encoding=\\\"([^\\\"]*)\\\"\\?>$";
Perl5Compiler compiler = new Perl5Compiler();
Perl5Matcher matcher = new Perl5Matcher();
Pattern pattern = null;
try {
pattern = compiler.compile(regex);
if (matcher.contains(str, pattern)) {
MatchResult matchResult = matcher.getMatch();
if (matchResult != null) {
encoding = matchResult.group(1);
}
}
} catch (MalformedPatternException malE) {
ExceptionHandler.process(malE);
}
}
}
fileContentText.setText(new String(fileContent));
} catch (Exception e) {
String msgError = "File" + " \"" + jsonFilePath.getText().replace("\\\\", "\\") + "\"\n";
if (e instanceof FileNotFoundException) {
msgError = msgError + "is not found";
} else if (e instanceof EOFException) {
msgError = msgError + "have an incorrect character EOF";
} else if (e instanceof IOException) {
msgError = msgError + "is locked by another soft";
} else {
msgError = msgError + "doesn't exist";
}
fileContentText.setText(msgError);
if (!isReadOnly()) {
updateStatus(IStatus.ERROR, msgError);
}
} finally {
try {
if (in != null) {
in.close();
}
} catch (Exception exception) {
ExceptionHandler.process(exception);
}
}
if (getConnection().getEncoding() == null || "".equals(getConnection().getEncoding())) {
getConnection().setEncoding(encoding);
if (encoding != null && !"".equals(encoding)) {
encodingCombo.setText(encoding);
} else {
encodingCombo.setText("UTF-8");
}
}
// if (tempJSONXsdPath != null && getConnection().getFileContent() != null
// && getConnection().getFileContent().length > 0 && !isModifing) {
// valid = treePopulator.populateTree(tempJSONXsdPath, treeNode);
// } else {
// valid = treePopulator.populateTree(text, treeNode);
// }
if (file.exists()) {
valid = treePopulator.populateTree(JSONUtil.changeJsonToXml(text, getConnection().getEncoding()), treeNode);
updateConnection(text);
}
checkFieldsValue();
isModifing = true;
}
}

View File

@@ -244,7 +244,7 @@ public class JSONFileStep1Form extends AbstractJSONFileStepForm {
if (JSONFileStep1Form.this.wizard.getTempJsonPath() == null
|| JSONFileStep1Form.this.wizard.getTempJsonPath().length() == 0) {
if (EJsonReadbyMode.XPATH.getValue().equals(JSONFileStep1Form.this.wizard.getReadbyMode())) {
tempxml = JSONUtil.changeJsonToXml(jsonFilePath, getConnection().getEncoding());
tempxml = JSONUtil.changeJsonToXml(jsonFilePath);
} else {
tempxml = jsonFilePath;
}
@@ -271,7 +271,6 @@ public class JSONFileStep1Form extends AbstractJSONFileStepForm {
treePopulator.setLimit(limit);
this.treePopulator.configureDefaultTreeViewer();
if (filePath != null && !filePath.isEmpty()) {
this.treePopulator.setEncoding(getConnection().getEncoding());
valid = this.treePopulator.populateTree(filePath, treeNode);
}
}
@@ -507,7 +506,7 @@ public class JSONFileStep1Form extends AbstractJSONFileStepForm {
if (EJsonReadbyMode.JSONPATH.getValue().equals(readbyMode)) {
tempxml = text;
} else {
tempxml = JSONUtil.changeJsonToXml(text, getConnection().getEncoding());
tempxml = JSONUtil.changeJsonToXml(text);
}
JSONFileStep1Form.this.wizard.setTempJsonPath(tempxml);
switchPopulator(readbyMode, tempxml);
@@ -519,7 +518,170 @@ public class JSONFileStep1Form extends AbstractJSONFileStepForm {
@Override
public void modifyText(final ModifyEvent e) {
validateJsonFile();
String jsonPath = fileFieldJSON.getText();
String _jsonPath = jsonPath;
if (isContextMode()) {
ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(
connectionItem.getConnection(), connectionItem.getConnection().getContextName());
jsonPath = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType,
jsonPath));
}
String text = validateJsonFilePath(jsonPath);
if (text == null || text.isEmpty()) {
return;
}
String tempxml = null;
String readbyMode = JSONFileStep1Form.this.wizard.getReadbyMode();
if (EJsonReadbyMode.JSONPATH.getValue().equals(readbyMode)) {
tempxml = text;
} else {
tempxml = JSONUtil.changeJsonToXml(text);
}
File file = new File(text);
if (!file.exists()) {
file = new File(JSONUtil.tempJSONXsdPath);
}
JSONFileStep1Form.this.wizard.setTempJsonPath(tempxml);
String limitString = commonNodesLimitation.getText();
try {
limit = Integer.valueOf(limitString);
labelLimitation.setToolTipText(MessageFormat.format(Messages.JSONLimitToolTip, limit));
} catch (Exception excpt) {
// nothing need to do
}
switchPopulator(readbyMode, tempxml);
// }
// add for bug TDI-20432
checkFieldsValue();
// }
// String text = fileFieldJSON.getText();
// File temp = new File(text);
// if (!temp.exists()) {
// return;
// }
if (getConnection().getJSONFilePath() != null && !getConnection().getJSONFilePath().equals(text)) {
getConnection().getLoop().clear();
xsdPathChanged = true;
} else {
xsdPathChanged = false;
}
if (isContextMode()) {
jsonPath = _jsonPath;
}
if (Path.fromOSString(jsonPath).toFile().isFile()) {
getConnection().setJSONFilePath(PathUtils.getPortablePath(jsonPath));
} else {
getConnection().setJSONFilePath(jsonPath);
}
JSONWizard wizard = ((JSONWizard) getPage().getWizard());
wizard.setTreeRootNode(treeNode);
BufferedReader in = null;
// File file = null;
//
// if (tempJSONXsdPath != null && getConnection().getFileContent() != null
// && getConnection().getFileContent().length > 0 && !isModifing) {
// file = new File(tempJSONXsdPath);
// if (!file.exists()) {
// try {
// file.createNewFile();
// } catch (IOException e2) {
// ExceptionHandler.process(e2);
// }
// FileOutputStream outStream;
// try {
// outStream = new FileOutputStream(file);
// outStream.write(getConnection().getFileContent());
// outStream.close();
// } catch (FileNotFoundException e1) {
// ExceptionHandler.process(e1);
// } catch (IOException e3) {
// ExceptionHandler.process(e3);
// }
// }
//
// } else {
// file = new File(text);
// }
// setFileContent(file);
// }
try {
Charset guessedCharset = CharsetToolkit.guessEncoding(file, 4096);
String str;
in = new BufferedReader(new InputStreamReader(new FileInputStream(file), guessedCharset.displayName()));
while ((str = in.readLine()) != null) {
if (str.contains("encoding")) { //$NON-NLS-1$
String regex = "^<\\?JSON\\s*version=\\\"[^\\\"]*\\\"\\s*encoding=\\\"([^\\\"]*)\\\"\\?>$"; //$NON-NLS-1$
Perl5Compiler compiler = new Perl5Compiler();
Perl5Matcher matcher = new Perl5Matcher();
Pattern pattern = null;
try {
pattern = compiler.compile(regex);
if (matcher.contains(str, pattern)) {
MatchResult matchResult = matcher.getMatch();
if (matchResult != null) {
encoding = matchResult.group(1);
}
}
} catch (MalformedPatternException malE) {
ExceptionHandler.process(malE);
}
}
}
} catch (Exception ex) {
String fileStr = text;
String msgError = "JSON" + " \"" + fileStr.replace("\\\\", "\\") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ "\"\n"; //$NON-NLS-1$
if (ex instanceof FileNotFoundException) {
msgError = msgError + "is not found";
} else if (ex instanceof EOFException) {
msgError = msgError + "have an incorrect character EOF";
} else if (ex instanceof IOException) {
msgError = msgError + "is locked by another soft";
} else {
msgError = msgError + "doesn't exist";
}
if (!isReadOnly()) {
updateStatus(IStatus.ERROR, msgError);
}
// ExceptionHandler.process(ex);
} finally {
try {
if (in != null) {
in.close();
}
} catch (Exception ex2) {
ExceptionHandler.process(ex2);
}
}
if (getConnection().getEncoding() == null || "".equals(getConnection().getEncoding())) { //$NON-NLS-1$
getConnection().setEncoding(encoding);
if (encoding != null && !("").equals(encoding)) { //$NON-NLS-1$
encodingCombo.setText(encoding);
} else {
encodingCombo.setText("UTF-8"); //$NON-NLS-1$
}
}
// if (tempJSONXsdPath != null && getConnection().getFileContent() != null
// && getConnection().getFileContent().length > 0 && !isModifing) {
// valid = treePopulator.populateTree(tempJSONXsdPath, treeNode);
// } else {
// valid = treePopulator.populateTree(text, treeNode);
// }
checkFieldsValue();
isModifing = true;
}
});
@@ -529,19 +691,6 @@ public class JSONFileStep1Form extends AbstractJSONFileStepForm {
@Override
public void modifyText(final ModifyEvent e) {
getConnection().setEncoding(encodingCombo.getText());
String encoding = getConnection().getEncoding();
if (treePopulator != null) {
treePopulator.setEncoding(encoding);
}
try {
Charset charSet = Charset.forName(encoding);
if (charSet != null) {
validateJsonFile();
return;
}
} catch (Exception ex) {
// ignore
}
checkFieldsValue();
}
});
@@ -734,171 +883,4 @@ public class JSONFileStep1Form extends AbstractJSONFileStepForm {
// valid = this.treePopulator.populateTree(tempJSONXsdPath, treeNode);
// temfile.delete();
}
private void validateJsonFile() {
String jsonPath = fileFieldJSON.getText();
String _jsonPath = jsonPath;
if (isContextMode()) {
ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(
connectionItem.getConnection(), connectionItem.getConnection().getContextName());
jsonPath = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType,
jsonPath));
}
String text = validateJsonFilePath(jsonPath);
if (text == null || text.isEmpty()) {
return;
}
String tempxml = null;
String readbyMode = JSONFileStep1Form.this.wizard.getReadbyMode();
if (EJsonReadbyMode.JSONPATH.getValue().equals(readbyMode)) {
tempxml = text;
} else {
tempxml = JSONUtil.changeJsonToXml(text, getConnection().getEncoding());
}
File file = new File(text);
if (!file.exists()) {
file = new File(JSONUtil.tempJSONXsdPath);
}
JSONFileStep1Form.this.wizard.setTempJsonPath(tempxml);
String limitString = commonNodesLimitation.getText();
try {
limit = Integer.valueOf(limitString);
labelLimitation.setToolTipText(MessageFormat.format(Messages.JSONLimitToolTip, limit));
} catch (Exception excpt) {
// nothing need to do
}
switchPopulator(readbyMode, tempxml);
// }
// add for bug TDI-20432
checkFieldsValue();
// }
// String text = fileFieldJSON.getText();
// File temp = new File(text);
// if (!temp.exists()) {
// return;
// }
if (getConnection().getJSONFilePath() != null && !getConnection().getJSONFilePath().equals(text)) {
getConnection().getLoop().clear();
xsdPathChanged = true;
} else {
xsdPathChanged = false;
}
if (isContextMode()) {
jsonPath = _jsonPath;
}
if (Path.fromOSString(jsonPath).toFile().isFile()) {
getConnection().setJSONFilePath(PathUtils.getPortablePath(jsonPath));
} else {
getConnection().setJSONFilePath(jsonPath);
}
JSONWizard wizard = ((JSONWizard) getPage().getWizard());
wizard.setTreeRootNode(treeNode);
BufferedReader in = null;
// File file = null;
//
// if (tempJSONXsdPath != null && getConnection().getFileContent() != null
// && getConnection().getFileContent().length > 0 && !isModifing) {
// file = new File(tempJSONXsdPath);
// if (!file.exists()) {
// try {
// file.createNewFile();
// } catch (IOException e2) {
// ExceptionHandler.process(e2);
// }
// FileOutputStream outStream;
// try {
// outStream = new FileOutputStream(file);
// outStream.write(getConnection().getFileContent());
// outStream.close();
// } catch (FileNotFoundException e1) {
// ExceptionHandler.process(e1);
// } catch (IOException e3) {
// ExceptionHandler.process(e3);
// }
// }
//
// } else {
// file = new File(text);
// }
// setFileContent(file);
// }
try {
Charset guessedCharset = CharsetToolkit.guessEncoding(file, 4096);
String str;
in = new BufferedReader(new InputStreamReader(new FileInputStream(file), guessedCharset.displayName()));
while ((str = in.readLine()) != null) {
if (str.contains("encoding")) { //$NON-NLS-1$
String regex = "^<\\?JSON\\s*version=\\\"[^\\\"]*\\\"\\s*encoding=\\\"([^\\\"]*)\\\"\\?>$"; //$NON-NLS-1$
Perl5Compiler compiler = new Perl5Compiler();
Perl5Matcher matcher = new Perl5Matcher();
Pattern pattern = null;
try {
pattern = compiler.compile(regex);
if (matcher.contains(str, pattern)) {
MatchResult matchResult = matcher.getMatch();
if (matchResult != null) {
encoding = matchResult.group(1);
}
}
} catch (MalformedPatternException malE) {
ExceptionHandler.process(malE);
}
}
}
} catch (Exception ex) {
String fileStr = text;
String msgError = "JSON" + " \"" + fileStr.replace("\\\\", "\\") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ "\"\n"; //$NON-NLS-1$
if (ex instanceof FileNotFoundException) {
msgError = msgError + "is not found";
} else if (ex instanceof EOFException) {
msgError = msgError + "have an incorrect character EOF";
} else if (ex instanceof IOException) {
msgError = msgError + "is locked by another soft";
} else {
msgError = msgError + "doesn't exist";
}
if (!isReadOnly()) {
updateStatus(IStatus.ERROR, msgError);
}
// ExceptionHandler.process(ex);
} finally {
try {
if (in != null) {
in.close();
}
} catch (Exception ex2) {
ExceptionHandler.process(ex2);
}
}
if (getConnection().getEncoding() == null || "".equals(getConnection().getEncoding())) { //$NON-NLS-1$
getConnection().setEncoding(encoding);
if (encoding != null && !("").equals(encoding)) { //$NON-NLS-1$
encodingCombo.setText(encoding);
} else {
encodingCombo.setText("UTF-8"); //$NON-NLS-1$
}
}
// if (tempJSONXsdPath != null && getConnection().getFileContent() != null
// && getConnection().getFileContent().length > 0 && !isModifing) {
// valid = treePopulator.populateTree(tempJSONXsdPath, treeNode);
// } else {
// valid = treePopulator.populateTree(text, treeNode);
// }
checkFieldsValue();
isModifing = true;
}
}

View File

@@ -27,7 +27,6 @@ import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.log4j.Priority;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.viewers.TreeViewer;
@@ -53,7 +52,6 @@ import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.talend.commons.CommonsPlugin;
import org.talend.commons.ui.command.CommandStackForComposite;
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
import org.talend.commons.ui.runtime.ws.WindowSystem;
@@ -224,7 +222,6 @@ public class JSONFileStep2Form extends AbstractJSONFileStepForm implements IRefr
jsonXPathLoopDescriptor.setLimitBoucle(XmlArray.getRowLimit());
}
treePopulator.setEncoding(getConnection().getEncoding());
treePopulator.populateTree(wizard.getTempJsonPath(), treeNode);
fieldsModel.setJSONXPathLoopDescriptor(jsonXPathLoopDescriptor.getSchemaTargets());
fieldsTableEditorView.getTableViewerCreator().layout();
@@ -611,22 +608,7 @@ public class JSONFileStep2Form extends AbstractJSONFileStepForm implements IRefr
}
};
ProcessDescription processDescription = getProcessDescription(false);
EJsonReadbyMode mode = null;
String readbyMode = getConnection().getReadbyMode();
if (StringUtils.isNotBlank(readbyMode)) {
mode = EJsonReadbyMode.getEJsonReadbyModeByValue(readbyMode);
}
if (EJsonReadbyMode.XPATH.equals(mode)) {
/**
* JSON XPATH mode uses the temp generated xml file to execute the preview, the generated xml file is
* encoded using UTF-8. <br/>
* (The generated xml file can't be encoded using other charset, otherwise the converted xml file will be
* empty)
*/
processDescription.setEncoding(TalendQuoteUtils.addQuotes("UTF-8"));
}
previewLoader.load(processDescription);
previewLoader.load(getProcessDescription(false));
}
@@ -889,20 +871,10 @@ public class JSONFileStep2Form extends AbstractJSONFileStepForm implements IRefr
}
}
Charset guessedCharset = null;
try {
guessedCharset = Charset.forName(getConnection().getEncoding());
} catch (Exception e) {
if (CommonsPlugin.isDebugMode()) {
ExceptionHandler.process(e, Priority.WARN);
}
}
if (guessedCharset == null) {
guessedCharset = CharsetToolkit.guessEncoding(file, 4096);
}
Charset guessedCharset = CharsetToolkit.guessEncoding(file, 4096);
String str;
in = new BufferedReader(new InputStreamReader(new FileInputStream(pathStr), guessedCharset));
in = new BufferedReader(new InputStreamReader(new FileInputStream(pathStr), guessedCharset.displayName()));
while ((str = in.readLine()) != null) {
previewRows.append(str + "\n"); //$NON-NLS-1$
@@ -975,7 +947,6 @@ public class JSONFileStep2Form extends AbstractJSONFileStepForm implements IRefr
// fix bug: when the JSON file is changed, the linker doesn't work.
resetStatusIfNecessary();
String tempJson = this.wizard.getTempJsonPath();
this.treePopulator.setEncoding(getConnection().getEncoding());
this.treePopulator.populateTree(tempJson, treeNode);
ScrollBar verticalBar = availableJSONTree.getVerticalBar();

View File

@@ -328,7 +328,7 @@ public class JSONFileStep3Form extends AbstractJSONFileStepForm {
processDescription = JSONShadowProcessHelper.getProcessDescription(connection2, connection2.getJSONFilePath());
} else {
processDescription = JSONShadowProcessHelper.getProcessDescription(connection2,
JSONUtil.changeJsonToXml(connection2.getJSONFilePath(), getConnection().getEncoding()));
JSONUtil.changeJsonToXml(connection2.getJSONFilePath()));
}
}
return processDescription;
@@ -357,18 +357,10 @@ public class JSONFileStep3Form extends AbstractJSONFileStepForm {
informationLabel.setText(" " + "Guess in progress...");
CsvArray csvArray = null;
ProcessDescription processDescription = getProcessDescription(false);
if (EJsonReadbyMode.JSONPATH.getValue().equals(connection2.getReadbyMode())) {
csvArray = JSONShadowProcessHelper.getCsvArray(processDescription, "FILE_JSON"); //$NON-NLS-1$
csvArray = JSONShadowProcessHelper.getCsvArray(getProcessDescription(false), "FILE_JSON"); //$NON-NLS-1$
} else {
/**
* JSON XPATH mode uses the temp generated xml file to execute the preview, the generated xml file is
* encoded using UTF-8. <br/>
* (The generated xml file can't be encoded using other charset, otherwise the converted xml file will
* be empty)
*/
processDescription.setEncoding(TalendQuoteUtils.addQuotes("UTF-8"));
csvArray = JSONShadowProcessHelper.getCsvArray(processDescription, "FILE_XML"); //$NON-NLS-1$
csvArray = JSONShadowProcessHelper.getCsvArray(getProcessDescription(false), "FILE_XML"); //$NON-NLS-1$
}
if (csvArray == null) {
informationLabel.setText(" " + "Guess failure");

View File

@@ -20,13 +20,10 @@ import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.ui.actions.SelectionProviderAction;
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
import org.talend.core.model.metadata.builder.connection.Connection;
import org.talend.core.model.properties.ConnectionItem;
import org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode;
import org.talend.metadata.managment.ui.wizard.metadata.xml.utils.TreeUtil;
import org.talend.repository.json.ui.wizards.AbstractJSONStepForm;
import org.talend.repository.json.util.JSONUtil;
import org.talend.repository.model.json.JSONFileConnection;
/**
* hwang class global comment. Detailled comment
@@ -59,17 +56,7 @@ public class ImportTreeFromJSONAction extends SelectionProviderAction {
boolean changed = true;
try {
String encoding = "UTF-8";
if (this.form != null) {
ConnectionItem connectionItem = this.form.getConnectionItem();
if (connectionItem != null) {
Connection connection = connectionItem.getConnection();
if (connection instanceof JSONFileConnection) {
encoding = ((JSONFileConnection) connection).getEncoding();
}
}
}
newInput = TreeUtil.getFoxTreeNodes(JSONUtil.changeJsonToXml(filePath, encoding));
newInput = TreeUtil.getFoxTreeNodes(JSONUtil.changeJsonToXml(filePath));
changed = true;
} catch (Exception e) {
ExceptionHandler.process(e);

View File

@@ -272,7 +272,6 @@ public class JSONToXPathLinker extends TreeToTablesLinker<Object, Object> {
}
if (originalValue != null) {
loadItemDataForLazyLoad(loopTableEditorView);
createLoopLinks(originalValue, tableItem, monitorWrap);
}
@@ -312,7 +311,6 @@ public class JSONToXPathLinker extends TreeToTablesLinker<Object, Object> {
List<SchemaTarget> schemaTargetList, int startTableItem, int tableItemLength) {
monitorWrap.beginTask("Fields links creation ...", totalWork);
loadItemDataForLazyLoad(fieldsTableEditorView);
TableItem[] fieldsTableItems = fieldsTableEditorView.getTable().getItems();
for (int i = startTableItem, indexShemaTarget = 0; i < startTableItem + tableItemLength; i++, indexShemaTarget++) {
@@ -332,7 +330,6 @@ public class JSONToXPathLinker extends TreeToTablesLinker<Object, Object> {
createFieldLinks(relativeXpathQuery, tableItem, monitorWrap, schemaTarget);
monitorWrap.worked(1);
}
fieldsTableEditorView.getTableViewerCreator().getTableViewer().refresh();
getLinksManager().sortLinks(getDrawingLinksComparator());
getBackgroundRefresher().refreshBackground();
}

View File

@@ -111,7 +111,7 @@ public class JSONUtil {
return true;
}
public static String changeJsonToXml(String jsonPath, String encoding) {
public static String changeJsonToXml(String jsonPath) {
Project project = ProjectManager.getInstance().getCurrentProject();
IProject fsProject = null;
try {
@@ -166,9 +166,10 @@ public class JSONUtil {
}
try {
String jsonStr = IOUtils.toString(input, encoding);
String jsonStr = IOUtils.toString(input);
convertJSON.setJsonString(jsonStr);
convertJSON.generate();
jsonStr = convertJSON.getJsonString4XML();
inStream = new ByteArrayInputStream(jsonStr.getBytes());

View File

@@ -3129,15 +3129,6 @@
name="UseOracle11VersionInsteadOfRemoved"
version="7.1.0">
</projecttask>
<projecttask
beforeLogon="false"
breaks="7.0.0"
class="org.talend.repository.model.migration.changeDBVersionForMapROJAIOutputMigrationTask"
description="Changed DB version in MapROJAI output component"
id="org.talend.repository.model.migration.changeDBVersionForMapROJAIOutputMigrationTask"
name="changeDBVersionForMapROJAIOutputMigrationTask"
version="7.0.1">
</projecttask>
</extension>
<extension

View File

@@ -1,84 +0,0 @@
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.repository.model.migration;
import java.util.Arrays;
import java.util.Date;
import java.util.GregorianCalendar;
import org.talend.commons.exception.PersistenceException;
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
import org.talend.core.language.ECodeLanguage;
import org.talend.core.model.components.ComponentUtilities;
import org.talend.core.model.components.ModifyComponentsAction;
import org.talend.core.model.components.conversions.IComponentConversion;
import org.talend.core.model.components.filters.IComponentFilter;
import org.talend.core.model.components.filters.NameComponentFilter;
import org.talend.core.model.migration.AbstractJobMigrationTask;
import org.talend.core.model.properties.Item;
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
import org.talend.migration.IMigrationTask.ExecutionResult;
public class changeDBVersionForMapROJAIOutputMigrationTask extends AbstractJobMigrationTask {
@Override
public Date getOrder() {
GregorianCalendar gc = new GregorianCalendar(2019, 8, 12, 12, 0, 0);
return gc.getTime();
}
@Override
public ExecutionResult execute(Item item) {
final ProcessType processType = getProcessType(item);
String[] compNames = {"tMapROjaiOutput"};
IComponentConversion changeDBNVersion = new IComponentConversion() {
public void transform(NodeType node) {
if(node == null) {
return;
}
ElementParameterType database = ComponentUtilities.getNodeProperty(node, "DB_VERSION"); //$NON-NLS-1$
if (database == null) {
return;
}
String dbname = database.getValue();
if("MAPROJAI_5_1".equals(dbname)) {
database.setValue("MAPR510");
} else if ("MAPROJAI_5_2".equals(dbname)) {
database.setValue("MAPR520");
}
}
};
for (String name : compNames) {
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays
.<IComponentConversion> asList(changeDBNVersion));
} catch (PersistenceException e) {
// TODO Auto-generated catch block
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
}

View File

@@ -81,7 +81,6 @@ import org.talend.commons.ui.runtime.exception.ExceptionMessageDialog;
import org.talend.commons.ui.runtime.exception.MessageBoxExceptionHandler;
import org.talend.commons.ui.runtime.image.EImage;
import org.talend.commons.ui.runtime.image.ImageProvider;
import org.talend.commons.utils.network.TalendProxySelector;
import org.talend.commons.utils.system.EclipseCommandLine;
import org.talend.commons.utils.system.EnvironmentUtils;
import org.talend.core.CorePlugin;
@@ -695,8 +694,6 @@ public class LoginProjectPage extends AbstractLoginActionPage {
CommonExceptionHandler.process(e);
} catch (JSONException e) {
CommonExceptionHandler.process(e);
} finally {
TalendProxySelector.getInstance();
}
}

View File

@@ -32,7 +32,6 @@ import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
import org.talend.repository.ui.wizards.exportjob.JavaJobScriptsExportWSWizardPage.JobExportType;
import org.talend.repository.ui.wizards.exportjob.handler.BuildJobHandler;
import org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice;
import org.talend.repository.utils.EmfModelUtils;
/**
* created by ycbai on 2015年5月15日 Detailled comment
@@ -41,7 +40,6 @@ import org.talend.repository.utils.EmfModelUtils;
public class BuildJobFactory {
public static final Map<JobExportType, String> oldBuildTypeMap = new HashMap<JobExportType, String>();
private static final String T_REST_REQUEST = "tRESTRequest";
private static final List<String> esbComponents;
static {
// from the extension point
@@ -103,22 +101,15 @@ public class BuildJobFactory {
if (StringUtils.isEmpty(buildType)) {
final Object type = processItem.getProperty().getAdditionalProperties()
.get(TalendProcessArgumentConstant.ARG_BUILD_TYPE);
boolean esb = false; //for esb consumer job and service
boolean esb = false;
if (processItem instanceof ProcessItem) {
if (null != EmfModelUtils.getComponentByName((ProcessItem) processItem, T_REST_REQUEST)) {
if (type == null) {
processItem.getProperty().getAdditionalProperties().put(TalendProcessArgumentConstant.ARG_BUILD_TYPE,
oldBuildTypeMap.get(JobExportType.OSGI));
}
esb = true;
} else {
for (Object o : ((ProcessItem) processItem).getProcess().getNode()) {
if (o instanceof NodeType) {
NodeType node = (NodeType) o;
if (esbComponents.contains(node.getComponentName())) {
esb = true;
break;
}
for (Object o : ((ProcessItem) processItem).getProcess().getNode()) {
if (o instanceof NodeType) {
NodeType currentNode = (NodeType) o;
if(esbComponents.contains(currentNode.getComponentName())) {
esb = true;
break;
}
}
}

View File

@@ -30,10 +30,8 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import java.util.Set;
import java.util.TreeSet;
import java.util.jar.Manifest;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -67,7 +65,6 @@ import org.talend.core.runtime.process.ITalendProcessJavaProject;
import org.talend.core.runtime.process.LastGenerationInfo;
import org.talend.core.runtime.repository.build.BuildExportManager;
import org.talend.core.ui.branding.IBrandingService;
import org.talend.designer.core.ICamelDesignerCoreService;
import org.talend.designer.core.IDesignerCoreService;
import org.talend.designer.core.model.utils.emf.component.IMPORTType;
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
@@ -85,14 +82,9 @@ import org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobJavaScriptsM
import org.talend.repository.utils.EmfModelUtils;
import org.talend.repository.utils.TemplateProcessor;
import aQute.bnd.header.Attrs;
import aQute.bnd.osgi.Analyzer;
import aQute.bnd.osgi.Descriptors;
import aQute.bnd.osgi.FileResource;
import aQute.bnd.osgi.Jar;
import aQute.bnd.service.AnalyzerPlugin;
import aQute.bnd.service.Plugin;
import aQute.service.reporter.Reporter;
/**
* DOC ycbai class global comment. Detailled comment
@@ -209,40 +201,9 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
ExportFileResource libResource = getCompiledLibExportFileResource(processes);
list.add(libResource);
ExportFileResource libResourceSelected = new ExportFileResource(null, LIBRARY_FOLDER_NAME);
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(
ICamelDesignerCoreService.class);
Collection<String> unselectList = camelService.getUnselectDependenciesBundle(processItem);
List<URL> unselectListURLs = new ArrayList<>();
for(Set<URL> set:libResource.getAllResources()) {
for (URL url : set) {
boolean exist = false;
for(String name: unselectList) {
if (name.equals(new File(url.toURI()).getName())) {
exist = true;
}
}
if (!exist) {
unselectListURLs.add(url);
}
}
}
libResourceSelected.addResources(unselectListURLs);
}
// generate the META-INFO folder
ExportFileResource metaInfoFolder = genMetaInfoFolder(libResourceSelected, processItem);
ExportFileResource metaInfoFolder = genMetaInfoFolder(libResource, processItem);
list.add(0, metaInfoFolder);
ExportFileResource providedLibResources = getProvidedLibExportFileResource(processes);
@@ -823,9 +784,7 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
Set<URL> resources = libResource.getResourcesByRelativePath(path);
for (URL url : resources) {
// TESB-21804:Fail to deploy cMessagingEndpoint with quartz component in runtime for ClassCastException
if (url.getPath().matches("(.*)camel-(.*)-alldep-(.*)$")
|| url.getPath().matches("(.*)activemq-all-[\\d\\.]*.jar$")
|| url.getPath().matches("(.*)jms[\\d\\.-]*.jar$")) {
if (url.getPath().matches("(.*)camel-(.*)-alldep-(.*)$")) {
continue;
}
File dependencyFile = new File(FilesUtils.getFileRealPath(url.getPath()));
@@ -847,11 +806,6 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
bundleNativeCode.setLength(bundleNativeCode.length() - 1);
analyzer.setProperty(Analyzer.BUNDLE_NATIVECODE, bundleNativeCode.toString());
}
// TESB-24730 set specific version for "javax.annotation"
ImportedPackageRangeReplacer r = new ImportedPackageRangeReplacer();
r.addRange("javax.annotation", "[1.3,2)");
analyzer.addBasicPlugin(r);
return analyzer;
}
@@ -1046,116 +1000,4 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
}
return imports;
}
private class ImportedPackageRangeReplacer implements AnalyzerPlugin, Plugin {
private Set<Range> ranges = new TreeSet<>();
public void addRange(String packageName, String packageVersion) {
ranges.add(new Range(packageName, packageVersion));
}
/**
* Analyzes the jar and update the version range.
*
* @param analyzer the analyzer
* @return {@code false}
* @throws Exception if the analaysis fails.
*/
@Override
public boolean analyzeJar(Analyzer analyzer) throws Exception {
if (analyzer.getReferred() == null) {
return false;
}
for (Map.Entry<Descriptors.PackageRef, Attrs> entry : analyzer.getReferred().entrySet()) {
for (Range range : ranges) {
if (range.matches(entry.getKey().getFQN())) {
String value = range.getRange(analyzer);
if (value != null) {
entry.getValue().put("version", value);
}
}
}
}
return false;
}
private class Range implements Comparable<Range> {
final String name;
final String value;
final Pattern regex;
private String foundRange;
private Range(String name, String value) {
this.name = name;
this.value = value;
this.regex = Pattern.compile(name.trim().replace(".", "\\.").replace("*", ".*"));
}
private boolean matches(String pck) {
return regex.matcher(pck).matches();
}
private String getRange(Analyzer analyzer) throws Exception {
if (foundRange != null) {
return foundRange;
}
if (null == value || value.isEmpty()) {
for (Jar jar : analyzer.getClasspath()) {
if (isProvidedByJar(jar) && jar.getVersion() != null) {
foundRange = jar.getVersion();
return jar.getVersion();
}
}
return null;
} else {
return value;
}
}
private boolean isProvidedByJar(Jar jar) {
for (String s : jar.getPackages()) {
if (matches(s)) {
return true;
}
}
return false;
}
@Override
public int compareTo(Range o) {
return Integer.compare(this.regex.pattern().length(), o.regex.pattern().length());
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Range range = (Range) o;
return Objects.equals(name, range.name) &&
Objects.equals(value, range.value);
}
@Override
public int hashCode() {
return Objects.hashCode(name + value);
}
}
@Override
public void setReporter(Reporter processor) {
}
@Override
public void setProperties(Map<String, String> map) throws Exception {
}
}
}

View File

@@ -12,11 +12,7 @@
// ============================================================================
package org.talend.designer.core.model.process;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.*;
import org.eclipse.draw2d.geometry.Point;
import org.junit.After;
@@ -366,61 +362,4 @@ public class ConnectionManagerTest {
}
@Test
public void testCheckCircle() {
Process process = new Process(createProperty());
IComponent component = ComponentsFactoryProvider.getInstance().get("tJava", ComponentCategory.CATEGORY_4_DI.getName());
Node sourceNode = new Node(componentSource, process);
Node targetNode = new Node(componentTarget, process);
Node middleNode_1 = new Node(component, process);
Node middleNode_2 = new Node(component, process);
Node middleNode_3 = new Node(component, process);
// sourceNode -> middleNode_1 -> targetNode
resetNodeConnection(sourceNode);
resetNodeConnection(middleNode_1);
resetNodeConnection(targetNode);
((List<Connection>) middleNode_1.getIncomingConnections()).add(new Connection(sourceNode, middleNode_1,
EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "testRow", "testRow", "testRow", false));
((List<Connection>) targetNode.getIncomingConnections()).add(new Connection(middleNode_1, targetNode,
EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "testRow", "testRow", "testRow", false));
Assert.assertFalse(ConnectionManager.checkCircle(middleNode_1, targetNode));
// TUP-22620 source==target, no incomming connections
Assert.assertTrue(ConnectionManager.checkCircle(sourceNode, sourceNode));
// for circle connection, test checkCircle by canConnectToTrget
// sourceNode -> targetNode -> sourceNode
resetNodeConnection(sourceNode);
resetNodeConnection(middleNode_1);
resetNodeConnection(targetNode);
((List<Connection>) targetNode.getIncomingConnections()).add(new Connection(sourceNode, targetNode,
EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "testRow", "testRow", "testRow", false));
Assert.assertFalse(ConnectionManager.canConnectToTarget(targetNode, null, sourceNode, EConnectionType.FLOW_MAIN,
EConnectionType.FLOW_MAIN.getName(), "testRow"));
// sourceNode -> middleNode_1 -> middleNode_2 -> middleNode_3 -> middleNode_1 -> targetNode
resetNodeConnection(sourceNode);
resetNodeConnection(targetNode);
((List<Connection>) middleNode_1.getIncomingConnections()).add(new Connection(sourceNode, middleNode_1,
EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "testRow", "testRow", "testRow", false));
((List<Connection>) middleNode_2.getIncomingConnections()).add(new Connection(middleNode_1, middleNode_2,
EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "testRow", "testRow", "testRow", false));
((List<Connection>) middleNode_1.getIncomingConnections()).add(new Connection(middleNode_3, middleNode_1,
EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "testRow", "testRow", "testRow", false));
((List<Connection>) targetNode.getIncomingConnections()).add(new Connection(middleNode_1, targetNode,
EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "testRow", "testRow", "testRow", false));
Assert.assertFalse(ConnectionManager.canConnectToTarget(middleNode_2, null, middleNode_3, EConnectionType.FLOW_MAIN,
EConnectionType.FLOW_MAIN.getName(), "testRow"));
}
private static void resetNodeConnection(Node node) {
List<Connection> inconnections = new ArrayList<Connection>();
node.setIncomingConnections(inconnections);
List<Connection> outconnections = new ArrayList<Connection>();
node.setOutgoingConnections(outconnections);
}
}

View File

@@ -5,7 +5,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -611,163 +610,5 @@ public class DbGenerationManagerTest extends DbGenerationManagerTestHelper {
+" \n"
+" ) table2\"";
assertEquals(exceptQuery.replaceAll("\n", "").trim(), query.trim());
}
@Test
public void testBuildSqlSelect_endWithContext() {
String schema = "";
String table1 = "table1";
String table2 = "table2";
String table3 = "table3";
List<IConnection> incomingConnections = new ArrayList<IConnection>();
String[] mainTableEntities = new String[] { "id", "column1", "column2" };
incomingConnections.add(mockConnection(schema, table1, mainTableEntities));
dbMapComponent.setIncomingConnections(incomingConnections);
ExternalDbMapData externalData = new ExternalDbMapData();
List<ExternalDbMapTable> inputs = new ArrayList<ExternalDbMapTable>();
List<ExternalDbMapTable> outputs = new ArrayList<ExternalDbMapTable>();
// main table
ExternalDbMapTable inputTable = new ExternalDbMapTable();
String mainTableName = "".equals(schema) ? table1 : schema + "." + table1;
// quote will be removed in the ui for connections ,so we do the same for test
String mainTableNameNoQuote = TalendTextUtils.removeQuotes(mainTableName);
inputTable.setTableName(mainTableNameNoQuote);
inputTable.setName(mainTableName);
List<ExternalDbMapEntry> entities = getMetadataEntities(mainTableEntities, new String[3]);
inputTable.setMetadataTableEntries(entities);
inputs.add(inputTable);
// output
ExternalDbMapTable outputTable = new ExternalDbMapTable();
mainTableName = "".equals(schema) ? table2 : schema + "." + table2;
// quote will be removed in the ui for connections ,so we do the same for test
mainTableNameNoQuote = TalendTextUtils.removeQuotes(mainTableName);
outputTable.setTableName(mainTableNameNoQuote);
outputTable.setName("table2");
String[] names = new String[] { "id", "column1", "column2" };
String mainTable = mainTableName;
String[] expressions = new String[] { "table1.id",
"CASE WHEN table1.column1 IS NULL THEN context.param1 ELSE table1.column1 END", "table1.column2" };
outputTable.setMetadataTableEntries(getMetadataEntities(names, expressions));
String[] whereNames = new String[] { "whereFilter" };
String[] whereExps = new String[] { "t.column2 = context.param2" };
outputTable.setCustomWhereConditionsEntries(getMetadataEntities(whereNames, whereExps));
outputs.add(outputTable);
externalData.setInputTables(inputs);
externalData.setOutputTables(outputs);
dbMapComponent.setExternalData(externalData);
List<IMetadataTable> metadataList = new ArrayList<IMetadataTable>();
MetadataTable metadataTable = getMetadataTable(names);
metadataTable.setLabel("table2");
metadataList.add(metadataTable);
dbMapComponent.setMetadataList(metadataList);
JobContext newContext = new JobContext("Default");
List<IContextParameter> newParamList = new ArrayList<IContextParameter>();
newContext.setContextParameterList(newParamList);
JobContextParameter param = new JobContextParameter();
param.setName("schema");
newParamList.add(param);
process = mock(Process.class);
JobContextManager contextManger = new JobContextManager();
contextManger.setDefaultContext(newContext);
when(process.getContextManager()).thenReturn(contextManger);
dbMapComponent.setProcess(process);
ExternalDbMapData externalData2 = new ExternalDbMapData();
DbMapComponent dbMapComponent2 = new DbMapComponent();
dbMapComponent2.setExternalData(externalData2);
mainTableEntities = new String[] { "id", "column1", "column2" };
List<IConnection> outgoingConnections = new ArrayList<IConnection>();
Node map1 = mockNode(dbMapComponent);
outgoingConnections.add(mockConnection(map1, schema, table2, mainTableEntities));
dbMapComponent.setOutgoingConnections(outgoingConnections);
dbMapComponent2.setIncomingConnections(outgoingConnections);
inputs = new ArrayList<ExternalDbMapTable>();
outputs = new ArrayList<ExternalDbMapTable>();
// main table
inputTable = new ExternalDbMapTable();
mainTableName = "".equals(schema) ? table2 : schema + "." + table2;
// quote will be removed in the ui for connections ,so we do the same for test
mainTableNameNoQuote = TalendTextUtils.removeQuotes(mainTableName);
inputTable.setTableName(mainTableNameNoQuote);
inputTable.setName("table2");
entities = getMetadataEntities(mainTableEntities, new String[3]);
inputTable.setMetadataTableEntries(entities);
inputs.add(inputTable);
// output
outputTable = new ExternalDbMapTable();
mainTableName = "".equals(schema) ? table3 : schema + "." + table3;
// quote will be removed in the ui for connections ,so we do the same for test
mainTableNameNoQuote = TalendTextUtils.removeQuotes(mainTableName);
outputTable.setTableName(mainTableNameNoQuote);
outputTable.setName("table3");
names = new String[] { "id", "column1", "column2" };
mainTable = mainTableName;
expressions = new String[] { "table2.id", "table2.column1", "table2.column2" };
outputTable.setMetadataTableEntries(getMetadataEntities(names, expressions));
whereNames = new String[] { "whereFilter" };
whereExps = new String[] { "t.column2A = context.param2A" };
outputTable.setCustomWhereConditionsEntries(getMetadataEntities(whereNames, whereExps));
outputs.add(outputTable);
externalData2.setInputTables(inputs);
externalData2.setOutputTables(outputs);
dbMapComponent2.setExternalData(externalData2);
metadataList = new ArrayList<IMetadataTable>();
metadataTable = getMetadataTable(names);
metadataTable.setLabel("table3");
metadataList.add(metadataTable);
dbMapComponent2.setMetadataList(metadataList);
if (dbMapComponent2.getElementParameters() == null) {
dbMapComponent2.setElementParameters(Collections.EMPTY_LIST);
}
JobContextParameter param1 = new JobContextParameter();
param1.setName("param1");
newParamList.add(param1);
JobContextParameter param2 = new JobContextParameter();
param2.setName("param2");
newParamList.add(param2);
dbMapComponent2.setProcess(process);
outgoingConnections = new ArrayList<IConnection>();
outgoingConnections.add(mockConnection(schema, table3, mainTableEntities));
dbMapComponent2.setOutgoingConnections(outgoingConnections);
ElementParameter comName = new ElementParameter(dbMapComponent);
comName.setName("COMPONENT_NAME");
comName.setValue("tELTMap");
List<ElementParameter> list = new ArrayList<>();
list.add(comName);
dbMapComponent.setElementParameters(list);
dbManager = new GenericDbGenerationManager() {
@Override
protected java.util.List<String> getContextList(DbMapComponent component) {
return Arrays.asList("context.param1", "context.param2", "context.param2A");
};
};
String query = dbManager.buildSqlSelect(dbMapComponent2, "table3");
String exceptQuery = "\"SELECT\n" +
"table2.id, table2.column1, table2.column2\n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" table1.id AS id, CASE WHEN table1.column1 IS NULL THEN \" +context.param1+ \" ELSE table1.column1 END AS column1, table1.column2 AS column2\n" +
" FROM\n" +
" table1\n" +
" WHERE t.column2 = \" +context.param2+ \"\n" +
" ) table2\n" +
"WHERE t.column2A = \" +context.param2A";
assertEquals(exceptQuery.trim(), query.trim());
}
}

View File

@@ -31,47 +31,26 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.talend.commons.utils.workbench.resources.ResourceUtils;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.language.ECodeLanguage;
import org.talend.core.model.context.JobContextManager;
import org.talend.core.model.process.IContext;
import org.talend.core.model.process.IContextManager;
import org.talend.core.model.process.IProcess;
import org.talend.core.model.process.IProcess2;
import org.talend.core.model.process.JobInfo;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.PropertiesFactory;
import org.talend.core.model.properties.Property;
import org.talend.core.model.relationship.Relation;
import org.talend.core.model.relationship.RelationshipItemBuilder;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.model.repository.RepositoryObject;
import org.talend.core.repository.model.ProxyRepositoryFactory;
import org.talend.core.runtime.process.ITalendProcessJavaProject;
import org.talend.core.runtime.process.TalendProcessOptionConstants;
import org.talend.designer.core.IDesignerCoreService;
import org.talend.designer.core.model.utils.emf.talendfile.ParametersType;
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
import org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory;
import org.talend.designer.core.ui.editor.process.Process;
import org.talend.designer.maven.model.TalendJavaProjectConstants;
import org.talend.designer.maven.model.TalendMavenConstants;
import org.talend.designer.maven.tools.AggregatorPomsHelper;
import org.talend.designer.maven.utils.PomUtil;
import org.talend.designer.runprocess.IProcessor;
import org.talend.designer.runprocess.IRunProcessService;
import org.talend.designer.runprocess.java.TalendJavaProjectManager;
import org.talend.designer.runprocess.maven.MavenJavaProcessor;
import org.talend.repository.ProjectManager;
import org.talend.repository.documentation.ERepositoryActionName;
import org.talend.repository.model.IProxyRepositoryFactory;
@@ -369,145 +348,6 @@ public class ProcessChangeListenerTest {
checkRootPomModules(toRemove, toAdd);
}
@Test
public void testSyncParentJobPomsForPropertyChange() throws Exception {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Property maintestProp = createJobPropertyWithContext("maintest", "0.1");
Property childtestProp = createJobPropertyWithContext("childtest", "0.1");
ProcessItem mainItem = (ProcessItem) maintestProp.getItem();
mainItem.getProcess().setDefaultContext("Default");
JobInfo mainJobInfo = new JobInfo(mainItem, mainItem.getProcess().getDefaultContext());
ProcessItem childItem = (ProcessItem) childtestProp.getItem();
JobInfo childJobInfo = new JobInfo(childItem, childItem.getProcess().getDefaultContext());
childJobInfo.setJobId(childtestProp.getId());
childJobInfo.setFatherJobInfo(mainJobInfo);
IProcessor mainProcessor = getProcessor(maintestProp.getItem());
assertTrue(mainProcessor != null);
mainProcessor.getBuildFirstChildrenJobs().add(childJobInfo);
int option = 0;
option |= TalendProcessOptionConstants.GENERATE_POM_ONLY;
option |= TalendProcessOptionConstants.GENERATE_IS_MAINJOB;
// ((MavenJavaProcessor) processor).generatePom(option);
MavenJavaProcessor mavenProcessor = (MavenJavaProcessor) mainProcessor;
mavenProcessor.generatePom(option);
// prepare relationship
RelationshipItemBuilder relationBuilder = RelationshipItemBuilder
.getInstance(ProjectManager.getInstance().getCurrentProject(), true);
relationBuilder.load();
Map<Relation, Set<Relation>> currentProjectItemsRelations = relationBuilder.getCurrentProjectItemsRelations();
Relation baseItem = new Relation();
baseItem.setId(maintestProp.getId());
baseItem.setType(RelationshipItemBuilder.JOB_RELATION);
baseItem.setVersion("0.1");
Relation relatedItem = new Relation();
relatedItem.setId(childtestProp.getId());
relatedItem.setVersion(RelationshipItemBuilder.LATEST_VERSION);
relatedItem.setType(RelationshipItemBuilder.JOB_RELATION);
currentProjectItemsRelations.put(baseItem, new HashSet<Relation>());
currentProjectItemsRelations.get(baseItem).add(relatedItem);
relationBuilder.saveRelations();
IFile maintestPom = getJobPomFile(maintestProp);
assertTrue(maintestPom.exists());
// expect: parentJob pom exist childJob dependency
assertTrue(PomUtil.checkIfJobDependencyExist(maintestPom, childtestProp));
// to upgrade child job version
IRepositoryViewObject childObject = factory.getSpecificVersion(childtestProp.getId(), childtestProp.getVersion(), true);
RepositoryObject upperChildObject = new RepositoryObject(childObject.getProperty());
Property upperProperty = upperChildObject.getProperty();
upperProperty.setVersion("0.2");
factory.save(upperProperty, childtestProp.getLabel(), childtestProp.getVersion());
RelationshipItemBuilder.getInstance().addOrUpdateItem(upperChildObject.getProperty().getItem());
// to moke the process of syncParentJobPomsForPropertyChange
List<Relation> itemsHaveRelationWith = RelationshipItemBuilder.getInstance()
.getItemsHaveRelationWith(upperProperty.getId(), upperProperty.getVersion());
assertTrue(itemsHaveRelationWith.size() == 1);
Relation relation = itemsHaveRelationWith.get(0);
assertTrue(relation.getId().equals(maintestProp.getId()));
assertTrue(relation.getVersion().equals(maintestProp.getVersion()));
// will get latest version childJobInfo in ProcessorUtilities.getSubjobInfo
mainProcessor.getBuildFirstChildrenJobs().clear();
ProcessItem upperItem = (ProcessItem) upperChildObject.getProperty().getItem();
JobInfo newChildJobInfo = new JobInfo(upperItem, upperItem.getProcess().getDefaultContext());
newChildJobInfo.setJobId(upperProperty.getId());
newChildJobInfo.setFatherJobInfo(mainJobInfo);
mainProcessor.getBuildFirstChildrenJobs().add(newChildJobInfo);
mavenProcessor.generatePom(option);
// expect: after childJob upgrade version, parentJob pom exist childJob dependency
// dependency version should be new version
assertTrue(PomUtil.checkIfJobDependencyExist(maintestPom, upperProperty));
}
private Property createJobPropertyWithContext(String label, String version) throws Exception {
Property property = PropertiesFactory.eINSTANCE.createProperty();
String id = ProxyRepositoryFactory.getInstance().getNextId();
property.setId(id);
property.setLabel(label);
property.setVersion(version);
ProcessItem item = PropertiesFactory.eINSTANCE.createProcessItem();
item.setProperty(property);
Process process = new Process(property);
ProcessType processType = TalendFileFactory.eINSTANCE.createProcessType();
ParametersType parameterType = TalendFileFactory.eINSTANCE.createParametersType();
processType.setParameters(parameterType);
item.setProcess(processType);
IContextManager contextManager = process.getContextManager();
if (contextManager == null) {
contextManager = new JobContextManager();
}
ProxyRepositoryFactory.getInstance().create(item, new Path(""));
testJobs.add(property);
return property;
}
private IProcessor getProcessor(Item item) {
GlobalServiceRegister register = GlobalServiceRegister.getDefault();
IProcessor processor = null;
IProcess process = null;
IContext context = null;
Property curProperty = item.getProperty();
if (register.isServiceRegistered(IDesignerCoreService.class)) {
IDesignerCoreService designerService = (IDesignerCoreService) register.getService(IDesignerCoreService.class);
process = designerService.getProcessFromItem(item);
if (item.getProperty() == null && process instanceof IProcess2) {
curProperty = ((IProcess2) process).getProperty();
}
context = process.getContextManager().getDefaultContext();
}
if (process != null && GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService runProcessservice = (IRunProcessService) GlobalServiceRegister.getDefault()
.getService(IRunProcessService.class);
processor = runProcessservice.createCodeProcessor(process, curProperty, ECodeLanguage.getCodeLanguage("java"), true);
}
processor.setContext(context);
return processor;
}
private IFile getJobPomFile(Property property) {
String projectTechName = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
final IProject project = root.getProject(projectTechName);
IFolder pomsFolder = project.getFolder(TalendJavaProjectConstants.DIR_POMS);
IFolder jobFolder = pomsFolder.getFolder("jobs").getFolder("process")
.getFolder(property.getLabel() + "_" + property.getVersion());
IFile jobPom = jobFolder.getFile("pom.xml");
return jobPom;
}
private Property createJobProperty(String label, String version, boolean create) throws Exception {
String id = ProxyRepositoryFactory.getInstance().getNextId();
return createJobProperty(id, label, version, new Path(""), create);