Requirements - https://
...
folio-org.
...
atlassian.
...
net/browse/MODORDSTOR-34
In order to proceed with this story we need to come up with a solution on how to generate unique sequential numbers for PO Lines.
Namely, PO lines might be added in parallel by several users and we may have several instances of the module running. So implementing it without a mechanism to guarantee uniqueness in these conditions, there is a risk to end up with duplicate numbers. The things are further complicated by the fact that we need to keep separate sequence per Order.
...
In order to verify that SEQUENCE is supported in the FOLIO environment, the following code was run from within a unit test:
Code Block | ||
---|---|---|
| ||
PostgresClient dbClient = PostgresClient.getInstance(vertx, "test_tenant"); |
...
CompletableFuture<ResultSet> selectCompleted = new CompletableFuture<>(); |
...
String sql = "CREATE SEQUENCE ponumber_seq; SELECT * FROM SETVAL('ponumber_seq',13);SELECT * FROM NEXTVAL('ponumber_seq');"; |
...
dbClient.select(sql, result -> { |
...
...
if(result.succeeded()) { |
...
...
logger.info("--- mod-vendors-test: Result success!!! "); |
...
selectCompleted.complete(result.result()); |
...
}
else {
...
} else { logger.info("--- mod-vendors-test: Result failure!!!"); |
...
selectCompleted.completeExceptionally(result.cause()); |
...
...
} |
...
}); |
...
ResultSet results = selectCompleted.get(5, TimeUnit.SECONDS); |
...
JsonObject mismatchedRowCount = results.toJson(); |
...
logger.info("--- mod-vendors-test: Finished SQL call ... " + mismatchedRowCount); |
The output:
INFO: --- mod-vendors-test: Finished SQL call ... {"columnNames":["nextval"],"numColumns":1,"numRows":1,"results":[[14]],"rows":[{"nextval":14}]}
...