Skip to content

Commit

Permalink
* Fixed the bug that set paramCode and paramCodeBase with the value
Browse files Browse the repository at this point in the history
selected on anMethCode when changed from the default records generated
by the tool (in Analytical Res),
* added the anPortSeq also to the default code in the tableSchema.
  • Loading branch information
shahaal authored and shahaal committed Mar 21, 2019
1 parent cb31617 commit 89ddd6c
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 128 deletions.
Binary file added compat/tablesSchema.1.2.8.xlsx
Binary file not shown.
4 changes: 2 additions & 2 deletions config/appConfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<properties>
<comment>Application configuration</comment>
<entry key="Application.Name">EFSA TSE data reporting tool</entry> <!-- main title of the application -->
<entry key="Application.Version">1.2.7</entry> <!-- version of the application that will displayed after the application name -->
<entry key="Db.MinRequiredVersion">1.2.7</entry> <!-- version of the database needed -->
<entry key="Application.Version">1.2.8</entry> <!-- version of the application that will displayed after the application name -->
<entry key="Db.MinRequiredVersion">1.2.8</entry> <!-- version of the database needed -->
<entry key="Application.Icon">app-icon.png</entry> <!-- application icon (in the icon folder) -->

<entry key="TechnicalSupport.Email">[email protected]</entry> <!-- email which will be used for technical support -->
Expand Down
7 changes: 0 additions & 7 deletions config/proxyConfig.xml

This file was deleted.

Binary file modified config/tablesSchema.xlsx
Binary file not shown.
205 changes: 96 additions & 109 deletions src/tse_analytical_result/ResultDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,178 +41,166 @@

/**
* 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;
this.reportService = reportService;
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;
}

Expand All @@ -233,46 +221,45 @@ public Collection<TableRow> 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();
Expand All @@ -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
}
}
2 changes: 1 addition & 1 deletion src/tse_config/DebugConfig.java
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
4 changes: 2 additions & 2 deletions target/classes/appConfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<properties>
<comment>Application configuration</comment>
<entry key="Application.Name">EFSA TSE data reporting tool</entry> <!-- main title of the application -->
<entry key="Application.Version">1.2.7</entry> <!-- version of the application that will displayed after the application name -->
<entry key="Db.MinRequiredVersion">1.2.7</entry> <!-- version of the database needed -->
<entry key="Application.Version">1.2.8</entry> <!-- version of the application that will displayed after the application name -->
<entry key="Db.MinRequiredVersion">1.2.8</entry> <!-- version of the database needed -->
<entry key="Application.Icon">app-icon.png</entry> <!-- application icon (in the icon folder) -->

<entry key="TechnicalSupport.Email">[email protected]</entry> <!-- email which will be used for technical support -->
Expand Down
7 changes: 0 additions & 7 deletions target/classes/proxyConfig.xml

This file was deleted.

Binary file modified target/classes/tablesSchema.xlsx
Binary file not shown.
Binary file modified target/classes/tse_analytical_result/ResultDialog$1.class
Binary file not shown.
Binary file modified target/classes/tse_analytical_result/ResultDialog.class
Binary file not shown.

0 comments on commit 89ddd6c

Please sign in to comment.