Search in sources :

Example 1 with VNItem

use of org.devgateway.ocvn.persistence.mongo.dao.VNItem in project ocvn by devgateway.

the class TenderRowImporter method readLocationAndClassificationFromReleaseRow.

public void readLocationAndClassificationFromReleaseRow(final String[] row, Tender tender) {
    // location attached to tender/items
    String locationName = getRowCell(row, 16);
    VNLocation location = null;
    if (locationName != null) {
        location = locationRepository.findByDescription(locationName);
        if (location == null) {
            location = new VNLocation();
            location.setDescription(locationName);
            location = locationRepository.insert(location);
        }
    }
    if (tender.getItems().isEmpty()) {
        VNItem item = new VNItem();
        item.setId(Integer.toString(tender.getItems().size()));
        if (location != null) {
            item.setDeliveryLocation(location);
        }
        tender.getItems().add(item);
    }
    // are found, we create a fake item and add only this classification
    for (Item item : tender.getItems()) {
        String classificationId = getRowCell(row, 13);
        Classification classification = classificationRepository.findOne(classificationId);
        if (classification == null) {
            classification = new Classification();
            classification.setId(classificationId);
            switch(classificationId) {
                case "1":
                    classification.setDescription("Hàng hóa");
                    break;
                case "3":
                    classification.setDescription("Xây lắp");
                    break;
                case "5":
                    classification.setDescription("Tư vấn");
                    break;
                case "10":
                    classification.setDescription("Hỗn hợp");
                    break;
                case "15":
                    classification.setDescription("Phi tư vấn");
                    break;
                default:
                    classification.setDescription("Chưa xác định");
                    break;
            }
            classification = classificationRepository.insert(classification);
        }
        item.setClassification(classification);
        if (location != null) {
            ((VNItem) item).setDeliveryLocation(location);
        }
    }
}
Also used : Item(org.devgateway.ocds.persistence.mongo.Item) VNItem(org.devgateway.ocvn.persistence.mongo.dao.VNItem) VNLocation(org.devgateway.ocvn.persistence.mongo.dao.VNLocation) VNItem(org.devgateway.ocvn.persistence.mongo.dao.VNItem) Classification(org.devgateway.ocds.persistence.mongo.Classification)

Example 2 with VNItem

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

Aggregations

VNItem (org.devgateway.ocvn.persistence.mongo.dao.VNItem)2 Amount (org.devgateway.ocds.persistence.mongo.Amount)1 Budget (org.devgateway.ocds.persistence.mongo.Budget)1 Classification (org.devgateway.ocds.persistence.mongo.Classification)1 Item (org.devgateway.ocds.persistence.mongo.Item)1 Release (org.devgateway.ocds.persistence.mongo.Release)1 Tender (org.devgateway.ocds.persistence.mongo.Tender)1 VNLocation (org.devgateway.ocvn.persistence.mongo.dao.VNLocation)1 VNPlanning (org.devgateway.ocvn.persistence.mongo.dao.VNPlanning)1 VNTender (org.devgateway.ocvn.persistence.mongo.dao.VNTender)1