Skip to content

Commit

Permalink
Add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dmgaldi committed Jul 18, 2024
1 parent f43daa0 commit e7ee571
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

// Project settings
group = "org.veupathdb.eda"
version = "4.16.3"
version = "4.16.4"

plugins {
`java-library`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public TreeNode<Entity> getStudyEntityTree(String studyId) {
*/
private boolean attributesTableExists(Entity entity) {
PlatformUtils.DBPlatform platform = PlatformUtils.fromDataSource(_dataSource);
LOG.info("Found DB platform: " + platform);
String wideTable = DB.Tables.Attributes.NAME(entity).toUpperCase(Locale.ROOT);
if (platform == PlatformUtils.DBPlatform.PostgresDB) {
String postgresTableExists = String.format("SELECT EXISTS (\n" +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package org.veupathdb.service.eda.subset.model.db;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;

public class PlatformUtils {
private static final Logger LOG = LogManager.getLogger(PlatformUtils.class);

public enum DBPlatform {
PostgresDB("PostgreSQL"),
Expand All @@ -26,6 +30,7 @@ public String getProductName() {
public static DBPlatform fromDataSource(DataSource dataSource) {
try (Connection c = dataSource.getConnection()) {
final String productName = c.getMetaData().getDatabaseProductName();
LOG.info("Found product name: " + productName)
return Arrays.stream(DBPlatform.values())
.filter(platform -> platform.getProductName().equals(productName))
.findAny()
Expand Down

0 comments on commit e7ee571

Please sign in to comment.