Search in sources :

Example 1 with Release

use of org.devgateway.ocds.persistence.mongo.Release 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;
}
Also used : ReleasePackage(org.devgateway.ocds.persistence.mongo.ReleasePackage) ArrayList(java.util.ArrayList) Release(org.devgateway.ocds.persistence.mongo.Release) ApiOperation(io.swagger.annotations.ApiOperation) JsonView(com.fasterxml.jackson.annotation.JsonView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with Release

use of org.devgateway.ocds.persistence.mongo.Release in project ocvn by devgateway.

the class ReleaseRepositoryTest method testReleaseSaveAndFind.

@Test
public void testReleaseSaveAndFind() {
    final Release release = new Release();
    release.setOcid(ocid);
    releaseRepository.insert(release);
    final Release byOcid = releaseRepository.findByOcid(ocid);
    Assert.assertEquals(ocid, byOcid.getOcid());
}
Also used : Release(org.devgateway.ocds.persistence.mongo.Release) AbstractMongoTest(org.devgateway.toolkit.persistence.mongo.AbstractMongoTest) Test(org.junit.Test)

Example 3 with Release

use of org.devgateway.ocds.persistence.mongo.Release in project ocvn by devgateway.

the class XMLFileImportDefault method process.

@Test
@Ignore
public void process() throws Exception {
    final ClassLoader classLoader = getClass().getClassLoader();
    final File file = new File(classLoader.getResource("xml/release.xml").getFile());
    xmlFile.process(file);
    final List<Release> releases = releaseRepository.findAll();
    Assert.assertNotNull(releases);
    final Release release = releaseRepository.findById("xmlimport-123");
    Assert.assertNotNull(release);
    Assert.assertEquals("check field", release.getLanguage(), "en");
}
Also used : File(java.io.File) Release(org.devgateway.ocds.persistence.mongo.Release) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractMongoTest(org.devgateway.toolkit.persistence.mongo.AbstractMongoTest)

Example 4 with Release

use of org.devgateway.ocds.persistence.mongo.Release in project ocvn by devgateway.

the class ReleasePackageJsonImportTest method importObjectsTenderAmendment.

@Test
public void importObjectsTenderAmendment() throws Exception {
    final ClassLoader classLoader = getClass().getClassLoader();
    final File file = new File(classLoader.getResource("json/fictional-example/ocds-213czf-000-00001-03-tenderAmendment.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-03-tenderAmendment");
    Assert.assertEquals(1, releases.size());
    Assert.assertNotNull(importedRelease);
    Assert.assertArrayEquals(new Tender.SubmissionMethod[] { Tender.SubmissionMethod.electronicSubmission }, importedRelease.getTender().getSubmissionMethod().toArray());
}
Also used : File(java.io.File) Tender(org.devgateway.ocds.persistence.mongo.Tender) Release(org.devgateway.ocds.persistence.mongo.Release) Test(org.junit.Test) AbstractMongoTest(org.devgateway.toolkit.persistence.mongo.AbstractMongoTest)

Example 5 with Release

use of org.devgateway.ocds.persistence.mongo.Release in project ocvn 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, false);
    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());
}
Also used : File(java.io.File) Release(org.devgateway.ocds.persistence.mongo.Release) Test(org.junit.Test) AbstractMongoTest(org.devgateway.toolkit.persistence.mongo.AbstractMongoTest)

Aggregations

Release (org.devgateway.ocds.persistence.mongo.Release)69 Test (org.junit.Test)44 File (java.io.File)22 AbstractMongoTest (org.devgateway.toolkit.persistence.mongo.AbstractMongoTest)20 ReleasePackage (org.devgateway.ocds.persistence.mongo.ReleasePackage)12 Amount (org.devgateway.ocds.persistence.mongo.Amount)9 JsonNode (com.fasterxml.jackson.databind.JsonNode)6 ProcessingMessage (com.github.fge.jsonschema.core.report.ProcessingMessage)6 BigDecimal (java.math.BigDecimal)6 Award (org.devgateway.ocds.persistence.mongo.Award)6 OcdsSchemaValidatorService (org.devgateway.ocds.persistence.mongo.spring.OcdsSchemaValidatorService)6 JsonImport (org.devgateway.ocds.persistence.mongo.spring.json.JsonImport)6 ReleaseJsonImport (org.devgateway.ocds.persistence.mongo.spring.json.ReleaseJsonImport)6 AbstractWebTest (org.devgateway.toolkit.web.AbstractWebTest)6 MvcResult (org.springframework.test.web.servlet.MvcResult)6 Budget (org.devgateway.ocds.persistence.mongo.Budget)5 Contract (org.devgateway.ocds.persistence.mongo.Contract)4 Planning (org.devgateway.ocds.persistence.mongo.Planning)4 VNPlanning (org.devgateway.ocvn.persistence.mongo.dao.VNPlanning)4 VNTender (org.devgateway.ocvn.persistence.mongo.dao.VNTender)4