Package org.openqreg.bean

Examples of org.openqreg.bean.CentreBean


* @return A populated CentreBean
*
* @throws SQLException
*/
protected static CentreBean populate(ResultSet rs) throws SQLException {
CentreBean valueObject = new CentreBean();
valueObject.setId((String)rs.getObject(1));
valueObject.setCentrename((String)rs.getObject(2));
valueObject.setBelongsto((String)rs.getObject(3));
valueObject.setOrganisation((String)rs.getObject(4));
valueObject.setCentreshortname((String)rs.getObject(5));
valueObject.setTimezone((String)rs.getObject(6));
valueObject.setImportformat((Integer)rs.getObject(7));
valueObject.setImporting((Integer)rs.getObject(8));
valueObject.setStatus((Integer)rs.getObject(9));
valueObject.setLanguageid((String)rs.getObject(10));
valueObject.setCountryid((String)rs.getObject(11));
valueObject.setTypeid((Integer)rs.getObject(12));
valueObject.setTest((Integer)rs.getObject(13));
valueObject.setDefaultlanguageid((String)rs.getObject(14));
valueObject.setCreatedby((String)rs.getObject(15));
valueObject.setTscreated((java.sql.Timestamp)rs.getObject(16));
valueObject.setUpdatedby((String)rs.getObject(17));
valueObject.setTsupdated((java.sql.Timestamp)rs.getObject(18));
return valueObject;
}
View Full Code Here


* @throws SQLException
*/
public static Collection<CentreBean> findAll(Connection con) throws SQLException {
PreparedStatement pStmt = null;
ResultSet rs = null;
CentreBean valueObject = null;
Collection<CentreBean> col = Collections.synchronizedList(new ArrayList<CentreBean>());
try{
pStmt = con.prepareStatement(FIND_ALL_STATEMENT);
rs = pStmt.executeQuery();
while (rs.next()){
valueObject = populate(rs);
valueObject.afterPopulate(con);
col.add(valueObject);
}
return col;
}finally{
if(null!=rs){
View Full Code Here

* @throws SQLException
*/
public static Object findByPrimaryKey(Connection con, PrimaryKey key) throws SQLException {
PreparedStatement pStmt = null;
ResultSet rs = null;
CentreBean valueObject = null;
CentreKey primaryKey = (CentreKey) key;
try{
pStmt = con.prepareStatement(CentreBeanBase.SELECT_STATEMENT);
pStmt.setObject(1, primaryKey.getId());
rs = pStmt.executeQuery();
while (rs.next()){
valueObject = populate(rs);
valueObject.afterPopulate(con);
}
return valueObject;
}finally{
if(null!=rs){
rs.close();
View Full Code Here

   * Creates a new CentreBean. This method can be overridden in subclasses.
   *
   * @return A new CentreBean
   */
  public CentreBean createCentre() {
    return new CentreBean();
  }
View Full Code Here

     * OR have ADMINUSER_CENTRE AND be in the same country<br/>
     * OR must have ADMINUSER_COUNTRY
     */

    try {
      CentreBean userCentre = (CentreBean) CentreFinderBase
          .findByPrimaryKey(new CentreKey(user.getCentreid()));
      CentreBean userToEditCentre = (CentreBean) CentreFinderBase
          .findByPrimaryKey(new CentreKey(userToEdit.getCentreid()));

      if (user.getCentreid().equals(userToEdit.getCentreid())
          || (disp.checkAccess(user.getId(), "ADMINUSER_CENTRE") && userCentre
              .getId().equals(userToEditCentre.getId()))
          || disp.checkAccess(user.getId(), "ADMINUSER_COUNTRY")

      ) {

        // ok on centre
View Full Code Here

     * nonUcrUser<br/>
     * must be on the same centre as the one we are looking at<br/>
     * OR have ADMINMYSELF_CENTRE AND be in the same country<br/>
     * OR must have ADMINMYSELF_COUNTRY
     */
    CentreBean userCentre = (CentreBean) CentreFinderBase.findByPrimaryKey(
        con, new CentreKey(user.getCentreid()));
    CentreBean centre = (CentreBean) CentreFinderBase.findByPrimaryKey(con,
        new CentreKey(centreId));

    if (user.getCentreid().equals(centreId)
        || (Dispatcher.getInstance().checkGroupAccess(
            user.getGroupid(), "ADMINMYSELF_CENTREID") && userCentre
            .getCountryid().equals(centre.getCountryid()))
        || Dispatcher.getInstance().checkGroupAccess(user.getGroupid(),
            "ADMINMYSELF_COUNTRYID")) {
      // nonUcr has a relation to this centre, return groupId
      return user.getGroupid();
    }
View Full Code Here

      countId = ((CentreBean) CentreFinderBase.findByPrimaryKey(con,
          new CentreKey(user.getCentreid()))).getCountryid();
    }
    // Limit search if not superuser (SYSTEM, CC)
    if (isUcrUser(con, user)) {
      CentreBean centre = null;
      // get a collection of all ucrBeans for user, (all centres user
      // can be on)
      Collection<UsercentrerelBean> colUserCentres = UsercentrerelFinder
          .findByUseridPartOfCentrename(con, user.getId(),
              partOfCentrename);
      // loop ucrBeans check relation on each centre
      for (UsercentrerelBean ucrBean : colUserCentres) {
        if (null == ucrStatus || ucrStatus.equals(ucrBean.getStatus())) {
          centre = (CentreBean) CentreFinderBase.findByPrimaryKey(
              con, new CentreKey(ucrBean.getCentreid()));
          // if centre is active, add to collection
          if (null == centreStatus
              || centreStatus.equals(centre.getStatus())) {
            col.add(centre);
          }
        }
      }
      return col;
View Full Code Here

     * nonUcrUser<br/>
     * must be on the same centre as the one we are looking at<br/>
     * OR have ADMINMYSELF_CENTRE AND be in the same country<br/>
     * OR must have ADMINMYSELF_COUNTRY
     */
    CentreBean userCentre = (CentreBean) CentreFinderBase.findByPrimaryKey(
        con, new CentreKey(user.getCentreid()));
    CentreBean centre = (CentreBean) CentreFinderBase.findByPrimaryKey(con,
        new CentreKey(centreId));

    if (user.getCentreid().equals(centreId)
        || (Dispatcher.getInstance().checkGroupAccess(
            user.getGroupid(), "ADMINMYSELF_CENTREID") && userCentre
            .getCountryid().equals(centre.getCountryid()))
        || Dispatcher.getInstance().checkGroupAccess(user.getGroupid(),
            "ADMINMYSELF_COUNTRYID")) {
      // nonUcr has a relation to this centre, return groupId
      return true;
    }
View Full Code Here

 
  public static CentreBean getCentre(long id) throws SQLException{
   
    String centreid = "JUnit@"+ id +"@"+ System.currentTimeMillis();
    CentreBean testCentre = new CentreBean();
   
    Collection<LanguageBean> languages = LanguageFinderBase.findAll();
    Language language = languages.iterator().next();
   
    Collection<CountryBean> countries = CountryFinderBase.findAll();
    Country country = countries.iterator().next();
   
    Collection<CentretypeBean> centretypes = CentretypeFinderBase.findAll();
    Centretype centretype = centretypes.iterator().next();
   
    testCentre.setId(centreid);
    testCentre.setCentrename(centreid);
    testCentre.setBelongsto(null);
    testCentre.setCentreshortname(centreid.substring(0, 9));
    testCentre.setTimezone(null);
    testCentre.setImportformat(null);
    testCentre.setImporting(new Integer(0));
    testCentre.setStatus(new Integer(Status.ACTIVE));
    testCentre.setLanguageid(language.getLanguageid());
    testCentre.setCountryid(country.getId());
    testCentre.setTypeid(centretype.getId());
    testCentre.setTest(new Integer(1));
    testCentre.setDefaultlanguageid(language.getLanguageid());
    testCentre.setCreatedby("System");
    testCentre.setTscreated(new Timestamp(System.currentTimeMillis()));
    testCentre.setUpdatedby("System");
    testCentre.setTsupdated(new Timestamp(System.currentTimeMillis()));
   
    return testCentre;
  }
View Full Code Here

   
    Collection<UsergroupBean> usergroups = UsergroupFinderBase.findAll();
    UsergroupBean usergroup = usergroups.iterator().next();
   
    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

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.