Search in sources :

Example 1 with Identifier

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

the class OrganizationRepositoryTests method saveOrganization.

@Test
public void saveOrganization() {
    Organization o = new Organization();
    Address a = new Address();
    a.setCountryName("United States");
    a.setLocality("Washington");
    a.setRegion("DC");
    a.setPostalCode("20005");
    a.setStreetAddress("1110 Vermont Ave. NW, Suite 500");
    o.setAddress(a);
    ContactPoint cp = new ContactPoint();
    cp.setEmail("info@developmentgateway.org");
    cp.setName("John Doe");
    cp.setTelephone("555-1234567");
    cp.setUrl("http://developmentgateway.org");
    cp.setFaxNumber("555-7654321");
    o.setContactPoint(cp);
    Identifier i = new Identifier();
    i.setId("DG");
    i.setLegalName("Development Gateway");
    o.setIdentifier(i);
    o.getRoles().add(OrganizationType.procuringEntity);
    o.getAdditionalIdentifiers().add(i);
    Organization save = vnOrganizationRepository.save(o);
    assertThat(save.getId(), is(not(nullValue())));
    LOGGER.info(save.getId());
}
Also used : ContactPoint(org.devgateway.ocds.persistence.mongo.ContactPoint) Organization(org.devgateway.ocds.persistence.mongo.Organization) Identifier(org.devgateway.ocds.persistence.mongo.Identifier) Address(org.devgateway.ocds.persistence.mongo.Address) Test(org.junit.Test) AbstractMongoTest(org.devgateway.toolkit.persistence.mongo.AbstractMongoTest)

Example 2 with Identifier

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

the class OrganizationEndpointsTest method importTestData.

@Before
public void importTestData() throws IOException, InterruptedException {
    organizationRepository.deleteAll();
    final Organization organization = new Organization();
    organization.setName("Development Gateway");
    organization.setId(ORG_ID);
    final Address address = new Address();
    address.setCountryName("Romania");
    address.setLocality("Bucuresti");
    address.setPostalCode("022671");
    address.setRegion("Bucuresti");
    address.setStreetAddress("7 Sos. Iancului");
    organization.setAddress(address);
    final ContactPoint contactPoint = new ContactPoint();
    contactPoint.setEmail("mpostelnicu@developmentgateway.org");
    contactPoint.setFaxNumber("01234567");
    contactPoint.setTelephone("01234567");
    contactPoint.setUrl("http://developmentgateway.org");
    organization.setContactPoint(contactPoint);
    final Identifier identifier = new Identifier();
    identifier.setId(ORG_ID);
    organization.getAdditionalIdentifiers().add(identifier);
    organization.getRoles().add(Organization.OrganizationType.procuringEntity);
    organization.getRoles().add(Organization.OrganizationType.buyer);
    final Organization savedOrganization = organizationRepository.save(organization);
    Assert.assertNotNull(savedOrganization);
    Assert.assertEquals(ORG_ID, savedOrganization.getId());
}
Also used : ContactPoint(org.devgateway.ocds.persistence.mongo.ContactPoint) Organization(org.devgateway.ocds.persistence.mongo.Organization) Identifier(org.devgateway.ocds.persistence.mongo.Identifier) Address(org.devgateway.ocds.persistence.mongo.Address) Before(org.junit.Before)

Example 3 with Identifier

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

the class OrganizationRepositoryTest method importTestData.

@Before
public void importTestData() throws IOException, InterruptedException {
    // be sure that the organization collection is empty
    organizationRepository.deleteAll();
    final Organization organization = new Organization();
    organization.setName("Development Gateway");
    organization.setId(ORG_ID);
    final Address address = new Address();
    address.setCountryName("Romania");
    address.setLocality("Bucuresti");
    address.setPostalCode("022671");
    address.setRegion("Bucuresti");
    address.setStreetAddress("7 Sos. Iancului");
    organization.setAddress(address);
    final ContactPoint contactPoint = new ContactPoint();
    contactPoint.setEmail("mpostelnicu@developmentgateway.org");
    contactPoint.setFaxNumber("01234567");
    contactPoint.setTelephone("01234567");
    contactPoint.setUrl("http://developmentgateway.org");
    organization.setContactPoint(contactPoint);
    final Identifier identifier = new Identifier();
    organization.getAdditionalIdentifiers().add(identifier);
    organization.getRoles().add(Organization.OrganizationType.procuringEntity);
    organization.getRoles().add(Organization.OrganizationType.buyer);
    final Organization savedOrganization = organizationRepository.save(organization);
    Assert.assertNotNull(savedOrganization);
    Assert.assertEquals(ORG_ID, savedOrganization.getId());
}
Also used : ContactPoint(org.devgateway.ocds.persistence.mongo.ContactPoint) Organization(org.devgateway.ocds.persistence.mongo.Organization) Identifier(org.devgateway.ocds.persistence.mongo.Identifier) Address(org.devgateway.ocds.persistence.mongo.Address) Before(org.junit.Before)

Example 4 with Identifier

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

the class PublicInstitutionRowImporter method importRow.

@Override
public void importRow(final String[] row) throws ParseException {
    if (getRowCell(row, 0) == null) {
        throw new RuntimeException("Main identifier empty!");
    }
    String newIdentifier = getRowCellUpper(row, 0);
    String name = getRowCellUpper(row, 1);
    VNOrganization organization = repository.findByName(name);
    Identifier identifier = new Identifier();
    identifier.setId(newIdentifier);
    if (organization == null) {
        organization = (VNOrganization) newOrganization(new VNOrganization(), identifier, name);
        newAddress(organization, getRowCell(row, 14));
        if (getRowCell(row, 44) != null) {
            Identifier additionalIdentifier = new Identifier();
            additionalIdentifier.setId(getRowCellUpper(row, 44));
            addAditionalIdentifierOrFail(organization, additionalIdentifier, null);
        }
        newContactPoint(organization, getRowCell(row, 5), getRowCell(row, 7), getRowCell(row, 8), getRowCell(row, 9), getRowCell(row, 18));
        if (getRowCell(row, 13) != null) {
            newCity(organization, getInteger(getRowCell(row, 13)));
        }
        if (getRowCell(row, 47) != null) {
            newDepartment(organization, getInteger(getRowCell(row, 47)));
        }
        if (getRowCell(row, 48) != null) {
            newOrgGroup(organization, getInteger(getRowCell(row, 48)));
        }
    } else {
        addAditionalIdentifierOrFail(organization, identifier, null);
    }
    repository.save(organization);
}
Also used : Identifier(org.devgateway.ocds.persistence.mongo.Identifier) VNOrganization(org.devgateway.ocvn.persistence.mongo.dao.VNOrganization)

Example 5 with Identifier

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

the class SupplierRowImporter method importRow.

@Override
public void importRow(final String[] row) throws ParseException {
    if (getRowCell(row, 0) == null) {
        throw new RuntimeException("Main identifier empty!");
    }
    String newIdentifier = getRowCellUpper(row, 0);
    String name = getRowCellUpper(row, 2);
    Organization organization = repository.findByName(name);
    Identifier identifier = new Identifier();
    identifier.setId(newIdentifier);
    if (organization == null) {
        organization = newOrganization(new Organization(), identifier, name);
        newAddress(organization, getRowCell(row, 18));
        newContactPoint(organization, null, getRowCell(row, 20), getRowCell(row, 21), null, getRowCell(row, 22));
        if (getRowCell(row, 17) != null) {
            newCity(organization, getInteger(getRowCell(row, 17)));
        }
    } else {
        addAditionalIdentifierOrFail(organization, identifier, Organization.OrganizationType.supplier);
    }
    organization.getRoles().add(Organization.OrganizationType.supplier);
    repository.save(organization);
}
Also used : Organization(org.devgateway.ocds.persistence.mongo.Organization) VNOrganization(org.devgateway.ocvn.persistence.mongo.dao.VNOrganization) Identifier(org.devgateway.ocds.persistence.mongo.Identifier)

Aggregations

Identifier (org.devgateway.ocds.persistence.mongo.Identifier)6 Organization (org.devgateway.ocds.persistence.mongo.Organization)5 Address (org.devgateway.ocds.persistence.mongo.Address)3 ContactPoint (org.devgateway.ocds.persistence.mongo.ContactPoint)3 VNOrganization (org.devgateway.ocvn.persistence.mongo.dao.VNOrganization)2 Before (org.junit.Before)2 AbstractMongoTest (org.devgateway.toolkit.persistence.mongo.AbstractMongoTest)1 Test (org.junit.Test)1