Examples of MandatoryFacet


Examples of org.apache.isis.core.metamodel.facets.mandatory.MandatoryFacet

        return containsFacet(PropertyChoicesFacet.class);
    }

    @Override
    public boolean isMandatory() {
        final MandatoryFacet mandatoryFacet = getFacet(MandatoryFacet.class);
        return mandatoryFacet != null && !mandatoryFacet.isInvertedSemantics();
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.facets.mandatory.MandatoryFacet

    }

    @Override
    public void toDefault(final ObjectAdapter ownerAdapter) {
        // don't default optional fields
        final MandatoryFacet mandatoryFacet = getFacet(MandatoryFacet.class);
        if (mandatoryFacet != null && mandatoryFacet.isInvertedSemantics()) {
            return;
        }

        final ObjectAdapter defaultValue = getDefault(ownerAdapter);
        if (defaultValue != null) {
View Full Code Here

Examples of org.apache.isis.core.metamodel.facets.mandatory.MandatoryFacet

        assertFalse(objectAssociation.isMandatory());
    }

    @Test
    public void mandatory() throws Exception {
        final MandatoryFacet mockFacet = mockFacetIgnoring(MandatoryFacet.class);
        facetedMethod.addFacet(mockFacet);
        assertTrue(objectAssociation.isMandatory());
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.facets.mandatory.MandatoryFacet

        }
        final PropertyModifyContext propertyModifyContext = (PropertyModifyContext) context;
        ObjectAdapter proposed = propertyModifyContext.getProposed();
        if(proposed == null) {
            // skip validation if null value and optional property.
            MandatoryFacet mandatoryFacet = getFacetHolder().getFacet(MandatoryFacet.class);
            if(mandatoryFacet == null || mandatoryFacet.isNoop() || mandatoryFacet.isInvertedSemantics()) {
                return null;
            }
        }
        return invalidReason(propertyModifyContext.getTarget(), proposed);
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.facets.mandatory.MandatoryFacet

        return description == null ? "" : description;
    }

    @Override
    public boolean isOptional() {
        final MandatoryFacet facet = getFacet(MandatoryFacet.class);
        return facet.isInvertedSemantics();
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.facets.mandatory.MandatoryFacet

    public void process(final ProcessMethodContext processMethodContext) {
        final Column annotation = Annotations.getAnnotation(processMethodContext.getMethod(), Column.class);

        final FacetedMethod holder = processMethodContext.getFacetHolder();
       
        final MandatoryFacet existingFacet = holder.getFacet(MandatoryFacet.class);
        if(existingFacet != null) {
           
            if (existingFacet instanceof OptionalFacetDerivedFromJdoPrimaryKeyAnnotation) {
                // do not replace this facet;
                // we must keep an optional facet here for different reasons
                return;
            }
            if (existingFacet instanceof MandatoryFacetExplicitForProperty) {
                // do not replace this facet;
                // an explicit @Mandatory annotation cannot be overridden by @Column annotation
                return;
            }
        }
       
        boolean required = whetherRequired(processMethodContext, annotation);
        MandatoryFacet facet = annotation != null
                ? new MandatoryFacetDerivedFromJdoColumn(holder, required)
                : new MandatoryFacetInferredFromAbsenceOfJdoColumn(holder, required);
               
       
        // as a side-effect, will chain any existing facets.
        // we'll exploit this fact for meta-model validation (see #refineMetaModelValidator(), below)
        FacetUtil.addFacet(facet);
       
        // however, if a @Column was explicitly provided, and the underlying facet
        // was the simple MandatoryFacetDefault (from an absence of @Optional or @Mandatory),
        // then don't chain, simply replace.
        if(facet instanceof MandatoryFacetDerivedFromJdoColumn && facet.getUnderlyingFacet() instanceof MandatoryFacetDefault) {
            facet.setUnderlyingFacet(null);
        }
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.facets.mandatory.MandatoryFacet

                    // skip checks if annotated with JDO @NotPersistent
                    if(association.containsDoOpFacet(JdoNotPersistentFacet.class)) {
                        return;
                    }
                   
                    MandatoryFacet facet = association.getFacet(MandatoryFacet.class);

                    MandatoryFacet underlying = (MandatoryFacet) facet.getUnderlyingFacet();
                    if(underlying == null) {
                        continue;
                    }

                    if(facet instanceof MandatoryFacetDerivedFromJdoColumn) {

                        if(association.isNotPersisted()) {
                            validationFailures.add("%s: @javax.jdo.annotations.Column found on non-persisted property; please remove)", association.getIdentifier().toClassAndNameIdentityString());
                            continue;
                        }

                        if(underlying.isInvertedSemantics() == facet.isInvertedSemantics()) {
                            continue;
                        }
                       
                        if(underlying.isInvertedSemantics()) {
                            // ie @Optional
                            validationFailures.add("%s: incompatible usage of Isis' @Optional annotation and @javax.jdo.annotations.Column; use just @javax.jdo.annotations.Column(allowNulls=\"...\")", association.getIdentifier().toClassAndNameIdentityString());
                        } else {
                            validationFailures.add("%s: incompatible Isis' default of required/optional properties vs JDO; add @javax.jdo.annotations.Column(allowNulls=\"...\")", association.getIdentifier().toClassAndNameIdentityString());
                        }
                    }
                   
                    if(facet instanceof MandatoryFacetInferredFromAbsenceOfJdoColumn) {
                       
                        if(association.isNotPersisted()) {
                            // nothing to do.
                            continue;
                        }

                        if(underlying.isInvertedSemantics() == facet.isInvertedSemantics()) {
                            continue;
                        }
                        if(underlying.isInvertedSemantics()) {
                            // ie @Optional
                            validationFailures.add("%s: incompatible usage of Isis' @Optional annotation and @javax.jdo.annotations.Column; use just @javax.jdo.annotations.Column(allowNulls=\"...\")", association.getIdentifier().toClassAndNameIdentityString());
                        } else {
                            validationFailures.add("%s: incompatible default handling of required/optional properties between Isis and JDO; add @javax.jdo.annotations.Column(allowsNull=\"...\")", association.getIdentifier().toClassAndNameIdentityString());
                        }
View Full Code Here

Examples of org.apache.isis.core.metamodel.facets.mandatory.MandatoryFacet

        return description == null ? "" : description;
    }

    @Override
    public boolean isOptional() {
        final MandatoryFacet facet = getFacet(MandatoryFacet.class);
        return facet.isInvertedSemantics();
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.facets.mandatory.MandatoryFacet

        assertFalse(objectAssociation.isMandatory());
    }

    @Test
    public void mandatory() throws Exception {
        final MandatoryFacet mockFacet = mockFacetIgnoring(MandatoryFacet.class);
        facetedMethod.addFacet(mockFacet);
        assertTrue(objectAssociation.isMandatory());
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.facets.mandatory.MandatoryFacet

    }

    @Override
    public void toDefault(final ObjectAdapter ownerAdapter) {
        // don't default optional fields
        final MandatoryFacet mandatoryFacet = getFacet(MandatoryFacet.class);
        if (mandatoryFacet != null && mandatoryFacet.isInvertedSemantics()) {
            return;
        }

        final ObjectAdapter defaultValue = getDefault(ownerAdapter);
        if (defaultValue != null) {
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.