use of org.devgateway.ocds.persistence.mongo.ReleasePackage in project ocvn by devgateway.
the class ReleaseExportFileTest method createWorkbook.
@Test
public void createWorkbook() throws Exception {
final ClassLoader classLoader = getClass().getClassLoader();
final File file = new File(classLoader.getResource("json/release-excel-export.json").getFile());
final JsonToObject releasePackageJsonToObject = new ReleasePackageJsonToObject(file, false);
final ReleasePackage releasePackage = (ReleasePackage) releasePackageJsonToObject.toObject();
final ExcelFile releaseExcelFile = new ReleaseExportFile(new ArrayList<>(releasePackage.getReleases()));
final Workbook workbook = releaseExcelFile.createWorkbook();
// try (FileOutputStream outputStream = new FileOutputStream("/Users/ionut/Downloads/ocds-export.xlsx")) {
// workbook.write(outputStream);
// }
Assert.assertEquals("Number of sheets", 6, workbook.getNumberOfSheets());
Assert.assertNotNull("release sheet", workbook.getSheet("release"));
Assert.assertNotNull("tender sheet", workbook.getSheet("vntender"));
Assert.assertNotNull("award sheet", workbook.getSheet("vnaward"));
Assert.assertNotNull("item sheet", workbook.getSheet("vnitem"));
Assert.assertEquals("release id", "ocds-213czf-000-00001-01-planning", workbook.getSheet("release").getRow(3).getCell(0).toString());
Assert.assertEquals("release id", "ocds-213czf-000-00001-06-implementation", workbook.getSheet("release").getRow(5).getCell(0).toString());
Assert.assertEquals("tender parent", "release - ocds-213czf-000-00001", workbook.getSheet("vntender").getRow(1).getCell(0).toString());
Assert.assertEquals("tender id", "ocds-213czf-000-00001-01-planning", workbook.getSheet("vntender").getRow(1).getCell(1).toString());
Assert.assertEquals("award number of rows", 4, workbook.getSheet("vnaward").getLastRowNum());
Assert.assertEquals("item number of rows", 7, workbook.getSheet("vnitem").getLastRowNum());
}
use of org.devgateway.ocds.persistence.mongo.ReleasePackage in project ocvn by devgateway.
the class OcdsController method ocdsPackages.
@ApiOperation(value = "Returns all available packages, filtered by the given criteria." + "This will contain the OCDS package information (metadata about publisher) plus the release itself.")
@RequestMapping(value = "/api/ocds/package/all", method = { RequestMethod.POST, RequestMethod.GET }, produces = "application/json")
@JsonView(Views.Public.class)
public List<ReleasePackage> ocdsPackages(@ModelAttribute @Valid final YearFilterPagingRequest releaseRequest) {
List<Release> ocdsReleases = ocdsReleases(releaseRequest);
List<ReleasePackage> releasePackages = new ArrayList<>(ocdsReleases.size());
for (Release release : ocdsReleases) {
releasePackages.add(createReleasePackage(release));
}
return releasePackages;
}
use of org.devgateway.ocds.persistence.mongo.ReleasePackage in project ocvn by devgateway.
the class OcdsController method createReleasePackage.
public ReleasePackage createReleasePackage(final Release release) {
ReleasePackage releasePackage = new ReleasePackage();
releasePackage.setLicense("https://creativecommons.org/licenses/by/2.0/");
releasePackage.setPublicationPolicy("https://github.com/open-contracting/sample-data/");
releasePackage.setPublishedDate(release.getDate());
releasePackage.getReleases().add(release);
releasePackage.setUri(SERVER_DOMAIN + "/api/ocds/package/ocid/" + release.getOcid());
Publisher publisher = new Publisher();
publisher.setName("Government of Vietnam: Public Procurement Agency");
publisher.setScheme("VN-PPA");
publisher.setUid(release.getOcid());
publisher.setUri(SERVER_DOMAIN);
releasePackage.setPublisher(publisher);
return releasePackage;
}
use of org.devgateway.ocds.persistence.mongo.ReleasePackage in project ocvn by devgateway.
the class ReleasePackageJsonImport method importObjects.
@Override
public Collection<Release> importObjects() throws IOException {
final ReleasePackage releasePackage = (ReleasePackage) releasePackageJsonToObject.toObject();
final Collection<Release> savedReleases = new LinkedHashSet<>();
if (!releasePackage.getReleases().isEmpty()) {
Set<Release> releases = releasePackage.getReleases();
for (Release release : releases) {
Release savedRelease = releaseRepository.save(release);
savedReleases.add(savedRelease);
}
}
return savedReleases;
}
use of org.devgateway.ocds.persistence.mongo.ReleasePackage in project ocvn by devgateway.
the class OcdsControllerTest method createReleasePackage.
@Test
public void createReleasePackage() throws Exception {
final ReleasePackage releasePackage = ocdsController.createReleasePackage(ocdsController.ocdsByOcid("ocds-endpoint-001"));
Assert.assertNotNull(releasePackage);
final Optional<Release> release = releasePackage.getReleases().stream().findFirst();
Assert.assertEquals(true, release.isPresent());
Assert.assertEquals("ocds-endpoint-001", release.get().getOcid());
}
Aggregations