Skip to content
Snippets Groups Projects
Commit 8caed4ce authored by gakin's avatar gakin
Browse files

SSDM-1825 CORE: Warning on deleting samples with

SVN: 34002
parent b0742d8b
No related branches found
No related tags found
No related merge requests found
...@@ -56,6 +56,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.IC ...@@ -56,6 +56,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.IC
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.IDisposableComponent; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.IDisposableComponent;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.listener.OpenEntityDetailsTabHelper; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.listener.OpenEntityDetailsTabHelper;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.IDataRefreshCallback; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.IDataRefreshCallback;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.EntityDeletionConfirmationUtils;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedActionWithResult; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedActionWithResult;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDirectlyConnectedController; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDirectlyConnectedController;
...@@ -598,50 +599,16 @@ public class SampleBrowserGrid extends AbstractEntityGrid<Sample> ...@@ -598,50 +599,16 @@ public class SampleBrowserGrid extends AbstractEntityGrid<Sample>
new AbstractAsyncCallback<List<SampleChildrenInfo>>(viewContext) new AbstractAsyncCallback<List<SampleChildrenInfo>>(viewContext)
{ {
@Override @Override
protected void process(List<SampleChildrenInfo> sampleChildrenInfo) protected void process(List<SampleChildrenInfo> sampleChildrenInfoList)
{ {
int samplesWithChildren = 0; String additionalMessage = null;
int samplesWithDataSets = 0; if(sampleChildrenInfoList.size() == 1)
final int MAX_DISPLAY_SIZE = 10; {
additionalMessage = EntityDeletionConfirmationUtils.getMessageForSingleSample(sampleChildrenInfoList.get(0));
Set<String> samplesWithChildrenToDisplay = new HashSet<String>();
Set<String> samplesWithDataSetsToDisplay = new HashSet<String>();
for(SampleChildrenInfo info: sampleChildrenInfo) {
if(info.getChildCount() > 0) {
samplesWithChildren++;
if(samplesWithChildren <= MAX_DISPLAY_SIZE) {
samplesWithChildrenToDisplay.add(techIdsToSampleIds.get(info.getSampleIdentifier()));
}
}
if(info.getDataSetCount() > 0) {
samplesWithDataSets++;
if(samplesWithDataSets <= MAX_DISPLAY_SIZE) {
samplesWithDataSetsToDisplay.add(techIdsToSampleIds.get(info.getSampleIdentifier()));
}
}
} }
String additionalMessage=""; else {
if(samplesWithChildren > 0) { additionalMessage = EntityDeletionConfirmationUtils.getMessageForMultipleSamples(sampleChildrenInfoList, techIdsToSampleIds);
additionalMessage += "<br>There are " + samplesWithChildren + " sample(s) with children samples, these relationships will be broken but the children will remain:<br>"; }
for(String sample : samplesWithChildrenToDisplay) {
additionalMessage += "<br>" + sample;
}
if(samplesWithChildren > MAX_DISPLAY_SIZE) {
additionalMessage += "<br>and " + (samplesWithChildren-MAX_DISPLAY_SIZE) + " more";
}
additionalMessage += "<br>";
}
if(samplesWithDataSets > 0) {
additionalMessage += "<br>There are " + samplesWithDataSets + " sample(s) with data sets, these will be deleted with the sample:<br>";
for(String sample : samplesWithDataSetsToDisplay) {
additionalMessage += "<br>" + sample;
}
if(samplesWithDataSets > MAX_DISPLAY_SIZE) {
additionalMessage += "<br>and " + (samplesWithDataSets-MAX_DISPLAY_SIZE) + " more";
}
additionalMessage += "<br>";
}
new SampleListDeletionConfirmationDialog<TableModelRowWithObject<Sample>>(viewContext.getCommonViewContext(), samples, callback, s, additionalMessage).show();; new SampleListDeletionConfirmationDialog<TableModelRowWithObject<Sample>>(viewContext.getCommonViewContext(), samples, callback, s, additionalMessage).show();;
} }
}; };
......
package ch.systemsx.cisd.openbis.generic.client.web.client.application.util;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SampleChildrenInfo;
public class EntityDeletionConfirmationUtils
{
//return information about selected samples child samples and data sets
public static String getMessageForSingleSample(SampleChildrenInfo sampleChildrenInfo) {
final int MAX_DISPLAY_SIZE = 10;
StringBuffer additionalMessage = new StringBuffer();
StringBuffer sampleSb = new StringBuffer();
StringBuffer dataSetSb = new StringBuffer();
for (String child : sampleChildrenInfo.getDerivedSamples())
{
sampleSb.append("<br>" + child);
}
for (String ds : sampleChildrenInfo.getDataSets())
{
dataSetSb.append("<br>" + ds);
}
if(sampleSb.length() > 0) {
additionalMessage.append("<br>The sample has " + sampleChildrenInfo.getChildCount() + " children samples, these relationships will be broken but the children will remain:");
additionalMessage.append("<br>");
additionalMessage.append(sampleSb);
if(sampleChildrenInfo.getChildCount() > MAX_DISPLAY_SIZE ) {
additionalMessage.append("<br> and " + (sampleChildrenInfo.getChildCount()-MAX_DISPLAY_SIZE) + " more");
}
additionalMessage.append("<br>");
}
if(dataSetSb.length() > 0) {
additionalMessage.append("<br>The sample has " + sampleChildrenInfo.getDataSetCount() + " datasets, these will be deleted with the sample:");
additionalMessage.append("<br>");
additionalMessage.append(dataSetSb);
if(sampleChildrenInfo.getDataSetCount() > MAX_DISPLAY_SIZE) {
additionalMessage.append("<br>and " + (sampleChildrenInfo.getDataSetCount()-MAX_DISPLAY_SIZE) + " more");
}
additionalMessage.append("<br>");
}
return additionalMessage.toString();
}
//return information about the number of samples with child samples and data sets
//and a summary of those
public static String getMessageForMultipleSamples(List<SampleChildrenInfo> sampleChildrenInfo, Map<String, String> techIdsToSampleIds) {
StringBuffer additionalMessage = new StringBuffer();
int samplesWithChildren = 0;
int samplesWithDataSets = 0;
final int MAX_DISPLAY_SIZE = 10;
Set<String> samplesWithChildrenToDisplay = new HashSet<String>();
Set<String> samplesWithDataSetsToDisplay = new HashSet<String>();
for(SampleChildrenInfo info: sampleChildrenInfo) {
if(info.getChildCount() > 0) {
samplesWithChildren++;
if(samplesWithChildren <= MAX_DISPLAY_SIZE) {
samplesWithChildrenToDisplay.add(techIdsToSampleIds.get(info.getSampleIdentifier()));
}
}
if(info.getDataSetCount() > 0) {
samplesWithDataSets++;
if(samplesWithDataSets <= MAX_DISPLAY_SIZE) {
samplesWithDataSetsToDisplay.add(techIdsToSampleIds.get(info.getSampleIdentifier()));
}
}
}
if(samplesWithChildren > 0) {
additionalMessage.append("<br>There are " + samplesWithChildren + " sample(s) with children samples, these relationships will be broken but the children will remain:<br>");
for(String sample : samplesWithChildrenToDisplay) {
additionalMessage.append("<br>" + sample);
}
if(samplesWithChildren > MAX_DISPLAY_SIZE) {
additionalMessage.append("<br>and " + (samplesWithChildren-MAX_DISPLAY_SIZE) + " more");
}
additionalMessage.append("<br>");
}
if(samplesWithDataSets > 0) {
additionalMessage.append("<br>There are " + samplesWithDataSets + " sample(s) with data sets, these will be deleted with the sample:<br>");
for(String sample : samplesWithDataSetsToDisplay) {
additionalMessage.append("<br>" + sample);
}
if(samplesWithDataSets > MAX_DISPLAY_SIZE) {
additionalMessage.append("<br>and " + (samplesWithDataSets-MAX_DISPLAY_SIZE) + " more");
}
additionalMessage.append("<br>");
}
return additionalMessage.toString();
}
}
...@@ -53,6 +53,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.propert ...@@ -53,6 +53,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.propert
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.sample.SampleListDeletionConfirmationDialog; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.sample.SampleListDeletionConfirmationDialog;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.ExternalHyperlink; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.ExternalHyperlink;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.SectionsPanel; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.SectionsPanel;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.EntityDeletionConfirmationUtils;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IMessageProvider; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IMessageProvider;
import ch.systemsx.cisd.openbis.generic.client.web.client.dto.GridRowModels; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.GridRowModels;
...@@ -182,47 +183,16 @@ abstract public class GenericSampleViewer extends AbstractViewerWithVerticalSpli ...@@ -182,47 +183,16 @@ abstract public class GenericSampleViewer extends AbstractViewerWithVerticalSpli
//we need info for just 1 sample/ //we need info for just 1 sample/
List<TechId> sampleIds = new ArrayList<TechId>(Arrays.asList(TechId.create(getOriginalData()))); List<TechId> sampleIds = new ArrayList<TechId>(Arrays.asList(TechId.create(getOriginalData())));
// new ArrayList<TechId>();
// sampleIds.add(TechId.create(getOriginalData()));
viewContext.getCommonService().getSampleChildrenInfo(sampleIds, true, viewContext.getCommonService().getSampleChildrenInfo(sampleIds, true,
new AbstractAsyncCallback<List<SampleChildrenInfo>>(viewContext) new AbstractAsyncCallback<List<SampleChildrenInfo>>(viewContext)
{ {
@Override @Override
protected void process(List<SampleChildrenInfo> info) protected void process(List<SampleChildrenInfo> info)
{ {
final int MAX_INFO_SIZE = 10;
SampleChildrenInfo sampleInfo = info.get(0); SampleChildrenInfo sampleInfo = info.get(0);
additionalMessage.append(EntityDeletionConfirmationUtils.getMessageForSingleSample(sampleInfo));
StringBuffer sampleSb = new StringBuffer();
StringBuffer dataSetSb = new StringBuffer();
for (String child : sampleInfo.getDerivedSamples())
{
sampleSb.append("<br>" + child);
}
for (String ds : sampleInfo.getDataSets())
{
dataSetSb.append("<br>" + ds);
}
if(sampleSb.length() > 0) {
additionalMessage.append("<br>The sample has " + sampleInfo.getChildCount() + " children samples, these relationships will be broken but the children will remain:");
additionalMessage.append("<br>");
additionalMessage.append(sampleSb);
if(sampleInfo.getChildCount() > MAX_INFO_SIZE ) {
additionalMessage.append("<br> and " + (sampleInfo.getChildCount()-MAX_INFO_SIZE) + " more");
}
additionalMessage.append("<br>");
}
if(dataSetSb.length() > 0) {
additionalMessage.append("<br>The sample has " + sampleInfo.getDataSetCount() + " datasets, these will be deleted with the sample:");
additionalMessage.append("<br>");
additionalMessage.append(dataSetSb);
if(sampleInfo.getDataSetCount() > MAX_INFO_SIZE) {
additionalMessage.append("<br>and " + (sampleInfo.getDataSetCount()-MAX_INFO_SIZE) + " more");
}
additionalMessage.append("<br>");
}
new SampleListDeletionConfirmationDialog(getViewContext() new SampleListDeletionConfirmationDialog(getViewContext()
.getCommonViewContext(), getOriginalDataAsSingleton(), callback, .getCommonViewContext(), getOriginalDataAsSingleton(), callback,
getOriginalData(), additionalMessage.toString()).show(); getOriginalData(), additionalMessage.toString()).show();
......
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