Search in sources :

Example 6 with Release

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

the class OcdsController method ocdsPackages.

@ApiOperation(value = "Returns all available packages, filtered by the given criteria." + "This will contain the OCDS package information (metadata about publisher) plus the release itself.")
@RequestMapping(value = "/api/ocds/package/all", method = { RequestMethod.POST, RequestMethod.GET }, produces = "application/json")
@JsonView(Views.Public.class)
public List<ReleasePackage> ocdsPackages(@ModelAttribute @Valid final YearFilterPagingRequest releaseRequest) {
    List<Release> ocdsReleases = ocdsReleases(releaseRequest);
    List<ReleasePackage> releasePackages = new ArrayList<>(ocdsReleases.size());
    for (Release release : ocdsReleases) {
        releasePackages.add(createReleasePackage(release));
    }
    return releasePackages;
}
Also used : ReleasePackage(org.devgateway.ocds.persistence.mongo.ReleasePackage) ArrayList(java.util.ArrayList) 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 7 with Release

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

the class EBidAwardRowImporter 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.electronicSubmission);
    VNAward award = new VNAward();
    award.setId(release.getOcid() + "-award-" + release.getAwards().size());
    release.getAwards().add(award);
    Amount value = new Amount();
    value.setCurrency("VND");
    value.setAmount(getDecimal(getRowCell(row, 1)));
    award.setValue(value);
    Organization supplier = organizationRepository.findByAllIds(getRowCellUpper(row, 2));
    if (supplier == null) {
        supplier = OrganizationRepositoryUtil.newAndInsertOrganization(Organization.OrganizationType.supplier, getRowCellUpper(row, 2), organizationRepository);
    } else {
        supplier = OrganizationRepositoryUtil.ensureOrgIsOfTypeAndSave(supplier, Organization.OrganizationType.supplier, organizationRepository);
    }
    Organization supplierOrganization = supplier;
    Detail detail = null;
    if (supplierOrganization != null && getRowCell(row, 1) != null) {
        Amount value2 = new Amount();
        value2.setCurrency("VND");
        value2.setAmount(getDecimal(getRowCell(row, 1)));
        VNTendererOrganization tendererOrganization = new VNTendererOrganization(supplier);
        tendererOrganization.setBidValue(value2);
        supplierOrganization = tendererOrganization;
        detail = newBidDetailFromAwardData(getRowCell(row, 0), value2, supplier);
    }
    award.setStatus("Y".equals(getRowCell(row, 5)) ? Award.Status.active : Award.Status.unsuccessful);
    // active=successful awards have suppliers
    if (Award.Status.active.equals(award.getStatus())) {
        award.getSuppliers().add(supplier);
    }
    award.setContractTime(getRowCell(row, 3));
    award.setBidOpenRank(getInteger(getRowCell(row, 4)));
    award.setIneligibleYN(getRowCell(row, 6));
    award.setIneligibleRson(getRowCell(row, 7));
    if (getRowCell(row, 8) != null) {
        award.setAlternateDate(getExcelDate(getRowCell(row, 8)));
    }
    if (getRowCell(row, 10) != null) {
        award.setDate(getExcelDate(getRowCell(row, 10)));
    }
    if (getRowCell(row, 9) != null) {
        award.setPublishedDate(getExcelDate(getRowCell(row, 9)));
    }
    // tenderers
    if (supplierOrganization != null) {
        release.getTender().getTenderers().add(supplierOrganization);
    }
    if (detail != null) {
        release.getBids().getDetails().add(detail);
    }
    release.getTender().setNumberOfTenderers(release.getTender().getTenderers().size());
    // 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 8 with Release

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

the class ReleaseCompilerService method createSaveCompiledReleaseAndSaveRecord.

public void createSaveCompiledReleaseAndSaveRecord(final Record record) {
    Release compiledRelease = createCompiledRelease(record);
    record.setCompiledRelease(releaseRepository.save(compiledRelease));
    recordRepository.save(record);
}
Also used : Release(org.devgateway.ocds.persistence.mongo.Release)

Example 9 with Release

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

the class ReleaseCompilerService method createCompiledRelease.

protected Release createCompiledRelease(final Record record) {
    // empty records produce null compiled release
    if (record.getReleases().isEmpty()) {
        return null;
    }
    // records with just one release produce a compiled release identical to
    // the one release
    Release left = record.getReleases().get(0);
    if (record.getReleases().size() > 1) {
        // we merge each element of the list to its left partner
        List<Release> subList = record.getReleases().subList(1, record.getReleases().size());
        for (Release right : subList) {
            Release compiled = mergeOcdsBeans(left, right);
            left = compiled;
        }
    }
    // this was purposefully nullified by ocdsOmit
    left.setTag(new ArrayList<Tag>());
    left.getTag().add(Tag.compiled);
    return left;
}
Also used : Tag(org.devgateway.ocds.persistence.mongo.Tag) Release(org.devgateway.ocds.persistence.mongo.Release)

Example 10 with Release

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

the class ReleaseJsonImport method importObject.

@Override
public Release importObject() throws IOException {
    Release release = (Release) releaseJsonToObject.toObject();
    release = releaseRepository.save(release);
    return release;
}
Also used : Release(org.devgateway.ocds.persistence.mongo.Release)

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