Search in sources :

Example 1 with CountryElement

use of com.hack23.cia.model.external.worldbank.countries.impl.CountryElement in project cia by Hack23.

the class AdminCountryPageModContentFactoryImpl method createContent.

@Secured({ "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
    final VerticalLayout content = createPanelContent();
    final String pageId = getPageId(parameters);
    final int pageNr = getPageNr(parameters);
    getMenuItemFactory().createMainPageMenuBar(menuBar);
    LabelFactory.createHeader2Label(content, ADMIN_COUNTRY);
    final DataContainer<CountryElement, Long> dataContainer = getApplicationManager().getDataContainer(CountryElement.class);
    final List<CountryElement> pageOrderBy = dataContainer.getPageOrderBy(pageNr, DEFAULT_RESULTS_PER_PAGE, CountryElement_.countryName);
    createPagingControls(content, NAME, pageId, dataContainer.getSize(), pageNr, DEFAULT_RESULTS_PER_PAGE);
    getGridFactory().createBasicBeanItemNestedPropertiesGrid(content, CountryElement.class, pageOrderBy, COUNTRY2, null, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);
    if (pageId != null && !pageId.isEmpty()) {
        final CountryElement country = dataContainer.load(Long.valueOf(pageId));
        if (country != null) {
            getFormFactory().addFormPanelTextFields(content, country, CountryElement.class, AS_LIST);
        }
    }
    getPageActionEventHelper().createPageEvent(ViewAction.VISIT_ADMIN_COUNTRY_VIEW, ApplicationEventGroup.ADMIN, NAME, null, pageId);
    return content;
}
Also used : VerticalLayout(com.vaadin.ui.VerticalLayout) CountryElement(com.hack23.cia.model.external.worldbank.countries.impl.CountryElement) Secured(org.springframework.security.access.annotation.Secured)

Example 2 with CountryElement

use of com.hack23.cia.model.external.worldbank.countries.impl.CountryElement in project cia by Hack23.

the class WorldbankCountryElementWorkConsumerImplITest method onMessageSuccessTest.

/**
 * On message success test.
 *
 * @throws JMSException
 *             the JMS exception
 */
@Test
@Transactional
public void onMessageSuccessTest() throws JMSException {
    final ObjectMessage message = mock(ObjectMessage.class);
    when(message.getObject()).thenReturn(new CountryElement());
    messsageListener.onMessage(message);
    verify(message, atLeastOnce()).getObject();
}
Also used : ObjectMessage(javax.jms.ObjectMessage) CountryElement(com.hack23.cia.model.external.worldbank.countries.impl.CountryElement) Test(org.junit.Test) AbstractServiceComponentAgentFunctionalIntegrationTest(com.hack23.cia.service.component.agent.impl.AbstractServiceComponentAgentFunctionalIntegrationTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with CountryElement

use of com.hack23.cia.model.external.worldbank.countries.impl.CountryElement in project cia by Hack23.

the class WorldBankCountryWorkGeneratorImpl method generateWorkOrders.

@Override
public void generateWorkOrders() {
    try {
        final List<CountryElement> countryList = worldbankCountryApi.getCountries();
        final Map<String, String> currentSaved = getImportService().getWorldBankCountryMap();
        for (final CountryElement countryElement : countryList) {
            if (countryElement.getCapitalCity() != null && countryElement.getCapitalCity().length() > 0 && !currentSaved.containsKey(countryElement.getIso2Code())) {
                getJmsSender().send(countryElementWorkdestination, countryElement);
            }
        }
    } catch (final DataFailureException exception) {
        LOGGER.warn("jms", exception);
    }
}
Also used : DataFailureException(com.hack23.cia.service.external.worldbank.api.DataFailureException) CountryElement(com.hack23.cia.model.external.worldbank.countries.impl.CountryElement)

Aggregations

CountryElement (com.hack23.cia.model.external.worldbank.countries.impl.CountryElement)3 AbstractServiceComponentAgentFunctionalIntegrationTest (com.hack23.cia.service.component.agent.impl.AbstractServiceComponentAgentFunctionalIntegrationTest)1 DataFailureException (com.hack23.cia.service.external.worldbank.api.DataFailureException)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 ObjectMessage (javax.jms.ObjectMessage)1 Test (org.junit.Test)1 Secured (org.springframework.security.access.annotation.Secured)1 Transactional (org.springframework.transaction.annotation.Transactional)1