Package org.gatein.mop.api

Examples of org.gatein.mop.api.Attributes


                            UIContainer dstDashboard = session.findObjectById(ObjectType.CONTAINER, app.getStorageId());
                            data = loadDashboard(dstDashboard);

                            // Update those attributes as we have to do it now, they don't exist in a container
                            // but do exist in a dashboard container
                            Attributes attrs = dstDashboard.getAttributes();
                            attrs.setValue(MappedAttributes.SHOW_INFO_BAR, app.isShowInfoBar());
                            attrs.setValue(MappedAttributes.SHOW_MODE, app.isShowApplicationMode());
                            attrs.setValue(MappedAttributes.SHOW_WINDOW_STATE, app.isShowApplicationState());
                            attrs.setValue(MappedAttributes.THEME, app.getTheme());
                        } else {
                            data = DashboardData.INITIAL_DASHBOARD;
                            transientDashboardData = (ApplicationData<?>) srcChild;
                        }

                        //
                        String icon = data.getIcon();
                        if (icon == null)
                            icon = app.getIcon();

                        String title = data.getTitle();
                        if (title == null)
                            title = app.getTitle();

                        String description = data.getDescription();
                        if (description == null)
                            description = app.getDescription();

                        String width = data.getWidth();
                        if (width == null)
                            width = app.getWidth();

                        String height = data.getHeight();
                        if (height == null)
                            height = app.getHeight();

                        data = new DashboardData(data.getStorageId(), data.getId(), data.getName(), icon, data.getTemplate(),
                                data.getFactoryId(), title, description, width, height, app.getAccessPermissions(),
                                data.getChildren());

                        //
                        srcChild = data;
                    }
                }
            }

            //
            UIComponent dstChild;
            if (srcChildId != null) {
                dstChild = session.findObjectById(ObjectType.COMPONENT, srcChildId);
                if (dstChild == null) {
                    throw new StaleModelException("Could not find supposed present child with id " + srcChildId);
                }

                // julien : this can fail due to a bug in chromattic not implementing equals method properly
                // and is replaced with the foreach below
                /*
                 * if (!dst.contains(dstChild)) { throw new IllegalArgumentException("Attempt for updating a ui component " +
                 * session.pathOf(dstChild) + "that is not present in the target ui container " + session.pathOf(dst)); }
                 */
                boolean found = false;
                for (UIComponent child : dst.getComponents()) {
                    if (child.getObjectId().equals(srcChildId)) {
                        found = true;
                        break;
                    }
                }

                //
                if (!found) {
                    if (hierarchyRelationships.containsKey(srcChildId)) {
                        String srcId = hierarchyRelationships.get(srcChildId);

                        // It's a move operation, so we move the node first
                        dst.getComponents().add(dstChild);

                        //
                        changes.add(new ModelChange.Move(srcId, dst.getObjectId(), srcChildId));
                    } else {
                        throw new IllegalArgumentException("Attempt for updating a ui component " + session.pathOf(dstChild)
                                + " that is not present in the target ui container " + session.pathOf(dst));
                    }
                }

                //
                changes.add(new ModelChange.Update(srcChild));
            } else {
                String name = srcChild.getStorageName();
                if (name == null) {
                    // We manufacture one name
                    name = UUID.randomUUID().toString();
                }
                if (srcChild instanceof ContainerData) {
                    dstChild = dst.add(ObjectType.CONTAINER, name);
                } else if (srcChild instanceof ApplicationData) {
                    dstChild = dst.add(ObjectType.WINDOW, name);
                } else if (srcChild instanceof BodyData) {
                    dstChild = dst.add(ObjectType.BODY, name);
                } else {
                    throw new StaleModelException("Was not expecting child " + srcChild);
                }
                changes.add(new ModelChange.Create(dst.getObjectId(), srcChild));
            }

            //
            if (transientDashboardData != null) {
                Attributes attrs = dstChild.getAttributes();
                attrs.setValue(MappedAttributes.SHOW_INFO_BAR, transientDashboardData.isShowInfoBar());
                attrs.setValue(MappedAttributes.SHOW_MODE, transientDashboardData.isShowApplicationMode());
                attrs.setValue(MappedAttributes.SHOW_WINDOW_STATE, transientDashboardData.isShowApplicationState());
                attrs.setValue(MappedAttributes.THEME, transientDashboardData.getTheme());
            }
            save(srcChild, dstChild, changes, hierarchyRelationships);

            //
            String dstChildId = dstChild.getObjectId();
View Full Code Here


        //
        org.gatein.mop.api.workspace.Page dstPage = dstPages.addChild(dst.getName());

        // Copy all attributes
        Attributes srcAttrs = srcPage.getAttributes();
        Attributes dstAttrs = dstPage.getAttributes();
        for (String key : srcAttrs.getKeys()) {
            Object value = srcAttrs.getObject(key);
            dstAttrs.setObject(key, value);
        }

        // Copy described
        Described srcDescribed = srcPage.adapt(Described.class);
        Described dstDescribed = dstPage.adapt(Described.class);
View Full Code Here

                dstPR.setAccessPermissions(srcPR.getAccessPermissions());
                dstPR.setEditPermission(srcPR.getEditPermission());
            }

            //
            Attributes srcAttrs = srcChild.getAttributes();
            Attributes dstAttrs = dstChild.getAttributes();
            for (String key : srcAttrs.getKeys()) {
                Object value = srcAttrs.getObject(key);
                dstAttrs.setObject(key, value);
            }

            //
            if (srcChild instanceof UIWindow) {
                UIWindow srcWindow = (UIWindow) srcChild;
View Full Code Here

            dst.getComponents().add(j, a[j]);
        }
    }

    public <S> ApplicationData<S> load(UIWindow src) {
        Attributes attrs = src.getAttributes();

        //
        Customization<?> customization = src.getCustomization();

        //
        ContentType<?> contentType = customization.getType();

        //
        String customizationid = customization.getId();

        // julien: should type check that
        ApplicationType<S> type = (ApplicationType<S>) ApplicationType.getType(contentType);

        //
        PersistentApplicationState<S> instanceState = new PersistentApplicationState<S>(customizationid);

        //
        HashMap<String, String> properties = new HashMap<String, String>();
        load(attrs, properties, windowPropertiesBlackList);

        //
        List<String> accessPermissions = Collections.emptyList();
        if (src.isAdapted(ProtectedResource.class)) {
            ProtectedResource pr = src.adapt(ProtectedResource.class);
            accessPermissions = pr.getAccessPermissions();
        }

        //
        Described described = src.adapt(Described.class);

        //
        boolean showInfoBar = attrs.getValue(MappedAttributes.SHOW_INFO_BAR, false);
        boolean showWindowState = attrs.getValue(MappedAttributes.SHOW_WINDOW_STATE, false);
        boolean showMode = attrs.getValue(MappedAttributes.SHOW_MODE, false);
        String theme = attrs.getValue(MappedAttributes.THEME, null);

        //
        return new ApplicationData<S>(src.getObjectId(), src.getName(), type, instanceState, null, described.getName(),
                attrs.getValue(MappedAttributes.ICON), described.getDescription(), showInfoBar, showWindowState, showMode,
                theme, attrs.getValue(MappedAttributes.WIDTH), attrs.getValue(MappedAttributes.HEIGHT),
                Utils.safeImmutableMap(properties), Utils.safeImmutableList(accessPermissions));
    }
View Full Code Here

        Described described = dst.adapt(Described.class);
        described.setName(src.getTitle());
        described.setDescription(src.getDescription());

        //
        Attributes attrs = dst.getAttributes();
        attrs.setValue(MappedAttributes.SHOW_INFO_BAR, src.isShowInfoBar());
        attrs.setValue(MappedAttributes.SHOW_WINDOW_STATE, src.isShowApplicationState());
        attrs.setValue(MappedAttributes.SHOW_MODE, src.isShowApplicationMode());
        attrs.setValue(MappedAttributes.THEME, src.getTheme());
        attrs.setValue(MappedAttributes.ICON, src.getIcon());
        attrs.setValue(MappedAttributes.WIDTH, src.getWidth());
        attrs.setValue(MappedAttributes.HEIGHT, src.getHeight());
        save(src.getProperties(), attrs, windowPropertiesBlackList);

        //
        ApplicationState<S> instanceState = src.getState();
View Full Code Here

        //
        Described described = container.adapt(Described.class);

        //
        Attributes attrs = container.getAttributes();
        List<ComponentData> children = loadChildren(container);
        return new DashboardData(container.getObjectId(), attrs.getValue(MappedAttributes.ID),
                attrs.getValue(MappedAttributes.NAME), attrs.getValue(MappedAttributes.ICON),
                attrs.getValue(MappedAttributes.TEMPLATE), attrs.getValue(MappedAttributes.FACTORY_ID), described.getName(),
                described.getDescription(), attrs.getValue(MappedAttributes.WIDTH), attrs.getValue(MappedAttributes.HEIGHT),
                Utils.safeImmutableList(accessPermissions), children);
    }
View Full Code Here

    final List<String> moveContainersPermissions;

    public PageState(Page page) {

        Attributes attrs = page.getAttributes();
        Described described = page.adapt(Described.class);

        //
        List<String> accessPermissions = Collections.emptyList();
        String editPermission = null;
        if (page.isAdapted(ProtectedResource.class)) {
            ProtectedResource pr = page.adapt(ProtectedResource.class);
            accessPermissions = pr.getAccessPermissions();
            editPermission = pr.getEditPermission();
        }

        //
        this.factoryId = attrs.getValue(MappedAttributes.FACTORY_ID);
        this.displayName = described.getName();
        this.description = described.getDescription();
        this.accessPermissions = Utils.safeImmutableList(accessPermissions);
        this.editPermission = editPermission;
        this.showMaxWindow = attrs.getValue(MappedAttributes.SHOW_MAX_WINDOW, false);

        if (page.isAdapted(ProtectedContainer.class)) {
            ProtectedContainer pc = page.adapt(ProtectedContainer.class);
            this.moveAppsPermissions = pc.getMoveAppsPermissions();
            this.moveContainersPermissions = pc.getMoveContainersPermissions();
View Full Code Here

            restrictAccess.setStartPublicationDate(state.getStartPublicationDate());
            restrictAccess.setEndPublicationDate(state.getEndPublicationDate());
            restrictAccess.setRestrictOutsidePublicationWindow(state.isRestrictOutsidePublicationWindow());

            // Sync the attributes
            Attributes attrs = sourceNav.getAttributes();
            AttributesState.sync(state.getAttributesState(), CUSTOM_NODE_ATTRIBUTE_PREFIX, attrs);
            attrs.setValue(MappedAttributes.ICON, state.getIcon());

            //
            source.data = new NodeData(sourceNav);
            source.state = null;
View Full Code Here

                pageRef = Utils.siteType(site.getObjectType()).key(site.getName()).page(target.getName());
            }
        }

        //
        Attributes attrs = navigation.getAttributes();
        AttributesState attributesState = new AttributesState.Builder()
                .attributes(NavigationServiceImpl.CUSTOM_NODE_ATTRIBUTE_PREFIX, attrs)
                .build();

        //
        NodeState state = new NodeState(label, attrs.getValue(MappedAttributes.ICON),
                startPublicationDate != null ? startPublicationDate.getTime() : -1,
                endPublicationDate != null ? endPublicationDate.getTime() : -1, visibility, pageRef,
                restrictOutsidePublicationWindow,
                attributesState);
View Full Code Here

      if (type == NavigationData.class)
      {
         Site site = src.getSite();
         String ownerType = getOwnerType(site.getObjectType());
         String ownerId = site.getName();
         Attributes attrs = src.getAttributes();
         NavigationData dstNav = new NavigationData(
            src.getObjectId(),
            ownerType,
            ownerId,
            attrs.getValue(MappedAttributes.PRIORITY, 1),
            children);
         dst = (T)dstNav;
      }
      else if (type == NavigationNodeData.class)
      {
         Attributes attrs = src.getAttributes();
         String pageReference = null;
         Link link = src.getLink();
         if (link instanceof PageLink)
         {
            PageLink pageLink = (PageLink)link;
            org.gatein.mop.api.workspace.Page target = pageLink.getPage();
            if (target != null)
            {
               Site site = target.getSite();
               ObjectType<? extends Site> siteType = site.getObjectType();
               pageReference = getOwnerType(siteType) + "::" + site.getName() + "::" + target.getName();
            }
         }

         //
         Described described = src.adapt(Described.class);

         //
         Visible visible = src.adapt(Visible.class);

         //
         NavigationNodeData dstNode = new NavigationNodeData(
            src.getObjectId(),
            attrs.getValue(MappedAttributes.URI),
            described.getName(),
            attrs.getValue(MappedAttributes.ICON),
            src.getName(),
            visible.getStartPublicationDate(),
            visible.getEndPublicationDate(),
            visible.getVisibility() != null ? visible.getVisibility() : Visibility.DISPLAYED,
            pageReference,
View Full Code Here

TOP

Related Classes of org.gatein.mop.api.Attributes

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.