use of de.symeda.sormas.api.campaign.data.CampaignFormDataCriteria in project SORMAS-Project by hzi-braunschweig.
the class CampaignDataGrid method setDataProvider.
public void setDataProvider() {
DataProvider<CampaignFormDataIndexDto, CampaignFormDataCriteria> dataProvider = DataProvider.fromFilteringCallbacks(query -> FacadeProvider.getCampaignFormDataFacade().getIndexList(query.getFilter().orElse(null), query.getOffset(), query.getLimit(), query.getSortOrders().stream().map(sortOrder -> new SortProperty(sortOrder.getSorted(), sortOrder.getDirection() == SortDirection.ASCENDING)).collect(Collectors.toList())).stream(), query -> (int) FacadeProvider.getCampaignFormDataFacade().count(query.getFilter().orElse(null)));
setDataProvider(dataProvider);
setSelectionMode(SelectionMode.NONE);
}
use of de.symeda.sormas.api.campaign.data.CampaignFormDataCriteria in project SORMAS-Project by hzi-braunschweig.
the class CampaignFormDataImporter method importDataFromCsvLine.
@Override
protected ImportLineResult importDataFromCsvLine(String[] values, String[] entityClasses, String[] entityProperties, String[][] entityPropertyPaths, boolean firstLine) throws IOException, InterruptedException {
if (values.length > entityProperties.length) {
writeImportError(values, I18nProperties.getValidationError(Validations.importLineTooLong));
return ImportLineResult.ERROR;
}
CampaignFormDataDto campaignFormData = CampaignFormDataDto.build();
campaignFormData.setCreatingUser(userFacade.getCurrentUserAsReference());
try {
insertImportRowIntoData(campaignFormData, values, entityProperties);
campaignFormData.setCampaign(campaignReferenceDto);
CampaignFormDataDto existingData = FacadeProvider.getCampaignFormDataFacade().getExistingData(new CampaignFormDataCriteria().campaign(campaignFormData.getCampaign()).campaignFormMeta(campaignFormData.getCampaignFormMeta()).community(campaignFormData.getCommunity()).formDate(campaignFormData.getFormDate()));
if (existingData != null) {
final CampaignFormDataImportLock lock = new CampaignFormDataImportLock();
synchronized (lock) {
handleDetectedDuplicate(campaignFormData, existingData, lock);
try {
if (!lock.wasNotified) {
lock.wait();
}
} catch (InterruptedException e) {
logger.error("InterruptedException when trying to perform LOCK.wait() in campaign form data import: " + e.getMessage());
throw e;
}
if (lock.similarityChoice == CampaignFormDataSimilarityChoice.CANCEL) {
cancelImport();
return ImportLineResult.SKIPPED;
} else if (lock.similarityChoice == CampaignFormDataSimilarityChoice.SKIP) {
return ImportLineResult.SKIPPED;
} else {
FacadeProvider.getCampaignFormDataFacade().overwriteCampaignFormData(existingData, campaignFormData);
}
}
} else {
FacadeProvider.getCampaignFormDataFacade().saveCampaignFormData(campaignFormData);
}
} catch (ImportErrorException | InvalidColumnException | ValidationRuntimeException e) {
writeImportError(values, e.getLocalizedMessage());
return ImportLineResult.ERROR;
}
return ImportLineResult.SUCCESS;
}
Aggregations