Package org.openqreg.bean

Examples of org.openqreg.bean.CentreBean


   
    try {
      con = DbHandler.getConnection();
      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) {
      fail("Database error: "+ e);
View Full Code Here


      if (null == ucrB || !Integer.valueOf(1).equals(ucrB.getStatus())) {
        // not active
        for (UsercentrerelBean ucr : UsercentrerelFinder.findByUserid(con, userToEdit.getId())) {
          if (Integer.valueOf(1).equals(ucr.getStatus())) {
            CentreBean cb = (CentreBean) CentreFinderBase
                .findByPrimaryKey(new CentreKey(ucr
                    .getCentreid()));
            if (cb.getStatus().equals(Integer.valueOf(1))) {
              activeUcrExists = true;
              possibleActiveCentre = ucr.getCentreid();
              currentGroupId = ucr.getGroupid();
              changeCentre = true;
            }
View Full Code Here

  }

  @Test
  public void testPersistance() {
    try {
      CentreBean centre1 = BeanFactory.getCentre(Thread.currentThread().getId());
      Connection con = DbHandler.getConnection();
      con.setAutoCommit(false);
      centre1.create(con);
      centre1.setStatus(new Integer(Status.INACTIVE));
      centre1.store(con);

      CentreBean centre2 = (CentreBean) CentreFinderBase.findByPrimaryKey(con, new CentreKey(centre1.getId()));
      assertEquals("Centren skall vara lika", centre1, centre2);
      assertEquals("Centren skall ha samma status", centre1.getStatus(), centre2.getStatus());

      centre1.remove(con);
      centre2 = (CentreBean) CentreFinderBase.findByPrimaryKey(con, new CentreKey(centre1.getId()));
      assertNull("Ingen tr�ff f�rv�ntad", centre2);
      con.rollback();
View Full Code Here

    String centrename = "JUnit@"+ Thread.currentThread().getId() +"@";
    try {
      con = DbHandler.getConnection();
      con.setAutoCommit(false);
     
      CentreBean centre1 = BeanFactory.getCentre(Thread.currentThread().getId());
      centre1.setCentrename(centrename+"12345");
      centre1.create(con);
     
      CentreBean centre2 = BeanFactory.getCentre(Thread.currentThread().getId());
      centre2.setCentrename(centrename+"1234");
      centre2.create(con);
     
      CentreBean centre3 = BeanFactory.getCentre(Thread.currentThread().getId());
      centre3.setCentrename(centrename+"123");
      centre3.create(con);
      con.rollback();
      con.close();
     
    } catch (SQLException sqle) {
      fail("SQLException on findLikeCentreName: " + sqle.getMessage());
View Full Code Here

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

      //Spara och ladda attribut
      CentreBean centre1 = BeanFactory.getCentre(Thread.currentThread().getId());
      centre1.setAttribute("name1", "value1");
      centre1.create(con);
      CentreBean centre2 = (CentreBean)CentreFinderBase.findByPrimaryKey(con, new CentreKey(centre1.getId()));
      assertEquals("Centrena skall vara lika", centre1, centre2);
      assertEquals("Attributen skall vara lika", centre1.getAttribute("name1"), centre2.getAttribute("name1"));
     
      //Radera attribut
      centre2.removeAttribute("name1");
      assertNull("Attributet skall inte finnas", centre2.getAttribute("name1"));
      centre2.store(con);
      centre1 = (CentreBean)CentreFinderBase.findByPrimaryKey(con, new CentreKey(centre2.getId()));
      assertNull("Attributet skall inte finnas", centre2.getAttribute("name1"));

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

      /**
       * must be on the same centre as before<br/>
       * OR have ADMINMYSELF_CENTREID AND be in the same country<br/>
       * OR must have ADMINMYSELF_COUNTRYID
       */
      CentreBean oldCentre = (CentreBean) CentreFinderBase
          .findByPrimaryKey(con, new CentreKey(user.getCentreid()));
      CentreBean newCentre = (CentreBean) CentreFinderBase
          .findByPrimaryKey(con, new CentreKey(myself.getCentreid()));

      if (oldCentre.getId().equals(newCentre.getId())
          || (disp.checkAccess(user.getId(), "ADMINMYSELF_CENTREID") && oldCentre
              .getCountryid().equals(newCentre.getCountryid()))
          || disp.checkAccess(user.getId(), "ADMINMYSELF_COUNTRYID")) {
        // ok on centre
      } else {
        abuseLog("updateData, noUncrUser wrong centre ");
        myself = null;
View Full Code Here

    // + loginAnswer.getUserId() + inData);

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

    CentreBean centreBean = null;
    try {
      centreBean = (CentreBean) CentreFinderBase
          .findByPrimaryKey(new CentreKey(centreId));

      // write out about mainPic
      res.getWriter().write("<centre>\n");
      res.getWriter().write(centreBean.toString());
      res.getWriter().write("<id>");
      res.getWriter().write(centreBean.getId().toString());
      res.getWriter().write("</id>\n");
      res.getWriter().write("<name>");
      res.getWriter().write(centreBean.getCentrename().toString());
      res.getWriter().write("</name>\n");
      res.getWriter().write("<centreshortname>");
      res.getWriter().write(centreBean.getCentreshortname().toString());
      res.getWriter().write("</centreshortname>\n");
      res.getWriter().write("</centre>\n");
    } catch (SQLException sqle) {
      log.log(Level.ERROR, "Unable to load requested CentreBean", sqle);
    }
View Full Code Here

TOP

Related Classes of org.openqreg.bean.CentreBean

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.