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

SSDM-1081 implementing unarchiving of multi data set archiver

SVN: 32711
parent 4cfcdbcd
No related branches found
No related tags found
No related merge requests found
......@@ -22,9 +22,11 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
......@@ -863,6 +865,16 @@ public final class DataSetTable extends AbstractDataSetBusinessObject implements
Map<DataStorePE, List<ExternalDataPE>> datasetsByStore = groupExternalDataByDataStores();
Map<DataStoreWithService, List<ExternalDataPE>> datasetsWithService =
enrichWithService(datasetsByStore);
boolean needRefresh = prepareForUnarchiving(datasetsWithService);
if (needRefresh)
{
datasetsByStore = groupExternalDataByDataStores();
datasetsWithService =
enrichWithService(datasetsByStore);
}
int result =
filterByStatusAndUpdate(datasetsByStore, DataSetArchivingStatus.ARCHIVED,
DataSetArchivingStatus.UNARCHIVE_PENDING);
......@@ -870,6 +882,52 @@ public final class DataSetTable extends AbstractDataSetBusinessObject implements
return result;
}
/**
* Asks datastore servers for the extended list of datasets to unarchive, and reloads itself.
*
* @return true if the reaload of data has happened
*/
private boolean prepareForUnarchiving(Map<DataStoreWithService, List<ExternalDataPE>> datasetsWithService)
{
List<String> result = new LinkedList<String>();
boolean enhancementsFound = false;
for (Entry<DataStoreWithService, List<ExternalDataPE>> entry : datasetsWithService.entrySet())
{
DataStoreWithService dssws = entry.getKey();
DataStorePE dataStore = dssws.dataStore;
IDataStoreService service = dssws.service;
List<ExternalDataPE> datasets = entry.getValue();
if (datasets.isEmpty())
{
continue;
}
List<String> dataSetCodes = new LinkedList<String>();
for (ExternalDataPE data : datasets)
{
dataSetCodes.add(data.getCode());
}
List<String> enhancedCodes = service.getDataSetCodesForUnarchiving(dataStore.getSessionToken(), session.getSessionToken(),
dataSetCodes, tryGetLoggedUserId());
result.addAll(enhancedCodes);
if (new HashSet<String>(enhancedCodes).containsAll(dataSetCodes))
{
enhancementsFound = true;
}
}
if (enhancementsFound)
{
loadByDataSetCodes(result, false, true);
return true;
}
return false;
}
@Override
public int lockDatasets()
{
......
......@@ -127,6 +127,13 @@ public interface IDataStoreService
public void unarchiveDatasets(String sessionToken, String userSessionToken,
List<DatasetDescription> datasets, String userId, String userEmailOrNull);
/**
* Asks arcvhiver to provide an extended list of data sets to unarchive.
*
* @param userId id of user who initiated unarchiving.
*/
public List<String> getDataSetCodesForUnarchiving(String sessionToken, String userSessionToken, List<String> datasets, String userId);
/**
* Gets the link from a service that supports the IReportingPluginTask#createLink method.
*
......
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