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

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


    private void remapAggregatedObject(final ObjectAdapter adapter, final RootOid persistedRootOid) {
        final Oid oid = adapter.getOid();
        if (!(oid instanceof AggregatedOid) || !oid.isTransient()) {
                return;
        }
        AggregatedOid aoid = (AggregatedOid) oid;
        AggregatedOid childOid = new AggregatedOid(aoid.getObjectSpecId(), persistedRootOid, aoid.getLocalId());
        adapter.replaceOid(childOid);
       
        remapContainedAggregatedObject(adapter, persistedRootOid);
    }
View Full Code Here


       
        final ObjectSpecification objSpec = getSpecificationLoader().loadSpecification(pojo.getClass());
       
        final ObjectAdapter newAdapter;
        if(isAggregated(objSpec)) {
            final AggregatedOid aggregatedOid = getOidGenerator().createAggregateOid(pojo, parentAdapter);
            newAdapter = createAggregatedAdapter(pojo, aggregatedOid);
        } else {
            newAdapter = createTransientOrViewModelRootAdapter(pojo);
        }
       
View Full Code Here

            createdAdapter = createRootAdapterAndInferResolveState(pojo, rootOid);
        } else if (oid instanceof CollectionOid){
            final CollectionOid collectionOid = (CollectionOid) oid;
            createdAdapter = createCollectionAdapterAndInferResolveState(pojo, collectionOid);
        } else {
            final AggregatedOid aggregatedOid = (AggregatedOid) oid;
            createdAdapter = createAggregatedAdapter(pojo, aggregatedOid);
        }
        return createdAdapter;
    }
View Full Code Here

    private void remapAggregatedObject(final ObjectAdapter adapter, final RootOid persistedRootOid) {
        final Oid oid = adapter.getOid();
        if (!(oid instanceof AggregatedOid) || !oid.isTransient()) {
                return;
        }
        AggregatedOid aoid = (AggregatedOid) oid;
        AggregatedOid childOid = new AggregatedOid(aoid.getObjectSpecId(), persistedRootOid, aoid.getLocalId());
        adapter.replaceOid(childOid);
       
        remapContainedAggregatedObject(adapter, persistedRootOid);
    }
View Full Code Here

            if(typedOid instanceof AggregatedOid) {

//              final RootOid parentOid = deString(objectType, oidData, State.PERSISTENT);
//              Oid aggregatedOid = new AggregatedOid(objectType, parentOid, aggregatedId);

                AggregatedOid aggregatedOid = (AggregatedOid) typedOid;
                final TypedOid parentOid = aggregatedOid.getParentOid();

                getPersistenceSession().loadObject(parentOid);
                return getAdapterManager().getAdapterFor(aggregatedOid);
            }
View Full Code Here

    @Test
    public void adapterFor_whenAggregated() throws Exception {
        // given
        allowing_oidGenerator_createAggregatedOid(
                aggregatedObject,
                new AggregatedOid(ObjectSpecId.of("NME"), (TypedOid) persistentParentAdapter.getOid(), "123"));
       
        // when
        aggregatedAdapter = adapterManager.adapterFor(aggregatedObject, persistentParentAdapter);

        // then
        final AggregatedOid aggregatedOid = (AggregatedOid) aggregatedAdapter.getOid();
        assertEquals(persistentParentAdapter.getOid(), aggregatedOid.getParentOid());
    }
View Full Code Here

        assertEquals(persistentParentAdapter.getOid(), aggregatedOid.getParentOid());
    }

    @Test
    public void testOidHasSubId() throws Exception {
        allowing_oidGenerator_createAggregatedOid(aggregatedObject, new AggregatedOid(ObjectSpecId.of("NME"), (TypedOid) persistentParentAdapter.getOid(), "123"));
        aggregatedAdapter = adapterManager.adapterFor(aggregatedObject, persistentParentAdapter);

        final AggregatedOid aggregatedOid = (AggregatedOid) aggregatedAdapter.getOid();
        assertEquals("123", aggregatedOid.getLocalId());
    }
View Full Code Here

        assertEquals("123", aggregatedOid.getLocalId());
    }

    @Test
    public void getResolveState_isInitiallyGhost() throws Exception {
        allowing_oidGenerator_createAggregatedOid(aggregatedObject, new AggregatedOid(ObjectSpecId.of("NME"), (TypedOid) persistentParentAdapter.getOid(), "123"));
        aggregatedAdapter = adapterManager.adapterFor(aggregatedObject, persistentParentAdapter);

        assertEquals(ResolveState.GHOST, aggregatedAdapter.getResolveState());
    }
View Full Code Here

        assertEquals(ResolveState.GHOST, aggregatedAdapter.getResolveState());
    }

    @Test
    public void testSameParametersRetrievesSameAdapter() throws Exception {
        allowing_oidGenerator_createAggregatedOid(aggregatedObject, new AggregatedOid(ObjectSpecId.of("NME"), (TypedOid) persistentParentAdapter.getOid(), "123"));
        aggregatedAdapter = adapterManager.adapterFor(aggregatedObject, persistentParentAdapter);

        final ObjectAdapter valueAdapter2 = adapterManager.adapterFor(aggregatedObject, persistentParentAdapter, mockCollection);
        assertSame(aggregatedAdapter, valueAdapter2);
    }
View Full Code Here

        }

        //
        // else, handle aggregate
        //
        AggregatedOid aggregatedOid = (AggregatedOid) typedOid;
        final TypedOid parentOid = aggregatedOid.getParentOid();

        //final ObjectAdapter parentAdapter = objectMapping.mappedObject(idParts[0] + "@" + idParts[1]);
        final ObjectAdapter parentAdapter = objectMapping.mappedObject(parentOid.enString(getOidMarshaller()));
        getPersistenceSession().resolveImmediately(parentAdapter);

        //ObjectSpecId objectType = null;
        //final AggregatedOid aggregatedOid = new AggregatedOid(objectType, (TypedOid) parentAdapter.getOid(), idParts[2]);

        ObjectAdapter aggregatedAdapter = null;
        outer: for (final ObjectAssociation association : parentAdapter.getSpecification().getAssociations(Contributed.EXCLUDED)) {
            if (association.getSpecification().isParented()) {
                final ObjectAdapter objectAdapter = association.get(parentAdapter);
                if (objectAdapter == null) {
                    continue;
                }
                if (association.isOneToManyAssociation()) {
                    final ObjectAdapter coll = objectAdapter;
                    final CollectionFacet facet = coll.getSpecification().getFacet(CollectionFacet.class);
                    for (final ObjectAdapter element : facet.iterable(coll)) {
                        if (element.getOid().equals(aggregatedOid)) {
                            aggregatedAdapter = element;
                            break outer;
                        }
                    }
                } else {
                    if (objectAdapter.getOid().equals(aggregatedOid)) {
                        aggregatedAdapter = objectAdapter;
                        break;
                    }
                }
            } else if (association.isOneToManyAssociation()) {
                if (association.getId().equals(aggregatedOid.getLocalId())) {
                //if (association.getId().equals(idParts[2])) {
                    return association.get(parentAdapter);
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.isis.core.metamodel.adapter.oid.AggregatedOid

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.