Examples of RootOid


Examples of org.apache.isis.core.metamodel.adapter.oid.RootOid

    }

    private ObjectAdapter createRootOrAggregatedAdapter(final Oid oid, final Object pojo) {
        final ObjectAdapter createdAdapter;
        if(oid instanceof RootOid) {
            final RootOid rootOid = (RootOid) oid;
            createdAdapter = createRootAdapterAndInferResolveState(pojo, rootOid);
        } else if (oid instanceof CollectionOid){
            final CollectionOid collectionOid = (CollectionOid) oid;
            createdAdapter = createCollectionAdapterAndInferResolveState(pojo, collectionOid);
        } else {
View Full Code Here

Examples of org.apache.isis.core.metamodel.adapter.oid.RootOid

     */
    @Override
    public void remapAsPersistent(final ObjectAdapter adapter, RootOid hintRootOid) {
       
        final ObjectAdapter rootAdapter = adapter.getAggregateRoot()// REVIEW: think this is redundant; would seem this method is only ever called for roots anyway.
        final RootOid transientRootOid = (RootOid) rootAdapter.getOid();

        Ensure.ensureThatArg(rootAdapter.isTransient(), is(true), "root adapter should be transient; oid:" + transientRootOid);
        Ensure.ensureThatArg(transientRootOid.isTransient(), is(true), "root adapter's OID should be transient; oid:" + transientRootOid);
       
        final RootAndCollectionAdapters rootAndCollectionAdapters = new RootAndCollectionAdapters(adapter, this);
       
       
        if (LOG.isDebugEnabled()) {
            LOG.debug("remapAsPersistent: " + transientRootOid);
        }
       
        if (LOG.isDebugEnabled()) {
            LOG.debug("removing root adapter from oid map");
        }
       
        boolean removed = oidAdapterMap.remove(transientRootOid);
        if (!removed) {
            LOG.warn("could not remove oid: " + transientRootOid);
            // should we fail here with a more serious error?
        }
       
        if (LOG.isDebugEnabled()) {
            LOG.debug("removing collection adapter(s) from oid map");
        }
        for (final ObjectAdapter collectionAdapter : rootAndCollectionAdapters) {
            final Oid collectionOid = collectionAdapter.getOid();
            removed = oidAdapterMap.remove(collectionOid);
            if (!removed) {
                LOG.warn("could not remove collectionOid: " + collectionOid);
                // should we fail here with a more serious error?
            }
        }
       
        if (LOG.isDebugEnabled()) {
            LOG.debug("updating the Oid");
        }
       
        // intended for testing (bit nasty)
        final RootOid persistedRootOid;
        if(hintRootOid != null) {
            if(hintRootOid.isTransient()) {
                throw new IsisAssertException("hintRootOid must be persistent");
            }
            final ObjectSpecId hintRootOidObjectSpecId = hintRootOid.getObjectSpecId();
            final ObjectSpecId adapterObjectSpecId = adapter.getSpecification().getSpecId();
            if(!hintRootOidObjectSpecId.equals(adapterObjectSpecId)) {
                throw new IsisAssertException("hintRootOid's objectType must be same as that of adapter " +
                    "(was: '" + hintRootOidObjectSpecId + "'; adapter's is " + adapterObjectSpecId + "'");
            }
            // ok
            persistedRootOid = hintRootOid;
        } else {
            // normal flow - delegate to OidGenerator to obtain a persistent root oid
            persistedRootOid = getOidGenerator().createPersistentOrViewModelOid(adapter.getObject(), transientRootOid);
        }
       
        // associate root adapter with the new Oid, and remap
        if (LOG.isDebugEnabled()) {
            LOG.debug("replacing Oid for root adapter and re-adding into maps; oid is now: " + persistedRootOid.enString(getOidMarshaller()) + " (was: " + transientRootOid.enString(getOidMarshaller()) + ")");
        }
        adapter.replaceOid(persistedRootOid);
        oidAdapterMap.add(persistedRootOid, adapter);
       
        // associate the collection adapters with new Oids, and re-map
View Full Code Here

Examples of org.apache.isis.core.metamodel.adapter.oid.RootOid

     *
     * <p>
     * Has <tt>protected</tt> visibility just so can be used by subclasses if required.
     */
    protected final ObjectAdapter createTransientOrViewModelRootAdapter(final Object pojo) {
        final RootOid rootOid = getOidGenerator().createTransientOrViewModelOid(pojo);
        return createRootAdapterAndInferResolveState(pojo, rootOid);
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.adapter.oid.RootOid

        }
        if(Bookmark.class != argType) {
            return adapterFor(arg);
        } else {
            final Bookmark argBookmark = (Bookmark)arg;
            final RootOid rootOid = RootOidDefault.create(argBookmark);
            return adapterFor(rootOid);
        }
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.adapter.oid.RootOid

        if(isParented()) {
            // ignored
            return;
        }
        if (shouldSetVersion(version)) {
            RootOid rootOid = (RootOid) getOid(); // since not parented
            rootOid.setVersion(version);
        }
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.adapter.oid.RootOid

        return adapter;
    }

    @Override
    public RootOid getOidForService(ObjectSpecification serviceSpec) {
        final RootOid serviceOid = underlying.getOidForService(serviceSpec);
        if(serviceOid != null) {
            log("get OID for service: " + serviceOid.enString(getOidMarshaller()));
        } else {
            log("get OID for service: null (presumably in the process of being registered for '" + serviceSpec.getSpecId() + "')");
        }
        return serviceOid;
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.adapter.oid.RootOid

    public void updateInstance() throws Exception {

        // given persisted
        resetPersistenceStore();
        ObjectAdapter adapter = iswf.persist(iswf.fixtures.smpl2);
        final RootOid oid = (RootOid) adapter.getOid();
        iswf.bounceSystem();
       
        // when change
        adapter = iswf.reload(oid);
       
View Full Code Here

Examples of org.apache.isis.core.metamodel.adapter.oid.RootOid

        // given persisted
        iswf.beginTran();
        resetPersistenceStore();
        ObjectAdapter adapter = iswf.persist(iswf.fixtures.smpl2);
        final RootOid oid = (RootOid) adapter.getOid();
        iswf.commitTran();
       
        iswf.bounceSystem();

        // when destroy
View Full Code Here

Examples of org.apache.isis.core.metamodel.adapter.oid.RootOid

            // a slight compromise? close enough.
            if(!(oid instanceof RootOid)) {
                throw new IllegalArgumentException("oid is view model but not a RootOid; " + oid.toString());
            }
            final RootOid rootOid = (RootOid) oid;
            final String memento = rootOid.getIdentifier();

            facet.initialize(pojo, memento);
        }
        return pojo;
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.adapter.oid.RootOid

    public DomainObjectContainerResolve() {
    }

    public Object lookup(final Bookmark bookmark) {
        RootOid oid = RootOidDefault.create(bookmark);
        final ObjectAdapter adapter = adapterFor(oid);
        if(adapter == null) {
            return null;
        }
        if (adapter.canTransitionToResolving()) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.