Package org.apache.isis.core.metamodel.spec.feature

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


    }

    @Override
    public Consent canClear() {
        final ObjectAdapter parentAdapter = getParent();
        final OneToOneAssociation association = getOneToOneAssociation();
        // ObjectAdapter associatedObject = getObject();

        final Consent isEditable = isEditable();
        if (isEditable.isVetoed()) {
            return isEditable;
        }

        final Consent consent = association.isAssociationValid(parentAdapter, null);
        if (consent.isAllowed()) {
            consent.setDescription("Clear the association to this object from '" + parentAdapter.titleString() + "'");
        }
        return consent;
    }
View Full Code Here


        final JsonRepresentation membersList = JsonRepresentation.newArray();
        representation.mapPut("members", membersList);
        final List<ObjectAssociation> associations = objectSpecification.getAssociations();
        for (final ObjectAssociation association : associations) {
            if (association.isOneToOneAssociation()) {
                final OneToOneAssociation property = (OneToOneAssociation) association;
                final LinkBuilder linkBuilder = PropertyDescriptionReprRenderer.newLinkToBuilder(getResourceContext(), Rel.PROPERTY, objectSpecification, property);
                membersList.arrayAdd(linkBuilder.build());
            } else if (association.isOneToManyAssociation()) {
                final OneToManyAssociation collection = (OneToManyAssociation) association;
                final LinkBuilder linkBuilder = CollectionDescriptionReprRenderer.newLinkToBuilder(getResourceContext(), Rel.PROPERTY, objectSpecification, collection);
View Full Code Here

        final ObjectMember objectMember = parentSpec.getAssociation(propertyId);
        if (objectMember == null || objectMember.isOneToManyAssociation()) {
            throw JsonApplicationException.create(HttpStatusCode.NOT_FOUND);
        }
        final OneToOneAssociation property = (OneToOneAssociation) objectMember;

        final RendererFactory rendererFactory = rendererFactoryRegistry.find(representationType);

        final PropertyDescriptionReprRenderer renderer = (PropertyDescriptionReprRenderer) rendererFactory.newRenderer(getResourceContext(), null, JsonRepresentation.newMap());
        renderer.with(new ParentSpecAndProperty(parentSpec, property)).includesSelf();
View Full Code Here

        return titleString(value, field.getObjectAssociation(), field.getSpecification());
    }

    private ObjectAdapter validateAndParse(final String entryText) {
        final ObjectAdapter newValue = parse(entryText);
        final OneToOneAssociation objectAssociation = (OneToOneAssociation) field.getObjectAssociation();
        final Consent valid = objectAssociation.isAssociationValid(parent, newValue);
        if (valid.isVetoed()) {
            throw new InvalidEntryException(valid.getReason());
        }
        return newValue;
    }
View Full Code Here

    public ScalarModel(final ObjectAdapterMemento parentObjectAdapterMemento, final PropertyMemento pm) {
        this.kind = Kind.PROPERTY;
        this.parentObjectAdapterMemento = parentObjectAdapterMemento;
        this.propertyMemento = pm;

        final OneToOneAssociation property = propertyMemento.getProperty();
        final ObjectAdapter associatedAdapter = property.get(parentObjectAdapterMemento.getObjectAdapter());

        setObject(associatedAdapter);
        setMode(Mode.VIEW);
    }
View Full Code Here

    }

    public void apply() {
        final ObjectAdapter adapter = getObjectAdapterMemento().getObjectAdapter();
        for (final ScalarModel scalarModel : propertyScalarModels.values()) {
            final OneToOneAssociation property = scalarModel.getPropertyMemento().getProperty();
            final ObjectAdapter associate = scalarModel.getObject();
            property.set(adapter, associate);
        }
        getObjectAdapterMemento().setAdapter(adapter);
        toViewMode();
    }
View Full Code Here

        final boolean openForObjectsWithOutReferences = true;
        return openForObjectsWithOutReferences ? CAN_OPEN : CANT_OPEN;
    }

    private boolean fieldContainsReference(final ObjectAdapter parent, final ObjectAssociation field) {
        final OneToOneAssociation association = (OneToOneAssociation) field;
        final OneToOneFieldImpl fieldContent = new OneToOneFieldImpl(parent, field.get(parent), association);
        if (openViewSpecification.canDisplay(new ViewRequirement(fieldContent, ViewRequirement.OPEN))) {
            return true;
        }
        return false;
View Full Code Here

        final List<ObjectAssociation> associations = target.getSpecification().getAssociations(ObjectAssociationFilters.dynamicallyVisible(IsisContext.getAuthenticationSession(), target));

        for (int i = 0; i < associations.size(); i++) {
            final ObjectAssociation association = associations.get(i);
            if (association.isOneToOneAssociation() && source.getSpecification().isOfType(association.getSpecification())) {
                final OneToOneAssociation otoa = (OneToOneAssociation) association;
                if (association.get(target) == null && otoa.isAssociationValid(target, source).isAllowed()) {
                    otoa.setAssociation(target, source);
                    break;
                }
            }
        }
View Full Code Here

            LOG.debug("request setValue " + fieldIdentifier + " on " + targetIdentityData + " with "
                + encodeableObjectData + " for " + session);
        }

        final ObjectAdapter targetAdapter = getPersistentObjectAdapter(session, targetIdentityData);
        final OneToOneAssociation association =
            (OneToOneAssociation) targetAdapter.getSpecification().getAssociation(fieldIdentifier);

        ensureAssociationModifiableElseThrowException(session, targetAdapter, association);

        final String encodedObject = encodeableObjectData.getEncodedObjectData();

        final ObjectSpecification specification = association.getSpecification();
        final ObjectAdapter adapter = restoreLeafObject(encodedObject, specification);
        association.setAssociation(targetAdapter, adapter);

        return new SetValueResponse(getUpdates());
    }
View Full Code Here

        if (LOG.isDebugEnabled()) {
            LOG.debug("request clearValue " + fieldIdentifier + " on " + targetIdentityData + " for " + session);
        }

        final ObjectAdapter targetAdapter = getPersistentObjectAdapter(session, targetIdentityData);
        final OneToOneAssociation association =
            (OneToOneAssociation) targetAdapter.getSpecification().getAssociation(fieldIdentifier);

        ensureAssociationModifiableElseThrowException(session, targetAdapter, association);

        association.clearAssociation(targetAdapter);
        return new ClearValueResponse(getUpdates());
    }
View Full Code Here

TOP

Related Classes of org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation

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.