Search in sources :

Example 6 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)

Example 7 with Identifier

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

the class OrganizationRepositoryUtil method newAndInsertOrganization.

/**
     * {@link Organization} factory, creating one organization and label it as
     * {@link Organization.OrganizationType}
     * 
     * @param type
     *            the type
     * @param name
     *            the org name
     * @param id
     *            the org id
     * @return the created organization
     */
public static Organization newAndInsertOrganization(Organization.OrganizationType type, String name, String id, OrganizationRepository repository) {
    Organization org = new Organization();
    org.getRoles().add(type);
    org.setName(name);
    org.setId(id);
    Identifier identifier = new Identifier();
    identifier.setId(id);
    org.setIdentifier(identifier);
    org.getAdditionalIdentifiers().add(identifier);
    return repository.insert(org);
}
Also used : Organization(org.devgateway.ocds.persistence.mongo.Organization) Identifier(org.devgateway.ocds.persistence.mongo.Identifier)

Example 8 with Identifier

use of org.devgateway.ocds.persistence.mongo.Identifier in project oc-explorer 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");
    try {
        contactPoint.setUrl(new URI("http://developmentgateway.org"));
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    organization.setContactPoint(contactPoint);
    final Identifier identifier = new Identifier();
    identifier.setId(ORG_ID);
    organization.getAdditionalIdentifiers().add(identifier);
    organization.getRoles().add(Organization.OrganizationType.procuringEntity.toString());
    organization.getRoles().add(Organization.OrganizationType.buyer.toString());
    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) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) Before(org.junit.Before)

Aggregations

Identifier (org.devgateway.ocds.persistence.mongo.Identifier)8 Organization (org.devgateway.ocds.persistence.mongo.Organization)7 Address (org.devgateway.ocds.persistence.mongo.Address)5 ContactPoint (org.devgateway.ocds.persistence.mongo.ContactPoint)5 Before (org.junit.Before)4 URI (java.net.URI)2 VNOrganization (org.devgateway.ocvn.persistence.mongo.dao.VNOrganization)2 URISyntaxException (java.net.URISyntaxException)1 AbstractMongoTest (org.devgateway.toolkit.persistence.mongo.AbstractMongoTest)1 Test (org.junit.Test)1