XMLInteraction interaction = (XMLInteraction)object;
Vector argumentNames = interaction.getArgumentNames();
Vector arguments = interaction.getArguments();
Vector interactionArguments = new Vector(arguments.size());
for (int index = 0; index < arguments.size(); index++) {
InteractionArgument interactionArgument = new InteractionArgument();
interactionArgument.setArgumentName((String)argumentNames.get(index));
Object argument = arguments.get(index);
if (argument instanceof DatabaseField) {
interactionArgument.setKey(argument);
} else {
interactionArgument.setValue(argument);
}
interactionArguments.add(interactionArgument);
}
return interactionArguments;
}
public void setAttributeValueInObject(Object object, Object value) {
XMLInteraction interaction = (XMLInteraction)object;
Vector interactionArguments = (Vector)value;
Vector arguments = new Vector(interactionArguments.size());
Vector argumentNames = new Vector(interactionArguments.size());
Vector values = new Vector(interactionArguments.size());
for (int index = 0; index < interactionArguments.size(); index++) {
InteractionArgument interactionArgument = (InteractionArgument)interactionArguments.get(index);
if (interactionArgument.getKey() != null) {
arguments.add(new DatabaseField((String)interactionArgument.getKey()));
}
if (interactionArgument.getValue() != null) {
values.add(interactionArgument.getValue());
}
if (interactionArgument.getArgumentName() != null) {
argumentNames.add(interactionArgument.getArgumentName());
}
}
if (!arguments.isEmpty()) {
interaction.setArguments(arguments);
} else if (!values.isEmpty()) {
interaction.setArguments(values);
}
if (!argumentNames.isEmpty()) {
interaction.setArgumentNames(argumentNames);
}
}
});
argumentsMapping.setAttributeName("arguments");
argumentsMapping.setXPath(getPrimaryNamespaceXPath() + "input-arguments/" + getPrimaryNamespaceXPath() + "argument");
argumentsMapping.setReferenceClass(InteractionArgument.class);
descriptor.addMapping(argumentsMapping);
XMLCompositeCollectionMapping outputArgumentsMapping = new XMLCompositeCollectionMapping();
// Handle translation of argument lists to interaction-arguments.
outputArgumentsMapping.setAttributeAccessor(new AttributeAccessor() {
public Object getAttributeValueFromObject(Object object) {
XMLInteraction interaction = (XMLInteraction)object;
Vector arguments = interaction.getOutputArguments();
Vector argumentNames = interaction.getOutputArgumentNames();
Vector interactionArguments = new Vector(arguments.size());
for (int index = 0; index < arguments.size(); index++) {
InteractionArgument interactionArgument = new InteractionArgument();
interactionArgument.setKey(((DatabaseField)arguments.get(index)).getName());
interactionArgument.setArgumentName((String)argumentNames.get(index));
interactionArguments.add(interactionArgument);
}
return interactionArguments;
}
public void setAttributeValueInObject(Object object, Object value) {
XMLInteraction interaction = (XMLInteraction)object;
Vector interactionArguments = (Vector)value;
Vector arguments = new Vector(interactionArguments.size());
Vector argumentNames = new Vector(interactionArguments.size());
for (int index = 0; index < interactionArguments.size(); index++) {
InteractionArgument interactionArgument = (InteractionArgument)interactionArguments.get(index);
arguments.add(new DatabaseField((String)interactionArgument.getKey()));
argumentNames.add(interactionArgument.getArgumentName());
}
interaction.setOutputArguments(arguments);
interaction.setOutputArgumentNames(argumentNames);
}
});