Package org.apache.isis.core.metamodel.facets.collections.modify

Examples of org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet$Utils


        final ObjectAdapter adapter = deserializer.deserialize(data);

        final Vector restoredCollection = (Vector) adapter.getObject();
        assertEquals(2, restoredCollection.size());

        final CollectionFacet facet = adapter.getSpecification().getFacet(CollectionFacet.class);
        final Enumeration elements2 = facet.elements(adapter);
        final ObjectAdapter element0 = (ObjectAdapter) elements2.nextElement();
        final ObjectAdapter element2 = (ObjectAdapter) elements2.nextElement();

        assertNotNull(element0.getObject());
        assertNotNull(element2.getObject());
View Full Code Here


     * "A Customer", "A Product".
     */
    @Override
    public String titleString() {
        if (getSpecification().isCollection()) {
            final CollectionFacet facet = getSpecification().getFacet(CollectionFacet.class);
            return collectionTitleString(facet);
        } else {
            return objectTitleString();
        }
    }
View Full Code Here

        }
    }

    private Data createMadePersistentCollection(final CollectionData collectionData, final ObjectAdapter collection) {
        final ReferenceData[] elementData = collectionData.getElements();
        final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection);
        final Iterator elements = facet.iterator(collection);
        for (int i = 0; i < elementData.length; i++) {
            final ObjectAdapter element = (ObjectAdapter) elements.next();
            final Oid oid = element.getOid();
            Assert.assertNotNull(oid);
            elementData[i] = encodeMadePersistentGraph((ObjectData) elementData[i], element);
View Full Code Here

            // recent object prior to the task
            // null object - so just view service
            request.forward(ForwardRequest.viewService(targetId));
        } else {
            if (result.getSpecification().isCollection()) {
                final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(result);
                if (facet.size(result) == 1) {
                    forwardObjectResult(request, context, facet.firstElement(result));
                } else {
                    forwardCollectionResult(request, context, result);
                }
            } else if (result.getSpecification().isValueOrIsAggregated()) {
                // TODO deal with this object properly, it might not be just a
View Full Code Here

                    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;
                            }
                        }
View Full Code Here

    }

    @Override
    public void checkInstances(final Context context, final ObjectAdapter[] objects) {
        final ObjectAdapter collection = field.get(getTarget(context));
        final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection);
        final ObjectAdapter target = getTarget(context);
        for (int i = 0; i < objects.length; i++) {
            final Consent valueValid = field.isValidToAdd(target, objects[i]);
            if (valueValid.isVetoed()) {
                objects[i] = null;
            } else if (facet.contains(collection, objects[i])) {
                objects[i] = null;
            }
        }
    }
View Full Code Here

        return createTable(context, collectionField != null, collection, summary, type);
    }

    public static Table createTable(final Context context, final boolean addSelector, final ObjectAdapter collection, final String summary, final ObjectSpecification elementType) {

        final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection);
        final List<ObjectAssociation> columnAssociations = elementType.getAssociations(Filters.and(STATICALLY_VISIBLE_ASSOCIATIONS, PROPERTIES));

        final int len = columnAssociations.size();

        final ComponentFactory factory = context.getComponentFactory();
        final Table table = factory.createTable(len, addSelector);
        table.setSummary(summary);

        for (final ObjectAssociation columnAssociation : columnAssociations) {
            table.addColumnHeader(columnAssociation.getName());
        }

        for (final ObjectAdapter rowAdapter : facet.iterable(collection)) {
            getPersistenceSession().resolveImmediately(rowAdapter);
            final String elementId = context.mapObject(rowAdapter);
            table.addRowHeader(factory.createObjectIcon(rowAdapter, elementId, "icon"));

            for (final ObjectAssociation columnAssociation : columnAssociations) {
View Full Code Here

    @Override
    public boolean isEmpty(final ObjectAdapter parentAdapter) {
        // REVIEW should we be able to determine if a collection is empty
        // without loading it?
        final ObjectAdapter collection = get(parentAdapter);
        final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection);
        return facet.size(collection) == 0;
    }
View Full Code Here

    private void makeCollectionPersistent(final ObjectAdapter collection, final ToPersistObjectSet toPersistObjectSet) {
        LOG.info("persist " + collection);
        if (collection.getResolveState() == ResolveState.TRANSIENT) {
            collection.changeState(ResolveState.RESOLVED);
        }
        final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection);
        final Enumeration elements = facet.elements(collection);
        while (elements.hasMoreElements()) {
            makePersistent((ObjectAdapter) elements.nextElement(), toPersistObjectSet);
        }
    }
View Full Code Here

    private void makeCollectionPersistent(final ObjectAdapter collection, final ToPersistObjectSet toPersistObjectSet) {
        LOG.info("persist " + collection);
        if (collection.getResolveState() == ResolveState.TRANSIENT) {
            collection.changeState(ResolveState.RESOLVED);
        }
        final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection);
        final Enumeration elements = facet.elements(collection);
        while (elements.hasMoreElements()) {
            makePersistent((ObjectAdapter) elements.nextElement(), toPersistObjectSet);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet$Utils

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.