Skip to content

Commit

Permalink
Fixed test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
dashrath-chauhan committed Dec 21, 2023
1 parent 901adc0 commit 55b0c7f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
* @author dashrath
*/
public enum DatabaseType {
mysql
mysql,
postrges,
sqlite
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import java.util.Properties;

import static org.ga4gh.starterkit.common.constant.DatabasePropsConstants.DEFAULT_CURRENT_SESSION_CONTEXT_CLASS;
import static org.ga4gh.starterkit.common.constant.DatabasePropsConstants.*;

/**
* @author dashrath
Expand Down Expand Up @@ -49,19 +49,47 @@ public Properties getAllProperties() {
case mysql:
assignMySQLProperties(props);
break;

case postrges:
assignPostgresProperties(props);
break;

case sqlite:
assignSqliteProperties(props);
break;
}

return props;
}

private DatabaseType getDatabaseTypeFromUrl(String url) {

if (url.startsWith("jdbc:sqlite")) {
return DatabaseType.sqlite;
}

if (url.startsWith("jdbc:postgresql")) {
return DatabaseType.postrges;
}

if (url.startsWith("jdbc:mysql")) {
return DatabaseType.mysql;
}

throw new IllegalArgumentException("Invalid JDBC URL: MUST be a valid 'sqlite', 'postgresql', or 'mysql' JDBC URL");
}

private void assignSqliteProperties(Properties props) {
props.setProperty("hibernate.connection.driver_class", SQLITE_DRIVER_CLASS);
props.setProperty("hibernate.dialect", SQLITE_DIALECT);
props.setProperty("hibernate.connection.date_class", SQLITE_DATE_CLASS);
}

private void assignPostgresProperties(Properties props) {
props.setProperty("hibernate.connection.driver_class", POSTGRES_DRIVER_CLASS);
props.setProperty("hibernate.dialect", POSTGRES_DIALECT);
}

private void assignMySQLProperties(Properties props) {
props.setProperty("hibernate.connection.driver_class", MYSQL_DRIVER_CLASS);
props.setProperty("hibernate.dialect", MYSQL_DIALECT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ public ResponseEntity<String> bulkInsert(@RequestParam("file") MultipartFile fil
hibernateUtil.insertBulkDrsObjects(file);
return new ResponseEntity<>("File uploaded and data inserted successfully", HttpStatus.OK);
} catch (Exception e) {
e.printStackTrace();
//e.printStackTrace();
//loggingUtil.debug("Error occured: ", e.printStackTrace());
return new ResponseEntity<>("Error processing the file: " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,9 @@ private List<DrsObject> prepareDataForInsert(BufferedReader reader) throws IOExc
List<DrsObject> dataToInsert = new ArrayList<>();
String row;
reader.readLine();
DrsObject drsObject = null;
while ((row = reader.readLine()) != null) {
DrsObject drsObject = createAndReturnDrsObject(row);
drsObject = createAndReturnDrsObject(row);
dataToInsert.add(drsObject);
}
return dataToInsert;
Expand Down

0 comments on commit 55b0c7f

Please sign in to comment.