Skip to content
Snippets Groups Projects
Commit 740a8ca6 authored by felmer's avatar felmer
Browse files

SE-312 introducing processDataSets in Proteomics Data API. Changes in...

SE-312 introducing processDataSets in Proteomics Data API. Changes in MsInjectionCopier: target file name is just data set code

SVN: 18676
parent 3ca4abc3
No related branches found
No related tags found
No related merge requests found
Showing
with 89 additions and 42 deletions
...@@ -279,9 +279,7 @@ class MsInjectionCopier implements Serializable, IPostRegistrationDatasetHandler ...@@ -279,9 +279,7 @@ class MsInjectionCopier implements Serializable, IPostRegistrationDatasetHandler
/** /**
* Copies specified data file/folder to destination specified in constructor. The name of the * Copies specified data file/folder to destination specified in constructor. The name of the
* file/folder at the destination is defined as * file/folder at the destination is defined by the data set code.
* <code>&lt;sample code&gt;_&lt;data set type code&gt;</code> where sample code is provided by
* the parameter bindings (key: data set code).
*/ */
public Status handle(File originalData, DataSetInformation dataSetInformation, public Status handle(File originalData, DataSetInformation dataSetInformation,
Map<String, String> parameterBindings) Map<String, String> parameterBindings)
...@@ -292,7 +290,7 @@ class MsInjectionCopier implements Serializable, IPostRegistrationDatasetHandler ...@@ -292,7 +290,7 @@ class MsInjectionCopier implements Serializable, IPostRegistrationDatasetHandler
} }
try try
{ {
String target = createTargetFolderName(dataSetInformation, parameterBindings); String target = dataSetInformation.getDataSetCode();
File targetFolder = new File(destination, target); File targetFolder = new File(destination, target);
deleteTargetFolder(targetFolder); deleteTargetFolder(targetFolder);
executor.copyDataSet(originalData, destination); executor.copyDataSet(originalData, destination);
...@@ -305,16 +303,6 @@ class MsInjectionCopier implements Serializable, IPostRegistrationDatasetHandler ...@@ -305,16 +303,6 @@ class MsInjectionCopier implements Serializable, IPostRegistrationDatasetHandler
} }
} }
private String createTargetFolderName(DataSetInformation dataSetInformation,
Map<String, String> parameterBindings)
{
String dataSetTypeCode = dataSetInformation.getDataSetType().getCode();
String dataSetCode = dataSetInformation.getDataSetCode();
String sampleCode = parameterBindings.get(dataSetCode);
return (sampleCode == null ? SAMPLE_UNKNOWN : sampleCode) + "_" + dataSetCode + "_"
+ dataSetTypeCode;
}
private void deleteTargetFolder(File targetFolder) private void deleteTargetFolder(File targetFolder)
{ {
BooleanStatus targetExists = executor.exists(targetFolder); BooleanStatus targetExists = executor.exists(targetFolder);
......
...@@ -28,10 +28,7 @@ import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.dto.MsInjection ...@@ -28,10 +28,7 @@ import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.dto.MsInjection
* *
* @author Franz-Josef Elmer * @author Franz-Josef Elmer
*/ */
public interface IProteomicsDataApiFacade
// This interfaces replaces the IRawDataApiFacade.
@SuppressWarnings("deprecation")
public interface IProteomicsDataApiFacade extends IRawDataApiFacade
{ {
/** /**
* Return the session token for the logged-in user. * Return the session token for the logged-in user.
...@@ -53,8 +50,11 @@ public interface IProteomicsDataApiFacade extends IRawDataApiFacade ...@@ -53,8 +50,11 @@ public interface IProteomicsDataApiFacade extends IRawDataApiFacade
* Processes the data sets of specified samples by the DSS processing plug-in of specified key * Processes the data sets of specified samples by the DSS processing plug-in of specified key
* for the specified user. Only the most recent data sets of specified type are processed. * for the specified user. Only the most recent data sets of specified type are processed.
*/ */
@Deprecated
public void processingRawData(String userID, String dataSetProcessingKey, public void processingRawData(String userID, String dataSetProcessingKey,
long[] rawDataSampleIDs, String dataSetType); long[] rawDataSampleIDs, String dataSetType);
public void processDataSets(String userID, String dataSetProcessingKey, List<String> dataSetCodes);
/** /**
* Returns all projects where the specified user has USER access rights. * Returns all projects where the specified user has USER access rights.
...@@ -74,6 +74,7 @@ public interface IProteomicsDataApiFacade extends IRawDataApiFacade ...@@ -74,6 +74,7 @@ public interface IProteomicsDataApiFacade extends IRawDataApiFacade
*/ */
public void processSearchData(String userID, String dataSetProcessingKey, public void processSearchData(String userID, String dataSetProcessingKey,
long[] searchExperimentIDs); long[] searchExperimentIDs);
/** /**
* Logs current user out. * Logs current user out.
......
...@@ -71,6 +71,12 @@ class ProteomicsDataApiFacade implements IProteomicsDataApiFacade ...@@ -71,6 +71,12 @@ class ProteomicsDataApiFacade implements IProteomicsDataApiFacade
dataSetType); dataSetType);
} }
public void processDataSets(String userID, String dataSetProcessingKey,
List<String> dataSetCodes)
{
service.processDataSets(sessionToken, userID, dataSetProcessingKey, dataSetCodes);
}
public List<Project> listProjects(String userID) public List<Project> listProjects(String userID)
{ {
Map<String, Set<Role>> namedRoleSets = generalInfoService.listNamedRoleSets(sessionToken); Map<String, Set<Role>> namedRoleSets = generalInfoService.listNamedRoleSets(sessionToken);
......
...@@ -146,6 +146,13 @@ public class ProteomicsDataServiceInternal extends AbstractServer<IProteomicsDat ...@@ -146,6 +146,13 @@ public class ProteomicsDataServiceInternal extends AbstractServer<IProteomicsDat
processDataSets(session, dataSetProcessingKey, dataSetCodes, parameterBindings); processDataSets(session, dataSetProcessingKey, dataSetCodes, parameterBindings);
} }
public void processDataSets(String sessionToken, String dataSetProcessingKey,
List<String> dataSetCodes)
{
Session session = getSession(sessionToken);
processDataSets(session, dataSetProcessingKey, dataSetCodes, new HashMap<String, String>());
}
public List<Experiment> listSearchExperiments(String sessionToken) public List<Experiment> listSearchExperiments(String sessionToken)
{ {
checkSession(sessionToken); checkSession(sessionToken);
......
...@@ -55,6 +55,14 @@ class ProteomicsDataServiceInternalLogger extends AbstractServerLogger implement ...@@ -55,6 +55,14 @@ class ProteomicsDataServiceInternalLogger extends AbstractServerLogger implement
numberOfDataSets, dataSetType); numberOfDataSets, dataSetType);
} }
public void processDataSets(String sessionToken, String dataSetProcessingKey,
List<String> dataSetCodes)
{
logAccess(sessionToken, "process_data_sets",
"DSS_PROCESSING_PLUGIN(%s) NUMBER_OF_DATA_SETS(%s)", dataSetProcessingKey,
dataSetCodes.size());
}
public List<Experiment> listSearchExperiments(String sessionToken) public List<Experiment> listSearchExperiments(String sessionToken)
{ {
logAccess(sessionToken, "list_search_experiments"); logAccess(sessionToken, "list_search_experiments");
......
...@@ -212,6 +212,20 @@ public class ProteomicsDataService extends AbstractServer<IProteomicsDataService ...@@ -212,6 +212,20 @@ public class ProteomicsDataService extends AbstractServer<IProteomicsDataService
} }
} }
public void processDataSets(String sessionToken, String userID, String dataSetProcessingKey,
List<String> dataSetCodes)
{
checkSession(sessionToken);
SessionContextDTO session = login(userID);
try
{
service.processDataSets(session.getSessionToken(), dataSetProcessingKey, dataSetCodes);
} finally
{
service.logout(session.getSessionToken());
}
}
public List<ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.dto.Experiment> listSearchExperiments( public List<ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.dto.Experiment> listSearchExperiments(
String sessionToken, String userID) String sessionToken, String userID)
{ {
......
...@@ -65,6 +65,14 @@ class ProteomicsDataServiceLogger extends AbstractServerLogger implements IProte ...@@ -65,6 +65,14 @@ class ProteomicsDataServiceLogger extends AbstractServerLogger implements IProte
userID, dataSetProcessingKey, numberOfDataSets, dataSetType); userID, dataSetProcessingKey, numberOfDataSets, dataSetType);
} }
public void processDataSets(String sessionToken, String userID, String dataSetProcessingKey,
List<String> dataSetCodes)
{
logAccess(sessionToken, "process_data_sets",
"USER_ID(%s) DSS_PROCESSING_PLUGIN(%s) DATA_SETS(%s)", userID,
dataSetProcessingKey, dataSetCodes);
}
public List<Experiment> listSearchExperiments(String sessionToken, String userID) public List<Experiment> listSearchExperiments(String sessionToken, String userID)
{ {
logAccess(sessionToken, "list_search_experiments"); logAccess(sessionToken, "list_search_experiments");
......
...@@ -21,8 +21,10 @@ import java.util.List; ...@@ -21,8 +21,10 @@ import java.util.List;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import ch.systemsx.cisd.openbis.generic.shared.IServer; import ch.systemsx.cisd.openbis.generic.shared.IServer;
import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.AuthorizationGuard;
import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.ReturnValueFilter; import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.ReturnValueFilter;
import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.RolesAllowed; import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.RolesAllowed;
import ch.systemsx.cisd.openbis.generic.shared.authorization.predicate.DataSetCodeCollectionPredicate;
import ch.systemsx.cisd.openbis.generic.shared.authorization.validator.ExperimentValidator; import ch.systemsx.cisd.openbis.generic.shared.authorization.validator.ExperimentValidator;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Experiment; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Experiment;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.RoleWithHierarchy; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.RoleWithHierarchy;
...@@ -45,11 +47,19 @@ public interface IProteomicsDataServiceInternal extends IServer ...@@ -45,11 +47,19 @@ public interface IProteomicsDataServiceInternal extends IServer
@ReturnValueFilter(validatorClass = RawDataSampleValidator.class) @ReturnValueFilter(validatorClass = RawDataSampleValidator.class)
public List<MsInjectionSample> listRawDataSamples(String sessionToken); public List<MsInjectionSample> listRawDataSamples(String sessionToken);
@Deprecated
@Transactional(readOnly = true) @Transactional(readOnly = true)
@RolesAllowed(RoleWithHierarchy.SPACE_USER) @RolesAllowed(RoleWithHierarchy.SPACE_USER)
public void processRawData(String sessionToken, String dataSetProcessingKey, public void processRawData(String sessionToken, String dataSetProcessingKey,
long[] rawDataSampleIDs, String dataSetType); long[] rawDataSampleIDs, String dataSetType);
@Transactional(readOnly = true)
@RolesAllowed(RoleWithHierarchy.SPACE_USER)
public void processDataSets(
String sessionToken,
String dataSetProcessingKey,
@AuthorizationGuard(guardClass = DataSetCodeCollectionPredicate.class) List<String> dataSetCodes);
@Transactional(readOnly = true) @Transactional(readOnly = true)
@RolesAllowed(RoleWithHierarchy.SPACE_USER) @RolesAllowed(RoleWithHierarchy.SPACE_USER)
@ReturnValueFilter(validatorClass = ExperimentValidator.class) @ReturnValueFilter(validatorClass = ExperimentValidator.class)
......
...@@ -80,10 +80,21 @@ public interface IProteomicsDataService extends IRpcService ...@@ -80,10 +80,21 @@ public interface IProteomicsDataService extends IRpcService
* for the specified user. Implementations should check that the specified user is allowed to * for the specified user. Implementations should check that the specified user is allowed to
* read specified samples. * read specified samples.
*/ */
@Deprecated
@Transactional(readOnly = true) @Transactional(readOnly = true)
@RolesAllowed(RoleWithHierarchy.INSTANCE_OBSERVER) @RolesAllowed(RoleWithHierarchy.INSTANCE_OBSERVER)
public void processingRawData(String sessionToken, String userID, String dataSetProcessingKey, public void processingRawData(String sessionToken, String userID, String dataSetProcessingKey,
long[] rawDataSampleIDs, String dataSetType); long[] rawDataSampleIDs, String dataSetType);
/**
* Processes the specified data sets by the DSS processing plug-in of specified key for the
* specified user. Implementations should check that the specified user is allowed to read
* specified data sets.
*/
@Transactional(readOnly = true)
@RolesAllowed(RoleWithHierarchy.INSTANCE_OBSERVER)
public void processDataSets(String sessionToken, String userID, String dataSetProcessingKey,
List<String> dataSetCodes);
/** /**
* Returns all experiments of type <tt>MS_SEARCH</tt> which the specified user is allowed to * Returns all experiments of type <tt>MS_SEARCH</tt> which the specified user is allowed to
......
...@@ -56,7 +56,7 @@ public class MsInjectionCopierTest extends AbstractFileSystemTestCase ...@@ -56,7 +56,7 @@ public class MsInjectionCopierTest extends AbstractFileSystemTestCase
private static final String SAMPLE_CODE = "my-sample"; private static final String SAMPLE_CODE = "my-sample";
private static final DataSetType DATA_SET_TYPE = new DataSetType("MY"); private static final DataSetType DATA_SET_TYPE = new DataSetType("MY");
private static final String DATA_SET_CODE = "my-dataset-123"; private static final String DATA_SET_CODE = "my-dataset-123";
private static final String FOLDER_NAME = SAMPLE_CODE + "_" + DATA_SET_CODE + "_" + DATA_SET_TYPE.getCode(); private static final String FOLDER_NAME = DATA_SET_CODE;
private static final String DATA = "hello test"; private static final String DATA = "hello test";
private Mockery context; private Mockery context;
...@@ -139,8 +139,7 @@ public class MsInjectionCopierTest extends AbstractFileSystemTestCase ...@@ -139,8 +139,7 @@ public class MsInjectionCopierTest extends AbstractFileSystemTestCase
assertEquals(Status.OK, status); assertEquals(Status.OK, status);
File copiedDataSet = File copiedDataSet =
new File(destination, MsInjectionCopier.SAMPLE_UNKNOWN + "_" + DATA_SET_CODE + "_" new File(destination, DATA_SET_CODE);
+ DATA_SET_TYPE.getCode());
assertEquals(true, copiedDataSet.isDirectory()); assertEquals(true, copiedDataSet.isDirectory());
context.assertIsSatisfied(); context.assertIsSatisfied();
......
...@@ -122,23 +122,23 @@ public class ProteomicsDataApiFacadeTest extends AssertJUnit ...@@ -122,23 +122,23 @@ public class ProteomicsDataApiFacadeTest extends AssertJUnit
assertSame(result, facade.listRawDataSamples("user1")); assertSame(result, facade.listRawDataSamples("user1"));
context.assertIsSatisfied(); context.assertIsSatisfied();
} }
@Test @Test
public void testProcessingRawData() public void testProcessDataSets()
{ {
context.checking(new Expectations() context.checking(new Expectations()
{ {
{ {
one(proteomicsDataService).processingRawData(SESSION_TOKEN, "user1", "key", one(proteomicsDataService).processDataSets(SESSION_TOKEN, "user1", "key",
new long[42], "type"); Arrays.asList("ds1", "ds2"));
} }
}); });
facade.processingRawData("user1", "key", new long[42], "type"); facade.processDataSets("user1", "key", Arrays.asList("ds1", "ds2"));
context.assertIsSatisfied(); context.assertIsSatisfied();
} }
@Test @Test
public void testListProjectsButNoUserRoles() public void testListProjectsButNoUserRoles()
{ {
......
...@@ -126,17 +126,13 @@ public class ProteomicsDataServiceInternalTest extends AbstractServerTestCase ...@@ -126,17 +126,13 @@ public class ProteomicsDataServiceInternalTest extends AbstractServerTestCase
} }
@Test @Test
public void testCopyRawData() public void testProcessDataSets()
{ {
prepareGetSession(); prepareGetSession();
prepareListRawDataSamples(1L, 2L, 3L, 42L);
final long[] ids = new long[]
{ 2 };
HashMap<String, String> parameterBindings = new HashMap<String, String>(); HashMap<String, String> parameterBindings = new HashMap<String, String>();
parameterBindings.put("ds-21-child", "s-2"); prepareProcessDataSets(SESSION, parameterBindings, "ds1", "ds2");
prepareProcessDataSets(SESSION, parameterBindings, "ds-21-child");
service.processRawData(SESSION_TOKEN, COPY_PROCESSING_KEY, ids, "dt-0"); service.processDataSets(SESSION_TOKEN, COPY_PROCESSING_KEY, Arrays.asList("ds1", "ds2"));
context.assertIsSatisfied(); context.assertIsSatisfied();
} }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package ch.systemsx.cisd.openbis.plugin.phosphonetx.server; package ch.systemsx.cisd.openbis.plugin.phosphonetx.server.api.v1;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -261,14 +261,14 @@ public class ProteomicsDataServiceTest extends AbstractServerTestCase ...@@ -261,14 +261,14 @@ public class ProteomicsDataServiceTest extends AbstractServerTestCase
} }
@Test @Test
public void testCopyRawDataForUnknownUser() public void testProcessDataSetsForUnknownUser()
{ {
prepareGetSession(); prepareGetSession();
prepareLoginLogout(null); prepareLoginLogout(null);
try try
{ {
service.processingRawData(SESSION_TOKEN, "abc", null, new long[0], null); service.processDataSets(SESSION_TOKEN, "abc", null, Arrays.asList("ds1"));
fail("UserFailureException expected"); fail("UserFailureException expected");
} catch (UserFailureException ex) } catch (UserFailureException ex)
{ {
...@@ -279,19 +279,18 @@ public class ProteomicsDataServiceTest extends AbstractServerTestCase ...@@ -279,19 +279,18 @@ public class ProteomicsDataServiceTest extends AbstractServerTestCase
} }
@Test @Test
public void testCopyRawData() public void testProcessDataSets()
{ {
prepareGetSession(); prepareGetSession();
prepareLoginLogout(session2); prepareLoginLogout(session2);
final long[] ids = new long[] {42};
context.checking(new Expectations() context.checking(new Expectations()
{ {
{ {
one(internalService).processRawData(session2.getSessionToken(), "dsp1", ids, "my-type"); one(internalService).processDataSets(session2.getSessionToken(), "dsp1", Arrays.asList("ds1"));
} }
}); });
service.processingRawData(SESSION_TOKEN, "abc", "dsp1", ids, "my-type"); service.processDataSets(SESSION_TOKEN, "abc", "dsp1", Arrays.asList("ds1"));
context.assertIsSatisfied(); context.assertIsSatisfied();
} }
......
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