public int canOpen(final Content content) { NakedCollection collection = ((CollectionContent) content).getCollection(); if (collection.getResolveState().isGhost()) { return UNKNOWN; } else { return collection.size() > 0 ? CAN_OPEN : CANT_OPEN; } }
public Object getEntity(final String entityName, final Serializable id) throws CallbackException { if (LOG.isDebugEnabled()) { LOG.debug("getEntity entityName=" + entityName + ", id=" + id); } final HibernateOid oid = new HibernateOid(entityName, id); final NakedObject adapter = NakedObjectsContext.getObjectLoader().getAdapterFor(oid); if (adapter != null) { LOG.debug("getEntity found naked object with same oid - " + oid); if (adapter.getResolveState().isGhost() || adapter.getResolveState().isPartlyResolved() || adapter.getResolveState().isResolving()) { // change for lazy loading objects - this prevents hibernate // picking up the GHOST object as an already loaded entity by only returning // the object if it is resolved return null; } return adapter.getObject(); } return null; }
public void viewMenuOptions(final UserActionSet options) { super.viewMenuOptions(options); TreeDisplayRules.menuOptions(options); options.add(new AbstractUserAction("Select node") { public void execute(final Workspace workspace, final View view, final Location at) { selectNode(); } public String getDescription(final View view) { return "Show this node in the right-hand pane"; } }); Naked object = getView().getContent().getNaked(); ResolveState resolveState = ((NakedReference) object).getResolveState(); if (object instanceof NakedReference && (resolveState.isGhost() || resolveState.isPartlyResolved())) { options.add(new AbstractUserAction("Load object") { public void execute(final Workspace workspace, final View view, final Location at) { resolveContent(); } }); } }
public NakedCollection getAdapterForElseCreateAdapterForCollection( final NakedObject parent, final String fieldName, final NakedObjectSpecification specification, final Object collection) { Assert.assertNotNull("can't get an adapter for null", this, collection); InternalCollectionKey key = InternalCollectionKey.createKey(parent, fieldName); HibernateCollectionAdapter adapter = (HibernateCollectionAdapter) pojoAdapterMap.getPojo(key); if (adapter == null) { adapter = new HibernateCollectionAdapter(); adapter.setCollection(createAdapter(parent, fieldName, specification, collection, key)); pojoAdapterMap.add(key, adapter); } else if (collection != adapter.getObject()) { LOG.debug("Collection changed within parent, re-adding to map: " + fieldName); adapter.setCollection(createAdapter(parent, fieldName, specification, collection, key)); } Assert.assertSame(collection, adapter.getObject()); Assert.assertNotNull("should have an adapter for ", collection, adapter); if (adapter.getResolveState().isGhost()) { } return adapter; }