use of org.devgateway.ocds.persistence.mongo.Classification 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);
}
}
}
Aggregations