Skip to content
Snippets Groups Projects
Commit 64121072 authored by jakubs's avatar jakubs
Browse files

SSDM-2276: add cache of many entities for data set registrations in entity operations

SVN: 34799
parent d2872fef
No related branches found
No related tags found
No related merge requests found
...@@ -120,7 +120,7 @@ public class DataBO extends AbstractDataSetBusinessObject implements IDataBO ...@@ -120,7 +120,7 @@ public class DataBO extends AbstractDataSetBusinessObject implements IDataBO
if (dataSetId instanceof DataSetCodeId) if (dataSetId instanceof DataSetCodeId)
{ {
DataSetCodeId codeId = (DataSetCodeId) dataSetId; DataSetCodeId codeId = (DataSetCodeId) dataSetId;
return getDataDAO().tryToFindDataSetByCode(codeId.getCode()); return tryToFindDataSetByCode(codeId.getCode());
} else if (dataSetId instanceof DataSetTechIdId) } else if (dataSetId instanceof DataSetTechIdId)
{ {
DataSetTechIdId techIdId = (DataSetTechIdId) dataSetId; DataSetTechIdId techIdId = (DataSetTechIdId) dataSetId;
...@@ -297,11 +297,11 @@ public class DataBO extends AbstractDataSetBusinessObject implements IDataBO ...@@ -297,11 +297,11 @@ public class DataBO extends AbstractDataSetBusinessObject implements IDataBO
{ {
for (String parentCode : parentDataSetCodes) for (String parentCode : parentDataSetCodes)
{ {
DataPE parent = this.getCache().getParentDataSets().get(parentCode); DataPE parent = this.getCache().getDataSets().get(parentCode);
if (parent == null) if (parent == null)
{ {
parent = getOrCreateData(parentCode, experiment, sample); parent = getOrCreateData(parentCode, experiment, sample);
this.getCache().getParentDataSets().put(parentCode, parent); this.getCache().getDataSets().put(parentCode, parent);
} }
parentsToAdd.add(parent); parentsToAdd.add(parent);
} }
...@@ -544,7 +544,7 @@ public class DataBO extends AbstractDataSetBusinessObject implements IDataBO ...@@ -544,7 +544,7 @@ public class DataBO extends AbstractDataSetBusinessObject implements IDataBO
assert dataSetCode != null : "Unspecified parent data set code."; assert dataSetCode != null : "Unspecified parent data set code.";
final IDataDAO dataDAO = getDataDAO(); final IDataDAO dataDAO = getDataDAO();
DataPE result = dataDAO.tryToFindDataSetByCode(dataSetCode); DataPE result = tryToFindDataSetByCode(dataSetCode);
if (result == null) if (result == null)
{ {
result = new DataPE(); result = new DataPE();
...@@ -560,6 +560,17 @@ public class DataBO extends AbstractDataSetBusinessObject implements IDataBO ...@@ -560,6 +560,17 @@ public class DataBO extends AbstractDataSetBusinessObject implements IDataBO
return result; return result;
} }
private DataPE tryToFindDataSetByCode(final String dataSetCode)
{
DataPE dataSet = this.getCache().getDataSets().get(dataSetCode);
if (dataSet == null)
{
dataSet = getDataDAO().tryToFindDataSetByCode(dataSetCode);
this.getCache().getDataSets().put(dataSetCode, dataSet);
}
return dataSet;
}
@Override @Override
public void save() throws UserFailureException public void save() throws UserFailureException
{ {
...@@ -567,7 +578,7 @@ public class DataBO extends AbstractDataSetBusinessObject implements IDataBO ...@@ -567,7 +578,7 @@ public class DataBO extends AbstractDataSetBusinessObject implements IDataBO
IDataDAO dataDAO = getDataDAO(); IDataDAO dataDAO = getDataDAO();
String dataCode = data.getCode(); String dataCode = data.getCode();
DataPE placeholder = dataDAO.tryToFindDataSetByCode(dataCode); DataPE placeholder = tryToFindDataSetByCode(dataCode);
if (placeholder == null) if (placeholder == null)
{ {
dataDAO.createDataSet(data, findPerson()); dataDAO.createDataSet(data, findPerson());
......
...@@ -55,11 +55,11 @@ public class DataSetRegistrationCache ...@@ -55,11 +55,11 @@ public class DataSetRegistrationCache
private Map<EntityTypePE, List<EntityTypePropertyTypePE>> entityTypePropertyTypes = new HashMap<>(); private Map<EntityTypePE, List<EntityTypePropertyTypePE>> entityTypePropertyTypes = new HashMap<>();
private Map<String, DataPE> parentDataSets = new HashMap<>(); private Map<String, DataPE> dataSets = new HashMap<>();
public Map<String, DataPE> getParentDataSets() public Map<String, DataPE> getDataSets()
{ {
return parentDataSets; return dataSets;
} }
public Map<EntityTypePE, List<EntityTypePropertyTypePE>> getEntityTypePropertyTypes() public Map<EntityTypePE, List<EntityTypePropertyTypePE>> getEntityTypePropertyTypes()
......
...@@ -509,6 +509,13 @@ public class DataBOTest extends AbstractBOTest ...@@ -509,6 +509,13 @@ public class DataBOTest extends AbstractBOTest
final DataPE data = new DataPE(); final DataPE data = new DataPE();
data.setCode(COMPONENT_CODE); data.setCode(COMPONENT_CODE);
data.setExperiment(createExperiment("EXP1", "S2")); data.setExperiment(createExperiment("EXP1", "S2"));
context.checking(new Expectations()
{
{
allowing(dataDAO).tryToFindDataSetByCode(COMPONENT_CODE);
will(returnValue(data));
}
});
IDataBO dataBO = createDataBO(); IDataBO dataBO = createDataBO();
NewContainerDataSet newData = createContainerDataSetWithComponents(COMPONENT_CODE); NewContainerDataSet newData = createContainerDataSetWithComponents(COMPONENT_CODE);
...@@ -518,9 +525,6 @@ public class DataBOTest extends AbstractBOTest ...@@ -518,9 +525,6 @@ public class DataBOTest extends AbstractBOTest
context.checking(new Expectations() context.checking(new Expectations()
{ {
{ {
one(dataDAO).tryToFindDataSetByCode(COMPONENT_CODE);
will(returnValue(data));
one(relationshipService).assignDataSetToContainer(with(EXAMPLE_SESSION), with(data), with(conatinerMatcher)); one(relationshipService).assignDataSetToContainer(with(EXAMPLE_SESSION), with(data), with(conatinerMatcher));
} }
}); });
...@@ -532,9 +536,6 @@ public class DataBOTest extends AbstractBOTest ...@@ -532,9 +536,6 @@ public class DataBOTest extends AbstractBOTest
context.checking(new Expectations() context.checking(new Expectations()
{ {
{ {
one(dataDAO).tryToFindDataSetByCode(COMPONENT_CODE);
will(returnValue(data));
one(relationshipService).assignDataSetToContainer(with(EXAMPLE_SESSION), with(data), with(conatinerMatcher2)); one(relationshipService).assignDataSetToContainer(with(EXAMPLE_SESSION), with(data), with(conatinerMatcher2));
} }
}); });
......
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