val = ((Double) pval).floatValue();
break;
case RELATED_ONE: {
final Model rltdOne = (Model) pval;
final IEntityType rltdEntityType =
rltdOne == null ? ((RelatedOneProperty) mprop).getRelatedType() : rltdOne.getEntityType();
assert rltdEntityType != null;
IEntity toOne;
if(rltdOne == null || rltdOne.isMarkedDeleted()) {
toOne = null;
}
else {
final Class<? extends IEntity> rltdEntityClass =
(Class<? extends IEntity>) etResolver.resolveEntityClass(rltdEntityType);
try {
toOne = (IEntity) bw.getPropertyValue(propName);
if(toOne == null) toOne = instantiateEntity(rltdEntityClass);
}
catch(final RuntimeException re) {
log.warn("Unable to get related one entity ref", re);
toOne = null;
}
log.debug("About to marshal related one [model: " + rltdOne + "] [entity: " + toOne + "]");
marshalModel(rltdOne, toOne, visited, depth + 1);
}
val = toOne;
}
break;
case NESTED:
// no-op since these are expressed as "{parent}_{nestedA}"
break;
case RELATED_MANY: {
if(pval != null) { // should always be non-null (see RelatedManyProperty)
final List<Model> rmModelList = (List<Model>) pval;
Set<IEntity> rmEntitySet = null;
//try {
rmEntitySet = (Set<IEntity>) bw.getPropertyValue(propName);
final LinkedHashSet<IEntity> newRmEntitySet = new LinkedHashSet<IEntity>(rmModelList.size());
if(rmEntitySet != null) {
newRmEntitySet.addAll(rmEntitySet); // fail fast so don't trap exception here
}
//if(rmEntitySet != null) {
// re-build the rm entity set
for(final Model indexedModel : rmModelList) {
assert indexedModel != null;
final IEntityType indexedEntityType = indexedModel.getEntityType();
final Class<IEntity> indexedEntityClass = (Class<IEntity>) etResolver.resolveEntityClass(indexedEntityType);
final PrimaryKey<IEntity> imodelPk = new PrimaryKey<IEntity>(indexedEntityClass, indexedModel.getId());
IEntity indexedEntity = null;