Search in sources :

Example 1 with VNLocation

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

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

Example 3 with VNLocation

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

the class LocationRowImporter method importRow.

@Override
public void importRow(final String[] row) throws ParseException {
    VNLocation location = repository.findByDescription(getRowCell(row, 0));
    if (location != null) {
        throw new RuntimeException("Duplicate location name " + getRowCell(row, 0));
    }
    location = new VNLocation();
    location.setId(getRowCell(row, 3));
    location.setDescription(getRowCell(row, 0));
    GeoJsonPoint coordinates = new GeoJsonPoint(getDouble(getRowCell(row, 2)), getDouble(getRowCell(row, 1)));
    location.setGeometry(coordinates);
    Gazetteer gazetteer = new Gazetteer();
    gazetteer.getIdentifiers().add(getRowCell(row, 3));
    location.setGazetteer(gazetteer);
    location.setUri(location.getGazetteerPrefix() + getRowCell(row, 3));
    repository.insert(location);
}
Also used : VNLocation(org.devgateway.ocvn.persistence.mongo.dao.VNLocation) Gazetteer(org.devgateway.ocds.persistence.mongo.Gazetteer) GeoJsonPoint(org.springframework.data.mongodb.core.geo.GeoJsonPoint)

Aggregations

VNLocation (org.devgateway.ocvn.persistence.mongo.dao.VNLocation)3 Amount (org.devgateway.ocds.persistence.mongo.Amount)1 Classification (org.devgateway.ocds.persistence.mongo.Classification)1 Gazetteer (org.devgateway.ocds.persistence.mongo.Gazetteer)1 Item (org.devgateway.ocds.persistence.mongo.Item)1 Release (org.devgateway.ocds.persistence.mongo.Release)1 VNBudget (org.devgateway.ocvn.persistence.mongo.dao.VNBudget)1 VNItem (org.devgateway.ocvn.persistence.mongo.dao.VNItem)1 VNPlanning (org.devgateway.ocvn.persistence.mongo.dao.VNPlanning)1 GeoJsonPoint (org.springframework.data.mongodb.core.geo.GeoJsonPoint)1