Examples of OneToManyAssociation


Examples of org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation

        } else if (field instanceof OneToManyAssociation) {
            if (LOG.isDebugEnabled()) {
                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)));
            }
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation

                if (LOG.isDebugEnabled()) {
                    LOG.debug("objectToElement(NO): " + log("field", fieldName) + " is OneToManyAssociation");
                }

                final OneToManyAssociation oneToManyAssociation = (OneToManyAssociation) field;
                final Element xmlCollectionElement = xmlFieldElement; // more
                                                                      // meaningful
                                                                      // locally
                                                                      // scoped
                                                                      // name

                ObjectAdapter collection;
                try {
                    collection = oneToManyAssociation.get(object);
                    final ObjectSpecification referencedTypeNos = oneToManyAssociation.getSpecification();
                    final String fullyQualifiedClassName = referencedTypeNos.getFullIdentifier();

                    // XML
                    isisMetaModel.setIsisCollection(xmlCollectionElement, schema.getPrefix(), fullyQualifiedClassName, collection);
                } catch (final Exception ex) {
                    LOG.warn("objectToElement(NO): " + log("field", fieldName) + ": get(obj) threw exception - skipping XML generation");
                }

                // XSD
                xsdFieldElement = schema.createXsElementForNofCollection(xsElement, xmlCollectionElement, oneToManyAssociation.getSpecification().getFullIdentifier(), FacetUtil.getFacetsByType(oneToManyAssociation));

            } else {
                if (LOG.isInfoEnabled()) {
                    LOG.info("objectToElement(NO): " + log("field", fieldName) + " is unknown type; ignored");
                }
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation

    @Override
    protected void doExecute(final Context context, final ViewPane content, final ObjectAdapter object, final String field) {
        final String id = context.mapObject(object);
        final ObjectSpecification specification = object.getSpecification();

        final OneToManyAssociation collection = (OneToManyAssociation) specification.getAssociation(field);

        IsisContext.getPersistenceSession().resolveField(object, collection);

        context.addCollectionFieldCrumb(collection.getName());
        content.add(context.getComponentFactory().createHeading(collection.getName()));
        final Table table = TableUtil.createTable(context, id, object, collection);
        content.add(table);
        if (collection.isUsable(IsisContext.getAuthenticationSession(), object).isAllowed()) {
            content.add(context.getComponentFactory().createAddOption(id, collection.getId()));
        }
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation

    // getInstance
    // /////////////////////////////////////////////////////////////

    @Override
    public Instance getInstance(final ObjectAdapter adapter) {
        final OneToManyAssociation specification = this;
        return adapter.getInstance(specification);
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation

        init();

        final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), objectAdapter);

        final OneToManyAssociation collection = helper.getCollectionThatIsVisibleAndUsable(collectionId, Intent.MUTATE);

        if (!collection.getCollectionSemantics().isSet()) {
            throw JsonApplicationException.create(HttpStatusCode.BAD_REQUEST, "Collection '%s' does not have set semantics", collectionId);
        }

        final ObjectSpecification collectionSpec = collection.getSpecification();
        final String bodyAsString = DomainResourceHelper.asStringUtf8(body);
        final ObjectAdapter argAdapter = helper.parseAsMapWithSingleValue(collectionSpec, bodyAsString);

        final Consent consent = collection.isValidToAdd(objectAdapter, argAdapter);
        if (consent.isVetoed()) {
            throw JsonApplicationException.create(HttpStatusCode.UNAUTHORIZED, consent.getReason());
        }

        collection.addElement(objectAdapter, argAdapter);

        return helper.collectionDetails(objectAdapter, collectionId, MemberMode.MUTATING, Caching.NONE);
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation

        init();

        final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), objectAdapter);

        final OneToManyAssociation collection = helper.getCollectionThatIsVisibleAndUsable(collectionId, Intent.MUTATE);

        if (!collection.getCollectionSemantics().isListOrArray()) {
            throw JsonApplicationException.create(HttpStatusCode.METHOD_NOT_ALLOWED, "Collection '%s' does not have list or array semantics", collectionId);
        }

        final ObjectSpecification collectionSpec = collection.getSpecification();
        final String bodyAsString = DomainResourceHelper.asStringUtf8(body);
        final ObjectAdapter argAdapter = helper.parseAsMapWithSingleValue(collectionSpec, bodyAsString);

        final Consent consent = collection.isValidToAdd(objectAdapter, argAdapter);
        if (consent.isVetoed()) {
            throw JsonApplicationException.create(HttpStatusCode.UNAUTHORIZED, consent.getReason());
        }

        collection.addElement(objectAdapter, argAdapter);

        return helper.collectionDetails(objectAdapter, collectionId, MemberMode.MUTATING, Caching.NONE);
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation

        init();

        final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), objectAdapter);

        final OneToManyAssociation collection = helper.getCollectionThatIsVisibleAndUsable(collectionId, Intent.MUTATE);

        final ObjectSpecification collectionSpec = collection.getSpecification();
        final ObjectAdapter argAdapter = helper.parseAsMapWithSingleValue(collectionSpec, getResourceContext().getQueryString());

        final Consent consent = collection.isValidToRemove(objectAdapter, argAdapter);
        if (consent.isVetoed()) {
            throw JsonApplicationException.create(HttpStatusCode.UNAUTHORIZED, consent.getReason());
        }

        collection.removeElement(objectAdapter, argAdapter);

        return helper.collectionDetails(objectAdapter, collectionId, MemberMode.MUTATING, Caching.NONE);
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation

            if (mode.isCutDown()) {
                // don't include collections
                continue;
            }
            if (assoc instanceof OneToManyAssociation) {
                final OneToManyAssociation collection = (OneToManyAssociation) assoc;

                final RendererFactory factory = getRendererFactoryRegistry().find(RepresentationType.OBJECT_COLLECTION);
                final ObjectCollectionReprRenderer renderer = (ObjectCollectionReprRenderer) factory.newRenderer(getResourceContext(), linkFollower, JsonRepresentation.newMap());

                renderer.with(new ObjectAndCollection(objectAdapter, collection)).usingLinkTo(linkToBuilder);
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation

    // collectionDetails
    // //////////////////////////////////////////////////////////////

    Response collectionDetails(final ObjectAdapter objectAdapter, final String collectionId, final MemberMode memberMode, final Caching caching) {

        final OneToManyAssociation collection = getCollectionThatIsVisibleAndUsable(collectionId, Intent.ACCESS);

        final RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.OBJECT_COLLECTION);
        final ObjectCollectionReprRenderer renderer = (ObjectCollectionReprRenderer) factory.newRenderer(resourceContext, null, JsonRepresentation.newMap());

        renderer.with(new ObjectAndCollection(objectAdapter, collection)).usingLinkTo(adapterLinkTo);
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation

        final ObjectAssociation association = objectAdapter.getSpecification().getAssociation(collectionId);
        if (association == null || !association.isOneToManyAssociation()) {
            throwNotFoundException(collectionId, MemberType.COLLECTION);
        }
        final OneToManyAssociation collection = (OneToManyAssociation) association;
        return memberThatIsVisibleAndUsable(collection, MemberType.COLLECTION, intent);
    }
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.