Search in sources :

Example 11 with Organization

use of org.devgateway.ocds.persistence.mongo.Organization in project oc-explorer by devgateway.

the class OCDSPopulatorService method randomizeOrganization.

public void randomizeOrganization(Organization o) {
    o.setName(getIdxName("Organization"));
    String oldId = o.getId();
    orgNameId.put(oldId, o.getName());
    o.setId(o.getName());
    o.getIdentifier().setId(o.getId());
    o.getAdditionalIdentifiers().stream().filter(i -> i.getId().equals(oldId)).findFirst().get().setId(o.getId());
    if (o.getAddress() != null) {
        o.getAddress().setCountryName(getIdxName("Country"));
        o.getAddress().setLocality(getIdxName("Locality"));
        o.getAddress().setPostalCode(getIdxName("Postal Code"));
        o.getAddress().setRegion(getIdxName("Region"));
        o.getAddress().setStreetAddress(getIdxName("Street"));
    }
    if (o.getContactPoint() != null) {
        o.getContactPoint().setEmail("sample@sample.abc");
        o.getContactPoint().setFaxNumber("Fax");
        o.getContactPoint().setName(getIdxName("Contact"));
        o.getContactPoint().setTelephone("Phone");
        try {
            o.getContactPoint().setUrl(new URI("http://sample.abc"));
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
    }
    mongoTemplate.save(o, "tmporg");
}
Also used : Organization(org.devgateway.ocds.persistence.mongo.Organization) Iterator(java.util.Iterator) URISyntaxException(java.net.URISyntaxException) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Autowired(org.springframework.beans.factory.annotation.Autowired) FlaggedRelease(org.devgateway.ocds.persistence.mongo.FlaggedRelease) Aggregation(org.springframework.data.mongodb.core.aggregation.Aggregation) Identifiable(org.devgateway.ocds.persistence.mongo.Identifiable) Serializable(java.io.Serializable) Consumer(java.util.function.Consumer) Logger(org.apache.log4j.Logger) Classification(org.devgateway.ocds.persistence.mongo.Classification) ClassificationRepository(org.devgateway.ocds.persistence.mongo.repository.main.ClassificationRepository) DBObject(com.mongodb.DBObject) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Service(org.springframework.stereotype.Service) FlaggedReleaseRepository(org.devgateway.ocds.persistence.mongo.repository.main.FlaggedReleaseRepository) OrganizationRepository(org.devgateway.ocds.persistence.mongo.repository.main.OrganizationRepository) URI(java.net.URI) MongoUtil(org.devgateway.toolkit.persistence.mongo.spring.MongoUtil) MongoTemplate(org.springframework.data.mongodb.core.MongoTemplate) MongoRepository(org.springframework.data.mongodb.repository.MongoRepository) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 12 with Organization

use of org.devgateway.ocds.persistence.mongo.Organization in project oc-explorer by devgateway.

the class OrganizationEndpointsTest method testSupplierIdEndpoint.

@Test
public void testSupplierIdEndpoint() {
    final Organization organizationId = supplierSearchController.byId(ORG_ID);
    Assert.assertNull(organizationId);
}
Also used : Organization(org.devgateway.ocds.persistence.mongo.Organization) Test(org.junit.Test) AbstractWebTest(org.devgateway.toolkit.web.AbstractWebTest)

Example 13 with Organization

use of org.devgateway.ocds.persistence.mongo.Organization in project oc-explorer by devgateway.

the class OrganizationEndpointsTest method testBuyerSearchText.

@Test
public void testBuyerSearchText() {
    final OrganizationSearchRequest osr = new OrganizationSearchRequest();
    osr.setText("Development");
    final List<Organization> organizations = buyerSearchController.searchText(osr);
    Assert.assertEquals(1, organizations.size(), 0);
}
Also used : Organization(org.devgateway.ocds.persistence.mongo.Organization) OrganizationSearchRequest(org.devgateway.ocds.web.rest.controller.request.OrganizationSearchRequest) Test(org.junit.Test) AbstractWebTest(org.devgateway.toolkit.web.AbstractWebTest)

Example 14 with Organization

use of org.devgateway.ocds.persistence.mongo.Organization in project oc-explorer by devgateway.

the class OrganizationRepositoryTest method importTestData.

@Before
public void importTestData() throws IOException, InterruptedException, URISyntaxException {
    // 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(new URI("http://developmentgateway.org"));
    organization.setContactPoint(contactPoint);
    final Identifier identifier = new Identifier();
    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) URI(java.net.URI) Before(org.junit.Before)

Example 15 with Organization

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

the class OrganizationRepositoryTest method testOrganizationSaveAndFind.

@Test
public void testOrganizationSaveAndFind() {
    final Organization foundOrg = organizationRepository.findOne(ORG_ID);
    Assert.assertNotNull(foundOrg);
    final Organization foundOrg2 = organizationRepository.findByIdOrNameAndTypes(ORG_ID, Organization.OrganizationType.procuringEntity);
    Assert.assertNotNull(foundOrg2);
    final Organization foundOrg3 = organizationRepository.findByIdOrNameAndTypes(ORG_ID, Organization.OrganizationType.supplier);
    Assert.assertNull(foundOrg3);
    final Organization foundOrg4 = organizationRepository.findByIdOrNameAllIgnoreCase(ORG_ID, ORG_ID);
    Assert.assertNotNull(foundOrg4);
}
Also used : Organization(org.devgateway.ocds.persistence.mongo.Organization) AbstractMongoTest(org.devgateway.toolkit.persistence.mongo.AbstractMongoTest) Test(org.junit.Test)

Aggregations

Organization (org.devgateway.ocds.persistence.mongo.Organization)31 Test (org.junit.Test)20 AbstractWebTest (org.devgateway.toolkit.web.AbstractWebTest)17 Identifier (org.devgateway.ocds.persistence.mongo.Identifier)7 Address (org.devgateway.ocds.persistence.mongo.Address)5 ContactPoint (org.devgateway.ocds.persistence.mongo.ContactPoint)5 TextSearchRequest (org.devgateway.ocds.web.rest.controller.request.TextSearchRequest)5 OrganizationSearchRequest (org.devgateway.ocds.web.rest.controller.request.OrganizationSearchRequest)4 Before (org.junit.Before)4 URI (java.net.URI)3 Amount (org.devgateway.ocds.persistence.mongo.Amount)3 Release (org.devgateway.ocds.persistence.mongo.Release)3 VNTender (org.devgateway.ocvn.persistence.mongo.dao.VNTender)3 AbstractMongoTest (org.devgateway.toolkit.persistence.mongo.AbstractMongoTest)3 URISyntaxException (java.net.URISyntaxException)2 Detail (org.devgateway.ocds.persistence.mongo.Detail)2 VNAward (org.devgateway.ocvn.persistence.mongo.dao.VNAward)2 VNTendererOrganization (org.devgateway.ocvn.persistence.mongo.dao.VNTendererOrganization)2 DBObject (com.mongodb.DBObject)1 Serializable (java.io.Serializable)1