Skip to content

Commit

Permalink
dashboard: drop unused API
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed Jun 30, 2017
1 parent e4b821c commit 535beae
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import de.metas.logging.LogManager;
import de.metas.ui.web.config.WebConfig;
import de.metas.ui.web.dashboard.UserDashboardRepository.DashboardItemPatchPath;
import de.metas.ui.web.dashboard.UserDashboardRepository.DashboardPatchPath;
import de.metas.ui.web.dashboard.UserDashboardRepository.UserDashboardItemChangeResult;
import de.metas.ui.web.dashboard.UserDashboardRepository.UserDashboardKey;
import de.metas.ui.web.dashboard.json.JSONDashboard;
Expand Down Expand Up @@ -177,32 +176,6 @@ private final JSONDashboardItem addDashboardItem(final JsonUserDashboardItemAddR
return JSONDashboardItem.of(targetIndicatorItem, newJSONOpts());
}

@PatchMapping("/kpis")
public void changeKPIsDashboard(@RequestBody final List<JSONPatchEvent<DashboardPatchPath>> events)
{
changeDashboard(DashboardWidgetType.KPI, events);
}

@PatchMapping("/targetIndicators")
public void changeTargetIndicatorsDashboard(@RequestBody final List<JSONPatchEvent<DashboardPatchPath>> events)
{
changeDashboard(DashboardWidgetType.TargetIndicator, events);
}

private void changeDashboard(final DashboardWidgetType widgetType, final List<JSONPatchEvent<DashboardPatchPath>> events)
{
userSession.assertLoggedIn();

userDashboardRepo.changeDashboard(getUserDashboardForWriting(), widgetType, events);

//
// Notify on websocket
final UserDashboard dashboard = getUserDashboardForReading();
sendEvents(dashboard, JSONDashboardChangedEventsList.builder()
.event(JSONDashboardOrderChangedEvent.of(dashboard.getId(), widgetType, dashboard.getItemIds(widgetType)))
.build());
}

@GetMapping("/kpis/{itemId}/data")
public KPIDataResult getKPIData( //
@PathVariable final int itemId //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import de.metas.ui.web.base.model.I_WEBUI_DashboardItem;
import de.metas.ui.web.base.model.I_WEBUI_KPI;
import de.metas.ui.web.dashboard.UserDashboardRepository.UserDashboardItemChangeResult.UserDashboardItemChangeResultBuilder;
import de.metas.ui.web.window.datatypes.json.JSONPatchEvent;
import lombok.Builder;
import lombok.NonNull;
import lombok.Value;
Expand Down Expand Up @@ -291,47 +290,6 @@ private <R> R executeChangeActionAndInvalidateAndReturn(final int dashboardId, f
return result.getValue();
}

public static enum DashboardPatchPath
{
orderedItemIds
};

public void changeDashboard(@NonNull final UserDashboard userDashboard, @NonNull final DashboardWidgetType widgetType, @NonNull final List<JSONPatchEvent<DashboardPatchPath>> events)
{
if (events.isEmpty())
{
throw new AdempiereException("no events");
}

final int dashboardId = userDashboard.getId();

//
// Extract change actions
final List<Runnable> changeActions = new ArrayList<>(events.size());
for (final JSONPatchEvent<DashboardPatchPath> event : events)
{
if (!event.isReplace())
{
throw new AdempiereException("Invalid event operation").setParameter("event", event);
}

final DashboardPatchPath path = event.getPath();
if (DashboardPatchPath.orderedItemIds.equals(path))
{
final List<Integer> orderItemIds = event.getValueAsIntegersList();
changeActions.add(() -> changeDashboardItemsOrder(dashboardId, widgetType, orderItemIds));
}
else
{
throw new AdempiereException("Unknown path").setParameter("event", event).setParameter("availablePaths", DashboardPatchPath.values());
}
}

//
// Execute the change actions
executeChangeActionsAndInvalidate(dashboardId, changeActions);
}

private void changeDashboardItemsOrder(final int dashboardId, final DashboardWidgetType dashboardWidgetType, final List<Integer> requestOrderedItemIds)
{
// Retrieve all itemIds ordered
Expand Down

0 comments on commit 535beae

Please sign in to comment.