Search in sources :

Example 1 with IStylesheetParameterDescriptor

use of org.apereo.portal.layout.om.IStylesheetParameterDescriptor in project uPortal by Jasig.

the class SingleTabUrlNodeSyntaxHelper method getDefaultTabIndex.

/** Get the index of the default tab for the user */
protected String getDefaultTabIndex(HttpServletRequest httpServletRequest) {
    final String stylesheetParameter = this.stylesheetUserPreferencesService.getStylesheetParameter(httpServletRequest, PreferencesScope.STRUCTURE, this.defaultTabParameter);
    if (stylesheetParameter != null) {
        return stylesheetParameter;
    }
    final IStylesheetDescriptor stylesheetDescriptor = this.stylesheetUserPreferencesService.getStylesheetDescriptor(httpServletRequest, PreferencesScope.STRUCTURE);
    final IStylesheetParameterDescriptor stylesheetParameterDescriptor = stylesheetDescriptor.getStylesheetParameterDescriptor(this.defaultTabParameter);
    if (stylesheetParameterDescriptor != null) {
        return stylesheetParameterDescriptor.getDefaultValue();
    }
    return null;
}
Also used : IStylesheetParameterDescriptor(org.apereo.portal.layout.om.IStylesheetParameterDescriptor) IStylesheetDescriptor(org.apereo.portal.layout.om.IStylesheetDescriptor)

Example 2 with IStylesheetParameterDescriptor

use of org.apereo.portal.layout.om.IStylesheetParameterDescriptor in project uPortal by Jasig.

the class StylesheetDescriptorTransformerConfigurationSource method getCacheKey.

@Override
public final CacheKey getCacheKey(HttpServletRequest request, HttpServletResponse response) {
    final CacheKeyBuilder cacheKeyBuilder = CacheKey.builder(this.getName());
    final PreferencesScope preferencesScope = this.getStylesheetPreferencesScope(request);
    final IStylesheetDescriptor stylesheetDescriptor = this.stylesheetUserPreferencesService.getStylesheetDescriptor(request, preferencesScope);
    //Build key from stylesheet descriptor parameters
    for (final IStylesheetParameterDescriptor stylesheetParameterDescriptor : stylesheetDescriptor.getStylesheetParameterDescriptors()) {
        final String defaultValue = stylesheetParameterDescriptor.getDefaultValue();
        if (defaultValue != null) {
            final String name = stylesheetParameterDescriptor.getName();
            cacheKeyBuilder.put(name, defaultValue);
        }
    }
    return cacheKeyBuilder.build();
}
Also used : IStylesheetParameterDescriptor(org.apereo.portal.layout.om.IStylesheetParameterDescriptor) CacheKeyBuilder(org.apereo.portal.utils.cache.CacheKey.CacheKeyBuilder) IStylesheetDescriptor(org.apereo.portal.layout.om.IStylesheetDescriptor) PreferencesScope(org.apereo.portal.layout.IStylesheetUserPreferencesService.PreferencesScope)

Example 3 with IStylesheetParameterDescriptor

use of org.apereo.portal.layout.om.IStylesheetParameterDescriptor in project uPortal by Jasig.

the class StylesheetDescriptorTransformerConfigurationSource method getParameters.

@Override
public final Map<String, Object> getParameters(HttpServletRequest request, HttpServletResponse response) {
    final PreferencesScope preferencesScope = this.getStylesheetPreferencesScope(request);
    final IStylesheetDescriptor stylesheetDescriptor = this.stylesheetUserPreferencesService.getStylesheetDescriptor(request, preferencesScope);
    //Build map of stylesheet descriptor parameters
    final LinkedHashMap<String, Object> parameters = new LinkedHashMap<String, Object>();
    for (final IStylesheetParameterDescriptor stylesheetParameterDescriptor : stylesheetDescriptor.getStylesheetParameterDescriptors()) {
        final String defaultValue = stylesheetParameterDescriptor.getDefaultValue();
        if (defaultValue != null) {
            final String name = stylesheetParameterDescriptor.getName();
            parameters.put(name, defaultValue);
        }
    }
    return parameters;
}
Also used : IStylesheetParameterDescriptor(org.apereo.portal.layout.om.IStylesheetParameterDescriptor) IStylesheetDescriptor(org.apereo.portal.layout.om.IStylesheetDescriptor) PreferencesScope(org.apereo.portal.layout.IStylesheetUserPreferencesService.PreferencesScope) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with IStylesheetParameterDescriptor

use of org.apereo.portal.layout.om.IStylesheetParameterDescriptor in project uPortal by Jasig.

the class WindowStateSettingsStAXComponent method getEventReader.

/* (non-Javadoc)
     * @see org.apereo.portal.rendering.PipelineComponent#getEventReader(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
     */
@Override
public PipelineEventReader<XMLEventReader, XMLEvent> getEventReader(HttpServletRequest request, HttpServletResponse response) {
    final PipelineEventReader<XMLEventReader, XMLEvent> pipelineEventReader = this.wrappedComponent.getEventReader(request, response);
    final XMLEventReader eventReader = pipelineEventReader.getEventReader();
    final IStylesheetDescriptor stylesheetDescriptor = stylesheetAttributeSource.getStylesheetDescriptor(request);
    final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
    final XMLEventReader filteredEventReader;
    if (portalRequestInfo.getTargetedPortletWindowId() == null) {
        final IStylesheetParameterDescriptor defaultWindowStateParam = stylesheetDescriptor.getStylesheetParameterDescriptor("dashboardForcedWindowState");
        if (defaultWindowStateParam != null) {
            //Set all window states to the specified default
            final WindowState windowState = PortletUtils.getWindowState(defaultWindowStateParam.getDefaultValue());
            filteredEventReader = new SinglePortletWindowStateSettingXMLEventReader(request, eventReader, windowState);
        } else {
            //Make sure there aren't any portlets in a "targeted" window state
            filteredEventReader = new NonTargetedPortletWindowStateSettingXMLEventReader(request, eventReader);
        }
    } else {
        //Not mobile, don't bother filtering
        filteredEventReader = eventReader;
    }
    final Map<String, String> outputProperties = pipelineEventReader.getOutputProperties();
    return new PipelineEventReaderImpl<XMLEventReader, XMLEvent>(filteredEventReader, outputProperties);
}
Also used : WindowState(javax.portlet.WindowState) IStylesheetParameterDescriptor(org.apereo.portal.layout.om.IStylesheetParameterDescriptor) IPortalRequestInfo(org.apereo.portal.url.IPortalRequestInfo) XMLEvent(javax.xml.stream.events.XMLEvent) XMLEventReader(javax.xml.stream.XMLEventReader) FilteringXMLEventReader(org.apereo.portal.xml.stream.FilteringXMLEventReader) IStylesheetDescriptor(org.apereo.portal.layout.om.IStylesheetDescriptor)

Example 5 with IStylesheetParameterDescriptor

use of org.apereo.portal.layout.om.IStylesheetParameterDescriptor in project uPortal by Jasig.

the class StylesheetDescriptorImporterExporter method importData.

/* (non-Javadoc)
     * @see org.apereo.portal.io.xml.IDataImporterExporter#importData(java.lang.Object)
     */
@Transactional
@Override
public void importData(ExternalStylesheetDescriptor data) {
    final String stylesheetName = data.getName();
    final String uri = data.getUri();
    IStylesheetDescriptor stylesheetDescriptor = this.stylesheetDescriptorDao.getStylesheetDescriptorByName(stylesheetName);
    if (stylesheetDescriptor == null) {
        stylesheetDescriptor = this.stylesheetDescriptorDao.createStylesheetDescriptor(stylesheetName, uri);
    } else {
        stylesheetDescriptor.setStylesheetResource(uri);
    }
    stylesheetDescriptor.setUrlNodeSyntaxHelperName(data.getUrlSyntaxHelper());
    stylesheetDescriptor.setDescription(data.getDescription());
    final List<ExternalOutputPropertyDescriptor> extOutputProperties = data.getOutputProperties();
    final List<IOutputPropertyDescriptor> outputPropertyDescriptors = new ArrayList<IOutputPropertyDescriptor>(extOutputProperties.size());
    for (final ExternalOutputPropertyDescriptor extOutputProperty : extOutputProperties) {
        final String name = extOutputProperty.getName();
        final Scope scope = Scope.valueOf(extOutputProperty.getScope().name());
        final OutputPropertyDescriptorImpl outputPropertyDescriptor = new OutputPropertyDescriptorImpl(name, scope);
        outputPropertyDescriptor.setDefaultValue(extOutputProperty.getDefaultValue());
        outputPropertyDescriptor.setDescription(extOutputProperty.getDescription());
        outputPropertyDescriptors.add(outputPropertyDescriptor);
    }
    stylesheetDescriptor.setOutputPropertyDescriptors(outputPropertyDescriptors);
    final List<ExternalStylesheetParameterDescriptor> extStylesheetParameters = data.getStylesheetParameters();
    final List<IStylesheetParameterDescriptor> stylesheetParameterDescriptors = new ArrayList<IStylesheetParameterDescriptor>(extOutputProperties.size());
    for (final ExternalStylesheetParameterDescriptor extStylesheetParameter : extStylesheetParameters) {
        final String name = extStylesheetParameter.getName();
        final Scope scope = Scope.valueOf(extStylesheetParameter.getScope().name());
        final StylesheetParameterDescriptorImpl stylesheetParameterDescriptor = new StylesheetParameterDescriptorImpl(name, scope);
        stylesheetParameterDescriptor.setDefaultValue(extStylesheetParameter.getDefaultValue());
        stylesheetParameterDescriptor.setDescription(extStylesheetParameter.getDescription());
        stylesheetParameterDescriptors.add(stylesheetParameterDescriptor);
    }
    stylesheetDescriptor.setStylesheetParameterDescriptors(stylesheetParameterDescriptors);
    final List<ExternalLayoutAttributeDescriptor> extLayoutAttributes = data.getLayoutAttributes();
    final List<ILayoutAttributeDescriptor> layoutAttributeDescriptors = new ArrayList<ILayoutAttributeDescriptor>(extOutputProperties.size());
    for (final ExternalLayoutAttributeDescriptor extLayoutAttribute : extLayoutAttributes) {
        final String name = extLayoutAttribute.getName();
        final Scope scope = Scope.valueOf(extLayoutAttribute.getScope().name());
        final LayoutAttributeDescriptorImpl layoutAttributeDescriptor = new LayoutAttributeDescriptorImpl(name, scope);
        layoutAttributeDescriptor.setDefaultValue(extLayoutAttribute.getDefaultValue());
        layoutAttributeDescriptor.setDescription(extLayoutAttribute.getDescription());
        layoutAttributeDescriptor.setTargetElementNames(new LinkedHashSet<String>(extLayoutAttribute.getTargetElements()));
        layoutAttributeDescriptors.add(layoutAttributeDescriptor);
    }
    stylesheetDescriptor.setLayoutAttributeDescriptors(layoutAttributeDescriptors);
    this.stylesheetDescriptorDao.updateStylesheetDescriptor(stylesheetDescriptor);
}
Also used : LayoutAttributeDescriptorImpl(org.apereo.portal.layout.dao.jpa.LayoutAttributeDescriptorImpl) OutputPropertyDescriptorImpl(org.apereo.portal.layout.dao.jpa.OutputPropertyDescriptorImpl) ArrayList(java.util.ArrayList) StylesheetParameterDescriptorImpl(org.apereo.portal.layout.dao.jpa.StylesheetParameterDescriptorImpl) ILayoutAttributeDescriptor(org.apereo.portal.layout.om.ILayoutAttributeDescriptor) IOutputPropertyDescriptor(org.apereo.portal.layout.om.IOutputPropertyDescriptor) IStylesheetParameterDescriptor(org.apereo.portal.layout.om.IStylesheetParameterDescriptor) Scope(org.apereo.portal.layout.om.IStylesheetData.Scope) IStylesheetDescriptor(org.apereo.portal.layout.om.IStylesheetDescriptor) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

IStylesheetParameterDescriptor (org.apereo.portal.layout.om.IStylesheetParameterDescriptor)11 IStylesheetDescriptor (org.apereo.portal.layout.om.IStylesheetDescriptor)10 Scope (org.apereo.portal.layout.om.IStylesheetData.Scope)5 IStylesheetUserPreferences (org.apereo.portal.layout.om.IStylesheetUserPreferences)5 ILayoutAttributeDescriptor (org.apereo.portal.layout.om.ILayoutAttributeDescriptor)3 IOutputPropertyDescriptor (org.apereo.portal.layout.om.IOutputPropertyDescriptor)3 Transactional (org.springframework.transaction.annotation.Transactional)3 PreferencesScope (org.apereo.portal.layout.IStylesheetUserPreferencesService.PreferencesScope)2 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 WindowState (javax.portlet.WindowState)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpSession (javax.servlet.http.HttpSession)1 XMLEventReader (javax.xml.stream.XMLEventReader)1 XMLEvent (javax.xml.stream.events.XMLEvent)1 IUserPreferencesManager (org.apereo.portal.IUserPreferencesManager)1 IUserProfile (org.apereo.portal.IUserProfile)1 IStylesheetDescriptorDao (org.apereo.portal.layout.dao.IStylesheetDescriptorDao)1 IStylesheetUserPreferencesDao (org.apereo.portal.layout.dao.IStylesheetUserPreferencesDao)1 LayoutAttributeDescriptorImpl (org.apereo.portal.layout.dao.jpa.LayoutAttributeDescriptorImpl)1