Search in sources :

Example 61 with Mapper

use of org.mongodb.morphia.mapping.Mapper in project morphia by mongodb.

the class QueryValidatorTest method shouldNotAllowStringValueWithTypeThatIsNotString.

@Test
public void shouldNotAllowStringValueWithTypeThatIsNotString() {
    // expect
    MappedClass mappedClass = new MappedClass(SimpleEntity.class, new Mapper());
    MappedField mappedField = mappedClass.getMappedField("name");
    assertThat(QueryValidator.isCompatibleForOperator(mappedClass, mappedField, Integer.class, EQUAL, "value", new ArrayList<ValidationFailure>()), is(false));
}
Also used : MappedField(org.mongodb.morphia.mapping.MappedField) Mapper(org.mongodb.morphia.mapping.Mapper) ArrayList(java.util.ArrayList) MappedClass(org.mongodb.morphia.mapping.MappedClass) Test(org.junit.Test)

Example 62 with Mapper

use of org.mongodb.morphia.mapping.Mapper in project webprotege by protegeproject.

the class MorphiaProvider method get.

@Override
public Morphia get() {
    Morphia morphia = new Morphia();
    Mapper mapper = morphia.getMapper();
    mapper.getOptions().setStoreEmpties(true);
    mapper.getOptions().setObjectFactory(new CustomMorphiaObjectFactory());
    Converters converters = mapper.getConverters();
    converters.addConverter(userIdConverter);
    converters.addConverter(entityConverter);
    converters.addConverter(projectIdConverter);
    converters.addConverter(threadIdConverter);
    converters.addConverter(commentIdConverter);
    FormDataValueConverter formDataValueConverter = new FormDataValueConverter(new OWLDataFactoryImpl(), entityConverter);
    converters.addConverter(formDataValueConverter);
    converters.addConverter(new FormDataConverter(formDataValueConverter));
    converters.addConverter(collectionIdConverter);
    converters.addConverter(formIdConverter);
    converters.addConverter(tagIdConverter);
    converters.addConverter(colorConverter);
    converters.addConverter(new CollectionIdConverter());
    converters.addConverter(new CollectionItemConverter());
    morphia.map(EntityDiscussionThread.class);
    morphia.map(UserActivityRecord.class);
    morphia.map(RoleAssignment.class);
    return morphia;
}
Also used : CollectionIdConverter(edu.stanford.bmir.protege.web.server.collection.CollectionIdConverter) Mapper(org.mongodb.morphia.mapping.Mapper) FormDataConverter(edu.stanford.bmir.protege.web.server.form.FormDataConverter) Morphia(org.mongodb.morphia.Morphia) FormDataValueConverter(edu.stanford.bmir.protege.web.server.form.FormDataValueConverter) CollectionItemConverter(edu.stanford.bmir.protege.web.server.collection.CollectionItemConverter) Converters(org.mongodb.morphia.converters.Converters) OWLDataFactoryImpl(uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl)

Aggregations

Mapper (org.mongodb.morphia.mapping.Mapper)62 Test (org.junit.Test)61 MappedClass (org.mongodb.morphia.mapping.MappedClass)53 MappedField (org.mongodb.morphia.mapping.MappedField)46 ArrayList (java.util.ArrayList)41 BasicDBObject (com.mongodb.BasicDBObject)9 DBObject (com.mongodb.DBObject)5 List (java.util.List)5 ObjectId (org.bson.types.ObjectId)5 SimpleEntity (org.mongodb.morphia.entities.SimpleEntity)5 Key (org.mongodb.morphia.Key)4 ParentType (org.mongodb.morphia.entities.ParentType)2 DefaultEntityCache (org.mongodb.morphia.mapping.cache.DefaultEntityCache)2 CollectionIdConverter (edu.stanford.bmir.protege.web.server.collection.CollectionIdConverter)1 CollectionItemConverter (edu.stanford.bmir.protege.web.server.collection.CollectionItemConverter)1 FormDataConverter (edu.stanford.bmir.protege.web.server.form.FormDataConverter)1 FormDataValueConverter (edu.stanford.bmir.protege.web.server.form.FormDataValueConverter)1 BsonDocument (org.bson.BsonDocument)1 BsonString (org.bson.BsonString)1 Document (org.bson.Document)1