package org.molgenis.app; import freemarker.template.TemplateException; import org.molgenis.CommandLineOnlyConfiguration; import org.molgenis.DatabaseConfig; import org.molgenis.data.DataService; import org.molgenis.data.config.HttpClientConfig; import org.molgenis.data.elasticsearch.config.EmbeddedElasticSearchConfig; import org.molgenis.dataexplorer.freemarker.DataExplorerHyperlinkDirective; import org.molgenis.ui.MolgenisWebAppConfig; import org.molgenis.ui.freemarker.RepositoryTemplateLoader; import org.molgenis.util.GsonConfig; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.Import; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; import java.io.IOException; import java.util.Map; @Configuration @EnableTransactionManagement @EnableWebMvc @EnableAsync @ComponentScan(basePackages = "org.molgenis", excludeFilters = @Filter(type = FilterType.ANNOTATION, value = CommandLineOnlyConfiguration.class)) @Import({ WebAppSecurityConfig.class, DatabaseConfig.class, HttpClientConfig.class, EmbeddedElasticSearchConfig.class, GsonConfig.class }) public class WebAppConfig extends MolgenisWebAppConfig { @Autowired private DataService dataService; @Override protected void addFreemarkerVariables(Map<String, Object> freemarkerVariables) { freemarkerVariables .put("dataExplorerLink", new DataExplorerHyperlinkDirective(molgenisPluginRegistry(), dataService)); } /** * Configures Freemarker * * @return * @throws IOException * @throws TemplateException */ @Override public FreeMarkerConfigurer freeMarkerConfigurer() throws IOException, TemplateException { FreeMarkerConfigurer result = super.freeMarkerConfigurer(); // Look up unknown templates in the FreemarkerTemplate repository result.setPostTemplateLoaders(new RepositoryTemplateLoader(dataService)); return result; } }