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

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


    @Override
    public void process(final Request request) {
        final String id = request.getOptionalProperty(OBJECT);
        final String fieldName = request.getRequiredProperty(FIELD);
        final ObjectAdapter object = request.getContext().getMappedObjectOrResult(id);
        final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
        if (field == null) {
            throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
        }
        if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
            throw new ForbiddenException(field, ForbiddenException.VISIBLE);
        }
        request.appendAsHtmlEncoded(field.getName());
    }
View Full Code Here


        final String linkView = request.getOptionalProperty(LINK_VIEW);
        String className = request.getOptionalProperty(CLASS);
        className = className == null ? "" : " class=\"" + className + "\"";
        RequestContext context = request.getContext();
        final ObjectAdapter object = context.getMappedObjectOrVariable(id, tableBlock.getElementName());
        final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
        if (field == null) {
            throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
        }
        request.appendHtml("<td" + className + ">");
        if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed()) {
            final ObjectAdapter fieldReference = field.get(object);
            final String source = fieldReference == null ? "" : context.mapObject(fieldReference, Scope.REQUEST);
            final String name = request.getOptionalProperty(RESULT_NAME, fieldName);
            context.addVariable(name, Request.getEncoder().encoder(source), Scope.REQUEST);

            if (linkView != null) {
View Full Code Here

        final String objectId = id != null ? id : (String) context.getVariable(RequestContext.RESULT);

        ObjectAdapter object = context.getMappedObjectOrResult(objectId);
        final String field = request.getOptionalProperty(FIELD);
        if (field != null) {
            final ObjectAssociation objectField = object.getSpecification().getAssociation(field);
            object = objectField.get(object);
        }
        request.appendDebug(" for " + object);

        final ObjectSpecification specification = object.getSpecification();
        final String name = showPlural != null ? specification.getPluralName() : specification.getSingularName();
View Full Code Here

        final String id = request.getOptionalProperty(OBJECT);
        ObjectAdapter object = request.getContext().getMappedObjectOrResult(id);

        final String field = request.getOptionalProperty(FIELD);
        if (field != null) {
            final ObjectAssociation objectField = object.getSpecification().getAssociation(field);
            final String error = checkFieldType(objectField);
            if (error != null) {
                throw new ScimpiException("Field " + objectField.getId() + " " + error);
            }
            IsisContext.getPersistenceSession().resolveField(object, objectField);
            object = objectField.get(object);
        }

        process(request, object);
    }
View Full Code Here

        if (!(parent instanceof ObjectAdapter)) {
            parent = getParent().getParent().getContent().getAdapter();
        }

        if (getContent() instanceof FieldContent) {
            final ObjectAssociation field = ((FieldContent) getContent()).getField();
            IsisContext.getPersistenceSession().resolveField(parent, field);
        } else if (getContent() instanceof CollectionContent) {
            IsisContext.getPersistenceSession().resolveImmediately(parent);
        } else if (getContent() instanceof CollectionElement) {
            IsisContext.getPersistenceSession().resolveImmediately(getContent().getAdapter());
View Full Code Here

    }

    private FormState validateObject(final RequestContext context, final ObjectAdapter object, final List<ObjectAssociation> fields) {
        final FormState formState = new FormState();
        for (int i = 0; i < fields.size(); i++) {
            final ObjectAssociation field = fields.get(i);
            final String fieldId = field.getId();
            String newEntry = context.getParameter(fieldId);
            if (fields.get(i).isOneToManyAssociation()) {
                continue;
            }
            if (fields.get(i).isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
                continue;
            }
            if (field.isUsable(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
                continue;
            }

            if (newEntry != null && newEntry.equals("-OTHER-")) {
                newEntry = context.getParameter(fieldId + "-other");
            }

            if (newEntry == null) {
                // TODO duplicated in EditObject; line 97
                final ObjectSpecification spec = field.getSpecification();
                if (spec.isOfType(IsisContext.getSpecificationLoader().loadSpecification(boolean.class)) || spec.isOfType(IsisContext.getSpecificationLoader().loadSpecification(Boolean.class))) {
                    newEntry = FALSE;
                } else {
                    continue;
                }
            }
            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);
                    Localization localization = IsisContext.getLocalization();
                    final ObjectAdapter newValue = facet.parseTextEntry(originalValue, newEntry, localization);
                    consent = ((OneToOneAssociation) field).isAssociationValid(object, newValue);
                    fieldState.setValue(newValue);
                } catch (final TextEntryParseException e) {
View Full Code Here

        try {
            final ObjectAdapter parent = context.getMappedObject(parentId);
            final ObjectAdapter row = context.getMappedObject(rowId);

            final String fieldName = context.getParameter(FIELD);
            final ObjectAssociation field = parent.getSpecification().getAssociation(fieldName);
            if (field == null) {
                throw new ScimpiException("No field " + fieldName + " in " + parent.getSpecification().getFullIdentifier());
            }
            if (field.isVisible(IsisContext.getAuthenticationSession(), parent, where).isVetoed()) {
                throw new ForbiddenException(field, ForbiddenException.VISIBLE);
            }

            ((OneToManyAssociation) field).removeElement(parent, row);
View Full Code Here

        // ObjectAdapter object = getContent().getAdapter();
        final List<ObjectAssociation> associations = getContent().getSpecification().getAssociations(Contributed.EXCLUDED);

        for (final ObjectAssociation objectAssociation : associations) {
            final ObjectAssociation f = objectAssociation;
            final UserActionAbstract action = new UserActionAbstract("Add field " + objectAssociation.getName()) {

                @Override
                public void execute(final Workspace workspace, final View view, final Location at) {
                    final NewObjectField field = new NewObjectField(f);
View Full Code Here

    private void initialBuild(final View view, final Axes axes, final ObjectAdapter object, final List<ObjectAssociation> flds) {
        LOG.debug("  as new build");
        // addViewAxes(view);
        for (int f = 0; f < flds.size(); f++) {
            final ObjectAssociation field = flds.get(f);
            addField(view, axes, object, field, f);
        }
    }
View Full Code Here

        // remove views for fields that no longer exist
        outer: for (int i = 0; i < subviews.length; i++) {
            final FieldContent fieldContent = ((FieldContent) subviews[i].getContent());

            for (int j = 0; j < flds.size(); j++) {
                final ObjectAssociation field = flds.get(j);
                if (fieldContent.getField() == field) {
                    continue outer;
                }
            }
            view.removeView(subviews[i]);
        }

        // update existing fields if needed
        subviews = view.getSubviews();
        for (int i = 0; i < subviews.length; i++) {
            final View subview = subviews[i];
            final ObjectAssociation field = ((FieldContent) subview.getContent()).getField();
            final ObjectAdapter value = field.get(object);

            if (field.isOneToManyAssociation()) {
                subview.update(value);
            } else if (field.isOneToOneAssociation()) {
                final ObjectAdapter existing = subview.getContent().getAdapter();

                // if the field is parseable then it may have been modified; we
                // need to replace what was
                // typed in with the actual title.
                if (!field.getSpecification().isParseable()) {
                    final boolean changedValue = value != existing;
                    final boolean isDestroyed = existing != null && existing.isDestroyed();
                    if (changedValue || isDestroyed) {
                        View fieldView;
                        fieldView = createFieldView(view, axes, object, i, field);
                        if (fieldView != null) {
                            view.replaceView(subview, decorateSubview(axes, fieldView));
                        } else {
                            view.addView(new FieldErrorView("No field for " + value));
                        }
                    }
                } else {
                    if (AdapterUtils.exists(value) && !AdapterUtils.wrappedEqual(value, existing)) {
                        final View fieldView = createFieldView(view, axes, object, i, field);
                        view.replaceView(subview, decorateSubview(axes, fieldView));
                    } else {
                        subview.refresh();
                    }
                }
            } else {
                throw new UnknownTypeException(field.getName());
            }
        }

        // add new fields
        outer2: for (int j = 0; j < flds.size(); j++) {
            final ObjectAssociation field = flds.get(j);
            for (int i = 0; i < subviews.length; i++) {
                final FieldContent fieldContent = ((FieldContent) subviews[i].getContent());
                if (fieldContent.getField() == field) {
                    continue outer2;
                }
View Full Code Here

TOP

Related Classes of org.apache.isis.core.metamodel.spec.feature.ObjectAssociation

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.