Package org.openqreg.bean

Examples of org.openqreg.bean.UserBean


   * Creates a new user. This method can be overrridden in subclasses.
   *
   * @return A new user
   */
  public UserBean createUser() {
    return new UserBean();
  }
View Full Code Here


   *            of the user to populate
   */
  public void repopulateUser(String userId) {
    User user = this.getUser(userId);
    if (null != user) {
      UserBean updatedUser = null;
      try {
        updatedUser = (UserBean) UserFinderBase
            .findByPrimaryKey(new UserKey(user.getId()));
        ClassPopulater.populateFromObjectIgnoreNull(user, updatedUser);
        user.removeAllAttributes();
        Map<String, String> attr = updatedUser.getAttributes();
        Set<String> set = attr.keySet();
        for (String elem : set) {
          user.setAttribute(elem, updatedUser.getAttribute(elem));
        }
      } catch (SQLException sqle) {
        logger.log(Level.ERROR, "unable to repopulateUser", sqle);
      }
      updatedUser = null;
View Full Code Here

      con.setAutoCommit(false);
      long id = Thread.currentThread().getId();
      CentreBean centre = BeanFactory.getCentre(id);
      centre.create(con);
     
      UserBean user = BeanFactory.getUser(id);
      user.setCentreid(centre.getId());
      user.create(con);
     
      Collection<UserBean> users = UserFinder.findByCentreid(con, centre.getId());
      assertTrue("Anv�ndaren hittades inte", users.contains(user));
      user.remove(con);
      centre.remove(con);
      con.rollback();
      con.close();     
     
    } catch (SQLException e) {
View Full Code Here

    Connection con = null;
    try {
      con = DbHandler.getConnection();
      con.setAutoCommit(false);
     
      UserBean user = BeanFactory.getUser(Thread.currentThread().getId());
      user.create(con);
     
      UsergroupBean parent = new UsergroupBean();
      parent.setId("parent");
      parent.setStatus(new Integer(Status.ACTIVE));
      parent.setDescription("Parent usergroup");
      parent.setUseucr(Integer.valueOf(0));
      parent.setCreatedby(user.getId());
      parent.setTscreated(new Timestamp(System.currentTimeMillis()));
      parent.create(con);
     
     
     
View Full Code Here

   
    Collection<CentreBean> centres = CentreFinderBase.findAll();
    CentreBean centre = centres.iterator().next();
   
    String userid = "JUnit@"+ id +"@"+ System.currentTimeMillis();
    UserBean testUser = new UserBean();
    testUser.setId(userid);
    testUser.setLanguageid(language.getLanguageid());
    testUser.setGroupid(usergroup.getId());
    testUser.setCentreid(centre.getId());
   
    return testUser;
  }
View Full Code Here


public class UserTest {
  public static void main(String[] args) {
    String id = "RogerS";
    UserBean user = new UserBean();
    System.out.println("Starting to populate user with id: " + id);
    try {
      user.setId(id);
      //user.load();
    } catch (Exception e) {
      System.out.println(e);
    }
    System.out.println("Starting to populate done: " + id);
    StringBuffer outstring = new StringBuffer();

    outstring.append(user.getFirstname());

    System.out.println(outstring.toString());
  }
View Full Code Here

    Connection con = null;
    try {
      con = DbHandler.getConnection();
      con.setAutoCommit(false);
      UserBean user = (UserBean) UserFinderBase.findByPrimaryKey(new UserKey("System"));

      UsergroupBean ug1 = new UsergroupBean();
      ug1.setId("JUnit@Master1");
      ug1.setDescription("JUnit@Master1");
      ug1.setUseucr(Integer.valueOf(0));
      ug1.setStatus(new Integer(Status.ACTIVE));
      ug1.setCreatedby(user.getId());
      ug1.setTscreated(new Timestamp(System.currentTimeMillis()));
      ug1.create(con);

      UsergroupBean sg1 = new UsergroupBean();
      sg1.setId("JUNit@Subgroup1");
      sg1.setDescription("JUNit@Subgroup1");
      sg1.setUseucr(Integer.valueOf(0));
      sg1.setStatus(new Integer(Status.ACTIVE));
      sg1.setCreatedby(user.getId());
      sg1.setTscreated(new Timestamp(System.currentTimeMillis()));
      sg1.create(con);

      UsergroupBean sg2 = new UsergroupBean();
      sg2.setId("JUNit@Subgroup2");
      sg2.setDescription("JUNit@Subgroup2");
      sg2.setUseucr(Integer.valueOf(0));
      sg2.setStatus(new Integer(Status.ACTIVE));
      sg2.setCreatedby(user.getId());
      sg2.setTscreated(new Timestamp(System.currentTimeMillis()));
      sg2.create(con);

//      assertTrue("En undergrupp skall ha blivit tillagd", ug1.addChild(sg1));
//      assertTrue("Undergruppen skall finnas", ug1.isChild(sg1));
View Full Code Here

  public void testEquals(){
    try {
      Connection con = DbHandler.getConnection();
      con.setAutoCommit(false);
     
      UserBean user1 = BeanFactory.getUser(Thread.currentThread().getId());
      user1.setAttribute("name1", "value1");
      user1.create(con);
      UserBean user2 = (UserBean)UserFinderBase.findByPrimaryKey(con, new UserKey(user1.getId()));
      assertEquals("Userna skall vara lika", user1, user2);
      con.rollback();
      con.close();
    } catch (SQLException sqle) {
      fail("SQLException on testEquals: "+ sqle.getMessage());
View Full Code Here

    try {
      Connection con = DbHandler.getConnection();
      con.setAutoCommit(false);

      //Spara och ladda attribut
      UserBean user1 = BeanFactory.getUser(Thread.currentThread().getId());
      user1.setAttribute("name1", "value1");
      user1.create(con);
      UserBean user2 = (UserBean)UserFinderBase.findByPrimaryKey(con, new UserKey(user1.getId()));
      assertEquals("Attributen skall vara lika", user1.getAttribute("name1"), user2.getAttribute("name1"));
     
      //Radera attribut
      user2.removeAttribute("name1");
      assertNull("Attributet skall inte finnas", user2.getAttribute("name1"));
      user2.store(con);
      user1 = (UserBean)UserFinderBase.findByPrimaryKey(con, new UserKey(user2.getId()));
      assertNull("Attributet skall inte finnas", user2.getAttribute("name1"));

      //Uppdatera attribut
      user1.setAttribute("name1", "value1");
      user1.store(con);
      user1.setAttribute("name1", "newvalue1");
      user1.store(con);
      user2 = (UserBean)UserFinderBase.findByPrimaryKey(con, new UserKey(user1.getId()));
      assertEquals("Attributet skall ha nytt v�rde", "newvalue1", user2.getAttribute("name1"));
      user2.removeAllAttributes();
      user2.store(con);
     
      //Skapa tre attribut, d�refter uppdatera ett och radera ett
      assertTrue("Det skall inte finnas n�gra attribut", user2.getAttributes().isEmpty());
      user2.setAttribute("name1", "value1");
      user2.setAttribute("name2", "value2");
      user2.setAttribute("name3", "value3");
      user2.store(con);
     
      user2.setAttribute("name1", "newvalue1");
      user2.setAttribute("name3", "");
      user2.removeAttribute("name2");
      assertEquals("Det skall finnas tv� attribut", 2, user2.getAttributes().size());
      user2.store(con);
     
      user1 = (UserBean)UserFinderBase.findByPrimaryKey(con, new UserKey(user2.getId()));
      assertEquals("Det skall finnas ett attribut", 1, user1.getAttributes().size());
      assertEquals("Fel attributv�rde", "newvalue1", user1.getAttribute("name1"));
      assertNull("Attributet skall inte finnas", user1.getAttribute("name2"));
      assertNull("Attributet skall inte finnas", user1.getAttribute("name3"));
     
View Full Code Here

  @Override
  protected void giveService(HttpServletRequest req, HttpServletResponse res,
      String incXML)
      throws ServletException, IOException {
    UserBean userBean = null;
    // System.out.println(file);
    // log.log(Level.ERROR, "ajaxLogger() error from js: "
    // + loginAnswer.getUserId() + inData);

    String userId = incXML.substring(incXML.indexOf("<id>") + 4, incXML
        .indexOf("</id>"));

   
    try {
      userBean = (UserBean) UserFinder
          .findByPrimaryKey(new UserKey(userId));
      userBean.setPassword(null);
      userBean.setChangepassword(null);
      userBean.setTspassword(null);
     
    res.getWriter().write("<user>\n");
    res.getWriter().write(userBean.toString());
//    res.getWriter().write("<id>");
//    res.getWriter().write(userBean.getId().toString());
//    res.getWriter().write("</id>\n");
//    res.getWriter().write("<name>");
//    res.getWriter().write(userBean.getCentrename().toString());
View Full Code Here

TOP

Related Classes of org.openqreg.bean.UserBean

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.