use of com.serotonin.m2m2.watchlist.WatchListVO in project ma-modules-public by infiniteautomation.
the class WatchListDwr method setSelectedWatchList.
@DwrPermission(user = true)
public Map<String, Object> setSelectedWatchList(int watchListId) {
User user = Common.getUser();
WatchListVO watchList = WatchListDao.instance.get(watchListId);
WatchListCommon.ensureWatchListPermission(user, watchList);
prepareWatchList(watchList, user);
WatchListDao.instance.saveSelectedWatchList(user.getId(), watchList.getId());
Map<String, Object> data = getWatchListData(user, watchList);
// Set the watchlist in the user object after getting the data since it may take a while, and the long poll
// updates will all be missed in the meantime.
setWatchList(user, watchList);
return data;
}
use of com.serotonin.m2m2.watchlist.WatchListVO in project ma-modules-public by infiniteautomation.
the class WatchListDwr method init.
@DwrPermission(user = true)
public Map<String, Object> init() {
Map<String, Object> data = new HashMap<>();
PointHierarchy ph = DataPointDao.instance.getPointHierarchy(true).copyFoldersOnly();
User user = Common.getHttpUser();
List<DataPointVO> points = DataPointDao.instance.getDataPoints(DataPointExtendedNameComparator.instance, false);
final boolean admin = Permissions.hasAdmin(user);
for (DataPointVO point : points) {
if (admin || Permissions.hasDataPointReadPermission(user, point))
ph.addDataPoint(point.getPointFolderId(), new DataPointSummary(point));
}
ph.parseEmptyFolders();
WatchListVO watchList = WatchListDao.instance.getSelectedWatchList(user.getId());
prepareWatchList(watchList, user);
setWatchList(user, watchList);
data.put("pointFolder", ph.getRoot());
data.put("selectedWatchList", getWatchListData(user, watchList));
return data;
}
use of com.serotonin.m2m2.watchlist.WatchListVO in project ma-modules-public by infiniteautomation.
the class WatchListDwr method getPermissions.
@DwrPermission(user = true)
public ProcessResult getPermissions() {
WatchListVO wl = getWatchList();
ProcessResult result = new ProcessResult();
result.addData("readPermission", wl.getReadPermission());
result.addData("editPermission", wl.getEditPermission());
return result;
}
use of com.serotonin.m2m2.watchlist.WatchListVO in project ma-modules-public by infiniteautomation.
the class WatchListDwr method getWatchListData.
private Map<String, Object> getWatchListData(User user, WatchListVO watchList) {
Map<String, Object> data = new HashMap<>();
if (watchList == null)
return data;
List<DataPointVO> points = watchList.getPointList();
List<Integer> pointIds = new ArrayList<>(points.size());
for (DataPointVO point : points) {
if (Permissions.hasDataPointReadPermission(user, point))
pointIds.add(point.getId());
}
data.put("points", pointIds);
data.put("access", watchList.getUserAccess(user));
data.put("readPermission", watchList.getReadPermission());
data.put("editPermission", watchList.getEditPermission());
return data;
}
use of com.serotonin.m2m2.watchlist.WatchListVO in project ma-modules-public by infiniteautomation.
the class WatchListDwr method addNewWatchList.
@DwrPermission(user = true)
public IntStringPair addNewWatchList(int copyId) {
User user = Common.getUser();
WatchListVO watchList;
if (copyId == Common.NEW_ID) {
watchList = new WatchListVO();
watchList.setName(translate("common.newName"));
} else {
watchList = WatchListDao.instance.get(getWatchList().getId());
watchList.setId(Common.NEW_ID);
watchList.setName(translate(new TranslatableMessage("common.copyPrefix", watchList.getName())));
}
watchList.setUserId(user.getId());
watchList.setXid(WatchListDao.instance.generateUniqueXid());
WatchListDao.instance.saveWatchList(watchList);
setWatchList(user, watchList);
WatchListDao.instance.saveSelectedWatchList(user.getId(), watchList.getId());
return new IntStringPair(watchList.getId(), watchList.getName());
}
Aggregations