Examples of ObjectAssociation


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

    public String getName() {
        return "remove-element";
    }

    public static void write(final Request request, final ObjectAdapter adapter, final String fieldName, final ObjectAdapter element, final String resultOverride, final String view, final String error, final String title, final String cssClass) {
        final ObjectAssociation field = adapter.getSpecification().getAssociation(fieldName);
        if (field == null) {
            throw new ScimpiException("No field " + fieldName + " in " + adapter.getSpecification().getFullIdentifier());
        }
        if (!field.isOneToManyAssociation()) {
            throw new ScimpiException("Field " + fieldName + " not a collection, in " + adapter.getSpecification().getFullIdentifier());
        }
        if (field.isVisible(IsisContext.getAuthenticationSession(), adapter, where).isVetoed()) {
            throw new ForbiddenException(field, ForbiddenException.VISIBLE);
        }
        IsisContext.getPersistenceSession().resolveField(adapter, field);

        Consent usable = field.isUsable(IsisContext.getAuthenticationSession(), adapter, where);
        if (usable.isAllowed()) {
            usable = ((OneToManyAssociation) field).isValidToRemove(adapter, element);
        }

        if (usable.isVetoed()) {
View Full Code Here

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

            public int compare(final ObjectAssociation o1, final ObjectAssociation o2) {
                return o1.getName().compareTo(o2.getName());
            }
        });
        for (int i = 0; i < fields.size(); i++) {
            final ObjectAssociation field = fields.get(i);
            final ObjectSpecification specification = field.getSpecification();
            if (!specification.isValue()) {
                final boolean contains = visited.contains(specification);
                final String aggregated = specification.isParented() ? "++" : "";
                view.appendln(aggregated + field.getName() + "  (<a href=\"./debug.shtml?type=specification-graph&value=" + specification.getFullIdentifier() + "\">" + specification.getFullIdentifier() + "</a>" + (contains ? "..." : "") + ")");
                if (!contains) {
                    visited.add(specification);
                    view.indent();
                    specificationGraph(specification, view, visited);
                    view.unindent();
View Full Code Here

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

        specificationMembers(view, "Debug Actions", spec.getObjectActions(ActionType.DEBUG, Contributed.INCLUDED, Filters.<ObjectAction>any()));
        view.endSection();

        view.startSection("Fields");
        for (int i = 0; i < fields.size(); i++) {
            final ObjectAssociation field = fields.get(i);
            view.appendTitle("<span id=\"" + field.getId() + "\"><em>Field:</em> " + field.getId() + "</span>");
            view.appendln("ID", field.getIdentifier());
            view.appendln("Short ID", field.getId());
            view.appendln("Name", field.getName());
            view.appendln("Specification", specificationLink(field.getSpecification()));

            view.appendln("Type", field.isOneToManyAssociation() ? "Collection" : field.isOneToOneAssociation() ? "Object" : "Unknown");
            view.appendln("Flags", (field.isAlwaysHidden() ? "" : "Visible ") + (field.isNotPersisted() ? "Not-Persisted " : " ") + (field.isMandatory() ? "Mandatory " : ""));

            speficationFacets(view, field);
        }
        view.endSection();
View Full Code Here

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

        }
        String titleString;
        if (fieldName == null) {
            titleString = object.titleString();
        } else {
            final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
            if (field.isVisible(IsisContext.getAuthenticationSession(), object, Where.ANYWHERE).isVetoed()) {
                throw new ForbiddenException(field, ForbiddenException.VISIBLE);
            }
            final ObjectAdapter fieldReference = field.get(object);
            if (fieldReference != null) {
                titleString = fieldReference.titleString();
            } else {
                titleString = "";
            }
View Full Code Here

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

            request.appendHtml("</div>");
            HelpLink.append(request, object.getSpecification().getDescription(), object.getSpecification().getHelp());
        }
        int row = 1;
        for (int i = 0; i < fields.size(); i++) {
            final ObjectAssociation field = fields.get(i);
            if (ignoreField(field)) {
                continue;
            }
            if (field.isVisible(IsisContext.getAuthenticationSession(), object, Where.OBJECT_FORMS).isVetoed()) {
                continue;
            }

            final String description = field.getDescription().equals("") ? "" : "title=\"" + field.getDescription() + "\"";
            String cls;
            if (row++ % 2 == 1) {
                cls = " class=\"field " + (oddRowClass == null ? ODD_ROW_CLASS : oddRowClass) + "\"";
            } else {
                cls = " class=\"field " + (evenRowClass == null ? EVEN_ROW_CLASS : evenRowClass) + "\"";
            }
            request.appendHtml("<div " + cls + description + "><span class=\"label\">");
            request.appendAsHtmlEncoded(field.getName());
            request.appendHtml(labelDelimiter + "</span>");
            final LinkedObject linkedObject = linkFields[i];
            addField(request, object, field, linkedObject, showIcons);
            HelpLink.append(request, field.getDescription(), field.getHelp());
            request.appendHtml("</div>");
        }
        request.appendHtml("</div>");
    }
View Full Code Here

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

        final String id = request.getOptionalProperty(OBJECT);
        final String fieldName = request.getOptionalProperty(FIELD);
        request.appendHtml("<pre class=\"debug\">");
        try {
            ObjectAdapter object = request.getContext().getMappedObjectOrResult(id);
            ObjectAssociation field = null;
            if (fieldName != null) {
                field = object.getSpecification().getAssociation(fieldName);
                if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
                    throw new ForbiddenException(field, ForbiddenException.VISIBLE);
                }
                object = field.get(object);
            }
            request.processUtilCloseTag();

            final ObjectSpecification specification = field == null ? object.getSpecification() : field.getSpecification();

            request.appendHtml(specification.getSingularName() + " (" + specification.getFullIdentifier() + ") \n");
            final List<ObjectAssociation> fields = specification.getAssociations(Contributed.EXCLUDED);
            for (final ObjectAssociation fld : fields) {
                if (!fld.isAlwaysHidden()) {
View Full Code Here

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

                parameters[1] = facet.parseTextEntry(null, password, localization);
                final ObjectAdapter result = loginAction.execute(object, parameters);
                isValid = result != null;
                if (isValid) {
                    ObjectSpecification specification = result.getSpecification();
                    ObjectAssociation association = specification.getAssociation(roleFieldName);
                    if (association == null) {
                        throw new ScimpiException("Expected a role name field called: " + roleFieldName);
                    }
                    ObjectAdapter role = association.get(result);
                    List<String> roles = new ArrayList<String>();
                    if (role != null) {
                        String[] split = role.titleString().split("\\|");
                        for (String r : split) {
                            roles.add(r);
View Full Code Here

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

        final String field = request.getOptionalProperty(FIELD);
        if (field != null) {
            final String id = request.getOptionalProperty(OBJECT);
            final ObjectAdapter object = context.getMappedObjectOrResult(id);
            final ObjectAssociation objectField = object.getSpecification().getAssociation(field);
            if (!objectField.isOneToManyAssociation()) {
                throw new ScimpiException("Field " + objectField.getId() + " is not a collection");
            }
            IsisContext.getPersistenceSession().resolveField(object, objectField);
            collection = objectField.get(object);
        } else {
            final String id = request.getOptionalProperty(COLLECTION);
            collection = context.getMappedObjectOrResult(id);
        }
View Full Code Here

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

    public void process(final Request request) {
        final String className = request.getOptionalProperty(CLASS);
        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);
        }
        final boolean isIconShowing = request.isRequested(SHOW_ICON, showIconByDefault());
        final int truncateTo = Integer.valueOf(request.getOptionalProperty(TRUNCATE, "0")).intValue();
View Full Code Here

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

        final ObjectSpecification specification = object.getSpecification();
        final FormFieldBlock containedBlock = new FormFieldBlock() {
            @Override
            public boolean isVisible(final String name) {
                final ObjectAssociation fld = specification.getAssociation(name);
                final boolean isVisible = fld.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed();
                final boolean isUseable = fld.isUsable(IsisContext.getAuthenticationSession(), object, where).isAllowed();
                return isVisible && isUseable;
            }

            @Override
            public ObjectAdapter getCurrent(final String name) {
                ObjectAdapter value = null;
                if (entryState != null) {
                    final FieldEditState field2 = entryState.getField(name);
                    value = field2.getValue();
                }
                if (value == null) {
                    final ObjectAssociation fld = specification.getAssociation(name);
                    value = fld.get(object);
                }
                return value;
            }

            @Override
            public boolean isNullable(final String name) {
                final ObjectAssociation fld = specification.getAssociation(name);
                return !fld.isMandatory();
            }
        };

        request.setBlockContent(containedBlock);
        request.processUtilCloseTag();

        final AuthenticationSession session = IsisContext.getAuthenticationSession();
        List<ObjectAssociation> viewFields = specification.getAssociations(Contributed.EXCLUDED, ObjectAssociation.Filters.dynamicallyVisible(session, object, where));
        viewFields = containedBlock.includedFields(viewFields);
        final InputField[] formFields = createFields(viewFields);

        initializeFields(context, object, formFields, entryState, !hideNonEditableFields);
        setDefaults(context, object, formFields, entryState, showIcon);

        copyFieldContent(context, object, formFields, showIcon);
        overrideWithHtml(context, containedBlock, formFields);
        String errors = null;
        if (entryState != null && entryState.isForForm(formId)) {
            copyEntryState(context, object, formFields, entryState);
            errors = entryState.getError();
        }

        final String errorView = context.fullFilePath(forwardErrorTo == null ? context.getResourceFile() : forwardErrorTo);
        final List<HiddenInputField> hiddenFields = new ArrayList<HiddenInputField>();
        hiddenFields.add(new HiddenInputField("_" + OBJECT, actualObjectId));
        hiddenFields.add(new HiddenInputField("_" + VERSION, version));
        hiddenFields.add(new HiddenInputField("_" + FORM_ID, formId));
        hiddenFields.add(completionMessage == null ? null : new HiddenInputField("_" + MESSAGE, completionMessage));
        hiddenFields.add(forwardEditedTo == null ? null : new HiddenInputField("_" + VIEW, context.fullFilePath(forwardEditedTo)));
        hiddenFields.add(new HiddenInputField("_" + ERROR, errorView));
        hiddenFields.add(variable == null ? null : new HiddenInputField("_" + RESULT_NAME, variable));
        hiddenFields.add(resultOverride == null ? null : new HiddenInputField("_" + RESULT_OVERRIDE, resultOverride));
        hiddenFields.add(scope == null ? null : new HiddenInputField("_" + SCOPE, scope));

        if (!object.isTransient()) {
            // ensure all booleans are included so the pass back TRUE if set.
            final List<ObjectAssociation> fields2 = object.getSpecification().getAssociations(Contributed.EXCLUDED);
            for (int i = 0; i < fields2.size(); i++) {
                final ObjectAssociation field = fields2.get(i);
                if (!viewFields.contains(field) && field.getSpecification().containsFacet(BooleanValueFacet.class)) {
                    final String fieldId = field.getId();
                    final String value = getValue(context, field.get(object));
                    hiddenFields.add(new HiddenInputField(fieldId, value));
                }
            }
        }
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.