Bug #9763
xml-node-name buffer option
100%
Related issues
History
#2 Updated by Constantin Asofiei over 1 year ago
- Status changed from New to Review
- reviewer Ovidiu Maxiniuc added
A buffer can set its own XML-NODE-NAME - and multiple buffers (for the same temp-table) can have different XML-NODE-NAME values; this will be used in WRITE-XML (and I think READ-XML, also) - see this test:
def temp-table tt1 field f1 as int.
def buffer btt1 for tt1 xml-node-name "xbtt1".
create tt1.
tt1.f1 = 10.
release tt1.
def var lc as longchar.
buffer btt1:write-xml("longchar", lc).
message string(lc). // xbtt1
buffer tt1:write-xml("longchar", lc).
message string(lc). // tt1
The conversion fix is in 9763a rev 15767.
The runtime fix requires to move the XML-NODE-NAME from the temp-table to the actual BufferImpl instance.
Eduard: can you look at this? Not very high prio, the conversion part is what is high prio.
Ovidiu: please review 9763a
#3 Updated by Ovidiu Maxiniuc over 1 year ago
Constantin Asofiei wrote:
Ovidiu: please review 9763a
9763a/15767 only adds conversion support for buffer's xml-node-name attribute. But the implementation will defer to setting the attribute on parent table:
public void BufferImpl.setXmlNodeName(String name)
{
buffer().getParentTable().setXmlNodeName(name);
}
The new value should be saved locally, in the buffer.
Also, the other attributes set to the buffer:
[ LABEL label-name ]
[ NAMESPACE-URI namespace ][ NAMESPACE-PREFIX prefix ]
[ XML-NODE-NAME node-name ][ SERIALIZE-NAME serialize-name ]should be handled the same. Right? I did not check each of them, but the situation is likely the same.#4 Updated by Constantin Asofiei over 1 year ago
- Status changed from Review to New
- Assignee set to Eduard Soltan
Ovidiu Maxiniuc wrote:
Constantin Asofiei wrote:
Ovidiu: please review 9763a
9763a/15767 only adds conversion support for buffer's
xml-node-nameattribute. But the implementation will defer to setting the attribute on parent table:
Yes, runtime needs to be fixed. Any concerns about the approach with the conversion?
Also, the other attributes set to the buffer:[...]should be handled the same. Right? I did not check each of them, but the situation is likely the same.
Probably.
Eduard: please do some small tests and see if conversion of these works properly.
#5 Updated by Eduard Soltan over 1 year ago
Constantin Asofiei wrote:
Eduard: please do some small tests and see if conversion of these works properly.
Conversion break for the following statment:
def temp-table tt1 field f1 as int.
def buffer btt1 for tt1 label "mybuffer"
NAMESPACE-URI "buffer_namespace"
NAMESPACE-PREFIX "my_prefix"
xml-node-name "xbtt1"
SERIALIZE-NAME "buf".
The converted output looks like this:
btt1.setXmlNodeName("xbtt1");
"mybuffer";
"buffer_namespace";
"my_prefix";
"buf";
This will happen with label, NAMESPACE-URI, NAMESPACE-PREFIX and SERIALIZE-NAME when taken separately.
#6 Updated by Constantin Asofiei over 1 year ago
I don't see any label support in BufferImpl, so we may want to defer that.
Otherwise, please create a more complex test for the other options, and see if they are used in JSON or XML write/read. If so, please work on the conversion changes.
#7 Updated by Ovidiu Maxiniuc over 1 year ago
Constantin Asofiei wrote:
9763a/15767 only adds conversion support for buffer's
xml-node-nameattribute. But the implementation will defer to setting the attribute on parent table:Yes, runtime needs to be fixed. Any concerns about the approach with the conversion?
Taking into consideration that the conversion is broken for these options of define buffer, I am puzzled how this issue surfaced only now. Apparently none of the existing customer projects uses this syntax. Only the latest customer does.
I think the prototype for conversion is correct.
From the conversion point of view, the buffers will have to keep a local copy of these attributes. When they are null / unknown (?), the will delegate the call to parent table, as we do now. This is the simple part. There are some other issues, related to serialisation. Most likely parts of TempTableSchema, XmlExport.java and JsonExport.java (not sure whether the import utilities, too) will have to adjust the accesses to these attributes via the provided BUFFER handle, not its TEMP-TABLE.
#8 Updated by Constantin Asofiei over 1 year ago
Eduard, so I found SERIALIZE-NAME also at the DEF BUFFER statement. Please work on adding all these. I don't know what LABEL is used for - can you find a test which shows how is used?
#9 Updated by Eduard Soltan over 1 year ago
Constantin Asofiei wrote:
Eduard, so I found
SERIALIZE-NAMEalso at theDEF BUFFERstatement. Please work on adding all these. I don't know whatLABELis used for - can you find a test which shows how is used?
According to the docs it is used in error messages instead of the actual buffer name;
LABEL label-name
Specifies a label for the buffer. This label is used in error messages in place of the buffer name.
def temp-table tt1 field f1 as int index idx1 is unique f1. def buffer btt1 for tt1 label "my_buffer". create btt1. btt1.f1 = 10. release btt1. create btt1. btt1.f1 = 10. release btt1.
The following program will display the the error message ** my_buffer already exists with 10. (132).
#10 Updated by Constantin Asofiei over 1 year ago
Is this LABEL only for buffers, or temp-table, too? Is it accessible via BUFFER btt1:LABEL = "something"?
#11 Updated by Eduard Soltan over 1 year ago
Constantin Asofiei wrote:
Is this LABEL only for buffers, or temp-table, too? Is it accessible via
BUFFER btt1:LABEL = "something"?
Well in the docs for temp-table statement definition there is no such thing as LABEL.
This syntax BUFFER btt1:LABEL = "something" or message BUFFER btt1:LABEL will give the following warning ** LABEL is not queryable/ setable attribute for BUFFER widget. (4052)
#12 Updated by Eduard Soltan over 1 year ago
Eduard Soltan wrote:
Constantin Asofiei wrote:
Is this LABEL only for buffers, or temp-table, too? Is it accessible via
BUFFER btt1:LABEL = "something"?Well in the docs for temp-table statement definition there is no such thing as
LABEL.
However the following syntax in OE will not raise any errors def temp-table tt1 field f1 as int label "my_table".
#13 Updated by Constantin Asofiei over 1 year ago
- Status changed from New to WIP
Eduard Soltan wrote:
However the following syntax in OE will not raise any errors
def temp-table tt1 field f1 as int label "my_table".
OK, add it there, too. Add a method to the Buffer interface.
Otherwise, please focus on the conversion for now.
#14 Updated by Eduard Soltan over 1 year ago
- vendor_id deleted (
GCD) - Assignee changed from Eduard Soltan to Eric Faulhaber
Committed on 9765a, rev. 15768. Conversion support for NAMESPACE-URI, NAMESPACE-PREFIX, SERIALIZE-NAME and LABEL buffer attributes.
#15 Updated by Eduard Soltan over 1 year ago
- Assignee changed from Eric Faulhaber to Eduard Soltan
#16 Updated by Constantin Asofiei over 1 year ago
Please post the test and how it converts now.
#17 Updated by Constantin Asofiei over 1 year ago
As LABEL is not an attribute for BUFFER or TEMP-TABLE (you can't set or get it via h:LABEL), then please do not use LabelAttribute or mark the methods with LegacyAttribute. Leave them only in Buffer.java, and also use UnimplementedFeature and for the getter just return unknown.
#18 Updated by Eduard Soltan over 1 year ago
Constantin Asofiei wrote:
Please post the test and how it converts now.
The 4gl test:
def temp-table tt1 field f1 as int.
def buffer btt1 for tt1 label "mybuffer"
NAMESPACE-URI "buffer_namespace"
NAMESPACE-PREFIX "my_prefix"
xml-node-name "xbtt1"
SERIALIZE-NAME "buf".
Converted output is:
btt1.setXmlNodeName("xbtt1");
btt1.namespaceURI("buffer_namespace");
btt1.namespacePrefix("my_prefix");
btt1.setSerializeName("buf");
btt1.setLabel("mybuffer");
#19 Updated by Eduard Soltan over 1 year ago
Constantin Asofiei wrote:
As
LABELis not an attribute for BUFFER or TEMP-TABLE (you can't set or get it viah:LABEL), then please do not useLabelAttributeor mark the methods withLegacyAttribute. Leave them only inBuffer.java, and also useUnimplementedFeatureand for the getter just return unknown.
Committed on 9763a, rev. 15770.
#20 Updated by Constantin Asofiei over 1 year ago
9763a rev 15771 changes return new character("label") to return character.UNKNOWN.
I'll move ahead with the conversion testing for this.
Otherwise, for the runtime parts, Eduard, please work in a second branch.
#21 Updated by Eduard Soltan over 1 year ago
Added runtime support for buffer attributes, on 9763b, rev. 15771.
buffer btt1:write-xml("longchar", lc).
buffer will use the attributes in buffer definition.
temp-table btt1:write-xml("longchar", lc).
temp-table will use the attributes in temp-table definition.
#22 Updated by Constantin Asofiei over 1 year ago
Eduard Soltan wrote:
Added runtime support for buffer attributes, on 9763b, rev. 15771.
buffer btt1:write-xml("longchar", lc).
bufferwill use the attributes in buffer definition.
temp-table btt1:write-xml("longchar", lc).
temp-tablewill use the attributes in temp-table definition.
Test also with buffer tt1:write-xml and buffer tt1:xml-node-name = "something".. I.e. use the default buffer instead of the temp-table definition. After that, check if this affects temp-table tt1:write-xml.
#23 Updated by Eduard Soltan over 1 year ago
Constantin Asofiei wrote:
Test also with
buffer tt1:write-xmlandbuffer tt1:xml-node-name = "something".. I.e. use the default buffer instead of the temp-table definition. After that, check if this affectstemp-table tt1:write-xml.
temp-table definition sets the attributes of the default buffer.
temp-table tt1:write-xml and buffer tt1:write-xml will give the same result.
If I will try to modify some attributes of the default buffer with statement buffer tt1:xml-node-name = "something". Execution of temp-table btt1:write-xml("longchar", lc)., will use the use the updated version of xml-node-name.
Committed on 9763b, rev. 15772 this aspect.
#24 Updated by Constantin Asofiei over 1 year ago
- Status changed from WIP to Internal Test
- % Done changed from 0 to 50
Please do some minimal tests with 9763a to get this into trunk.
#25 Updated by Ovidiu Maxiniuc over 1 year ago
I looked at 9763a and I do NOT agree with the implementation.
IMHO, the values of these new attributes should be stored at BufferImpl level, not in RecordBuffer. The set to null should only be ignored for the default buffer, not the others. The XmlExport.java should simply take the attribute from the buffer, not compute it locally.
At any rate, the changes in (only a new import for IOException) AbstractTempTable.java should be reverted.
Please use the following procedure for tests:
output to /tmp/9763.out.
def temp-table tt1 field f1 as int.
def buffer btt1 for tt1 xml-node-name "xbtt1".
message temp-table tt1:xml-node-name temp-table btt1:xml-node-name. // tt1 tt1
create tt1.
tt1.f1 = 10.
release tt1.
def var lc as longchar.
buffer btt1:write-xml("longchar", lc).
message "~n" buffer btt1:xml-node-name string(lc). // xbtt1
buffer tt1:write-xml("longchar", lc).
message buffer tt1:xml-node-name string(lc). // tt1
buffer btt1:xml-node-name = ?. // remove local copy
buffer btt1:write-xml("longchar", lc).
message "~n" buffer btt1:xml-node-name string(lc). // tt1 (from default)
buffer tt1:write-xml("longchar", lc).
message buffer tt1:xml-node-name string(lc). // tt1
buffer btt1:xml-node-name = "bla-bla". // overwrite local copy
buffer btt1:write-xml("longchar", lc).
message "~n" buffer btt1:xml-node-name string(lc). // bla-bla
buffer tt1:write-xml("longchar", lc).
message buffer tt1:xml-node-name string(lc). // tt1
buffer tt1:xml-node-name = ?. // no effect
temp-table tt1:xml-node-name = ?. // no effect
buffer btt1:write-xml("longchar", lc).
message "~n" buffer btt1:xml-node-name string(lc). // bla-bla
buffer tt1:write-xml("longchar", lc).
message buffer tt1:xml-node-name string(lc). // tt1
#26 Updated by Constantin Asofiei over 1 year ago
Ovidiu Maxiniuc wrote:
I looked at 9763a and I do NOT agree with the implementation.
I assume you mean 9763b.
#27 Updated by Ovidiu Maxiniuc over 1 year ago
Constantin Asofiei wrote:
I assume you mean 9763b.
Yes, you are right. Sorry, I did not realise that there are 2 branches. I have not (yet) looked at 9763a.
#28 Updated by Ovidiu Maxiniuc over 1 year ago
I looked at 9763a.
buffer_definitions.rules:- contains some hard tabs (
#09,\t) - rules should use token names in lower-case:
this.downPath(prog.KW_NAMESP_U), etc - I think we may have a problem with
setXmlNodeNameandsetSerializeName. They should be replaced withxmlNodeNameandserializeNameto avoid collisions with property setters of the records.
However, this will probably be deferred to another task.
- contains some hard tabs (
#29 Updated by Constantin Asofiei over 1 year ago
Ovidiu, you are right. Eduard: for now, please rename setLabel and getLabel to label; this way we don't introduce new issues. setXmlNodeName and setSerializeName already are defined in Buffer.
I think we need to add some 'safety code' in FWD, so that if it finds a collision between a DMO getter/setter and Buffer methods, then FWD will abend. We need to 'fail early' if there are such cases.
#30 Updated by Ovidiu Maxiniuc over 1 year ago
Constantin Asofiei wrote:
Ovidiu, you are right. Eduard: for now, please rename
setLabelandgetLabeltolabel; this way we don't introduce new issues.setXmlNodeNameandsetSerializeNamealready are defined in Buffer.
I think a field cannot be name label in 4GL.
I think we need to add some 'safety code' in FWD, so that if it finds a collision between a DMO getter/setter and Buffer methods, then FWD will abend. We need to 'fail early' if there are such cases.
My suggestion - I think of some time - is to have a better distinction between the record and the buffer. Assuming the following procedure:
define temp-table tt001 serialize-name "x-data" label "xlabel" field serialize-name as character. define variable btt0 as handle. btt0 = buffer tt001:handle. create tt001. buffer tt001:serialize-name = "d-data". tt001.serialize-name = buffer tt001:serialize-name. message tt001.serialize-name.We generate the following code:
tt001.create();
buffer(tt001).unwrapNamedSerializable().setSerializeName(new character("d-data"));
tt001.setSerializeName(buffer(tt001).unwrapNamedSerializable().getSerializeName());
message((character) new FieldReference(tt001, "serializeName").getValue());But it should rather be: tt001.create();
buf(tt001).setSerializeName(new character("d-data"));
tt001.setSerializeName(buf(tt001).getSerializeName());
message((character) new FieldReference(tt001, "serializeName").getValue());
In other words, translate tt001.serialize-name as before, tt001.getSerializeName()but
buffer tt001:serialize-name as buf(tt001).getSerializeName() instead of buf fer (tt001) .unwrapNamedSerializable() .getSerializeName()
This new buf should do the unwrapping automatically for tables and buffers it would return the cast to a BufferImpl:
public static BufferImpl buf(Buffer b) {
return (BufferImpl) b;
}
Notice that the generated code is a bit more simple. There is no intermediary wrapping into a handle (this is what the current buffer() does)Also, there is a chance that this will drop need for a proxy? Since there are no collisions any more.
Is my thinking too simple? Please let me know if I am in error.
#31 Updated by Eduard Soltan over 1 year ago
Constantin Asofiei wrote:
Ovidiu, you are right. Eduard: for now, please rename
setLabelandgetLabeltolabel; this way we don't introduce new issues.setXmlNodeNameandsetSerializeNamealready are defined in Buffer.I think we need to add some 'safety code' in FWD, so that if it finds a collision between a DMO getter/setter and Buffer methods, then FWD will abend. We need to 'fail early' if there are such cases.
I removed the hard tabs, and renamed the token names to lowercase. Since the label is not a valid name for 4gl field, I assume I could leave setLabel and getLabel. Also in this case logic for temp-table tt1:label = "labe2" should also be modified, which could cause problems with other 4gl structures.
Did a conversion of the following programe, and it went propely:
DEFINE VARIABLE bh AS HANDLE NO-UNDO.
def temp-table tt1 LABEL "label"
NAMESPACE-URI "namespace_url"
NAMESPACE-PREFIX "amespace-prefix"
XML-NODE-NAME "xml_node_name"
SERIALIZE-NAME "seraization_name"
field f1 as int.
def buffer btt1 for tt1 LABEL "label1"
NAMESPACE-URI "namespace_url1"
NAMESPACE-PREFIX "namespace_prefix1"
XML-NODE-NAME "xml_node_name1"
SERIALIZE-NAME "seraization_name1".
buffer tt1:label = "1abel2".
temp-table tt1:label = "labe2".
message buffer tt1:label.
buffer tt1:xml-node-name = "xml-node-name2".
temp-table tt1:xml-node-name = "xml-node-name2".
message buffer tt1:xml-node-name.
buffer tt1:namespace-uri = "namespace_uri2".
temp-table tt1:namespace-uri = "namespace_uri2".
message buffer tt1:namespace-uri.
buffer tt1:namespace-prefix = "namespace-prefix2".
temp-table tt1:namespace-prefix = "namespace-prefix2".
message buffer tt1:namespace-prefix.
buffer tt1:serialize-name = "serialize-name2".
temp-table tt1:serialize-name = "serialize-name2".
message buffer tt1:serialize-name.
I think I will have converted Regression test project just to make sure it does not break.
#32 Updated by Constantin Asofiei over 1 year ago
Eduard, the fact that 4GL doesn't allow label as a field name doesn't mean is not possible for the DMO property name to get converted to getLabel and setLabel.
#33 Updated by Eduard Soltan over 1 year ago
Constantin Asofiei wrote:
Eduard, the fact that 4GL doesn't allow
labelas a field name doesn't mean is not possible for the DMO property name to get converted togetLabelandsetLabel.
I understand that. I put the change of label methods in rev. 15774.
#34 Updated by Eduard Soltan over 1 year ago
I performed a conversion of Regression test project with 9763a, rev. 15774. And it went without any problems.
#35 Updated by Constantin Asofiei over 1 year ago
You are missing history entry in a file.
#36 Updated by Eduard Soltan over 1 year ago
Constantin Asofiei wrote:
You are missing history entry in a file.
Added history entry.
#37 Updated by Constantin Asofiei over 1 year ago
- Status changed from Internal Test to Merge Pending
Please merge after 9756a.
#38 Updated by Eduard Soltan over 1 year ago
9763a was merged into trunk revision 15785 and archived.
#39 Updated by Eduard Soltan over 1 year ago
- Status changed from Merge Pending to WIP
#40 Updated by Eduard Soltan over 1 year ago
Main faindings regarding buffer attributes:
NAMESPACE-URI
1) for statement buffer btt1:NAMESPACE-URI, it will be used the namepace-uri of the buffer or empty character.
2) for statement temp-table btt1:NAMESPACE-URI, it will be used the namepace-uri of the default buffer or empty character.
NAMESPACE-PREFIX
1) for statement buffer btt1:NAMESPACE-PREFIX, it will be used the namepace-prefix of the buffer or empty character.
2) for statement temp-table btt1:NAMESPACE-PREFIX, it will be used the namepace-prefix of the default buffer or empty character.
XML-NODE-NAME
1) for statement buffer btt1:XML-NODE-NAME, it will be used the xml-node-name of the buffer. If xml-node-name is unknown, it will fallback to SERIALIZE-NAME of the buffer. And if serialization-name is null, it will fallback to the table name.
1) for statement temp-table btt1:XML-NODE-NAME, it will be used the xml-node-name of the default buffer. If xml-node-name is unknown, it will fallback to SERIALIZE-NAME of the default buffer. And if serialization-name is null, it will fallback to the table name.
SERIALIZE-NAME
1) for statement buffer btt1:SERIALIZE-NAME, it will be used the SERIALIZE-NAME of the buffer. If serialization-name is null, it will fallback to the table name.
2) for statement temp-table btt1:SERIALIZE-NAME, it will be used the SERIALIZE-NAME of the default buffer. If SERIALIZE-NAME is null, it will fallback to the table name.
Same applies to the write-xml operation:
1) buffer btt1:write-xml will use only the attributes of the buffer.
2) temp-table btt1:write-xml will only use the attributes of the default table.
Read-Xml operation¶
The only attributes of interest in read operation are xml-node-name and SERIALIZE-NAME.
- for statement buffer btt1:read-xml there are 3 cases, note the attributes are for buffer definitions:
1) xml-node-name is set, in this case it will search only for XML tags that math the value in xml-node-name.
2) xml-node-name not set and SERIALIZE-NAME set, in this case it will search only for XML tags that match the value in SERIALIZE-NAME.
3) xml-node-name not set and SERIALIZE-NAME not set, in this case it will search only for XML tags that match the value in SERIALIZE-NAME.
- same goes for temp-table btt1:read-xml, only the attributes are for temp-table definitions or default buffer.
For NAMESPACE-PREFIX and NAMESPACE-URI are in correct form in XML file, this does not have any effect on attributes of the buffer.
JSON¶
For JSON the only attribute of interests in SERIALIZE-NAME.
1) For buffer btt1:write-json it will be used the SERIALIZE-NAME of the buffer. If SERIALIZE-NAME is null, it will fallback to the table name.
2) For temp-table btt1:write-json it will be used the SERIALIZE-NAME of the default buffer. If SERIALIZE-NAME is null, it will fallback to the table name.
The same goes with read-xml.
I committed on 9763b, rev. 15792, changes to address the behaviour.
#41 Updated by Constantin Asofiei over 1 year ago
Eduard, isn't SERIALIZE-NAME used for JSON? So please try READ-JSON and WRITE-JSON.
#42 Updated by Eduard Soltan over 1 year ago
Constantin Asofiei wrote:
Eduard, isn't
SERIALIZE-NAMEused for JSON? So please tryREAD-JSONandWRITE-JSON.
Yes, SERIALIZE-NAME is used for JSON. I updated my previous post with info of that.
#43 Updated by Constantin Asofiei over 1 year ago
Created task branch 9763c from trunk rev 15790. 15791 fixes a problem with an edge case (regression in trunk 15785), where a DEFINE BUFFER b FOR b. needs to be dropped completely, if 'b' default buffer is used before this statement, all while in an internal procedure.
#44 Updated by Constantin Asofiei over 1 year ago
Branch 9763c was merged to trunk rev 15800 and archived.
#45 Updated by Constantin Asofiei over 1 year ago
Eduard, is 9763b ready for review?
#46 Updated by Eduard Soltan over 1 year ago
- Status changed from WIP to Review
- % Done changed from 50 to 100
Constantin Asofiei wrote:
Eduard, is 9763b ready for review?
Yes, it is ready for review.
#47 Updated by Ovidiu Maxiniuc over 1 year ago
Review of 9763b/15792
This is pretty good, but there are several things which must be addressed:AbstractTempTable.java:- line 105: the H entry is a bit misleading/reversed. The implementation was actually delegated from temp-table to the default buffer;
- line 2535: isn't the correct code is
defaultBuffer.namespaceURI(uri); - lines 2660-2692: these method seem to be duplicates of 2695-2725? The file most likely fill not compile. At the same time I think we can implement the
labelaccessors methods by raising error 4052:
for the setter andErrorManager.recordOrShowError(4052, "LABEL", "setable" /*sic*/, LegacyResource.TEMP_TABLE + " widget");
for the getter, instead of theErrorManager.recordOrShowError(4052, "LABEL", "queryable", LegacyResource.TEMP_TABLE + " widget"); return character.UNKNOWN;UnimplementedFeature.
BufferImpl.java:- line 4961: the javadoc mentions
NAMESPACE-PREFIXbut the method's name isnamespaceURI(); - all affected methods: why dropping of
@Overrideannotation? - line 4968: comparing to the original code from temp-table, in case the
namespaceURIis null / not initialised, an empty string should be returned. Have you tested and found otherwise? - line 4979: as above, assigning unknown/null value to
NAMESPACE-URIshould raise 4083, not only simply return:
Note that, at least in this case, the error is aware of the originating handle. When the buffer handle is used, theErrorManager.recordOrShowError(4083, " NAMESPACE-URI", LegacyResource.TEMP_TABLE + " widget");LegacyResource.BUFFERis used instead. That means that the test for null/unknown argument should be performed inAbstractTempTablebefore delegating the call to its default buffer. Please check the other attributes, as well. - lines 5036-5067: please see the notes on
LABELattribute from theTEMP-TABLEimplementation above; - lines 5137-5162: the javadocs seem mangled/mixed;
- line 5637: a redundant line between the javadoc and the method;
- line 4961: the javadoc mentions
RecordBuffer.java: the H entry can be dropped, there are no other changes in this file, anymore.
#48 Updated by Eduard Soltan over 1 year ago
Ovidiu Maxiniuc wrote:
- lines 2660-2692: these method seem to be duplicates of 2695-2725? The file most likely fill not compile. At the same time I think we can implement the
labelaccessors methods by raising error 4052:[...]for the setter and[...]for the getter, instead of theUnimplementedFeature.
The file will compile but an warning will be displayed.
- line 4968: comparing to the original code from temp-table, in case the
namespaceURIis null / not initialised, an empty string should be returned. Have you tested and found otherwise?
Yes, for both temp-table and buffer (buffer btt1:NAMESPACE-URI. and btt1:NAMESPACE-URI.) will return ?.
- line 4979: as above, assigning unknown/null value to
NAMESPACE-URIshould raise 4083, not only simply return:[...]Note that, at least in this case, the error is aware of the originating handle. When the buffer handle is used, theLegacyResource.BUFFERis used instead. That means that the test for null/unknown argument should be performed inAbstractTempTablebefore delegating the call to its default buffer. Please check the other attributes, as well.
Modified just for NAMESPACE-PREFIX.
Fixed review issues in rev. 15793.
#49 Updated by Eduard Soltan over 1 year ago
Also initialize to defaultBuffer in StaticTempTable before setting up its attributes.
#50 Updated by Ovidiu Maxiniuc over 1 year ago
Eduard, for some reasons I missed some files in #9763-47 (I think I pressed Ctrl+C in wrong console):
JsonExport.java,JsonImport.java,XmlExport.java, andXmlImport.java:- missing the H entry (and copyright year to be updated);
- line 884, 635, 718, 873, respectively: I do not think there is computation in these lines. The
serializeNamealways uses thecurrentBuffer, in caseisDefaultBufferistruethetempTablewill use its default buffer which is actuallycurrentBuffer. So the original piece of code
should be simply replaced withTempTable tempTable = buffer.getParentTable(); String serializeName = tempTable.getSerializeName().toJavaType();
if that is the correct behaviour. And similar for rest of the files.String serializeName = ((Buffer) buffer.getDMOProxy()).getSerializeName().toJavaType();
- Do not forget to add the #refid to the comment when you do the commit.
Finally, please check these test cases
Compare the output from FWD and 4GL. I used output to file to be easier to compare (meld) their results.
#51 Updated by Eduard Soltan over 1 year ago
Committed on 9763a, rev. 15796.
I modified the JsonImport, JsonExport, XmlExport and XmlImport, to use just the currentBuffer in getting the attributes.
I had to modify the namespaceUri methods not to generate a empty Java string when trying to set a character.UNKNOWN.
And the fwd output of the previous test matches completely the 4GL output.
#52 Updated by Ovidiu Maxiniuc over 1 year ago
- Status changed from Review to Internal Test
Eduard Soltan wrote:
A couple of minor observations:Committed on 9763a, rev. 15796.
- Please revert
RecordBuffer.javaandJsonImport.javato their versions from r15789, as they have no actual code changes anymore; JsonExport.java,XmlImport.javaandXmlExport.javarequire the copyright year update.
And the fwd output of the previous test matches completely the 4GL output.
That's good news. Please go ahead with internal testing after the minor changes above.
#53 Updated by Eduard Soltan over 1 year ago
I tested read-json and read-xml, and they are fine.
Also made some tests with datasets (define dataset dtt1 for btt1.), and noticed a few things:
- write-json and read-json for dataset are good, since for buffer write it will use JsonExport.serializeTempTable method that it also used in buffer:writeJson. And for
- read-json is good, since the JsonImport.readDataSetContent method will use SerializeName of the buffers.
- write-xml for dataset is not ok, some attributes of the temp-table are used (namespaceURI, namespacePrefix).
#54 Updated by Eduard Soltan over 1 year ago
Ovidiu, why do we use if (buffer.getSerializeName().toStringMessage().equalsIgnoreCase(name) in XmlImport.importDataset, to match the XML token to a buffer? From what I tested xml-node-name always takes precedence.
#55 Updated by Radu Apetrii over 1 year ago
Testing on another customer application was successful. No more errors encountered nor strange behaviors. ✅
#56 Updated by Eduard Soltan over 1 year ago
The unit tests and smoke tests of a large GUI application went fine.✅
Also got some news that unit test of a very large application have a 5% increase rate when run 9763b. But it has to be checked with a new baseline.
#57 Updated by Ovidiu Maxiniuc over 1 year ago
Eduard Soltan wrote:
Ovidiu, why do we use
if (buffer.getSerializeName().toStringMessage().equalsIgnoreCase(name)inXmlImport.importDataset, to match the XML token to a buffer? From what I testedxml-node-namealways takes precedence.
I did a bit of digging and I think the reason is because the original implementation of getSerializeName() was returning the SERIALIZE-NAME attribute, only if it was expressly set. For that, the name of the buffer was checked in XmlImport. More recent code added this check right into getSerializeName():
return new character(serializeName == null || serializeName.trim().isEmpty() ? name : serializeName);Therefore, the check in XmlImport.importDataset became redundant.#58 Updated by Eduard Soltan over 1 year ago
There is a regression in at dataset ddt1:read-xml, when has no buffer set.
In XmlImport.importDataset it go on if (numBuf == 0) branch and will create a TempTableBuilder.
ctx.tt = new TempTableBuilder();
String ttNsUri = reader.getNamespaceURI();
String ttNsPrefix = reader.getPrefix();
if (ttNsUri != null)
{
ctx.tt.namespaceURI(ttNsUri);
}
if (ttNsPrefix != null)
{
ctx.tt.namespacePrefix(ttNsPrefix);
}
The problem is that TempTableBuilder does not initialize the defaultBuffer. Hence setting the namespaceURI or namespacePrefix will result in NPE.
#59 Updated by Eduard Soltan over 1 year ago
Eduard Soltan wrote:
The problem is that
TempTableBuilderdoes not initialize thedefaultBuffer. Hence setting thenamespaceURIornamespacePrefixwill result in NPE.
I am thinking to initialize the ctx.tt.tempTablePrepare and create the defaultBuffer, but this will result in a error because I don't have any fields added yet.
#60 Updated by Ovidiu Maxiniuc over 1 year ago
The AbstractTempTable has two specialised subclasses: StaticTempTable and TempTableBuilder (for dynamic temp-tables). In the former case case, the default buffer is created automatically (statically) even before the code of procedure that declares it starts to be executed. For the latter, the buffer is created only AFTER the temp-table is prepared. This is the case you are encountering. Only in this particular case (AbstractTempTable._dynamic() returns true), the attributes should be temporarily stored in TempTableBuilder until it is prepared and the default buffer created (see createDefaultBuffer()). That why it is called a 'builder', after all.
#61 Updated by Ovidiu Maxiniuc over 1 year ago
Eduard Soltan wrote:
I am thinking to initialize the
ctx.tt.tempTablePrepareand create thedefaultBuffer, but this will result in a error because I don't have any fields added yet.
No, the defaultBuffer should be initialised at that specific time. Therefore, the attributes should be accumulated in the builder and set all at once, when the buffer is created.
#62 Updated by Eduard Soltan over 1 year ago
Ovidiu Maxiniuc wrote:
Only in this particular case (
AbstractTempTable._dynamic()returnstrue), the attributes should be temporarily stored inTempTableBuilderuntil it is prepared and the default buffer created (seecreateDefaultBuffer()). That why it is called a 'builder', after all.
I was think about that, working now to add back the attributes to AbstractTempTable and will set them in AbstractTempTable only when defaultBuffer is null. And when the defualtBuffer is indeed created, will set the attributes.
#63 Updated by Ovidiu Maxiniuc over 1 year ago
Not in AbstractTempTable, just in TempTableBuilder.
LE: and the attributes will be set in TempTableBuilder.createDefaultBuffer(), as noted above, after initialisation of defaultBuffer.
#64 Updated by Eduard Soltan over 1 year ago
Ovidiu Maxiniuc wrote:
Not in
AbstractTempTable, just inTempTableBuilder.
But this implies to override all the setter and getter for the attributes in TempTableBuilder.
#65 Updated by Ovidiu Maxiniuc over 1 year ago
Indeed, it does. This is specific to dynamic temp-tables, therefore, this is the proper place to do it.
LE: the implementation of a setter would look like:
setAttribute(value) :
if (!prepared)
store-locally(value)
else
super.setAttribute(value)and similar for the getter.#66 Updated by Eduard Soltan over 1 year ago
Committed on 9763b, rev. 15832.
Sure thing, I added the method in TempTableBuilder, and the attributes will be set in tempTablePrepareImpl, the only place where createDefaultBuffer is called.
#67 Updated by Ovidiu Maxiniuc over 1 year ago
Good, that's the idea.
I think the code will work as expected. My observations forTempTableBuilder.java, the only affected file are only related to optimisation and code aspect:
- methods like
namespacePrefix(character prefix)do not need to be overridden. The code is identical as insuperclass; - lines 2781-2804: why don't set the attributes directly on the default buffer?
- lines 1241, 1286: the code is difficult to read because the ternary operator is used with different layouts. Also the length of the line is too long. Try a solution would be to replace the first with an
if(which is also consequent with the similar/neighbour methods); - note: the way 4GL checks if a dynamic temp-table is 'ready' for use is the
PREPAREDattribute. Along the code we used_prepared()method, which is the actual unwrapped implementation. Testing withdefaultBuffer == nullwill do, though.
#68 Updated by Eduard Soltan over 1 year ago
I have made the modification in TempTableBuilder.
But also made some changes in XmlExport and XmlExport to match the write-xml and read-xml methods.
Some test wrote for testing of write-xml:
def temp-table tt1 NAMESPACE-URI "namespace_url0"
NAMESPACE-PREFIX "amespace-prefix0"
XML-NODE-NAME "xml_node_name0"
SERIALIZE-NAME "seraization_name0"
LABEL "label"
BEFORE-TABLE before-table-name
field f1 as int.
define buffer btt1 for tt1 NAMESPACE-URI "namespace_url01"
NAMESPACE-PREFIX "amespace-prefix01"
XML-NODE-NAME "xml_node_name01"
SERIALIZE-NAME "seraization_name01"
temp-table tt1:TRACKING-CHANGES = true.
create tt1. f1 = 1.
create tt1.
define variable xml as longchar.
define dataset dtt1 for tt1.
dataset dtt1:write-xml("longchar", xml).
message string(xml).
For write-xml:
def temp-table tt1 NAMESPACE-URI "namespace_url0"
NAMESPACE-PREFIX "amespace-prefix0"
XML-NODE-NAME "xml_node_name0"
SERIALIZE-NAME "seraization_name0"
LABEL "label"
BEFORE-TABLE before-table-name
field f1 as int.
define buffer btt1 for tt1 NAMESPACE-URI "namespace_url01"
NAMESPACE-PREFIX "amespace-prefix01"
XML-NODE-NAME "xml_node_name01"
SERIALIZE-NAME "seraization_name01"
temp-table tt1:TRACKING-CHANGES = true.
create tt1. f1 = 1.
create tt1.
DEFINE VARIABLE cSourceType AS CHARACTER NO-UNDO.
DEFINE VARIABLE cReadMode AS CHARACTER NO-UNDO.
DEFINE VARIABLE lOverrideDefaultMapping AS LOGICAL NO-UNDO.
DEFINE VARIABLE cFile AS CHARACTER NO-UNDO.
DEFINE VARIABLE cSchemaLocation AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFieldTypeMapping AS CHARACTER NO-UNDO.
DEFINE VARIABLE cVerifySchemaMode AS CHARACTER NO-UNDO.
DEFINE VARIABLE lRetOK AS LOGICAL NO-UNDO.
ASSIGN
cSourceType = "file"
cFile = "file.json"
cReadMode = "empty"
cSchemaLocation = ""
lOverrideDefaultMapping = ?
cFieldTypeMapping = ?
cVerifySchemaMode = ?.
lRetOK = dataset dtt1:READ-json(cSourceType, cFile, cReadMode).
for each btt1:
message btt1.f1 .
end.
#69 Updated by Ovidiu Maxiniuc over 1 year ago
Eduard Soltan wrote:
I have made the modification in
TempTableBuilder.
The setters use _prepared() and the getters defaultBuffer != null for same condition.
But also made some changes in
XmlExportandXmlExportto match thewrite-xmlandread-xmlmethods.
No objections except for copyright year.
Some test wrote for testing of
write-xml:
[...]
Forwrite-xml:
[...]
I see READ-json, I was expecting a read-xml based on the changes in XmlImport.java, right?
#70 Updated by Eduard Soltan over 1 year ago
Ovidiu Maxiniuc wrote:
[...]
I see
READ-json, I was expecting aread-xmlbased on the changes inXmlImport.java, right?
Sorry, meant to post the following test:
def temp-table tt1 NAMESPACE-URI "namespace_url0"
NAMESPACE-PREFIX "amespace-prefix0"
XML-NODE-NAME "xml_node_name0"
SERIALIZE-NAME "seraization_name0"
LABEL "label"
BEFORE-TABLE before-table-name
field f1 as int.
define buffer btt1 for tt1 NAMESPACE-URI "namespace_url01"
NAMESPACE-PREFIX "amespace-prefix01"
XML-NODE-NAME "xml_node_name01"
SERIALIZE-NAME "seraization_name01"
temp-table tt1:TRACKING-CHANGES = true.
create tt1. f1 = 1.
create tt1.
DEFINE VARIABLE cSourceType AS CHARACTER NO-UNDO.
DEFINE VARIABLE cReadMode AS CHARACTER NO-UNDO.
DEFINE VARIABLE lOverrideDefaultMapping AS LOGICAL NO-UNDO.
DEFINE VARIABLE cFile AS CHARACTER NO-UNDO.
DEFINE VARIABLE cSchemaLocation AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFieldTypeMapping AS CHARACTER NO-UNDO.
DEFINE VARIABLE cVerifySchemaMode AS CHARACTER NO-UNDO.
DEFINE VARIABLE lRetOK AS LOGICAL NO-UNDO.
ASSIGN
cSourceType = "file"
cFile = "file.xml"
cReadMode = "empty"
cSchemaLocation = ""
lOverrideDefaultMapping = ?
cFieldTypeMapping = ?
cVerifySchemaMode = ?.
lRetOK = dataset dtt1:read-xml(cSourceType, cFile, cReadMode, cSchemaLocation, lOverrideDefaultMapping, cFieldTypeMapping, cVerifySchemaMode).
for each btt1:
message btt1.f1 .
end.
Test from the previous post I used to read-json and it works as expected.
#71 Updated by Eduard Soltan over 1 year ago
Testing performed with rev. 15835:
- unit tests of a large customer application ✅
- harness ✅
- Chui regression testing ✅
- unit test and smoke tests of a large GUI application ✅
- smoke of a GUI application ✅
#72 Updated by Eduard Soltan about 1 year ago
Rebased to latest trunk, rev. 15937. Did some quick smoke testing and unit tests of a large GUI application and it passed.
#73 Updated by Ovidiu Maxiniuc about 1 year ago
Do you mean 9763b? The current revision is 15835. Is it possible you pushed to different branch?
#74 Updated by Eduard Soltan about 1 year ago
Ovidiu Maxiniuc wrote:
Do you mean 9763b? The current revision is 15835. Is it possible you pushed to different branch?
Yes it the 9763b branch, I run 9763b bzr push --overwrite ~/secure/code/p2j_repo/p2j/active/9763b, but it is taking a very long time.
#75 Updated by Eduard Soltan about 1 year ago
Eduard Soltan wrote:
Yes it the 9763b branch, I run 9763b
bzr push --overwrite ~/secure/code/p2j_repo/p2j/active/9763b, but it is taking a very long time.
Now the 9763b, is at revision 15949.
#76 Updated by Ovidiu Maxiniuc about 1 year ago
I had one more quick look over 9763b, r15949.
In BufferImpl.java, I think there is a rebase error, ** 139 ES 20250508 was overwritten by ** 139 ES 20250313. And there are a few usages of the character constructor which should have been replaced by character.of() static method. But since you have already tested the branch and it was a success, let's defer this for another time, do avoid the unnecessary risk.
In RecordBuffer.java, all code changes were removed and only H entry remained. Please revert this as well.
Side note:
Instead of ~/secure/code/p2j_repo/p2j/active/9763b, try using bzr+ssh://localhost:2224/opt/secure/code/p2j_repo/p2j/active/9763b. It is much faster. You can do this when checking out, as well. You only need to have your signature installed on your /.ssh folder on the dev server.
#77 Updated by Eduard Soltan about 1 year ago
Fixed rebase issues in rev. 15950. Is additional testing necessary?
#78 Updated by Constantin Asofiei about 1 year ago
- BufferImpl - missing history number
- RecordBuffer - no actual change, use 'bzr revert' to get it to branch's trunk level
Ovidiu: any other concerns?
#79 Updated by Ovidiu Maxiniuc about 1 year ago
No, everything seems correct now.
#80 Updated by Constantin Asofiei about 1 year ago
- Status changed from Internal Test to Merge Pending
Eduard, you can merge 9763b now.
#81 Updated by Eduard Soltan about 1 year ago
- Status changed from Merge Pending to Test
9763b was merged to trunk rev. 15942 and archived.
#83 Updated by Teodor Gorghe 12 months ago
- Related to Bug #10308: DYNAMIC TEMP-TABLE issue when using READ-XML before TEMP-TABLE-PREPARE added
#84 Updated by Eduard Soltan 10 months ago
Exporting of child buffer (in a dataset relation) is using the attributes from TempTableSchema, when it should switch to buffer attributes.
Committed on 9763c, rev. 16177.
#85 Updated by Eduard Soltan 10 months ago
- Status changed from Test to WIP
#86 Updated by Eduard Soltan 10 months ago
- Status changed from WIP to Review
#88 Updated by Ovidiu Maxiniuc 10 months ago
- Status changed from Review to Internal Test
I think the update is fine. Please go ahead with internal testing.
#89 Updated by Constantin Asofiei 10 months ago
Eduard, please merge after 10586a.
#90 Updated by Constantin Asofiei 10 months ago
- Status changed from Internal Test to Merge Pending
#91 Updated by Eduard Soltan 10 months ago
- Status changed from Merge Pending to Test
9763c was merged to trunk rev. 16202 and archived.