Examples of ObjectAssociation


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

        collectionMappers = new CollectionMapper[collectionFieldCount];
        collectionMapperFields = new String[collectionFieldCount];
        final IsisConfiguration subset = getConfiguration().createSubset(parameterBase + ".mapper.");

        for (int i = 0, simpleFieldNo = 0, collectionFieldNo = 0; i < fields.size(); i++) {
            final ObjectAssociation field = fields.get(i);
            if (field.isNotPersisted()) {
                continue;
            } else if (field.isOneToManyAssociation()) {
                oneToManyProperties[collectionFieldNo] = field;

                // TODO: Replace "new ForeignKeyCollectionMapper" with a factory
                // method(?) to allow a different
                // default CollectionMapper

                // TODO: I think the default order should be changed - and I
                // think I (KAM) have dropped support for the
                // original "association-table" implementation. This means the
                // current checks are misleading.
                final String type = subset.getString(field.getId());
                if (type == null || type.equals("association-table")) {
                    // collectionMappers[collectionFieldNo] = new
                    // AutoCollectionMapper(specification,
                    // oneToManyProperties[collectionFieldNo], lookup);
                    // collectionMappers[collectionFieldNo] = new
                    // ForeignKeyCollectionMapper(oneToManyProperties[collectionFieldNo],
                    // parameterBase, lookup,
                    // objectMapperLookup);

                    CollectionMapper collectionMapper = null;

                    // Trying to detect recursion, here.
                    // Let ForeignKeyInChildCollectionMapper find itself when a
                    // field is a collection of the current
                    // field type.
                    if (this instanceof ForeignKeyInChildCollectionMapper) {
                        final ForeignKeyInChildCollectionMapper mc = (ForeignKeyInChildCollectionMapper) this;

                        if (mc.priorField == field) {
                            collectionMapper = mc;
                        }
                    }

                    if (collectionMapper == null) {
                        // TODO: Polymorphism - is it sufficient for the
                        // collectionMapper to handle the subclasses?
                        final ObjectSpecification fieldSpecification = field.getSpecification();
                        if (fieldSpecification.hasSubclasses() || fieldSpecification.isAbstract()) {
                            // PolymorphicForeignKeyInChildCollectionBaseMapper
                            // Or PolymorphicForeignKeyInChildCollectionMapper
                            collectionMapper =
                                new PolymorphicForeignKeyInChildCollectionBaseMapper(
                                    oneToManyProperties[collectionFieldNo], parameterBase, lookup, objectMapperLookup,
                                    this, field);
                        } else {
                            final ForeignKeyInChildCollectionMapper mapper =
                                new ForeignKeyInChildCollectionMapper(oneToManyProperties[collectionFieldNo],
                                    parameterBase, lookup, objectMapperLookup, this, field);
                            mapper.setUpFieldMappers();
                            collectionMapper = mapper;
                        }
                    }

                    collectionMappers[collectionFieldNo] = collectionMapper;
                    collectionMapperFields[collectionFieldNo] = field.getId();

                } else if (type.equals("fk-table")) {
                    final String property = parameterBase + field.getId() + ".element-type";
                    final String elementType = configParameters.getString(property);
                    if (elementType == null) {
                        throw new SqlObjectStoreException("Expected property " + property);
                    }
                    /*
                     * collectionMappers[collectionFieldNo] = new ForeignKeyCollectionMapper(elementType,
                     * oneToManyProperties[collectionFieldNo], parameterBase, lookup, objectMapperLookup);
                     */
                } else {
                    // TODO use other mappers where necessary
                    throw new NotYetImplementedException("for " + type);
                }

                collectionFieldNo++;
            } else if (field.isOneToOneAssociation()) {
                oneToOneProperties[simpleFieldNo] = field;
                simpleFieldNo++;
            } else {
                oneToOneProperties[simpleFieldNo] = field;
                simpleFieldNo++;
View Full Code Here

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

        }
        return cellContents;
    }

    private Date dateFor(final ObjectAdapter element) {
        final ObjectAssociation dateField = findDate(element);
        if (dateField == null) {
            return null;
        }
        final DateValueFacet facet = dateField.getSpecification().getFacet(DateValueFacet.class);
        final ObjectAdapter field = dateField.get(element);
        final Date date = facet.dateValue(field);
        return date;
    }
View Full Code Here

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

                super.firstClick(click);
            } else if (column == -1) {
                ((CollectionContent) getContent()).setOrderByElement();
                invalidateContent();
            } else {
                final ObjectAssociation field = axis.getFieldForColumn(column);
                ((CollectionContent) getContent()).setOrderByField(field);
                invalidateContent();
            }
        } else {
            super.firstClick(click);
View Full Code Here

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

        canvas.drawLine(0, 0, getSize().getWidth() - 1, 0, secondary1);
        canvas.drawLine(0, height - 1, getSize().getWidth() - 1, height - 1, secondary1);
        canvas.drawLine(x, 0, x, getSize().getHeight() - 1, secondary1);
        x++;
        final int columns = axis.getColumnCount();
        final ObjectAssociation fieldSortOrder = ((CollectionContent) getContent()).getFieldSortOrder();
        for (int i = 0; i < columns; i++) {
            if (fieldSortOrder == axis.getFieldForColumn(i)) {
                drawOrderIndicator(canvas, axis, x + axis.getColumnWidth(i) - 10);
            }
View Full Code Here

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

        try {
            // work through all its fields
            final List<ObjectAssociation> fields = adapter.getSpecification().getAssociations(Contributed.EXCLUDED);
            for (int i = 0; i < fields.size(); i++) {
                final ObjectAssociation field = fields.get(i);
                final ObjectAdapter obj = field.get(adapter);
                final String name = field.getId();
                graphIndent(level, s);

                if (field.isVisible(authenticationSession, adapter, where).isVetoed()) {
                    s.append(name + ": (not visible)");
                    s.append("\n");
                } else {
                    if (obj == null) {
                        s.append(name + ": null\n");
View Full Code Here

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

        LOG.debug("update view " + view + " for " + object);
        final View[] subviews = view.getSubviews();
        final ObjectSpecification spec = object.getSpecification();
        for (int i = 0; i < subviews.length; i++) {
            final ObjectAssociation field = fieldFromActualSpec(spec, viewAxis.getFieldForColumn(i));
            final View subview = subviews[i];
            final ObjectAdapter value = field.get(object);

            // 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 visiblityChange = !field.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed() ^ (subview instanceof BlankView);
                final ObjectAdapter adapter = subview.getContent().getAdapter();
                final boolean valueChange = value != null && value.getObject() != null && !value.getObject().equals(adapter.getObject());

                if (visiblityChange || valueChange) {
                    final View fieldView = createFieldView(view, axes, object, field, value);
                    view.replaceView(subview, decorateSubview(axes, fieldView));
                }
                subview.refresh();
            } else if (field.isOneToOneAssociation()) {
                final ObjectAdapter existing = ((ObjectContent) subviews[i].getContent()).getObject();
                final boolean changedValue = value != existing;
                if (changedValue) {
                    View fieldView;
                    fieldView = createFieldView(view, axes, object, field, value);
View Full Code Here

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

        final ObjectSpecification spec = object.getSpecification();
        for (int f = 0; f < len; f++) {
            if (f > 3) {
                continue;
            }
            final ObjectAssociation field = fieldFromActualSpec(spec, viewAxis.getFieldForColumn(f));
            addField(view, axes, object, field);
        }
    }
View Full Code Here

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

        final int len = fields.length;
        for (int i = 0; i < len; i++) {
            if (readOnly[i] || errors[i] != null) {
                continue;
            }
            final ObjectAssociation fld = fields[i];
            if (fld.isOneToOneAssociation()) {
                final OneToOneAssociation oneToOneAssociation = (OneToOneAssociation) fld;
                final ObjectAdapter entryReference = entries[i];
                final ObjectAdapter currentReference = oneToOneAssociation.get(target);
                if (currentReference != entryReference) {
                    final Consent valueValid = ((OneToOneAssociation) fld).isAssociationValid(target, entryReference);
View Full Code Here

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

    }

    private void saveState(final ObjectAdapter targetAdapter, final ObjectAdapter[] entryAdapters) {
        getPersistenceSession().getTransactionManager().startTransaction();
        for (int i = 0; i < fields.length; i++) {
            final ObjectAssociation fld = fields[i];
            final ObjectAdapter entryAdapter = entryAdapters[i];
            final boolean isReadOnly = readOnly[i];

            if (isReadOnly) {
                continue;
            }

            if (fld.isOneToOneAssociation()) {
                final OneToOneAssociation oneToOneAssociation = ((OneToOneAssociation) fld);
                final Object entryPojo = AdapterUtils.unwrap(entryAdapter);
                if (entryPojo == null) {
                    if (oneToOneAssociation.get(targetAdapter) != null) {
                        oneToOneAssociation.clearAssociation(targetAdapter);
View Full Code Here

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

        final List<ObjectAssociation> allFields = adapter.getSpecification().getAssociations(ObjectAssociationFilters.dynamicallyVisible(getAuthenticationSession(), adapter, where));

        fields = new ObjectAssociation[names.length];
        for (int i = 0, j = 0; j < allFields.size(); j++) {
            final ObjectAssociation fld = allFields.get(j);
            fields[i] = fld;
            names[i] = fld.getName();
            descriptions[i] = fld.getDescription();

            final Consent usableByUser = fld.isUsable(getAuthenticationSession(), adapter, where);
            if (usableByUser.isVetoed()) {
                descriptions[i] = usableByUser.getReason();
            }

            fieldSpecifications[i] = fld.getSpecification();
            initialState[i] = fld.get(adapter);
            if (skipField(adapter, fld)) {
                readOnly[i] = true;
            } else {
                readOnly[i] = false;
                optional[i] = !fld.isMandatory();
                if (fieldSpecifications[i].isParseable()) {
                    final MultiLineFacet multilineFacet = fld.getFacet(MultiLineFacet.class);
                    noLines[i] = multilineFacet.numberOfLines();
                    wraps[i] = !multilineFacet.preventWrapping();

                    final MaxLengthFacet maxLengthFacet = fld.getFacet(MaxLengthFacet.class);
                    maxLength[i] = maxLengthFacet.value();

                    final TypicalLengthFacet typicalLengthFacet = fld.getFacet(TypicalLengthFacet.class);
                    typicalLength[i] = typicalLengthFacet.value();
                }
            }
            i++;
        }
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.