Package chat.model

Examples of chat.model.User


  @Service
  @Transac.Readonly
  public List<Chat> read(Chat c) throws Exception
  {
    Criteria<Chat> _ = data.criteria(Chat.class);
    User me = new User().id(sess.me);

    Criterion out = Restrictions.eq("out", me);
    if (c.in != null)
      out = Restrictions.and(out, // chats from me
        Restrictions.eq("in", c.in));
View Full Code Here


   * @return with {@link Chat#datime}
   */
  @Service
  public Chat post(Chat c, Input.Upload smiley) throws Exception
  {
    c.out = new User().id(sess.me);
    validate(c);

    Criteria<?> _ = data.criteria(User.class).setProjection(Projections.rowCount());
    _.add(Restrictions.idEq(c.in.id));
    _.createCriteria("friends").add(Restrictions.idEq(c.out.id));
View Full Code Here

  /** @return me with {@link User#friends_} */
  @Service
  @Transac.Readonly
  public User me() throws Exception
  {
    User me = data.load(User.class, sess.me);
    me.friends_ = me.friends;
    return me;
  }
View Full Code Here

  @Service
  public void update(User u) throws Exception
  {
    if (u.friends_ == null) // || name
      return;
    User me = data.load(User.class, sess.me);
    if (u.friends_ != null)
      me.friends = u.friends_;
  }
View Full Code Here

  User u1;
  User u2;

  void signIn() throws Exception
  {
    User u = new User();
    u.name = u.password = "b";
    u2 = doChat.doSign.inUp(u);
    u = new User();
    u.name = u.password = "a";
    doChat.doSign.inUp(u);
    u1 = doChat.doUser.me();
    u1.friends_ = null;
  }
View Full Code Here

  User u1;
  User u2;

  void signIn() throws Exception
  {
    User u = new User();
    u.name = u.password = "b";
    u2 = doUser.doSign.inUp(u);
    u = new User();
    u.name = u.password = "a";
    doUser.doSign.inUp(u);
    u1 = doUser.me();
    u1.friends_ = null;
  }
View Full Code Here

  public void update_existId() throws Exception
  {
    signIn();
    (u1.friends_ = u1.friends).add(u2);
    doUser.update(u1);
    User x = new User();
    x.id = ((User)u1.friends.toArray()[u1.friends.size() - 1]).id;
    u1.friends_.add(x); // aready exist id
    doUser.update(u1);
  }
View Full Code Here

  @Test
  public void get() throws Exception
  {
    signIn();
    User[] s = new User[] { new User(), new User(), new User() };
    s[1].id = sess.me;
    s[2].name = "b";
    User[] ss = doUser.get(s.clone());
    assertNotSame(s, ss);
    assertNull(ss[0]);
View Full Code Here

  DoSign doSign = container.get(DoSign.class);

  @Test
  public void inUp_up() throws Exception
  {
    User a = new User();
    a.name = a.password = "a";
    User aa = doSign.inUp(a);
    assertSame(a, aa);
    asser(a.id > 0);
    asserts(new Id[] { a }, a.friends);
    assertEquals(a.id, sess.me);
  }
View Full Code Here

  }

  @Test
  public void inUp_in() throws Exception
  {
    User a = new User();
    a.name = a.password = "a";
    doSign.inUp(a);
    User aa = doSign.inUp(a);
    assertNotSame(a, aa);
    assertEquals(a.name, aa.name);
  }
View Full Code Here

TOP

Related Classes of chat.model.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.