Package org.openqreg.bean

Examples of org.openqreg.bean.CountryBean


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


* @return A populated CountryBean
*
* @throws SQLException
*/
protected static CountryBean populate(ResultSet rs) throws SQLException {
CountryBean valueObject = new CountryBean();
valueObject.setId((String)rs.getObject(1));
valueObject.setPatientidstyle((Integer)rs.getObject(2));
valueObject.setStatus((Integer)rs.getObject(3));
valueObject.setTscreated((java.sql.Timestamp)rs.getObject(4));
valueObject.setTsupdated((java.sql.Timestamp)rs.getObject(5));
valueObject.setUpdatedby((String)rs.getObject(6));
valueObject.setTimezone((String)rs.getObject(7));
valueObject.setDefaultlanguageid((String)rs.getObject(8));
valueObject.setCreatedby((String)rs.getObject(9));
return valueObject;
}
View Full Code Here

  public static CountryBean getCountry(String countryid) throws SQLException{
   
    Collection<LanguageBean> languages = LanguageFinderBase.findAll();
    LanguageBean language = languages.iterator().next();
   
    CountryBean testCountry = new CountryBean();
    testCountry.setId(countryid);
    testCountry.setPatientidstyle(new Integer(1));
    testCountry.setStatus(new Integer(Status.ACTIVE));
    testCountry.setDefaultlanguageid(language.getLanguageid());
    testCountry.setTimezone(TimeZone.getDefault().getDisplayName());
    testCountry.setCreatedby("System");
    testCountry.setTscreated(new Timestamp(System.currentTimeMillis()));
    testCountry.setUpdatedby("System");
    testCountry.setTsupdated(new Timestamp(System.currentTimeMillis()));
   
    return testCountry;
  }
View Full Code Here

    try {
     
      Connection con = DbHandler.getConnection();
      con.setAutoCommit(false);
     
      CountryBean country1 = BeanFactory.getCountry("uz");
      country1.create(con);
     
      country1.setStatus(new Integer(Status.INACTIVE));
      country1.store(con);

      CountryBean country2 = (CountryBean) CountryFinderBase.findByPrimaryKey(con, new CountryKey(country1.getId()));
      assertEquals("Countryn skall vara lika", country1, country2);
      assertEquals("Countryn skall ha samma status", country1.getStatus(), country2.getStatus());

      country1.remove(con);
      country2 = (CountryBean) CountryFinderBase.findByPrimaryKey(con, new CountryKey(country1.getId()));
      assertNull("Ingen tr�ff f�rv�ntad", country2);
      con.rollback();
View Full Code Here

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

      //Spara och ladda attribut
      CountryBean country1 = BeanFactory.getCountry("bi");
      country1.setAttribute("name1", "value1");
      country1.create(con);
      CountryBean country2 = (CountryBean)CountryFinderBase.findByPrimaryKey(con, new CountryKey(country1.getId()));
      assertEquals("Countryna skall vara lika", country1, country2);
      assertEquals("Attributen skall vara lika", country1.getAttribute("name1"), country2.getAttribute("name1"));
     
      //Radera attribut
      country2.removeAttribute("name1");
      assertNull("Attributet skall inte finnas", country2.getAttribute("name1"));
      country2.store(con);
      country1 = (CountryBean)CountryFinderBase.findByPrimaryKey(con, new CountryKey(country2.getId()));
      assertNull("Attributet skall inte finnas", country2.getAttribute("name1"));

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

* @throws SQLException
*/
public static Collection<CountryBean> findAll(Connection con) throws SQLException {
PreparedStatement pStmt = null;
ResultSet rs = null;
CountryBean valueObject = null;
Collection<CountryBean> col = Collections.synchronizedList(new ArrayList<CountryBean>());
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;
CountryBean valueObject = null;
CountryKey primaryKey = (CountryKey) key;
try{
pStmt = con.prepareStatement(CountryBeanBase.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

TOP

Related Classes of org.openqreg.bean.CountryBean

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.