Skip to content
Snippets Groups Projects
Commit 9501d749 authored by felmer's avatar felmer
Browse files

SSDM-3768: tag creation moved at the end of the list of creations in order to...

SSDM-3768: tag creation moved at the end of the list of creations in order to allow creation of entities and tags in one transaction.
Bug found: data set and related sample couldn't be updated at the same time. ExecuteOperationsTest.testUpdateDataSetAndRelatedSample introduced which fails because of the bug. Bug fixed by clearing Hibernate session.

SVN: 37550
parent 73612484
No related branches found
No related tags found
No related merge requests found
...@@ -304,6 +304,7 @@ public class OperationsExecutor implements IOperationsExecutor ...@@ -304,6 +304,7 @@ public class OperationsExecutor implements IOperationsExecutor
resultMap.putAll(internalOperationExecutor.execute(context, operations)); resultMap.putAll(internalOperationExecutor.execute(context, operations));
flushCurrentSession(); flushCurrentSession();
clearCurrentSession();
verify(operations, resultMap, context); verify(operations, resultMap, context);
...@@ -401,13 +402,13 @@ public class OperationsExecutor implements IOperationsExecutor ...@@ -401,13 +402,13 @@ public class OperationsExecutor implements IOperationsExecutor
Map<IOperation, IOperationResult> resultMap, IOperationContext context) Map<IOperation, IOperationResult> resultMap, IOperationContext context)
{ {
resultMap.putAll(createVocabularyTermsExecutor.execute(context, operations)); resultMap.putAll(createVocabularyTermsExecutor.execute(context, operations));
resultMap.putAll(createTagsExecutor.execute(context, operations));
resultMap.putAll(createMaterialsExecutor.execute(context, operations)); resultMap.putAll(createMaterialsExecutor.execute(context, operations));
resultMap.putAll(createSpacesExecutor.execute(context, operations)); resultMap.putAll(createSpacesExecutor.execute(context, operations));
resultMap.putAll(createProjectsExecutor.execute(context, operations)); resultMap.putAll(createProjectsExecutor.execute(context, operations));
resultMap.putAll(createExperimentsExecutor.execute(context, operations)); resultMap.putAll(createExperimentsExecutor.execute(context, operations));
resultMap.putAll(createSamplesExecutor.execute(context, operations)); resultMap.putAll(createSamplesExecutor.execute(context, operations));
resultMap.putAll(createDataSetsExecutor.execute(context, operations)); resultMap.putAll(createDataSetsExecutor.execute(context, operations));
resultMap.putAll(createTagsExecutor.execute(context, operations));
} }
private void executeDeletions(List<? extends IOperation> operations, private void executeDeletions(List<? extends IOperation> operations,
......
...@@ -53,6 +53,12 @@ import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.id.CreationId; ...@@ -53,6 +53,12 @@ import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.id.CreationId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.operation.IOperation; import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.operation.IOperation;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.operation.IOperationResult; import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.operation.IOperationResult;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.search.SearchResult; import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.search.SearchResult;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.DataSet;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.fetchoptions.DataSetFetchOptions;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.id.DataSetPermId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.id.IDataSetId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.update.DataSetUpdate;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.update.UpdateDataSetsOperation;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.id.EntityTypePermId; import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.id.EntityTypePermId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.history.PropertyHistoryEntry; import ch.ethz.sis.openbis.generic.asapi.v3.dto.history.PropertyHistoryEntry;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.operation.AsynchronousOperationExecutionOptions; import ch.ethz.sis.openbis.generic.asapi.v3.dto.operation.AsynchronousOperationExecutionOptions;
...@@ -406,6 +412,47 @@ public class ExecuteOperationsTest extends AbstractOperationExecutionTest ...@@ -406,6 +412,47 @@ public class ExecuteOperationsTest extends AbstractOperationExecutionTest
assertEquals(historyEntry.getPropertyName(), "COMMENT"); assertEquals(historyEntry.getPropertyName(), "COMMENT");
assertEquals(historyEntry.getPropertyValue(), "created"); assertEquals(historyEntry.getPropertyValue(), "created");
} }
@Test
public void testUpdateDataSetAndRelatedSample()
{
String sessionToken = v3api.login(TEST_USER, PASSWORD);
DataSetUpdate dataSetUpdate = new DataSetUpdate();
DataSetPermId dataSetId = new DataSetPermId("20081105092159111-1");
dataSetUpdate.setDataSetId(dataSetId);
dataSetUpdate.setProperty("COMMENT", "test data set");
SampleUpdate sampleUpdate = new SampleUpdate();
SamplePermId sampleId = new SamplePermId("200902091219327-1025");
sampleUpdate.setSampleId(sampleId);
sampleUpdate.setProperty("COMMENT", "test comment");
List<? extends IOperation> operations = Arrays.asList(new UpdateDataSetsOperation(dataSetUpdate), new UpdateSamplesOperation(sampleUpdate));
SynchronousOperationExecutionOptions options = new SynchronousOperationExecutionOptions();
SynchronousOperationExecutionResults results = (SynchronousOperationExecutionResults) v3api.executeOperations(sessionToken,
operations, options);
assertEquals(results.getResults().size(), 2);
DataSetFetchOptions dataSetFetchOptions = new DataSetFetchOptions();
dataSetFetchOptions.withProperties();
dataSetFetchOptions.withHistory();
Map<IDataSetId, DataSet> dataSets = v3api.getDataSets(sessionToken, Arrays.asList(dataSetId), dataSetFetchOptions);
assertEquals(dataSets.size(), 1);
DataSet dataSet = dataSets.get(dataSetId);
assertEquals(dataSet.getProperty("COMMENT"), "test data set");
PropertyHistoryEntry historyEntry = (PropertyHistoryEntry) dataSet.getHistory().get(0);
assertEquals(historyEntry.getPropertyName(), "COMMENT");
assertEquals(historyEntry.getPropertyValue(), "no comment");
SampleFetchOptions sampleFetchOptions = new SampleFetchOptions();
sampleFetchOptions.withProperties();
sampleFetchOptions.withHistory();
Map<ISampleId, Sample> samples = v3api.getSamples(sessionToken, Arrays.asList(sampleId), sampleFetchOptions);
assertEquals(samples.size(), 1);
Sample updatedSample = samples.get(sampleId);
assertEquals(updatedSample.getProperty("COMMENT"), "test comment");
historyEntry = (PropertyHistoryEntry) updatedSample.getHistory().get(0);
assertEquals(historyEntry.getPropertyName(), "COMMENT");
assertEquals(historyEntry.getPropertyValue(), "very advanced stuff");
}
@Test @Test
public void testExecuteWithSynchronousOperationThatSucceedsAndExecutionIdNull() public void testExecuteWithSynchronousOperationThatSucceedsAndExecutionIdNull()
......
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