Search in sources :

Example 21 with StartupForm

use of org.motechproject.server.web.form.StartupForm in project motech by motech.

the class StartupController method getStartupViewData.

@RequestMapping(value = "/startupviewdata", method = RequestMethod.GET)
@ResponseBody
public StartupViewData getStartupViewData(final HttpServletRequest request) {
    StartupViewData viewData = new StartupViewData();
    if (startupManager.canLaunchBundles()) {
        viewData.setRedirectHome(true);
        return viewData;
    } else {
        Locale userLocale = localeService.getUserLocale(request);
        ConfigSource configSource = (configurationService.loadBootstrapConfig() != null) ? configurationService.loadBootstrapConfig().getConfigSource() : ConfigSource.UI;
        boolean requiresConfigFiles = configSource.isFile() && configurationService.requiresConfigurationFiles();
        StartupForm startupSettings = new StartupForm();
        startupSettings.setLanguage(userLocale.getLanguage());
        viewData.setRequireConfigFiles(requiresConfigFiles);
        viewData.setSuggestions(createSuggestions());
        viewData.setStartupSettings(startupSettings);
        viewData.setLanguages(localeService.getSupportedLanguages());
        viewData.setPageLang(userLocale);
        viewData.setIsFileMode(ConfigSource.FILE.equals(configSource));
        viewData.setIsAdminRegistered(userService.hasActiveMotechAdmin());
        viewData.setRedirectHome(false);
    }
    return viewData;
}
Also used : Locale(java.util.Locale) ConfigSource(org.motechproject.config.core.domain.ConfigSource) StartupForm(org.motechproject.server.web.form.StartupForm) StartupViewData(org.motechproject.server.web.dto.StartupViewData) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

StartupForm (org.motechproject.server.web.form.StartupForm)21 Test (org.junit.Test)18 Locale (java.util.Locale)5 Matchers.anyString (org.mockito.Matchers.anyString)5 ArrayList (java.util.ArrayList)4 MotechSettings (org.motechproject.config.domain.MotechSettings)2 StartupViewData (org.motechproject.server.web.dto.StartupViewData)2 Properties (java.util.Properties)1 TreeMap (java.util.TreeMap)1 ConfigSource (org.motechproject.config.core.domain.ConfigSource)1 StartupSuggestionsForm (org.motechproject.server.web.form.StartupSuggestionsForm)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1