@Override
  public void mergeDashboardItem(DashboardItem item) {
    if (item.getChart() != null) {
      item.setChart(objectManager.get(Chart.class, item.getChart().getUid()));
    }

    if (item.getEventChart() != null) {
      item.setEventChart(objectManager.get(EventChart.class, item.getEventChart().getUid()));
    }

    if (item.getMap() != null) {
      item.setMap(objectManager.get(Map.class, item.getMap().getUid()));
    }

    if (item.getReportTable() != null) {
      item.setReportTable(objectManager.get(ReportTable.class, item.getReportTable().getUid()));
    }

    if (item.getUsers() != null) {
      item.setUsers(objectManager.getByUid(User.class, getUids(item.getUsers())));
    }

    if (item.getReportTables() != null) {
      item.setReportTables(
          objectManager.getByUid(ReportTable.class, getUids(item.getReportTables())));
    }

    if (item.getReports() != null) {
      item.setReports(objectManager.getByUid(Report.class, getUids(item.getReports())));
    }

    if (item.getResources() != null) {
      item.setResources(objectManager.getByUid(Document.class, getUids(item.getResources())));
    }
  }
  @Override
  public boolean addItemContent(String dashboardUid, String type, String contentUid) {
    Dashboard dashboard = getDashboard(dashboardUid);

    if (dashboard == null) {
      return false;
    }

    if (TYPE_CHART.equals(type)) {
      DashboardItem item = new DashboardItem();
      item.setChart(objectManager.get(Chart.class, contentUid));
      dashboard.getItems().add(0, item);
    } else if (TYPE_EVENT_CHART.equals(type)) {
      DashboardItem item = new DashboardItem();
      item.setEventChart(objectManager.get(EventChart.class, contentUid));
      dashboard.getItems().add(0, item);
    } else if (TYPE_MAP.equals(type)) {
      DashboardItem item = new DashboardItem();
      item.setMap(objectManager.get(Map.class, contentUid));
      dashboard.getItems().add(0, item);
    } else if (TYPE_REPORT_TABLE.equals(type)) {
      DashboardItem item = new DashboardItem();
      item.setReportTable(objectManager.get(ReportTable.class, contentUid));
      dashboard.getItems().add(0, item);
    } else if (TYPE_MESSAGES.equals(type)) {
      DashboardItem item = new DashboardItem();
      item.setMessages(true);
      dashboard.getItems().add(0, item);
    } else // Link item
    {
      DashboardItem availableItem = dashboard.getAvailableItemByType(type);

      DashboardItem item = availableItem == null ? new DashboardItem() : availableItem;

      if (TYPE_USERS.equals(type)) {
        item.getUsers().add(objectManager.get(User.class, contentUid));
      } else if (TYPE_REPORT_TABLES.equals(type)) {
        item.getReportTables().add(objectManager.get(ReportTable.class, contentUid));
      } else if (TYPE_REPORTS.equals(type)) {
        item.getReports().add(objectManager.get(Report.class, contentUid));
      } else if (TYPE_RESOURCES.equals(type)) {
        item.getResources().add(objectManager.get(Document.class, contentUid));
      }

      if (availableItem == null) {
        dashboard.getItems().add(0, item);
      }
    }

    if (dashboard.getItemCount() > Dashboard.MAX_ITEMS) {
      return false;
    }

    updateDashboard(dashboard);

    return true;
  }