Search in sources :

Example 31 with Release

use of org.devgateway.ocds.persistence.mongo.Release in project ocvn by devgateway.

the class OcdsController method ocdsReleases.

/**
     * Returns a list of OCDS Releases, order by Id, using pagination
     *
     * @return the release data
     */
@ApiOperation(value = "Resturns all available releases, filtered by the given criteria.")
@RequestMapping(value = "/api/ocds/release/all", method = { RequestMethod.POST, RequestMethod.GET }, produces = "application/json")
@JsonView(Views.Public.class)
public List<Release> ocdsReleases(@ModelAttribute @Valid final YearFilterPagingRequest releaseRequest) {
    Pageable pageRequest = new PageRequest(releaseRequest.getPageNumber(), releaseRequest.getPageSize(), Direction.ASC, "id");
    List<Release> find = mongoTemplate.find(query(getYearFilterCriteria(releaseRequest, "planning.bidPlanProjectDateApprove").andOperator(getDefaultFilterCriteria(releaseRequest))).with(pageRequest), Release.class);
    return find;
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) Release(org.devgateway.ocds.persistence.mongo.Release) ApiOperation(io.swagger.annotations.ApiOperation) JsonView(com.fasterxml.jackson.annotation.JsonView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 32 with Release

use of org.devgateway.ocds.persistence.mongo.Release in project ocvn by devgateway.

the class ExcelGenerator method getExcelDownload.

/**
     * Method that returns a byte array with excel export.
     *
     * @param filter
     * @return
     * @throws IOException
     */
@Cacheable
public byte[] getExcelDownload(final YearFilterPagingRequest filter) throws IOException {
    PageRequest pageRequest = new PageRequest(filter.getPageNumber(), filter.getPageSize(), Sort.Direction.ASC, "id");
    List<Release> releases = mongoTemplate.find(query(getYearDefaultFilterCriteria(filter, MongoConstants.FieldNames.TENDER_PERIOD_START_DATE)).with(pageRequest), Release.class);
    ExcelFile releaseExcelFile = new ReleaseExportFile(releases);
    Workbook workbook = releaseExcelFile.createWorkbook();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    workbook.write(baos);
    byte[] bytes = baos.toByteArray();
    return bytes;
}
Also used : ReleaseExportFile(org.devgateway.ocds.persistence.mongo.excel.ReleaseExportFile) PageRequest(org.springframework.data.domain.PageRequest) ExcelFile(org.devgateway.ocds.persistence.mongo.excel.ExcelFile) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Release(org.devgateway.ocds.persistence.mongo.Release) Workbook(org.apache.poi.ss.usermodel.Workbook) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 33 with Release

use of org.devgateway.ocds.persistence.mongo.Release in project ocvn by devgateway.

the class OcdsControllerTest method ocdsByProjectId.

@Test
public void ocdsByProjectId() throws Exception {
    final Release release = ocdsController.ocdsByProjectId("SP001");
    Assert.assertNotNull(release);
    Assert.assertEquals("ocds-endpoint-001", release.getOcid());
}
Also used : Release(org.devgateway.ocds.persistence.mongo.Release) Test(org.junit.Test)

Example 34 with Release

use of org.devgateway.ocds.persistence.mongo.Release in project ocvn by devgateway.

the class OcdsControllerTest method ocdsReleases.

@Test
public void ocdsReleases() throws Exception {
    final List<Release> releases = ocdsController.ocdsReleases(new YearFilterPagingRequest());
    Assert.assertEquals(3, releases.size());
}
Also used : YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) Release(org.devgateway.ocds.persistence.mongo.Release) Test(org.junit.Test)

Example 35 with Release

use of org.devgateway.ocds.persistence.mongo.Release in project ocvn by devgateway.

the class OcdsControllerTest method ocdsByOcid.

@Test
public void ocdsByOcid() throws Exception {
    final Release release = ocdsController.ocdsByOcid("ocds-endpoint-001");
    Assert.assertNotNull(release);
    Assert.assertEquals("ocds-endpoint-001-tender", release.getTender().getId());
}
Also used : Release(org.devgateway.ocds.persistence.mongo.Release) Test(org.junit.Test)

Aggregations

Release (org.devgateway.ocds.persistence.mongo.Release)38 Test (org.junit.Test)23 File (java.io.File)12 AbstractMongoTest (org.devgateway.toolkit.persistence.mongo.AbstractMongoTest)10 Amount (org.devgateway.ocds.persistence.mongo.Amount)7 ReleasePackage (org.devgateway.ocds.persistence.mongo.ReleasePackage)6 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 ProcessingMessage (com.github.fge.jsonschema.core.report.ProcessingMessage)4 OcdsSchemaValidatorService (org.devgateway.ocds.persistence.mongo.spring.OcdsSchemaValidatorService)4 JsonImport (org.devgateway.ocds.persistence.mongo.spring.json.JsonImport)4 ReleaseJsonImport (org.devgateway.ocds.persistence.mongo.spring.json.ReleaseJsonImport)4 VNPlanning (org.devgateway.ocvn.persistence.mongo.dao.VNPlanning)4 VNTender (org.devgateway.ocvn.persistence.mongo.dao.VNTender)4 AbstractWebTest (org.devgateway.toolkit.web.AbstractWebTest)4 MvcResult (org.springframework.test.web.servlet.MvcResult)4 BigDecimal (java.math.BigDecimal)3 Award (org.devgateway.ocds.persistence.mongo.Award)3 Budget (org.devgateway.ocds.persistence.mongo.Budget)3 Organization (org.devgateway.ocds.persistence.mongo.Organization)3 JsonView (com.fasterxml.jackson.annotation.JsonView)2