Skip to content

Commit

Permalink
PC-1067: reformat all Java + XML files using template
Browse files Browse the repository at this point in the history
  • Loading branch information
harschware committed Feb 10, 2017
1 parent d76f35e commit 6ae2a1e
Show file tree
Hide file tree
Showing 1,155 changed files with 14,964 additions and 15,889 deletions.
2 changes: 1 addition & 1 deletion commons/commons-constants/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion commons/commons-feed-util/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,14 @@ public static String category(String name) {

/**
* parse the feed name from a full feed name (category.feed)
* @param name
* @return
*/
public static String feed(String name) {
return StringUtils.trim(StringUtils.substringAfterLast(name, "."));
}

/**
* return the full feed name from a category and feed.
* @param category
* @param feed
*
* @return returns the (category.feed) name
*/
public static String fullName(String category, String feed) {
Expand Down
4 changes: 2 additions & 2 deletions commons/commons-jdbc/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,153 +34,150 @@
* Common DatabaseType defining some of the major databases and validationQuery strings
*/
public enum DatabaseType {
DERBY("Apache Derby", "jdbc:derby:", "select 1"),
DB2("DB2", "jdbc:db2", "select 1 from sysibm.sysdummy1"),
FIREBIRD("Firebird", "jdbc:firebird", "select 1 from rdb$database"),
H2("H2", "jdbc:h2", "select 1"),
HSQL("HSQL Database Engine", "jdbc:hsqldb", "select 1 from INFORMATION_SCHEMA.SYSTEM_USERS"),
MYSQL("MySQL", "jdbc:mysql", "select 1"),
ORACLE("Oracle", "jdbc:oracle", "select 1"),
POSTGRES("PostgreSQL", "jdbc:postgressql", "select 1"),
SQLITE("SQLite", "jdbc:sqlite", "select 1"),
SQLSERVER("Microsoft SQL Server", "jdbc:sqlserver", "select 1"),
SYBASE("Sybase", "jdbc:sybase", "select 1"),
TERADATA("Teradata", "jdbc:teradata", "select 1");


private static final Map<String, DatabaseType> databaseProductNameMap;

/**
* lookup map based upon the jdbc connectoin string identifier
*/
private static final Map<String, DatabaseType> jdbcConnectionStringMap;

/**
* The database name obtained from the connection.getDatabaseProductName
*/
private final String productName;
/**
* unique string of jdbc connection to identify the database
*/
private final String[] jdbcConnectionStringIdentifiers;

/**
* The validation Query needed to reconnect
*/
private final String validationQuery;


private DatabaseType(String productName, String jdbcUrlIdentifier, String validationQuery) {
this(productName, new String[]{jdbcUrlIdentifier}, validationQuery);
}

private DatabaseType(String productName, String[] jdbcConnectionStringIdentifiers, String validationQuery) {
this.productName = productName;
this.jdbcConnectionStringIdentifiers = jdbcConnectionStringIdentifiers;
this.validationQuery = validationQuery;
}

/**
* Get the database product name
* @return the database product name
*/
public String getProductName() {
return this.productName;
}

/**
* get the array of connection identifiers for this database type
*
* @return the array of unique jdbc connection identifiers
*/
public String[] getJdbcConnectionStringIdentifiers() {
return this.jdbcConnectionStringIdentifiers;
}

/**
* get the validation query for this database
*
* @return the validation query for the database
*/
public String getValidationQuery() {
return validationQuery;
}


/**
* Return the DatabaseType from the known Database Product name.
*
* @return the DatabaseType matching the product name
*/
public static DatabaseType fromProductName(String productName) throws IllegalArgumentException {
if (!databaseProductNameMap.containsKey(productName)) {
throw new IllegalArgumentException("DatabaseType not found for product name: " + productName );
} else {
return databaseProductNameMap.get(productName);
DERBY("Apache Derby", "jdbc:derby:", "select 1"),
DB2("DB2", "jdbc:db2", "select 1 from sysibm.sysdummy1"),
FIREBIRD("Firebird", "jdbc:firebird", "select 1 from rdb$database"),
H2("H2", "jdbc:h2", "select 1"),
HSQL("HSQL Database Engine", "jdbc:hsqldb", "select 1 from INFORMATION_SCHEMA.SYSTEM_USERS"),
MYSQL("MySQL", "jdbc:mysql", "select 1"),
ORACLE("Oracle", "jdbc:oracle", "select 1"),
POSTGRES("PostgreSQL", "jdbc:postgressql", "select 1"),
SQLITE("SQLite", "jdbc:sqlite", "select 1"),
SQLSERVER("Microsoft SQL Server", "jdbc:sqlserver", "select 1"),
SYBASE("Sybase", "jdbc:sybase", "select 1"),
TERADATA("Teradata", "jdbc:teradata", "select 1");


private static final Map<String, DatabaseType> databaseProductNameMap;

/**
* lookup map based upon the jdbc connectoin string identifier
*/
private static final Map<String, DatabaseType> jdbcConnectionStringMap;

/**
* Build up the lookup maps
*/
static {
databaseProductNameMap = new HashMap<>();
jdbcConnectionStringMap = new HashMap<>();
DatabaseType[] databaseTypes = values();
for (DatabaseType dbType : databaseTypes) {
databaseProductNameMap.put(dbType.getProductName(), dbType);
for (String jdbcConnectionId : dbType.getJdbcConnectionStringIdentifiers()) {
jdbcConnectionStringMap.put(jdbcConnectionId, dbType);
}
}
}
}

/**
* Return the DatabaseType containing the first match to the jdbc connection string
* @param connectionString a jdbc url connection string
* @return the DatabaseType matching the connection String
* @throws IllegalArgumentException
*/
public static DatabaseType fromJdbcConnectionString(String connectionString) throws IllegalArgumentException {
return jdbcConnectionStringMap.entrySet().stream()
.filter(entry -> connectionString.toLowerCase().contains(entry.getKey())).map(entry -> entry.getValue())
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("DatabaseType not found for jdbc connection String: " + connectionString));
}


/**
* Parse the Database ProductName from the DataSource and return the matching DatabaseType
*/
public static DatabaseType fromMetaData(DataSource dataSource) throws MetaDataAccessException {
String databaseProductName = JdbcUtils.extractDatabaseMetaData(dataSource, "getDatabaseProductName").toString();
databaseProductName = JdbcUtils.commonDatabaseName(databaseProductName);
try {
return fromProductName(databaseProductName);
} catch (IllegalArgumentException e) {
throw new MetaDataAccessException(e.getMessage());

/**
* The database name obtained from the connection.getDatabaseProductName
*/
private final String productName;
/**
* unique string of jdbc connection to identify the database
*/
private final String[] jdbcConnectionStringIdentifiers;
/**
* The validation Query needed to reconnect
*/
private final String validationQuery;

private DatabaseType(String productName, String jdbcUrlIdentifier, String validationQuery) {
this(productName, new String[]{jdbcUrlIdentifier}, validationQuery);
}

private DatabaseType(String productName, String[] jdbcConnectionStringIdentifiers, String validationQuery) {
this.productName = productName;
this.jdbcConnectionStringIdentifiers = jdbcConnectionStringIdentifiers;
this.validationQuery = validationQuery;
}

/**
* Return the DatabaseType from the known Database Product name.
*
* @return the DatabaseType matching the product name
*/
public static DatabaseType fromProductName(String productName) throws IllegalArgumentException {
if (!databaseProductNameMap.containsKey(productName)) {
throw new IllegalArgumentException("DatabaseType not found for product name: " + productName);
} else {
return databaseProductNameMap.get(productName);
}
}

/**
* Return the DatabaseType containing the first match to the jdbc connection string
*
* @param connectionString a jdbc url connection string
* @return the DatabaseType matching the connection String
*/
public static DatabaseType fromJdbcConnectionString(String connectionString) throws IllegalArgumentException {
return jdbcConnectionStringMap.entrySet().stream()
.filter(entry -> connectionString.toLowerCase().contains(entry.getKey())).map(entry -> entry.getValue())
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("DatabaseType not found for jdbc connection String: " + connectionString));
}
}

/**
* Parse the Database ProductName from the Connection and return the matching DatabaseType
*/
public static DatabaseType fromMetaData(Connection connection) throws MetaDataAccessException {
String databaseProductName = null;
try {
databaseProductName = connection.getMetaData().getDatabaseProductName();
} catch (SQLException e) {
throw new MetaDataAccessException(e.getMessage());

/**
* Parse the Database ProductName from the DataSource and return the matching DatabaseType
*/
public static DatabaseType fromMetaData(DataSource dataSource) throws MetaDataAccessException {
String databaseProductName = JdbcUtils.extractDatabaseMetaData(dataSource, "getDatabaseProductName").toString();
databaseProductName = JdbcUtils.commonDatabaseName(databaseProductName);
try {
return fromProductName(databaseProductName);
} catch (IllegalArgumentException e) {
throw new MetaDataAccessException(e.getMessage());
}
}

/**
* Parse the Database ProductName from the Connection and return the matching DatabaseType
*/
public static DatabaseType fromMetaData(Connection connection) throws MetaDataAccessException {
String databaseProductName = null;
try {
databaseProductName = connection.getMetaData().getDatabaseProductName();
} catch (SQLException e) {
throw new MetaDataAccessException(e.getMessage());
}
if (databaseProductName != null) {
databaseProductName = JdbcUtils.commonDatabaseName(databaseProductName);
try {
return fromProductName(databaseProductName);
} catch (IllegalArgumentException e) {
throw new MetaDataAccessException(e.getMessage());
}
} else {
throw new MetaDataAccessException("Database Type not found for connection");
}
}
if (databaseProductName != null) {
databaseProductName = JdbcUtils.commonDatabaseName(databaseProductName);
try {
return fromProductName(databaseProductName);
} catch (IllegalArgumentException e) {
throw new MetaDataAccessException(e.getMessage());
}
} else {
throw new MetaDataAccessException("Database Type not found for connection");

/**
* Get the database product name
*
* @return the database product name
*/
public String getProductName() {
return this.productName;
}
}

/**
* Build up the lookup maps
*/
static {
databaseProductNameMap = new HashMap<>();
jdbcConnectionStringMap = new HashMap<>();
DatabaseType[] databaseTypes = values();
for(DatabaseType dbType: databaseTypes){
databaseProductNameMap.put(dbType.getProductName(), dbType);
for (String jdbcConnectionId : dbType.getJdbcConnectionStringIdentifiers()) {
jdbcConnectionStringMap.put(jdbcConnectionId, dbType);
}

/**
* get the array of connection identifiers for this database type
*
* @return the array of unique jdbc connection identifiers
*/
public String[] getJdbcConnectionStringIdentifiers() {
return this.jdbcConnectionStringIdentifiers;
}

/**
* get the validation query for this database
*
* @return the validation query for the database
*/
public String getValidationQuery() {
return validationQuery;
}
}
}
2 changes: 1 addition & 1 deletion commons/commons-jpa/pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
*
*
*/
package com.thinkbiganalytics.jpa;

Expand Down Expand Up @@ -36,15 +36,19 @@
@MappedSuperclass
@EntityListeners(AuditTimestampListener.class)
public class AbstractAuditedEntity implements AuditedEntity {
@Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
@Column(name="created_time")

@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
@Column(name = "created_time")
private DateTime createdTime;
@Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
@Column(name="modified_time")

@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
@Column(name = "modified_time")
private DateTime modifiedTime;

public DateTime getCreatedTime() {
return createdTime;
}

/* (non-Javadoc)
* @see com.thinkbiganalytics.jpa.AuditedEntity#setCreatedTime(org.joda.time.DateTime)
*/
Expand All @@ -53,20 +57,16 @@ public void setCreatedTime(DateTime time) {
this.createdTime = time;
}

public DateTime getModifiedTime() {
return modifiedTime;
}

/* (non-Javadoc)
* @see com.thinkbiganalytics.jpa.AuditedEntity#setModifiedTime(org.joda.time.DateTime)
*/
@Override
public void setModifiedTime(DateTime time) {
this.modifiedTime = time;
}

public DateTime getCreatedTime() {
return createdTime;
}

public DateTime getModifiedTime() {
return modifiedTime;
}

}
Loading

0 comments on commit 6ae2a1e

Please sign in to comment.