Compare commits
35 Commits
patch/TPS-
...
bhe/TPS-36
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
128f0cc479 | ||
|
|
a76d4e1bc4 | ||
|
|
d308b66352 | ||
|
|
d46c202e6b | ||
|
|
f536ed47ae | ||
|
|
de82c16af4 | ||
|
|
c5eac4ef90 | ||
|
|
1fa26e95ed | ||
|
|
4d4040de42 | ||
|
|
2fa1c9c6c0 | ||
|
|
d69f83c3bd | ||
|
|
2ad55908cd | ||
|
|
f6209cee95 | ||
|
|
fe032a359c | ||
|
|
dec8461335 | ||
|
|
46eae3db6a | ||
|
|
0b2496cca6 | ||
|
|
24c2e1bbb3 | ||
|
|
dd18017695 | ||
|
|
af1d09968b | ||
|
|
4a0e546f9a | ||
|
|
9142b137de | ||
|
|
96d9b2c8a2 | ||
|
|
96a52cea5a | ||
|
|
af6792732a | ||
|
|
48571e54bc | ||
|
|
dc64a893c6 | ||
|
|
78d8d901b6 | ||
|
|
6947ccdf9d | ||
|
|
91bd64ec32 | ||
|
|
d96a383857 | ||
|
|
85581b5d25 | ||
|
|
32e02c0bbd | ||
|
|
f0251625b4 | ||
|
|
cb3b7a5b37 |
@@ -69,145 +69,140 @@ if(hasInput){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boolean hasValidInput = inputConn!=null;
|
||||
|
||||
IMetadataTable metadata = null;
|
||||
List<IMetadataTable> metadatas = node.getMetadataList();
|
||||
boolean haveValidNodeMetadata = ((metadatas != null) && (metadatas.size() > 0) && (metadata = metadatas.get(0)) != null);
|
||||
|
||||
if (hasValidInput && haveValidNodeMetadata) {
|
||||
if (hasValidInput) {
|
||||
List<IMetadataColumn> input_columnList = inputConn.getMetadataTable().getListColumns();
|
||||
if(input_columnList == null) {
|
||||
input_columnList = new ArrayList<IMetadataColumn>();
|
||||
}
|
||||
// add incoming (not present) columns to enforcer for this comps
|
||||
if (cid.contains("tDataStewardship") || cid.contains("tMarkLogic")){
|
||||
%>
|
||||
boolean shouldCreateRuntimeSchemaForIncomingNode = false;
|
||||
<%
|
||||
for (int i = 0; i < input_columnList.size(); i++) {
|
||||
if(!input_columnList.get(i).getTalendType().equals("id_Dynamic")) {
|
||||
%>
|
||||
if (incomingEnforcer_<%=cid%>.getDesignSchema().getField("<%=input_columnList.get(i)%>") == null){
|
||||
incomingEnforcer_<%=cid%>.addIncomingNodeField("<%=input_columnList.get(i)%>", ((Object) <%=inputConn.getName()%>.<%=input_columnList.get(i)%>).getClass().getCanonicalName());
|
||||
shouldCreateRuntimeSchemaForIncomingNode = true;
|
||||
}
|
||||
<%
|
||||
}
|
||||
}
|
||||
%>
|
||||
if (shouldCreateRuntimeSchemaForIncomingNode){
|
||||
incomingEnforcer_<%=cid%>.createRuntimeSchema();
|
||||
}
|
||||
<%
|
||||
}
|
||||
// If there are dynamic columns in the schema, they need to be
|
||||
// initialized into the runtime schema of the actual IndexedRecord
|
||||
// provided to the component.
|
||||
|
||||
int dynamicPos = -1;
|
||||
for (int i = 0; i < input_columnList.size(); i++) {
|
||||
if (input_columnList.get(i).getTalendType().equals("id_Dynamic")) {
|
||||
dynamicPos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (dynamicPos != -1) {
|
||||
%>
|
||||
if (!incomingEnforcer_<%=cid%>.areDynamicFieldsInitialized()) {
|
||||
// Initialize the dynamic columns when they are first encountered.
|
||||
for (routines.system.DynamicMetadata dm_<%=cid%> : <%=inputConn.getName()%>.<%=input_columnList.get(dynamicPos).getLabel()%>.metadatas) {
|
||||
incomingEnforcer_<%=cid%>.addDynamicField(
|
||||
dm_<%=cid%>.getName(),
|
||||
dm_<%=cid%>.getType(),
|
||||
dm_<%=cid%>.getLogicalType(),
|
||||
dm_<%=cid%>.getFormat(),
|
||||
dm_<%=cid%>.getDescription(),
|
||||
dm_<%=cid%>.isNullable());
|
||||
}
|
||||
incomingEnforcer_<%=cid%>.createRuntimeSchema();
|
||||
}
|
||||
<%
|
||||
}
|
||||
|
||||
%>
|
||||
incomingEnforcer_<%=cid%>.createNewRecord();
|
||||
<%
|
||||
for (int i = 0; i < input_columnList.size(); i++) { // column
|
||||
IMetadataColumn column = input_columnList.get(i);
|
||||
if (dynamicPos != i) {
|
||||
%>
|
||||
//skip the put action if the input column doesn't appear in component runtime schema
|
||||
if (incomingEnforcer_<%=cid%>.getRuntimeSchema().getField("<%=input_columnList.get(i)%>") != null){
|
||||
incomingEnforcer_<%=cid%>.put("<%=column.getLabel()%>", <%=inputConn.getName()%>.<%=column.getLabel()%>);
|
||||
}
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
for (int i = 0; i < <%=inputConn.getName()%>.<%=column.getLabel()%>.getColumnCount(); i++) {
|
||||
incomingEnforcer_<%=cid%>.put(<%=inputConn.getName()%>.<%=column.getLabel()%>.getColumnMetadata(i).getName(),
|
||||
<%=inputConn.getName()%>.<%=column.getLabel()%>.getColumnValue(i));
|
||||
}
|
||||
<%
|
||||
}
|
||||
} // column
|
||||
|
||||
// If necesary, generate the code to handle outgoing connections.
|
||||
// TODO: For now, this can only handle one outgoing record for
|
||||
// each incoming record. To handle multiple outgoing records, code
|
||||
// generation needs to occur in component_begin in order to open
|
||||
// a for() loop.
|
||||
|
||||
// There will be a ClassCastException if the output component does
|
||||
// not implement WriterWithFeedback, but permits outgoing
|
||||
// connections.
|
||||
|
||||
if (input_columnList!=null && !input_columnList.isEmpty()) {
|
||||
// add incoming (not present) columns to enforcer for this comps
|
||||
if (cid.contains("tDataStewardship") || cid.contains("tMarkLogic")){
|
||||
%>
|
||||
boolean shouldCreateRuntimeSchemaForIncomingNode = false;
|
||||
<%
|
||||
for (int i = 0; i < input_columnList.size(); i++) {
|
||||
if(!input_columnList.get(i).getTalendType().equals("id_Dynamic")) {
|
||||
%>
|
||||
if (incomingEnforcer_<%=cid%>.getDesignSchema().getField("<%=input_columnList.get(i)%>") == null){
|
||||
incomingEnforcer_<%=cid%>.addIncomingNodeField("<%=input_columnList.get(i)%>", ((Object) <%=inputConn.getName()%>.<%=input_columnList.get(i)%>).getClass().getCanonicalName());
|
||||
shouldCreateRuntimeSchemaForIncomingNode = true;
|
||||
}
|
||||
<%
|
||||
}
|
||||
}
|
||||
%>
|
||||
if (shouldCreateRuntimeSchemaForIncomingNode){
|
||||
incomingEnforcer_<%=cid%>.createRuntimeSchema();
|
||||
}
|
||||
<%
|
||||
}
|
||||
// If there are dynamic columns in the schema, they need to be
|
||||
// initialized into the runtime schema of the actual IndexedRecord
|
||||
// provided to the component.
|
||||
|
||||
int dynamicPos = -1;
|
||||
for (int i = 0; i < input_columnList.size(); i++) {
|
||||
if (input_columnList.get(i).getTalendType().equals("id_Dynamic")) {
|
||||
dynamicPos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (dynamicPos != -1) {
|
||||
%>
|
||||
if (!incomingEnforcer_<%=cid%>.areDynamicFieldsInitialized()) {
|
||||
// Initialize the dynamic columns when they are first encountered.
|
||||
for (routines.system.DynamicMetadata dm_<%=cid%> : <%=inputConn.getName()%>.<%=input_columnList.get(dynamicPos).getLabel()%>.metadatas) {
|
||||
incomingEnforcer_<%=cid%>.addDynamicField(
|
||||
dm_<%=cid%>.getName(),
|
||||
dm_<%=cid%>.getType(),
|
||||
dm_<%=cid%>.getLogicalType(),
|
||||
dm_<%=cid%>.getFormat(),
|
||||
dm_<%=cid%>.getDescription(),
|
||||
dm_<%=cid%>.isNullable());
|
||||
}
|
||||
incomingEnforcer_<%=cid%>.createRuntimeSchema();
|
||||
}
|
||||
<%
|
||||
}
|
||||
|
||||
%>
|
||||
incomingEnforcer_<%=cid%>.createNewRecord();
|
||||
<%
|
||||
for (int i = 0; i < input_columnList.size(); i++) { // column
|
||||
IMetadataColumn column = input_columnList.get(i);
|
||||
if (dynamicPos != i) {
|
||||
%>
|
||||
//skip the put action if the input column doesn't appear in component runtime schema
|
||||
if (incomingEnforcer_<%=cid%>.getRuntimeSchema().getField("<%=input_columnList.get(i)%>") != null){
|
||||
incomingEnforcer_<%=cid%>.put("<%=column.getLabel()%>", <%=inputConn.getName()%>.<%=column.getLabel()%>);
|
||||
}
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
for (int i = 0; i < <%=inputConn.getName()%>.<%=column.getLabel()%>.getColumnCount(); i++) {
|
||||
incomingEnforcer_<%=cid%>.put(<%=inputConn.getName()%>.<%=column.getLabel()%>.getColumnMetadata(i).getName(),
|
||||
<%=inputConn.getName()%>.<%=column.getLabel()%>.getColumnValue(i));
|
||||
}
|
||||
<%
|
||||
}
|
||||
} // column
|
||||
|
||||
// If necesary, generate the code to handle outgoing connections.
|
||||
// TODO: For now, this can only handle one outgoing record for
|
||||
// each incoming record. To handle multiple outgoing records, code
|
||||
// generation needs to occur in component_begin in order to open
|
||||
// a for() loop.
|
||||
|
||||
// There will be a ClassCastException if the output component does
|
||||
// not implement WriterWithFeedback, but permits outgoing
|
||||
// connections.
|
||||
|
||||
ComponentProperties componentProps = node.getComponentProperties();
|
||||
ProcessPropertiesGenerator generator = new ProcessPropertiesGenerator(cid, component);
|
||||
List<Component.CodegenPropInfo> propsToProcess = component.getCodegenPropInfos(componentProps);
|
||||
for (Component.CodegenPropInfo propInfo : propsToProcess) { // propInfo
|
||||
List<NamedThing> properties = propInfo.props.getProperties();
|
||||
for (NamedThing prop : properties) { // property
|
||||
if (prop instanceof Property) { // if, only deal with valued Properties
|
||||
Property property = (Property)prop;
|
||||
if (property.getFlags() != null && (property.getFlags().contains(Property.Flags.DESIGN_TIME_ONLY) || property.getFlags().contains(Property.Flags.HIDDEN)))
|
||||
continue;
|
||||
if(property.getTaggedValue(IGenericConstants.DYNAMIC_PROPERTY_VALUE)!=null && Boolean.valueOf(String.valueOf(property.getTaggedValue(IGenericConstants.DYNAMIC_PROPERTY_VALUE)))) {
|
||||
generator.setPropertyValues(property, propInfo, null, false, false);
|
||||
}
|
||||
ComponentProperties componentProps = node.getComponentProperties();
|
||||
ProcessPropertiesGenerator generator = new ProcessPropertiesGenerator(cid, component);
|
||||
List<Component.CodegenPropInfo> propsToProcess = component.getCodegenPropInfos(componentProps);
|
||||
for (Component.CodegenPropInfo propInfo : propsToProcess) { // propInfo
|
||||
List<NamedThing> properties = propInfo.props.getProperties();
|
||||
for (NamedThing prop : properties) { // property
|
||||
if (prop instanceof Property) { // if, only deal with valued Properties
|
||||
Property property = (Property)prop;
|
||||
if (property.getFlags() != null && (property.getFlags().contains(Property.Flags.DESIGN_TIME_ONLY) || property.getFlags().contains(Property.Flags.HIDDEN)))
|
||||
continue;
|
||||
if(property.getTaggedValue(IGenericConstants.DYNAMIC_PROPERTY_VALUE)!=null && Boolean.valueOf(String.valueOf(property.getTaggedValue(IGenericConstants.DYNAMIC_PROPERTY_VALUE)))) {
|
||||
generator.setPropertyValues(property, propInfo, null, false, false);
|
||||
}
|
||||
} // property
|
||||
} // propInfo
|
||||
|
||||
%>
|
||||
org.apache.avro.generic.IndexedRecord data_<%=cid%> = incomingEnforcer_<%=cid%>.getCurrentRecord();
|
||||
|
||||
<%
|
||||
boolean isParallelize ="true".equalsIgnoreCase(ElementParameterParser.getValue(node, "__PARALLELIZE__"));
|
||||
if (isParallelize) {
|
||||
String sourceComponentId = inputConn.getSource().getUniqueName();
|
||||
if(sourceComponentId!=null && sourceComponentId.contains("tAsyncIn")) {
|
||||
%>
|
||||
globalMap.put(buffersSizeKey_<%=cid%>, buffersSize_<%=sourceComponentId%>);
|
||||
<%
|
||||
}
|
||||
}
|
||||
%>
|
||||
}
|
||||
} // property
|
||||
} // propInfo
|
||||
|
||||
%>
|
||||
org.apache.avro.generic.IndexedRecord data_<%=cid%> = incomingEnforcer_<%=cid%>.getCurrentRecord();
|
||||
|
||||
<%
|
||||
boolean isParallelize ="true".equalsIgnoreCase(ElementParameterParser.getValue(node, "__PARALLELIZE__"));
|
||||
if (isParallelize) {
|
||||
String sourceComponentId = inputConn.getSource().getUniqueName();
|
||||
if(sourceComponentId!=null && sourceComponentId.contains("tAsyncIn")) {
|
||||
%>
|
||||
globalMap.put(buffersSizeKey_<%=cid%>, buffersSize_<%=sourceComponentId%>);
|
||||
<%
|
||||
}
|
||||
}
|
||||
%>
|
||||
|
||||
writer_<%=cid%>.write(data_<%=cid%>);
|
||||
|
||||
nb_line_<%=cid %>++;
|
||||
<%if(hasMainOutput){
|
||||
%>
|
||||
if(!(writer_<%=cid%> instanceof org.talend.components.api.component.runtime.WriterWithFeedback)) {
|
||||
// For no feedback writer,just pass the input record to the output
|
||||
if (data_<%=cid%>!=null) {
|
||||
outgoingMainRecordsList_<%=cid%> = java.util.Arrays.asList(data_<%=cid%>);
|
||||
}
|
||||
}
|
||||
<%
|
||||
}
|
||||
writer_<%=cid%>.write(data_<%=cid%>);
|
||||
|
||||
nb_line_<%=cid %>++;
|
||||
<%if(hasMainOutput){
|
||||
%>
|
||||
if(!(writer_<%=cid%> instanceof org.talend.components.api.component.runtime.WriterWithFeedback)) {
|
||||
// For no feedback writer,just pass the input record to the output
|
||||
if (data_<%=cid%>!=null) {
|
||||
outgoingMainRecordsList_<%=cid%> = java.util.Arrays.asList(data_<%=cid%>);
|
||||
}
|
||||
}
|
||||
<%
|
||||
}
|
||||
}
|
||||
} // canStart
|
||||
|
||||
@@ -258,76 +258,80 @@
|
||||
|
||||
com.google.api.services.bigquery.model.JobConfiguration config_<%=cid%> = new com.google.api.services.bigquery.model.JobConfiguration();
|
||||
com.google.api.services.bigquery.model.JobConfigurationLoad queryLoad_<%=cid%> = new com.google.api.services.bigquery.model.JobConfigurationLoad();
|
||||
com.google.api.services.bigquery.model.TableSchema schema_<%=cid%> = new com.google.api.services.bigquery.model.TableSchema();
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
log.info("<%=cid%> - Table field schema:");
|
||||
<%
|
||||
}
|
||||
%>
|
||||
java.util.List<com.google.api.services.bigquery.model.TableFieldSchema> fields_<%=cid%> = new java.util.ArrayList<com.google.api.services.bigquery.model.TableFieldSchema>();
|
||||
<%
|
||||
List<IMetadataTable> metadatas = node.getMetadataList();
|
||||
if ((metadatas!=null) && (metadatas.size() > 0)) {
|
||||
IMetadataTable metadata = metadatas.get(0);
|
||||
if (metadata != null) {
|
||||
List<IMetadataColumn> columns = metadata.getListColumns();
|
||||
int nbColumns = columns.size();
|
||||
for (int i = 0; i < nbColumns; i++ ) {
|
||||
IMetadataColumn column = columns.get(i);
|
||||
String columnName = column.getLabel();
|
||||
String typeToGenerate = "string";
|
||||
if("id_Float".equals(column.getTalendType()) || "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";
|
||||
|
||||
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.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__"))) {
|
||||
%>
|
||||
@@ -534,6 +538,7 @@
|
||||
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%>);
|
||||
|
||||
}
|
||||
|
||||
<%
|
||||
@@ -579,7 +584,7 @@
|
||||
|
||||
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)), com.google.cloud.RetryOption.totalTimeout(org.threeten.bp.Duration.ofSeconds(30)));
|
||||
job_<%=cid%> = job_<%=cid%>.waitFor(com.google.cloud.RetryOption.initialRetryDelay(org.threeten.bp.Duration.ofSeconds(1)));
|
||||
if (job_<%=cid%> != null && job_<%=cid%>.getStatus().getError() == null) {
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
@@ -598,4 +603,4 @@
|
||||
} else {
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\" or \"OAUTH\", but it is " + authMode);
|
||||
}
|
||||
%>
|
||||
%>
|
||||
|
||||
@@ -62,11 +62,12 @@ class BigQueryUtil_<%=cid%> {
|
||||
com.google.api.services.bigquery.model.JobConfigurationQuery queryConfig = new com.google.api.services.bigquery.model.JobConfigurationQuery();
|
||||
queryConfig.setQuery(query);
|
||||
queryConfig.setUseLegacySql(useLegacySql);
|
||||
String location = getLocation(queryConfig);
|
||||
if(useLargeResult){
|
||||
this.useLargeResult = true;
|
||||
tempDataset = genTempName("dataset");
|
||||
tempTable = genTempName("table");
|
||||
createDataset(getLocation(queryConfig));
|
||||
createDataset(location);
|
||||
queryConfig.setAllowLargeResults(true);
|
||||
queryConfig.setDestinationTable(new com.google.api.services.bigquery.model.TableReference()
|
||||
.setProjectId(projectId)
|
||||
@@ -131,7 +132,7 @@ class BigQueryUtil_<%=cid%> {
|
||||
%>
|
||||
// wait for query execution
|
||||
while (true) {
|
||||
com.google.api.services.bigquery.model.Job pollJob = bigqueryclient.jobs().get(projectId, jobId.getJobId()).execute();
|
||||
com.google.api.services.bigquery.model.Job pollJob = bigqueryclient.jobs().get(projectId, jobId.getJobId()).setLocation(location).execute();
|
||||
com.google.api.services.bigquery.model.JobStatus status = pollJob.getStatus();
|
||||
if (status.getState().equals("DONE")) {
|
||||
com.google.api.services.bigquery.model.ErrorProto errorProto = status.getErrorResult();
|
||||
|
||||
@@ -43,10 +43,8 @@
|
||||
JavaType javaType = JavaTypesManager.getJavaTypeFromId(column.getTalendType());
|
||||
String pattern = column.getPattern() == null || column.getPattern().trim().length() == 0 ? null : column.getPattern();
|
||||
if(JavaTypesManager.isJavaPrimitiveType( column.getTalendType(), column.isNullable())){
|
||||
%>
|
||||
if(<%=conn.getName() %>.<%=column.getLabel() %> != null) {
|
||||
<%
|
||||
if(javaType == JavaTypesManager.BOOLEAN ){
|
||||
|
||||
if(javaType == JavaTypesManager.BOOLEAN ){
|
||||
%>
|
||||
row_<%=cid%>[<%=i%>] = String.valueOf(
|
||||
true == <%=conn.getName() %>.<%=column.getLabel() %> ?"1":"0"
|
||||
@@ -56,12 +54,8 @@
|
||||
%>
|
||||
row_<%=cid%>[<%=i%>] = String.valueOf(<%=conn.getName() %>.<%=column.getLabel() %>);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
} else {
|
||||
row_<%=cid%>[<%=i%>] = null;
|
||||
}
|
||||
<%
|
||||
}
|
||||
|
||||
}else {
|
||||
%>
|
||||
if(<%=conn.getName() %>.<%=column.getLabel() %> != null){
|
||||
@@ -70,10 +64,24 @@
|
||||
%>
|
||||
row_<%=cid%>[<%=i%>] = <%=conn.getName() %>.<%=column.getLabel() %>;
|
||||
<%
|
||||
}else if(javaType == JavaTypesManager.DATE && pattern != null){
|
||||
%>
|
||||
row_<%=cid%>[<%=i%>] = FormatterUtils.format_Date(<%=conn.getName() %>.<%=column.getLabel() %>, "yyyy-MM-dd HH:mm:ss");
|
||||
}else if(javaType == JavaTypesManager.DATE && pattern == null){
|
||||
%>
|
||||
row_<%=cid%>[<%=i%>] = FormatterUtils.format_Date(<%=conn.getName() %>.<%=column.getLabel() %>, "yyyy-MM-dd");
|
||||
<%
|
||||
}else if(javaType == JavaTypesManager.DATE && pattern != null){
|
||||
if(pattern.length() > 12){
|
||||
%>
|
||||
row_<%=cid%>[<%=i%>] = FormatterUtils.format_Date(<%=conn.getName() %>.<%=column.getLabel() %>, "yyyy-MM-dd HH:mm:ss");
|
||||
<%
|
||||
}else if(pattern.length() == 12 || "\"\"".equals(pattern)) {
|
||||
%>
|
||||
row_<%=cid%>[<%=i%>] = FormatterUtils.format_Date(<%=conn.getName() %>.<%=column.getLabel() %>, "yyyy-MM-dd");
|
||||
<%
|
||||
}else {
|
||||
%>
|
||||
row_<%=cid%>[<%=i%>] = FormatterUtils.format_Date(<%=conn.getName() %>.<%=column.getLabel() %>, <%=pattern%>);
|
||||
<%
|
||||
}
|
||||
}else if(javaType == JavaTypesManager.BYTE_ARRAY){
|
||||
%>
|
||||
row_<%=cid%>[<%=i%>] = java.nio.charset.Charset.forName(<%=encoding %>).decode(java.nio.ByteBuffer.wrap(<%=conn.getName() %>.<%=column.getLabel() %>)).toString();
|
||||
@@ -92,7 +100,7 @@
|
||||
}
|
||||
%>
|
||||
} else {
|
||||
row_<%=cid%>[<%=i%>] = null;
|
||||
row_<%=cid%>[<%=i%>] = "\\N";
|
||||
}
|
||||
<%
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ imports="
|
||||
%>
|
||||
String driverClass_<%=cid%> = "<%=this.getDirverClassName(node)%>";
|
||||
java.lang.Class.forName(driverClass_<%=cid%>);
|
||||
globalMap.put("driverClass_<%=cid%>", driverClass_<%=cid%>);
|
||||
<%
|
||||
}
|
||||
|
||||
|
||||
@@ -165,6 +165,12 @@ imports="
|
||||
close_begin();
|
||||
%>
|
||||
conn_<%=cid%>.close();
|
||||
<% /* TESB-24900 - graceful shutdown for MYSQL connection */ %>
|
||||
if("com.mysql.cj.jdbc.Driver".equals((String)globalMap.get("driverClass_<%=(connection!=null)?connection.replaceAll("'","").trim():""%>"))
|
||||
&& routines.system.BundleUtils.inOSGi()) {
|
||||
Class.forName("com.mysql.cj.jdbc.AbandonedConnectionCleanupThread").
|
||||
getMethod("checkedShutdown").invoke(null, (Object[]) null);
|
||||
}
|
||||
<%
|
||||
close_end();
|
||||
}
|
||||
|
||||
@@ -758,6 +758,15 @@
|
||||
id="org.talend.designer.core.ui.preferences.migration.ChangeOracleVersionForProjectSetting"
|
||||
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
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.gef.palette.PaletteEntry;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
import org.talend.core.model.process.INode;
|
||||
import org.talend.core.model.process.IProcess;
|
||||
@@ -31,6 +32,7 @@ import org.talend.core.model.process.IReplaceNodeInProcess;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.JobletProcessItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryEditorInput;
|
||||
import org.talend.core.model.update.UpdateResult;
|
||||
import org.talend.designer.core.ui.editor.process.Process;
|
||||
|
||||
@@ -143,7 +145,7 @@ public abstract class AbstractProcessProvider implements IReplaceNodeInProcess {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DOC qzhang Comment method "canDeleteNode".
|
||||
*
|
||||
@@ -257,5 +259,10 @@ public abstract class AbstractProcessProvider implements IReplaceNodeInProcess {
|
||||
public boolean canHandleNode(INode node) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public IRepositoryEditorInput createJobletEditorInput(JobletProcessItem processItem, boolean load, Boolean lastVersion, Boolean readonly,
|
||||
Boolean openedInJob) throws PersistenceException{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@ import org.talend.core.model.update.IUpdateManager;
|
||||
import org.talend.core.model.utils.TalendTextUtils;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.repository.utils.ConvertJobsUtil;
|
||||
import org.talend.core.repository.utils.ProjectHelper;
|
||||
import org.talend.core.repository.utils.XmiResourceManager;
|
||||
import org.talend.core.runtime.repository.item.ItemProductKeys;
|
||||
import org.talend.core.runtime.util.ItemDateParser;
|
||||
@@ -1914,12 +1915,25 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
}
|
||||
}
|
||||
|
||||
for (IRepositoryViewObject object : routines) {
|
||||
if (routinesToAdd.contains(object.getLabel()) && !routinesAlreadySetup.contains(object.getLabel())) {
|
||||
RoutinesParameterType routinesParameterType = TalendFileFactory.eINSTANCE.createRoutinesParameterType();
|
||||
routinesParameterType.setId(object.getId());
|
||||
routinesParameterType.setName(object.getLabel());
|
||||
routinesDependencies.add(routinesParameterType);
|
||||
//
|
||||
boolean isLimited = false;
|
||||
org.talend.core.model.properties.Project currProject = getProject().getEmfProject();
|
||||
org.talend.core.model.properties.Project project = ProjectManager.getInstance().getProject(this.property);
|
||||
if (currProject != null && project != null && !currProject.equals(project)) {
|
||||
int currOrdinal = ProjectHelper.getProjectTypeOrdinal(currProject);
|
||||
int ordinal = ProjectHelper.getProjectTypeOrdinal(project);
|
||||
if (currOrdinal > ordinal) {
|
||||
isLimited = true;
|
||||
}
|
||||
}
|
||||
if (!isLimited) {
|
||||
for (IRepositoryViewObject object : routines) {
|
||||
if (routinesToAdd.contains(object.getLabel()) && !routinesAlreadySetup.contains(object.getLabel())) {
|
||||
RoutinesParameterType routinesParameterType = TalendFileFactory.eINSTANCE.createRoutinesParameterType();
|
||||
routinesParameterType.setId(object.getId());
|
||||
routinesParameterType.setName(object.getLabel());
|
||||
routinesDependencies.add(routinesParameterType);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (PersistenceException e) {
|
||||
@@ -4533,6 +4547,9 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
}
|
||||
|
||||
private void saveJobletNode(AbstractJobletContainer jobletContainer) {
|
||||
if (CommonsPlugin.isHeadless()) {
|
||||
return;
|
||||
}
|
||||
INode jobletNode = jobletContainer.getNode();
|
||||
IProcess jobletProcess = jobletNode.getComponent().getProcess();
|
||||
if (jobletProcess == null) {
|
||||
|
||||
@@ -587,6 +587,7 @@ public class MainComposite extends AbstractTabComposite {
|
||||
|| property == null) {
|
||||
return;
|
||||
}
|
||||
String oldVersion = repositoryObject.getVersion();
|
||||
String originalName = nameText.getText();
|
||||
String originalJobType = jobTypeCCombo.getText();
|
||||
String originalFramework = ConvertJobsUtil.convertFrameworkByJobType(originalJobType,
|
||||
@@ -779,6 +780,9 @@ public class MainComposite extends AbstractTabComposite {
|
||||
public void run(final IProgressMonitor monitor) throws CoreException {
|
||||
try {
|
||||
if (repositoryObject.getProperty() != null) {
|
||||
if (!originalversion.equals(StringUtils.trimToEmpty(oldVersion))) {
|
||||
RelationshipItemBuilder.getInstance().addOrUpdateItem(repositoryObject.getProperty().getItem());
|
||||
}
|
||||
proxyRepositoryFactory.save(ProjectManager.getInstance().getCurrentProject(),
|
||||
repositoryObject.getProperty().getItem(), false);
|
||||
if (needjobletRelateUpdate && GlobalServiceRegister.getDefault()
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.designer.core.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.model.components.ComponentUtilities;
|
||||
import org.talend.core.model.components.ModifyComponentsAction;
|
||||
import org.talend.core.model.components.conversions.IComponentConversion;
|
||||
import org.talend.core.model.components.filters.IComponentFilter;
|
||||
import org.talend.core.model.components.filters.NameComponentFilter;
|
||||
import org.talend.core.model.migration.AbstractItemMigrationTask;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.JobletProcessItem;
|
||||
import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.designer.core.DesignerPlugin;
|
||||
import org.talend.designer.core.model.components.EParameterName;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
|
||||
/**
|
||||
* Created by bhe on Nov 22, 2019
|
||||
*/
|
||||
public class FillTRunJobReferenceParametersMigrationTask extends AbstractItemMigrationTask {
|
||||
|
||||
@Override
|
||||
public List<ERepositoryObjectType> getTypes() {
|
||||
List<ERepositoryObjectType> toReturn = new ArrayList<ERepositoryObjectType>();
|
||||
toReturn.addAll(ERepositoryObjectType.getAllTypesOfProcess());
|
||||
toReturn.addAll(ERepositoryObjectType.getAllTypesOfProcess2());
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ExecutionResult execute(Item item) {
|
||||
ProcessType pt = null;
|
||||
if (item instanceof ProcessItem) {
|
||||
ProcessItem processItem = (ProcessItem) item;
|
||||
pt = processItem.getProcess();
|
||||
} else if (item instanceof JobletProcessItem) {
|
||||
JobletProcessItem jobletItem = (JobletProcessItem) item;
|
||||
pt = jobletItem.getJobletProcess();
|
||||
}
|
||||
|
||||
if (pt == null) {
|
||||
return ExecutionResult.NOTHING_TO_DO;
|
||||
}
|
||||
|
||||
IComponentFilter filter = new NameComponentFilter("tRunJob"); //$NON-NLS-1$
|
||||
try {
|
||||
ModifyComponentsAction.searchAndModify(item, pt, filter,
|
||||
Arrays.<IComponentConversion> asList(new IComponentConversion() {
|
||||
|
||||
@Override
|
||||
public void transform(NodeType node) {
|
||||
ElementParameterType jobId = ComponentUtilities.getNodeProperty(node,
|
||||
EParameterName.PROCESS.getName() + ":" + EParameterName.PROCESS_TYPE_PROCESS.getName()); //$NON-NLS-1$
|
||||
if (jobId.getValue() == null || jobId.getValue().isEmpty()) {
|
||||
ElementParameterType jobLabel = ComponentUtilities.getNodeProperty(node,
|
||||
EParameterName.PROCESS.getName()); // $NON-NLS-1$
|
||||
String id = getIdFormLabel(jobLabel.getValue());
|
||||
if (id != null && !id.isEmpty()) {
|
||||
jobId.setValue(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}));
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
return ExecutionResult.FAILURE;
|
||||
}
|
||||
|
||||
return ExecutionResult.SUCCESS_NO_ALERT;
|
||||
}
|
||||
|
||||
private static String getIdFormLabel(final String label) {
|
||||
if (label == null || label.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
final IProxyRepositoryFactory proxyRepositoryFactory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
|
||||
try {
|
||||
List<IRepositoryViewObject> allRepositoryObject = proxyRepositoryFactory.getAll(ERepositoryObjectType.PROCESS, true);
|
||||
for (IRepositoryViewObject repObject : allRepositoryObject) {
|
||||
Item item = repObject.getProperty().getItem();
|
||||
if (item != null && label.equals(item.getProperty().getLabel())) {
|
||||
return item.getProperty().getId();
|
||||
}
|
||||
}
|
||||
} catch (PersistenceException e) {
|
||||
//
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Date getOrder() {
|
||||
GregorianCalendar gc = new GregorianCalendar(2019, 11, 22, 12, 0, 0);
|
||||
return gc.getTime();
|
||||
}
|
||||
}
|
||||
@@ -677,7 +677,11 @@ public abstract class DbGenerationManager {
|
||||
query = query + " \""; //$NON-NLS-1$
|
||||
} else {
|
||||
if (query.trim().endsWith("+ \"")) { //$NON-NLS-1$
|
||||
query = query.substring(0, query.lastIndexOf("+ \"")); //$NON-NLS-1$
|
||||
if (DEFAULT_TAB_SPACE_STRING.equals(this.tabSpaceString)) {
|
||||
query = query.substring(0, query.lastIndexOf("+ \"")); //$NON-NLS-1$
|
||||
} else {
|
||||
query = query + "\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1173,7 +1177,11 @@ public abstract class DbGenerationManager {
|
||||
}
|
||||
}
|
||||
if(i % 2 == 0 && i != indexs.size() - 1){
|
||||
result.append(expression.substring(indexs.get(i), indexs.get(i+1)+1));
|
||||
result.append(expression.substring(indexs.get(i), indexs.get(i+1)+1));
|
||||
if (i < indexs.size() - 2) {
|
||||
String exp = expression.substring(indexs.get(i + 1) + 1, indexs.get(i + 2));
|
||||
result.append(exp.replaceAll(quoParser,"\\\\" +quote)); //$NON-NLS-1$
|
||||
}
|
||||
start = indexs.get(i+1)+1;
|
||||
}else if(i == indexs.size() - 1){
|
||||
String exp = expression.substring(indexs.get(i)+1, expression.length());
|
||||
|
||||
@@ -507,6 +507,8 @@ public class CompleteDropTargetTableListener extends DefaultDropTargetListener {
|
||||
|
||||
uiManager.selectLinks(dataMapTableViewTarget, selectedEntries, true, false);
|
||||
dataMapTableViewTarget.checkChangementsAfterEntryModifiedOrAdded(false);
|
||||
// refresh for cell data disappear on MAC
|
||||
tableViewerCreatorTarget.getTableViewer().refresh();
|
||||
tableViewerCreatorTarget.getTable().setFocus();
|
||||
|
||||
uiManager.setDragging(false);
|
||||
|
||||
@@ -48,6 +48,9 @@ import org.talend.core.ui.metadata.editor.MetadataToolbarEditorView;
|
||||
import org.talend.designer.mapper.MapperMain;
|
||||
import org.talend.designer.mapper.i18n.Messages;
|
||||
import org.talend.designer.mapper.managers.MapperManager;
|
||||
import org.talend.designer.mapper.model.table.InputTable;
|
||||
import org.talend.designer.mapper.model.table.OutputTable;
|
||||
import org.talend.designer.mapper.ui.visualmap.table.DataMapTableView;
|
||||
|
||||
/**
|
||||
* DOC amaumont class global comment. Detailled comment <br/>
|
||||
@@ -158,8 +161,20 @@ public class TabFolderEditors extends CTabFolder {
|
||||
|
||||
};
|
||||
|
||||
IExtendedButtonListener afterCommandListener = new IExtendedButtonListener() {
|
||||
|
||||
public void handleEvent(ExtendedButtonEvent event) {
|
||||
List<InputTable> inputTablesList = mapperManager.getInputTables();
|
||||
for (InputTable inputTable : inputTablesList) {
|
||||
DataMapTableView view = mapperManager.retrieveAbstractDataMapTableView(inputTable);
|
||||
view.getTableViewerCreatorForColumns().getTableViewer().refresh();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (ExtendedPushButton extendedPushButton : inputToolBarButtons) {
|
||||
extendedPushButton.addListener(beforeCommandListenerForInputButtons, true);
|
||||
extendedPushButton.addListener(afterCommandListener, false);
|
||||
}
|
||||
|
||||
this.addDisposeListener(new DisposeListener() {
|
||||
@@ -197,8 +212,20 @@ public class TabFolderEditors extends CTabFolder {
|
||||
|
||||
};
|
||||
|
||||
IExtendedButtonListener afterCommandListener = new IExtendedButtonListener() {
|
||||
|
||||
public void handleEvent(ExtendedButtonEvent event) {
|
||||
List<OutputTable> outputTablesList = mapperManager.getOutputTables();
|
||||
for (OutputTable outputTable : outputTablesList) {
|
||||
DataMapTableView view = mapperManager.retrieveAbstractDataMapTableView(outputTable);
|
||||
view.getTableViewerCreatorForColumns().getTableViewer().refresh();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (ExtendedPushButton extendedPushButton : outputToolBarButtons) {
|
||||
extendedPushButton.addListener(beforeCommandListenerForOutputButtons, true);
|
||||
extendedPushButton.addListener(afterCommandListener, false);
|
||||
if (extendedPushButton instanceof RemovePushButton && !mapperManager.componentIsReadOnly()) {
|
||||
removeButton = (RemovePushButtonForExtendedTable) extendedPushButton;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<outputDirectory>${file.separator}</outputDirectory>
|
||||
<includes>
|
||||
<include>${talend.job.path}/**/*.class</include>
|
||||
<include>${talend.job.path}/**/*.wsdl</include>
|
||||
<include>__tdm/**</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<outputDirectory>${file.separator}</outputDirectory>
|
||||
<includes>
|
||||
<include>${talend.job.path}/**/*.class</include>
|
||||
<include>${talend.job.path}/**/*.wsdl</include>
|
||||
<include>__tdm/**</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
|
||||
@@ -798,7 +798,7 @@ public class DefaultRunProcessService implements IRunProcessService {
|
||||
for (ProjectReference ref : references) {
|
||||
initRefPoms(new Project(ref.getReferencedProject()));
|
||||
}
|
||||
helper.updateRefProjectModules(references);
|
||||
helper.updateRefProjectModules(references, monitor);
|
||||
helper.updateCodeProjects(monitor, true);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
@@ -825,13 +825,17 @@ public class DefaultRunProcessService implements IRunProcessService {
|
||||
if (ProcessUtils.isRequiredBeans(null, refProject)) {
|
||||
installRefCodeProject(ERepositoryObjectType.valueOf("BEANS"), refHelper, monitor); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
deleteRefProjects(refProject, refHelper);
|
||||
|
||||
}
|
||||
|
||||
private void installRefCodeProject(ERepositoryObjectType codeType, AggregatorPomsHelper refHelper, IProgressMonitor monitor)
|
||||
throws Exception, CoreException {
|
||||
if (!refHelper.getProjectRootPom().exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String projectTechName = refHelper.getProjectTechName();
|
||||
ITalendProcessJavaProject codeProject = TalendJavaProjectManager.getExistingTalendCodeProject(codeType, projectTechName);
|
||||
if (codeProject != null) {
|
||||
@@ -840,6 +844,35 @@ public class DefaultRunProcessService implements IRunProcessService {
|
||||
argumentsMap.put(TalendProcessArgumentConstant.ARG_GOAL, TalendMavenConstants.GOAL_INSTALL);
|
||||
argumentsMap.put(TalendProcessArgumentConstant.ARG_PROGRAM_ARGUMENTS, TalendMavenConstants.ARG_MAIN_SKIP);
|
||||
codeProject.buildModules(monitor, null, argumentsMap);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteRefProjects(Project refProject, AggregatorPomsHelper refHelper) throws Exception {
|
||||
IProgressMonitor monitor = new NullProgressMonitor();
|
||||
|
||||
deleteRefProject(ERepositoryObjectType.ROUTINES, refHelper, monitor);
|
||||
|
||||
if (ProcessUtils.isRequiredPigUDFs(null, refProject)) {
|
||||
deleteRefProject(ERepositoryObjectType.PIG_UDF, refHelper, monitor);
|
||||
}
|
||||
|
||||
if (ProcessUtils.isRequiredBeans(null, refProject)) {
|
||||
deleteRefProject(ERepositoryObjectType.valueOf("BEANS"), refHelper, monitor); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void deleteRefProject(ERepositoryObjectType codeType, AggregatorPomsHelper refHelper, IProgressMonitor monitor)
|
||||
throws Exception, CoreException {
|
||||
|
||||
if (!refHelper.getProjectRootPom().exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String projectTechName = refHelper.getProjectTechName();
|
||||
ITalendProcessJavaProject codeProject = TalendJavaProjectManager.getExistingTalendCodeProject(codeType, projectTechName);
|
||||
|
||||
if (codeProject != null) {
|
||||
codeProject.getProject().delete(false, true, monitor);
|
||||
TalendJavaProjectManager.removeFromCodeJavaProjects(codeType, projectTechName);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ package org.talend.designer.runprocess;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -31,7 +32,6 @@ import org.talend.commons.exception.CommonExceptionHandler;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.exception.SystemException;
|
||||
import org.talend.commons.ui.runtime.exception.MessageBoxExceptionHandler;
|
||||
import org.talend.core.CorePlugin;
|
||||
import org.talend.core.model.process.IContainerEntry;
|
||||
import org.talend.core.model.process.IProcess;
|
||||
@@ -61,15 +61,17 @@ public class JobErrorsChecker {
|
||||
|
||||
public static List<IContainerEntry> getErrors() {
|
||||
List<IContainerEntry> input = new ArrayList<IContainerEntry>();
|
||||
|
||||
if(LastGenerationInfo.getInstance() == null ||
|
||||
LastGenerationInfo.getInstance().getLastMainJob() == null) {
|
||||
return input;
|
||||
}
|
||||
try {
|
||||
Item item = null;
|
||||
IProxyRepositoryFactory proxyRepositoryFactory = CorePlugin.getDefault().getRepositoryService()
|
||||
.getProxyRepositoryFactory();
|
||||
ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
|
||||
IProxyRepositoryFactory proxyRepositoryFactory =
|
||||
CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
|
||||
ITalendSynchronizer synchronizer =
|
||||
CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
|
||||
|
||||
Set<String> jobIds = new HashSet<String>();
|
||||
HashSet<JobInfo> jobInfos = new HashSet<>();
|
||||
@@ -94,14 +96,15 @@ public class JobErrorsChecker {
|
||||
}
|
||||
jobIds.add(item.getProperty().getId());
|
||||
|
||||
// Property property = process.getProperty();
|
||||
Problems.addJobRoutineFile(sourceFile, ProblemType.JOB, item, true);
|
||||
}
|
||||
if (!CommonsPlugin.isHeadless()) {
|
||||
List<IRepositoryViewObject> routinesObjects = proxyRepositoryFactory.getAll(ERepositoryObjectType.ROUTINES, false);
|
||||
Set<String> dependentRoutines = LastGenerationInfo.getInstance().getRoutinesNeededWithSubjobPerJob(
|
||||
LastGenerationInfo.getInstance().getLastMainJob().getJobId(),
|
||||
LastGenerationInfo.getInstance().getLastMainJob().getJobVersion());
|
||||
List<IRepositoryViewObject> routinesObjects =
|
||||
proxyRepositoryFactory.getAll(ERepositoryObjectType.ROUTINES, false);
|
||||
Set<String> dependentRoutines = LastGenerationInfo
|
||||
.getInstance()
|
||||
.getRoutinesNeededWithSubjobPerJob(LastGenerationInfo.getInstance().getLastMainJob().getJobId(),
|
||||
LastGenerationInfo.getInstance().getLastMainJob().getJobVersion());
|
||||
if (routinesObjects != null) {
|
||||
for (IRepositoryViewObject obj : routinesObjects) {
|
||||
Property property = obj.getProperty();
|
||||
@@ -110,7 +113,7 @@ public class JobErrorsChecker {
|
||||
IFile routineFile = synchronizer.getFile(routinesitem);
|
||||
Problems.addJobRoutineFile(routineFile, ProblemType.ROUTINE, routinesitem, true);
|
||||
} else {
|
||||
Problems.clearAllComliationError(property.getLabel());
|
||||
Problems.clearAllComliationError(property.getLabel());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,11 +156,11 @@ public class JobErrorsChecker {
|
||||
|
||||
public static boolean checkExportErrors(IStructuredSelection selection, boolean isJob) {
|
||||
if (!selection.isEmpty()) {
|
||||
final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService()
|
||||
.createRoutineSynchronizer();
|
||||
final ITalendSynchronizer synchronizer =
|
||||
CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
|
||||
Set<String> jobIds = new HashSet<String>();
|
||||
|
||||
List<RepositoryNode> nodes = selection.toList();
|
||||
List<RepositoryNode> nodes = extractNodes(selection);
|
||||
if (nodes.size() > 1) {
|
||||
// in case it's a multiple export, only check the status of the latest job to export
|
||||
for (RepositoryNode node : nodes) {
|
||||
@@ -189,22 +192,35 @@ public class JobErrorsChecker {
|
||||
}
|
||||
if (ret) {
|
||||
if (isJob) {
|
||||
throw new ProcessorException(Messages.getString("JobErrorsChecker_compile_errors") + '\n' + //$NON-NLS-1$
|
||||
Messages.getString("JobErrorsChecker_compile_error_content", item.getProperty() //$NON-NLS-1$
|
||||
.getLabel()) + '\n' + message);
|
||||
throw new ProcessorException(
|
||||
Messages.getString("JobErrorsChecker_compile_errors") + '\n' + //$NON-NLS-1$
|
||||
Messages
|
||||
.getString("JobErrorsChecker_compile_error_content", //$NON-NLS-1$
|
||||
item.getProperty().getLabel())
|
||||
+ '\n' + message);
|
||||
} else {
|
||||
throw new ProcessorException(Messages.getString("CamelJobErrorsChecker_compile_errors") + '\n' + //$NON-NLS-1$
|
||||
Messages.getString("CamelJobErrorsChecker_compile_error_content", item.getProperty() //$NON-NLS-1$
|
||||
.getLabel()) + '\n' + message);
|
||||
throw new ProcessorException(
|
||||
Messages.getString("CamelJobErrorsChecker_compile_errors") + '\n' + //$NON-NLS-1$
|
||||
Messages
|
||||
.getString("CamelJobErrorsChecker_compile_error_content", //$NON-NLS-1$
|
||||
item.getProperty().getLabel())
|
||||
+ '\n' + message);
|
||||
}
|
||||
}
|
||||
|
||||
jobIds.add(item.getProperty().getId());
|
||||
|
||||
Problems.addRoutineFile(sourceFile, ProblemType.JOB, item.getProperty().getLabel(), item.getProperty()
|
||||
.getVersion(), true);
|
||||
Problems
|
||||
.addRoutineFile(sourceFile, ProblemType.JOB, item.getProperty().getLabel(),
|
||||
item.getProperty().getVersion(), true);
|
||||
} catch (Exception e) {
|
||||
MessageBoxExceptionHandler.process(e);
|
||||
CommonExceptionHandler.process(e);
|
||||
if (CommonsPlugin.isHeadless()) {
|
||||
// [TESB-8953] avoid SWT invoked and also throw Exception let Command Executor to have
|
||||
// detailed
|
||||
// trace in command status.
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -214,13 +230,12 @@ public class JobErrorsChecker {
|
||||
try {
|
||||
checkLastGenerationHasCompilationError(true);
|
||||
} catch (Exception e) {
|
||||
CommonExceptionHandler.process(e);
|
||||
if (CommonsPlugin.isHeadless()) {
|
||||
CommonExceptionHandler.process(e);
|
||||
// [TESB-8953] avoid SWT invoked and also throw Exception let Command Executor to have detailed
|
||||
// trace in command status.
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
MessageBoxExceptionHandler.process(e);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -249,7 +264,12 @@ public class JobErrorsChecker {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MessageBoxExceptionHandler.process(e);
|
||||
CommonExceptionHandler.process(e);
|
||||
if (CommonsPlugin.isHeadless()) {
|
||||
// [TESB-8953] avoid SWT invoked and also throw Exception let Command Executor to have detailed
|
||||
// trace in command status.
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -264,9 +284,10 @@ public class JobErrorsChecker {
|
||||
boolean hasError = false;
|
||||
boolean isJob = true;
|
||||
Item item = null;
|
||||
final IProxyRepositoryFactory proxyRepositoryFactory = CorePlugin.getDefault().getRepositoryService()
|
||||
.getProxyRepositoryFactory();
|
||||
final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
|
||||
final IProxyRepositoryFactory proxyRepositoryFactory =
|
||||
CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
|
||||
final ITalendSynchronizer synchronizer =
|
||||
CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
|
||||
Integer line = null;
|
||||
String errorMessage = null;
|
||||
try {
|
||||
@@ -299,7 +320,7 @@ public class JobErrorsChecker {
|
||||
// one job
|
||||
final IResource[] members = file.getParent().members();
|
||||
for (IResource member : members) {
|
||||
if (member instanceof IFile && "java".equals(member.getFileExtension())) {
|
||||
if (member instanceof IFile && "java".equals(member.getFileExtension())) { //$NON-NLS-1$
|
||||
IMarker[] markers = ((IFile) member).findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ONE);
|
||||
for (IMarker marker : markers) {
|
||||
Integer lineNr = (Integer) marker.getAttribute(IMarker.LINE_NUMBER);
|
||||
@@ -322,8 +343,9 @@ public class JobErrorsChecker {
|
||||
}
|
||||
}
|
||||
if (updateProblemsView) {
|
||||
Problems.addRoutineFile(file, ProblemType.JOB, item.getProperty().getLabel(),
|
||||
item.getProperty().getVersion(), true);
|
||||
Problems
|
||||
.addRoutineFile(file, ProblemType.JOB, item.getProperty().getLabel(),
|
||||
item.getProperty().getVersion(), true);
|
||||
}
|
||||
if (hasError) {
|
||||
break;
|
||||
@@ -335,17 +357,17 @@ public class JobErrorsChecker {
|
||||
}
|
||||
if (hasError && item != null) {
|
||||
if (isJob) {
|
||||
throw new ProcessorException(Messages.getString("JobErrorsChecker_compile_errors") + " " + '\n' + //$NON-NLS-1$
|
||||
Messages.getString("JobErrorsChecker_compile_error_message", item.getProperty().getLabel()) + '\n' //$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + '\n' //$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage + '\n' //$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_jvmmessage")); //$NON-NLS-1$
|
||||
throw new ProcessorException(Messages.getString("JobErrorsChecker_compile_errors") + ' ' + '\n' + //$NON-NLS-1$
|
||||
Messages.getString("JobErrorsChecker_compile_error_message", item.getProperty().getLabel()) //$NON-NLS-1$
|
||||
+ '\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + '\n' //$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage //$NON-NLS-1$
|
||||
+ '\n' + Messages.getString("JobErrorsChecker_compile_error_jvmmessage")); //$NON-NLS-1$
|
||||
} else {
|
||||
throw new ProcessorException(Messages.getString("CamelJobErrorsChecker_compile_errors") + " " + '\n' + //$NON-NLS-1$
|
||||
Messages.getString("JobErrorsChecker_compile_error_message", item.getProperty().getLabel()) + '\n' //$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + '\n' //$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage + '\n' //$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_jvmmessage")); //$NON-NLS-1$
|
||||
throw new ProcessorException(Messages.getString("CamelJobErrorsChecker_compile_errors") + ' ' + '\n' + //$NON-NLS-1$
|
||||
Messages.getString("JobErrorsChecker_compile_error_message", item.getProperty().getLabel()) //$NON-NLS-1$
|
||||
+ '\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + '\n' //$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage //$NON-NLS-1$
|
||||
+ '\n' + Messages.getString("JobErrorsChecker_compile_error_jvmmessage")); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,6 +378,7 @@ public class JobErrorsChecker {
|
||||
}
|
||||
|
||||
private static void checkRoutinesCompilationError() throws ProcessorException {
|
||||
|
||||
if(LastGenerationInfo.getInstance() == null || LastGenerationInfo.getInstance().getLastMainJob() == null) {
|
||||
return;
|
||||
}
|
||||
@@ -368,32 +391,35 @@ public class JobErrorsChecker {
|
||||
for (Problem p : errors) {
|
||||
if (p instanceof TalendProblem) {
|
||||
TalendProblem talendProblem = (TalendProblem) p;
|
||||
if (talendProblem.getType() == ProblemType.ROUTINE && dependentRoutines.contains(talendProblem.getJavaUnitName())) {
|
||||
if (talendProblem.getType() == ProblemType.ROUTINE
|
||||
&& dependentRoutines.contains(talendProblem.getJavaUnitName())) {
|
||||
int line = talendProblem.getLineNumber();
|
||||
String errorMessage = talendProblem.getDescription();
|
||||
throw new ProcessorException(Messages.getString(
|
||||
"JobErrorsChecker_routines_compile_errors", talendProblem.getJavaUnitName()) + '\n'//$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + '\n' //$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage); //$NON-NLS-1$
|
||||
throw new ProcessorException(Messages
|
||||
.getString("JobErrorsChecker_routines_compile_errors", talendProblem.getJavaUnitName()) //$NON-NLS-1$
|
||||
+ '\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + '\n' //$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' //$NON-NLS-1$
|
||||
+ errorMessage);
|
||||
}
|
||||
} else {
|
||||
// for now not to check components errors when building jobs in studio/commandline
|
||||
// throw new ProcessorException(Messages.getString("JobErrorsChecker_jobDesign_errors", p.getType().getTypeName(), //$NON-NLS-1$
|
||||
// p.getJobInfo().getJobName(), p.getComponentName(), p.getDescription()));
|
||||
// throw new ProcessorException(Messages.getString("JobErrorsChecker_jobDesign_errors",
|
||||
// p.getType().getTypeName(), //$NON-NLS-1$
|
||||
// p.getJobInfo().getJobName(), p.getComponentName(), p.getDescription()));
|
||||
}
|
||||
}
|
||||
|
||||
// if can't find the routines problem, try to check the file directly(mainly for commandline)
|
||||
try {
|
||||
final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService()
|
||||
.createRoutineSynchronizer();
|
||||
final ITalendSynchronizer synchronizer =
|
||||
CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
|
||||
IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
|
||||
List<IRepositoryViewObject> routinesObjects = factory.getAll(ERepositoryObjectType.ROUTINES, false);
|
||||
if (routinesObjects != null) {
|
||||
for (IRepositoryViewObject obj : routinesObjects) {
|
||||
Property property = obj.getProperty();
|
||||
if (!dependentRoutines.contains(property.getLabel())) {
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
Item routinesitem = property.getItem();
|
||||
IFile routinesFile = synchronizer.getFile(routinesitem);
|
||||
@@ -407,10 +433,12 @@ public class JobErrorsChecker {
|
||||
if (lineNr != null && message != null && severity != null && start != null && end != null) {
|
||||
switch (severity) {
|
||||
case IMarker.SEVERITY_ERROR:
|
||||
throw new ProcessorException(
|
||||
Messages.getString("JobErrorsChecker_routines_compile_errors", property.getLabel()) + '\n'//$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + lineNr + '\n' //$NON-NLS-1$
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + message); //$NON-NLS-1$
|
||||
throw new ProcessorException(Messages
|
||||
.getString("JobErrorsChecker_routines_compile_errors", property.getLabel()) //$NON-NLS-1$
|
||||
+ '\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' //$NON-NLS-1$
|
||||
+ lineNr + '\n'
|
||||
+ Messages.getString("JobErrorsChecker_compile_error_detailmessage") //$NON-NLS-1$
|
||||
+ ':' + ' ' + message);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -427,11 +455,11 @@ public class JobErrorsChecker {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected static void checkSubJobMultipleVersionsError() throws ProcessorException {
|
||||
if(LastGenerationInfo.getInstance() == null || LastGenerationInfo.getInstance().getLastGeneratedjobs() == null) {
|
||||
return;
|
||||
}
|
||||
if (LastGenerationInfo.getInstance() == null
|
||||
|| LastGenerationInfo.getInstance().getLastGeneratedjobs() == null) {
|
||||
return;
|
||||
}
|
||||
Set<JobInfo> jobInfos = LastGenerationInfo.getInstance().getLastGeneratedjobs();
|
||||
Map<String, Set<String>> jobInfoMap = new HashMap<>();
|
||||
for (JobInfo jobInfo : jobInfos) {
|
||||
@@ -458,4 +486,14 @@ public class JobErrorsChecker {
|
||||
}
|
||||
}
|
||||
|
||||
private static List<RepositoryNode> extractNodes(IStructuredSelection selection) {
|
||||
List<RepositoryNode> nodes = new ArrayList<>();
|
||||
for (Iterator<?> iterator = selection.iterator(); iterator.hasNext();) {
|
||||
Object o = iterator.next();
|
||||
if (o instanceof RepositoryNode)
|
||||
nodes.add((RepositoryNode) o);
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -125,6 +125,8 @@ public class ProcessChangeListener implements PropertyChangeListener {
|
||||
// version change, will create new item
|
||||
// create new job project.
|
||||
TalendJavaProjectManager.generatePom(property.getItem());
|
||||
AggregatorPomsHelper helper = new AggregatorPomsHelper();
|
||||
helper.syncParentJobPomsForPropertyChange(property);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.Priority;
|
||||
import org.apache.oro.text.regex.MalformedPatternException;
|
||||
import org.apache.oro.text.regex.MatchResult;
|
||||
import org.apache.oro.text.regex.Pattern;
|
||||
@@ -54,8 +55,9 @@ import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.talend.commons.CommonsPlugin;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.commons.ui.swt.formtools.Form;
|
||||
import org.talend.commons.ui.swt.formtools.LabelledCombo;
|
||||
import org.talend.commons.ui.swt.formtools.LabelledFileField;
|
||||
@@ -79,6 +81,7 @@ import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.json.i18n.Messages;
|
||||
import org.talend.repository.json.util.JSONUtil;
|
||||
import org.talend.repository.ui.wizards.metadata.connection.files.xml.TreePopulator;
|
||||
|
||||
import orgomg.cwm.resource.record.RecordFactory;
|
||||
import orgomg.cwm.resource.record.RecordFile;
|
||||
|
||||
@@ -151,7 +154,7 @@ public class JSONFileOutputStep1Form extends AbstractJSONFileStepForm {
|
||||
}
|
||||
if (JSONFileOutputStep1Form.this.tempPath == null) {
|
||||
if (jsonXmlPath != null && !jsonXmlPath.equals("")) {
|
||||
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(jsonXmlPath);
|
||||
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(jsonXmlPath, getConnection().getEncoding());
|
||||
} else {
|
||||
JSONFileOutputStep1Form.this.tempPath = "";
|
||||
}
|
||||
@@ -315,7 +318,7 @@ public class JSONFileOutputStep1Form extends AbstractJSONFileStepForm {
|
||||
|
||||
List<FOXTreeNode> rootFoxTreeNodes = null;
|
||||
if (JSONFileOutputStep1Form.this.tempPath == null) {
|
||||
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(text);
|
||||
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(text, getConnection().getEncoding());
|
||||
}
|
||||
if (treeNode == null) {
|
||||
rootFoxTreeNodes = TreeUtil.getFoxTreeNodes(JSONFileOutputStep1Form.this.tempPath);
|
||||
@@ -362,12 +365,12 @@ public class JSONFileOutputStep1Form extends AbstractJSONFileStepForm {
|
||||
}
|
||||
// getConnection().setJSONFilePath(PathUtils.getPortablePath(JSONXsdFilePath.getText()));
|
||||
if (JSONFileOutputStep1Form.this.tempPath == null) {
|
||||
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(text);
|
||||
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(text, getConnection().getEncoding());
|
||||
}
|
||||
File file = new File(text);
|
||||
if (file.exists()) {
|
||||
List<ATreeNode> treeNodes = new ArrayList<ATreeNode>();
|
||||
valid = treePopulator.populateTree(JSONUtil.changeJsonToXml(text), treeNode);
|
||||
valid = treePopulator.populateTree(JSONUtil.changeJsonToXml(text, getConnection().getEncoding()), treeNode);
|
||||
checkFieldsValue();
|
||||
if (!valid) {
|
||||
return;
|
||||
@@ -391,130 +394,7 @@ public class JSONFileOutputStep1Form extends AbstractJSONFileStepForm {
|
||||
|
||||
@Override
|
||||
public void modifyText(ModifyEvent event) {
|
||||
String text = jsonFilePath.getText();
|
||||
if (isContextMode()) {
|
||||
ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(
|
||||
connectionItem.getConnection(), true);
|
||||
text = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType, text));
|
||||
}
|
||||
|
||||
if (getConnection().getJSONFilePath() != null && !getConnection().getJSONFilePath().equals(text)) {
|
||||
getConnection().getLoop().clear();
|
||||
getConnection().getRoot().clear();
|
||||
getConnection().getGroup().clear();
|
||||
xsdPathChanged = true;
|
||||
} else {
|
||||
xsdPathChanged = false;
|
||||
}
|
||||
if (Path.fromOSString(jsonFilePath.getText()).toFile().isFile()) {
|
||||
getConnection().setJSONFilePath(PathUtils.getPortablePath(jsonFilePath.getText()));
|
||||
} else {
|
||||
getConnection().setJSONFilePath(jsonFilePath.getText());
|
||||
}
|
||||
|
||||
// updateConnection(text);
|
||||
|
||||
StringBuilder fileContent = new StringBuilder();
|
||||
BufferedReader in = null;
|
||||
File file = null;
|
||||
if (tempJSONPath != null && getConnection().getFileContent() != null
|
||||
&& getConnection().getFileContent().length > 0 && !isModifing) {
|
||||
file = new File(tempJSONPath);
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e2) {
|
||||
ExceptionHandler.process(e2);
|
||||
}
|
||||
FileOutputStream outStream;
|
||||
try {
|
||||
outStream = new FileOutputStream(file);
|
||||
outStream.write(getConnection().getFileContent());
|
||||
outStream.close();
|
||||
} catch (FileNotFoundException e1) {
|
||||
ExceptionHandler.process(e1);
|
||||
} catch (IOException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
file = new File(text);
|
||||
}
|
||||
String str;
|
||||
try {
|
||||
Charset guessCharset = CharsetToolkit.guessEncoding(file, 4096);
|
||||
in = new BufferedReader(new InputStreamReader(new FileInputStream(file), guessCharset.displayName()));
|
||||
|
||||
while ((str = in.readLine()) != null) {
|
||||
fileContent.append(str + "\n");
|
||||
// for encoding
|
||||
if (str.contains("encoding")) {
|
||||
String regex = "^<\\?JSON\\s*version=\\\"[^\\\"]*\\\"\\s*encoding=\\\"([^\\\"]*)\\\"\\?>$";
|
||||
Perl5Compiler compiler = new Perl5Compiler();
|
||||
Perl5Matcher matcher = new Perl5Matcher();
|
||||
Pattern pattern = null;
|
||||
try {
|
||||
pattern = compiler.compile(regex);
|
||||
if (matcher.contains(str, pattern)) {
|
||||
MatchResult matchResult = matcher.getMatch();
|
||||
if (matchResult != null) {
|
||||
encoding = matchResult.group(1);
|
||||
}
|
||||
}
|
||||
} catch (MalformedPatternException malE) {
|
||||
ExceptionHandler.process(malE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fileContentText.setText(new String(fileContent));
|
||||
|
||||
} catch (Exception e) {
|
||||
String msgError = "File" + " \"" + jsonFilePath.getText().replace("\\\\", "\\") + "\"\n";
|
||||
if (e instanceof FileNotFoundException) {
|
||||
msgError = msgError + "is not found";
|
||||
} else if (e instanceof EOFException) {
|
||||
msgError = msgError + "have an incorrect character EOF";
|
||||
} else if (e instanceof IOException) {
|
||||
msgError = msgError + "is locked by another soft";
|
||||
} else {
|
||||
msgError = msgError + "doesn't exist";
|
||||
}
|
||||
fileContentText.setText(msgError);
|
||||
if (!isReadOnly()) {
|
||||
updateStatus(IStatus.ERROR, msgError);
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
ExceptionHandler.process(exception);
|
||||
}
|
||||
}
|
||||
if (getConnection().getEncoding() == null || "".equals(getConnection().getEncoding())) {
|
||||
getConnection().setEncoding(encoding);
|
||||
if (encoding != null && !"".equals(encoding)) {
|
||||
encodingCombo.setText(encoding);
|
||||
} else {
|
||||
encodingCombo.setText("UTF-8");
|
||||
}
|
||||
}
|
||||
|
||||
// if (tempJSONXsdPath != null && getConnection().getFileContent() != null
|
||||
// && getConnection().getFileContent().length > 0 && !isModifing) {
|
||||
// valid = treePopulator.populateTree(tempJSONXsdPath, treeNode);
|
||||
// } else {
|
||||
// valid = treePopulator.populateTree(text, treeNode);
|
||||
// }
|
||||
if (file.exists()) {
|
||||
valid = treePopulator.populateTree(JSONUtil.changeJsonToXml(text), treeNode);
|
||||
updateConnection(text);
|
||||
}
|
||||
checkFieldsValue();
|
||||
isModifing = true;
|
||||
validateJsonFile();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -523,6 +403,16 @@ public class JSONFileOutputStep1Form extends AbstractJSONFileStepForm {
|
||||
@Override
|
||||
public void modifyText(ModifyEvent e) {
|
||||
getConnection().setEncoding(encodingCombo.getText());
|
||||
String encoding = getConnection().getEncoding();
|
||||
try {
|
||||
Charset charSet = Charset.forName(encoding);
|
||||
if (charSet != null) {
|
||||
validateJsonFile();
|
||||
return;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// ignore
|
||||
}
|
||||
checkFieldsValue();
|
||||
}
|
||||
});
|
||||
@@ -540,7 +430,8 @@ public class JSONFileOutputStep1Form extends AbstractJSONFileStepForm {
|
||||
labelLimitation.setToolTipText(MessageFormat.format(Messages.JSONLimitToolTip, str));
|
||||
}
|
||||
if (JSONFileOutputStep1Form.this.tempPath == null) {
|
||||
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(jsonFilePath.getText());
|
||||
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(jsonFilePath.getText(),
|
||||
getConnection().getEncoding());
|
||||
}
|
||||
|
||||
File file = new File(JSONFileOutputStep1Form.this.tempPath);
|
||||
@@ -779,4 +670,141 @@ public class JSONFileOutputStep1Form extends AbstractJSONFileStepForm {
|
||||
// valid = this.treePopulator.populateTree(tempJSONXsdPath, treeNode);
|
||||
|
||||
}
|
||||
|
||||
private void validateJsonFile() {
|
||||
String text = jsonFilePath.getText();
|
||||
if (isContextMode()) {
|
||||
ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(
|
||||
connectionItem.getConnection(), true);
|
||||
text = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType, text));
|
||||
}
|
||||
|
||||
if (getConnection().getJSONFilePath() != null && !getConnection().getJSONFilePath().equals(text)) {
|
||||
getConnection().getLoop().clear();
|
||||
getConnection().getRoot().clear();
|
||||
getConnection().getGroup().clear();
|
||||
xsdPathChanged = true;
|
||||
} else {
|
||||
xsdPathChanged = false;
|
||||
}
|
||||
if (Path.fromOSString(jsonFilePath.getText()).toFile().isFile()) {
|
||||
getConnection().setJSONFilePath(PathUtils.getPortablePath(jsonFilePath.getText()));
|
||||
} else {
|
||||
getConnection().setJSONFilePath(jsonFilePath.getText());
|
||||
}
|
||||
|
||||
// updateConnection(text);
|
||||
|
||||
StringBuilder fileContent = new StringBuilder();
|
||||
BufferedReader in = null;
|
||||
File file = null;
|
||||
if (tempJSONPath != null && getConnection().getFileContent() != null
|
||||
&& getConnection().getFileContent().length > 0 && !isModifing) {
|
||||
file = new File(tempJSONPath);
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e2) {
|
||||
ExceptionHandler.process(e2);
|
||||
}
|
||||
FileOutputStream outStream;
|
||||
try {
|
||||
outStream = new FileOutputStream(file);
|
||||
outStream.write(getConnection().getFileContent());
|
||||
outStream.close();
|
||||
} catch (FileNotFoundException e1) {
|
||||
ExceptionHandler.process(e1);
|
||||
} catch (IOException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
file = new File(text);
|
||||
}
|
||||
String str;
|
||||
try {
|
||||
Charset guessCharset = null;
|
||||
try {
|
||||
guessCharset = Charset.forName(getConnection().getEncoding());
|
||||
} catch (Exception e) {
|
||||
if (CommonsPlugin.isDebugMode()) {
|
||||
ExceptionHandler.process(e, Priority.INFO);
|
||||
}
|
||||
}
|
||||
if (guessCharset == null) {
|
||||
guessCharset = CharsetToolkit.guessEncoding(file, 4096);
|
||||
}
|
||||
in = new BufferedReader(new InputStreamReader(new FileInputStream(file), guessCharset.displayName()));
|
||||
|
||||
while ((str = in.readLine()) != null) {
|
||||
fileContent.append(str + "\n");
|
||||
// for encoding
|
||||
if (str.contains("encoding")) {
|
||||
String regex = "^<\\?JSON\\s*version=\\\"[^\\\"]*\\\"\\s*encoding=\\\"([^\\\"]*)\\\"\\?>$";
|
||||
Perl5Compiler compiler = new Perl5Compiler();
|
||||
Perl5Matcher matcher = new Perl5Matcher();
|
||||
Pattern pattern = null;
|
||||
try {
|
||||
pattern = compiler.compile(regex);
|
||||
if (matcher.contains(str, pattern)) {
|
||||
MatchResult matchResult = matcher.getMatch();
|
||||
if (matchResult != null) {
|
||||
encoding = matchResult.group(1);
|
||||
}
|
||||
}
|
||||
} catch (MalformedPatternException malE) {
|
||||
ExceptionHandler.process(malE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fileContentText.setText(new String(fileContent));
|
||||
|
||||
} catch (Exception e) {
|
||||
String msgError = "File" + " \"" + jsonFilePath.getText().replace("\\\\", "\\") + "\"\n";
|
||||
if (e instanceof FileNotFoundException) {
|
||||
msgError = msgError + "is not found";
|
||||
} else if (e instanceof EOFException) {
|
||||
msgError = msgError + "have an incorrect character EOF";
|
||||
} else if (e instanceof IOException) {
|
||||
msgError = msgError + "is locked by another soft";
|
||||
} else {
|
||||
msgError = msgError + "doesn't exist";
|
||||
}
|
||||
fileContentText.setText(msgError);
|
||||
if (!isReadOnly()) {
|
||||
updateStatus(IStatus.ERROR, msgError);
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
ExceptionHandler.process(exception);
|
||||
}
|
||||
}
|
||||
if (getConnection().getEncoding() == null || "".equals(getConnection().getEncoding())) {
|
||||
getConnection().setEncoding(encoding);
|
||||
if (encoding != null && !"".equals(encoding)) {
|
||||
encodingCombo.setText(encoding);
|
||||
} else {
|
||||
encodingCombo.setText("UTF-8");
|
||||
}
|
||||
}
|
||||
|
||||
// if (tempJSONXsdPath != null && getConnection().getFileContent() != null
|
||||
// && getConnection().getFileContent().length > 0 && !isModifing) {
|
||||
// valid = treePopulator.populateTree(tempJSONXsdPath, treeNode);
|
||||
// } else {
|
||||
// valid = treePopulator.populateTree(text, treeNode);
|
||||
// }
|
||||
if (file.exists()) {
|
||||
valid = treePopulator.populateTree(JSONUtil.changeJsonToXml(text, getConnection().getEncoding()), treeNode);
|
||||
updateConnection(text);
|
||||
}
|
||||
checkFieldsValue();
|
||||
isModifing = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ public class JSONFileStep1Form extends AbstractJSONFileStepForm {
|
||||
if (JSONFileStep1Form.this.wizard.getTempJsonPath() == null
|
||||
|| JSONFileStep1Form.this.wizard.getTempJsonPath().length() == 0) {
|
||||
if (EJsonReadbyMode.XPATH.getValue().equals(JSONFileStep1Form.this.wizard.getReadbyMode())) {
|
||||
tempxml = JSONUtil.changeJsonToXml(jsonFilePath);
|
||||
tempxml = JSONUtil.changeJsonToXml(jsonFilePath, getConnection().getEncoding());
|
||||
} else {
|
||||
tempxml = jsonFilePath;
|
||||
}
|
||||
@@ -271,6 +271,7 @@ public class JSONFileStep1Form extends AbstractJSONFileStepForm {
|
||||
treePopulator.setLimit(limit);
|
||||
this.treePopulator.configureDefaultTreeViewer();
|
||||
if (filePath != null && !filePath.isEmpty()) {
|
||||
this.treePopulator.setEncoding(getConnection().getEncoding());
|
||||
valid = this.treePopulator.populateTree(filePath, treeNode);
|
||||
}
|
||||
}
|
||||
@@ -506,7 +507,7 @@ public class JSONFileStep1Form extends AbstractJSONFileStepForm {
|
||||
if (EJsonReadbyMode.JSONPATH.getValue().equals(readbyMode)) {
|
||||
tempxml = text;
|
||||
} else {
|
||||
tempxml = JSONUtil.changeJsonToXml(text);
|
||||
tempxml = JSONUtil.changeJsonToXml(text, getConnection().getEncoding());
|
||||
}
|
||||
JSONFileStep1Form.this.wizard.setTempJsonPath(tempxml);
|
||||
switchPopulator(readbyMode, tempxml);
|
||||
@@ -518,170 +519,7 @@ public class JSONFileStep1Form extends AbstractJSONFileStepForm {
|
||||
|
||||
@Override
|
||||
public void modifyText(final ModifyEvent e) {
|
||||
String jsonPath = fileFieldJSON.getText();
|
||||
String _jsonPath = jsonPath;
|
||||
if (isContextMode()) {
|
||||
ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(
|
||||
connectionItem.getConnection(), connectionItem.getConnection().getContextName());
|
||||
jsonPath = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType,
|
||||
jsonPath));
|
||||
|
||||
}
|
||||
String text = validateJsonFilePath(jsonPath);
|
||||
if (text == null || text.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String tempxml = null;
|
||||
String readbyMode = JSONFileStep1Form.this.wizard.getReadbyMode();
|
||||
|
||||
if (EJsonReadbyMode.JSONPATH.getValue().equals(readbyMode)) {
|
||||
tempxml = text;
|
||||
} else {
|
||||
tempxml = JSONUtil.changeJsonToXml(text);
|
||||
}
|
||||
File file = new File(text);
|
||||
if (!file.exists()) {
|
||||
file = new File(JSONUtil.tempJSONXsdPath);
|
||||
}
|
||||
JSONFileStep1Form.this.wizard.setTempJsonPath(tempxml);
|
||||
String limitString = commonNodesLimitation.getText();
|
||||
try {
|
||||
limit = Integer.valueOf(limitString);
|
||||
labelLimitation.setToolTipText(MessageFormat.format(Messages.JSONLimitToolTip, limit));
|
||||
} catch (Exception excpt) {
|
||||
// nothing need to do
|
||||
}
|
||||
switchPopulator(readbyMode, tempxml);
|
||||
// }
|
||||
// add for bug TDI-20432
|
||||
checkFieldsValue();
|
||||
// }
|
||||
|
||||
// String text = fileFieldJSON.getText();
|
||||
// File temp = new File(text);
|
||||
// if (!temp.exists()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (getConnection().getJSONFilePath() != null && !getConnection().getJSONFilePath().equals(text)) {
|
||||
getConnection().getLoop().clear();
|
||||
xsdPathChanged = true;
|
||||
} else {
|
||||
xsdPathChanged = false;
|
||||
}
|
||||
|
||||
if (isContextMode()) {
|
||||
jsonPath = _jsonPath;
|
||||
}
|
||||
if (Path.fromOSString(jsonPath).toFile().isFile()) {
|
||||
getConnection().setJSONFilePath(PathUtils.getPortablePath(jsonPath));
|
||||
} else {
|
||||
getConnection().setJSONFilePath(jsonPath);
|
||||
}
|
||||
|
||||
JSONWizard wizard = ((JSONWizard) getPage().getWizard());
|
||||
wizard.setTreeRootNode(treeNode);
|
||||
|
||||
BufferedReader in = null;
|
||||
|
||||
// File file = null;
|
||||
//
|
||||
// if (tempJSONXsdPath != null && getConnection().getFileContent() != null
|
||||
// && getConnection().getFileContent().length > 0 && !isModifing) {
|
||||
// file = new File(tempJSONXsdPath);
|
||||
// if (!file.exists()) {
|
||||
// try {
|
||||
// file.createNewFile();
|
||||
// } catch (IOException e2) {
|
||||
// ExceptionHandler.process(e2);
|
||||
// }
|
||||
// FileOutputStream outStream;
|
||||
// try {
|
||||
// outStream = new FileOutputStream(file);
|
||||
// outStream.write(getConnection().getFileContent());
|
||||
// outStream.close();
|
||||
// } catch (FileNotFoundException e1) {
|
||||
// ExceptionHandler.process(e1);
|
||||
// } catch (IOException e3) {
|
||||
// ExceptionHandler.process(e3);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// } else {
|
||||
// file = new File(text);
|
||||
// }
|
||||
|
||||
// setFileContent(file);
|
||||
// }
|
||||
|
||||
try {
|
||||
|
||||
Charset guessedCharset = CharsetToolkit.guessEncoding(file, 4096);
|
||||
String str;
|
||||
in = new BufferedReader(new InputStreamReader(new FileInputStream(file), guessedCharset.displayName()));
|
||||
while ((str = in.readLine()) != null) {
|
||||
if (str.contains("encoding")) { //$NON-NLS-1$
|
||||
String regex = "^<\\?JSON\\s*version=\\\"[^\\\"]*\\\"\\s*encoding=\\\"([^\\\"]*)\\\"\\?>$"; //$NON-NLS-1$
|
||||
|
||||
Perl5Compiler compiler = new Perl5Compiler();
|
||||
Perl5Matcher matcher = new Perl5Matcher();
|
||||
Pattern pattern = null;
|
||||
try {
|
||||
pattern = compiler.compile(regex);
|
||||
if (matcher.contains(str, pattern)) {
|
||||
MatchResult matchResult = matcher.getMatch();
|
||||
if (matchResult != null) {
|
||||
encoding = matchResult.group(1);
|
||||
}
|
||||
}
|
||||
} catch (MalformedPatternException malE) {
|
||||
ExceptionHandler.process(malE);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
String fileStr = text;
|
||||
String msgError = "JSON" + " \"" + fileStr.replace("\\\\", "\\") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
+ "\"\n"; //$NON-NLS-1$
|
||||
if (ex instanceof FileNotFoundException) {
|
||||
msgError = msgError + "is not found";
|
||||
} else if (ex instanceof EOFException) {
|
||||
msgError = msgError + "have an incorrect character EOF";
|
||||
} else if (ex instanceof IOException) {
|
||||
msgError = msgError + "is locked by another soft";
|
||||
} else {
|
||||
msgError = msgError + "doesn't exist";
|
||||
}
|
||||
if (!isReadOnly()) {
|
||||
updateStatus(IStatus.ERROR, msgError);
|
||||
}
|
||||
// ExceptionHandler.process(ex);
|
||||
} finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (Exception ex2) {
|
||||
ExceptionHandler.process(ex2);
|
||||
}
|
||||
}
|
||||
if (getConnection().getEncoding() == null || "".equals(getConnection().getEncoding())) { //$NON-NLS-1$
|
||||
getConnection().setEncoding(encoding);
|
||||
if (encoding != null && !("").equals(encoding)) { //$NON-NLS-1$
|
||||
encodingCombo.setText(encoding);
|
||||
} else {
|
||||
encodingCombo.setText("UTF-8"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
// if (tempJSONXsdPath != null && getConnection().getFileContent() != null
|
||||
// && getConnection().getFileContent().length > 0 && !isModifing) {
|
||||
// valid = treePopulator.populateTree(tempJSONXsdPath, treeNode);
|
||||
// } else {
|
||||
// valid = treePopulator.populateTree(text, treeNode);
|
||||
// }
|
||||
checkFieldsValue();
|
||||
isModifing = true;
|
||||
validateJsonFile();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -691,6 +529,19 @@ public class JSONFileStep1Form extends AbstractJSONFileStepForm {
|
||||
@Override
|
||||
public void modifyText(final ModifyEvent e) {
|
||||
getConnection().setEncoding(encodingCombo.getText());
|
||||
String encoding = getConnection().getEncoding();
|
||||
if (treePopulator != null) {
|
||||
treePopulator.setEncoding(encoding);
|
||||
}
|
||||
try {
|
||||
Charset charSet = Charset.forName(encoding);
|
||||
if (charSet != null) {
|
||||
validateJsonFile();
|
||||
return;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// ignore
|
||||
}
|
||||
checkFieldsValue();
|
||||
}
|
||||
});
|
||||
@@ -883,4 +734,171 @@ public class JSONFileStep1Form extends AbstractJSONFileStepForm {
|
||||
// valid = this.treePopulator.populateTree(tempJSONXsdPath, treeNode);
|
||||
// temfile.delete();
|
||||
}
|
||||
|
||||
private void validateJsonFile() {
|
||||
String jsonPath = fileFieldJSON.getText();
|
||||
String _jsonPath = jsonPath;
|
||||
if (isContextMode()) {
|
||||
ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(
|
||||
connectionItem.getConnection(), connectionItem.getConnection().getContextName());
|
||||
jsonPath = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType,
|
||||
jsonPath));
|
||||
|
||||
}
|
||||
String text = validateJsonFilePath(jsonPath);
|
||||
if (text == null || text.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String tempxml = null;
|
||||
String readbyMode = JSONFileStep1Form.this.wizard.getReadbyMode();
|
||||
|
||||
if (EJsonReadbyMode.JSONPATH.getValue().equals(readbyMode)) {
|
||||
tempxml = text;
|
||||
} else {
|
||||
tempxml = JSONUtil.changeJsonToXml(text, getConnection().getEncoding());
|
||||
}
|
||||
File file = new File(text);
|
||||
if (!file.exists()) {
|
||||
file = new File(JSONUtil.tempJSONXsdPath);
|
||||
}
|
||||
JSONFileStep1Form.this.wizard.setTempJsonPath(tempxml);
|
||||
String limitString = commonNodesLimitation.getText();
|
||||
try {
|
||||
limit = Integer.valueOf(limitString);
|
||||
labelLimitation.setToolTipText(MessageFormat.format(Messages.JSONLimitToolTip, limit));
|
||||
} catch (Exception excpt) {
|
||||
// nothing need to do
|
||||
}
|
||||
switchPopulator(readbyMode, tempxml);
|
||||
// }
|
||||
// add for bug TDI-20432
|
||||
checkFieldsValue();
|
||||
// }
|
||||
|
||||
// String text = fileFieldJSON.getText();
|
||||
// File temp = new File(text);
|
||||
// if (!temp.exists()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (getConnection().getJSONFilePath() != null && !getConnection().getJSONFilePath().equals(text)) {
|
||||
getConnection().getLoop().clear();
|
||||
xsdPathChanged = true;
|
||||
} else {
|
||||
xsdPathChanged = false;
|
||||
}
|
||||
|
||||
if (isContextMode()) {
|
||||
jsonPath = _jsonPath;
|
||||
}
|
||||
if (Path.fromOSString(jsonPath).toFile().isFile()) {
|
||||
getConnection().setJSONFilePath(PathUtils.getPortablePath(jsonPath));
|
||||
} else {
|
||||
getConnection().setJSONFilePath(jsonPath);
|
||||
}
|
||||
|
||||
JSONWizard wizard = ((JSONWizard) getPage().getWizard());
|
||||
wizard.setTreeRootNode(treeNode);
|
||||
|
||||
BufferedReader in = null;
|
||||
|
||||
// File file = null;
|
||||
//
|
||||
// if (tempJSONXsdPath != null && getConnection().getFileContent() != null
|
||||
// && getConnection().getFileContent().length > 0 && !isModifing) {
|
||||
// file = new File(tempJSONXsdPath);
|
||||
// if (!file.exists()) {
|
||||
// try {
|
||||
// file.createNewFile();
|
||||
// } catch (IOException e2) {
|
||||
// ExceptionHandler.process(e2);
|
||||
// }
|
||||
// FileOutputStream outStream;
|
||||
// try {
|
||||
// outStream = new FileOutputStream(file);
|
||||
// outStream.write(getConnection().getFileContent());
|
||||
// outStream.close();
|
||||
// } catch (FileNotFoundException e1) {
|
||||
// ExceptionHandler.process(e1);
|
||||
// } catch (IOException e3) {
|
||||
// ExceptionHandler.process(e3);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// } else {
|
||||
// file = new File(text);
|
||||
// }
|
||||
|
||||
// setFileContent(file);
|
||||
// }
|
||||
|
||||
try {
|
||||
|
||||
Charset guessedCharset = CharsetToolkit.guessEncoding(file, 4096);
|
||||
String str;
|
||||
in = new BufferedReader(new InputStreamReader(new FileInputStream(file), guessedCharset.displayName()));
|
||||
while ((str = in.readLine()) != null) {
|
||||
if (str.contains("encoding")) { //$NON-NLS-1$
|
||||
String regex = "^<\\?JSON\\s*version=\\\"[^\\\"]*\\\"\\s*encoding=\\\"([^\\\"]*)\\\"\\?>$"; //$NON-NLS-1$
|
||||
|
||||
Perl5Compiler compiler = new Perl5Compiler();
|
||||
Perl5Matcher matcher = new Perl5Matcher();
|
||||
Pattern pattern = null;
|
||||
try {
|
||||
pattern = compiler.compile(regex);
|
||||
if (matcher.contains(str, pattern)) {
|
||||
MatchResult matchResult = matcher.getMatch();
|
||||
if (matchResult != null) {
|
||||
encoding = matchResult.group(1);
|
||||
}
|
||||
}
|
||||
} catch (MalformedPatternException malE) {
|
||||
ExceptionHandler.process(malE);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
String fileStr = text;
|
||||
String msgError = "JSON" + " \"" + fileStr.replace("\\\\", "\\") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
+ "\"\n"; //$NON-NLS-1$
|
||||
if (ex instanceof FileNotFoundException) {
|
||||
msgError = msgError + "is not found";
|
||||
} else if (ex instanceof EOFException) {
|
||||
msgError = msgError + "have an incorrect character EOF";
|
||||
} else if (ex instanceof IOException) {
|
||||
msgError = msgError + "is locked by another soft";
|
||||
} else {
|
||||
msgError = msgError + "doesn't exist";
|
||||
}
|
||||
if (!isReadOnly()) {
|
||||
updateStatus(IStatus.ERROR, msgError);
|
||||
}
|
||||
// ExceptionHandler.process(ex);
|
||||
} finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (Exception ex2) {
|
||||
ExceptionHandler.process(ex2);
|
||||
}
|
||||
}
|
||||
if (getConnection().getEncoding() == null || "".equals(getConnection().getEncoding())) { //$NON-NLS-1$
|
||||
getConnection().setEncoding(encoding);
|
||||
if (encoding != null && !("").equals(encoding)) { //$NON-NLS-1$
|
||||
encodingCombo.setText(encoding);
|
||||
} else {
|
||||
encodingCombo.setText("UTF-8"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
// if (tempJSONXsdPath != null && getConnection().getFileContent() != null
|
||||
// && getConnection().getFileContent().length > 0 && !isModifing) {
|
||||
// valid = treePopulator.populateTree(tempJSONXsdPath, treeNode);
|
||||
// } else {
|
||||
// valid = treePopulator.populateTree(text, treeNode);
|
||||
// }
|
||||
checkFieldsValue();
|
||||
isModifing = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.Priority;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
@@ -52,6 +53,7 @@ import org.eclipse.swt.widgets.ScrollBar;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
import org.talend.commons.CommonsPlugin;
|
||||
import org.talend.commons.ui.command.CommandStackForComposite;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.commons.ui.runtime.ws.WindowSystem;
|
||||
@@ -222,6 +224,7 @@ public class JSONFileStep2Form extends AbstractJSONFileStepForm implements IRefr
|
||||
jsonXPathLoopDescriptor.setLimitBoucle(XmlArray.getRowLimit());
|
||||
|
||||
}
|
||||
treePopulator.setEncoding(getConnection().getEncoding());
|
||||
treePopulator.populateTree(wizard.getTempJsonPath(), treeNode);
|
||||
fieldsModel.setJSONXPathLoopDescriptor(jsonXPathLoopDescriptor.getSchemaTargets());
|
||||
fieldsTableEditorView.getTableViewerCreator().layout();
|
||||
@@ -608,7 +611,22 @@ public class JSONFileStep2Form extends AbstractJSONFileStepForm implements IRefr
|
||||
}
|
||||
};
|
||||
|
||||
previewLoader.load(getProcessDescription(false));
|
||||
ProcessDescription processDescription = getProcessDescription(false);
|
||||
EJsonReadbyMode mode = null;
|
||||
String readbyMode = getConnection().getReadbyMode();
|
||||
if (StringUtils.isNotBlank(readbyMode)) {
|
||||
mode = EJsonReadbyMode.getEJsonReadbyModeByValue(readbyMode);
|
||||
}
|
||||
if (EJsonReadbyMode.XPATH.equals(mode)) {
|
||||
/**
|
||||
* JSON XPATH mode uses the temp generated xml file to execute the preview, the generated xml file is
|
||||
* encoded using UTF-8. <br/>
|
||||
* (The generated xml file can't be encoded using other charset, otherwise the converted xml file will be
|
||||
* empty)
|
||||
*/
|
||||
processDescription.setEncoding(TalendQuoteUtils.addQuotes("UTF-8"));
|
||||
}
|
||||
previewLoader.load(processDescription);
|
||||
|
||||
}
|
||||
|
||||
@@ -871,10 +889,20 @@ public class JSONFileStep2Form extends AbstractJSONFileStepForm implements IRefr
|
||||
}
|
||||
}
|
||||
|
||||
Charset guessedCharset = CharsetToolkit.guessEncoding(file, 4096);
|
||||
Charset guessedCharset = null;
|
||||
try {
|
||||
guessedCharset = Charset.forName(getConnection().getEncoding());
|
||||
} catch (Exception e) {
|
||||
if (CommonsPlugin.isDebugMode()) {
|
||||
ExceptionHandler.process(e, Priority.WARN);
|
||||
}
|
||||
}
|
||||
if (guessedCharset == null) {
|
||||
guessedCharset = CharsetToolkit.guessEncoding(file, 4096);
|
||||
}
|
||||
|
||||
String str;
|
||||
in = new BufferedReader(new InputStreamReader(new FileInputStream(pathStr), guessedCharset.displayName()));
|
||||
in = new BufferedReader(new InputStreamReader(new FileInputStream(pathStr), guessedCharset));
|
||||
|
||||
while ((str = in.readLine()) != null) {
|
||||
previewRows.append(str + "\n"); //$NON-NLS-1$
|
||||
@@ -947,6 +975,7 @@ public class JSONFileStep2Form extends AbstractJSONFileStepForm implements IRefr
|
||||
// fix bug: when the JSON file is changed, the linker doesn't work.
|
||||
resetStatusIfNecessary();
|
||||
String tempJson = this.wizard.getTempJsonPath();
|
||||
this.treePopulator.setEncoding(getConnection().getEncoding());
|
||||
this.treePopulator.populateTree(tempJson, treeNode);
|
||||
|
||||
ScrollBar verticalBar = availableJSONTree.getVerticalBar();
|
||||
|
||||
@@ -328,7 +328,7 @@ public class JSONFileStep3Form extends AbstractJSONFileStepForm {
|
||||
processDescription = JSONShadowProcessHelper.getProcessDescription(connection2, connection2.getJSONFilePath());
|
||||
} else {
|
||||
processDescription = JSONShadowProcessHelper.getProcessDescription(connection2,
|
||||
JSONUtil.changeJsonToXml(connection2.getJSONFilePath()));
|
||||
JSONUtil.changeJsonToXml(connection2.getJSONFilePath(), getConnection().getEncoding()));
|
||||
}
|
||||
}
|
||||
return processDescription;
|
||||
@@ -357,10 +357,18 @@ public class JSONFileStep3Form extends AbstractJSONFileStepForm {
|
||||
informationLabel.setText(" " + "Guess in progress...");
|
||||
|
||||
CsvArray csvArray = null;
|
||||
ProcessDescription processDescription = getProcessDescription(false);
|
||||
if (EJsonReadbyMode.JSONPATH.getValue().equals(connection2.getReadbyMode())) {
|
||||
csvArray = JSONShadowProcessHelper.getCsvArray(getProcessDescription(false), "FILE_JSON"); //$NON-NLS-1$
|
||||
csvArray = JSONShadowProcessHelper.getCsvArray(processDescription, "FILE_JSON"); //$NON-NLS-1$
|
||||
} else {
|
||||
csvArray = JSONShadowProcessHelper.getCsvArray(getProcessDescription(false), "FILE_XML"); //$NON-NLS-1$
|
||||
/**
|
||||
* JSON XPATH mode uses the temp generated xml file to execute the preview, the generated xml file is
|
||||
* encoded using UTF-8. <br/>
|
||||
* (The generated xml file can't be encoded using other charset, otherwise the converted xml file will
|
||||
* be empty)
|
||||
*/
|
||||
processDescription.setEncoding(TalendQuoteUtils.addQuotes("UTF-8"));
|
||||
csvArray = JSONShadowProcessHelper.getCsvArray(processDescription, "FILE_XML"); //$NON-NLS-1$
|
||||
}
|
||||
if (csvArray == null) {
|
||||
informationLabel.setText(" " + "Guess failure");
|
||||
|
||||
@@ -20,10 +20,13 @@ import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.swt.widgets.FileDialog;
|
||||
import org.eclipse.ui.actions.SelectionProviderAction;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.properties.ConnectionItem;
|
||||
import org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode;
|
||||
import org.talend.metadata.managment.ui.wizard.metadata.xml.utils.TreeUtil;
|
||||
import org.talend.repository.json.ui.wizards.AbstractJSONStepForm;
|
||||
import org.talend.repository.json.util.JSONUtil;
|
||||
import org.talend.repository.model.json.JSONFileConnection;
|
||||
|
||||
/**
|
||||
* hwang class global comment. Detailled comment
|
||||
@@ -56,7 +59,17 @@ public class ImportTreeFromJSONAction extends SelectionProviderAction {
|
||||
|
||||
boolean changed = true;
|
||||
try {
|
||||
newInput = TreeUtil.getFoxTreeNodes(JSONUtil.changeJsonToXml(filePath));
|
||||
String encoding = "UTF-8";
|
||||
if (this.form != null) {
|
||||
ConnectionItem connectionItem = this.form.getConnectionItem();
|
||||
if (connectionItem != null) {
|
||||
Connection connection = connectionItem.getConnection();
|
||||
if (connection instanceof JSONFileConnection) {
|
||||
encoding = ((JSONFileConnection) connection).getEncoding();
|
||||
}
|
||||
}
|
||||
}
|
||||
newInput = TreeUtil.getFoxTreeNodes(JSONUtil.changeJsonToXml(filePath, encoding));
|
||||
changed = true;
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
|
||||
@@ -272,6 +272,7 @@ public class JSONToXPathLinker extends TreeToTablesLinker<Object, Object> {
|
||||
}
|
||||
|
||||
if (originalValue != null) {
|
||||
loadItemDataForLazyLoad(loopTableEditorView);
|
||||
createLoopLinks(originalValue, tableItem, monitorWrap);
|
||||
}
|
||||
|
||||
@@ -311,6 +312,7 @@ public class JSONToXPathLinker extends TreeToTablesLinker<Object, Object> {
|
||||
List<SchemaTarget> schemaTargetList, int startTableItem, int tableItemLength) {
|
||||
monitorWrap.beginTask("Fields links creation ...", totalWork);
|
||||
|
||||
loadItemDataForLazyLoad(fieldsTableEditorView);
|
||||
TableItem[] fieldsTableItems = fieldsTableEditorView.getTable().getItems();
|
||||
for (int i = startTableItem, indexShemaTarget = 0; i < startTableItem + tableItemLength; i++, indexShemaTarget++) {
|
||||
|
||||
@@ -330,6 +332,7 @@ public class JSONToXPathLinker extends TreeToTablesLinker<Object, Object> {
|
||||
createFieldLinks(relativeXpathQuery, tableItem, monitorWrap, schemaTarget);
|
||||
monitorWrap.worked(1);
|
||||
}
|
||||
fieldsTableEditorView.getTableViewerCreator().getTableViewer().refresh();
|
||||
getLinksManager().sortLinks(getDrawingLinksComparator());
|
||||
getBackgroundRefresher().refreshBackground();
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class JSONUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String changeJsonToXml(String jsonPath) {
|
||||
public static String changeJsonToXml(String jsonPath, String encoding) {
|
||||
Project project = ProjectManager.getInstance().getCurrentProject();
|
||||
IProject fsProject = null;
|
||||
try {
|
||||
@@ -166,10 +166,9 @@ public class JSONUtil {
|
||||
}
|
||||
|
||||
try {
|
||||
String jsonStr = IOUtils.toString(input);
|
||||
String jsonStr = IOUtils.toString(input, encoding);
|
||||
|
||||
convertJSON.setJsonString(jsonStr);
|
||||
|
||||
convertJSON.generate();
|
||||
jsonStr = convertJSON.getJsonString4XML();
|
||||
inStream = new ByteArrayInputStream(jsonStr.getBytes());
|
||||
|
||||
@@ -3129,6 +3129,15 @@
|
||||
name="UseOracle11VersionInsteadOfRemoved"
|
||||
version="7.1.0">
|
||||
</projecttask>
|
||||
<projecttask
|
||||
beforeLogon="false"
|
||||
breaks="7.0.0"
|
||||
class="org.talend.repository.model.migration.changeDBVersionForMapROJAIOutputMigrationTask"
|
||||
description="Changed DB version in MapROJAI output component"
|
||||
id="org.talend.repository.model.migration.changeDBVersionForMapROJAIOutputMigrationTask"
|
||||
name="changeDBVersionForMapROJAIOutputMigrationTask"
|
||||
version="7.0.1">
|
||||
</projecttask>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.repository.model.migration;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.core.language.ECodeLanguage;
|
||||
import org.talend.core.model.components.ComponentUtilities;
|
||||
import org.talend.core.model.components.ModifyComponentsAction;
|
||||
import org.talend.core.model.components.conversions.IComponentConversion;
|
||||
import org.talend.core.model.components.filters.IComponentFilter;
|
||||
import org.talend.core.model.components.filters.NameComponentFilter;
|
||||
import org.talend.core.model.migration.AbstractJobMigrationTask;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
|
||||
import org.talend.migration.IMigrationTask.ExecutionResult;
|
||||
|
||||
public class changeDBVersionForMapROJAIOutputMigrationTask extends AbstractJobMigrationTask {
|
||||
|
||||
@Override
|
||||
public Date getOrder() {
|
||||
GregorianCalendar gc = new GregorianCalendar(2019, 8, 12, 12, 0, 0);
|
||||
return gc.getTime();
|
||||
}
|
||||
@Override
|
||||
public ExecutionResult execute(Item item) {
|
||||
final ProcessType processType = getProcessType(item);
|
||||
String[] compNames = {"tMapROjaiOutput"};
|
||||
|
||||
IComponentConversion changeDBNVersion = new IComponentConversion() {
|
||||
|
||||
public void transform(NodeType node) {
|
||||
if(node == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ElementParameterType database = ComponentUtilities.getNodeProperty(node, "DB_VERSION"); //$NON-NLS-1$
|
||||
|
||||
if (database == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String dbname = database.getValue();
|
||||
|
||||
if("MAPROJAI_5_1".equals(dbname)) {
|
||||
database.setValue("MAPR510");
|
||||
} else if ("MAPROJAI_5_2".equals(dbname)) {
|
||||
database.setValue("MAPR520");
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
for (String name : compNames) {
|
||||
IComponentFilter filter = new NameComponentFilter(name);
|
||||
|
||||
try {
|
||||
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays
|
||||
.<IComponentConversion> asList(changeDBNVersion));
|
||||
} catch (PersistenceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
ExceptionHandler.process(e);
|
||||
return ExecutionResult.FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return ExecutionResult.SUCCESS_NO_ALERT;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -30,8 +30,10 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -65,6 +67,7 @@ import org.talend.core.runtime.process.ITalendProcessJavaProject;
|
||||
import org.talend.core.runtime.process.LastGenerationInfo;
|
||||
import org.talend.core.runtime.repository.build.BuildExportManager;
|
||||
import org.talend.core.ui.branding.IBrandingService;
|
||||
import org.talend.designer.core.ICamelDesignerCoreService;
|
||||
import org.talend.designer.core.IDesignerCoreService;
|
||||
import org.talend.designer.core.model.utils.emf.component.IMPORTType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
@@ -82,9 +85,14 @@ import org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobJavaScriptsM
|
||||
import org.talend.repository.utils.EmfModelUtils;
|
||||
import org.talend.repository.utils.TemplateProcessor;
|
||||
|
||||
import aQute.bnd.header.Attrs;
|
||||
import aQute.bnd.osgi.Analyzer;
|
||||
import aQute.bnd.osgi.Descriptors;
|
||||
import aQute.bnd.osgi.FileResource;
|
||||
import aQute.bnd.osgi.Jar;
|
||||
import aQute.bnd.service.AnalyzerPlugin;
|
||||
import aQute.bnd.service.Plugin;
|
||||
import aQute.service.reporter.Reporter;
|
||||
|
||||
/**
|
||||
* DOC ycbai class global comment. Detailled comment
|
||||
@@ -201,9 +209,40 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
|
||||
ExportFileResource libResource = getCompiledLibExportFileResource(processes);
|
||||
list.add(libResource);
|
||||
|
||||
|
||||
ExportFileResource libResourceSelected = new ExportFileResource(null, LIBRARY_FOLDER_NAME);
|
||||
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
|
||||
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(
|
||||
ICamelDesignerCoreService.class);
|
||||
|
||||
Collection<String> unselectList = camelService.getUnselectDependenciesBundle(processItem);
|
||||
List<URL> unselectListURLs = new ArrayList<>();
|
||||
|
||||
for(Set<URL> set:libResource.getAllResources()) {
|
||||
|
||||
for (URL url : set) {
|
||||
|
||||
boolean exist = false;
|
||||
for(String name: unselectList) {
|
||||
if (name.equals(new File(url.toURI()).getName())) {
|
||||
exist = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!exist) {
|
||||
unselectListURLs.add(url);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
libResourceSelected.addResources(unselectListURLs);
|
||||
}
|
||||
|
||||
// generate the META-INFO folder
|
||||
ExportFileResource metaInfoFolder = genMetaInfoFolder(libResource, processItem);
|
||||
ExportFileResource metaInfoFolder = genMetaInfoFolder(libResourceSelected, processItem);
|
||||
list.add(0, metaInfoFolder);
|
||||
|
||||
ExportFileResource providedLibResources = getProvidedLibExportFileResource(processes);
|
||||
@@ -806,6 +845,11 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
bundleNativeCode.setLength(bundleNativeCode.length() - 1);
|
||||
analyzer.setProperty(Analyzer.BUNDLE_NATIVECODE, bundleNativeCode.toString());
|
||||
}
|
||||
|
||||
// TESB-24730 set specific version for "javax.annotation"
|
||||
ImportedPackageRangeReplacer r = new ImportedPackageRangeReplacer();
|
||||
r.addRange("javax.annotation", "[1.3,2)");
|
||||
analyzer.addBasicPlugin(r);
|
||||
|
||||
return analyzer;
|
||||
}
|
||||
@@ -1000,4 +1044,116 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
|
||||
}
|
||||
return imports;
|
||||
}
|
||||
|
||||
private class ImportedPackageRangeReplacer implements AnalyzerPlugin, Plugin {
|
||||
|
||||
private Set<Range> ranges = new TreeSet<>();
|
||||
|
||||
public void addRange(String packageName, String packageVersion) {
|
||||
ranges.add(new Range(packageName, packageVersion));
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyzes the jar and update the version range.
|
||||
*
|
||||
* @param analyzer the analyzer
|
||||
* @return {@code false}
|
||||
* @throws Exception if the analaysis fails.
|
||||
*/
|
||||
@Override
|
||||
public boolean analyzeJar(Analyzer analyzer) throws Exception {
|
||||
|
||||
if (analyzer.getReferred() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Map.Entry<Descriptors.PackageRef, Attrs> entry : analyzer.getReferred().entrySet()) {
|
||||
for (Range range : ranges) {
|
||||
if (range.matches(entry.getKey().getFQN())) {
|
||||
String value = range.getRange(analyzer);
|
||||
if (value != null) {
|
||||
entry.getValue().put("version", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private class Range implements Comparable<Range> {
|
||||
final String name;
|
||||
final String value;
|
||||
final Pattern regex;
|
||||
|
||||
private String foundRange;
|
||||
|
||||
private Range(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.regex = Pattern.compile(name.trim().replace(".", "\\.").replace("*", ".*"));
|
||||
}
|
||||
|
||||
private boolean matches(String pck) {
|
||||
return regex.matcher(pck).matches();
|
||||
}
|
||||
|
||||
private String getRange(Analyzer analyzer) throws Exception {
|
||||
if (foundRange != null) {
|
||||
return foundRange;
|
||||
}
|
||||
if (null == value || value.isEmpty()) {
|
||||
for (Jar jar : analyzer.getClasspath()) {
|
||||
if (isProvidedByJar(jar) && jar.getVersion() != null) {
|
||||
foundRange = jar.getVersion();
|
||||
return jar.getVersion();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isProvidedByJar(Jar jar) {
|
||||
for (String s : jar.getPackages()) {
|
||||
if (matches(s)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Range o) {
|
||||
return Integer.compare(this.regex.pattern().length(), o.regex.pattern().length());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Range range = (Range) o;
|
||||
return Objects.equals(name, range.name) &&
|
||||
Objects.equals(value, range.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(name + value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReporter(Reporter processor) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperties(Map<String, String> map) throws Exception {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ 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;
|
||||
|
||||
@@ -610,5 +611,163 @@ 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());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,26 +31,47 @@ import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.language.ECodeLanguage;
|
||||
import org.talend.core.model.context.JobContextManager;
|
||||
import org.talend.core.model.process.IContext;
|
||||
import org.talend.core.model.process.IContextManager;
|
||||
import org.talend.core.model.process.IProcess;
|
||||
import org.talend.core.model.process.IProcess2;
|
||||
import org.talend.core.model.process.JobInfo;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.model.properties.PropertiesFactory;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.relationship.Relation;
|
||||
import org.talend.core.model.relationship.RelationshipItemBuilder;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.model.repository.RepositoryObject;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.runtime.process.ITalendProcessJavaProject;
|
||||
import org.talend.core.runtime.process.TalendProcessOptionConstants;
|
||||
import org.talend.designer.core.IDesignerCoreService;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ParametersType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory;
|
||||
import org.talend.designer.core.ui.editor.process.Process;
|
||||
import org.talend.designer.maven.model.TalendJavaProjectConstants;
|
||||
import org.talend.designer.maven.model.TalendMavenConstants;
|
||||
import org.talend.designer.maven.tools.AggregatorPomsHelper;
|
||||
import org.talend.designer.maven.utils.PomUtil;
|
||||
import org.talend.designer.runprocess.IProcessor;
|
||||
import org.talend.designer.runprocess.IRunProcessService;
|
||||
import org.talend.designer.runprocess.java.TalendJavaProjectManager;
|
||||
import org.talend.designer.runprocess.maven.MavenJavaProcessor;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.documentation.ERepositoryActionName;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
@@ -348,6 +369,145 @@ public class ProcessChangeListenerTest {
|
||||
checkRootPomModules(toRemove, toAdd);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSyncParentJobPomsForPropertyChange() throws Exception {
|
||||
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
Property maintestProp = createJobPropertyWithContext("maintest", "0.1");
|
||||
Property childtestProp = createJobPropertyWithContext("childtest", "0.1");
|
||||
|
||||
ProcessItem mainItem = (ProcessItem) maintestProp.getItem();
|
||||
mainItem.getProcess().setDefaultContext("Default");
|
||||
JobInfo mainJobInfo = new JobInfo(mainItem, mainItem.getProcess().getDefaultContext());
|
||||
ProcessItem childItem = (ProcessItem) childtestProp.getItem();
|
||||
JobInfo childJobInfo = new JobInfo(childItem, childItem.getProcess().getDefaultContext());
|
||||
childJobInfo.setJobId(childtestProp.getId());
|
||||
childJobInfo.setFatherJobInfo(mainJobInfo);
|
||||
|
||||
IProcessor mainProcessor = getProcessor(maintestProp.getItem());
|
||||
assertTrue(mainProcessor != null);
|
||||
mainProcessor.getBuildFirstChildrenJobs().add(childJobInfo);
|
||||
int option = 0;
|
||||
option |= TalendProcessOptionConstants.GENERATE_POM_ONLY;
|
||||
option |= TalendProcessOptionConstants.GENERATE_IS_MAINJOB;
|
||||
// ((MavenJavaProcessor) processor).generatePom(option);
|
||||
MavenJavaProcessor mavenProcessor = (MavenJavaProcessor) mainProcessor;
|
||||
mavenProcessor.generatePom(option);
|
||||
|
||||
// prepare relationship
|
||||
RelationshipItemBuilder relationBuilder = RelationshipItemBuilder
|
||||
.getInstance(ProjectManager.getInstance().getCurrentProject(), true);
|
||||
relationBuilder.load();
|
||||
Map<Relation, Set<Relation>> currentProjectItemsRelations = relationBuilder.getCurrentProjectItemsRelations();
|
||||
Relation baseItem = new Relation();
|
||||
baseItem.setId(maintestProp.getId());
|
||||
baseItem.setType(RelationshipItemBuilder.JOB_RELATION);
|
||||
baseItem.setVersion("0.1");
|
||||
Relation relatedItem = new Relation();
|
||||
relatedItem.setId(childtestProp.getId());
|
||||
relatedItem.setVersion(RelationshipItemBuilder.LATEST_VERSION);
|
||||
relatedItem.setType(RelationshipItemBuilder.JOB_RELATION);
|
||||
currentProjectItemsRelations.put(baseItem, new HashSet<Relation>());
|
||||
currentProjectItemsRelations.get(baseItem).add(relatedItem);
|
||||
relationBuilder.saveRelations();
|
||||
|
||||
IFile maintestPom = getJobPomFile(maintestProp);
|
||||
assertTrue(maintestPom.exists());
|
||||
// expect: parentJob pom exist childJob dependency
|
||||
assertTrue(PomUtil.checkIfJobDependencyExist(maintestPom, childtestProp));
|
||||
|
||||
// to upgrade child job version
|
||||
IRepositoryViewObject childObject = factory.getSpecificVersion(childtestProp.getId(), childtestProp.getVersion(), true);
|
||||
RepositoryObject upperChildObject = new RepositoryObject(childObject.getProperty());
|
||||
Property upperProperty = upperChildObject.getProperty();
|
||||
upperProperty.setVersion("0.2");
|
||||
factory.save(upperProperty, childtestProp.getLabel(), childtestProp.getVersion());
|
||||
RelationshipItemBuilder.getInstance().addOrUpdateItem(upperChildObject.getProperty().getItem());
|
||||
|
||||
// to moke the process of syncParentJobPomsForPropertyChange
|
||||
List<Relation> itemsHaveRelationWith = RelationshipItemBuilder.getInstance()
|
||||
.getItemsHaveRelationWith(upperProperty.getId(), upperProperty.getVersion());
|
||||
assertTrue(itemsHaveRelationWith.size() == 1);
|
||||
Relation relation = itemsHaveRelationWith.get(0);
|
||||
assertTrue(relation.getId().equals(maintestProp.getId()));
|
||||
assertTrue(relation.getVersion().equals(maintestProp.getVersion()));
|
||||
// will get latest version childJobInfo in ProcessorUtilities.getSubjobInfo
|
||||
mainProcessor.getBuildFirstChildrenJobs().clear();
|
||||
ProcessItem upperItem = (ProcessItem) upperChildObject.getProperty().getItem();
|
||||
JobInfo newChildJobInfo = new JobInfo(upperItem, upperItem.getProcess().getDefaultContext());
|
||||
newChildJobInfo.setJobId(upperProperty.getId());
|
||||
newChildJobInfo.setFatherJobInfo(mainJobInfo);
|
||||
mainProcessor.getBuildFirstChildrenJobs().add(newChildJobInfo);
|
||||
mavenProcessor.generatePom(option);
|
||||
|
||||
// expect: after childJob upgrade version, parentJob pom exist childJob dependency
|
||||
// dependency version should be new version
|
||||
assertTrue(PomUtil.checkIfJobDependencyExist(maintestPom, upperProperty));
|
||||
|
||||
}
|
||||
|
||||
private Property createJobPropertyWithContext(String label, String version) throws Exception {
|
||||
Property property = PropertiesFactory.eINSTANCE.createProperty();
|
||||
String id = ProxyRepositoryFactory.getInstance().getNextId();
|
||||
property.setId(id);
|
||||
property.setLabel(label);
|
||||
property.setVersion(version);
|
||||
|
||||
ProcessItem item = PropertiesFactory.eINSTANCE.createProcessItem();
|
||||
item.setProperty(property);
|
||||
Process process = new Process(property);
|
||||
|
||||
ProcessType processType = TalendFileFactory.eINSTANCE.createProcessType();
|
||||
ParametersType parameterType = TalendFileFactory.eINSTANCE.createParametersType();
|
||||
processType.setParameters(parameterType);
|
||||
item.setProcess(processType);
|
||||
IContextManager contextManager = process.getContextManager();
|
||||
if (contextManager == null) {
|
||||
contextManager = new JobContextManager();
|
||||
}
|
||||
|
||||
ProxyRepositoryFactory.getInstance().create(item, new Path(""));
|
||||
testJobs.add(property);
|
||||
|
||||
return property;
|
||||
}
|
||||
|
||||
private IProcessor getProcessor(Item item) {
|
||||
GlobalServiceRegister register = GlobalServiceRegister.getDefault();
|
||||
IProcessor processor = null;
|
||||
IProcess process = null;
|
||||
IContext context = null;
|
||||
Property curProperty = item.getProperty();
|
||||
|
||||
if (register.isServiceRegistered(IDesignerCoreService.class)) {
|
||||
IDesignerCoreService designerService = (IDesignerCoreService) register.getService(IDesignerCoreService.class);
|
||||
process = designerService.getProcessFromItem(item);
|
||||
if (item.getProperty() == null && process instanceof IProcess2) {
|
||||
curProperty = ((IProcess2) process).getProperty();
|
||||
}
|
||||
context = process.getContextManager().getDefaultContext();
|
||||
}
|
||||
|
||||
if (process != null && GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
|
||||
IRunProcessService runProcessservice = (IRunProcessService) GlobalServiceRegister.getDefault()
|
||||
.getService(IRunProcessService.class);
|
||||
processor = runProcessservice.createCodeProcessor(process, curProperty, ECodeLanguage.getCodeLanguage("java"), true);
|
||||
}
|
||||
processor.setContext(context);
|
||||
|
||||
return processor;
|
||||
}
|
||||
|
||||
private IFile getJobPomFile(Property property) {
|
||||
String projectTechName = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
final IProject project = root.getProject(projectTechName);
|
||||
IFolder pomsFolder = project.getFolder(TalendJavaProjectConstants.DIR_POMS);
|
||||
IFolder jobFolder = pomsFolder.getFolder("jobs").getFolder("process")
|
||||
.getFolder(property.getLabel() + "_" + property.getVersion());
|
||||
IFile jobPom = jobFolder.getFile("pom.xml");
|
||||
return jobPom;
|
||||
}
|
||||
|
||||
private Property createJobProperty(String label, String version, boolean create) throws Exception {
|
||||
String id = ProxyRepositoryFactory.getInstance().getNextId();
|
||||
return createJobProperty(id, label, version, new Path(""), create);
|
||||
|
||||
Reference in New Issue
Block a user