@Override
public Key getParentKey(Object data) {
if (!repository.containsKey(parentField.getType())) {
throw new NonStoredParentException(parentField);
}
DatastoreFinderService parentService = (DatastoreFinderService) repository
.get(parentField.getType());
IdManager parentIdManager = parentService.getIdManager();
Object parentObject = parentField.get(data);
String parentKind = parentService.getKind();
if (!parentIdManager.hasKey(parentKind, parentObject)) {
parentIdManager.createKey(parentKind, parentObject);
}
return parentIdManager.getKey(parentKind, parentObject);
}