Metamodel metaModel = kunderaMetadata.getApplicationMetadata().getMetamodel(pu);
((MetamodelImpl) metaModel).addEntityMetadata(clazz, mAdd);
kunderaMetadata.getApplicationMetadata().getMetamodelMap().put(pu, metaModel);
// kunderaMetadata.getApplicationMetadata().addEntityMetadata(pu,
// clazz, mAdd);
PersistenceUnitMetadata puMetadata = kunderaMetadata.getApplicationMetadata()
.getPersistenceUnitMetadata(pu);
CoreMetadata coreMetadata = new CoreMetadata();
coreMetadata.setLazyInitializerFactory(new CglibLazyInitializerFactory());
kunderaMetadata.setCoreMetadata(coreMetadata);
String client = puMetadata.getProperties().getProperty(PersistenceProperties.KUNDERA_CLIENT_FACTORY);
if (client.equalsIgnoreCase("com.impetus.client.cassandra.pelops.PelopsClientFactory")
|| client.equalsIgnoreCase("com.impetus.client.cassandra.thrift.ThriftClientFactory"))
{
if (RUN_IN_EMBEDDED_MODE)
{
CassandraCli.cassandraSetUp();
CassandraCli.initClient();
}
if (AUTO_MANAGE_SCHEMA)
{
if (mAdd.getTableName().equalsIgnoreCase(colFamilies[0]))
{
loadDataForHABITAT();
}
else if (mAdd.getTableName().equalsIgnoreCase(colFamilies[1]))
{
loadDataForPERSONNEL();
}
}
}
if (client.equalsIgnoreCase("com.impetus.client.hbase.HBaseClientFactory") && RUN_IN_EMBEDDED_MODE)
{
// HBaseCli.startCluster();
// HBaseCli.createTable("PERSONNEL");
// HBaseCli.addColumnFamily("PERSONNEL", "PERSON_NAME");
// HBaseCli.addColumnFamily("PERSONNEL", "ADDRESS_ID");
//
// HBaseCli.createTable("ADDRESS");
// HBaseCli.addColumnFamily("ADDRESS", "STREET");
// HBaseCli.addColumnFamily("ADDRESS", "PERSON_ID");
//
// HBaseCli.createTable("PERSONNEL_ADDRESS");
// HBaseCli.addColumnFamily("PERSONNEL_ADDRESS",
// "ADDRESS_ID");
// HBaseCli.addColumnFamily("PERSONNEL_ADDRESS",
// "PERSON_ID");
// HBaseCli.addColumnFamily("PERSONNEL_ADDRESS",
// "JoinColumns");
}
if (client.equalsIgnoreCase("com.impetus.client.rdbms.RDBMSClientFactory"))
{
try
{
createSchemaForPERSONNEL();
createSchemaForHABITAT();
}
catch (Exception e)
{
log.error("error during creating table in HSQLDB", e);
}
}
if (client.equalsIgnoreCase("com.impetus.client.couchdb.CouchDBClientFactory"))
{
try
{
CouchDBTestUtils.createDatabase("KunderaTests".toLowerCase(), httpClient, httpHost);
// CouchDBTestUtils.createViews(new String[] { "STREET",
// "ADDRESS_ID", "PERSON_ID" }, "ADDRESS",
// httpHost, "KunderaTests".toLowerCase(), httpClient);
// CouchDBTestUtils.createViews(new String[] {
// "PERSON_NAME", "PERSON_ID", "ADDRESS_ID" },
// "PERSONNEL", httpHost, "KunderaTests".toLowerCase(),
// httpClient);
// CouchDBTestUtils.createViews(new String[] {
// "PERSON_ID", "ADDRESS_ID" }, "PERSONNEL_ADDRESS",
// httpHost, "KunderaTests".toLowerCase(), httpClient);
CouchDBTestUtils.createViews(new String[] { "STREET", "ADDRESS_ID", "PERSON_ID" },
colFamilies[0], httpHost, "KunderaTests".toLowerCase(), httpClient);
CouchDBTestUtils.createViews(new String[] { "PERSON_NAME", "PERSON_ID", "ADDRESS_ID" },
colFamilies[1], httpHost, "KunderaTests".toLowerCase(), httpClient);
if (colFamilies.length == 3)
{
CouchDBTestUtils.createViews(new String[] { "PERSON_ID", "ADDRESS_ID" }, colFamilies[2],
httpHost, "KunderaTests".toLowerCase(), httpClient);
}
}
catch (Exception e)
{
log.error("error during creating design document in couchDB", e);
}
}
String schema = puMetadata.getProperty(PersistenceProperties.KUNDERA_KEYSPACE);
mAdd.setSchema(schema != null ? schema : KEYSPACE);
// mAdd.setSchema(schema)
log.warn("persistence unit:" + pu + " and class:" + clazz.getCanonicalName());
}