Skip to content

Commit

Permalink
issue #380, #270
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Bastide <pbastide@us.ibm.com>
  • Loading branch information
prb112 committed Jan 29, 2020
1 parent 6bc05a5 commit 4cb01c2
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ public void createTenantPartitions(Collection<Table> tables, String schemaName,
// try to create the actual partitions
final String tablespaceName = "TS_TENANT" + newTenantId;
try (ITransaction tx =
(TransactionFactory.getTransaction() != null) ?
TransactionFactory.getTransaction()
(TransactionFactory.getTransaction(true) != null) ?
TransactionFactory.getTransaction(true)
: TransactionFactory.openTransaction(connectionProvider);) {
try {
logger.info("Creating tablespace: " + tablespaceName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,12 @@ private ITransaction openTransactionForThread(IConnectionProvider cp) {
* @throws IllegalStateException if no transaction is open
*/
public static ITransaction getTransaction() {
return getTransaction(false);
}

public static ITransaction getTransaction(boolean override) {
ITransaction result = getInstance().getTransactionForThread();
if (result == null) {
if (!override && result == null) {
throw new IllegalStateException("No transaction is open");
}
return result;
Expand Down
3 changes: 1 addition & 2 deletions fhir-persistence-schema/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@

# keep db2.properties from propagating
**/db2.properties
fhirschema.log
fhirschema.log*
**/fhirschema.log
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ public static void configureLogger() {
*/
public static void configureLogger(final String logDir) {
String tmpLogDir = ".";

final String TARGET = "./target/";
File tgt = new File(TARGET);
if (tgt.exists()) {
tmpLogDir = TARGET;
}

if (logDir != null && !logDir.isEmpty()) {
tmpLogDir = logDir;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ public UpdateTenantStatusAction() {
public void run(ActionBean actionBean, IDatabaseTarget target, IDatabaseAdapter adapter,
ITransactionProvider transactionProvider) throws SchemaActionException {
adapter.updateTenantStatus(actionBean.getAdminSchemaName(), actionBean.getTenantId(), actionBean.getStatus());
logger.info("Update Tenant Status: " + actionBean.getTenantName() + "] " + actionBean.getStatus());
logger.info("Update Tenant Status: [" + actionBean.getTenantName() + "] " + actionBean.getStatus());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class SchemaUtilTest {
@Test
public void testSchemaUtil() {
ITaskGroup group = new ITaskGroup() {

@Override
public String getTaskId() {
return "TEST_ID";
Expand All @@ -45,7 +44,6 @@ public void addParent(ITaskGroup parent) {
public void taskCompletionCallback(ITaskGroup taskGroup) {
// No Operation
}

};

String taskId = SchemaUtil.mapToId(group);
Expand Down Expand Up @@ -245,7 +243,7 @@ public boolean clobSupportsInline() {
SchemaUtil.loadDriver(translator);
fail();
}

@Test
public void testConfigureLogger() {
SchemaUtil.configureLogger();
Expand All @@ -254,14 +252,14 @@ public void testConfigureLogger() {
SchemaUtil.configureLogger();
assert true;
}

@Test
public void testRandomKey() {
String output = SchemaUtil.getRandomKey();
assertNotNull(output);
assertFalse(output.isEmpty());
}

@Test
public void testLogClasspath() {
Logger rootLogger = Logger.getLogger(SchemaUtil.class.getCanonicalName());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* (C) Copyright IBM Corp. 2020
*
* SPDX-License-Identifier: Apache-2.0
*/

package com.ibm.fhir.schema.app.test.main;

import com.ibm.fhir.schema.app.Main;
import com.ibm.fhir.schema.app.test.main.helper.TestHelper;

public class UpdateProcMain {
public static void main(String[] args) {
String[] arguments = {
"--prop-file", TestHelper.absolutePathToProperties(),
"--pool-size", "5",
"--schema-name", "FHIRDATA1",
"--update-proc", "default2"
};
Main.main(arguments);
}
}

0 comments on commit 4cb01c2

Please sign in to comment.