Examples of OneToManyAssociation


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, where).isAllowed()) {
            content.add(context.getComponentFactory().createAddOption(id, collection.getId()));
        }
    }
View Full Code Here

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

        final ObjectAdapter onAdapter = performContext.getOnAdapter();
        final ObjectMember nakedObjectMember = performContext.getObjectMember();
        final CellBinding onMemberBinding = performContext.getPeer().getOnMemberBinding();

        final OneToManyAssociation otma = (OneToManyAssociation) nakedObjectMember;

        final CollectionAddToFacet addToFacet = nakedObjectMember.getFacet(CollectionAddToFacet.class);
        if (addToFacet == null) {
            throw ScenarioBoundValueException.current(onMemberBinding, "(cannot add to collection)");
        }

        // safe since guaranteed by superclass
        final CellBinding arg0Binding = performContext.getPeer().getArg0Binding();
        final ScenarioCell arg0Cell = arg0Binding.getCurrentCell();
        final String toAddAlias = arg0Cell.getText();

        final ObjectAdapter toAddAdapter = performContext.getPeer().getAliasRegistry().getAliased(toAddAlias);
        if (toAddAdapter == null) {
            throw ScenarioBoundValueException.current(arg0Binding, "(unknown alias)");
        }

        // validate argument
        otma.createValidateAddInteractionContext(getSession(), InteractionInvocationMethod.BY_USER, onAdapter, toAddAdapter);
        final Consent validToAdd = otma.isValidToAdd(onAdapter, toAddAdapter);
        if (validToAdd.isVetoed()) {
            throw ScenarioBoundValueException.current(arg0Binding, validToAdd.getReason());
        }

        // add
View Full Code Here

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

        @SuppressWarnings("unused")
        final ScenarioCell onMemberCell = onMemberBinding.getCurrentCell();

        final List<ScenarioCell> argumentCells = performContext.getArgumentCells();

        final OneToManyAssociation otma = (OneToManyAssociation) nakedObjectMember;

        // safe since guaranteed by superclass
        final CellBinding arg0Binding = performContext.getPeer().getArg0Binding();
        final ScenarioCell arg0Cell = argumentCells.get(0);
        final String toRemove = arg0Cell.getText();

        final CollectionRemoveFromFacet removeFromFacet = nakedObjectMember.getFacet(CollectionRemoveFromFacet.class);
        if (removeFromFacet == null) {
            throw ScenarioBoundValueException.current(onMemberBinding, "(cannot remove from collection)");
        }

        final ObjectAdapter toRemoveAdapter = performContext.getPeer().getAliasRegistry().getAliased(toRemove);
        if (toRemoveAdapter == null) {
            throw ScenarioBoundValueException.current(arg0Binding, "(unknown alias)");
        }

        // validate argument
        otma.createValidateAddInteractionContext(getSession(), InteractionInvocationMethod.BY_USER, onAdapter, toRemoveAdapter);
        final Consent validToRemove = otma.isValidToRemove(onAdapter, toRemoveAdapter);
        if (validToRemove.isVetoed()) {
            throw ScenarioBoundValueException.current(onMemberBinding, validToRemove.getReason());
        }

        // remove
View Full Code Here

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

    @Override
    protected Consent determineConsent(final PerformContext performContext, final ObjectAdapter toValidateAdapter) {

        final ObjectAdapter onAdapter = performContext.getOnAdapter();
        final OneToManyAssociation otma = (OneToManyAssociation) performContext.getObjectMember();

        return otma.isValidToAdd(onAdapter, toValidateAdapter);
    }
View Full Code Here

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

            if (intent == Intent.CHECK_IF_VALID) {
                throw new UnsupportedOperationException(String.format("Cannot invoke supporting method '%s'; use only collection accessor/mutator", memberName));
            }

            final OneToManyAssociation otma = (OneToManyAssociation) objectMember;
            if (intent == Intent.ACCESSOR) {
                return handleGetterMethodOnCollection(method, args, targetAdapter, otma, memberName);
            }
            if (intent == Intent.MODIFY_COLLECTION_ADD) {
                return handleCollectionAddToMethod(args, targetAdapter, otma, methodName);
View Full Code Here

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

        if (idString == null) {
            throw new ActionException("Task no longer in progress");
        }
        final ObjectAdapter object = context.getMappedObject(idString);
        final ObjectSpecification specification = object.getSpecification();
        final OneToManyAssociation field = (OneToManyAssociation) specification.getAssociation(collectionField);
        final AddItemToCollectionTask addTask = new AddItemToCollectionTask(context, object, field);
        context.addTaskCrumb(addTask);
        request.forward(ForwardRequest.task(addTask));
    }
View Full Code Here

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

            if (association.isNotPersisted()) {
                continue;
            }
            final ObjectAdapter fieldAdapter = association.get(adapter);
            if (association.isOneToManyAssociation()) {
                final OneToManyAssociation oneToManyAssociation = (OneToManyAssociation) association;
                final ObjectAdapter collectionAdapter = fieldAdapter; // to explain
                writeCollection(writer, oneToManyAssociation, collectionAdapter);
            } else {
                final OneToOneAssociation oneToOneAssociation = (OneToOneAssociation) association;
                final ObjectAdapter propertyAdapter = fieldAdapter; // to explain
View Full Code Here

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

        final String collectionField = request.getProperty();

        final ObjectAdapter target = context.getMappedObject(objectId);
        final ObjectAdapter element = context.getMappedObject(elementId);
        final ObjectSpecification specification = target.getSpecification();
        final OneToManyAssociation field = (OneToManyAssociation) specification.getAssociation(collectionField);
        field.removeElement(target, element);

        request.forward(ForwardRequest.viewObject(objectId, collectionField));
    }
View Full Code Here

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

        final EntityCollectionModel entityCollectionModel = (EntityCollectionModel) model;
        if(!entityCollectionModel.isParented()) {
            return false;
        }

        final OneToManyAssociation collection =
                entityCollectionModel.getCollectionMemento().getCollection();
        RenderFacet renderFacet = collection.getFacet(RenderFacet.class);
        return renderFacet != null && renderFacet.value() == Type.EAGERLY;
    }
View Full Code Here

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

            final String collectionId,
            final MemberReprMode memberMode) {

        ObjectAdapterAccessHelper accessHelper = new ObjectAdapterAccessHelper(representationServiceContext, objectAdapter);

        final OneToManyAssociation collection = accessHelper.getCollectionThatIsVisibleForIntent(collectionId, ObjectAdapterAccessHelper.Intent.ACCESS);

        return representationService.collectionDetails(representationServiceContext, new ObjectAndCollection(objectAdapter, collection), memberMode);
    }
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.