Compare commits

...

3 Commits

Author SHA1 Message Date
roman.voievidko
8d4e1bf57c patch(TPS-3379): update release notes 2019-09-17 07:52:40 +03:00
roman.voievidko
2054c1a17f patch(TPS-3379): add PATCH_RELEASE_NOTE.md 2019-09-03 08:20:13 +03:00
chmyga
fca64405a2 fix(TDI-37801): tWriteJSONField null values (#3865)
* fix(TDI-37801): tWriteJSONField null values

* fix(TDI-37801): Handle nulls and empty strings correctly in json-lib

* fix(TDI-37801): Update json-lib version in components

* fix(TDI-37801): tWriteJSONField null values

* fix(TDI-37801): Fix import name
2019-09-03 08:03:42 +03:00
11 changed files with 146 additions and 12 deletions

77
PATCH_RELEASE_NOTE.md Normal file
View File

@@ -0,0 +1,77 @@
---
version: 7.2.1
module: https://talend.poolparty.biz/coretaxonomy/42
product:
- https://talend.poolparty.biz/coretaxonomy/23
---
# TPS-3379
| Info | Value |
| ---------------- | ---------------- |
| Patch Name | Patch\_20190917_TPS-3379\_v1-7.2.1 |
| Release Date | 2019-09-17 |
| Target Version | 20190620\_1446-V7.2.1 |
| Product affected | Talend Studio |
## Introduction
This is a self-contained patch.
**NOTE**: For information on how to obtain this patch, reach out to your Support contact at Talend.
## Fixed issues
This patch contains the following fixes:
- TPS-3379 [7.2.1]tWriteJsonField does not handle null values consistently(TDI-37801)
## Prerequisites
Consider the following requirements for your system:
- Talend Studio 7.2.1 must be installed.
## Installation
### Installing the patch using Software update
1) Logon TAC and switch to Configuration->Software Update, then enter the correct values and save referring to the documentation: https://help.talend.com/reader/f7Em9WV_cPm2RRywucSN0Q/j9x5iXV~vyxMlUafnDejaQ
2) Switch to Software update page, where the new patch will be listed. The patch can be downloaded from here into the nexus repository.
3) On Studio Side: Logon Studio with remote mode, on the logon page the Update button is displayed: click this button to install the patch.
### Installing the patch using Talend Studio
1) Create a folder named "patches" under your studio installer directory and copy the patch .zip file to this folder.
2) Restart your studio: a window pops up, then click OK to install the patch, or restart the commandline and the patch will be installed automatically.
### Installing the patch using Commandline
Execute the following commands:
1. Talend-Studio-win-x86_64.exe -nosplash -application org.talend.commandline.CommandLine -consoleLog -data commandline-workspace startServer -p 8002 --talendDebug
2. initRemote {tac_url} -ul {TAC login username} -up {TAC login password}
3. checkAndUpdate -tu {TAC login username} -tup {TAC login password}
## Uninstallation
Backup the Affected files list below. Uninstall the patch by restore the backup files.
## Affected files for this patch
The following files are installed by this patch:
- {Talend\_Studio\_path}/plugins/org.talend.designer.components.localprovider\_7.2.1.20190614\_0309/components/tExtractJSONFields/tExtractJSONFields\_java.xml
- {Talend\_Studio\_path}/plugins/org.talend.designer.components.localprovider\_7.2.1.20190614\_0309/components/tFileInputJSON/tFileInputJSON\_java.xml
- {Talend\_Studio\_path}/plugins/org.talend.designer.components.localprovider\_7.2.1.20190614\_0309/components/tWriteJSONField/tWriteJSONField\_java.xml
- {Talend\_Studio\_path}/plugins/org.talend.designer.components.localprovider\_7.2.1.20190614\_0309/components/tWriteJSONField/tWriteJSONField\_messages.properties
- {Talend\_Studio\_path}/plugins/org.talend.designer.components.localprovider\_7.2.1.20190614\_0309/components/tWriteJSONFieldIn/tWriteJSONFieldIn\_begin.javajet
- {Talend\_Studio\_path}/plugins/org.talend.designer.components.localprovider\_7.2.1.20190614\_0309/components/tWriteJSONFieldIn/tWriteJSONFieldIn\_java.xml
- {Talend\_Studio\_path}/plugins/org.talend.designer.components.localprovider\_7.2.1.20190614\_0309/components/tWriteXMLFieldOut/tWriteXMLFieldOut\_java.xml
- {Talend\_Studio\_path}/plugins/org.talend.designer.components.localprovider\_7.2.1.20190614\_0309/components/tWriteXMLFieldOut/tWriteXMLFieldOut\_main.javajet
- {Talend\_Studio\_path}/plugins/org.talend.designer.components.bigdata\_7.2.1.20190619\_1114/components/tCosmosDBWriteConf/tCosmosDBWriteConf\_java.xml
- {Talend\_Studio\_path}/plugins/org.talend.designer.components.bigdata\_7.2.1.20190619\_1114/components/tMongoDBWriteConf/tMongoDBWriteConf\_java.xml
- {Talend\_Studio\_path}/plugins/org.talend.designer.components.tisprovider\_7.2.1.20190614\_0242/components/tDataprepOut/tDataprepOut\_java.xml

View File

@@ -7,7 +7,7 @@
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<packaging>jar</packaging>
<version>2.4.1-talend</version>
<version>2.4.3-talend</version>
<name>json-lib</name>
<properties>

View File

@@ -163,6 +163,11 @@ public class XMLSerializer {
*/
private boolean useLongDecimals;
/**
* flag for if parse empty elements as empty strings
*/
private boolean useEmptyStrings;
/**
* Creates a new XMLSerializer with default options.<br>
* <ul>
@@ -803,6 +808,8 @@ public class XMLSerializer {
clazz = JSONTypes.OBJECT;
}else if( JSONTypes.ARRAY.compareToIgnoreCase( clazzText ) == 0 ){
clazz = JSONTypes.ARRAY;
} else if(JSONTypes.STRING.equalsIgnoreCase(clazzText)) {
clazz = JSONTypes.STRING;
}
}
return clazz;
@@ -1414,6 +1421,8 @@ public class XMLSerializer {
String text = element.getValue();
params = StringUtils.split( paramsAttribute.getValue(), "," );
setOrAccumulate( jsonObject, key, new JSONFunction( params, text ) );
} else if( useEmptyStrings && clazz != null && clazz.equalsIgnoreCase(JSONTypes.STRING) ) {
setTextValue(jsonObject, key, element);
}else{
if( isArray( element, false ) ){
setOrAccumulate( jsonObject, key, processArrayElement( element, defaultType ) );
@@ -1421,19 +1430,23 @@ public class XMLSerializer {
setOrAccumulate( jsonObject, key, simplifyValue( jsonObject,
processObjectElement( element, defaultType ) ) );
}else{
String value;
if( isKeepCData && isCData( element ) ){
value = "<![CDATA[" + element.getValue() + "]]>";
}else{
value = element.getValue();
}
setOrAccumulate( jsonObject, key, trimSpaceFromValue( value ) );
setTextValue(jsonObject, key, element);
}
}
}
}
}
private void setTextValue(final JSONObject jsonObject, final String key, final Element element) {
String value;
if( isKeepCData && isCData( element ) ){
value = "<![CDATA[" + element.getValue() + "]]>";
}else{
value = element.getValue();
}
setOrAccumulate( jsonObject, key, trimSpaceFromValue( value ) );
}
private boolean isCData( Element element ) {
if( element.getChildCount() == 1 ){
final Node child = element.getChild( 0 );
@@ -1493,6 +1506,14 @@ public class XMLSerializer {
return str;
}
public void setUseEmptyStrings(boolean useEmptyStrings) {
this.useEmptyStrings = useEmptyStrings;
}
public boolean isUseEmptyStrings() {
return this.useEmptyStrings;
}
private static class CustomElement extends Element {
private static String getName( String name ) {
int colon = name.indexOf( ':' );

View File

@@ -178,7 +178,7 @@
<IMPORTS>
<IMPORT NAME="Java_DOM4J1.6" MODULE="dom4j-1.6.1.jar" MVN="mvn:dom4j/dom4j/1.6.1" UrlPath="platform:/plugin/org.talend.libraries.dom4j-jaxen/lib/dom4j-1.6.1.jar" REQUIRED_IF="READ_BY == 'XPATH'" BundleID="" />
<IMPORT NAME="Java_JAXEN1.1" MODULE="jaxen-1.1.1.jar" MVN="mvn:org.talend.libraries/jaxen-1.1.1/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.dom4j-jaxen/lib/jaxen-1.1.1.jar" REQUIRED_IF="READ_BY == 'XPATH'" BundleID="" />
<IMPORT NAME="json-lib" MODULE="json-lib-2.4.1-talend.jar" MVN="mvn:net.sf.json-lib/json-lib/2.4.1-talend" REQUIRED_IF="READ_BY == 'XPATH'" />
<IMPORT NAME="json-lib" MODULE="json-lib-2.4.3-talend.jar" MVN="mvn:net.sf.json-lib/json-lib/2.4.3-talend" REQUIRED_IF="READ_BY == 'XPATH'" />
<IMPORT NAME="commons_lang" MODULE="commons-lang-2.6.jar" MVN="mvn:commons-lang/commons-lang/2.6" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-lang-2.6.jar" REQUIRED_IF="READ_BY == 'XPATH'" />
<IMPORT NAME="commons_logging" MODULE="commons-logging-1.1.1.jar" MVN="mvn:org.talend.libraries/commons-logging-1.1.1/6.0.0" UrlPath="platform:/base/plugins/org.apache.commons.logging_1.1.1.v201101211721.jar" REQUIRED_IF="READ_BY == 'XPATH'" />
<IMPORT NAME="ezmorph" MODULE="ezmorph-1.0.6.jar" MVN="mvn:org.talend.libraries/ezmorph-1.0.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.jackson/lib/ezmorph-1.0.6.jar" REQUIRED_IF="READ_BY == 'XPATH'" />

View File

@@ -165,7 +165,7 @@
REQUIRED_IF="(READ_BY == 'XPATH')" BundleID="" />
<IMPORT NAME="Java_JAXEN1.1" MODULE="jaxen-1.1.1.jar" MVN="mvn:org.talend.libraries/jaxen-1.1.1/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.dom4j-jaxen/lib/jaxen-1.1.1.jar"
REQUIRED_IF="(READ_BY == 'XPATH')" BundleID="" />
<IMPORT NAME="json-lib" MODULE="json-lib-2.4.1-talend.jar" MVN="mvn:net.sf.json-lib/json-lib/2.4.1-talend" REQUIRED_IF="(READ_BY == 'XPATH')" />
<IMPORT NAME="json-lib" MODULE="json-lib-2.4.3-talend.jar" MVN="mvn:net.sf.json-lib/json-lib/2.4.3-talend" REQUIRED_IF="(READ_BY == 'XPATH')" />
<IMPORT NAME="commons_lang" MODULE="commons-lang-2.6.jar" MVN="mvn:commons-lang/commons-lang/2.6" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-lang-2.6.jar"
REQUIRED_IF="(READ_BY == 'XPATH')" />
<IMPORT NAME="commons_logging" MODULE="commons-logging-1.1.1.jar" MVN="mvn:org.talend.libraries/commons-logging-1.1.1/6.0.0" UrlPath="platform:/base/plugins/org.apache.commons.logging_1.1.1.v201101211721.jar"

View File

@@ -98,6 +98,10 @@
<PARAMETER NAME="QUOTE_ALL_VALUES" FIELD="CHECK" REQUIRED="true" NUM_ROW="20">
<DEFAULT>false</DEFAULT>
</PARAMETER>
<PARAMETER NAME="ALLOW_EMPTY_STRINGS" FIELD="CHECK" NUM_ROW="21"
REQUIRED="false">
<DEFAULT>false</DEFAULT>
</PARAMETER>
</ADVANCED_PARAMETERS>
<CODEGENERATION>
@@ -124,6 +128,8 @@
<TEMPLATE_PARAM SOURCE="self.REMOVE_ROOT" TARGET="In.REMOVE_ROOT" />
<TEMPLATE_PARAM SOURCE="self.UNIQUE_NAME" TARGET="In.DESTINATION" />
<TEMPLATE_PARAM SOURCE="self.UNIQUE_NAME" TARGET="Out.DESTINATION" />
<TEMPLATE_PARAM SOURCE="self.ALLOW_EMPTY_STRINGS" TARGET="Out.ALLOW_EMPTY_STRINGS" />
<TEMPLATE_PARAM SOURCE="self.ALLOW_EMPTY_STRINGS" TARGET="In.ALLOW_EMPTY_STRINGS" />
</TEMPLATES>
</CODEGENERATION>

View File

@@ -29,4 +29,5 @@ SCHEMA.NAME=Schema
JSONFIELD.NAME=Output Column
COMPACT_FORMAT.NAME = Compact Format
REMOVE_ROOT.NAME=Remove root node.
QUOTE_ALL_VALUES.NAME=Quote all values
QUOTE_ALL_VALUES.NAME=Quote all values
ALLOW_EMPTY_STRINGS.NAME=Pass null values and empty strings explicitly

View File

@@ -16,6 +16,7 @@ imports="
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();
final boolean allowEmptyStrings = ("true").equals(ElementParameterParser.getValue(node, "__ALLOW_EMPTY_STRINGS__"));
List<IMetadataTable> metadatas = node.getMetadataList();
if ((metadatas!=null)&&(metadatas.size()>0)) {
@@ -33,6 +34,7 @@ if ((metadatas!=null)&&(metadatas.size()>0)) {
xmlSerializer_<%=cid%>.clearNamespaces();
xmlSerializer_<%=cid%>.setSkipNamespaces(true);
xmlSerializer_<%=cid%>.setForceTopLevelObject(<%=(removeRoot?false:true)%>);
xmlSerializer_<%=cid%>.setUseEmptyStrings(<%=allowEmptyStrings%>);
<%
INode sourceNode = node.getIncomingConnections(EConnectionType.ON_COMPONENT_OK).get(0).getSource();
String virtualSourceCid = sourceNode.getUniqueName();

View File

@@ -59,6 +59,13 @@
</ITEMS>
</PARAMETER>
</PARAMETERS>
<ADVANCED_PARAMETERS>
<PARAMETER NAME="ALLOW_EMPTY_STRINGS" FIELD="CHECK" NUM_ROW="21"
REQUIRED="false">
<DEFAULT>false</DEFAULT>
</PARAMETER>
</ADVANCED_PARAMETERS>
<CODEGENERATION>
<IMPORTS>
@@ -68,7 +75,7 @@
<IMPORT NAME="commons_lang" MODULE="commons-lang-2.6.jar" MVN="mvn:commons-lang/commons-lang/2.6" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-lang-2.6.jar" REQUIRED="true" />
<IMPORT NAME="commons_logging" MODULE="commons-logging-1.1.1.jar" MVN="mvn:org.talend.libraries/commons-logging-1.1.1/6.0.0" UrlPath="platform:/base/plugins/org.apache.commons.logging_1.1.1.v201101211721.jar" REQUIRED="true" />
<IMPORT NAME="ezmorph" MODULE="ezmorph-1.0.6.jar" MVN="mvn:org.talend.libraries/ezmorph-1.0.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.jackson/lib/ezmorph-1.0.6.jar" REQUIRED="true" />
<IMPORT NAME="json-lib" MODULE="json-lib-2.4.1-talend.jar" MVN="mvn:net.sf.json-lib/json-lib/2.4.1-talend" REQUIRED="true" />
<IMPORT NAME="json-lib" MODULE="json-lib-2.4.3-talend.jar" MVN="mvn:net.sf.json-lib/json-lib/2.4.3-talend" REQUIRED="true" />
</IMPORTS>
</CODEGENERATION>

View File

@@ -103,6 +103,11 @@
SHOW_IF="CREATE_EMPTY_ELEMENT=='true'">
<DEFAULT>false</DEFAULT>
</PARAMETER>
<PARAMETER NAME="ALLOW_EMPTY_STRINGS" FIELD="CHECK" NUM_ROW="12"
REQUIRED="false">
<DEFAULT>false</DEFAULT>
</PARAMETER>
<PARAMETER NAME="OUTPUT_AS_XSD" FIELD="CHECK"
REQUIRED="false" NUM_ROW="15">

View File

@@ -29,6 +29,7 @@ String destination4JSON = ElementParameterParser.getValue(node, "__DESTINATION__
boolean istWriteJSONField = destination4JSON == null ? false : destination4JSON.contains("tWriteJSONField_");
boolean isQuoteAllValues = ("true").equals(ElementParameterParser.getValue(node, "__QUOTE_ALL_VALUES__"));
boolean isCompactFormat = ("true").equals(ElementParameterParser.getValue(node, "__COMPACT_FORMAT__"));
final boolean allowEmptyStrings = ("true").equals(ElementParameterParser.getValue(node, "__ALLOW_EMPTY_STRINGS__"));
final String whiteSpace;
final String rowSeparator;
if(!isCompactFormat) { // pretty format
@@ -262,6 +263,14 @@ class GenerateToolByDom4j{
if(<%tool.getValue(node);%>!=null){
nestXMLTool_<%=cid%> .setText(<%=currEleName%>_<%=cid%>,<%tool.getValue(node);%>);
<%
if(istWriteJSONField && allowEmptyStrings) {
if (javaType == JavaTypesManager.STRING) {
%>
<%=currEleName%>_<%=cid%>.addAttribute("type", "string");
<%=currEleName%>_<%=cid%>.addAttribute("class", "string");
<%
}
}
boolean hasCustomAttrs = false;
for (XMLNode attribute : node.attributes) {
if (!"type".equals(attribute.name) && !"class".equals(attribute.name)) {
@@ -283,7 +292,13 @@ class GenerateToolByDom4j{
}
%>
}
<% if(istWriteJSONField && allowEmptyStrings) { %>
else {
nestXMLTool_<%=cid%> .setText(<%=currEleName%>_<%=cid%>,"null");
<%=currEleName%>_<%=cid%>.addAttribute("null", "true");
}
<%
}
if(outputAsXSD){
%>
else{