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

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


        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


            }
            // ignore disabled properties
            if (property.isUsable(context.getSession(), adapter).isVetoed()) {
                continue;
            }
            final OneToOneAssociation otoa = (OneToOneAssociation) property;
            final ObjectAdapter value = otoa.get(adapter);
            if (otoa.isAssociationValid(adapter, value).isVetoed()) {
                if (buf.length() > 0) {
                    buf.append(", ");
                }
                buf.append(property.getName());
            }
View Full Code Here

            throw new WebApplicationException(responseOfGone("could not determine object"));
        }

        final ObjectSpecification noSpec = nakedObject.getSpecification();

        final OneToOneAssociation property = (OneToOneAssociation) noSpec.getAssociation(propertyId);

        final ObjectAdapter proposedValueNO = getObjectAdapter(proposedValue, nakedObject, property);

        // make sure we have a value (should be using clear otherwise)
        if (proposedValueNO == null) {
            throw new WebApplicationException(responseOfBadRequest("null argument"));
        }

        // validate
        final Consent consent = property.isAssociationValid(nakedObject, proposedValueNO);
        if (consent.isVetoed()) {
            throw new WebApplicationException(responseOfBadRequest(consent));
        }

        // html template
        final XhtmlTemplate xhtml =
            new XhtmlTemplate(nakedObject.titleString() + "." + propertyId, getServletRequest());
        xhtml.appendToBody(asDivIsisSession());
        xhtml.appendToBody(resourcesDiv());

        // title & Oid
        final Element div = asDivTableObjectDetails(nakedObject);
        xhtml.appendToBody(div);

        // if valid, then set
        property.setAssociation(nakedObject, proposedValueNO);

        return xhtml.toXML();
    }
View Full Code Here

            throw new WebApplicationException(responseOfGone("could not determine object"));
        }

        final ObjectSpecification noSpec = objectAdapter.getSpecification();

        final OneToOneAssociation property = (OneToOneAssociation) noSpec.getAssociation(propertyId);

        // validate
        final Consent consent = property.isAssociationValid(objectAdapter, null);
        if (consent.isVetoed()) {
            throw new WebApplicationException(responseOfBadRequest(consent));
        }

        // html template
        final XhtmlTemplate xhtml =
            new XhtmlTemplate(objectAdapter.titleString() + "." + propertyId, getServletRequest());
        xhtml.appendToBody(asDivIsisSession());
        xhtml.appendToBody(resourcesDiv());

        // title & Oid
        final Element div = asDivTableObjectDetails(objectAdapter);
        xhtml.appendToBody(div);

        // if valid, then clear
        property.clearAssociation(objectAdapter);

        return xhtml.toXML();
    }
View Full Code Here

    }

    @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

        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

    // header
    // ///////////////////////////////////////////////////////////////////////

    public PropertyResult definePropertyOrAlias(final String heading, final int colNum) {

        OneToOneAssociation otoa = null;

        try {
            final int aliasColumn = getAliasBinding().getColumn();
            if (colNum == aliasColumn) {
                return PropertyResult.ALIAS;
View Full Code Here

        return getPersistenceSession().createInstance(spec);
    }

    public SetUpObjectResult setUpProperty(final ObjectAdapter adapter, final int colNum) {

        final OneToOneAssociation association = getProperties().get(colNum);
        if (association == null) {
            return SetUpObjectResult.NO_ASSOCIATION;
        }

        final String cellText = cellTextList.get(colNum);

        // handle empty cell as null
        if (cellText == null || cellText.length() == 0) {

            // use clear facet if available
            final PropertyClearFacet clearFacet = association.getFacet(PropertyClearFacet.class);

            if (clearFacet != null) {
                clearFacet.clearProperty(adapter);
                return SetUpObjectResult.CLEARED;
            }

            // use setter facet otherwise
            final PropertySetterFacet setterFacet = association.getFacet(PropertySetterFacet.class);

            if (setterFacet != null) {
                setterFacet.setProperty(adapter, null);
                return SetUpObjectResult.CLEARED;
            }

            return SetUpObjectResult.CANNOT_CLEAR;
        }

        // non-empty, will need a setter
        final PropertySetterFacet setterFacet = association.getFacet(PropertySetterFacet.class);
        if (setterFacet == null) {
            return SetUpObjectResult.CANNOT_SET;
        }

        final ObjectSpecification fieldSpecification = association.getSpecification();
        final ParseableFacet parseableFacet = fieldSpecification.getFacet(ParseableFacet.class);

        ObjectAdapter referencedAdapter = null;
        if (parseableFacet != null) {
            // handle as parseable value
View Full Code Here

        }
    }

    public void forEachAssociation(final AssociationVisitor visitor) {
        for (int colNum = 0; colNum < getProperties().size(); colNum++) {
            final OneToOneAssociation association = getProperties().get(colNum);
            if (association != null) {
                visitor.visit(association, colNum);
            }
        }
    }
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

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.