Skip to content

Commit

Permalink
added some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinoAvonEFSA committed Mar 13, 2018
1 parent 82efc86 commit dd9c259
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 25 deletions.
1 change: 0 additions & 1 deletion src/dataset/DatasetList.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ public DatasetList getDownloadableDatasetsLatestVersions(String validSenderIdPat
public DatasetList getDownloadableDatasets(String validSenderIdPattern) {

Collection<RCLDatasetStatus> statusFilter = new ArrayList<>();
statusFilter.add(RCLDatasetStatus.REJECTED_EDITABLE);
statusFilter.add(RCLDatasetStatus.REJECTED);
statusFilter.add(RCLDatasetStatus.PROCESSING);
statusFilter.add(RCLDatasetStatus.DELETED);
Expand Down
2 changes: 1 addition & 1 deletion src/formula/Formula.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private void print(String value, String header) {
//if (column.equals("contextId") && fieldHeader.equals("labelFormula"))
// LOGGER.debug("Solving formula=" + value + " Solving formulas=" + header);

//if ((column.equals("sampAnId")) && fieldHeader.equals("labelFormula"))
//if ((column.equals("tseIndexCase")) && fieldHeader.equals("codeFormula"))
// System.out.println("column " + column + " " + header + " => " + value);
//System.out.println("TIME for " + header + " => "
// + (System.currentTimeMillis() - debugTime)/1000.00 + " seconds");
Expand Down
8 changes: 4 additions & 4 deletions src/formula/FormulaSolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ public ArrayList<Formula> solveAll(String fieldHeader) throws FormulaException {

// solve the formula and get the resolved text
String solvedFormula = formula.solve();

// skip if no value is found
if (solvedFormula == null || solvedFormula.isEmpty())
if (solvedFormula == null)
continue;
row.update(formula, fieldHeader);

row.update(formula.getColumn(), solvedFormula, fieldHeader);

// save solved formula
solvedFormulas.add(formula);
Expand Down
1 change: 0 additions & 1 deletion src/table_dialog/TableEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ private void setRowValue(Object arg0, Object value) {
break;

case PICKLIST:

Selection sel = (Selection) value;
TableCell newSelection = new TableCell(sel);
row.put(column.getId(), newSelection);
Expand Down
15 changes: 13 additions & 2 deletions src/table_skeleton/TableCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public TableCell(Selection sel) {
this.code = sel.getCode();
this.label = sel.getDescription();
this.changed = true;

if (code == null)
code = "";

if (label == null)
label = "";
}


Expand All @@ -40,8 +46,13 @@ public void setCode(String code) {
// empty code means that we do not
// need the field => we set the label
// as code
if (code == null || code.isEmpty())
this.code = label;
if (code == null || code.isEmpty()) {

if (label != null)
this.code = label;
else
this.code = "";
}

this.changed = true;
}
Expand Down
38 changes: 22 additions & 16 deletions src/table_skeleton/TableRow.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,38 +400,44 @@ public void initialize() {
* @param f
* @param fieldHeader
*/
public void update(Formula f, String fieldHeader) {
public void update(TableColumn col, String value, String fieldHeader) {

// skip editable columns
if (f.getColumn().isEditable(this))
if (col.isEditable(this))
return;

XlsxHeader h = XlsxHeader.fromString(fieldHeader);

if (h == null)
return;

TableCell colVal = this.get(f.getColumn().getId());

// if no value found, initialize
if (colVal == null)
colVal = new TableCell();

if (h == XlsxHeader.CODE_FORMULA && !f.getSolvedFormula().isEmpty()) {
colVal.setCode(f.getSolvedFormula());
if (h == XlsxHeader.CODE_FORMULA && !col.getCodeFormula().isEmpty()) {

if (value.isEmpty())
this.put(col.getId(), new TableCell());
else
this.put(col.getId(), value);
}
else if (h == XlsxHeader.LABEL_FORMULA && !f.getSolvedFormula().isEmpty()) {
colVal.setLabel(f.getSolvedFormula());
else if (h == XlsxHeader.LABEL_FORMULA && !col.getLabelFormula().isEmpty()) {


TableCell colVal = this.get(col.getId());

// if no value found, initialize
if (colVal == null)
colVal = new TableCell();

colVal.setLabel(value);

// if the field has not a code formula and it is not a pick-list, then
// update the code using the label
if (!f.getColumn().isPicklist() && f.getColumn().getCodeFormula().isEmpty())
colVal.setCode(f.getSolvedFormula());
if (!col.isPicklist() && col.getCodeFormula().isEmpty())
colVal.setCode(value);

this.put(col.getId(), colVal);
}
else // else do nothing
return;

this.put(f.getColumn().getId(), colVal);
}

/**
Expand Down

0 comments on commit dd9c259

Please sign in to comment.