Examples of UsercentrerelBean


Examples of org.openqreg.bean.UsercentrerelBean

      // there must be a groupid for this relation AND it must be active,
      // (new relations must be active to be created)
      if (!"".equals(fGroupId) && Integer.valueOf(1).equals(fStatus)) {
        // Tie user to centre in usercentrerel table
        ucrBean = new UsercentrerelBean();
        ucrBean.setUserid(userToEdit.getId());
        ucrBean.setCentreid(fCentreId);
        ucrBean.setGroupid(fGroupId);
        // ucrBean.setStatus(Integer.valueOf(1));
        ucrBean.setStatus(fStatus);
View Full Code Here

Examples of org.openqreg.bean.UsercentrerelBean

      // if for some reason ther is no groupid for this relation, do
      // nothing
      if (!"".equals(fGroupId)) {

        // get ucrBean for the user on this centreId
        UsercentrerelBean ucrBeanInDB = (UsercentrerelBean) UsercentrerelFinderBase
            .findByPrimaryKey(con, new UsercentrerelKey(userToEdit
                .getId(), fCentreId));

        if (null == ucrBeanInDB) {
          // new relation
          isNew = true;
          ucrBeanInDB = new UsercentrerelBean();
        }

        ucrBeanInDB.setStatus(fStatus);
        ucrBeanInDB.setGroupid(fGroupId);
        ucrBeanInDB.setTsupdated(tsNow);
        ucrBeanInDB.setUpdatedby(user.getId());

        // not stored in db since before, and is active
        // (new relations must be active to be created)
        if (isNew && Integer.valueOf(1).equals(fStatus)) {
          ucrBeanInDB.setUserid(userToEdit.getId());
          ucrBeanInDB.setTscreated(tsNow);
          ucrBeanInDB.setCreatedby(user.getId());
          ucrBeanInDB.setCentreid(fCentreId);
          ucrBeanInDB.create(con);
        }
        if (!isNew) {
          ucrBeanInDB.store(con);
        }
        // set groupId and status on users changed from nonUcr to ucr
        // on users new active centre ()
        if (setGroupToActiveCentre
            && fCentreId.equals(userToEdit.getCentreid())
            && null != fGroupId && null != fStatus) {
          setGroupToActiveCentre = false;
          userToEdit.setGroupid(fGroupId);
          userToEdit.setStatus(fStatus);
        }

        // if userToEdit has a group on this centre now
        // and user does not have relation to userToEdit on this centre
        // something is wrong, abuse
        if (null != UserRelation.retrieveGroupId(con, userToEdit,
            fCentreId)
            && !UserRelation.hasUserRelationToUserToEditOnCentre(
                con, user, userToEdit, fCentreId)) {
          abuseLog("updateData, before update", ucrBean.getUserid(),
              ucrBean.getCentreid(), ucrBean.getGroupid());
          rollback(con);
          return;
        }
      }
    }

    if (Integer.valueOf(0).equals(
        userGroups.get(userToEdit.getGroupid()).getUseucr())) {
      // if no ucr user remove all ucr beans.
      for (UsercentrerelBean ucr : UsercentrerelFinder.findByUserid(con, userToEdit.getId())) {
        ucr.remove(con);
      }
    } else {
      // ucrUser
      /**
       * check that the user is still active in relation to its current
       * centre, else move to an active relation<br/>
       * handle deactivated / activated ucr users
       *
       */
      boolean activeUcrExists = false;
      boolean changeCentre = false;
      String possibleActiveCentre = null;
      String currentGroupId = null;

      UsercentrerelBean ucrB = (UsercentrerelBean) UsercentrerelFinderBase
          .findByPrimaryKey(con, new UsercentrerelKey(userToEdit
              .getId(), userToEdit.getCentreid()));

      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;
            }
          }
          // if (ucr.getCentreid().equals(userToEdit.getCentreid())
          // && !Integer.valueOf(1).equals(ucr.getStatus())) {
          // // current centre not active
          // changeCentre = true;
          // }
        }
      } else {
        // active on current
        activeUcrExists = true;
        currentGroupId = ucrB.getGroupid();
      }

      if (activeUcrExists) {
        // user is active on any centre
        userToEdit.setStatus(Integer.valueOf(1));
View Full Code Here

Examples of org.openqreg.bean.UsercentrerelBean

      }
      // as only active centre is shown always set owning to active
      myself.setOwningcentre(myself.getCentreid());
    } else {
      // ucrUser
      UsercentrerelBean ucrBean = null;
      ucrBean = (UsercentrerelBean) UsercentrerelFinderBase
          .findByPrimaryKey(con, new UsercentrerelKey(myself.getId(),
              myself.getCentreid()));
      if (null == ucrBean
          || Integer.valueOf(0).equals(ucrBean.getStatus())) {
        abuseLog("updateData, no ucr relation to new centre or relation inactive ");
        myself = null;
        return;
      }
      myself.setGroupid(ucrBean.getGroupid());
      // ucrBeanOk = true; // Found identity on centre
    }

    myself.setTsupdated(new Timestamp(System.currentTimeMillis()));
    myself.setUpdatedby(user.getId());
View Full Code Here

Examples of org.openqreg.bean.UsercentrerelBean

        Timestamp now = new Timestamp(System.currentTimeMillis());
        user.setCentreid(centreId);
        user.setTsupdated(now);
        user.setUpdatedby(user.getId());
        if (UserRelation.isUcrUser(con, user)) {
          UsercentrerelBean ucrBean = (UsercentrerelBean) UsercentrerelFinderBase
              .findByPrimaryKey(
                  con,
                  new UsercentrerelKey(user.getId(), centreId));
          user.setGroupid(ucrBean.getGroupid());
        }
        ((UserBean) user).store();
      } else {
        abuseLog("updateData, No access to choosen centre ");
        return;
View Full Code Here

Examples of org.openqreg.bean.UsercentrerelBean

        "ADMINUSER_USERCENTREREL_DEACTIVATE_ALL_GROUP_D"));
    outTop.append("</span>");
    outTop.append("</td>\n");
    outTop.append("</tr>\n");

    UsercentrerelBean userToEditUcrBean = null;

    StringBuilder buffToCollection = null;
    // Store rows temporarely in Map, centre name+id as key == sorted table
    // rows
    Connection con = null;
    try {
      pageContext.getOut().println(outTop);

      // Get all groups that can never be set to UCR-table (USEUCR=0),
      // used below
      Map<String, UsergroupBean> userGroupMap = UsergroupFinder.searchByUseUcr(Integer.valueOf(0));
      con = DbHandler.getConnection();
      Collection<? extends Centre> col = UserRelation.retrieveCentreList(
          con, user, userToEdit, Integer.valueOf(1), null, true);

      BeanSorter.sort(BeanSorter.getLocale(user), col, "centrename");
      StringBuilder jsOut = new StringBuilder();
      jsOut.append("<script language=\"JavaScript\" type=\"text/JavaScript\">\n");
      for (Centre centre : col) {
        // if admin user is not ucr-user, then the user might have different groupid for different centers,
        // set to null now and find out groupid per center
        String grpidforcentre = (userGroupMap.get(user.getGroupid()) != null ? user.getGroupid() : null);     
        buffToCollection = new StringBuilder();
        userToEditUcrBean = ucrUserToEdit.get(centre.getId());
        if (userToEditUcrBean != null && userToEditUcrBean.getStatus() != null) {
          buffToCollection.append("<tr id=\"USERCENTREREL_ROW_");
          buffToCollection.append(centre.getId());
          buffToCollection.append("_TR\"");
          buffToCollection.append(">\n");
          buffToCollection.append("<td>\n");
          buffToCollection.append(centre.getCentrename());
          buffToCollection.append("</td>\n");
          buffToCollection.append("<td>\n");
          if (grpidforcentre == null) {
            grpidforcentre = UsercentrerelFinder.findGroupidByUseridCentreid(con, user.getId(), centre.getId());
          }         
          buffToCollection.append(getGroupSelect(lang, langId, grpidforcentre, centre.getId(), userToEditUcrBean, userGroupMap, userGroupRels));
          buffToCollection.append("<td>\n");
          buffToCollection.append(getStatusSelect(centre.getId(), userToEditUcrBean.getStatus()));
          buffToCollection.append("</td>\n");
         
         
          pageContext.getOut().println(buffToCollection);
          jsOut.append(getJs("USERCENTREREL_GROUPID", lang, langId, centre.getId()));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.