-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MODFISTO - 501] - Implement endpoint to save FY finance data in bulk (…
…#439) * [MODFISTO-501] - Implement endpoint to save FY finance data in bulk * Implement endpoint to save FY finance data in bulk * Improved update as a bulk, and added unit tests * Added FinanceDataServiceTest and improvements * minor update * added null check and fixed sonar issue * Remove set of allocated field * Fix test * Fix log * Added ledgerId, ledgerCode, and groupId, groupCode * improved response handling and removed initial allocation field set * Fixed finance_data_view and improved method names * Fixed error response handling
- Loading branch information
Showing
19 changed files
with
576 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule acq-models
updated
7 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,49 @@ | ||
package org.folio.rest.impl; | ||
|
||
|
||
import static io.vertx.core.Future.succeededFuture; | ||
import static org.folio.rest.jaxrs.resource.FinanceStorageFinanceData.PutFinanceStorageFinanceDataResponse.respond204; | ||
|
||
import javax.ws.rs.core.Response; | ||
import java.util.Map; | ||
|
||
import io.vertx.core.AsyncResult; | ||
import io.vertx.core.Context; | ||
import io.vertx.core.Handler; | ||
import io.vertx.core.Vertx; | ||
import org.folio.rest.core.model.RequestContext; | ||
import org.folio.rest.jaxrs.model.FyFinanceData; | ||
import org.folio.rest.jaxrs.model.FyFinanceDataCollection; | ||
import org.folio.rest.jaxrs.resource.FinanceStorageFinanceData; | ||
import org.folio.rest.persist.PgUtil; | ||
import org.folio.rest.util.ResponseUtils; | ||
import org.folio.service.financedata.FinanceDataService; | ||
import org.folio.spring.SpringContextUtil; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
public class FinanceDataApi implements FinanceStorageFinanceData { | ||
|
||
private static final String FINANCE_DATA_VIEW = "finance_data_view"; | ||
|
||
@Autowired | ||
private FinanceDataService financeDataService; | ||
|
||
public FinanceDataApi() { | ||
SpringContextUtil.autowireDependencies(this, Vertx.currentContext()); | ||
} | ||
|
||
@Override | ||
public void getFinanceStorageFinanceData(String query, String totalRecords, int offset, int limit, Map<String, String> okapiHeaders, | ||
Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) { | ||
PgUtil.get(FINANCE_DATA_VIEW, FyFinanceData.class, FyFinanceDataCollection.class, query, offset, limit, | ||
okapiHeaders, vertxContext, GetFinanceStorageFinanceDataResponse.class, asyncResultHandler); | ||
} | ||
|
||
@Override | ||
public void putFinanceStorageFinanceData(FyFinanceDataCollection entity, Map<String, String> okapiHeaders, | ||
Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) { | ||
financeDataService.update(entity, new RequestContext(vertxContext, okapiHeaders)) | ||
.onSuccess(v -> asyncResultHandler.handle(succeededFuture(respond204()))) | ||
.onFailure(ResponseUtils::handleFailure); | ||
} | ||
} |
Oops, something went wrong.