@Override public List<List<PortletConfiguration>> getPortletConfigurations(final Long portalPageId) { final List<List<PortletConfiguration>> columns = new ArrayList<List<PortletConfiguration>>(); final List<PortletConfiguration> portletConfigurations = portletConfigurationManager.getByPortalPage(portalPageId); final PortalPage portalPage = getPortalPageById(portalPageId); if ((portalPage != null) && !portletConfigurations.isEmpty()) { initColumns(portalPage.getLayout().getNumberOfColumns(), columns); for (final PortletConfiguration portletConfiguration : portletConfigurations) { final int column = portletConfiguration.getColumn(); columns.get(column).add(portletConfiguration); } //Once all portlet configs are inserted, sort each column then make it an unmodifieable list. for (int i = 0; i < columns.size(); i++) { final List<PortletConfiguration> column = columns.get(i); Collections.sort(column); columns.set(i, Collections.<PortletConfiguration> unmodifiableList(column)); } } return Collections.unmodifiableList(columns); }
public void visit(final RemoveGadgetChange removeGadgetChange) { final PortletConfiguration gadgetToRemove = portletConfigurationStore.getByPortletId(toLong(removeGadgetChange.getGadgetId())); final Iterable<DashboardItemState> gadgets = updateDashboardState.getDashboardColumns().getItemsInColumn(DashboardState.ColumnIndex.from(gadgetToRemove.getColumn())); portletConfigurationStore.delete(gadgetToRemove); int row = 0; for (DashboardItemState gadget : gadgets) { portletConfigurationStore.updateGadgetPosition(toLong(gadget.getId()), row, gadgetToRemove.getColumn(), toLong(updateDashboardState.getId())); row++; } }
null, pc.getPortlet(), pc.getColumn(), pc.getRow(), null,
String replace = "com.atlassian.streams.streams-jira-plugin:activityfeed"; final Long pageId = portlet.getDashboardPageId(); final Integer column = portlet.getColumn(); final Integer row = portlet.getRow(); final PropertySet propertySet = portlet.getProperties();
/** * Copy the passed portlet configuration. * * @param portletConfiguration the portlet configuration to copy. * @return the new deeply copied portlet configuration. The underlying property set is cloned into a new memory * property set. */ private PortletConfiguration copyConfiguration(final PortletConfiguration portletConfiguration) { if (portletConfiguration != null) { return new PortletConfigurationImpl(portletConfiguration.getId(), portletConfiguration.getDashboardPageId(), portletConfiguration.getColumn(), portletConfiguration.getRow(), portletConfiguration.getOpenSocialSpecUri(), portletConfiguration.getColor(), portletConfiguration.getUserPrefs(), portletConfiguration.getCompleteModuleKey()); } else { return null; } }
portletConfigurationStore.addDashboardItem(toAdd.getDashboardPageId(), toAdd.getId(), toAdd.getColumn(), toAdd.getRow(), toAdd.getOpenSocialSpecUri(), toAdd.getColor(), toAdd.getUserPrefs(), toAdd.getCompleteModuleKey());
public void visit(final AddGadgetChange addGadgetChange) { final DashboardState.ColumnIndex column = addGadgetChange.getColumnIndex(); final Iterable<DashboardItemState> dashboardItems = updateDashboardState.getDashboardColumns().getItemsInColumn(column); final DashboardItemState newItemState = addGadgetChange.getDashboardItemState(); final Long portalPageId = toLong(updateDashboardState.getId()); final PortletConfiguration pc = toPortletConfiguration(newItemState, portalPageId, column.index(), addGadgetChange.getRowIndex()); portletConfigurationStore.addDashboardItem(pc.getDashboardPageId(), pc.getId(), pc.getColumn(), pc.getRow(), pc.getOpenSocialSpecUri(), pc.getColor(), pc.getUserPrefs(), pc.getCompleteModuleKey()); moveDashboardItemsOnePositionDown(dashboardItems, addGadgetChange.getRowIndex() + 1, column.index()); }
public void visit(final UpdateLayoutChange updateLayoutChange) { final Long dashboardId = toLong(updateDashboardState.getId()); final PortalPage portalPage = portalPageStore.getPortalPage(dashboardId); if (!portalPage.getLayout().equals(updateLayoutChange.getLayout())) { portalPageStore.update(PortalPage.portalPage(portalPage).layout(updateLayoutChange.getLayout()).build()); } final GadgetLayout newLayout = updateLayoutChange.getGadgetLayout(); for (int column = 0; column < newLayout.getNumberOfColumns(); column++) { int row = 0; final Iterable<GadgetId> gadgets = newLayout.getGadgetsInColumn(column); for (GadgetId gadgetId : gadgets) { final Long gadgetIdLong = toLong(gadgetId); final PortletConfiguration portletConfiguration = portletConfigurationStore.getByPortletId(gadgetIdLong); if (portletConfiguration.getColumn() != column || portletConfiguration.getRow() != row) { portletConfigurationStore.updateGadgetPosition(gadgetIdLong, row, column, dashboardId); } row += 1; } } }
gv.set(Columns.COLUMN, pc.getColumn()); gv.set(Columns.ROW, pc.getRow()); gv.set(Columns.GADGET_XML, pc.getOpenSocialSpecUri().map(new Function<URI, String>()
private void clonePortletsFromOnePageToAnother(final ApplicationUser owner, final PortalPage clonePortalPage, final PortalPage targetPortalPage) { notNull("owner", owner); notNull("clonePortalPage", clonePortalPage); notNull("targetPortalPage", targetPortalPage); final GadgetPermissionManager gadgetPermissionManager = getGadgetPermissionManager(); final List<PortletConfiguration> pcsToClone = portletConfigurationManager.getByPortalPage(clonePortalPage.getId()); for (final PortletConfiguration pc : pcsToClone) { Option<PluginGadgetSpec> pluginGadgetSpec = gadgetPermissionManager.getPluginGadgetSpec(pc.getOpenSocialSpecUri().getOrNull()); final boolean userHasPermissionToOpenSocialGadget = (pluginGadgetSpec.isDefined()) && ALLOW.equals(gadgetPermissionManager.voteOn(pluginGadgetSpec.get(), owner)); final boolean isDashboardItem = pc.getCompleteModuleKey().isDefined(); if (isDashboardItem || userHasPermissionToOpenSocialGadget) { portletConfigurationManager.addDashBoardItem( targetPortalPage.getId(), pc.getColumn(), pc.getRow(), pc.getOpenSocialSpecUri(), pc.getColor(), pc.getUserPrefs(), pc.getCompleteModuleKey()); } } }