@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; }
@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; }
// // / // / 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; }
@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; }
@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(); }
/** * 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; }
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); } }
// // 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(); }
@MethodFilter public ViewComponent getViewComponent(String viewComponentId) { return getViewComponent(Common.getUser().getView(), viewComponentId); }
@MethodFilter public void deleteViewComponent(String viewComponentId) { View view = Common.getUser().getView(); view.removeViewComponent(getViewComponent(view, viewComponentId)); }
@MethodFilter public void deleteViewShare() { User user = Common.getUser(); new ViewDao().removeUserFromView(user.getView().getId(), user.getId()); }
/** * 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); }