use of org.springframework.data.mongodb.core.aggregation.ExposedFields.ExposedField in project spring-data-mongodb by spring-projects.
the class ProjectionOperation method getFields.
/*
* (non-Javadoc)
* @see org.springframework.data.mongodb.core.aggregation.FieldsExposingAggregationOperation#getFields()
*/
@Override
public ExposedFields getFields() {
ExposedFields fields = null;
for (Projection projection : projections) {
ExposedField field = projection.getExposedField();
fields = fields == null ? ExposedFields.from(field) : fields.and(field);
}
return fields != null ? fields : ExposedFields.empty();
}
use of org.springframework.data.mongodb.core.aggregation.ExposedFields.ExposedField in project spring-data-mongodb by spring-projects.
the class ExposedFields method createFields.
/**
* Creates a new {@link ExposedFields} instance for the given fields in either synthetic or non-synthetic way.
*
* @param fields must not be {@literal null}.
* @param synthetic
* @return
*/
private static ExposedFields createFields(Fields fields, boolean synthetic) {
Assert.notNull(fields, "Fields must not be null!");
List<ExposedField> result = new ArrayList<ExposedField>();
for (Field field : fields) {
result.add(new ExposedField(field, synthetic));
}
return from(result);
}
use of org.springframework.data.mongodb.core.aggregation.ExposedFields.ExposedField in project spring-data-mongodb by spring-projects.
the class TypeBasedAggregationOperationContext method getReferenceFor.
private FieldReference getReferenceFor(Field field) {
PersistentPropertyPath<MongoPersistentProperty> propertyPath = mappingContext.getPersistentPropertyPath(field.getTarget(), type);
Field mappedField = field(field.getName(), propertyPath.toDotPath(MongoPersistentProperty.PropertyToFieldNameConverter.INSTANCE));
return new DirectFieldReference(new ExposedField(mappedField, true));
}
use of org.springframework.data.mongodb.core.aggregation.ExposedFields.ExposedField in project spring-data-mongodb by spring-projects.
the class TypeBasedAggregationOperationContextUnitTests method aliasesIdFieldCorrectly.
// DATAMONGO-806
@Test
public void aliasesIdFieldCorrectly() {
AggregationOperationContext context = getContext(Foo.class);
assertThat(context.getReference("id"), is(new DirectFieldReference(new ExposedField(field("id", "_id"), true))));
}
Aggregations