@Override public PortletConfiguration getByPortletId(final Long portletId) { return portletConfigurationStore.getByPortletId(portletId); }
@Override @Nonnull public CacheObject<PortletConfiguration> load(@Nonnull final Long portletId) { return CacheObject.wrap(delegateStore.getByPortletId(portletId)); } }
public DashboardState findDashboardWithGadget(final GadgetId gadgetId) throws DashboardNotFoundException { notNull("gagdetId", gadgetId); try { final PortletConfiguration portletConfiguration = portletConfigurationStore.getByPortletId(toLong(gadgetId)); if (portletConfiguration == null) { throw new DashboardStateStoreException("Gadget with id '" + gadgetId + "' not found!"); } return retrieve(DashboardId.valueOf(Long.toString(portletConfiguration.getDashboardPageId()))); } catch (DataAccessException e) { throw new DashboardStateStoreException("Error looking up gadget with id '" + gadgetId + "'.", e); } }
public void visit(final GadgetColorChange gadgetColorChange) { final Long gadgetId = toLong(gadgetColorChange.getGadgetId()); final PortletConfiguration portletConfiguration = portletConfigurationStore.getByPortletId(gadgetId); if (portletConfiguration != null) { portletConfigurationStore.updateGadgetColor(gadgetId, gadgetColorChange.getColor()); } else { throw new DashboardStateStoreException("Gadget with id '" + gadgetColorChange.getGadgetId() + "' not found for color change."); } }
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++; } }
final PortletConfiguration pc = delegateStore.getByPortletId(gadgetId); existingDashboardId = pc.getDashboardPageId();
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; } } }