Package com.serotonin.m2m2.vo

Examples of com.serotonin.m2m2.vo.User


    }

    @Override
    public int doStartTag() throws JspException {
        // Check the user id.
        User user = new UserDao().getUser(username);
        if (user == null)
            throw new JspException("Username '" + username + "' not found");
        if (user.isDisabled())
            throw new JspException("Username '" + username + "' is disabled");

        JspViewsCommon.setJspView((HttpServletRequest) pageContext.getRequest(), new JspView(user));

        return EVAL_BODY_INCLUDE;
View Full Code Here


    public Map<String, Object> init() {
        DataPointDao dataPointDao = new DataPointDao();
        Map<String, Object> data = new HashMap<String, Object>();

        PointHierarchy ph = dataPointDao.getPointHierarchy(true).copyFoldersOnly();
        User user = Common.getUser();
        List<DataPointVO> points = dataPointDao.getDataPoints(DataPointExtendedNameComparator.instance, false);
        for (DataPointVO point : points) {
            if (Permissions.hasDataPointReadPermission(user, point))
                ph.addDataPoint(point.getPointFolderId(), new DataPointSummary(point));
        }

        ph.parseEmptyFolders();

        WatchList watchList = new WatchListDao().getSelectedWatchList(user.getId());
        prepareWatchList(watchList, user);
        setWatchList(user, watchList);

        data.put("pointFolder", ph.getRoot());
        data.put("shareUsers", getShareUsers(user));
View Full Code Here

    private List<WatchListState> getPointDataImpl(WatchList watchList) {
        if (watchList == null)
            return new ArrayList<WatchListState>();

        HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
        User user = Common.getUser(request);

        WatchListState state;
        List<WatchListState> states = new ArrayList<WatchListState>(watchList.getPointList().size());
        Map<String, Object> model = new HashMap<String, Object>();
        for (DataPointVO point : watchList.getPointList()) {
View Full Code Here

        return states;
    }

    @DwrPermission(user = true)
    public void updateWatchListName(String name) {
        User user = Common.getUser();
        WatchList watchList = getWatchList(user);
        WatchListCommon.ensureWatchListEditPermission(user, watchList);
        watchList.setName(name);
        new WatchListDao().saveWatchList(watchList);
    }
View Full Code Here

        new WatchListDao().saveWatchList(watchList);
    }

    @DwrPermission(user = true)
    public IntStringPair addNewWatchList(int copyId) {
        User user = Common.getUser();

        WatchListDao watchListDao = new WatchListDao();
        WatchList watchList;

        if (copyId == Common.NEW_ID) {
            watchList = new WatchList();
            watchList.setName(translate("common.newName"));
        }
        else {
            watchList = new WatchListDao().getWatchList(getWatchList().getId());
            watchList.setId(Common.NEW_ID);
            watchList.setName(translate(new TranslatableMessage("common.copyPrefix", watchList.getName())));
            //Check to see if we are a Shared User (we can't share a watchlist with ourselves)
            List<ShareUser> watchListShared =  new ArrayList<ShareUser>();
            for(ShareUser shareUser : watchList.getWatchListUsers()){
              //Don't add yourself
              if(shareUser.getUserId() != user.getId())
                watchListShared.add(shareUser);
            }
            watchList.setWatchListUsers(watchListShared);
           
        }
        watchList.setUserId(user.getId());
        watchList.setXid(watchListDao.generateUniqueXid());

        watchListDao.saveWatchList(watchList);

        setWatchList(user, watchList);
        watchListDao.saveSelectedWatchList(user.getId(), watchList.getId());

        return new IntStringPair(watchList.getId(), watchList.getName());
    }
View Full Code Here

        return new IntStringPair(watchList.getId(), watchList.getName());
    }

    @DwrPermission(user = true)
    public void deleteWatchList(int watchListId) {
        User user = Common.getUser();

        WatchListDao watchListDao = new WatchListDao();
        WatchList watchList = getWatchList(user);
        if (watchList == null || watchListId != watchList.getId())
            watchList = watchListDao.getWatchList(watchListId);

        if (watchList == null || watchListDao.getWatchLists(user.getId()).size() == 1)
            // Only one watch list left. Leave it.
            return;

        // Allow the delete.
        if (watchList.getUserAccess(user) == ShareUser.ACCESS_OWNER)
            watchListDao.deleteWatchList(watchListId);
        else
            watchListDao.removeUserFromWatchList(watchListId, user.getId());
    }
View Full Code Here

public class GraphicalViewHandler implements UrlHandler {
    @Override
    public View handleRequest(HttpServletRequest request, HttpServletResponse response, Map<String, Object> model) {
        GraphicalViewDao viewDao = new GraphicalViewDao();
        User user = Common.getUser(request);

        List<IntStringPair> views = viewDao.getViewNames(user.getId());
        model.put("views", views);

        // Set the current view.
        GraphicalView currentView = null;
        String vid = request.getParameter("viewId");
View Full Code Here

            watchListDao.removeUserFromWatchList(watchListId, user.getId());
    }

    @DwrPermission(user = true)
    public Map<String, Object> setSelectedWatchList(int watchListId) {
        User user = Common.getUser();

        WatchListDao watchListDao = new WatchListDao();
        WatchList watchList = watchListDao.getWatchList(watchListId);
        WatchListCommon.ensureWatchListPermission(user, watchList);
        prepareWatchList(watchList, user);

        watchListDao.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);
View Full Code Here

    }

    @DwrPermission(user = true)
    public WatchListState addToWatchList(int pointId) {
        HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
        User user = Common.getUser();
        DataPointVO point = new DataPointDao().getDataPoint(pointId);
        if (point == null)
            return null;
        WatchList watchList = getWatchList(user);
View Full Code Here

    }

    @DwrPermission(user = true)
    public void removeFromWatchList(int pointId) {
        // Remove the point from the user's list.
        User user = Common.getUser();
        WatchList watchList = getWatchList(user);
        WatchListCommon.ensureWatchListEditPermission(user, watchList);
        for (DataPointVO point : watchList.getPointList()) {
            if (point.getId() == pointId) {
                watchList.getPointList().remove(point);
View Full Code Here

TOP

Related Classes of com.serotonin.m2m2.vo.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.