protected List<ObjectAdapter> getServiceAdapters() { return rendererContext.getPersistenceSession().getServices(); }
private static ObjectAdapter getObjectAdapter( final RendererContext rendererContext, final String oidStrUnencoded) { RootOid rootOid = RootOid.deString(oidStrUnencoded); final PersistenceSession persistenceSession = rendererContext.getPersistenceSession(); return persistenceSession.adapterForAny(rootOid); }
private static ObjectAdapter getObjectAdapter(RendererContext resourceContext, String oidStrUnencoded) { RootOidDefault rootOid = RootOidDefault.deString(oidStrUnencoded, getOidMarshaller()); final ObjectSpecId specId = rootOid.getObjectSpecId(); final ObjectSpecification spec = IsisContext.getSpecificationLoader().lookupBySpecId(specId); if(spec == null) { // eg "NONEXISTENT:123" return null; } // TODO: the logic to figure out which PersistenceSession API to call should be pushed down into PersistenceSession itself. if(spec.containsFacet(ViewModelFacet.class)) { if(!rootOid.getIdentifier().startsWith(OidMarshaller.VIEWMODEL_INDICATOR)) { // TODO: this bodge to ensure that the "*" (view model indicator) is probably not required; but leaving it in until have better test coverage rootOid = RootOidDefault.create(rootOid.getObjectSpecId(), OidMarshaller.VIEWMODEL_INDICATOR + rootOid.getIdentifier()); } try { return resourceContext.getPersistenceSession().getAdapterManager().adapterFor(rootOid); } catch(final ObjectNotFoundException ex) { return null; } catch(final PojoRecreationException ex) { return null; } } else { try { ObjectAdapter objectAdapter = resourceContext.getPersistenceSession().loadObject(rootOid); return objectAdapter.isTransient() ? null : objectAdapter; } catch(final ObjectNotFoundException ex) { return null; } } }
@Override public JsonRepresentation render() { // self if (includesSelf) { addLinkToSelf(); } addLinkToUser(getRendererContext().getAuthenticationSession()); addLinkToMenuBars(); addLinkToServices(getRendererContext().getPersistenceSession().getServices()); addLinkToVersion(); addLinkToDomainTypes(((ResourceContext)getRendererContext()).getSpecificationLoader().allSpecifications()); // inks and extensions representation.mapPut("extensions", JsonRepresentation.newMap()); return representation; }