Package org.jasig.portal.layout

Examples of org.jasig.portal.layout.StylesheetUserPreferencesImpl


        final IStylesheetDescriptor stylesheetDescriptor = this.stylesheetDescriptorDao
                .getStylesheetDescriptor(stylesheetDescriptorId);
        final IStylesheetUserPreferences stylesheetUserPreferences = this.stylesheetUserPreferencesDao
                .getStylesheetUserPreferences(stylesheetDescriptor, person, profile);

        final IStylesheetUserPreferences distributedStylesheetUserPreferences = new StylesheetUserPreferencesImpl(
                stylesheetDescriptorId, person.getID(), profile.getProfileId());

        final FragmentActivator fragmentActivator = this.getFragmentActivator();

        for (final String fragName : fragmentNames) {
            final FragmentDefinition fragmentDefinition = this.configurationLoader.getFragmentByName(fragName);

            //UserView may be missing if the fragment isn't defined correctly
            final UserView userView = fragmentActivator.getUserView(fragmentDefinition, locale);
            if (userView == null) {
                logger.warn("No UserView is present for fragment {} it will be skipped when loading distributed stylesheet user preferences",
                            fragmentDefinition.getName());
                continue;
            }

            //IStylesheetUserPreferences only exist if something was actually set
            final IStylesheetUserPreferences fragmentStylesheetUserPreferences = this.stylesheetUserPreferencesDao
                    .getStylesheetUserPreferences(stylesheetDescriptor, userView.getUserId(), userView.profileId);
            if (fragmentStylesheetUserPreferences == null) {
                continue;
            }

            //Get the info needed to DLMify node IDs
            final Element root = userView.layout.getDocumentElement();
            final String labelBase = root.getAttribute(Constants.ATT_ID);

            boolean modified = false;

            //Copy all of the fragment preferences into the distributed preferences
            final Collection<String> allLayoutAttributeNodeIds = fragmentStylesheetUserPreferences
                    .getAllLayoutAttributeNodeIds();
            for (final String fragmentNodeId : allLayoutAttributeNodeIds) {
                final String userNodeId;
                if (!fragmentNodeId.startsWith(Constants.FRAGMENT_ID_USER_PREFIX)) {
                    userNodeId = labelBase + fragmentNodeId;
                }
                else {
                    userNodeId = fragmentNodeId;
                }

                final MapPopulator<String, String> layoutAttributesPopulator = new MapPopulator<String, String>();
                fragmentStylesheetUserPreferences.populateLayoutAttributes(fragmentNodeId, layoutAttributesPopulator);
                final Map<String, String> layoutAttributes = layoutAttributesPopulator.getMap();
                for (final Map.Entry<String, String> layoutAttributesEntry : layoutAttributes.entrySet()) {
                    final String name = layoutAttributesEntry.getKey();
                    final String value = layoutAttributesEntry.getValue();

                    //Fragmentize the nodeId here
                    distributedStylesheetUserPreferences.setLayoutAttribute(userNodeId, name, value);

                    //Clean out user preferences data that matches data from the fragment.
                    if (stylesheetUserPreferences != null) {
                        final String userValue = stylesheetUserPreferences.getLayoutAttribute(userNodeId, name);
                        if (userValue != null && userValue.equals(value)) {
View Full Code Here

TOP

Related Classes of org.jasig.portal.layout.StylesheetUserPreferencesImpl

Copyright © 2018 www.massapicom. 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.