Search in sources :

Example 46 with Release

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

the class OfflineAwardRowImporter method createReleaseFromReleaseRow.

@Override
public Release createReleaseFromReleaseRow(final String[] row) throws ParseException {
    Release release = repository.findByPlanningBidNo(getRowCell(row, 0));
    if (release == null) {
        release = newReleaseFromAwardFactory(getRowCell(row, 0));
    }
    if (release.getTender() == null) {
        VNTender tender = new VNTender();
        tender.setId(release.getOcid());
        release.setTender(tender);
    }
    release.getTender().getSubmissionMethod().add(Tender.SubmissionMethod.written);
    VNAward award = new VNAward();
    award.setId(release.getOcid() + "-award-" + release.getAwards().size());
    release.getAwards().add(award);
    award.setTitle(getRowCell(row, 1));
    if (getRowCell(row, 2) != null) {
        Amount value = new Amount();
        value.setCurrency("VND");
        value.setAmount(getDecimal(getRowCell(row, 2)));
        award.setValue(value);
    }
    Organization supplier = null;
    if (getRowCell(row, 3) != null) {
        supplier = organizationRepository.findByName(getRowCellUpper(row, 3));
        if (supplier == null) {
            supplier = OrganizationRepositoryUtil.newAndInsertOrganization(Organization.OrganizationType.supplier, getRowCellUpper(row, 3), organizationRepository);
        } else {
            supplier = OrganizationRepositoryUtil.ensureOrgIsOfTypeAndSave(supplier, Organization.OrganizationType.supplier, organizationRepository);
        }
    }
    award.setStatus("Y".equals(getRowCell(row, 5)) ? Award.Status.active : Award.Status.unsuccessful);
    // active=successful awards have suppliers
    if (supplier != null && Award.Status.active.equals(award.getStatus())) {
        award.getSuppliers().add(supplier);
    }
    award.setContractTime(getRowCell(row, 4));
    award.setIneligibleYN(getRowCell(row, 6));
    award.setIneligibleRson(getRowCell(row, 7));
    award.setBidType(getInteger(getRowCell(row, 8)));
    award.setBidSuccMethod(getInteger(getRowCell(row, 9)));
    Organization supplierOrganization = supplier;
    Detail detail = null;
    if (supplierOrganization != null && getRowCell(row, 10) != null) {
        Amount value2 = new Amount();
        value2.setCurrency("VND");
        value2.setAmount(getDecimal(getRowCell(row, 10)));
        VNTendererOrganization tendererOrganization = new VNTendererOrganization(supplier);
        tendererOrganization.setBidValue(value2);
        supplierOrganization = tendererOrganization;
        detail = newBidDetailFromAwardData(getRowCell(row, 0), value2, supplier);
    }
    if (getRowCell(row, 12) != null) {
        award.setDate(getExcelDate(getRowCell(row, 12)));
        award.setPublishedDate(getExcelDate(getRowCell(row, 12)));
    }
    if (getRowCell(row, 11) != null) {
        award.setAlternateDate(getExcelDate(getRowCell(row, 11)));
        detail.setDate(award.getAlternateDate());
    }
    // tenderers
    if (supplierOrganization != null) {
        release.getTender().getTenderers().add(supplierOrganization);
    }
    release.getTender().setNumberOfTenderers(release.getTender().getTenderers().size());
    if (detail != null) {
        release.getBids().getDetails().add(detail);
    }
    // copy items from tender
    award.getItems().addAll(release.getTender().getItems());
    checkForAwardOutliers(release, award);
    return release;
}
Also used : VNTendererOrganization(org.devgateway.ocvn.persistence.mongo.dao.VNTendererOrganization) Organization(org.devgateway.ocds.persistence.mongo.Organization) VNTendererOrganization(org.devgateway.ocvn.persistence.mongo.dao.VNTendererOrganization) Amount(org.devgateway.ocds.persistence.mongo.Amount) VNTender(org.devgateway.ocvn.persistence.mongo.dao.VNTender) VNAward(org.devgateway.ocvn.persistence.mongo.dao.VNAward) Release(org.devgateway.ocds.persistence.mongo.Release) Detail(org.devgateway.ocds.persistence.mongo.Detail)

Example 47 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 48 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 49 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 50 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)

Aggregations

Release (org.devgateway.ocds.persistence.mongo.Release)68 Test (org.junit.Test)44 File (java.io.File)22 AbstractMongoTest (org.devgateway.toolkit.persistence.mongo.AbstractMongoTest)20 ReleasePackage (org.devgateway.ocds.persistence.mongo.ReleasePackage)12 Amount (org.devgateway.ocds.persistence.mongo.Amount)9 JsonNode (com.fasterxml.jackson.databind.JsonNode)6 ProcessingMessage (com.github.fge.jsonschema.core.report.ProcessingMessage)6 BigDecimal (java.math.BigDecimal)6 Award (org.devgateway.ocds.persistence.mongo.Award)6 OcdsSchemaValidatorService (org.devgateway.ocds.persistence.mongo.spring.OcdsSchemaValidatorService)6 JsonImport (org.devgateway.ocds.persistence.mongo.spring.json.JsonImport)6 ReleaseJsonImport (org.devgateway.ocds.persistence.mongo.spring.json.ReleaseJsonImport)6 AbstractWebTest (org.devgateway.toolkit.web.AbstractWebTest)6 MvcResult (org.springframework.test.web.servlet.MvcResult)6 Budget (org.devgateway.ocds.persistence.mongo.Budget)5 Contract (org.devgateway.ocds.persistence.mongo.Contract)4 Planning (org.devgateway.ocds.persistence.mongo.Planning)4 VNPlanning (org.devgateway.ocvn.persistence.mongo.dao.VNPlanning)4 VNTender (org.devgateway.ocvn.persistence.mongo.dao.VNTender)4