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

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


        if (state == null) {
            return null;
        }
        final ObjectSpecification spec = getSpecificationLoader().loadSpecification(state.getClassName());
        ObjectAdapter object;
        ResolveState targetState;
        if (getOid().isTransient()) {
            object = getHydrator().recreateAdapter(getOid(), spec);
            targetState = ResolveState.SERIALIZING_TRANSIENT;
        } else {
            object = getHydrator().recreateAdapter(getOid(), spec);
View Full Code Here


            }
            ObjectAdapter ref;
            ref = getHydrator().recreateAdapter(oid, spec);
            if (data instanceof ObjectData) {
                if (oid.isTransient() || spec.isAggregated()) {
                    final ResolveState resolveState = spec.isAggregated() ? ResolveState.GHOST : ResolveState.TRANSIENT;
                    if (ref.getResolveState().isValidToChangeTo(resolveState)) {
                        ref.changeState(resolveState);
                    }
                    updateObject(ref, data, resolveState);
                }
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

    }

    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)) {
            return knownObjects.get(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

     * @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

    // 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

        // synchronize on the current session because getting race
        // conditions, I think between different UI threads when running
        // with DnD viewer + in-memory object store +
        // cglib bytecode enhancement
        synchronized (getAuthenticationSession()) {
            final ResolveState resolveState = adapter.getResolveState();
            if (!resolveState.canChangeTo(ResolveState.RESOLVING)) {
                return;
            }
            Assert.assertFalse("only resolve object that is not yet resolved", adapter, resolveState.isResolved());
            Assert.assertTrue("only resolve object that is persistent", adapter, adapter.isPersistent());
            resolveImmediatelyFromPersistenceLayer(adapter);
            if (LOG.isDebugEnabled()) {
                // don't log object - its toString() may use the unresolved
                // field, or unresolved collection
                LOG.debug("resolved: " + adapter.getSpecification().getShortIdentifier() + " " + resolveState.code() + " " + adapter.getOid());
            }
        }
    }
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

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.