Examples of ILayoutAttributeDescriptor


Examples of org.jasig.portal.layout.om.ILayoutAttributeDescriptor

        when(userProfile.getThemeStylesheetId()).thenReturn(1);
       
        final IStylesheetDescriptor stylesheetDescriptor = mock(IStylesheetDescriptor.class);
        when(stylesheetDescriptorDao.getStylesheetDescriptor(1)).thenReturn(stylesheetDescriptor);
       
        final ILayoutAttributeDescriptor skinLayoutAttributeDescriptor = mock(ILayoutAttributeDescriptor.class);
        when(stylesheetDescriptor.getLayoutAttributeDescriptor("minimized")).thenReturn(skinLayoutAttributeDescriptor);
        when(skinLayoutAttributeDescriptor.getName()).thenReturn("minimized");
        when(skinLayoutAttributeDescriptor.getScope()).thenReturn(Scope.REQUEST);
        when(skinLayoutAttributeDescriptor.getTargetElementNames()).thenReturn(Collections.singleton("folder"));
       
        final IOutputPropertyDescriptor mediaOutputPropertyDescriptor = mock(IOutputPropertyDescriptor.class);
        when(stylesheetDescriptor.getOutputPropertyDescriptor("media")).thenReturn(mediaOutputPropertyDescriptor);
        when(mediaOutputPropertyDescriptor.getName()).thenReturn("media");
        when(mediaOutputPropertyDescriptor.getScope()).thenReturn(Scope.SESSION);
View Full Code Here

Examples of org.jasig.portal.layout.om.ILayoutAttributeDescriptor

    @Override
    public String getLayoutAttribute(HttpServletRequest request, PreferencesScope prefScope, String nodeId, String name) {
        final StylesheetPreferencesKey stylesheetPreferencesKey = this.getStylesheetPreferencesKey(request, prefScope);
        final IStylesheetDescriptor stylesheetDescriptor = stylesheetPreferencesKey.stylesheetDescriptor;
        final ILayoutAttributeDescriptor layoutAttributeDescriptor = stylesheetDescriptor.getLayoutAttributeDescriptor(name);
        if (layoutAttributeDescriptor == null) {
            logger.warn("Attempted to get layout attribute {} for ID=\"{}\" but no such stylesheet parameter is defined in stylesheet descriptor {}. Null will be returned", new Object[] {name, nodeId, stylesheetDescriptor.getName()});
            return null;
        }


       
        //Load the default value
        String defaultValue = null;
        final IStylesheetUserPreferences distributedStylesheetUserPreferences = this.getDistributedStylesheetUserPreferences(request, prefScope);
        if (distributedStylesheetUserPreferences != null) {
            defaultValue = distributedStylesheetUserPreferences.getLayoutAttribute(nodeId, name);
           
            if (this.compareValues(defaultValue, layoutAttributeDescriptor.getDefaultValue())) {
                //DLM attribute value matches the stylesheet descriptor default, remove the DLM value
                distributedStylesheetUserPreferences.removeLayoutAttribute(nodeId, name);
                defaultValue = null;
            }
        }
       
        final String value;
        final Scope scope = layoutAttributeDescriptor.getScope();
        switch (scope) {
            case PERSISTENT: {
                final IStylesheetUserPreferences stylesheetUserPreferences = this.getStylesheetUserPreferences(request, stylesheetPreferencesKey);
                if (stylesheetUserPreferences == null) {
                    value = null;
                    break;
                }
               
                value = stylesheetUserPreferences.getLayoutAttribute(nodeId, name);
                break;
            }
            default: {
                final Map<String, String> nodeAttributes = this.getDataValue(request, stylesheetPreferencesKey, scope, LAYOUT_ATTRIBUTES_KEY, nodeId);
                if (nodeAttributes == null) {
                    value = null;
                    break;
                }
               
                value = nodeAttributes.get(name);
                break;
            }
        }
       
        if (value == null) {
            return defaultValue;
        }
       
        if (this.compareValues(value, layoutAttributeDescriptor.getDefaultValue()) || //Value is equal to stylesheet descriptor default
            (defaultValue != null && this.compareValues(value, defaultValue))) { //Value is equal to DLM stylesheet preferences default
           
            //Remove the user's customized value
            this.removeLayoutAttribute(request, prefScope, nodeId, name);
            return null;
View Full Code Here

Examples of org.jasig.portal.layout.om.ILayoutAttributeDescriptor

    @Transactional
    @Override
    public String setLayoutAttribute(HttpServletRequest request, PreferencesScope prefScope, String nodeId, String name, String value) {
        final StylesheetPreferencesKey stylesheetPreferencesKey = this.getStylesheetPreferencesKey(request, prefScope);
        final IStylesheetDescriptor stylesheetDescriptor = stylesheetPreferencesKey.stylesheetDescriptor;
        final ILayoutAttributeDescriptor layoutAttributeDescriptor = stylesheetDescriptor.getLayoutAttributeDescriptor(name);
        if (layoutAttributeDescriptor == null) {
            logger.warn("Attempted to set layout attribute {}={} on node with ID=\"{}\" but no such stylesheet parameter is defined in stylesheet descriptor {}. It will be ignored.", new Object[] {name, value, nodeId, stylesheetDescriptor.getName()});
            return null;
        }
       
        if (this.compareValues(value, layoutAttributeDescriptor.getDefaultValue())) {
            //Value matches the default value, remove the attribute
            return this.removeLayoutAttribute(request, prefScope, nodeId, name);
        }
       
        final IStylesheetUserPreferences distributedStylesheetUserPreferences = this.getDistributedStylesheetUserPreferences(request, prefScope);
View Full Code Here

Examples of org.jasig.portal.layout.om.ILayoutAttributeDescriptor

    @Transactional
    @Override
    public String removeLayoutAttribute(HttpServletRequest request, PreferencesScope prefScope, String nodeId, String name) {
        final StylesheetPreferencesKey stylesheetPreferencesKey = this.getStylesheetPreferencesKey(request, prefScope);
        final IStylesheetDescriptor stylesheetDescriptor = stylesheetPreferencesKey.stylesheetDescriptor;
        final ILayoutAttributeDescriptor layoutAttributeDescriptor = stylesheetDescriptor.getLayoutAttributeDescriptor(name);
        if (layoutAttributeDescriptor == null) {
            logger.warn("Attempted to remove layout attribute {} for ID=\"{}\" but no such stylesheet parameter is defined in stylesheet descriptor {}. It will be ignored.", new Object[] {name, nodeId, stylesheetDescriptor.getName()});
            return null;
        }
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.