Examples of ObjAttribute


Examples of org.apache.cayenne.map.ObjAttribute

    void indexAddedProperty(Property property) {
        if (property instanceof AttributeProperty) {

            AttributeProperty attributeProperty = (AttributeProperty) property;
            ObjAttribute attribute = attributeProperty.getAttribute();
            if (attribute.isPrimaryKey()) {

                if (idProperties == null) {
                    idProperties = new ArrayList<AttributeProperty>(2);
                }
View Full Code Here

Examples of org.apache.cayenne.map.ObjAttribute

        final Set<String> visited = new HashSet<String>();

        PropertyVisitor visitor = new PropertyVisitor() {

            public boolean visitAttribute(AttributeProperty property) {
                ObjAttribute oa = property.getAttribute();
                if (visited.add(oa.getDbAttributePath())) {
                    entityResult.addObjectField(
                            oa.getEntity().getName(),
                            oa.getName(),
                            prefix + index[0]++);
                }
                return true;
            }

            public boolean visitToMany(ToManyProperty property) {
                return true;
            }

            public boolean visitToOne(ToOneProperty property) {
                ObjRelationship rel = property.getRelationship();
                DbRelationship dbRel = rel.getDbRelationships().get(0);

                for (DbJoin join : dbRel.getJoins()) {
                    DbAttribute src = join.getSource();
                    if (src.isForeignKey() && visited.add(src.getName())) {
                        entityResult.addDbField(src.getName(), prefix + index[0]++);
                    }
                }

                return true;
            }
        };

        descriptor.visitAllProperties(visitor);

        // append id columns ... (some may have been appended already via relationships)
        for (String pkName : descriptor.getEntity().getPrimaryKeyNames()) {
            if (visited.add(pkName)) {
                entityResult.addDbField(pkName, prefix + index[0]++);
            }
        }

        // append inheritance discriminator columns...
        Iterator<ObjAttribute> discriminatorColumns = descriptor
                .getDiscriminatorColumns();
        while (discriminatorColumns.hasNext()) {
            ObjAttribute column = discriminatorColumns.next();

            if (visited.add(column.getName())) {
                entityResult.addDbField(column.getDbAttributePath(), prefix + index[0]++);
            }
        }

        return entityResult;
    }
View Full Code Here

Examples of org.apache.cayenne.map.ObjAttribute

        final boolean[] isPartialSnapshot = new boolean[1];

        descriptor.visitProperties(new PropertyVisitor() {

            public boolean visitAttribute(AttributeProperty property) {
                ObjAttribute attr = property.getAttribute();
                String dbAttrPath = attr.getDbAttributePath();

                Object value = snapshot.get(dbAttrPath);
                property.writePropertyDirectly(object, null, value);

                // note that a check "snaphsot.get(..) == null" would be incorrect in this
View Full Code Here

Examples of org.apache.cayenne.map.ObjAttribute

        final DataRow snapshot = new DataRow(10);

        descriptor.visitProperties(new PropertyVisitor() {

            public boolean visitAttribute(AttributeProperty property) {
                ObjAttribute objAttr = property.getAttribute();

                // processing compound attributes correctly
                snapshot.put(objAttr.getDbAttributePath(), property
                        .readPropertyDirectly(object));
                return true;
            }

            public boolean visitToMany(ToManyProperty property) {
View Full Code Here

Examples of org.apache.cayenne.map.ObjAttribute

        this.currentEntity = (ObjEntity) relationship.getTargetEntity();
    }

    protected void processLastPathComponent() {

        ObjAttribute attribute = (ObjAttribute) currentEntity
                .getAttribute(lastPathComponent);

        if (attribute != null) {
            processTerminatingAttribute(attribute);
            return;
View Full Code Here

Examples of org.apache.cayenne.map.ObjAttribute

        ClassDescriptor descriptor = context.getEntityDescriptor(idVar);

        PropertyVisitor visitor = new PropertyVisitor() {

            public boolean visitAttribute(AttributeProperty property) {
                ObjAttribute oa = property.getAttribute();
                Iterator<?> dbPathIterator = oa.getDbPathIterator();

                EJBQLJoinAppender joinAppender = null;
                String marker = null;
                EJBQLTableId lhsId = new EJBQLTableId(idVar);

                while (dbPathIterator.hasNext()) {
                    Object pathPart = dbPathIterator.next();

                    if (pathPart == null) {
                        throw new CayenneRuntimeException(
                                "ObjAttribute has no component: " + oa.getName());
                    }
                    else if (pathPart instanceof DbRelationship) {

                        if (marker == null) {
                            marker = EJBQLJoinAppender.makeJoinTailMarker(idVar);
                            joinAppender = context
                                    .getTranslatorFactory()
                                    .getJoinAppender(context);
                        }

                        DbRelationship dr = (DbRelationship) pathPart;

                        EJBQLTableId rhsId = new EJBQLTableId(lhsId, dr.getName());
                        joinAppender.appendOuterJoin(marker, lhsId, rhsId);
                        lhsId = rhsId;
                    }
                    else if (pathPart instanceof DbAttribute) {
                        appendColumn(idVar, oa, (DbAttribute) pathPart, fields, oa
                                .getType());
                    }
                }
                return true;
            }

            public boolean visitToMany(ToManyProperty property) {
                visitRelationship(property);
                return true;
            }

            public boolean visitToOne(ToOneProperty property) {
                visitRelationship(property);
                return true;
            }

            private void visitRelationship(ArcProperty property) {
                ObjRelationship rel = property.getRelationship();
                DbRelationship dbRel = rel.getDbRelationships().get(0);

                for (DbJoin join : dbRel.getJoins()) {
                    DbAttribute src = join.getSource();
                    appendColumn(idVar, null, src, fields);
                }
            }
        };

        // EJBQL queries are polymorphic by definition - there is no distinction between
        // inheritance/no-inheritance fetch
        descriptor.visitAllProperties(visitor);

        // append id columns ... (some may have been appended already via relationships)
        DbEntity table = descriptor.getEntity().getDbEntity();
        for (DbAttribute pk : table.getPrimaryKeys()) {
            appendColumn(idVar, null, pk, fields);
        }

        // append inheritance discriminator columns...
        Iterator<ObjAttribute> discriminatorColumns = descriptor.getDiscriminatorColumns();
        while (discriminatorColumns.hasNext()) {
           
            ObjAttribute attribute = discriminatorColumns.next();
            appendColumn(idVar, attribute, attribute.getDbAttribute(), fields);
        }

        return false;
    }
View Full Code Here

Examples of org.apache.cayenne.map.ObjAttribute

            }
            else {
                ObjEntity entity = field.getEntityName() != null ? resolver
                        .getObjEntity(field.getEntityName()) : getRootEntity(resolver);

                ObjAttribute attribute = (ObjAttribute) entity.getAttribute(field
                        .getAttributeName());
                dbFields.put(attribute.getDbAttributePath(), field.getColumn());
            }
        }

        return dbFields;
    }
View Full Code Here

Examples of org.apache.cayenne.map.ObjAttribute

     */
    public void addDeclaredProperty(Property property) {
        declaredProperties.put(property.getName(), property);

        if (property instanceof AttributeProperty) {
            ObjAttribute attribute = ((AttributeProperty) property).getAttribute();
            if (attribute.isPrimaryKey()) {

                if (declaredIdProperties == null) {
                    declaredIdProperties = new ArrayList<Property>(2);
                }

View Full Code Here

Examples of org.apache.cayenne.map.ObjAttribute

            }
        }

        // remove ObjAttribute mapped to same column
        for (ObjEntity objEntity : objEntitiesMappedToDbEntity(getEntity())) {
            ObjAttribute objAttribute = objEntity.getAttributeForDbAttribute(getColumn());
            if (objAttribute != null) {
                objEntity.removeAttribute(objAttribute.getName());
            }

        }

        // remove DbAttribute
View Full Code Here

Examples of org.apache.cayenne.map.ObjAttribute

        final boolean[] isPartialSnapshot = new boolean[1];

        descriptor.visitProperties(new PropertyVisitor() {

            public boolean visitAttribute(AttributeProperty property) {
                ObjAttribute attr = property.getAttribute();
                String dbAttrPath = attr.getDbAttributePath();

                Object value = snapshot.get(dbAttrPath);
                property.writePropertyDirectly(object, null, value);

                // note that a check "snaphsot.get(..) == null" would be incorrect in this
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.