Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
DevSeg committed Dec 4, 2024
1 parent 7de6c1f commit 03475c1
Show file tree
Hide file tree
Showing 26 changed files with 1,529 additions and 713 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ public ImportPopulationDataDialog(InfrastructureType infrastructureType, Campaig

file_ = new File(buffer.getFilename());

startDryRunImport.setVisible(true);
// startDryRunImport.setVisible(false);

startDataImport.setVisible(false);
startDataImport.setVisible(true);

});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
import de.symeda.sormas.api.campaign.CampaignReferenceDto;
import de.symeda.sormas.api.campaign.data.CampaignFormDataCriteria;
import de.symeda.sormas.api.campaign.data.CampaignFormDataDto;
import de.symeda.sormas.api.campaign.data.CampaignFormDataEntry;
import de.symeda.sormas.api.campaign.data.CampaignFormDataIndexDto;
import de.symeda.sormas.api.campaign.form.CampaignFormElement;
import de.symeda.sormas.api.campaign.form.CampaignFormMetaDto;
Expand Down Expand Up @@ -1350,17 +1351,18 @@ public void generateTransposeDataFunctions(HorizontalLayout actionButionLayout,

if (formName.toString().contains("Day 1")) {

DownloadTransposedDaywiseDataUtility downloadTransposedDaywiseDataUtility = new DownloadTransposedDaywiseDataUtility();
transposdeDataAnchor.setHref(downloadTransposedDaywiseDataUtility.createTransposedDataFromIndexList(
DownloadTransposedDaywiseDataUtility downloadTransposedDaywiseICMDataUtility = new DownloadTransposedDaywiseDataUtility();
transposdeDataAnchor.setHref(downloadTransposedDaywiseICMDataUtility.createTransposedDataFromIndexList(
transposedDataCriteria, formName, campaignz.getValue().toString()));
transposdeDataDictionaryAnchor.setHref(downloadTransposedDaywiseDataUtility.createTransposedDataFormExpressions(transposedDataCriteria));
transposdeDataDictionaryAnchor.setHref(downloadTransposedDaywiseICMDataUtility.createTransposedDataFormExpressions(transposedDataCriteria));


} else if (formName.toString().contains("LQAS")) {

DownloadTransposedLqasDataUtility downloadTransposedDaywiseDataUtility = new DownloadTransposedLqasDataUtility();
transposdeDataAnchor.setHref(downloadTransposedDaywiseDataUtility.createTransposedLqasDataFromIndexList(
DownloadTransposedLqasDataUtility downloadTransposedLqasDaywiseDataUtility = new DownloadTransposedLqasDataUtility();
transposdeDataAnchor.setHref(downloadTransposedLqasDaywiseDataUtility.createTransposedLqasDataFromIndexList(
transposedDataCriteria, formName, campaignz.getValue().toString()));
transposdeDataDictionaryAnchor.setHref(downloadTransposedDaywiseDataUtility.createTransposedDataFormExpressions(transposedDataCriteria));
transposdeDataDictionaryAnchor.setHref(downloadTransposedLqasDaywiseDataUtility.createTransposedDataFormExpressions(transposedDataCriteria));

}

Expand Down Expand Up @@ -2243,19 +2245,48 @@ private void setDataProvider() {
public void addCustomColumn(String property, String caption) {
if (!property.toString().contains("readonly")) {
// System.out.println(caption + "_--------------------UUUUUUUUUUUUUUUUUUUUUUUUUUUUu");
grid.addColumn(
e -> e.getFormValues().stream().filter(v -> v.getId().equals(property)).findFirst().orElse(null))
.setHeader(caption)
// createHeaderComponent(caption, caption))
.setFooter(property).setSortProperty(property).setSortable(false).setResizable(true)
.setAutoWidth(true)
.setTooltipGenerator(e -> caption + " : " + e.getFormValues().stream()
.filter(v -> v.getId().equals(property)).findFirst().orElse(null))
.setClassNameGenerator(item -> "full-width-column");
grid.addColumn(e -> {
return removeTrailingDecimal(e.getFormValues().stream()
.filter(v -> v.getId().equals(property))
.findFirst()
.orElse(null));
})
.setHeader(caption)
.setFooter(property)
.setSortProperty(property)
.setSortable(false)
.setResizable(true)
.setAutoWidth(true)
.setTooltipGenerator(e -> caption + " : " +
removeTrailingDecimal(e.getFormValues().stream()
.filter(v -> v.getId().equals(property))
.findFirst()
.orElse(null)))
.setClassNameGenerator(item -> "full-width-column");


// grid.addColumn(
// e -> e.getFormValues().stream().filter(v -> v.getId().equals(property)).findFirst().orElse(null))
// .setHeader(caption)
//// createHeaderComponent(caption, caption))
// .setFooter(property).setSortProperty(property).setSortable(false).setResizable(true)
// .setAutoWidth(true)
// .setTooltipGenerator(e -> caption + " : " + e.getFormValues().stream()
// .filter(v -> v.getId().equals(property)).findFirst().orElse(null))
// .setClassNameGenerator(item -> "full-width-column");

}

}

private String removeTrailingDecimal(CampaignFormDataEntry value) {
String valueCleaned = value == null ? null : value.toString();
if (valueCleaned != null && valueCleaned.endsWith(".0")) {
return valueCleaned.substring(0, valueCleaned.length() - 2);
}
return valueCleaned;
}


public void updateRowCount() {
int numberOfRows = (int) FacadeProvider.getCampaignFormDataFacade().count(criteria);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1479,8 +1479,14 @@ private String getOrderValue(Map<String, String> data, String key) {

public <T extends Component> void setFieldValue(T field, CampaignFormElementType type, Object value,
Map<String, String> options, String defaultvalue, Boolean isErrored, Object defaultErrorMsgr) {



Boolean isExpressionValue = false;
switch (type) {



case YES_NO:

if (value != null) {
Expand Down Expand Up @@ -1532,22 +1538,78 @@ public <T extends Component> void setFieldValue(T field, CampaignFormElementType
// Notification.show("Error found", tempz.toString(),
// Notification.TYPE_TRAY_NOTIFICATION);
}

if (value != null) {

// System.out.println( value + " VALUE FROM FORMBUILDER RANGE +===============");

if (value.toString().equals("")) {
// System.out.println( value + " VALUE FROM FORMBUILDER RANGE +===============IFFFF-----");

// logger.debug("))))))))))))))))))))))))))):setting empty value to nulll --- not sure");
((IntegerField) field).setValue(null);
} else {
((IntegerField) field).setValue(Integer.parseInt(value.toString()));

// System.out.println( value + " VALUE FROM FORMBUILDER RANGE +===============ELSE-----");
String cleanValue = value.toString().replace(".0", "");


System.out.println( value + " VALUE FROM FORMBUILDER RANGE +===============ELSE-----" + cleanValue);


// System.out.println( value + " VALUE FROM FORMBUILDER RANGE +===============ELSE-----");

String cleancleanvalue = value.toString(); // Assuming getValue() retrieves the value as a String
if (cleancleanvalue.endsWith(".0")) {
cleancleanvalue = cleancleanvalue.substring(0, cleancleanvalue.length() - 2); // Remove the ".0"
}

System.out.println( value + " VALUE FROM FORMBUILDER RANGE +===============ELSE-----" + cleancleanvalue);


((IntegerField) field).setValue(Integer.parseInt(cleancleanvalue));
}

} else if (defaultvalue != null) {

// System.out.println( defaultvalue + " defaultvalue FROM FORMBUILDER RANGE +===============ELSE-----");

((IntegerField) field).setValue(Integer.parseInt(defaultvalue));
} else {
// System.out.println( "not nullllllll defaultvalue FROM FORMBUILDER RANGE +===============ELSE-----");
((IntegerField) field).setValue(null);
}


// if (value != null) {
//
// if (value.toString().equals("")) {
// // Set empty value to null
// ((IntegerField) field).setValue(null);
// } else {
// try {
// // Parse the value to a Double to check for decimal or whole number
// double numericValue = Double.parseDouble(value.toString());
//
// // If it's a whole number (e.g., ends with .0), convert to an integer
// if (numericValue % 1 == 0) {
// ((IntegerField) field).setValue((int) numericValue); // Set whole number
// } else {
// // Value is a decimal, round or truncate as per your requirements
// ((IntegerField) field).setValue((int) numericValue); // Truncate decimal part
// }
// } catch (NumberFormatException e) {
// // Handle cases where the value is not a valid number
// System.err.println("Value is not a valid number: " + value);
// ((IntegerField) field).setValue(null); // Set to null for invalid input
// }
// }
// } else if (defaultvalue != null) {
// ((IntegerField) field).setValue(Integer.parseInt(defaultvalue));
// } else {
// ((IntegerField) field).setValue(null);
// }

// ((IntegerField) field).setValue(value != null ?
// Integer.parseInt(value.toString()) : defaultvalue != null ?
// Integer.parseInt(defaultvalue) : null);
Expand All @@ -1563,7 +1625,7 @@ public <T extends Component> void setFieldValue(T field, CampaignFormElementType
}
break;
case NUMBER:

if (value != null) {
String cvalue = value.toString().replace("null", "").trim();
if (cvalue.equals("") || cvalue.equals("null")) {
Expand Down Expand Up @@ -2127,6 +2189,8 @@ public boolean saveFormValues() {
boolean saveChecker = true;
UserProvider userProvider = new UserProvider();
List<CampaignFormDataEntry> entries = getFormValues();



CampaignFormDataEntry lotNo = new CampaignFormDataEntry();
CampaignFormDataEntry lotClusterNo = new CampaignFormDataEntry();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,12 @@ public CampaignFormDataImporter(File inputFile, boolean hasEntityClassRow, UserD
this.campaignDto = campaignDto;
this.userFacade = FacadeProvider.getUserFacade();
}


@Override
public void startImport(File file, Consumer<StreamResource> addErrorReportToLayoutCallback, Consumer<StreamResource> notused,
boolean notUsed, UI currentUI, boolean duplicatesPossible) throws IOException, CsvValidationException {
this.file=file;
this.file=file;
this.currentUI = currentUI;
super.startImport(file, addErrorReportToLayoutCallback, notused, false, currentUI, duplicatesPossible);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ public ImportCampaignsFormDataDialog(CampaignReferenceDto campaignReferenceDto,

upload.addSucceededListener(event -> {
file_ = new File(buffer.getFilename());
startDataImport.setVisible(false);
startImportDryRun.setVisible(true);
startDataImport.setVisible(true);
// startImportDryRun.setVisible(true);

});

Expand All @@ -205,7 +205,8 @@ public ImportCampaignsFormDataDialog(CampaignReferenceDto campaignReferenceDto,

startDataImport.addClickListener(ed -> {
I18nProperties.setUserLanguage(usr.getUser().getLanguage());
startIntervalCallback();
// startIntervalCallback();
resetImportState();
try {

DataImporter importer = new CampaignFormDataImporter(file_, false, userDto, campaignForm.getUuid(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ public ImportAreaDataDialog() {
upload.addSucceededListener(event -> {

file_ = new File(buffer.getFilename());
startDataImport.setVisible(false);
startImportDryRun.setVisible(true);
startDataImport.setVisible(true);
// startImportDryRun.setVisible(true);

});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public ImportClusterDataDialog() {

file_ = new File(buffer.getFilename());
startDataImport.setVisible(false);
startImportDryRun.setVisible(true);
// startImportDryRun.setVisible(true);

});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ public ImportDistrictDataDialog() {
upload.addSucceededListener(event -> {

file_ = new File(buffer.getFilename());
startDataImport.setVisible(false);
startImportDryRun.setVisible(true);
startDataImport.setVisible(true);
// startImportDryRun.setVisible(true);

});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ public ImportProvinceDataDialog() {
upload.addSucceededListener(event -> {

file_ = new File(buffer.getFilename());
startDataImport.setVisible(false);
startImportDryRun.setVisible(true);
startDataImport.setVisible(true);
// startImportDryRun.setVisible(true);

});

Expand Down
Loading

0 comments on commit 03475c1

Please sign in to comment.