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

Examples of org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet.iterable()


    private void writeCollection(final StateWriter writer, final ObjectAssociation association,
        final ObjectAdapter collection, final KeyCreator keyCreator) {
        final CollectionFacet collectionFacet = collection.getSpecification().getFacet(CollectionFacet.class);
        if (association.getSpecification().isAggregated()) {
            final List<StateWriter> elements = new ArrayList<StateWriter>();
            for (final ObjectAdapter element : collectionFacet.iterable(collection)) {
                final StateWriter elementWriter = writer.createElementWriter();
                elementWriter.writeId(((AggregatedOid) element.getOid()).getId());
                writeFields(elementWriter, element.getSpecification().getFullIdentifier(), element);
                elements.add(elementWriter);
            }
View Full Code Here


                elements.add(elementWriter);
            }
            writer.writeCollection(association.getId(), elements);
        } else {
            String refs = "";
            for (final ObjectAdapter element : collectionFacet.iterable(collection)) {
                if (element.isAggregated()) {
                    throw new DomainModelException(
                        "Can't store an aggregated object within a collection that is not exoected aggregates: "
                            + element + " (" + collection + ")");
                }
View Full Code Here

                        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

                final EncodableFacet encodeableFacet = fieldValue.getSpecification().getFacet(EncodableFacet.class);
                data.put(fieldName, encodeableFacet.toEncodedString(fieldValue));
            } else if (association instanceof OneToManyAssociation) {
                final List<JSONObject> collection = new ArrayList<JSONObject>();
                final CollectionFacet facet = fieldValue.getSpecification().getFacet(CollectionFacet.class);
                for (final ObjectAdapter element : facet.iterable(fieldValue)) {
                    collection.add(encodeTransientData(element, savedObject));
                }
                data.put(fieldName, collection);
            } else {
                if (fieldValue.isTransient() || fieldValue.isAggregated()) {
View Full Code Here

    private void remapContainedAggregatedObject(final ObjectAdapter adapter, final RootOid persistedRootOid) {
        for (final ObjectAssociation association: adapter.getSpecification().getAssociations(Contributed.EXCLUDED)) {
            if (association.isOneToManyAssociation() && !association.isNotPersisted()) {
                final ObjectAdapter collection = association.get(adapter);
                final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection);
                for (final ObjectAdapter element : facet.iterable(collection)) {
                   remapAggregatedObject(element, persistedRootOid);
                }
               
            } else if (association.getSpecification().isParented()) {
                final ObjectAdapter referencedAdapter = association.get(adapter);
View Full Code Here

            if (LOG.isDebugEnabled()) {
                LOG.debug("includeField(Pl, Vec, Str): 1->M: " + log("collection.size", "" + facet.size(collection)));
            }
            boolean allFieldsNavigated = true;
            for(final ObjectAdapter referencedObject: facet.iterable(collection)) {
                final boolean appendedXml = appendXmlThenIncludeRemaining(fieldPlace, referencedObject, names, annotation);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("includeField(Pl, Vec, Str): 1->M: + invoked appendXmlThenIncludeRemaining for " + log("referencedObj", referencedObject) + andlog("returned", "" + appendedXml));
                }
                allFieldsNavigated = allFieldsNavigated && appendedXml;
View Full Code Here

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

        final RenderFacet renderFacet = objectMember.getFacet(RenderFacet.class);
        boolean eagerlyRender = renderFacet != null && renderFacet.value() == Type.EAGERLY && rendererContext.canEagerlyRender(valueAdapter);

        final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(valueAdapter);
        final List<JsonRepresentation> list = Lists.newArrayList();
        for (final ObjectAdapter elementAdapter : facet.iterable(valueAdapter)) {

            final LinkBuilder valueLinkBuilder = DomainObjectReprRenderer.newLinkToBuilder(rendererContext, Rel.VALUE, elementAdapter);
            if(eagerlyRender) {
                final DomainObjectReprRenderer renderer = new DomainObjectReprRenderer(getRendererContext(), getLinkFollowSpecs(), JsonRepresentation.newMap());
                renderer.with(elementAdapter);
View Full Code Here

    private Data createCollectionData(final ObjectAdapter object) {
        final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(object);
        final Data[] collData = new Data[facet.size(object)];
        int i = 0;
        for (final ObjectAdapter ref : facet.iterable(object)) {
            collData[i++] = createReferenceData(ref);
        }
        final String elementTypeSpecName = object.getSpecification().getFullIdentifier();
        return new CollectionData(object.getOid(), object.getResolveState(), elementTypeSpecName, collData);
    }
View Full Code Here

    private void updateOneToManyAssociation(final ObjectAdapter object, final OneToManyAssociation field,
        final CollectionData collectionData) {
        final ObjectAdapter collection = field.get(object);
        final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection);
        final List<ObjectAdapter> original = Lists.newArrayList();
        for (final ObjectAdapter adapter : facet.iterable(collection)) {
            original.add(adapter);
        }

        final Data[] elements = collectionData.elements;
        for (final Data data : elements) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.