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);
}
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);
}
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());
}
Aggregations