Search in sources :

Example 21 with Release

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

the class RecordRepositoryTest method getRelease1.

private Release getRelease1() {
    final Release release = new Release();
    release.setOcid(ocid);
    final Planning planning = new Planning();
    release.setPlanning(planning);
    final Budget budget = new Budget();
    planning.setBudget(budget);
    final Amount amount = new Amount();
    amount.setAmount(BigDecimal.valueOf(1234));
    amount.setCurrency("VND");
    budget.setAmount(amount);
    budget.setDescription("Some description 1");
    budget.setProject("A nice project! 1");
    budget.setSource("The source! 1");
    final Award award1 = new Award();
    award1.setDescription("Some award1");
    award1.setId("1");
    release.getAwards().add(award1);
    final Award award2 = new Award();
    award2.setDescription("Some award2");
    award2.setId("2");
    release.getAwards().add(award2);
    return release;
}
Also used : Award(org.devgateway.ocds.persistence.mongo.Award) Amount(org.devgateway.ocds.persistence.mongo.Amount) Budget(org.devgateway.ocds.persistence.mongo.Budget) Planning(org.devgateway.ocds.persistence.mongo.Planning) Release(org.devgateway.ocds.persistence.mongo.Release)

Example 22 with Release

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

the class RecordRepositoryTest method testReleaseSaveAndFind.

@Test
public void testReleaseSaveAndFind() {
    final Release release = new Release();
    release.setOcid(ocid);
    releaseRepository.insert(release);
    final Release byOcid = releaseRepository.findByOcid(ocid);
    Assert.assertEquals(ocid, byOcid.getOcid());
}
Also used : Release(org.devgateway.ocds.persistence.mongo.Release) Test(org.junit.Test) AbstractMongoTest(org.devgateway.toolkit.persistence.mongo.AbstractMongoTest)

Example 23 with Release

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

the class TenderRowImporter method createReleaseFromReleaseRow.

@Override
public Release createReleaseFromReleaseRow(final String[] row) throws ParseException {
    Release release = repository.findByPlanningBidNo(getRowCell(row, 0));
    if (release == null) {
        release = new Release();
        release.setOcid(MongoConstants.OCDS_PREFIX + "bidno-" + getRowCell(row, 0));
        release.getTag().add(Tag.tender);
        VNPlanning planning = new VNPlanning();
        release.setPlanning(planning);
        planning.setBidNo(getRowCell(row, 0));
    }
    VNTender tender = (VNTender) release.getTender();
    if (tender == null) {
        tender = new VNTender();
        tender.setId(release.getOcid());
        release.setTender(tender);
    }
    readStatusFromReleaseRow(row, tender);
    tender.setApproveState(getRowCell(row, 1));
    tender.setCancelYN(getRowCell(row, 2));
    tender.setModYn(getRowCell(row, 3));
    tender.setBidMethod(getInteger(getRowCell(row, 4)));
    readProcurementMethodFromReleaseRow(row, tender);
    String contrMethodDetail = getRowCell(row, 6);
    if (contrMethodDetail != null) {
        ContrMethod contrMethod = contrMethodRepository.findByDetails(contrMethodDetail);
        if (contrMethod == null) {
            contrMethod = new ContrMethod();
            contrMethod.setDetails(contrMethodDetail);
            // switch (contrMethodId) {
            // case 1:
            // contrMethod.setDetails("Trọn gói");
            // break;
            // case 2:
            // contrMethod.setDetails("Theo đơn giá");
            // break;
            // case 3:
            // contrMethod.setDetails("Theo thời gian");
            // break;
            // case 4:
            // contrMethod.setDetails("Theo tỷ lệ phần trăm");
            // break;
            // case 5:
            // contrMethod.setDetails("Hỗn hợp");
            // break;
            // default:
            // contrMethod.setDetails("Undefined");
            // break;
            // }
            contrMethod = contrMethodRepository.insert(contrMethod);
        }
        tender.setContrMethod(contrMethod);
    }
    Period period = new Period();
    period.setStartDate(getExcelDate(getRowCell(row, 7)));
    period.setEndDate(getExcelDate(getRowCell(row, 8)));
    tender.setTenderPeriod(period);
    tender.setBidOpenDt(getExcelDate(getRowCell(row, 9)));
    Organization procuringEntity = organizationRepository.findByAllIds(getRowCellUpper(row, 10));
    if (procuringEntity == null) {
        procuringEntity = OrganizationRepositoryUtil.newAndInsertOrganization(Organization.OrganizationType.procuringEntity, getRowCellUpper(row, 10), organizationRepository);
    } else {
        procuringEntity = OrganizationRepositoryUtil.ensureOrgIsOfTypeAndSave(procuringEntity, Organization.OrganizationType.procuringEntity, organizationRepository);
    }
    tender.setProcuringEntity(procuringEntity);
    Organization orderInstituCd = organizationRepository.findByAllIds(getRowCellUpper(row, 11));
    if (orderInstituCd == null) {
        orderInstituCd = OrganizationRepositoryUtil.newAndInsertOrganization(Organization.OrganizationType.buyer, getRowCellUpper(row, 11), organizationRepository);
    } else {
        orderInstituCd = OrganizationRepositoryUtil.ensureOrgIsOfTypeAndSave(orderInstituCd, Organization.OrganizationType.procuringEntity, organizationRepository);
    }
    release.setBuyer(orderInstituCd);
    if (getRowCell(row, 12) != null) {
        Amount value = new Amount();
        value.setCurrency("VND");
        value.setAmount(getDecimal(getRowCell(row, 12)));
        tender.setValue(value);
    }
    tender.setPublicationMethod(getRowCell(row, 14));
    tender.setCancellationRationale(getRowCell(row, 15));
    readLocationAndClassificationFromReleaseRow(row, tender);
    return release;
}
Also used : ContrMethod(org.devgateway.ocvn.persistence.mongo.dao.ContrMethod) Organization(org.devgateway.ocds.persistence.mongo.Organization) Amount(org.devgateway.ocds.persistence.mongo.Amount) VNTender(org.devgateway.ocvn.persistence.mongo.dao.VNTender) VNPlanning(org.devgateway.ocvn.persistence.mongo.dao.VNPlanning) Period(org.devgateway.ocds.persistence.mongo.Period) Release(org.devgateway.ocds.persistence.mongo.Release)

Example 24 with Release

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

the class BidPlansRowImporter method createReleaseFromReleaseRow.

@Override
public Release createReleaseFromReleaseRow(final String[] row) throws ParseException {
    String projectID = getRowCell(row, 0);
    Release release = repository.findByBudgetProjectId(projectID);
    if (release == null) {
        release = new Release();
        release.getTag().add(Tag.planning);
        release.setOcid(MongoConstants.OCDS_PREFIX + "prjid-" + projectID);
        VNPlanning planning = new VNPlanning();
        release.setPlanning(planning);
    }
    Budget budget = release.getPlanning().getBudget();
    if (budget == null) {
        budget = new Budget();
        release.getPlanning().setBudget(budget);
    }
    budget.setProjectID(getRowCell(row, 0));
    Amount value = new Amount();
    value.setCurrency("VND");
    budget.setAmount(value);
    // decimal2
    value.setAmount(getDecimal(getRowCell(row, 5)));
    Tender tender = release.getTender();
    if (tender == null) {
        tender = new VNTender();
        tender.setId(release.getOcid());
        release.setTender(tender);
    }
    // create Items
    VNItem item = new VNItem();
    item.setId(Integer.toString(tender.getItems().size()));
    tender.getItems().add(item);
    // decimal2
    value.setAmount(getDecimal(getRowCell(row, 5)));
    item.setDescription(getRowCell(row, 1));
    item.setBidPlanItemRefNum(getRowCell(row, 2));
    item.setBidPlanItemStyle(getRowCell(row, 3));
    item.setBidPlanItemFund(getRowCell(row, 4));
    item.setBidPlanItemMethodSelect(getRowCell(row, 6));
    item.setBidPlanItemMethod(getRowCell(row, 7));
    item.setId(getRowCell(row, 8));
    return release;
}
Also used : VNItem(org.devgateway.ocvn.persistence.mongo.dao.VNItem) Amount(org.devgateway.ocds.persistence.mongo.Amount) VNTender(org.devgateway.ocvn.persistence.mongo.dao.VNTender) VNPlanning(org.devgateway.ocvn.persistence.mongo.dao.VNPlanning) Budget(org.devgateway.ocds.persistence.mongo.Budget) Tender(org.devgateway.ocds.persistence.mongo.Tender) VNTender(org.devgateway.ocvn.persistence.mongo.dao.VNTender) Release(org.devgateway.ocds.persistence.mongo.Release)

Example 25 with Release

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

the class ProcurementPlansRowImporter method createReleaseFromReleaseRow.

@Override
public Release createReleaseFromReleaseRow(final String[] row) throws ParseException {
    String projectID = getRowCell(row, 0);
    Release oldRelease = repository.findByBudgetProjectId(projectID);
    if (oldRelease != null) {
        throw new RuntimeException("Duplicate planning.budget.projectID");
    }
    Release release = new Release();
    release.setOcid(MongoConstants.OCDS_PREFIX + "prjid-" + projectID);
    release.getTag().add(Tag.planning);
    VNPlanning planning = new VNPlanning();
    VNBudget budget = new VNBudget();
    release.setPlanning(planning);
    planning.setBudget(budget);
    // search for locations
    if (getRowCell(row, 3) != null) {
        String[] locations = getRowCell(row, 3).split(",");
        for (int i = 0; i < locations.length; i++) {
            VNLocation location = locationRepository.findByDescription(locations[i].trim());
            if (location == null) {
                location = new VNLocation();
                location.setDescription(locations[i]);
                location = locationRepository.insert(location);
            }
            budget.getProjectLocation().add(location);
        }
    }
    planning.setBidPlanProjectDateIssue(getExcelDate(getRowCell(row, 4)));
    planning.setBidPlanProjectCompanyIssue(getRowCell(row, 6));
    planning.setBidPlanProjectFund(getInteger(getRowCell(row, 8)));
    budget.getProjectClassification().setDescription(getRowCell(row, 9));
    planning.setBidPlanProjectDateApprove(getExcelDate(getRowCell(row, 10)));
    budget.getProjectClassification().setId(getRowCell(row, 12));
    planning.setBidNo(getRowCell(row, 13));
    budget.setProjectID(getRowCell(row, 0));
    budget.setBidPlanProjectStyle(getRowCell(row, 5));
    budget.setBidPlanProjectType(getRowCell(row, 7));
    budget.setProject(getRowCell(row, 1));
    budget.setDescription(getRowCell(row, 11));
    Amount value = new Amount();
    budget.setProjectAmount(value);
    value.setCurrency("VND");
    value.setAmount(getDecimal(getRowCell(row, 2)));
    return release;
}
Also used : VNLocation(org.devgateway.ocvn.persistence.mongo.dao.VNLocation) VNBudget(org.devgateway.ocvn.persistence.mongo.dao.VNBudget) Amount(org.devgateway.ocds.persistence.mongo.Amount) VNPlanning(org.devgateway.ocvn.persistence.mongo.dao.VNPlanning) 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