Examples of Veto


Examples of org.apache.isis.core.metamodel.consent.Veto

    @Override
    public Consent canDrop(final Content sourceContent) {
        final ObjectAdapter target = getObject();
        if (!(sourceContent instanceof ObjectContent) || target == null) {
            // TODO: move logic into Facet
            return new Veto(String.format("Can't drop %s onto empty target", sourceContent.getAdapter().titleString()));
        } else {
            final ObjectAdapter source = ((ObjectContent) sourceContent).getObject();
            return canDropOntoObject(target, source);
        }
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.consent.Veto

    }

    private Consent setFieldOfMatchingType(final ObjectAdapter targetAdapter, final ObjectAdapter sourceAdapter) {
        if (targetAdapter.isTransient() && sourceAdapter.isPersistent()) {
            // TODO: use Facet for this test instead.
            return new Veto("Can't set field in persistent object with reference to non-persistent object");
        }
        final List<ObjectAssociation> fields =
            targetAdapter.getSpecification().getAssociations(
                ObjectAssociationFilters.dynamicallyVisible(IsisContext.getAuthenticationSession(), targetAdapter));
        for (final ObjectAssociation fld : fields) {
            if (!fld.isOneToOneAssociation()) {
                continue;
            }
            if (!sourceAdapter.getSpecification().isOfType(fld.getSpecification())) {
                continue;
            }
            if (fld.get(targetAdapter) != null) {
                continue;
            }
            final Consent associationValid =
                ((OneToOneAssociation) fld).isAssociationValid(targetAdapter, sourceAdapter);
            if (associationValid.isAllowed()) {
                return associationValid.setDescription("Set field " + fld.getName());
            }

        }
        // TODO: use Facet for this test instead
        return new Veto(String.format("No empty field accepting object of type %s in %s", sourceAdapter
            .getSpecification().getSingularName(), title()));
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.consent.Veto

            return isEditable();
        }

        if (!spec.isOfType(targetType)) {
            // TODO: move logic into Facet
            return new Veto(String.format("Can only drop objects of type %s", targetType.getSingularName()));
        }

        if (getParent().isPersistent() && adapter.isTransient()) {
            // TODO: move logic into Facet
            return new Veto("Can't drop a non-persistent into this persistent object");
        }

        final Consent perm = getOneToOneAssociation().isAssociationValid(getParent(), adapter);
        return perm;
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.consent.Veto

            final ObjectAdapter parentAdapter = field.getParent();

            final ObjectAdapter collection = getAdapter();
            if (collection == null) {
                // TODO: move logic into Facet
                return new Veto("Collection not set up; can't add elements to a non-existant collection");
            }

            final Consent usableInState =
                getOneToManyAssociation().isUsable(IsisContext.getAuthenticationSession(), parentAdapter);
            if (usableInState.isVetoed()) {
                return usableInState;
            }

            final ObjectSpecification specification = sourceAdapter.getSpecification();
            final ObjectSpecification elementSpecification = getElementSpecification();
            if (!specification.isOfType(elementSpecification)) {
                // TODO: move logic into Facet
                return new Veto(String.format("Only objects of type %s are allowed in this collection",
                    elementSpecification.getSingularName()));
            }
            if (parentAdapter.isPersistent() && sourceAdapter.isTransient()) {
                // TODO: move logic into Facet
                return new Veto("Can't set field in persistent object with reference to non-persistent object");
            }
            return getOneToManyAssociation().isValidToAdd(parentAdapter, sourceAdapter);
        } else {
            return Veto.DEFAULT;
        }
View Full Code Here

Examples of org.apache.isis.core.metamodel.consent.Veto

        }

        if (errorBuf.length() == 0) {
            return Allow.DEFAULT;
        } else {
            return new Veto(errorBuf.toString());
        }
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.consent.Veto

            if (appender instanceof SnapshotAppender) {
                return Allow.DEFAULT;
            }
        }
        // TODO: move logic into Facet
        return new Veto("No available snapshot appender");
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.consent.Veto

            }
            final FieldEditState fieldState = formState.createField(fieldName, newEntry);
            Consent consent = null;

            if (!parameters2.get(i).isOptional() && newEntry.equals("")) {
                consent = new Veto(parameters2.get(i).getName() + " required");
                formState.setError("Not all fields have been set");

            } else if (parameters2.get(i).getSpecification().getFacet(ParseableFacet.class) != null) {
                try {
                    final ParseableFacet facet = parameters2.get(i).getSpecification().getFacet(ParseableFacet.class);
                    final String message = parameters2.get(i).isValid(object, newEntry);
                    if (message != null) {
                        consent = new Veto(message);
                        formState.setError("Not all fields are valid");
                    }
                    final ObjectAdapter entry = facet.parseTextEntry(null, newEntry);
                    fieldState.setValue(entry);
                } catch (final TextEntryParseException e) {
                    consent = new Veto(e.getMessage());
                    formState.setError("Not all fields are valid");
                }
            } else {
                fieldState.setValue(newEntry == null ? null : context.getMappedObject(newEntry));
            }
View Full Code Here

Examples of org.apache.isis.core.metamodel.consent.Veto

            }
            final FieldEditState fieldState = formState.createField(fieldId, newEntry);

            Consent consent = null;
            if (field.isMandatory() && (newEntry.equals("") || newEntry.equals("NULL"))) {
                consent = new Veto(field.getName() + " required");
                formState.setError("Not all fields have been set");
            } else if (field.getSpecification().containsFacet(ParseableFacet.class)) {
                try {
                    final ParseableFacet facet = field.getSpecification().getFacet(ParseableFacet.class);
                    final ObjectAdapter originalValue = field.get(object);
                    final ObjectAdapter newValue = facet.parseTextEntry(originalValue, newEntry);
                    consent = ((OneToOneAssociation) field).isAssociationValid(object, newValue);
                    fieldState.setValue(newValue);
                } catch (final TextEntryParseException e) {
                    consent = new Veto(e.getMessage());
                    // formState.setError("Not all fields have been entered correctly");
                }

            } else {
                final ObjectAdapter associate = newEntry.equals("null") ? null : context.getMappedObject(newEntry);
View Full Code Here

Examples of org.apache.isis.core.metamodel.consent.Veto

        final Consent visibilityConsent = new Allow(new InteractionResult(new PropertyVisibilityEvent(employeeDO, null)));

        final InteractionResult usabilityInteractionResult = new InteractionResult(new PropertyUsabilityEvent(employeeDO, null));
        usabilityInteractionResult.advise("disabled", disabledFacet);
        final Consent usabilityConsent = new Veto(usabilityInteractionResult);

        context.checking(new Expectations() {
            {
                allowing(mockPasswordMember).getFacets(with(any(Filter.class)));
                will(returnValue(facets));
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.