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

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


    @Override
    public void reset() {
        LOG.debug("reset");
        for (final Iterator<Map.Entry<Object, ObjectAdapter>> iterator = adapterByPojoMap.entrySet().iterator(); iterator.hasNext();) {
            final Map.Entry<Object, ObjectAdapter> entry = iterator.next();
            final ObjectAdapter adapter = entry.getValue();
            if (!adapter.getSpecification().isService()) {
                iterator.remove();
            }
        }
    }
View Full Code Here


    public DomainObjectContainerObjectChanged() {
    }

    public void objectChanged(final Object object) {
        if (object != null) {
            final ObjectAdapter adapter = adapterFor(object);
            getPersistenceSession().objectChanged(adapter);
        }
    }
View Full Code Here

    @Override
    public void debugData(final DebugBuilder debug) {
        int count = 0;
        for (final Object pojo : adapterByPojoMap.keySet()) {
            final ObjectAdapter object = adapterByPojoMap.get(pojo);
            debug.append(count++ + 1, 5);
            debug.append(" '");
            debug.append(pojo.toString(), 50);
            debug.append("'    ");
            debug.appendln(object.toString());
        }
    }
View Full Code Here

            throw new UnknownTypeException("not an object, is this a collection?");
        }
    }

    public static Object[] getCollectionAsObjectArray(final Object option, final ObjectSpecification spec, final AdapterManagerSpi adapterManager) {
        final ObjectAdapter collection = adapterManager.adapterFor(option);
        final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection);
        final Object[] optionArray = new Object[facet.size(collection)];
        int j = 0;
        for (final ObjectAdapter adapter : facet.iterable(collection)) {
            optionArray[j++] = adapter.getObject();
View Full Code Here

    }


    @Override
    public ObjectAdapter loadInstanceAndAdapt(final TypedOid oid) throws ObjectNotFoundException, ObjectPersistenceException {
        final ObjectAdapter adapter = underlying.loadInstanceAndAdapt(oid);
        log("get object for " + oid + " (of type '" + oid.getObjectSpecId() + "')", adapter.getObject());
        return adapter;
    }
View Full Code Here

        final ObjectSpecification objectSpec = object.getSpecification();
        return objectSpec.equals(requiredSpec) && matchesPattern(pattern, object);
    }

    private boolean matchesPattern(final ObjectAdapter pattern, final ObjectAdapter instance) {
        final ObjectAdapter object = instance;
        final ObjectSpecification nc = object.getSpecification();
        final List<ObjectAssociation> fields = nc.getAssociations(Contributed.EXCLUDED);

        for (int f = 0; f < fields.size(); f++) {
            final ObjectAssociation fld = fields.get(f);

            // are ignoring internal collections - these probably should be
            // considered
           
            // ignore non-persistent fields - there is no persisted field to
            // compare against
            if (fld.isNotPersisted()) {
                continue;
            }
            if (!fld.isOneToOneAssociation()) {
                continue;
            }

            // if pattern contains empty value then it matches anything
            if (fld.isEmpty(pattern)) {
                continue;
            }

            // find the object to match against, if any
            final ObjectAdapter reqd = fld.get(pattern);
            if (reqd == null) {
                continue;
            }

            // find the object; it's a bust if nothing
            final ObjectAdapter search = fld.get(object);
            if (search == null) {
                return false;
            }

            if (fld.getSpecification().isValue()) {
                // compare values directly
                if (!reqd.getObject().equals(search.getObject())) {
                    return false;
                }
               
            } else {

                // compare the titles
                final String r = reqd.titleString().toLowerCase();
                final String s = search.titleString().toLowerCase();

                // if the pattern does not occur in the object, then it's a bust
                if (s.indexOf(r) == -1) {
                    return false;
                }
View Full Code Here

    @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

        if(isInjectMethod(method)) {
            return delegate(method, args);
        }

        final ObjectAdapter targetAdapter = getAdapterManager().getAdapterFor(getDelegate());

        if (isTitleMethod(method)) {
            return handleTitleMethod(method, args, targetAdapter);
        }


        final ObjectSpecification targetNoSpec = targetAdapter.getSpecification();

        // save method, through the proxy
        if (isSaveMethod(method)) {
            return handleSaveMethod(getAuthenticationSession(), targetAdapter, targetNoSpec);
        }
View Full Code Here

        checkVisibility(getAuthenticationSession(), targetAdapter, otoa);

        resolveIfRequired(targetAdapter);

        final ObjectAdapter currentReferencedAdapter = otoa.get(targetAdapter);
        final Object currentReferencedObj = AdapterUtils.unwrap(currentReferencedAdapter);

        final PropertyAccessEvent ev = new PropertyAccessEvent(getDelegate(), otoa.getIdentifier(), currentReferencedObj);
        notifyListeners(ev);
        return currentReferencedObj;
View Full Code Here

        if(getExecutionMode().shouldEnforceRules()) {
            checkVisibility(getAuthenticationSession(), targetAdapter, otoa);
            checkUsability(getAuthenticationSession(), targetAdapter, otoa);
        }

        final ObjectAdapter argumentAdapter = argumentObj != null ? getAdapterManager().adapterFor(argumentObj) : null;

        resolveIfRequired(targetAdapter);


        if(getExecutionMode().shouldEnforceRules()) {
View Full Code Here

TOP

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

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.