rbeckman-nextgen / test-mc

test-migration
1 stars 0 forks source link

Message tree drag-and-drop has incorrect syntax when namespaces / bound prefixes are present #3147

Closed rbeckman-nextgen closed 4 years ago

rbeckman-nextgen commented 4 years ago

If the actual node you're dragging has a namespace reference (like ), the drag-and-drop E4X syntax is incorrect. Currently it pastes msg['S:Body'], which will not work in actual message processing.

One option is to just always include wildcards, like msg.*::['Body']. That way it should always work regardless of what namespace is present.

The more "correct" way to do it would be to actually define the namespace and reference it (like "var S = new Namespace(...)" and then msg.S::['Body']), but that would require creating two steps, one JavaScript to define the namespace, and then the actual Mapper / Message Builder step. This might be too confusing/complex, so maybe it's better to leave that for MIRTH-1110.

Imported Issue. Original Details: Reporter: narupley Created: 2014-03-20T14:54:33.000-0700

rbeckman-nextgen commented 4 years ago

Added a patch for this. If an element contains a namespace we add a wildcard in dot notation.

Imported Comment. Original Details: Author: eduardoa Created: 2016-01-29T13:13:26.000-0800

rbeckman-nextgen commented 4 years ago

If json properties can have a colon then this would probably need to exclude the change for json data type.

Imported Comment. Original Details: Author: eduardoa Created: 2016-01-29T13:32:51.000-0800

rbeckman-nextgen commented 4 years ago

Updated patch so that it only applies to XML serialization.

As of now I think we just need to decide if we would like to apply this change. The patch I uploaded will wildcard the namespace. RIght now the drag and drop with namespaces does not work at all, but always adding a wildcard is not 100%. Adding the namespace correctly might be pretty tricky since there would need to be some extra js tied to the drag and drop.

One possibility is to wildcard the namespace and notify the user that the wildcard has been applied. Then we could still leave the correct implementation for MIRTH-1110

Imported Comment. Original Details: Author: eduardoa Created: 2016-02-29T15:12:27.000-0800

rbeckman-nextgen commented 4 years ago

rev 7956: We now assign nodes types as we iterate from child to parent to add more versatility to namespace drag and drop. The drag and drop can drag nodes, attribute or namespace attributes so the user should be able to correctly do these now. If a node has a namespace then will wildcard it. If an ancestor of the node has an implicit namespace then we will also append a wildcard. The only exception to this is if the implicit namespace is on the root node, we actually set this to the default namespace in JavaScriptBuilder.

Imported Comment. Original Details: Author: eduardoa Created: 2016-03-25T15:14:54.000-0700

rbeckman-nextgen commented 4 years ago

Here are the type of things we have to test for this ticket. Keep in mind that we are just testing the drag and drop so any old code won't be affected.

This is a good xml to test that prefixes are being correctly spotted and wildcarded. {code}

Book Review XML: A Primer Author Price Pages Date Simon St. Laurent 31.98 352 1998/01 {code} And the test would look something like this: {code} //test logger.info(msg['@test'].toString()); //http://www.w3.org/HTML/1998/html4 logger.info(msg.namespace('h').toString()); //testttt logger.info(msg.*::['head']['@test'].toString()); //Book Review logger.info(msg.*::['head'].*::['title'].toString()); //xml stuff here logger.info(msg.*::['body'].*::['bookreview'].toString()); //http://www.w3.org/1999/xhtml logger.info(msg.*::['body'].*::['bookreview'].*::['table'].namespace('').toString()); //Author logger.info(msg.*::['body'].*::['bookreview'].*::['table'].*::['tr'][0].*::['td'][0].toString()); //Pages logger.info(msg.*::['body'].*::['bookreview'].*::['table'].*::['tr'][0].*::['td'][2].toString()); //left logger.info(msg.*::['body'].*::['bookreview'].*::['table'].*::['tr'][1]['@align'].toString()); {code} This is an example of when the root node has an implicit namespace so no wildcards should be added {code} test2 {code} {code} //"http://www.w3.org/1999/xhtml logger.info(msg.namespace('').toString()) //test2 logger.info(msg['node']['test2']['node2'].toString()); {code} This is an example of when an implicit namespace is found deeper in the document then wildcards must be added to that element and any children nodes only. {code} test2 {code} {code} //http://www.w3.org/1999/xhtml logger.info(msg['node'].*::['test2'].namespace('').toString()); //test2 logger.info(msg['node'].*::['test2'].*::['node2'].toString()); //test2 logger.info(msg['node'].toString()); {code} We also need to make sure that all the JSON dragging still works since we did touch that code: {code} { "test" : "testString", "testArray" : [7, 4, 3, 4] } {code} {code} //testString logger.info(msg['test']); //7, 4, 3, 4 logger.info(msg['testArray'].toString()); //7 logger.info(msg['testArray'][0]); //4 logger.info(msg['testArray'][1]); {code} Imported Comment. Original Details: Author: eduardoa Created: 2016-03-25T15:22:30.000-0700
rbeckman-nextgen commented 4 years ago

Some of the new things that were added was that if you drag and drop a namespace attribute from the tree it will actually now drag a namespace function. For implicit namespaces it will drag .namespace('') for prefixed namespaces it will drag .namespace('prefix').

Also, it would be good to add more testing with actual HL7v3 (CCD) messages.

Imported Comment. Original Details: Author: eduardoa Created: 2016-03-25T15:27:42.000-0700

rbeckman-nextgen commented 4 years ago

It looks like namespaced attributes aren't being handled correctly. Take the following XML:

{code:xml}{code}

Then try to get out the "schemaLocation" attribute. The drag-and-drop creates:

{code:JavaScript}msg.*::['schemaLocation'].toString(){code}

But that doesn't work. This does though:

{code:JavaScript}msg.@*::['schemaLocation'].toString(){code}

Imported Comment. Original Details: Author: narupley Created: 2016-03-28T09:10:56.000-0700

rbeckman-nextgen commented 4 years ago

You definitely warned me about that, sorry. I added that to the drag and drop now(rev 7959).

Imported Comment. Original Details: Author: eduardoa Created: 2016-03-28T12:12:12.000-0700

rbeckman-nextgen commented 4 years ago

Verified that message tree drag-and-drop will now handle namespaces correctly. Before a node would have been dropped in and the namespace prefix / tag name would have been combined together, like {{msg['soapenv:Body']}}. However now the tree will detect when a namespace is required and if so, includes an E4X wildcard, like {{msg.*::['Body']}}.

This does mean that if there are multiple nodes at the same level with the same tag name but different namespaces, the wildcard may incorrectly reference both of them rather than a specific node. But at least this is better than it was before (would have just errored out before). If a user wants to reference a specific namespace, this can still easily be done by swapping out the "*" with the appropriate variable.

The drag-and-drop also handles xmlns attributes correctly now, using the E4X namespace method and passing in the prefix. Attributes with specific bound namespace prefixes are also correctly handled.

Imported Comment. Original Details: Author: narupley Created: 2016-03-28T13:45:25.000-0700