Skip to content
Snippets Groups Projects
Commit 913a1ee3 authored by cramakri's avatar cramakri
Browse files

SP-45 BIS-21 : Use the process function to process incoming in jython v2

SVN: 25289
parent 096d64bd
No related branches found
No related tags found
No related merge requests found
......@@ -163,6 +163,7 @@ public class JythonTopLevelDataSetHandler<T extends DataSetInformation> extends
(JythonDataSetRegistrationService<T>) genericService;
executeJythonScript(dataSetFile, scriptString, service);
executeJythonProcessFunction(service.interpreter);
}
private void executeJythonScript(File dataSetFile, String scriptString,
......@@ -178,6 +179,14 @@ public class JythonTopLevelDataSetHandler<T extends DataSetInformation> extends
verifyEvaluatorHookFunctions(interpreter);
}
/**
* Execute the function that processes the data set. Subclasses may override.
*/
protected void executeJythonProcessFunction(PythonInterpreter interpreter)
{
}
private void verifyEvaluatorHookFunctions(PythonInterpreter interpreter)
{
for (JythonHookFunction function : JythonHookFunction.values())
......@@ -455,20 +464,20 @@ public class JythonTopLevelDataSetHandler<T extends DataSetInformation> extends
private void invokeRollbackServiceFunction(PyFunction function,
DataSetRegistrationService<T> service, Throwable throwable)
{
invokeFuncion(service, function, service, throwable);
invokeFunction(service, function, service, throwable);
}
private void invokeRollbackTransactionFunction(PyFunction function,
DataSetRegistrationService<T> service, DataSetRegistrationTransaction<T> transaction,
DataSetStorageAlgorithmRunner<T> algorithmRunner, Throwable throwable)
{
invokeFuncion(service, function, service, transaction, algorithmRunner, throwable);
invokeFunction(service, function, service, transaction, algorithmRunner, throwable);
}
private void invokeServiceTransactionFunction(PyFunction function,
DataSetRegistrationService<T> service, DataSetRegistrationTransaction<T> transaction)
{
invokeFuncion(service, function, service, transaction);
invokeFunction(service, function, service, transaction);
}
private void invokeTransactionFunctionWithContext(PyFunction function,
......@@ -477,11 +486,11 @@ public class JythonTopLevelDataSetHandler<T extends DataSetInformation> extends
{
if (additionalArgs.length > 0)
{
invokeFuncion(service, function, transaction.getTransactionPersistentMap(),
invokeFunction(service, function, transaction.getTransactionPersistentMap(),
additionalArgs);
} else
{
invokeFuncion(service, function, transaction.getTransactionPersistentMap());
invokeFunction(service, function, transaction.getTransactionPersistentMap());
}
}
......@@ -489,14 +498,14 @@ public class JythonTopLevelDataSetHandler<T extends DataSetInformation> extends
DataSetRegistrationService<T> service, DataSetRegistrationTransaction<T> transaction,
List<SecondaryTransactionFailure> secondaryErrors)
{
invokeFuncion(service, function, service, transaction, secondaryErrors);
invokeFunction(service, function, service, transaction, secondaryErrors);
}
/**
* Turns all arguments into a python objects, and calls the specified function. Service is here
* only for the tests, so that the tests can hook it
*/
protected void invokeFuncion(DataSetRegistrationService<T> service, PyFunction function,
protected void invokeFunction(DataSetRegistrationService<T> service, PyFunction function,
Object... args)
{
PyObject[] pyArgs = new PyObject[args.length];
......
......@@ -18,8 +18,10 @@ package ch.systemsx.cisd.etlserver.registrator.api.v2;
import java.io.File;
import org.python.core.PyFunction;
import org.python.util.PythonInterpreter;
import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel;
import ch.systemsx.cisd.common.utilities.IDelegatedActionWithResult;
import ch.systemsx.cisd.common.utilities.PythonUtils;
import ch.systemsx.cisd.etlserver.ITopLevelDataSetRegistratorDelegate;
......@@ -91,6 +93,20 @@ public class JythonTopLevelDataSetHandlerV2<T extends DataSetInformation> extend
interpreter.set(FACTORY_VARIABLE_NAME, service.getDataSetRegistrationDetailsFactory());
}
@Override
protected void executeJythonProcessFunction(PythonInterpreter interpreter)
{
String PROCESS_FUNCTION_NAME = "process";
try
{
PyFunction function = interpreter.get(PROCESS_FUNCTION_NAME, PyFunction.class);
function.__call__();
} catch (Exception e)
{
throw CheckedExceptionTunnel.wrapIfNecessary(e);
}
}
@Override
protected boolean shouldUseOldJythonHookFunctions()
{
......
......@@ -56,11 +56,11 @@ public class TestingDataSetHandler extends JythonTopLevelDataSetHandler<DataSetI
}
@Override
protected void invokeFuncion(
protected void invokeFunction(
ch.systemsx.cisd.etlserver.registrator.DataSetRegistrationService<DataSetInformation> service,
PyFunction function, Object... args)
{
super.invokeFuncion(service, function, args);
super.invokeFunction(service, function, args);
expectations.checkPythonInterpreterVariables(service);
}
......
......@@ -57,11 +57,11 @@ public class TestingDataSetHandlerV2 extends JythonTopLevelDataSetHandlerV2<Data
}
@Override
protected void invokeFuncion(
protected void invokeFunction(
ch.systemsx.cisd.etlserver.registrator.DataSetRegistrationService<DataSetInformation> service,
PyFunction function, Object... args)
{
super.invokeFuncion(service, function, args);
super.invokeFunction(service, function, args);
expectations.checkPythonInterpreterVariables(service);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment