Package org.mongodb.morphia.mapping

Examples of org.mongodb.morphia.mapping.MappedField


        final DatastoreImpl dsi = (DatastoreImpl) getDs();
        for (final MappedClass mc : dsi.getMapper().getMappedClasses()) {
            final IgnoreFields ignores = (IgnoreFields) mc.getAnnotation(IgnoreFields.class);
            if (ignores != null) {
                for (final String field : ignores.value().split(",")) {
                    final MappedField mf = mc.getMappedFieldByJavaField(field);
                    mc.getPersistenceFields().remove(mf);
                }
            }
        }
    }
View Full Code Here


                }
            }
            //copy the fields.
            for (final MappedField mf : sourceMC.getPersistenceFields()) {
                final Map<Class<? extends Annotation>, Annotation> annMap = mf.getAnnotations();
                final MappedField destMF = destMC.getMappedFieldByJavaField(mf.getJavaFieldName());
                if (destMF != null && annMap != null && !annMap.isEmpty()) {
                    for (final Entry<Class<? extends Annotation>, Annotation> e : annMap.entrySet()) {
                        destMF.addAnnotation(e.getKey(), e.getValue());
                    }
                }
            }

        }
View Full Code Here

    @Test
    public void shouldAllowGeoWithinOperatorWithAllAppropriateTrimmings() {
        // given
        List<ValidationFailure> validationFailures = new ArrayList<ValidationFailure>();
        MappedClass mappedClass = new MappedClass(GeoEntity.class, new Mapper());
        MappedField mappedField = mappedClass.getMappedField("array");

        // when
        assertThat(GeoWithinOperationValidator.getInstance().apply(mappedField, GEO_WITHIN, new BasicDBObject("$box", 1),
                                                                   validationFailures), is(true));
    }
View Full Code Here

    @Test
    public void shouldAllowGeoWithinOperatorForGeoEntityWithListOfIntegers() {
        // given
        List<ValidationFailure> validationFailures = new ArrayList<ValidationFailure>();
        MappedClass mappedClass = new MappedClass(GeoEntity.class, new Mapper());
        MappedField mappedField = mappedClass.getMappedField("list");
        assertThat(GeoWithinOperationValidator.getInstance().apply(mappedField,
                                                                   GEO_WITHIN,
                                                                   new BasicDBObject("$box", 1),
                                                                   validationFailures),
                   is(true)
View Full Code Here

    @Test
    public void shouldRejectGeoWithinWhenValueDoesNotContainKeyword() {
        // given
        List<ValidationFailure> validationFailures = new ArrayList<ValidationFailure>();
        MappedClass mappedClass = new MappedClass(GeoEntity.class, new Mapper());
        MappedField mappedField = mappedClass.getMappedField("array");

        // when
        boolean validationApplied = GeoWithinOperationValidator.getInstance().apply(mappedField,
                                                                                    GEO_WITHIN,
                                                                                    new BasicDBObject("notValidKey", 1),
View Full Code Here

    @Test
    public void shouldRejectGeoWithinWhenValueIsNotADBObject() {
        // given
        List<ValidationFailure> validationFailures = new ArrayList<ValidationFailure>();
        MappedClass mappedClass = new MappedClass(GeoEntity.class, new Mapper());
        MappedField mappedField = mappedClass.getMappedField("array");

        // when
        boolean validationApplied = GeoWithinOperationValidator.getInstance().apply(mappedField,
                                                                                    GEO_WITHIN,
                                                                                    "NotAGeoQuery",
View Full Code Here

    @Test
    public void shouldRejectGeoWithinOperatorWhenMappedFieldIsArrayThatDoesNotContainNumbers() {
        // given
        List<ValidationFailure> validationFailures = new ArrayList<ValidationFailure>();
        MappedClass mappedClass = new MappedClass(InvalidGeoEntity.class, new Mapper());
        MappedField mappedField = mappedClass.getMappedField("arrayOfStrings");

        // when
        boolean validationApplied = GeoWithinOperationValidator.getInstance().apply(mappedField,
                                                                                    GEO_WITHIN,
                                                                                    new BasicDBObject("$box", 1),
View Full Code Here

    @Test
    public void shouldRejectGeoWithinOperatorWhenMappedFieldIsListThatDoesNotContainNumbers() {
        // given
        List<ValidationFailure> validationFailures = new ArrayList<ValidationFailure>();
        MappedClass mappedClass = new MappedClass(InvalidGeoEntity.class, new Mapper());
        MappedField mappedField = mappedClass.getMappedField("listOfStrings");

        // when
        boolean validationApplied = GeoWithinOperationValidator.getInstance().apply(mappedField,
                                                                                    GEO_WITHIN,
                                                                                    new BasicDBObject("$box", 1),
View Full Code Here

public class SizeOperationValidatorTest {
    @Test
    public void shouldNotApplyValidationToOperatorThatIsNotSize() {
        // given
        MappedClass mappedClass = new MappedClass(EntityWithListsAndArrays.class, new Mapper());
        MappedField mappedField = mappedClass.getMappedField("list");
        List<ValidationFailure> validationFailures = new ArrayList<ValidationFailure>();

        // when
        boolean validationApplied = SizeOperationValidator.getInstance().apply(mappedField, EQUAL, 1, validationFailures);
View Full Code Here

    @Test
    public void shouldAllowSizeOperatorForListTypesAndIntValues() {
        // given
        MappedClass mappedClass = new MappedClass(EntityWithListsAndArrays.class, new Mapper());
        MappedField mappedField = mappedClass.getMappedField("listOfIntegers");
        List<ValidationFailure> validationFailures = new ArrayList<ValidationFailure>();

        // when
        boolean validationApplied = SizeOperationValidator.getInstance().apply(mappedField, SIZE, 3, validationFailures);
View Full Code Here

TOP

Related Classes of org.mongodb.morphia.mapping.MappedField

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.