Package org.eurekastreams.server.domain

Examples of org.eurekastreams.server.domain.Tab


        for (Gadget gadget : newTabTemplate.getGadgets())
        {
            gadget.setOwner(currentUser);
        }

        currentUser.getStartTabGroup().addTab(new Tab(newTabTemplate));

        deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + currentUser.getId()));

        return true;
    }
View Full Code Here


        // if required set the tab template.
        if (tabId != null)
        {
            // look up source tab by id.
            Tab tab = findTabByIdMapper.execute(new FindByIdRequest("Tab", tabId));

            // create new tabTemplate from source.
            TabTemplate newTabTemplate = new TabTemplate(tab.getTemplate());

            gtt.setTabTemplate(newTabTemplate);
            gtt.setTitle(newTabTemplate.getTabName());
        }
View Full Code Here

        }

        start = System.currentTimeMillis();
        logger.debug("***Getting tab to undelete by tab Id and status");
        /* get the deleted Tab from the tab group */
        Tab tabToUndelete = (Tab) getEntityManager().createQuery("from Tab where id = :TabId and deleted = true")
                .setParameter("TabId", tabId).getSingleResult();
        logger.debug("***Done Getting tab to undelete by tab Id and status (" + (System.currentTimeMillis() - start)
                + "ms");

        if (tabToUndelete == null)
        {
            throw new TabUndeletionException("Failure when trying to get Tab with id=" + tabId, tabId);
        }

        try
        {
            /*
             * re-insert the undeleted tab into the collection
             */
            tabGroup.getTabs().add(tabToUndelete.getTabIndex(), tabToUndelete);

            /* update the status of the undeleted Tab in the database */
            start = System.currentTimeMillis();
            logger.debug("***Update tab status");
            getEntityManager()
                    .createQuery(
                            "update versioned Tab set deleted = false, "
                                    + "dateDeleted = null, tabGroupId = :tabGroupId " + "where id = :TabId")
                    .setParameter("TabId", tabToUndelete.getId()).setParameter("tabGroupId", tabGroup.getId())
                    .executeUpdate();
            logger.debug("***Done Update tab status (" + (System.currentTimeMillis() - start) + "ms)");

            logger.debug("Un-deleted the tab with id=" + tabToUndelete.getId());

            /* update the status of the template of the undeleted Tab */
            start = System.currentTimeMillis();
            logger.debug("***Update tab template status");
            getEntityManager()
                    .createQuery(
                            "update versioned TabTemplate set deleted = false, " + "dateDeleted = null "
                                    + "where id = :TabTemplateId")
                    .setParameter("TabTemplateId", tabToUndelete.getTemplate().getId()).executeUpdate();
            logger.debug("***Done Update tab template status (" + (System.currentTimeMillis() - start) + "ms)");

            logger.debug("Un-deleted the tab template with id=" + tabToUndelete.getTemplate().getId());

            /* update the status of the template's gadgets of the undeleted Tab */
            start = System.currentTimeMillis();
            logger.debug("***Update tab template's gadgets status");
            getEntityManager()
                    .createQuery(
                            "update versioned Gadget set deleted = false, " + "dateDeleted = null "
                                    + "where template.id = :TabTemplateId")
                    .setParameter("TabTemplateId", tabToUndelete.getTemplate().getId()).executeUpdate();
            logger.debug(//
            "***Done Update tab template's gadgets status (" + (System.currentTimeMillis() - start) + "ms)");

            logger.debug("Un-deleted gadgets belonging to tab template with id=" + tabToUndelete.getTemplate().getId());

            // refresh the restored tab to reload previously deleted components
            start = System.currentTimeMillis();
            logger.debug("***entity manager flush");
            // NOTE: DO NOT use entitymanager.refresh! It's far far faster to throw away object and re-query for it.
            // getEntityManager().refresh(tabToUndelete);
            getEntityManager().flush();
            getEntityManager().clear();
            logger.debug("***Done entity manager flush (" + (System.currentTimeMillis() - start) + "ms)");

            start = System.currentTimeMillis();
            logger.debug("***Getting tab to return by tab Id and status");
            /* get the deleted Tab from the tab group */
            tabToUndelete = (Tab) getEntityManager()
                    .createQuery("from Tab t left join fetch t.template where t.id = :tabId and t.deleted = 'false'")
                    .setParameter("tabId", tabId).getSingleResult();
            // Touch the gadgets so that they will be eagerly loaded.
            tabToUndelete.getGadgets().size();
            logger.debug("***Done Getting tab to return by tab Id and status (" + (System.currentTimeMillis() - start)
                    + "ms)");

            return tabToUndelete;
        }
View Full Code Here

    @Override
    public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException
    {
        Long gadgetId = (Long) inActionContext.getParams();

        Tab tab = tabMapper.findTabByGadgetId(gadgetId);

        List<Gadget> gadgets = tab.getGadgets();

        int targetIndex = findTargetIndex(gadgets, gadgetId);

        if (targetIndex == INVALID_INDEX)
        {
View Full Code Here

    @Override
    public Boolean execute(final PrincipalActionContext inActionContext)
    {
        RenameTabRequest requestParams = (RenameTabRequest) inActionContext.getParams();

        Tab tab = tabMapper.findById(requestParams.getTabId());

        tab.setTabName(requestParams.getTabName());

        tabMapper.flush();

        deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID
                + inActionContext.getPrincipal().getId()));
View Full Code Here

        List<Tab> tabs = person.getTabs(currentRequest.getTabType());

        // Find the tab to be moved
        int oldIndex = findTabIndex(tabs, currentRequest.getTabId());

        Tab movingTab = tabs.get(oldIndex);

        // move the tab
        tabs.remove(oldIndex);
        tabs.add(currentRequest.getNewIndex(), movingTab);
View Full Code Here

    @Override
    public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException
    {
        SetTabLayoutRequest currentRequest = (SetTabLayoutRequest) inActionContext.getParams();

        Tab tab = tabMapper.findById(currentRequest.getTabId());
        Layout oldTabLayout = tab.getTabLayout();
        tab.setTabLayout(currentRequest.getLayout());

        tabMapper.flush();

        // Call mapper to update gadgets for a shrinking layout.
        if (oldTabLayout.getNumberOfZones() > currentRequest.getLayout().getNumberOfZones())
        {
            updateMapper.execute(new UpdateGadgetsWithNewTabLayoutRequest(tab.getTemplate().getId(), currentRequest
                    .getLayout()));
        }

        // Need to retrieve the updated tab and touch the gadgets to return to the caller.
        Tab updatedTab = tabMapper.findById(currentRequest.getTabId());

        deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID
                + inActionContext.getPrincipal().getId()));

        return updatedTab;
View Full Code Here

            {
                destinationTemplate = (TabTemplate) inActionContext.getState().get("destinationTemplate");
            }
            else
            {
                Tab destinationTab = tabMapper.findById(targetTabId);
                destinationTemplate = destinationTab.getTemplate();
            }

            List<Gadget> gadgets = sourceTemplate.getGadgets();

            Gadget gadget = findTargetGadget(gadgets, gadgetId);
View Full Code Here

        {
            for (Gadget gadget : tt.getGadgets())
            {
                gadget.setOwner(person);
            }
            startTabGroup.addTab(new Tab(tt));
        }

        person.setStartTabGroup(startTabGroup);
        person.setTheme(properties.getTheme());
View Full Code Here

     * TEst execution of the mapper.
     */
    @Test
    public void testExecute()
    {
        Tab fordsThirdTab = jpaTabMapper.findById(TEST_TABTEMPLATE_ID);

        // Ensure the state is good ahead of time.
        assertEquals(Layout.THREECOLUMN, fordsThirdTab.getTabLayout());
        assertEquals(7, fordsThirdTab.getGadgets().size());
        assertEquals(0, fordsThirdTab.getGadgets().get(0).getZoneNumber());
        assertEquals(0, fordsThirdTab.getGadgets().get(1).getZoneNumber());
        assertEquals(0, fordsThirdTab.getGadgets().get(2).getZoneNumber());
        assertEquals(1, fordsThirdTab.getGadgets().get(3).getZoneNumber());
        assertEquals(2, fordsThirdTab.getGadgets().get(4).getZoneNumber());
        assertEquals(2, fordsThirdTab.getGadgets().get(5).getZoneNumber());
        assertEquals(2, fordsThirdTab.getGadgets().get(6).getZoneNumber());

        UpdateGadgetsWithNewTabLayoutRequest request = new UpdateGadgetsWithNewTabLayoutRequest(fordsThirdTab
                .getTemplate().getId(), Layout.TWOCOLUMN);
        sut.execute(request);

        getEntityManager().clear();

        fordsThirdTab = jpaTabMapper.findById(TEST_TABTEMPLATE_ID);

        assertEquals(7, fordsThirdTab.getGadgets().size());
        assertEquals(0, fordsThirdTab.getGadgets().get(0).getZoneNumber());
        assertEquals(0, fordsThirdTab.getGadgets().get(1).getZoneNumber());
        assertEquals(0, fordsThirdTab.getGadgets().get(2).getZoneNumber());
        assertEquals(1, fordsThirdTab.getGadgets().get(3).getZoneNumber());
        assertEquals(1, fordsThirdTab.getGadgets().get(4).getZoneNumber());
        assertEquals(1, fordsThirdTab.getGadgets().get(5).getZoneNumber());
        assertEquals(1, fordsThirdTab.getGadgets().get(6).getZoneNumber());
    }
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.domain.Tab

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.