final Map<Object, Object> params = new HashMap<Object, Object>();
final Map<Object, List<Object>> compositeKeyParams = new HashMap<Object, List<Object>>();
for (final Entry<Object, Object> paramEntry : parameters.entrySet())
if (paramEntry.getValue() instanceof OCompositeKey) {
final OCompositeKey compositeKey = (OCompositeKey) paramEntry.getValue();
compositeKeyParams.put(paramEntry.getKey(), compositeKey.getKeys());
} else
params.put(paramEntry.getKey(), paramEntry.getValue());
buffer.set(!params.isEmpty());
if (!params.isEmpty()) {
final ODocument param = new ODocument();
param.field("parameters", params);
buffer.set(param.toStream());
}
buffer.set(!compositeKeyParams.isEmpty());
if (!compositeKeyParams.isEmpty()) {
final ODocument compositeKey = new ODocument();
compositeKey.field("compositeKeyParams", compositeKeyParams);
buffer.set(compositeKey.toStream());
}
}
return buffer.toByteArray();
}