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

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


                writer.println();
                continue;
            }

            if (association.isOneToManyAssociation()) {
                final CollectionFacet facet = associatedObject.getSpecification().getFacet(CollectionFacet.class);
                for (final ObjectAdapter element : facet.iterable(associatedObject)) {
                    final String refId = saved.getId(element);
                    final String cls = element.getSpecification().getFullIdentifier();
                    writer.print(cls + "#" + refId + " ");
                }
                writer.println();
            } else if (association.getSpecification().isParseable()) {
                final ParseableFacet facet = associatedObject.getSpecification().getFacet(ParseableFacet.class);
                String encodedValue = facet.parseableTitle(associatedObject);
                encodedValue = encodedValue.replaceAll("\n", "\\n");
                writer.println(encodedValue);
            } else if (association.isOneToOneAssociation()) {
                final String refId = saved.getId(associatedObject);
                final String cls = associatedObject.getSpecification().getFullIdentifier();
View Full Code Here


            return createObjectData(object);
        }
    }

    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

        final ObjectAdapter[] initData = new ObjectAdapter[state.elements.length];
        int i = 0;
        for (final Data elementData : state.elements) {
            initData[i++] = recreateReference(elementData);
        }
        final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
        facet.init(collection, initData);
    }
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) {
            final ObjectAdapter element = recreateReference(data);
            if (!facet.contains(collection, element)) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("  association " + field + " changed, added " + element.getOid());
                }
                field.addElement(object, element);
            } else {
View Full Code Here

    private static void simpleObject(final ObjectAdapter collectionAdapter, final DebugBuilder debugBuilder) {
        debugBuilder.appendln(collectionAdapter.titleString());
        final ObjectSpecification objectSpec = collectionAdapter.getSpecification();
        if (objectSpec.isCollection()) {
            final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collectionAdapter);
            int i = 1;
            for (final ObjectAdapter element : facet.collection(collectionAdapter)) {
                debugBuilder.appendln(i++ + " " + element.titleString());
            }
        } else {
            // object is a regular Object
            try {
View Full Code Here

        if (ignoreAdapters.contains(collectionAdapter)) {
            debugBuilder.append("*\n");
        } else {
            ignoreAdapters.add(collectionAdapter);
            final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collectionAdapter);
            for (final ObjectAdapter element : facet.collection(collectionAdapter)) {
                graphIndent(level, debugBuilder);
                debugBuilder.append(element);
                if (ignoreAdapters.contains(element)) {
                    debugBuilder.append("*\n");
                } else {
View Full Code Here

                LOG.debug("includeField(Pl, Vec, Str): field is 1->M");
            }

            final OneToManyAssociation oneToManyAssociation = (OneToManyAssociation) field;
            final ObjectAdapter collection = oneToManyAssociation.get(fieldPlace.getObject());
            final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);

            if (LOG.isDebugEnabled()) {
                LOG.debug("includeField(Pl, Vec, Str): 1->M: " + log("collection.size", "" + facet.size(collection)));
            }
            boolean allFieldsNavigated = true;
            final Enumeration elements = facet.elements(collection);
            while (elements.hasMoreElements()) {
                final ObjectAdapter referencedObject = (ObjectAdapter) elements.nextElement();
                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));
View Full Code Here

    private CollectionUtils() {
    }

    public static Object[] getCollectionAsObjectArray(final Object option, final ObjectSpecification spec, final AdapterMap 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 String elementType = typeOfFacet.value().getName();
        final boolean hasAllElements = collectionAdapter.isTransient() || collectionAdapter.getResolveState().isResolved();
        ReferenceData[] elements;

        if (hasAllElements) {
            final CollectionFacet collectionFacet = CollectionFacetUtils.getCollectionFacetFromSpec(collectionAdapter);
            final Enumeration e = collectionFacet.elements(collectionAdapter);
            elements = new ReferenceData[collectionFacet.size(collectionAdapter)];
            int i = 0;
            while (e.hasMoreElements()) {
                final ObjectAdapter element = (ObjectAdapter) e.nextElement();
                elements[i++] = serializeAdapter(element, graphDepth, knownObjects);
            }
View Full Code Here

        final ObjectAdapter adapter = deserializer.deserialize(data);

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

        final CollectionFacet facet = adapter.getSpecification().getFacet(CollectionFacet.class);
        assertEquals(0, facet.size(adapter));
    }
View Full Code Here

TOP

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

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.