Package org.apache.isis.core.metamodel.adapter

Examples of org.apache.isis.core.metamodel.adapter.ResolveState


    private void updateLoadedObject(final ObjectAdapter adapter, final ObjectData adapterData,
        final KnownObjectsRequest knownObjects) {
        // object known and we have all the latest data; update/resolve the object
        if (adapterData.getFieldContent() != null) {
            adapter.setOptimisticLock(adapterData.getVersion());
            final ResolveState state = nextState(adapter.getResolveState(), adapterData.hasCompleteData());
            if (state != null) {
                LOG.debug("updating existing object (" + state.name() + ") " + adapter);
                setupFields(adapter, adapterData, state, knownObjects);
                getUpdateNotifier().addChangedObject(adapter);
            }
        } else {
            if (adapterData.getVersion() != null && adapterData.getVersion().different(adapter.getVersion())) {
View Full Code Here


                LOG.debug("adding element to " + field.getId() + ": " + elements[j]);
            }
        }

        final ObjectAdapter col = field.get(adapter);
        final ResolveState initialState = col.getResolveState();
        final ResolveState state = nextState(initialState, collectionContentData.hasAllElements());
        if (state != null) {
            PersistorUtil.start(col, state);
            final ObjectAdapter collection = ((OneToManyAssociation) field).get(adapter);
            final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection);
            facet.init(collection, elements);
View Full Code Here

    // ///////////////////////////////////////////////////////
    // Helpers: nextState
    // ///////////////////////////////////////////////////////

    private ResolveState nextState(final ResolveState initialState, final boolean complete) {
        ResolveState state = null;
        if (initialState == ResolveState.RESOLVED) {
            state = ResolveState.UPDATING;
        } else if (initialState == ResolveState.GHOST || initialState == ResolveState.PART_RESOLVED) {
            state = complete ? ResolveState.RESOLVING : ResolveState.RESOLVING_PART;
        } else if (initialState == ResolveState.TRANSIENT) {
View Full Code Here

    // Changed Objects
    // //////////////////////////////////////////////////

    @Override
    public synchronized void addChangedObject(final ObjectAdapter adapter) {
        final ResolveState resolveState = adapter.getResolveState();
        if (!resolveState.isResolved() && !adapter.isTransient()) {
            return;
        }

        if (LOG.isDebugEnabled()) {
            LOG.debug("mark as changed " + adapter);
View Full Code Here

     * @link ServerFacadeImpl#setAssociation(SetAssociationRequest) <li><li> by<li> {
     * @link ServerFacadeImpl#setValue(SetValueRequest) </ul>
     */
    @Override
    public ObjectData encodeForUpdate(final ObjectAdapter object) {
        final ResolveState resolveState = object.getResolveState();
        if (resolveState.isSerializing() || resolveState.isGhost()) {
            throw new IsisRemoteException("Illegal resolve state: " + object);
        }
        return encode(object, serverSideTouchedObjectGraphDepth);
    }
View Full Code Here

    @Override
    public Data encodeForResolveField(final ObjectAdapter adapter, final String fieldName) {
        final Oid oid = adapter.getOid();
        final ObjectSpecification specification = adapter.getSpecification();
        final String type = specification.getFullIdentifier();
        final ResolveState resolveState = adapter.getResolveState();

        Data[] fieldContent;
        final ObjectAssociation[] fields = getFieldOrder(specification);
        fieldContent = new Data[fields.length];

        PersistorUtil.start(adapter, adapter.getResolveState().serializeFrom());
        final KnownObjectsRequest knownObjects = new KnownObjectsRequest();
        for (int i = 0; i < fields.length; i++) {
            if (fields[i].getId().equals(fieldName)) {
                final ObjectAdapter field = fields[i].get(adapter);
                if (field == null) {
                    fieldContent[i] = dataFactory.createNullData(fields[i].getSpecification().getFullIdentifier());
                } else if (fields[i].getSpecification().isEncodeable()) {
                    fieldContent[i] = serializer.serializeEncodeable(field);
                } else if (fields[i].isOneToManyAssociation()) {
                    fieldContent[i] =
                        serializer.serializeCollection(field, serverSideRetrievedObjectGraphDepth, knownObjects);
                } else {
                    IsisContext.getPersistenceSession().resolveImmediately(field);
                    fieldContent[i] =
                        serializer.serializeAdapter(field, serverSideRetrievedObjectGraphDepth, knownObjects);
                }
                break;
            }
        }
        PersistorUtil.end(adapter);

        // TODO remove the fudge - needed as collections are part of parents, hence parent object gets set as
        // resolving (is not a ghost) yet it has no version number
        // return createObjectData(oid, type, fieldContent, resolveState.isResolved(),
        // !resolveState.isGhost(), object.getVersion());
        final ObjectData data =
            dataFactory.createObjectData(type, oid, resolveState.isResolved(), adapter.getVersion());
        data.setFieldContent(fieldContent);
        return data;
        // return createObjectData(oid, type, fieldContent, resolveState.isResolved(), object.getVersion());
    }
View Full Code Here

    private final Data serializeObject2(final ObjectAdapter adapter, final int graphDepth,
        final KnownObjectsRequest knownObjects) {
        Assert.assertNotNull(adapter);

        final ResolveState resolveState = adapter.getResolveState();
        final boolean isTransient = adapter.isTransient();

        if (!isTransient && (resolveState.isSerializing() || resolveState.isGhost() || graphDepth <= 0)) {
            Assert.assertNotNull("OID needed for reference", adapter, adapter.getOid());
            return this.dataFactory.createIdentityData(adapter.getSpecification().getFullIdentifier(),
                adapter.getOid(), adapter.getVersion());
        }
        if (isTransient && knownObjects.containsKey(adapter)) {
View Full Code Here

    /**
     * Marks the specified object as loaded: resolved, partly resolve or updated as specified by the second parameter.
     * Attempting to specify any other state throws a run time exception.
     */
    public static void end(final ObjectAdapter object) {
        final ResolveState endState = object.getResolveState().getEndState();
        Assert.assertNotNull("end state required", endState);
        if (LOG.isTraceEnabled()) {
            LOG.trace("end " + object + " as " + endState.name());
        }
        object.changeState(endState);
    }
View Full Code Here

    public DomainObjectContainerResolve() {
    }

    public void resolve(final Object parent) {
        final ObjectAdapter adapter = adapterFor(parent);
        final ResolveState resolveState = adapter.getResolveState();
        if (resolveState.canChangeTo(ResolveState.RESOLVING)) {
            getPersistenceSession().resolveImmediately(adapter);
        }
    }
View Full Code Here

            return objectTitleString();
        }
    }

    private String objectTitleString() {
        final ResolveState resolveState = getResolveState();
        if (resolveState.isNew()) {
            return "";
        } else {
            if (getObject() instanceof String) {
                return (String) getObject();
            }
            final ObjectSpecification specification = getSpecification();
            final Localization localization = getLocalization();
            String title = specification.getTitle(this, localization);
            if (title == null) {
                if (resolveState.isGhost()) {
                    if (LOG.isInfoEnabled()) {
                        LOG.info("attempting to use unresolved object; resolving it immediately: oid=" + this.getOid());
                    }
                    getObjectPersistor().resolveImmediately(this);
                }
View Full Code Here

TOP

Related Classes of org.apache.isis.core.metamodel.adapter.ResolveState

Copyright © 2018 www.massapicom. 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.