mirror of
https://github.com/datahub-project/datahub.git
synced 2025-07-19 07:30:54 +00:00
apply hibernate related change to frontend (#645)
This commit is contained in:
parent
cebdbc73a2
commit
d891b51ca6
@ -27,7 +27,9 @@ import java.io.FileReader;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hibernate.hikaricp.internal.HikariCPConnectionProvider;
|
||||
import play.Logger;
|
||||
import play.Play;
|
||||
import play.data.DynamicForm;
|
||||
@ -38,10 +40,12 @@ import play.mvc.Result;
|
||||
import play.mvc.Security;
|
||||
import security.AuthenticationManager;
|
||||
import utils.Tree;
|
||||
import wherehows.dao.ConnectionPoolProperties;
|
||||
import wherehows.dao.DaoFactory;
|
||||
|
||||
import static play.data.Form.*;
|
||||
|
||||
|
||||
public class Application extends Controller {
|
||||
|
||||
private static String TREE_NAME_SUBFIX = ".tree.name";
|
||||
@ -50,16 +54,39 @@ public class Application extends Controller {
|
||||
private static final String PIWIK_SITE_ID = Play.application().configuration().getString("tracking.piwik.siteid");
|
||||
private static final String PIWIK_URL = Play.application().configuration().getString("tracking.piwik.url");
|
||||
private static final Boolean IS_INTERNAL = Play.application().configuration().getBoolean("linkedin.internal", false);
|
||||
private static final String DB_WHEREHOWS_URL = Play.application().configuration().getString("db.wherehows.url");
|
||||
private static final String WHZ_DB_DSCLASSNAME =
|
||||
Play.application().configuration().getString("hikaricp.dataSourceClassName");
|
||||
private static final String DB_WHEREHOWS_USERNAME =
|
||||
Play.application().configuration().getString("database.opensource.username");
|
||||
private static final String DB_WHEREHOWS_PASSWORD =
|
||||
Play.application().configuration().getString("database.opensource.password");
|
||||
private static final String DB_WHEREHOWS_DIALECT = Play.application().configuration().getString("hikaricp.dialect");
|
||||
|
||||
public static final EntityManagerFactory entityManagerFactory;
|
||||
|
||||
static {
|
||||
entityManagerFactory = ConnectionPoolProperties.builder()
|
||||
.providerClass(HikariCPConnectionProvider.class.getName())
|
||||
.dataSourceClassName(WHZ_DB_DSCLASSNAME)
|
||||
.dataSourceURL(DB_WHEREHOWS_URL)
|
||||
.dataSourceUser(DB_WHEREHOWS_USERNAME)
|
||||
.dataSourcePassword(DB_WHEREHOWS_PASSWORD)
|
||||
.dialect(DB_WHEREHOWS_DIALECT)
|
||||
.build()
|
||||
.buildEntityManagerFactory();
|
||||
}
|
||||
|
||||
public static final DaoFactory daoFactory = createDaoFactory();
|
||||
|
||||
private static DaoFactory createDaoFactory() {
|
||||
try {
|
||||
String className =
|
||||
Play.application().configuration().getString("dao.factory.class", DaoFactory.class.getCanonicalName());
|
||||
String className = Play.application()
|
||||
.configuration()
|
||||
.getString("dao.entityManagerFactory.class", DaoFactory.class.getCanonicalName());
|
||||
Class factoryClass = Class.forName(className);
|
||||
Constructor<? extends DaoFactory> ctor = factoryClass.getConstructor();
|
||||
return ctor.newInstance();
|
||||
Constructor<? extends DaoFactory> ctor = factoryClass.getConstructor(EntityManagerFactory.class);
|
||||
return ctor.newInstance(entityManagerFactory);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@ -97,8 +124,7 @@ public class Application extends Controller {
|
||||
BufferedReader br = new BufferedReader(new FileReader(commitFile));
|
||||
commit = br.readLine();
|
||||
} catch (IOException ioe) {
|
||||
Logger.error("Error while reading commit file. Error message: " +
|
||||
ioe.getMessage());
|
||||
Logger.error("Error while reading commit file. Error message: " + ioe.getMessage());
|
||||
}
|
||||
|
||||
//get all the files from a directory
|
||||
@ -112,7 +138,6 @@ public class Application extends Controller {
|
||||
return ok("commit: " + commit + "\n" + libraries);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* index Action proxies to serveAsset
|
||||
*
|
||||
@ -203,7 +228,6 @@ public class Application extends Controller {
|
||||
String type = "azkaban";
|
||||
if (StringUtils.isNotBlank(application) && (application.toLowerCase().indexOf("appworx") != -1)) {
|
||||
type = "appworx";
|
||||
|
||||
}
|
||||
|
||||
return serveAsset("");
|
||||
@ -349,5 +373,4 @@ public class Application extends Controller {
|
||||
public static Result loadMetricNodes(String dashboard, String group) {
|
||||
return ok(MetricsDAO.getMetricNodes(dashboard, group));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -60,6 +60,16 @@ database.opensource.username = ${WHZ_DB_USERNAME}
|
||||
database.opensource.password = ${WHZ_DB_PASSWORD}
|
||||
database.opensource.url = ${WHZ_DB_URL}
|
||||
|
||||
# Hibernate HIKARICP connection driver name
|
||||
# HikariCP is an open source JDBC connection pooling library
|
||||
hikaricp.dataSourceClassName = "com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
|
||||
hikaricp.dataSourceClassName = ${?WHZ_DB_DSCLASSNAME}
|
||||
|
||||
# dialect for DB
|
||||
# example values for different db: org.hibernate.dialect.MySQL5InnoDBDialect, org.hibernate.dialect.H2Dialect
|
||||
hikaricp.dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"
|
||||
hikaricp.dialect = ${?WHZ_DB_DIALECT}
|
||||
|
||||
search.engine = "default"
|
||||
search.engine = ${?WHZ_SEARCH_ENGINE}
|
||||
|
||||
@ -81,3 +91,4 @@ lineage.look.back.time = ${?LINEAGE_LOOK_BACK_TIME}
|
||||
# Tracking
|
||||
tracking.piwik.siteid = ${?PIWIK_SITE_ID}
|
||||
tracking.piwik.url = ${?PIWIK_URL}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user