Skip to content
Snippets Groups Projects
Commit 3b3db0e8 authored by cramakri's avatar cramakri
Browse files

LMS-2506 Imposed uniform naming. Simplified API.

SVN: 22938
parent b1e6d6df
No related branches found
No related tags found
No related merge requests found
Showing
with 35 additions and 58 deletions
......@@ -23,4 +23,4 @@ LIB=$BASE/../webapps/$APPLICATION_NAME/WEB-INF/lib
$JVM \
-cp $LIB/\* \
ch.systemsx.cisd.openbis.generic.client.jython.api.v1.impl.JythonPluginScriptStandalone "$@"
ch.systemsx.cisd.openbis.generic.client.jython.api.v1.impl.MasterDataRegistrationScriptRunnerStandalone "$@"
......@@ -17,11 +17,16 @@
package ch.systemsx.cisd.openbis.generic.client.jython.api.v1;
/**
* A service that provides methods for registering master data.
*
* @author Kaloyan Enimanev
*/
public interface IJythonPluginService
public interface IMasterDataRegistrationService
{
/**
* Create a transaction for registering master data.
*/
IMasterDataRegistrationTransaction transaction();
}
......@@ -50,18 +50,7 @@ public interface IMasterDataRegistrationTransaction
* @param propertyType The property type to assign to the entity type.
* @return An object representing the assignment.
*/
IPropertyAssignment assignPropertyType(IEntityType entityType, IPropertyTypeImmutable propertyType);
IPropertyAssignment assignToExperimentType(IExperimentTypeImmutable experimentType,
IPropertyTypeImmutable propertyType);
IPropertyAssignment assignToSampleType(ISampleTypeImmutable sampleType,
IPropertyTypeImmutable propertyType);
IPropertyAssignment assignToDataSetType(IDataSetTypeImmutable dataSetType,
IPropertyTypeImmutable propertyType);
IPropertyAssignment assignToMaterialType(IMaterialTypeImmutable materialType,
IPropertyAssignment assignPropertyType(IEntityType entityType,
IPropertyTypeImmutable propertyType);
// controlled vocabularies not yet implemented
......
......@@ -26,9 +26,11 @@ import ch.systemsx.cisd.common.logging.LogLevel;
import ch.systemsx.cisd.openbis.generic.client.jython.api.v1.impl.MasterDataTransactionErrors.TransactionError;
/**
* A class for running python scripts that register master data.
*
* @author Kaloyan Enimanev
*/
public class JythonPluginScriptRunner
public class MasterDataRegistrationScriptRunner
{
private final static String SERVICE_VARIABLE_NAME = "service";
......@@ -36,7 +38,8 @@ public class JythonPluginScriptRunner
private final ISimpleLogger errorLogger;
JythonPluginScriptRunner(EncapsulatedCommonServer commonServer, ISimpleLogger errorLogger)
MasterDataRegistrationScriptRunner(EncapsulatedCommonServer commonServer,
ISimpleLogger errorLogger)
{
this.commonServer = commonServer;
this.errorLogger = errorLogger;
......@@ -44,7 +47,7 @@ public class JythonPluginScriptRunner
public void executeScript(File jythonScript)
{
JythonPluginService service = new JythonPluginService(commonServer);
MasterDataRegistrationService service = new MasterDataRegistrationService(commonServer);
runScript(service, jythonScript);
try
......@@ -56,7 +59,7 @@ public class JythonPluginScriptRunner
}
}
private void runScript(JythonPluginService service, File jythonScript)
private void runScript(MasterDataRegistrationService service, File jythonScript)
{
checkValidJythonScript(jythonScript);
......
......@@ -31,7 +31,7 @@ import ch.systemsx.cisd.common.logging.ConsoleLogger;
*
* @author Kaloyan Enimanev
*/
public class JythonPluginScriptStandalone
public class MasterDataRegistrationScriptRunnerStandalone
{
public static class Arguments extends ConsoleClientArguments
......@@ -81,14 +81,14 @@ public class JythonPluginScriptStandalone
EncapsulatedCommonServer.create(arguments.getServerBaseUrl(),
arguments.getUsername(), arguments.getPassword());
JythonPluginScriptRunner scriptRunner =
new JythonPluginScriptRunner(commonServer, new ConsoleLogger());
MasterDataRegistrationScriptRunner scriptRunner =
new MasterDataRegistrationScriptRunner(commonServer, new ConsoleLogger());
scriptRunner.executeScript(new File(arguments.scriptFileName));
}
public static void main(String[] args)
{
JythonPluginScriptStandalone cliApplication = new JythonPluginScriptStandalone();
MasterDataRegistrationScriptRunnerStandalone cliApplication = new MasterDataRegistrationScriptRunnerStandalone();
cliApplication.runMe(args);
}
......
......@@ -19,13 +19,13 @@ package ch.systemsx.cisd.openbis.generic.client.jython.api.v1.impl;
import java.util.ArrayList;
import java.util.List;
import ch.systemsx.cisd.openbis.generic.client.jython.api.v1.IJythonPluginService;
import ch.systemsx.cisd.openbis.generic.client.jython.api.v1.IMasterDataRegistrationService;
import ch.systemsx.cisd.openbis.generic.client.jython.api.v1.IMasterDataRegistrationTransaction;
/**
* @author Kaloyan Enimanev
*/
public class JythonPluginService implements IJythonPluginService
public class MasterDataRegistrationService implements IMasterDataRegistrationService
{
private final EncapsulatedCommonServer commonServer;
......@@ -33,7 +33,7 @@ public class JythonPluginService implements IJythonPluginService
private final List<MasterDataRegistrationTransaction> createdTransactions =
new ArrayList<MasterDataRegistrationTransaction>();
public JythonPluginService(EncapsulatedCommonServer commonServer)
public MasterDataRegistrationService(EncapsulatedCommonServer commonServer)
{
this.commonServer = commonServer;
}
......
......@@ -137,18 +137,22 @@ public class MasterDataRegistrationTransaction implements IMasterDataRegistratio
{
if (entityType instanceof IExperimentTypeImmutable)
{
return assignToExperimentType((IExperimentTypeImmutable) entityType, propertyType);
return createAssignment(EntityKind.EXPERIMENT, (IExperimentTypeImmutable) entityType,
propertyType);
} else if (entityType instanceof ISampleTypeImmutable)
{
return assignToSampleType((ISampleTypeImmutable) entityType, propertyType);
return createAssignment(EntityKind.SAMPLE, (ISampleTypeImmutable) entityType,
propertyType);
} else
if (entityType instanceof IDataSetTypeImmutable)
{
return assignToDataSetType((IDataSetTypeImmutable) entityType, propertyType);
return createAssignment(EntityKind.DATA_SET, (IDataSetTypeImmutable) entityType,
propertyType);
} else if (entityType instanceof IMaterialTypeImmutable)
{
return assignToMaterialType((IMaterialTypeImmutable) entityType, propertyType);
return createAssignment(EntityKind.MATERIAL, (IMaterialTypeImmutable) entityType,
propertyType);
}
throw new IllegalArgumentException(
......@@ -156,30 +160,6 @@ public class MasterDataRegistrationTransaction implements IMasterDataRegistratio
+ entityType + " is not valid.");
}
public IPropertyAssignment assignToExperimentType(IExperimentTypeImmutable experimentType,
IPropertyTypeImmutable propertyType)
{
return createAssignment(EntityKind.EXPERIMENT, experimentType, propertyType);
}
public IPropertyAssignment assignToSampleType(ISampleTypeImmutable sampleType,
IPropertyTypeImmutable propertyType)
{
return createAssignment(EntityKind.SAMPLE, sampleType, propertyType);
}
public IPropertyAssignment assignToDataSetType(IDataSetTypeImmutable dataSetType,
IPropertyTypeImmutable propertyType)
{
return createAssignment(EntityKind.DATA_SET, dataSetType, propertyType);
}
public IPropertyAssignment assignToMaterialType(IMaterialTypeImmutable materialType,
IPropertyTypeImmutable propertyType)
{
return createAssignment(EntityKind.MATERIAL, materialType, propertyType);
}
private <T extends IAbstractType> T findTypeForCode(List<T> types, String code)
{
for (T type : types)
......
......@@ -39,7 +39,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType;
/**
* @author Kaloyan Enimanev
*/
public class JythonPluginScriptRunnerTest extends AssertJUnit
public class MasterDataRegistrationScriptRunnerTest extends AssertJUnit
{
private static final String SESSION_TOKEN = "SESSION_TOKEN";
......@@ -51,7 +51,7 @@ public class JythonPluginScriptRunnerTest extends AssertJUnit
private ICommonServer commonServer;
private JythonPluginScriptRunner pluginScriptRunner;
private MasterDataRegistrationScriptRunner pluginScriptRunner;
private AssertingLogger errorLogger;
......@@ -63,7 +63,7 @@ public class JythonPluginScriptRunnerTest extends AssertJUnit
EncapsulatedCommonServer encapsulatedServer =
new EncapsulatedCommonServer(commonServer, SESSION_TOKEN);
errorLogger = new AssertingLogger();
pluginScriptRunner = new JythonPluginScriptRunner(encapsulatedServer, errorLogger);
pluginScriptRunner = new MasterDataRegistrationScriptRunner(encapsulatedServer, errorLogger);
}
......
......@@ -34,9 +34,9 @@ materialPropertyType.setManagedInternally(False)
#xmlPropertyType.setXmlSchema('')
#xmlPropertyType.setTransformation('')
assigment1 = tr.assignToSampleType(sampleType, materialPropertyType)
assigment1 = tr.assignPropertyType(sampleType, materialPropertyType)
assigment1.setMandatory(True)
assigment2 = tr.assignToExperimentType(expType, stringPropertyType)
assigment2 = tr.assignPropertyType(expType, stringPropertyType)
assigment2.setMandatory(False)
assigment2.setDefaultValue("Default STRING Value")
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