diff --git a/compat/tablesSchema.1.2.8.xlsx b/compat/tablesSchema.1.2.8.xlsx new file mode 100644 index 0000000..a8d5365 Binary files /dev/null and b/compat/tablesSchema.1.2.8.xlsx differ diff --git a/config/appConfig.xml b/config/appConfig.xml index 15928f4..6e909fe 100644 --- a/config/appConfig.xml +++ b/config/appConfig.xml @@ -3,8 +3,8 @@ Application configuration EFSA TSE data reporting tool -1.2.7 -1.2.7 +1.2.8 +1.2.8 app-icon.png zoonoses_support@efsa.europa.eu diff --git a/config/proxyConfig.xml b/config/proxyConfig.xml deleted file mode 100644 index 833bd8b..0000000 --- a/config/proxyConfig.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - -tmgproxy.efsa.eu.int -8080 -NO_PROXY - diff --git a/config/tablesSchema.xlsx b/config/tablesSchema.xlsx index 4ce5ec6..a8d5365 100644 Binary files a/config/tablesSchema.xlsx and b/config/tablesSchema.xlsx differ diff --git a/src/tse_analytical_result/ResultDialog.java b/src/tse_analytical_result/ResultDialog.java index c368bf9..d3c0c6f 100644 --- a/src/tse_analytical_result/ResultDialog.java +++ b/src/tse_analytical_result/ResultDialog.java @@ -41,29 +41,29 @@ /** * Class which allows adding and editing a summarized information report. + * * @author avonva * @author shahaal * */ public class ResultDialog extends TableDialogWithMenu { - + static final Logger LOGGER = LogManager.getLogger(ResultDialog.class); - + private RestoreableWindow window; private static final String WINDOW_CODE = "AnalyticalResult"; - + private TseReportService reportService; private ITableDaoService daoService; private Report report; private SummarizedInfo summInfo; private CaseReport caseInfo; - - public ResultDialog(Shell parent, Report report, SummarizedInfo summInfo, - CaseReport caseInfo, TseReportService reportService, ITableDaoService daoService, - IFormulaService formulaService) { - + + public ResultDialog(Shell parent, Report report, SummarizedInfo summInfo, CaseReport caseInfo, + TseReportService reportService, ITableDaoService daoService, IFormulaService formulaService) { + super(parent, TSEMessages.get("result.title"), true, false); - + this.report = report; this.summInfo = summInfo; this.caseInfo = caseInfo; @@ -71,148 +71,136 @@ public ResultDialog(Shell parent, Report report, SummarizedInfo summInfo, this.daoService = daoService; // create the dialog super.create(); - + this.window = new RestoreableWindow(getDialog(), WINDOW_CODE); boolean restored = window.restore(TSERestoreableWindowDao.class); window.saveOnClosure(TSERestoreableWindowDao.class); - + // add 300 px in height if (!restored) addHeight(300); - + setEditorListener(new EditorListener() { - + @Override - public void editStarted() {} - - @SuppressWarnings("unlikely-arg-type") + public void editStarted() { + } + @Override public void editEnded(TableRow row, TableColumn field, boolean changed) { - - // update the base term and the result value if - // the test aim was changed - if (changed && (field.getId().equals(CustomStrings.TEST_AIM_COL) - || field.getId().equals(CustomStrings.AN_METH_CODE_COL))) { - - // if genotyping set base term - if (row.getCode(CustomStrings.AN_METH_CODE_COL).equals(CustomStrings.AN_METH_CODE_GENOTYPING) - && !summInfo.getCode(CustomStrings.SUMMARIZED_INFO_TYPE) - .equals(CustomStrings.SUMMARIZED_INFO_BSEOS_TYPE)) { - - try { - - PredefinedResultService r = new PredefinedResultService(daoService, formulaService); - - PredefinedResult predRes = r.getPredefinedResult(summInfo, caseInfo); - row.put(CustomStrings.PARAM_CODE_BASE_TERM_COL, - predRes.get(PredefinedResultHeader.GENOTYPING_BASE_TERM)); - - } catch (IOException e) { - e.printStackTrace(); - LOGGER.error("Cannot fill results field=" - + CustomStrings.PARAM_CODE_BASE_TERM_COL + " using the predefined results", e); - } - } - else { - if (!row.getCode(CustomStrings.TEST_AIM_COL).isEmpty()) - PredefinedResultService.addParamAndResult(row, row.getCode(field.getId())); + //if a change is made on the row + if (changed) { + + // reset the testaim and the anmethcode if anmethtype is changed + if (field.getId().equals(CustomStrings.AN_METH_TYPE_COL)) { + row.initialize(CustomStrings.TEST_AIM_COL); + row.initialize(CustomStrings.AN_METH_CODE_COL); } - } - - // reset the aim of the test if the test type is changed - //shahaal here I should put the default value (empty obj) - if (changed && field.equals(CustomStrings.AN_METH_TYPE_COL)) { - - TableRow completeRow = getPanelBuilder().getTable().getCompleteRow(row.getDatabaseId()); - completeRow.remove(CustomStrings.TEST_AIM_COL); - completeRow.remove(CustomStrings.AN_METH_CODE_COL); - row.remove(CustomStrings.TEST_AIM_COL); - row.remove(CustomStrings.AN_METH_CODE_COL); + // update the baseterm and the result value if testaim changes + if (field.getId().equals(CustomStrings.TEST_AIM_COL) || + field.getId().equals(CustomStrings.AN_METH_CODE_COL)) { - completeRow.update(); + // if genotyping set base term + if (row.getCode(CustomStrings.AN_METH_CODE_COL).equals(CustomStrings.AN_METH_CODE_GENOTYPING) + && !summInfo.getCode(CustomStrings.SUMMARIZED_INFO_TYPE) + .equals(CustomStrings.SUMMARIZED_INFO_BSEOS_TYPE)) { + + try { + PredefinedResultService r = new PredefinedResultService(daoService, formulaService); + PredefinedResult predRes = r.getPredefinedResult(summInfo, caseInfo); + + row.put(CustomStrings.PARAM_CODE_BASE_TERM_COL, + predRes.get(PredefinedResultHeader.GENOTYPING_BASE_TERM)); + + } catch (IOException e) { + LOGGER.error("Cannot fill results field=" + CustomStrings.PARAM_CODE_BASE_TERM_COL + + " using the predefined results", e); + } + } else if (!row.getCode(CustomStrings.TEST_AIM_COL).isEmpty()) + PredefinedResultService.addParamAndResult(row, row.getCode(CustomStrings.TEST_AIM_COL)); + } } } }); - + updateUI(); } - + public void askForDefault() { - + // create default if no results are present - if (!reportService.hasChildren(caseInfo, TableSchemaList.getByName(CustomStrings.RESULT_SHEET)) - && isEditable() && !this.summInfo.isBSEOS()) { + if (!reportService.hasChildren(caseInfo, TableSchemaList.getByName(CustomStrings.RESULT_SHEET)) && isEditable() + && !this.summInfo.isBSEOS()) { // for RGT create directly the record if (!this.summInfo.isRGT()) { - int val = Warnings.warnUser(getDialog(), TSEMessages.get("warning.title"), - TSEMessages.get("result.confirm.default"), - SWT.YES | SWT.NO | SWT.ICON_QUESTION); - + int val = Warnings.warnUser(getDialog(), TSEMessages.get("warning.title"), + TSEMessages.get("result.confirm.default"), SWT.YES | SWT.NO | SWT.ICON_QUESTION); + LOGGER.info("Add default results to the list? " + (val == SWT.YES)); - + if (val == SWT.NO) return; } - + try { - + TableRowList results = reportService.createDefaultResults(report, summInfo, caseInfo); this.setRows(results); - + // warn user only if not RGT if (!this.summInfo.isRGT()) { - warnUser(TSEMessages.get("warning.title"), - TSEMessages.get("result.check.default"), + warnUser(TSEMessages.get("warning.title"), TSEMessages.get("result.check.default"), SWT.ICON_WARNING); } LOGGER.info("Default results created"); - + } catch (IOException e) { e.printStackTrace(); - LOGGER.error("Cannot create predefined results for case with sampId=" - + caseInfo.getCode(CustomStrings.SAMPLE_ID_COL), e); + LOGGER.error("Cannot create predefined results for case with sampId=" + + caseInfo.getCode(CustomStrings.SAMPLE_ID_COL), e); } } } - + /** * make table non editable if needed */ private void updateUI() { - + LOGGER.info("Updating GUI"); - + DialogBuilder panel = getPanelBuilder(); String status = report.getLabel(AppPaths.REPORT_STATUS); RCLDatasetStatus datasetStatus = RCLDatasetStatus.fromString(status); boolean editableReport = datasetStatus.isEditable(); panel.setTableEditable(editableReport); panel.setRowCreatorEnabled(editableReport); - + LOGGER.info("GUI updated"); } /** * Create a new row with default values + * * @param element * @return - * @throws IOException + * @throws IOException */ @Override public TableRow createNewRow(TableSchema schema, Selection element) { - + LOGGER.info("Creating a new result"); - + TableRow row = new TableRow(schema); - + Relation.injectParent(report, row); Relation.injectParent(summInfo, row); Relation.injectParent(caseInfo, row); - + return row; } @@ -233,46 +221,45 @@ public Collection loadInitialRows(TableSchema schema, TableRow parentF @Override public void processNewRow(TableRow row) { - + TableRowList results = this.getRows(); - + if (results.size() <= 1) return; - + int max = Integer.MIN_VALUE; - - for (TableRow result: results) { - + + for (TableRow result : results) { + if (result.getDatabaseId() == row.getDatabaseId()) continue; - + String seq = result.getLabel(CustomStrings.AN_PORT_SEQ_COL); - + int candidateMax; - + try { candidateMax = Integer.valueOf(seq); - } - catch(NumberFormatException e) { + } catch (NumberFormatException e) { e.printStackTrace(); candidateMax = 0; } - + if (candidateMax > max) max = candidateMax; } row.put(CustomStrings.AN_PORT_SEQ_COL, max + 1); - + daoService.update(row); this.refresh(row); } - + @Override public RowValidatorLabelProvider getValidator() { return new ResultValidator(); } - + @Override public Menu createMenu() { Menu menu = super.createMenu(); @@ -283,28 +270,28 @@ public Menu createMenu() { @Override public void addWidgets(DialogBuilder viewer) { - + String sampleId = caseInfo.getLabel(CustomStrings.SAMPLE_ID_COL); String animalId = caseInfo.getLabel(CustomStrings.ANIMAL_ID_COL); String caseId = caseInfo.getLabel(CustomStrings.NATIONAL_CASE_ID_COL); - + String sampleIdRow = TSEMessages.get("result.sample.id", sampleId); String animalIdRow = TSEMessages.get("result.animal.id", animalId); String caseIdRow = TSEMessages.get("result.case.id", caseId); - - viewer.addHelp(TSEMessages.get("result.help.title")) - .addRowCreator(TSEMessages.get("result.add.record")) - .addComposite("labelsComp", new GridLayout(1, false), null); - + + viewer.addHelp(TSEMessages.get("result.help.title")).addRowCreator(TSEMessages.get("result.add.record")) + .addComposite("labelsComp", new GridLayout(1, false), null); + if (!sampleId.isEmpty()) viewer.addLabelToComposite("sampLabel", sampleIdRow.toString(), "labelsComp"); - + if (!animalId.isEmpty()) viewer.addLabelToComposite("animalLabel", animalIdRow.toString(), "labelsComp"); - + if (!caseId.isEmpty()) viewer.addLabelToComposite("caseIdLabel", caseIdRow.toString(), "labelsComp"); - - viewer.addTable(CustomStrings.RESULT_SHEET, true, report, summInfo, caseInfo); // add parent to be able to solve isVisible field + + viewer.addTable(CustomStrings.RESULT_SHEET, true, report, summInfo, caseInfo); // add parent to be able to solve + // isVisible field } } diff --git a/src/tse_config/DebugConfig.java b/src/tse_config/DebugConfig.java index 05e465f..2241916 100644 --- a/src/tse_config/DebugConfig.java +++ b/src/tse_config/DebugConfig.java @@ -1,7 +1,7 @@ package tse_config; public class DebugConfig { - public static boolean debug = false; + public static boolean debug = true; public static boolean disableMainPanel = false; public static boolean disableFileFuncs = false; diff --git a/target/classes/appConfig.xml b/target/classes/appConfig.xml index 15928f4..6e909fe 100644 --- a/target/classes/appConfig.xml +++ b/target/classes/appConfig.xml @@ -3,8 +3,8 @@ Application configuration EFSA TSE data reporting tool -1.2.7 -1.2.7 +1.2.8 +1.2.8 app-icon.png zoonoses_support@efsa.europa.eu diff --git a/target/classes/proxyConfig.xml b/target/classes/proxyConfig.xml deleted file mode 100644 index 833bd8b..0000000 --- a/target/classes/proxyConfig.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - -tmgproxy.efsa.eu.int -8080 -NO_PROXY - diff --git a/target/classes/tablesSchema.xlsx b/target/classes/tablesSchema.xlsx index 4ce5ec6..a8d5365 100644 Binary files a/target/classes/tablesSchema.xlsx and b/target/classes/tablesSchema.xlsx differ diff --git a/target/classes/tse_analytical_result/ResultDialog$1.class b/target/classes/tse_analytical_result/ResultDialog$1.class index c0b99c3..d8f5511 100644 Binary files a/target/classes/tse_analytical_result/ResultDialog$1.class and b/target/classes/tse_analytical_result/ResultDialog$1.class differ diff --git a/target/classes/tse_analytical_result/ResultDialog.class b/target/classes/tse_analytical_result/ResultDialog.class index 86143aa..05794f3 100644 Binary files a/target/classes/tse_analytical_result/ResultDialog.class and b/target/classes/tse_analytical_result/ResultDialog.class differ