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

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


            toPersistObjectSet.remapAsPersistent(object);
            toPersistObjectSet.addPersistedObject(object);
            CallbackUtils.callCallback(object, PersistedCallbackFacet.class);

            for (int i = 0; i < fields.size(); i++) {
                final ObjectAssociation field = fields.get(i);
                if (field.isNotPersisted()) {
                    continue;
                } else if (field instanceof OneToManyAssociation) {
                    final ObjectAdapter collection = field.get(object);
                    if (collection == null) {
                        throw new ObjectPersistenceException("Collection " + field.getName() + " does not exist in " + object.getSpecification().getFullIdentifier());
                    }
                    makePersistent(collection, toPersistObjectSet);
                } else {
                    final ObjectAdapter fieldValue = field.get(object);
                    if (fieldValue == null) {
                        continue;
                    }
                    makePersistent(fieldValue, toPersistObjectSet);
                }
View Full Code Here


            CallbackUtils.callCallback(object, PersistingCallbackFacet.class);
            toPersistObjectSet.remapAsPersistent(object);
            object.changeState(ResolveState.SERIALIZING_RESOLVED);

            for (int i = 0; i < fields.size(); i++) {
                final ObjectAssociation field = fields.get(i);
                if (field.isNotPersisted()) {
                    continue;
                }
                if (field.isOneToManyAssociation()) {
                    final ObjectAdapter collection = field.get(object);
                    if (collection == null) {
                        throw new ObjectPersistenceException("Collection " + field.getName() + " does not exist in " + object.getSpecification().getFullIdentifier());
                    }
                    makePersistent(collection, toPersistObjectSet);
                } else {
                    final ObjectAdapter fieldValue = field.get(object);
                    if (fieldValue == null) {
                        continue;
                    }
                    persist(fieldValue, toPersistObjectSet);
                }
View Full Code Here

            final ObjectAssociation[] fields = fieldOrderCache.getFields(adapter.getSpecification());
            if (fields.length != fieldContent.length) {
                throw new IsisRemoteException("Data received for different number of fields; expected " + fields.length + ", but was " + fieldContent.length);
            }
            for (int i = 0; i < fields.length; i++) {
                final ObjectAssociation field = fields[i];
                final Data fieldData = fieldContent[i];
                if (fieldData == null || field.isNotPersisted()) {
                    LOG.debug("no data for field " + field.getId());
                    continue;
                }

                if (field.isOneToManyAssociation()) {
                    setUpCollectionField(adapter, adapterData, field, (CollectionData) fieldData, knownObjects);
                } else if (field.getSpecification().isEncodeable()) {
                    setUpEncodedField(adapter, (OneToOneAssociation) field, fieldData);
                } else {
                    setUpReferenceField(adapter, (OneToOneAssociation) field, fieldData, knownObjects);
                }
            }
View Full Code Here

        final Vector sorted = new Vector(originalFields.size());
        outer: for (int i = 0; i < originalFields.size(); i++) {
            final String fieldId = originalFields.get(i).getId();

            for (int j = 0; j < sorted.size(); j++) {
                final ObjectAssociation sortedElement = (ObjectAssociation) sorted.elementAt(j);
                final String sortedFieldId = sortedElement.getId();
                if (sortedFieldId.compareTo(fieldId) > 0) {
                    sorted.insertElementAt(originalFields.get(i), j);
                    continue outer;
                }
            }
View Full Code Here

            LOG.debug("request setAssociation " + fieldIdentifier + " on " + targetData + " with " + associateData + " for " + session);
        }

        final ObjectAdapter targetAdapter = getPersistentObjectAdapter(session, targetData);
        final ObjectAdapter associate = getPersistentObjectAdapter(session, associateData);
        final ObjectAssociation association = targetAdapter.getSpecification().getAssociation(fieldIdentifier);

        ensureAssociationModifiableElseThrowException(session, targetAdapter, association);

        if (association instanceof OneToOneAssociation) {
            ((OneToOneAssociation) association).setAssociation(targetAdapter, associate);
View Full Code Here

        }

        final ObjectAdapter targetAdapter = getPersistentObjectAdapter(session, targetData);
        final ObjectAdapter associateAdapter = getPersistentObjectAdapter(session, associateData);
        final ObjectSpecification specification = targetAdapter.getSpecification();
        final ObjectAssociation association = specification.getAssociation(fieldIdentifier);

        if (!association.isVisible(session, targetAdapter).isAllowed() || association.isUsable(session, targetAdapter).isVetoed()) {
            throw new IsisException("can't modify field as not visible or editable");
        }
        ensureAssociationModifiableElseThrowException(session, targetAdapter, association);

        if (association instanceof OneToOneAssociation) {
View Full Code Here

        if (LOG.isDebugEnabled()) {
            LOG.debug("request resolveField " + targetData + "/" + fieldIdentifier + " for " + session);
        }

        final ObjectSpecification spec = getSpecification(targetData.getType());
        final ObjectAssociation field = spec.getAssociation(fieldIdentifier);
        final ObjectAdapter targetAdapter = getPersistenceSession().recreateAdapter(targetData.getOid(), spec);

        getPersistenceSession().resolveField(targetAdapter, field);
        final Data data = encoderDecoder.encodeForResolveField(targetAdapter, fieldIdentifier);
        return new ResolveFieldResponse(data);
View Full Code Here

        collectionMappers = new CollectionMapper[collectionFieldCount];
        collectionMapperFields = new String[collectionFieldCount];
        final IsisConfiguration subset = IsisContext.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

    // get{MemberType}ThatIsVisibleAndUsable
    // ///////////////////////////////////////////////////////////////////

    protected OneToOneAssociation getPropertyThatIsVisibleAndUsable(final String propertyId, final Intent intent) {

        final ObjectAssociation association = objectAdapter.getSpecification().getAssociation(propertyId);
        if (association == null || !association.isOneToOneAssociation()) {
            throwNotFoundException(propertyId, MemberType.PROPERTY);
        }
        final OneToOneAssociation property = (OneToOneAssociation) association;
        return memberThatIsVisibleAndUsable(property, MemberType.PROPERTY, intent);
    }
View Full Code Here

        return memberThatIsVisibleAndUsable(property, MemberType.PROPERTY, intent);
    }

    protected OneToManyAssociation getCollectionThatIsVisibleAndUsable(final String collectionId, final Intent intent) {

        final ObjectAssociation association = objectAdapter.getSpecification().getAssociation(collectionId);
        if (association == null || !association.isOneToManyAssociation()) {
            throwNotFoundException(collectionId, MemberType.COLLECTION);
        }
        final OneToManyAssociation collection = (OneToManyAssociation) association;
        return memberThatIsVisibleAndUsable(collection, MemberType.COLLECTION, intent);
    }
View Full Code Here

TOP

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

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.