Java源码示例:org.apache.cayenne.exp.Property

示例1
/**
 * @param attributesOrRelationships an array of properties to exclude.
 * @return a new instance of Constraints.
 */
public ConstraintsBuilder<T> excludeProperties(Property<?>... attributesOrRelationships) {

    String[] names = new String[attributesOrRelationships.length];
    for (int i = 0; i < attributesOrRelationships.length; i++) {
        names[i] = attributesOrRelationships[i].getName();
    }

    return excludeProperties(names);
}
 
示例2
public <T> SelectQuery<T> createQueryWithParentQualifier(NestedResourceEntity<T> entity) {

        SelectQuery<T> query = createQuery(entity);

        ObjRelationship objRelationship = objRelationshipForIncomingRelationship(entity);
        String reversePath = objRelationship.getReverseDbRelationshipPath();

        List<Property<?>> properties = new ArrayList<>();
        properties.add(Property.createSelf(entity.getType()));
        AgEntity<?> parentEntity = entity.getParent().getAgEntity();

        for (AgAttribute attribute : entity.getParent().getAgEntity().getIds()) {

            DbAttribute dbAttribute = dbAttributeForAgAttribute(parentEntity, attribute);
            Expression propertyExp = ExpressionFactory.dbPathExp(reversePath
                    + "."
                    + dbAttribute.getName());
            properties.add(Property.create(propertyExp, (Class) attribute.getType()));
        }

        query.setColumns(properties);

        // Translate expression from parent.
        // Find the closest parent in the chain that has a query of its own, and use that as a base.
        Expression parentQualifier = resolveQualifier(entity, null);
        if (parentQualifier != null) {
            query.andQualifier(parentQualifier);
        }

        return query;
    }
 
示例3
public <T, P> SelectQuery<T> createQueryWithParentIdsQualifier(NestedResourceEntity<T> entity, Iterator<P> parentData) {

        SelectQuery<T> query = createQuery(entity);

        ObjRelationship objRelationship = objRelationshipForIncomingRelationship(entity);
        String outgoingPath = objRelationship.getReverseDbRelationshipPath();

        List<Property<?>> properties = new ArrayList<>();
        properties.add(Property.createSelf(entity.getType()));

        AgEntity<?> parentEntity = entity.getParent().getAgEntity();
        for (AgAttribute attribute : parentEntity.getIds()) {

            DbAttribute dbAttribute = dbAttributeForAgAttribute(parentEntity, attribute);
            Expression propertyExp = ExpressionFactory.dbPathExp(outgoingPath
                    + "."
                    + dbAttribute.getName());
            properties.add(Property.create(propertyExp, (Class) attribute.getType()));
        }

        query.setColumns(properties);

        // build id-based qualifier
        List<Expression> qualifiers = new ArrayList<>();

        // TODO: this only works for single column ids
        parentData.forEachRemaining(p -> qualifiers.add(ExpressionFactory.matchDbExp(outgoingPath, p)));

        // TODO: There is some functionality in Cayenne that allows to break long OR qualifiers in a series of queries.
        //  How do we use it here?
        query.andQualifier(ExpressionFactory.joinExp(Expression.OR, qualifiers));

        return query;
    }
 
示例4
protected void buildChildrenQuery(UpdateContext context, ResourceEntity<?> entity, Map<String, NestedResourceEntity<?>> children) {
    if (!children.isEmpty()) {
        for (Map.Entry<String, NestedResourceEntity<?>> e : children.entrySet()) {
            NestedResourceEntity child = e.getValue();

            if (entityResolver.getObjEntity(child.getType()) == null) {
                continue;
            }

            List<Property> properties = new ArrayList<>();
            properties.add(Property.createSelf(child.getType()));

            ObjRelationship objRelationship = objRelationshipForIncomingRelationship(child);

            for (AgAttribute attribute : entity.getAgEntity().getIds()) {
                properties.add(Property.create(ExpressionFactory.dbPathExp(
                        objRelationship.getReverseDbRelationshipPath() + "." + attribute.getName()),
                        (Class) attribute.getType()));
            }
            // transfer expression from parent
            if (entity.getSelect().getQualifier() != null) {
                child.andQualifier(translateExpressionToSource(objRelationship, entity.getSelect().getQualifier()));
            }

            SelectQuery childQuery = buildQuery(context, child);
            childQuery.setColumns(properties);
        }
    }
}
 
示例5
/**
 * @since 1.1
 */
@Override
public DefaultCreateOrUpdateBuilder<T> matchBy(Property<?>... matchAttributes) {
    this.mapper = null;
    this.mapperBuilder.matchBy(matchAttributes);
    return this;
}
 
示例6
@Test
public void testMatchBy_Additivity() {
	Map<String, Mapper> mappers = builder.matchBy(Property.create("a", Object.class), Property.create("b", Object.class))
			.matchBy("c").createPathMappers();
	assertEquals(3, mappers.size());
	assertTrue(mappers.containsKey("db:a"));
	assertTrue(mappers.containsKey("db:b"));
	assertTrue(mappers.containsKey("db:c"));
}
 
示例7
/**
 * @since 1.2
 */
@Override
public SimpleResponse unrelate(Class<?> type, Object sourceId, Property<?> relationship) {
    return unrelate(type, sourceId, relationship.getName());
}
 
示例8
/**
 * @since 1.2
 */
@Override
public SimpleResponse unrelate(Class<?> type, Object sourceId, Property<?> relationship, Object targetId) {
    return unrelate(type, sourceId, relationship.getName(), targetId);
}
 
示例9
public static ByKeyObjectMapperFactory byKey(Property<?> key) {
	return new ByKeyObjectMapperFactory(key.getName());
}
 
示例10
@Override
public SelectBuilder<T> parent(Class<?> parentType, Object parentId, Property<T> relationshipFromParent) {
    context.setParent(new EntityParent<>(parentType, parentId, relationshipFromParent.getName()));
    return this;
}
 
示例11
@Override
public SelectBuilder<T> parent(Class<?> parentType, Map<String, Object> parentIds,
                               Property<T> relationshipFromParent) {
    context.setParent(new EntityParent<>(parentType, parentIds, relationshipFromParent.getName()));
    return this;
}
 
示例12
@Override
public SelectBuilder<T> toManyParent(Class<?> parentType, Object parentId,
                                     Property<? extends Collection<T>> relationshipFromParent) {
    return parent(parentType, parentId, relationshipFromParent.getName());
}
 
示例13
@Override
public SelectBuilder<T> toManyParent(Class<?> parentType, Map<String, Object> parentIds,
                                     Property<? extends Collection<T>> relationshipFromParent) {
    return parent(parentType, parentIds, relationshipFromParent.getName());
}
 
示例14
@Override
public UpdateBuilder<T> parent(Class<?> parentType, Object parentId, Property<T> relationshipFromParent) {
    context.setParent(new EntityParent<>(parentType, parentId, relationshipFromParent.getName()));
    return this;
}
 
示例15
@Override
public UpdateBuilder<T> parent(Class<?> parentType, Map<String, Object> parentIds,
                               Property<T> relationshipFromParent) {
    context.setParent(new EntityParent<>(parentType, parentIds, relationshipFromParent.getName()));
    return this;
}
 
示例16
@Override
public UpdateBuilder<T> toManyParent(Class<?> parentType, Object parentId,
                                     Property<? extends Collection<T>> relationshipFromParent) {
    return parent(parentType, parentId, relationshipFromParent.getName());
}
 
示例17
@Override
public UpdateBuilder<T> toManyParent(Class<?> parentType, Map<String, Object> parentIds,
                                     Property<? extends Collection<T>> relationshipFromParent) {
    return parent(parentType, parentIds, relationshipFromParent.getName());
}
 
示例18
/**
 * @since 1.20
 */
@Override
public UpdateBuilder<T> mapper(Property<?> property) {
    return mapper(ByKeyObjectMapperFactory.byKey(property));
}
 
示例19
@Override
public DeleteBuilder<T> parent(Class<?> parentType, Object parentId, Property<T> relationshipFromParent) {
	context.setParent(new EntityParent<>(parentType, parentId, relationshipFromParent.getName()));
	return this;
}
 
示例20
@Override
public DeleteBuilder<T> parent(Class<?> parentType, Map<String, Object> parentIds, Property<T> relationshipFromParent) {
	context.setParent(new EntityParent<>(parentType, parentIds, relationshipFromParent.getName()));
	return this;
}
 
示例21
@Override
public DeleteBuilder<T> toManyParent(Class<?> parentType, Object parentId,
		Property<? extends Collection<T>> relationshipFromParent) {
	return parent(parentType, parentId, relationshipFromParent.getName());
}
 
示例22
@Override
public DeleteBuilder<T> toManyParent(Class<?> parentType, Map<String, Object> parentIds, Property<? extends Collection<T>> relationshipFromParent) {
	return parent(parentType, parentIds, relationshipFromParent.getName());
}
 
示例23
DeleteBuilder<T> toManyParent(Class<?> parentType, Object parentId,
Property<? extends Collection<T>> relationshipFromParent);
 
示例24
public <S> ConstraintsBuilder<T> toManyPath(Property<List<S>> path, ConstraintsBuilder<S> subentityBuilder) {
    return path(path.getName(), subentityBuilder);
}
 
示例25
public static <T> Consumer<SelectContext<T>> startsWithFilter(Property<?> property, UriInfo uriInfo) {
    String value = ParameterExtractor.string(uriInfo.getQueryParameters(), QUERY);
    return startsWithFilter(property, value);
}
 
示例26
public static <T> Consumer<SelectContext<T>> startsWithFilter(Property<?> property, String value) {
    return c -> StartsWithFilter
            .getInstance()
            .filter(c, property.getName(), value)
            .ifPresent(exp -> processStartsWith(c, exp));
}
 
示例27
protected <T> void appendAttribute(ResourceEntity<?> entity, Property<T> property, Class<T> type) {
    appendAttribute(entity, property.getName(), type);
}
 
示例28
protected <T> void appendPersistenceAttribute(ResourceEntity<?> entity, Property<T> property, Class<T> javaType) {
    appendPersistenceAttribute(entity, property.getName(), javaType);
}
 
示例29
protected <T> void appendAttribute(ResourceEntity<?> entity, Property<T> property, Class<T> type) {
    appendAttribute(entity, property.getName(), type);
}
 
示例30
protected <T> void appendPersistenceAttribute(ResourceEntity<?> entity, Property<T> property, Class<T> javaType) {
    appendPersistenceAttribute(entity, property.getName(), javaType);
}