Search in sources :

Example 16 with ClassDescriptor

use of org.apache.cayenne.reflect.ClassDescriptor in project cayenne by apache.

the class CustomColumnSetExtractor method extractFullObject.

private void extractFullObject(String prefix, Property<?> property) {
    prefix = calculatePrefix(prefix, property);
    ensureJoin(prefix);
    ObjEntity entity = context.getResolver().getObjEntity(property.getType());
    ColumnExtractor extractor;
    if (context.getMetadata().getPageSize() > 0) {
        extractor = new IdColumnExtractor(context, entity);
    } else {
        ClassDescriptor descriptor = context.getResolver().getClassDescriptor(entity.getName());
        extractor = new DescriptorColumnExtractor(context, descriptor);
    }
    int index = context.getResultNodeList().size();
    // extract required columns of entity
    extractor.extract(prefix);
    // Maybe we should change resolver, as it seems cleaner to have path from root as prefix in data row key.
    for (int i = index; i < context.getResultNodeList().size(); i++) {
        context.getResultNodeList().get(i).setDataRowKey(null);
    }
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) ClassDescriptor(org.apache.cayenne.reflect.ClassDescriptor)

Example 17 with ClassDescriptor

use of org.apache.cayenne.reflect.ClassDescriptor in project cayenne by apache.

the class DataObjectDescriptorFactory method createToManySetProperty.

@Override
protected void createToManySetProperty(PersistentDescriptor descriptor, ObjRelationship relationship) {
    ClassDescriptor targetDescriptor = descriptorMap.getDescriptor(relationship.getTargetEntityName());
    descriptor.addDeclaredProperty(new DataObjectToManyProperty(relationship, targetDescriptor, faultFactory.getSetFault()));
}
Also used : ClassDescriptor(org.apache.cayenne.reflect.ClassDescriptor)

Example 18 with ClassDescriptor

use of org.apache.cayenne.reflect.ClassDescriptor in project cayenne by apache.

the class DataObjectDescriptorFactory method createToManyListProperty.

@Override
protected void createToManyListProperty(PersistentDescriptor descriptor, ObjRelationship relationship) {
    ClassDescriptor targetDescriptor = descriptorMap.getDescriptor(relationship.getTargetEntityName());
    descriptor.addDeclaredProperty(new DataObjectToManyProperty(relationship, targetDescriptor, faultFactory.getListFault()));
}
Also used : ClassDescriptor(org.apache.cayenne.reflect.ClassDescriptor)

Example 19 with ClassDescriptor

use of org.apache.cayenne.reflect.ClassDescriptor in project cayenne by apache.

the class ValueHolderDescriptorFactory method createToOneProperty.

@Override
protected void createToOneProperty(PersistentDescriptor descriptor, ObjRelationship relationship) {
    ClassDescriptor targetDescriptor = descriptorMap.getDescriptor(relationship.getTargetEntityName());
    String reverseName = relationship.getReverseRelationshipName();
    Accessor accessor = createAccessor(descriptor, relationship.getName(), ValueHolder.class);
    PropertyDescriptor property = new ValueHolderProperty(descriptor, targetDescriptor, accessor, reverseName);
    descriptor.addDeclaredProperty(property);
}
Also used : ClassDescriptor(org.apache.cayenne.reflect.ClassDescriptor) PropertyDescriptor(org.apache.cayenne.reflect.PropertyDescriptor) Accessor(org.apache.cayenne.reflect.Accessor)

Example 20 with ClassDescriptor

use of org.apache.cayenne.reflect.ClassDescriptor in project cayenne by apache.

the class ValueHolderDescriptorFactory method createToManySetProperty.

@Override
protected void createToManySetProperty(PersistentDescriptor descriptor, ObjRelationship relationship) {
    ClassDescriptor targetDescriptor = descriptorMap.getDescriptor(relationship.getTargetEntityName());
    String reverseName = relationship.getReverseRelationshipName();
    Accessor accessor = createAccessor(descriptor, relationship.getName(), Set.class);
    descriptor.addDeclaredProperty(new ValueHolderSetProperty(descriptor, targetDescriptor, accessor, reverseName));
}
Also used : ClassDescriptor(org.apache.cayenne.reflect.ClassDescriptor) Accessor(org.apache.cayenne.reflect.Accessor)

Aggregations

ClassDescriptor (org.apache.cayenne.reflect.ClassDescriptor)90 AttributeProperty (org.apache.cayenne.reflect.AttributeProperty)25 PropertyVisitor (org.apache.cayenne.reflect.PropertyVisitor)23 ToManyProperty (org.apache.cayenne.reflect.ToManyProperty)23 ToOneProperty (org.apache.cayenne.reflect.ToOneProperty)23 ObjEntity (org.apache.cayenne.map.ObjEntity)22 ArcProperty (org.apache.cayenne.reflect.ArcProperty)21 Persistent (org.apache.cayenne.Persistent)20 CayenneRuntimeException (org.apache.cayenne.CayenneRuntimeException)16 PropertyDescriptor (org.apache.cayenne.reflect.PropertyDescriptor)15 DbRelationship (org.apache.cayenne.map.DbRelationship)14 ObjRelationship (org.apache.cayenne.map.ObjRelationship)13 DataRow (org.apache.cayenne.DataRow)12 ObjectId (org.apache.cayenne.ObjectId)12 Test (org.junit.Test)12 DbAttribute (org.apache.cayenne.map.DbAttribute)10 DataObject (org.apache.cayenne.DataObject)9 EJBQLException (org.apache.cayenne.ejbql.EJBQLException)9 DbJoin (org.apache.cayenne.map.DbJoin)9 ArrayList (java.util.ArrayList)8