Search in sources :

Example 1 with Portal

use of com.hack23.cia.model.internal.application.system.impl.Portal in project cia by Hack23.

the class AdminPortalPageModContentFactoryImpl 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_PORTAL);
    final DataContainer<Portal, Long> dataContainer = getApplicationManager().getDataContainer(Portal.class);
    final List<Portal> pageOrderBy = dataContainer.getPageOrderBy(pageNr, DEFAULT_RESULTS_PER_PAGE, Portal_.portalName);
    createPagingControls(content, NAME, pageId, dataContainer.getSize(), pageNr, DEFAULT_RESULTS_PER_PAGE);
    getGridFactory().createBasicBeanItemGrid(content, Portal.class, pageOrderBy, PORTAL2, COLUMN_ORDER, HIDE_COLUMNS, new PageItemPropertyClickListener(AdminViews.ADMIN_PORTAL_VIEW_NAME, "hjid"), null, null);
    if (pageId != null && !pageId.isEmpty()) {
        final Portal portal = dataContainer.load(Long.valueOf(pageId));
        if (portal != null) {
            getFormFactory().addFormPanelTextFields(content, portal, Portal.class, AS_LIST);
        }
    }
    getPageActionEventHelper().createPageEvent(ViewAction.VISIT_ADMIN_PORTAL_VIEW, ApplicationEventGroup.ADMIN, NAME, null, pageId);
    return content;
}
Also used : PageItemPropertyClickListener(com.hack23.cia.web.impl.ui.application.views.pageclicklistener.PageItemPropertyClickListener) VerticalLayout(com.vaadin.ui.VerticalLayout) Portal(com.hack23.cia.model.internal.application.system.impl.Portal) Secured(org.springframework.security.access.annotation.Secured)

Example 2 with Portal

use of com.hack23.cia.model.internal.application.system.impl.Portal in project cia by Hack23.

the class ConfigurationManagerImpl method getUserConfiguration.

@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public UserConfiguration getUserConfiguration(final String url, final String locale) {
    final Agency agency = agencyDAO.getAll().get(0);
    Portal usePortal = null;
    final LanguageData languageData = findLanguage(locale);
    for (final Portal portal : agency.getPortals()) {
        if (usePortal == null && PortalType.DEFAULT == portal.getPortalType() || url.contains(portal.getPortalName())) {
            usePortal = portal;
        }
    }
    return new UserConfigurationImpl(agency, usePortal, languageData);
}
Also used : Agency(com.hack23.cia.model.internal.application.system.impl.Agency) LanguageData(com.hack23.cia.model.internal.application.system.impl.LanguageData) Portal(com.hack23.cia.model.internal.application.system.impl.Portal) Secured(org.springframework.security.access.annotation.Secured)

Example 3 with Portal

use of com.hack23.cia.model.internal.application.system.impl.Portal in project cia by Hack23.

the class ConfigurationManagerImpl method createDefaultConfigIfEmpty.

@Secured({ "ROLE_ADMIN" })
@Override
public void createDefaultConfigIfEmpty() {
    if (agencyDAO.getAll().isEmpty()) {
        final List<Portal> portals = new ArrayList<>();
        final Portal defaulPortal = new Portal().withPortalType(PortalType.DEFAULT).withDescription("Global Portal").withPortalName("Default");
        portals.add(defaulPortal);
        final Portal domainPortal = new Portal().withPortalType(PortalType.DOMAIN).withDescription("Hack23.com").withPortalName("www.hack23.com");
        portals.add(domainPortal);
        final Agency agency = new Agency().withAgencyName("Citizen Intelligence Agency").withDescription("Tracking politicians like bugs");
        agency.setPortals(portals);
        agencyDAO.persist(agency);
    }
}
Also used : Agency(com.hack23.cia.model.internal.application.system.impl.Agency) ArrayList(java.util.ArrayList) Portal(com.hack23.cia.model.internal.application.system.impl.Portal) Secured(org.springframework.security.access.annotation.Secured)

Example 4 with Portal

use of com.hack23.cia.model.internal.application.system.impl.Portal in project cia by Hack23.

the class AdminRoleSystemTest method siteAdminPortalTest.

/**
 * Site admin portal test.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void siteAdminPortalTest() throws Exception {
    final WebDriver driver = getWebDriver();
    assertNotNull(NO_WEBDRIVER_EXIST_FOR_BROWSER + browser, driver);
    final UserPageVisit userPageVisit = new UserPageVisit(driver, browser);
    loginAsAdmin(userPageVisit);
    userPageVisit.visitDirectPage(new PageModeMenuCommand(AdminViews.ADMIN_PORTAL_VIEW_NAME, ""));
    assertTrue("Expect content", userPageVisit.checkHtmlBodyContainsText("Portal"));
    clickFirstRowInGrid(userPageVisit);
    userPageVisit.validatePage(new PageModeMenuCommand(AdminViews.ADMIN_PORTAL_VIEW_NAME, ""));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) PageModeMenuCommand(com.hack23.cia.web.impl.ui.application.views.common.pagelinks.api.PageModeMenuCommand) Test(org.junit.Test)

Example 5 with Portal

use of com.hack23.cia.model.internal.application.system.impl.Portal in project cia by Hack23.

the class AdminAgencyPageModContentFactoryImpl 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_AGENCY);
    final DataContainer<Agency, Long> dataContainer = getApplicationManager().getDataContainer(Agency.class);
    final List<Agency> pageOrderBy = dataContainer.getPageOrderBy(pageNr, DEFAULT_RESULTS_PER_PAGE, Agency_.agencyName);
    createPagingControls(content, NAME, pageId, dataContainer.getSize(), pageNr, DEFAULT_RESULTS_PER_PAGE);
    getGridFactory().createBasicBeanItemGrid(content, Agency.class, pageOrderBy, AGENCY, AGENCY_GRID_COLUMN_ORDER, AGENCY_GRID_HIDE_COLUMNS, AGENCY_GRID_LISTENER, null, AGENCY_GRID_COLLECTION_PROPERTY_CONVERTERS);
    if (pageId != null && !pageId.isEmpty()) {
        final VerticalLayout leftLayout = new VerticalLayout();
        leftLayout.setSizeFull();
        final VerticalLayout rightLayout = new VerticalLayout();
        rightLayout.setSizeFull();
        final HorizontalLayout horizontalLayout = new HorizontalLayout();
        horizontalLayout.setWidth(ContentSize.FULL_SIZE);
        content.addComponent(horizontalLayout);
        content.setExpandRatio(horizontalLayout, ContentRatio.LARGE_FORM);
        horizontalLayout.addComponent(leftLayout);
        horizontalLayout.addComponent(rightLayout);
        final Agency agency = dataContainer.load(Long.valueOf(pageId));
        if (agency != null) {
            getFormFactory().addFormPanelTextFields(leftLayout, agency, Agency.class, AGENCY_FORM_FIELDS);
            getGridFactory().createBasicBeanItemGrid(rightLayout, Portal.class, agency.getPortals(), PORTAL, PORTAL_GRID_COLUMN_ORDER, PORTAL_GRID_HIDE_COLUMNS, PORTAL_GRID_LISTENER, null, null);
        }
    }
    getPageActionEventHelper().createPageEvent(ViewAction.VISIT_ADMIN_AGENCY_VIEW, ApplicationEventGroup.ADMIN, NAME, null, pageId);
    return content;
}
Also used : Agency(com.hack23.cia.model.internal.application.system.impl.Agency) VerticalLayout(com.vaadin.ui.VerticalLayout) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Secured(org.springframework.security.access.annotation.Secured)

Aggregations

Secured (org.springframework.security.access.annotation.Secured)4 Agency (com.hack23.cia.model.internal.application.system.impl.Agency)3 Portal (com.hack23.cia.model.internal.application.system.impl.Portal)3 VerticalLayout (com.vaadin.ui.VerticalLayout)2 LanguageData (com.hack23.cia.model.internal.application.system.impl.LanguageData)1 PageModeMenuCommand (com.hack23.cia.web.impl.ui.application.views.common.pagelinks.api.PageModeMenuCommand)1 PageItemPropertyClickListener (com.hack23.cia.web.impl.ui.application.views.pageclicklistener.PageItemPropertyClickListener)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 WebDriver (org.openqa.selenium.WebDriver)1