Skip to content

Commit

Permalink
changed flow
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinoAvonEFSA committed Feb 27, 2018
1 parent e7bc796 commit a9e0406
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 61 deletions.
5 changes: 3 additions & 2 deletions src/amend_manager/DatasetComparisonDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ public void add(DatasetComparison comp) {
stmt.executeUpdate();
}
catch (SQLException e) {
e.printStackTrace();
LOGGER.error("Cannot add a new dataset comparison=" + comp, e);

//e.printStackTrace();
//LOGGER.error("Cannot add a new dataset comparison=" + comp, e);
}
}

Expand Down
43 changes: 32 additions & 11 deletions src/amend_manager/ReportImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,15 @@ public abstract class ReportImporter {
* @param versionField name of the field which contains the dataset version
* using the format value.version, as FR1704.01 (senderDatasetId.version)
*/
public ReportImporter(DatasetList datasetVersions,
String rowIdField, String versionField, IReportService reportService,
public ReportImporter(String rowIdField, String versionField, IReportService reportService,
ITableDaoService daoService) {

this.processedDatasets = 1;

this.datasetVersions = datasetVersions;
this.rowIdField = rowIdField;
this.versionField = versionField;
this.daoService = daoService;
this.reportService = reportService;

// get the sender id of the dataset versions
if (!datasetVersions.isEmpty()) {
senderDatasetId = datasetVersions.get(0).getDecomposedSenderId();
}
else {
throw new IllegalArgumentException("Cannot import an empty dataset list");
}
}

/**
Expand Down Expand Up @@ -123,6 +113,18 @@ private Dataset download(Dataset dataset) throws XMLStreamException, IOException
return populatedDataset;
}

public void setDatasetVersions(DatasetList datasetVersions) {
this.datasetVersions = datasetVersions;

// get the sender id of the dataset versions
if (!datasetVersions.isEmpty()) {
senderDatasetId = datasetVersions.get(0).getDecomposedSenderId();
}
else {
throw new IllegalArgumentException("Cannot import an empty dataset list");
}
}

/**
* Import an entire report (composed of several dataset versions)
* The amendment is also managed here
Expand Down Expand Up @@ -222,6 +224,25 @@ public void importReport() throws DetailedSOAPException, XMLStreamException, IOE
LOGGER.info("Report downloader ended for report=" + senderDatasetId);
}

/**
* Import a dataset from an .xml file. Note that amendments are not processed
* with this method, therefore it can be used only with the first
* version of a report.
* @param file
* @throws XMLStreamException
* @throws IOException
* @throws FormulaException
* @throws ParseException
*/
public void importFirstDatasetVersion(File file) throws XMLStreamException, IOException,
FormulaException, ParseException {

this.importDatasetFile(file);
Dataset d = reportService.datasetFromFile(file);
importDatasetMetadata(d);
this.createLocalReport();
}

/**
* Import a single dataset version into the database
* @param dataset
Expand Down
5 changes: 5 additions & 0 deletions src/formula/ColumnFormula.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,9 @@ public String solve(TableRow row) throws FormulaException {

return solvedFormula;
}

@Override
public String toString() {
return "column=" + columnId + "; formula=" + formula + "; fieldType=" + fieldType;
}
}
4 changes: 2 additions & 2 deletions src/formula/Formula.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ public String solve() throws FormulaException {
}

private void print(String value, String header) {
//if (column.equals("sampArea") && fieldHeader.equals("mandatory"))
//LOGGER.debug("Solving formula=" + value + " Solving formulas=" + header);
//if (column.equals("contextId") && fieldHeader.equals("labelFormula"))
// LOGGER.debug("Solving formula=" + value + " Solving formulas=" + header);

//if ((column.equals("sampAnId")) && fieldHeader.equals("labelFormula"))
// System.out.println("column " + column + " " + header + " => " + value);
Expand Down
3 changes: 3 additions & 0 deletions src/i18n_messages/rcl_messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ ack.invalid=ERR804: The status is not valid, found status %s1.
# ack log KO but no log errors found
ack.ko.no.errors=ERR806: Refresh status failed. Unknown error occurred. Please contact %s1.

# s1: ack error
ack.discarded=ERR807: The message was discarded with the following error: %s1

ack.processing=WARN500: Dataset still in processing.

# s1: error
Expand Down
99 changes: 55 additions & 44 deletions src/providers/ReportService.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import ack.DcfAck;
import ack.IDcfAckLog;
import ack.MessageValResCode;
import amend_manager.ReportXmlBuilder;
import app_config.AppPaths;
import app_config.BooleanValue;
Expand Down Expand Up @@ -736,51 +737,47 @@ public Message refreshStatus(Report report) {
return m;
}

// if ack is ready then check if the report status
// is the same as the one in the get dataset list
if (ack.isReady()) {
if (!ack.isReady()) {
// warn the user, the ack cannot be retrieved yet
String title = Messages.get("warning.title");
String message = Messages.get("ack.processing");
int style = SWT.ICON_INFORMATION;
Message m = Warnings.create(title, message, style);
m.setCode("WARN500");
return m;
}

IDcfAckLog log = ack.getLog();

boolean discarded = ack.getLog().getMessageValResCode() == MessageValResCode.DISCARDED;

// if discarded or KO
if (discarded || !log.isOk()) {

IDcfAckLog log = ack.getLog();
// mark status as failed
RCLDatasetStatus failedStatus = RCLDatasetStatus.getFailedVersionOf(
report.getRCLStatus());

if (failedStatus != null) {
report.setStatus(failedStatus);

// permanently save data
daoService.update(report);
}

// if TRXOK
if (log.isOk()) {
if (discarded) {

this.updateStatusWithAck(report, ack);
String title = Messages.get("error.title");
String message = Messages.get("ack.discarded",
ack.getLog().getMessageValResText());

RCLDatasetStatus status = RCLDatasetStatus
.fromDcfStatus(log.getDatasetStatus());
int style = SWT.ICON_ERROR;
Message m = Warnings.create(title, message, style);
m.setCode("ERR807");

// if no dataset retrieved for the current report
if (!status.existsInDCF()) {

// warn the user, the ack cannot be retrieved yet
String title = Messages.get("success.title");
String message = Messages.get("ack.invalid",
status.getLabel());
int style = SWT.ICON_ERROR;

Message m = Warnings.create(title, message, style);
m.setCode("ERR804");

return m;
}

return alignReportStatusWithDCF(report);
return m;
}
else {

// mark the status of the report accordingly
// since the refresh status discovered a TRXKO ack
RCLDatasetStatus failedStatus = RCLDatasetStatus.getFailedVersionOf(
report.getRCLStatus());

if (failedStatus != null) {
report.setStatus(failedStatus);

// permanently save data
daoService.update(report);
}

else if (!log.isOk()) {

// errors
if (log.hasErrors()) {
Expand All @@ -799,16 +796,30 @@ public Message refreshStatus(Report report) {
}
}
}
else {

// here log can only be OK

this.updateStatusWithAck(report, ack);

RCLDatasetStatus status = RCLDatasetStatus
.fromDcfStatus(log.getDatasetStatus());

// if no dataset retrieved for the current report
if (!status.existsInDCF()) {

// warn the user, the ack cannot be retrieved yet
String title = Messages.get("warning.title");
String message = Messages.get("ack.processing");
int style = SWT.ICON_INFORMATION;
String title = Messages.get("error.title");
String message = Messages.get("ack.invalid",
status.getLabel());
int style = SWT.ICON_ERROR;

Message m = Warnings.create(title, message, style);
m.setCode("WARN500");
m.setCode("ERR804");

return m;
}

return alignReportStatusWithDCF(report);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/report/Report.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public RCLDatasetStatus getRCLStatus() {
}

public void setStatus(String status) {
this.put(AppPaths.REPORT_PREVIOUS_STATUS, this.getRCLStatus().getLabel());
this.put(AppPaths.REPORT_PREVIOUS_STATUS, this.getRCLStatus().getStatus());
this.put(AppPaths.REPORT_STATUS, status);
}

Expand Down
7 changes: 6 additions & 1 deletion src/table_database/TableDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,12 @@ public TableRow getByResultSet(TableSchema schema, ResultSet rs, boolean solveFo
}
else {

String value = rs.getString(column.getId());
String value = null;

try {
value = rs.getString(column.getId());
}
catch(SQLException e) {}

// if no value go to the next field
if (value == null)
Expand Down

0 comments on commit a9e0406

Please sign in to comment.