Skip to content

Commit

Permalink
fix: bind variables in familleNormeDao
Browse files Browse the repository at this point in the history
  • Loading branch information
Nolife999 committed Nov 20, 2023
1 parent 16ae5cf commit f59d42f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -946,18 +946,12 @@ private void buildFilterDate(int headerIndex, ArcPreparedStatementBuilder s, Lis
// on découpe suivant les OU
String[] listeOR = conditionAND.split(FILTER_OR);
for (String condtionOR : listeOR) {
s.append(" to_date(" + headersDLabel.get(headerIndex) + "::text, " + s.quoteText(morceauReq[0]) + ")"); // cast
// database
// column
// to
// the
// searched
// date
// format
s.append(" to_date(" + headersDLabel.get(headerIndex) + "::text, " + s.quoteText(morceauReq[0]) + ")");
// cast database column to the searched date format
s.append(condtionOR.trim().substring(0, 1)); // operator
s.append(" to_date(" + s.quoteText(condtionOR.trim().substring(1)) + "," + s.quoteText(morceauReq[0])
+ ") "); // cast condition expression to the
// searched date format
+ ") ");
// cast condition expression to the searched date format
s.append(expressionOR);
}
// on retire les dernier OR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,21 +245,22 @@ public void execQueryDeleteVariableMetier(VObject viewVariableMetier, String idF

public void execQueryAddVariableMetier(VObject viewVariableMetier, String idFamilleSelected) throws ArcException {

StringBuilder query = new StringBuilder();
ArcPreparedStatementBuilder query = new ArcPreparedStatementBuilder();
query.append(addNonExistingVariableMetierWithoutSync(viewVariableMetier));
query.append(
GererFamilleNormeDao.querySynchronizeRegleWithVariableMetier(idFamilleSelected));
UtilitaireDao.get(0).executeBlock(null, query);
UtilitaireDao.get(0).executeRequest(null, query);
}

private static String querySynchronizeRegleWithVariableMetier(String idFamille) {
private static ArcPreparedStatementBuilder querySynchronizeRegleWithVariableMetier(String idFamille) {
StringBuilder requeteListeSupprRegleMapping = requeteListeSupprRegleMapping(idFamille);
StringBuilder requeteListeAddRegleMapping = requeteListeAddRegleMapping(idFamille);

StringBuilder requete = new StringBuilder();
ArcPreparedStatementBuilder requete = new ArcPreparedStatementBuilder();
requete.append(requeteListeAddRegleMapping.toString() + ";\n");
requete.append(requeteListeSupprRegleMapping.toString() + ";");
return requete.toString();

return requete;
}

/**
Expand Down Expand Up @@ -531,8 +532,10 @@ private String addExistingVariableMetierWithoutSync(VObject viewVariableMetier,
* @param message
* @throws ArcException
*/
private String addNonExistingVariableMetierWithoutSync(VObject viewVariableMetier) throws ArcException {
StringBuilder requete = new StringBuilder();
private ArcPreparedStatementBuilder addNonExistingVariableMetierWithoutSync(VObject viewVariableMetier) throws ArcException {

ArcPreparedStatementBuilder requete = new ArcPreparedStatementBuilder();

boolean blank = true;
for (int i = NUMBER_OF_COLUMN_TABLE_VARIABLE_METIER; i < viewVariableMetier.getInputFields().size(); i++) {
if (StringUtils.isNotBlank(viewVariableMetier.getInputFields().get(i))) {
Expand All @@ -547,19 +550,22 @@ private String addNonExistingVariableMetierWithoutSync(VObject viewVariableMetie

checkIsValide(viewVariableMetier.getInputFields());

ArcPreparedStatementBuilder values = new ArcPreparedStatementBuilder();

requete.append("INSERT INTO " + ViewEnum.IHM_MOD_VARIABLE_METIER.getFullName() + " (");
StringBuilder values = new StringBuilder();

for (int j = 0; j < NUMBER_OF_COLUMN_TABLE_VARIABLE_METIER; j++) {
if (j > 0) {
requete.append(", ");
values.append(", ");
}
requete.append(viewVariableMetier.getHeadersDLabel().get(j));
values.append("'" + viewVariableMetier.getInputFields().get(j) + "'::"
+ viewVariableMetier.getHeadersDType().get(j));
values.append(values.quoteText(viewVariableMetier.getInputFields().get(j))+ "::" + viewVariableMetier.getHeadersDType().get(j));
}
requete.append(", nom_table_metier) VALUES ("
+ values.append(", '" + viewVariableMetier.getHeadersDLabel().get(i)) + "'::text);\n");
requete.append(", nom_table_metier) VALUES (");
values.append("," + values.quoteText(viewVariableMetier.getHeadersDLabel().get(i)) + "::text);\n");

requete.append(values);

}
}
Expand All @@ -568,7 +574,7 @@ private String addNonExistingVariableMetierWithoutSync(VObject viewVariableMetie
throw new ArcException(ArcExceptionMessage.GUI_FAMILLENORME_VARIABLE_NO_TARGET_TABLE);
}

return requete.toString();
return requete;
}

/**
Expand Down

0 comments on commit f59d42f

Please sign in to comment.