Skip to content

Commit

Permalink
Error Handling for filter expressions longer 72 chars
Browse files Browse the repository at this point in the history
  • Loading branch information
jlolling committed Jan 31, 2023
1 parent 25b1d8c commit 3d23324
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/main/java/de/jlo/talendcomp/sap/impl/TableInputImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

import org.apache.commons.text.StringEscapeUtils;

Expand Down Expand Up @@ -48,6 +49,7 @@ public class TableInputImpl implements TableInput {
private Integer rowCount = null;
private Integer rowSkip = null;
private String functionDescription = null;
private String filter72Separator = "\\";

/**
* Create an instance if TableInput
Expand Down Expand Up @@ -111,12 +113,16 @@ public void execute() throws Exception {
}
JCoParameterList tableParameterList = function.getTableParameterList();
// add where condition
if (filter != null && filter.trim().isEmpty() == false) {
JCoTable tableInputOptions = tableParameterList.getTable("OPTIONS");
tableInputOptions.appendRows(1);
tableInputOptions.firstRow();
tableInputOptions.setValue("TEXT", filter);
tableInputOptions.nextRow();
if (filter != null) {
if (filter.length() > 72) {
throw new Exception("Filter expression: <" + filter + "> is longer than 72 chars. The function does not allows filter expressions longer than 72 chars.");
} else {
JCoTable tableInputOptions = tableParameterList.getTable("OPTIONS");
tableInputOptions.appendRows(1);
tableInputOptions.firstRow();
tableInputOptions.setValue("TEXT", filter);
tableInputOptions.nextRow();
}
}

// add fields
Expand Down Expand Up @@ -240,7 +246,9 @@ public String getWhereCondition() {

@Override
public void setFilter(String whereCondition) {
this.filter = whereCondition;
if (whereCondition != null) {
this.filter = whereCondition.trim();
}
}

@Override
Expand Down

0 comments on commit 3d23324

Please sign in to comment.