Skip to content

Commit

Permalink
fix: wsimport table bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
Nolife999 committed Oct 10, 2023
1 parent 460b0ae commit b10d265
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.apache.logging.log4j.Logger;
import org.json.JSONObject;

import fr.insee.arc.core.dataobjects.ViewEnum;
import fr.insee.arc.core.util.StaticLoggerDispatcher;
import fr.insee.arc.utils.exception.ArcException;
import fr.insee.arc.ws.services.importServlet.actions.SendResponse;
Expand Down Expand Up @@ -34,7 +35,7 @@ public void execute(SendResponse resp) throws ArcException {

try {
// binary transfer
ServiceDao.execQueryExportDataToResponse(resp.getWr(), arcClientIdentifier.getClient(), IS_EXPORT_CSV);
ServiceDao.execQueryExportDataToResponse(resp.getWr(), ViewEnum.normalizeTableName(arcClientIdentifier.getClient()), IS_EXPORT_CSV);
this.clientDao.dropTable(arcClientIdentifier.getClient());

resp.endSending();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public void updatePilotage(String tableSource) throws ArcException {
+ ColumnEnum.ID_SOURCE.getColumnName() + "=T2." + ColumnEnum.ID_SOURCE.getColumnName() + ") ");
query.append("AND T1.phase_traitement='" + TraitementPhase.MAPPING + "';");

UtilitaireDao.get(0).executeBlock(null, query.toString());
UtilitaireDao.get(0).executeBlock(connection, query.toString());
}

/**
Expand Down Expand Up @@ -368,17 +368,19 @@ public void createTableMetier() throws ArcException {
*/
public String getAClientTable(boolean isSourceListTable) throws ArcException {

String normalizedTable = ViewEnum.normalizeTableName(client);
String schema = ManipString.substringBeforeFirst(normalizedTable, ".");
String clientDb = ManipString.substringAfterFirst(normalizedTable, ".").replace("_", "\\_") + "%";
String schema = ManipString.substringBeforeFirst(client, ".");
String tableToFind = ViewEnum.normalizeTableName(ManipString.substringAfterFirst(client, ".").replace("_", "\\_") + "%");

ArcPreparedStatementBuilder requete = new ArcPreparedStatementBuilder();
requete.append("SELECT schemaname||'.'||tablename FROM pg_tables")
.append(" WHERE tablename like " + requete.quoteText(clientDb))
.append(" WHERE tablename like " + requete.quoteText(tableToFind))
.append(" AND schemaname=" + requete.quoteText(schema)).append(" AND tablename "
+ (isSourceListTable ? "" : "NOT") + " like " + requete.quoteText("%id\\_source%"));

return UtilitaireDao.get(0).getString(null, requete);
String selectedTableName = UtilitaireDao.get(0).getString(connection, requete);

return this.client + selectedTableName.substring(this.client.length());

}

public String getAClientTable() throws ArcException {
Expand All @@ -393,7 +395,7 @@ public void dropTable(String clientTable) throws ArcException {
if (StringUtils.isBlank(clientTable)) {
return;
}
UtilitaireDao.get(0).dropTable(null, clientTable);
UtilitaireDao.get(0).dropTable(connection, clientTable);
}

/**
Expand All @@ -410,10 +412,10 @@ public void dropPendingClientTables() throws ArcException {
requete.append(" WHERE tablename like " + requete.quoteText(findClientTable));
requete.append(" AND schemaname = " + requete.quoteText(this.environnement));

List<String> tablesToDrop = new GenericBean(UtilitaireDao.get(0).executeRequest(null, requete))
List<String> tablesToDrop = new GenericBean(UtilitaireDao.get(0).executeRequest(connection, requete))
.getColumnValues(ColumnEnum.TABLE_NAME.getColumnName());

UtilitaireDao.get(0).executeImmediate(null, FormatSQL.dropTable(tablesToDrop.toArray(new String[0])));
UtilitaireDao.get(0).executeImmediate(connection, FormatSQL.dropTable(tablesToDrop.toArray(new String[0])));

}

Expand Down

0 comments on commit b10d265

Please sign in to comment.