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

Examples of org.apache.isis.core.metamodel.facets.properties.modify.PropertySetterFacet


                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
            try {
                referencedAdapter = parseableFacet.parseTextEntry(adapter, cellText);
            } catch (final IllegalArgumentException ex) {
                return SetUpObjectResult.CANNOT_PARSE;
            }

        } else {
            // handle as reference to known object
            referencedAdapter = getAliasRegistry().getAliased(cellText);
            if (referencedAdapter == null) {
                return SetUpObjectResult.UNKNOWN_REFERENCE;
            }
        }

        setterFacet.setProperty(adapter, referencedAdapter);
        return SetUpObjectResult.OK;
    }
View Full Code Here


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

        final OneToOneAssociation otoa = (OneToOneAssociation) nakedObjectMember;

        // set
        final PropertySetterFacet setterFacet = otoa.getFacet(PropertySetterFacet.class);
        if (setterFacet == null) {
            final CellBinding onMemberBinding = performContext.getPeer().getOnMemberBinding();
            throw ScenarioBoundValueException.current(onMemberBinding, "(cannot set)");
        }

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

        // obtain existing as 'context' (used if this is a parsed @Value)
        final ObjectAdapter contextAdapter = otoa.get(onAdapter);

        // validate parameter
        final ObjectAdapter toSetAdapter =
            performContext.getPeer().getAdapter(contextAdapter, otoa.getSpecification(), arg0Binding, arg0Cell);
        final Consent validConsent = otoa.isAssociationValid(onAdapter, toSetAdapter);
        if (validConsent.isVetoed()) {
            throw ScenarioBoundValueException.current(arg0Binding, validConsent.getReason());
        }

        setterFacet.setProperty(onAdapter, toSetAdapter);

    }
View Full Code Here

        final PropertyOrCollectionAccessorFacet getterFacet = holder.getFacet(PropertyOrCollectionAccessorFacet.class);
        if(getterFacet == null) {
            return null;
        }
        final PropertyClearFacet clearFacet = holder.getFacet(PropertyClearFacet.class);
        final PropertySetterFacet setterFacet = holder.getFacet(PropertySetterFacet.class);
        if (clearFacet == null && setterFacet == null) {
            return null;
        }
        if(setterFacet != null) {
            holder.removeFacet(setterFacet);
View Full Code Here

        }
    }

    @Override
    public void setAssociation(final ObjectAdapter ownerAdapter, final ObjectAdapter newReferencedAdapter) {
        final PropertySetterFacet setterFacet = getFacet(PropertySetterFacet.class);
        if (setterFacet != null) {
            if (ownerAdapter.isPersistent() && newReferencedAdapter != null && newReferencedAdapter.isTransient()
                && !newReferencedAdapter.getSpecification().isAggregated()) {
                // TODO: move to facet ?
                throw new IsisException("can't set a reference to a transient object from a persistent one: "
                    + newReferencedAdapter.titleString() + " (transient)");
            }
            setterFacet.setProperty(ownerAdapter, newReferencedAdapter);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.isis.core.metamodel.facets.properties.modify.PropertySetterFacet

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.