Please open a bug. We should not be merging instructions.
|------------>
| From: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|Henrik Lindberg <[EMAIL PROTECTED]>
|
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|Equinox development mailing list <[email protected]>
|
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|06/26/2008 09:41 PM
|
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|[equinox-dev] P2 touchpoint parsing/writing problem
|
>--------------------------------------------------------------------------------------------------------------------------------------------------|
Hi,
I encountered a problem with reading and writing IU touchpoints. The IU
supports multiple touchpoints - the getTouchpointData() method returns an
array of TouchpointData, and it is possible to add mulitple touchpoint
data.
When writing the IU as XML however, all the touchpoint data gets merged.
When reading this back in again, the result is a map where instructions are
overwritten.
This is what touchpoint writer does:
protected void writeTouchpointData(TouchpointData[] touchpointData) {
if (touchpointData != null && touchpointData.length > 0) {
start(TOUCHPOINT_DATA_ELEMENT);
attribute(COLLECTION_SIZE_ATTRIBUTE, touchpointData.length);
for (int i = 0; i < touchpointData.length; i++) {
TouchpointData nextData = touchpointData[i];
Map instructions = nextData.getInstructions();
if (instructions.size() > 0) {
start(TOUCHPOINT_DATA_INSTRUCTIONS_ELEMENT);
attribute(COLLECTION_SIZE_ATTRIBUTE, instructions.size());
for (Iterator iter = instructions.entrySet().iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
start(TOUCHPOINT_DATA_INSTRUCTION_ELEMENT);
attribute(TOUCHPOINT_DATA_INSTRUCTION_KEY_ATTRIBUTE, entry.getKey());
cdata((String) entry.getValue(), true);
end(TOUCHPOINT_DATA_INSTRUCTION_ELEMENT);
}
}
}
end(TOUCHPOINT_DATA_ELEMENT);
}
}
For an IU with two touchpoints, with one install instruction each - the
output is:
<touchpointData size='2'>
<instructions size='1'>
<instruction key='install'>
doSomething(target:some target value, source:some source value);
</instruction>
<instructions size='1'>
<instruction key='install'>
doSomethingElse(source:some source value, target:some target
value);
</instruction>
</instructions>
</instructions>
</touchpointData>
When the parser reads this back in - it gets the hint that there are two
touchpoint data, but there is just one instructions element. The parser
seems to be able to handle multiple instructions elements. So I think the
writer is to blame, and that there should be an
end(TOUCHPOINT_DATA_INSTRUCTIONS_ELEMENT) after looping over the
instructions. Like this:
protected void writeTouchpointData(TouchpointData[] touchpointData) {
if (touchpointData != null && touchpointData.length > 0) {
start(TOUCHPOINT_DATA_ELEMENT);
attribute(COLLECTION_SIZE_ATTRIBUTE, touchpointData.length);
for (int i = 0; i < touchpointData.length; i++) {
TouchpointData nextData = touchpointData[i];
Map instructions = nextData.getInstructions();
if (instructions.size() > 0) {
start(TOUCHPOINT_DATA_INSTRUCTIONS_ELEMENT);
attribute(COLLECTION_SIZE_ATTRIBUTE, instructions.size());
for (Iterator iter = instructions.entrySet().iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
start(TOUCHPOINT_DATA_INSTRUCTION_ELEMENT);
attribute(TOUCHPOINT_DATA_INSTRUCTION_KEY_ATTRIBUTE, entry.getKey());
cdata((String) entry.getValue(), true);
end(TOUCHPOINT_DATA_INSTRUCTION_ELEMENT);
}
// ! ! ! ! ! ! ! ! !
// MISSING END OF INSTRUCTIONS
end(TOUCHPOINT_DATA_INSTRUCTIONS_ELEMENT);
}
}
end(TOUCHPOINT_DATA_ELEMENT);
}
}
This is from version 1.14 of MetadataWriter - which I think is the latest -
or is this something that has been fixed?
Regards.
Henrik Lindberg
[EMAIL PROTECTED]
_______________________________________________
equinox-dev mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/equinox-dev
<<inline: graycol.gif>>
<<inline: ecblank.gif>>
_______________________________________________ equinox-dev mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/equinox-dev
