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;
}
use of org.devgateway.ocds.persistence.mongo.Release in project ocvn by devgateway.
the class ReleaseJsonImportTest method importObject.
@Test
public void importObject() throws Exception {
final String jsonRelease = "{\n" + " tag: [\"tender\"],\n" + " planning: {\n" + " budget: {\n" + " description: \"budget desc...\",\n" + " amount: {\n" + " amount: 10000,\n" + " currency: \"USD\"\n" + " }\n" + " }\n" + " }\n" + "}";
final JsonImport releaseJsonImport = new ReleaseJsonImport(releaseRepository, jsonRelease, false);
final Release release = (Release) releaseJsonImport.importObject();
final Release releaseById = releaseRepository.findById(release.getId());
Assert.assertNotNull("Check if we have something in the database", releaseById);
Assert.assertEquals("Check if the releases are the same", release, releaseById);
}
use of org.devgateway.ocds.persistence.mongo.Release in project ocvn by devgateway.
the class ReleasePackageJsonImportTest method importObjectsImplementation.
@Test
public void importObjectsImplementation() throws Exception {
final ClassLoader classLoader = getClass().getClassLoader();
final File file = new File(classLoader.getResource("json/fictional-example/ocds-213czf-000-00001-06-implementation.json").getFile());
final ReleasePackageJsonImport releasePackageJsonImport = new ReleasePackageJsonImport(releaseRepository, file, false);
final Collection<Release> releases = releasePackageJsonImport.importObjects();
final Release importedRelease = releaseRepository.findById("ocds-213czf-000-00001-06-implementation");
Assert.assertEquals(1, releases.size());
Assert.assertNotNull(importedRelease);
Assert.assertArrayEquals(new Tag[] { Tag.implementation }, importedRelease.getTag().toArray());
final Set<Contract> contracts = importedRelease.getContracts();
final Set<Transaction> transactions = contracts.iterator().next().getImplementation().getTransactions();
Assert.assertEquals("https://openspending.org/uk-barnet-spending/", transactions.iterator().next().getSource());
}
use of org.devgateway.ocds.persistence.mongo.Release in project ocvn by devgateway.
the class ReleasePackageJsonImportTest method importObjectsAward.
@Test
public void importObjectsAward() throws Exception {
final ClassLoader classLoader = getClass().getClassLoader();
final File file = new File(classLoader.getResource("json/fictional-example/ocds-213czf-000-00001-04-award.json").getFile());
final ReleasePackageJsonImport releasePackageJsonImport = new ReleasePackageJsonImport(releaseRepository, file, false);
final Collection<Release> releases = releasePackageJsonImport.importObjects();
final Release importedRelease = releaseRepository.findById("ocds-213czf-000-00001-04-award");
Assert.assertEquals(1, releases.size());
Assert.assertNotNull(importedRelease);
final Set<Award> awards = importedRelease.getAwards();
Assert.assertEquals(Award.Status.pending, awards.iterator().next().getStatus());
}
use of org.devgateway.ocds.persistence.mongo.Release in project ocvn by devgateway.
the class ReleasePackageJsonImportTest method importObjectsContract.
@Test
public void importObjectsContract() throws Exception {
final ClassLoader classLoader = getClass().getClassLoader();
final File file = new File(classLoader.getResource("json/fictional-example/ocds-213czf-000-00001-05-contract.json").getFile());
final ReleasePackageJsonImport releasePackageJsonImport = new ReleasePackageJsonImport(releaseRepository, file, false);
final Collection<Release> releases = releasePackageJsonImport.importObjects();
final Release importedRelease = releaseRepository.findById("ocds-213czf-000-00001-05-contract");
Assert.assertEquals(1, releases.size());
Assert.assertNotNull(importedRelease);
final Set<Contract> contracts = importedRelease.getContracts();
Assert.assertEquals(Contract.Status.active, contracts.iterator().next().getStatus());
}
Aggregations