Search in sources :

Example 1 with ContrMethod

use of org.devgateway.ocvn.persistence.mongo.dao.ContrMethod 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)

Aggregations

Amount (org.devgateway.ocds.persistence.mongo.Amount)1 Organization (org.devgateway.ocds.persistence.mongo.Organization)1 Period (org.devgateway.ocds.persistence.mongo.Period)1 Release (org.devgateway.ocds.persistence.mongo.Release)1 ContrMethod (org.devgateway.ocvn.persistence.mongo.dao.ContrMethod)1 VNPlanning (org.devgateway.ocvn.persistence.mongo.dao.VNPlanning)1 VNTender (org.devgateway.ocvn.persistence.mongo.dao.VNTender)1