Search in sources :

Example 1 with User

use of com.serotonin.m2m2.vo.User in project JessMA by ldcsaa.

the class MyUser2 method create.

@Override
public // Rails-style REST 标准方法,不需要 REST 注解
RestResult create() throws Exception {
    // 注入 Form Bean
    User user = createFormBean(User.class);
    dao.createUser(user);
    if (getRestContext().getRenderType() == RenderType.HTML)
        return doQuery(user.getName(), user.getExperience());
    else
        return new RestResult(SUCCESS);
}
Also used : User(vo.User) RestResult(org.jessma.ext.rest.RestResult)

Example 2 with User

use of com.serotonin.m2m2.vo.User in project JessMA by ldcsaa.

the class UserDao method findUsers.

public List<User> findUsers(String name, int experience) {
    List<Criterion> criterions = new ArrayList<Criterion>();
    if (GeneralHelper.isStrNotEmpty(name))
        criterions.add(Restrictions.like("name", "%" + name + "%"));
    if (experience != 0)
        criterions.add(Restrictions.eq("experience", experience));
    Criterion[] cs = criterions.toArray(new Criterion[criterions.size()]);
    Order[] orders = new Order[] { Order.desc("id") };
    List<User> users = qbcQuery(User.class, orders, cs);
    Cache cache = Cache.getInstance();
    for (User user : users) {
        user.setGenderObj(cache.getGenderById(user.getGender()));
        user.setExperienceObj(cache.getExperenceById(user.getExperience()));
        List<Integer> ints = user.getInterests();
        if (ints != null) {
            List<Interest> intsObjs = new ArrayList<Interest>();
            for (Integer i : ints) intsObjs.add(cache.getInterestById(i));
            user.setInterestObjs(intsObjs);
        }
    }
    return users;
}
Also used : Order(org.hibernate.criterion.Order) User(vo.User) ArrayList(java.util.ArrayList) Interest(vo.Interest) Criterion(org.hibernate.criterion.Criterion) Cache(global.Cache)

Example 3 with User

use of com.serotonin.m2m2.vo.User in project JessMA by ldcsaa.

the class UserDao method queryInterest.

@Transaction(false)
public List<User> queryInterest(int gender, int experience) {
    Cache cache = Cache.getInstance();
    UserMapper mapper = getMapper(UserMapper.class);
    List<User> users = mapper.queryInterest(gender, experience);
    for (User user : users) {
        user.setGenderObj(cache.getGenderById(user.getGender()));
        user.setExperienceObj(cache.getExperenceById(user.getExperience()));
        List<Integer> ints = user.getInterests();
        if (ints != null) {
            List<Interest> intsObjs = new ArrayList<Interest>();
            for (Integer i : ints) intsObjs.add(cache.getInterestById(i));
            user.setInterestObjs(intsObjs);
        }
    }
    return users;
}
Also used : Interest(vo.Interest) UserMapper(vo.mapper.UserMapper) User(vo.User) ArrayList(java.util.ArrayList) Cache(global.Cache) Transaction(org.jessma.dao.Transaction)

Example 4 with User

use of com.serotonin.m2m2.vo.User in project JessMA by ldcsaa.

the class UserDao method findUsers.

@Transaction(false)
public List<User> findUsers(String name, int experience) {
    Cache cache = Cache.getInstance();
    UserMapper mapper = getMapper(UserMapper.class);
    List<User> users = mapper.findUsers(name, experience);
    for (User user : users) {
        user.setGenderObj(cache.getGenderById(user.getGender()));
        user.setExperienceObj(cache.getExperenceById(user.getExperience()));
        List<Integer> ints = user.getInterests();
        if (ints != null) {
            List<Interest> intsObjs = new ArrayList<Interest>();
            for (Integer i : ints) intsObjs.add(cache.getInterestById(i));
            user.setInterestObjs(intsObjs);
        }
    }
    return users;
}
Also used : Interest(vo.Interest) UserMapper(vo.mapper.UserMapper) User(vo.User) ArrayList(java.util.ArrayList) Cache(global.Cache) Transaction(org.jessma.dao.Transaction)

Example 5 with User

use of com.serotonin.m2m2.vo.User in project ma-core-public by infiniteautomation.

the class EventManagerImpl method acknowledgeEvent.

/**
 * Added to allow Acknowledge Events to be fired
 * @param evt
 * @param time
 * @param userId
 * @param alternateAckSource
 */
private boolean acknowledgeEvent(EventInstance evt, long time, User ackUser, TranslatableMessage alternateAckSource) {
    boolean acked;
    if (ackUser != null)
        acked = eventDao.ackEvent(evt.getId(), time, ackUser.getId(), alternateAckSource);
    else
        acked = eventDao.ackEvent(evt.getId(), time, 0, alternateAckSource);
    // event was already acknowledged or doesn't exist
    if (!acked) {
        return false;
    }
    // Fill in the info if someone on the other end wants it
    if (ackUser != null) {
        evt.setAcknowledgedByUserId(ackUser.getId());
        evt.setAcknowledgedByUsername(ackUser.getUsername());
    }
    evt.setAcknowledgedTimestamp(time);
    evt.setAlternateAckSource(alternateAckSource);
    for (User user : userDao.getActiveUsers()) {
        // user should be skipped.
        if (evt.getEventType().excludeUser(user))
            continue;
        if (Permissions.hasEventTypePermission(user, evt.getEventType())) {
            // Notify All User Event Listeners of the new event
            for (UserEventListener l : this.userEventListeners) {
                if (l.getUserId() == user.getId()) {
                    Common.backgroundProcessing.addWorkItem(new EventNotifyWorkItem(user, l, evt, false, false, false, true));
                }
            }
            this.userEventCache.removeEvent(user.getId(), evt);
        }
    }
    return true;
}
Also used : User(com.serotonin.m2m2.vo.User) UserEventListener(com.serotonin.m2m2.rt.event.UserEventListener)

Aggregations

User (com.serotonin.m2m2.vo.User)281 DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)163 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)163 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)163 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)123 RestProcessResult (com.serotonin.m2m2.web.mvc.rest.v1.message.RestProcessResult)119 ProcessResult (com.serotonin.m2m2.i18n.ProcessResult)99 ArrayList (java.util.ArrayList)97 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)95 HashMap (java.util.HashMap)46 NotFoundRestException (com.infiniteautomation.mango.rest.v2.exception.NotFoundRestException)45 PermissionException (com.serotonin.m2m2.vo.permission.PermissionException)41 List (java.util.List)36 ASTNode (net.jazdw.rql.parser.ASTNode)31 ResponseEntity (org.springframework.http.ResponseEntity)31 URI (java.net.URI)25 IOException (java.io.IOException)24 PointValueTime (com.serotonin.m2m2.rt.dataImage.PointValueTime)22 InvalidRQLRestException (com.infiniteautomation.mango.rest.v2.exception.InvalidRQLRestException)21 RestValidationFailedException (com.serotonin.m2m2.web.mvc.rest.v1.exception.RestValidationFailedException)20