use of org.devgateway.ocds.persistence.mongo.Release in project oc-explorer by devgateway.
the class ReleaseCompilerService method createCompiledRelease.
protected Release createCompiledRelease(final Record record) {
// empty records produce null compiled release
if (record.getReleases().isEmpty()) {
return null;
}
// records with just one release produce a compiled release identical to
// the one release
Release left = record.getReleases().get(0);
if (record.getReleases().size() > 1) {
// we merge each element of the list to its left partner
List<Release> subList = record.getReleases().subList(1, record.getReleases().size());
for (Release right : subList) {
Release compiled = mergeOcdsBeans(left, right);
left = compiled;
}
}
// this was purposefully nullified by ocdsOmit
left.setTag(new ArrayList<Tag>());
left.getTag().add(Tag.compiled);
return left;
}
use of org.devgateway.ocds.persistence.mongo.Release in project oc-explorer 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.Release in project oc-explorer by devgateway.
the class ReleasePackageJsonImportTest method importObjectsTender.
@Test
public void importObjectsTender() throws Exception {
final ClassLoader classLoader = getClass().getClassLoader();
final File file = new File(classLoader.getResource("json/fictional-example/ocds-213czf-000-00001-02-tender.json").getFile());
final ReleasePackageJsonImport releasePackageJsonImport = new ReleasePackageJsonImport(releaseRepository, file);
final Collection<Release> releases = releasePackageJsonImport.importObjects();
final Release importedRelease = releaseRepository.findById("ocds-213czf-000-00001-02-tender");
Assert.assertEquals(1, releases.size());
Assert.assertNotNull(importedRelease);
Assert.assertEquals(Tender.ProcurementMethod.open, importedRelease.getTender().getProcurementMethod());
}
use of org.devgateway.ocds.persistence.mongo.Release in project oc-explorer 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);
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(new URI("https://openspending.org/uk-barnet-spending/"), transactions.iterator().next().getSource());
}
use of org.devgateway.ocds.persistence.mongo.Release in project oc-explorer 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);
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());
}
Aggregations