Пример #1
0
  @MethodFilter
  public DwrResponseI18n setPointComponentSettings(
      String pointComponentId,
      int dataPointId,
      String name,
      boolean settable,
      String bkgdColorOverride,
      boolean displayControls) {
    DwrResponseI18n response = new DwrResponseI18n();
    PointComponent pc = (PointComponent) getViewComponent(pointComponentId);
    User user = Common.getUser();

    DataPointVO dp = new DataPointDao().getDataPoint(dataPointId);
    if (dp == null || !Permissions.hasDataPointReadPermission(user, dp))
      response.addContextualMessage("settingsPointList", "validate.required");
    else {
      pc.tsetDataPoint(dp);
      pc.setNameOverride(name);
      pc.setSettableOverride(settable && Permissions.hasDataPointSetPermission(user, dp));
      pc.setBkgdColorOverride(bkgdColorOverride);
      pc.setDisplayControls(displayControls);

      pc.validateDataPoint(user, false);
    }

    return response;
  }
Пример #2
0
 @MethodFilter
 public List<String> getViewComponentIds() {
   User user = Common.getUser();
   List<String> result = new ArrayList<String>();
   for (ViewComponent vc : user.getView().getViewComponents()) result.add(vc.getId());
   return result;
 }
Пример #3
0
  //
  // /
  // / View editing
  // /
  //
  @MethodFilter
  public Map<String, Object> editInit() {
    Map<String, Object> result = new HashMap<String, Object>();
    User user = Common.getUser();

    // Users with which to share.
    result.put("shareUsers", getShareUsers(user));

    // Users already sharing with.
    result.put("viewUsers", user.getView().getViewUsers());

    // View component types
    List<KeyValuePair> components = new ArrayList<KeyValuePair>();
    for (ImplDefinition impl : ViewComponent.getImplementations())
      components.add(new KeyValuePair(impl.getName(), getMessage(impl.getNameKey())));
    result.put("componentTypes", components);

    // Available points
    List<DataPointVO> allPoints =
        new DataPointDao().getDataPoints(DataPointExtendedNameComparator.instance, false);
    List<DataPointBean> availablePoints = new ArrayList<DataPointBean>();
    for (DataPointVO dataPoint : allPoints) {
      if (Permissions.hasDataPointReadPermission(user, dataPoint))
        availablePoints.add(new DataPointBean(dataPoint));
    }
    result.put("pointList", availablePoints);

    return result;
  }
Пример #4
0
  @MethodFilter
  public ViewComponent addComponent(String componentName) {
    ViewComponent viewComponent = ViewComponent.newInstance(componentName);

    User user = Common.getUser();
    View view = user.getView();
    view.addViewComponent(viewComponent);
    viewComponent.validateDataPoint(user, false);

    return viewComponent;
  }
Пример #5
0
  public String setViewPointAnon(int viewId, String viewComponentId, String valueStr) {
    View view = Common.getAnonymousView(viewId);
    if (view == null) throw new PermissionException("View is not in session", null);

    if (view.getAnonymousAccess() != ShareUser.ACCESS_SET)
      throw new PermissionException("Point is not anonymously settable", null);

    // Allow the set.
    setPointImpl(view.findDataPoint(viewComponentId), valueStr, new AnonymousUser());

    return viewComponentId;
  }
Пример #6
0
  @MethodFilter
  public List<ShareUser> removeSharedUser(int userId) {
    View view = Common.getUser().getView();

    for (ShareUser su : view.getViewUsers()) {
      if (su.getUserId() == userId) {
        view.getViewUsers().remove(su);
        break;
      }
    }

    return view.getViewUsers();
  }
Пример #7
0
  /**
   * Allows the setting of a given data point. Overrides BaseDwr to resolve the point view id.
   *
   * @param pointId
   * @param valueStr
   * @return
   */
  @MethodFilter
  public String setViewPoint(String viewComponentId, String valueStr) {
    User user = Common.getUser();
    View view = user.getView();
    DataPointVO point = view.findDataPoint(viewComponentId);

    if (point != null) {
      // Check that setting is allowed.
      int access = view.getUserAccess(user);
      if (!(access == ShareUser.ACCESS_OWNER || access == ShareUser.ACCESS_SET))
        throw new PermissionException("Not allowed to set this point", user);

      // Try setting the point.
      setPointImpl(point, valueStr, user);
    }

    return viewComponentId;
  }
Пример #8
0
  private void saveCompoundPoints(CompoundComponent c, List<KeyValuePair> childPointIds) {
    User user = Common.getUser();

    for (KeyValuePair kvp : childPointIds) {
      int dataPointId = -1;
      try {
        dataPointId = Integer.parseInt(kvp.getValue());
      } catch (NumberFormatException e) {
        // no op
      }

      DataPointVO dp = new DataPointDao().getDataPoint(dataPointId);

      if (dp == null || !Permissions.hasDataPointReadPermission(user, dp))
        c.setDataPoint(kvp.getKey(), null);
      else c.setDataPoint(kvp.getKey(), dp);
      c.getChildComponent(kvp.getKey()).validateDataPoint(user, false);
    }
  }
Пример #9
0
  //
  // View users
  //
  @MethodFilter
  public List<ShareUser> addUpdateSharedUser(int userId, int accessType) {
    View view = Common.getUser().getView();
    boolean found = false;
    for (ShareUser su : view.getViewUsers()) {
      if (su.getUserId() == userId) {
        found = true;
        su.setAccessType(accessType);
        break;
      }
    }

    if (!found) {
      ShareUser su = new ShareUser();
      su.setUserId(userId);
      su.setAccessType(accessType);
      view.getViewUsers().add(su);
    }

    return view.getViewUsers();
  }
Пример #10
0
 //
 //
 // /
 // / Anonymous views
 // /
 //
 //
 public List<ViewComponentState> getViewPointDataAnon(int viewId) {
   View view = Common.getAnonymousView(viewId);
   if (view == null) return new ArrayList<ViewComponentState>();
   return getViewPointData(null, view, false);
 }
Пример #11
0
 @MethodFilter
 public ViewComponent getViewComponent(String viewComponentId) {
   return getViewComponent(Common.getUser().getView(), viewComponentId);
 }
Пример #12
0
 @MethodFilter
 public void deleteViewComponent(String viewComponentId) {
   View view = Common.getUser().getView();
   view.removeViewComponent(getViewComponent(view, viewComponentId));
 }
Пример #13
0
 @MethodFilter
 public void deleteViewShare() {
   User user = Common.getUser();
   new ViewDao().removeUserFromView(user.getView().getId(), user.getId());
 }
Пример #14
0
 /**
  * Retrieves point state for all points on a given view. This is the monitoring version of the
  * method. See below for the view editing version.
  *
  * @param viewId
  * @return
  */
 @MethodFilter
 public List<ViewComponentState> getViewPointData(boolean edit) {
   User user = Common.getUser();
   return getViewPointData(user, user.getView(), edit);
 }