Object pk = getPrimaryKey(object);
if (!registry.contains(object.getType().getName(), Collections
.singletonList(pk))) {
// logger.info("creating " + object.getType().getName() + " with pk " + pk);
DataObject newObject = root.createDataObject(p.getName());
Iterator attrs = object.getType().getProperties().iterator();
while (attrs.hasNext()) {
Property attr = (Property) attrs.next();
if ( attr.getType().isDataType()) {
newObject.set(attr.getName(), object.get(attr));
}
}
registry.put(object.getType().getName(), Collections
.singletonList(pk), newObject);
Iterator refs = object.getType().getProperties().iterator();
while (refs.hasNext()) {
Property ref = (Property) refs.next();
if ( !ref.getType().isDataType()) {
List refObjects;
if (!ref.isMany()) {
refObjects = Collections.singletonList(object.get(ref));
} else {
refObjects = (List) object.get(ref);
}
Iterator iter = refObjects.iterator();
while (iter.hasNext()) {
DataObject refObject = (DataObject) iter.next();
createObjectWithSubtree(root, refObject
.getContainmentProperty(), refObject);
refObject = (DataObject) registry.get(refObject.getType().getName(), Collections.singletonList(getPrimaryKey(refObject)));
if (ref.isMany()) {
newObject.getList(
newObject.getType().getProperty(ref.getName()))
.add(refObject);
} else