Examples of Morphia


Examples of com.github.jmkgreen.morphia.Morphia

*
*/
public class EntityScannerTest extends TestCase {
  @Test
  public void testScanning() throws Exception {
    final Morphia m = new Morphia();
    assertFalse(m.isMapped(E.class));
    new EntityScanner(m, Predicates.equalTo(E.class.getName() + ".class"));
    assertTrue(m.isMapped(E.class));
    assertFalse(m.isMapped(F.class));
    new EntityScanner(m, new Predicate<String>() {
     
      public boolean apply(final String input) {
        return input.startsWith(EntityScannerTest.class.getPackage().getName());
      }
    });
    assertTrue(m.isMapped(F.class));
   
  }
View Full Code Here

Examples of com.github.jmkgreen.morphia.Morphia

    } catch (final Exception e) {
      throw new RuntimeException(e);
    }
   
    this.mongo.dropDatabase("morphia_test");
    morphia = new Morphia();
    this.db = this.mongo.getDB("morphia_test");
    this.ds = this.morphia.createDatastore(this.mongo, this.db.getName())
  }
View Full Code Here

Examples of com.github.jmkgreen.morphia.Morphia

    private final Datastore db;
    public static final String DB_NAME = "cal_dev";
    public MongoConnectionManager(String host, int port) {
      try {
        Mongo m = new MongoClient(host, port);
        db = new Morphia().map(BookingDetail.class).createDatastore(m, DB_NAME);
        db.ensureIndexes();
      } catch (Exception e) {
        throw new RuntimeException("Error initializing mongo db", e);
      }
    }
View Full Code Here

Examples of com.github.jmkgreen.morphia.Morphia

        if (ds != null) {
            return;
        }
        try {
            final MongoClient mongoClient = new MongoClient(ConfigurationHelper.prop.getProperty("mongo.host") );
            final Morphia morphia = new Morphia();
            morphia.map(Meteolog.class).map(News.class).map(Cache.class).map(MapReduceMinMax.class).map(MapReduceHistoryMinMax.class);
            ds = morphia.createDatastore(mongoClient, ConfigurationHelper.prop.getProperty("mongo.dbname"));
            ds.ensureCaps();
            ds.ensureIndexes();
        } catch (Exception e) {
            throw new RuntimeException("Error initializing mongo db", e);
        }
View Full Code Here

Examples of com.github.jmkgreen.morphia.Morphia

    expect(env.getProperty(APP_NAMESPACE, String[].class)).andReturn(
        new String[]{getClass().getPackage().getName() });

    replay(env);

    Morphia morphia = new MorphiaModule().morphia(env);
    assertNotNull(morphia);

    verify(env);
  }
View Full Code Here

Examples of com.github.jmkgreen.morphia.Morphia

    Mongo mongo = createMock(Mongo.class);

    Datastore datastore = createMock(Datastore.class);

    Morphia morphia = createMock(Morphia.class);
    expect(morphia.createDatastore(mongo, "mydb")).andReturn(datastore);

    replay(morphia, mongo, uri, datastore);

    Datastore result =
        new MorphiaModule().morphiaDatastore(morphia, mongo, uri);
View Full Code Here

Examples of com.github.jmkgreen.morphia.Morphia

   */
  @Bean
  public Morphia morphia(final Environment env) {
    notNull(env, "The env is required.");
    String[] namespace = env.getProperty(APP_NAMESPACE, String[].class);
    Morphia morphia = new Morphia();
    for (String ns : namespace) {
      logger.debug("Adding pacakge: {}", ns);
      morphia.mapPackage(ns);
    }

    if (validationFactory != null) {
      morphia.getMapper().addInterceptor(
          new Jsr303Interceptor(validationFactory));
    }
    return morphia;
  }
View Full Code Here

Examples of com.google.code.morphia.Morphia

    public void setPackageName(String packageName) {
        this.packageName = packageName;
    }

    public Morphia createInstance(){
        Morphia morphia = new Morphia();
        MorphiaValidation morphiaValidation = new MorphiaValidation();
        morphiaValidation.applyTo(morphia);
        return morphia.mapPackage(packageName);
    }
View Full Code Here

Examples of com.google.code.morphia.Morphia

    @BeforeClass
    public void initDB() throws Exception {
        connection = new Mongo("127.0.0.1");

        morphia = new Morphia().map(MongoDBChangeSet.class).map(MongoDBChangeSetEntry.class).map(MongoDBFile.class);

        ds = morphia.createDatastore(connection, "rhqtest");
    }
View Full Code Here

Examples of com.google.code.morphia.Morphia

    @BeforeClass
    public void initDB() throws Exception {
        connection = new Mongo("127.0.0.1");

        morphia = new Morphia()
            .map(MongoDBChangeSet.class)
            .map(MongoDBChangeSetEntry.class)
            .map(MongoDBFile.class);

        ds = morphia.createDatastore(connection, "rhqtest");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.