// More Helpers...
// /////////////////////////////////////////////////////////
void ensureFrameworksInAgreement(final PersistenceCapable pojo) {
final ObjectAdapter adapter = getAdapterManager().getAdapterFor(pojo);
final Oid oid = adapter.getOid();
if(!pojo.jdoIsPersistent()) {
// make sure the adapter is transient
if (!adapter.getResolveState().isTransient()) {
throw new IsisException(MessageFormat.format("adapter oid={0} has resolve state in invalid state; should be transient but is {1}; pojo: {2}", oid, adapter.getResolveState(), pojo));
}
// make sure the oid is transient
if (!oid.isTransient()) {
throw new IsisException(MessageFormat.format("adapter oid={0} has oid in invalid state; should be transient; pojo: {1}", oid, pojo));
}
} else if(pojo.jdoIsDeleted()) {
// make sure the adapter is destroyed
if (!adapter.getResolveState().isDestroyed()) {
throw new IsisException(MessageFormat.format("adapter oid={0} has resolve state in invalid state; should be destroyed but is {1}; pojo: {2}", oid, adapter.getResolveState(), pojo));
}
} else {
// make sure the adapter is persistent
if (!adapter.getResolveState().representsPersistent()) {
throw new IsisException(MessageFormat.format("adapter oid={0} has resolve state in invalid state; should be in a persistent but is {1}; pojo: {2}", oid, adapter.getResolveState(), pojo));
}
// make sure the oid is persistent
if (oid.isTransient()) {
throw new IsisException(MessageFormat.format("adapter oid={0} has oid in invalid state; should be persistent; pojo: {1}", oid, pojo));
}
}
}