Package org.apache.isis.core.metamodel.consent

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


    @Override
    public Consent disabled(final View view) {
        final ObjectAdapter adapter = view.getContent().getAdapter();
        if (adapter.getResolveState().isDestroyed()) {
            // TODO: move logic into Facet
            return new Veto("Can't do anything with a destroyed object");
        }
        if (isObjectInRootView(view)) {
            return Allow.DEFAULT;
        } else {
            // TODO: move logic into Facet
            return new Veto("Can't dispose an object from within another view.");
        }
    }
View Full Code Here

            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

    @Override
    public Consent disabled(final View view) {
        final ObjectAdapter adapter = view.getContent().getAdapter();
        if (adapter != null && adapter.getResolveState().isDestroyed()) {
            // TODO: move logic into Facet
            return new Veto("Can't do anything with a destroyed object");
        }
        final Consent usableForUser = action.isUsable(IsisContext.getAuthenticationSession(), target);
        if (usableForUser.isVetoed()) {
            return usableForUser;
        }
View Full Code Here

        }

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

            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

        if (dragSource.getSpecification().isOfType(getSpecification())) {
            // TODO: move logic into Facet
            return Allow.DEFAULT;
        } else {
            // TODO: move logic into Facet
            return new Veto(String.format("Object must be ", getSpecification().getShortIdentifier()));
        }
    }
View Full Code Here

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

                    invalidFields.append(parameterName);
                }
            }
            if (missingFields.length() > 0) {
                // TODO: move logic into Facet
                return new Veto(String.format("Fields needed: %s", missingFields));
            }
            if (invalidFields.length() > 0) {
                // TODO: move logic into Facet
                return new Veto(String.format("Invalid fields: %s", invalidFields));
            }

            final ActionContent actionContent = ((ActionContent) view.getContent());
            return actionContent.disabled();
        }
View Full Code Here

                ApplicationWorkspace.this.markDamaged();
            }

            @Override
            public Consent disabled(final View view) {
                return LookFactory.getInstalledLook() == look ? new Veto("Current look") : Allow.DEFAULT;
            }
        });
    }
View Full Code Here

TOP

Related Classes of org.apache.isis.core.metamodel.consent.Veto

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.