Package org.apache.empire.db

Examples of org.apache.empire.db.DBRecord


     * Insert a department
     */
    private int insertDepartmentSampleRecord(Connection conn, String department_name, String businessUnit)
    {
        // Insert a Department
        DBRecord rec = new DBRecord();
        rec.create(db.DEPARTMENTS);
        rec.setValue(db.DEPARTMENTS.NAME, department_name);
        rec.setValue(db.DEPARTMENTS.BUSINESS_UNIT, businessUnit);
        if (!rec.update(conn))
        {
            log.error(rec.getErrorMessage());
            return 0;
        }
        // Return Department ID
        return rec.getInt(db.DEPARTMENTS.DEPARTMENT_ID);
    }
View Full Code Here


     */
    private int insertEmployeeSampleRecord(Connection conn, String salutation, String firstName, String lastName,
                                           String gender, int depID)
    {
        // Insert an Employee
        DBRecord rec = new DBRecord();
        rec.create(db.EMPLOYEES);
        rec.setValue(db.EMPLOYEES.SALUTATION, salutation);
        rec.setValue(db.EMPLOYEES.FIRSTNAME, firstName);
        rec.setValue(db.EMPLOYEES.LASTNAME, lastName);
        rec.setValue(db.EMPLOYEES.GENDER, gender);
        rec.setValue(db.EMPLOYEES.DEPARTMENT_ID, depID);
        if (!rec.update(conn))
        {
            log.error(rec.getErrorMessage());
            return 0;
        }
        // Return Employee ID
        return rec.getInt(db.EMPLOYEES.EMPLOYEE_ID);
    }
View Full Code Here

        T_EMP = db.EMPLOYEES;
    }

    public boolean saveEmmployee(javax.xml.ws.Holder<Employee> empHolder)
    {
        DBRecord r = new DBRecord();
        Employee emp = empHolder.value;
        boolean init;
        if (emp.isNew())
            init = r.create(T_EMP, conn);
        else
            init = r.read(T_EMP, emp.getEmployeeId(), conn);

        boolean fill = r.setBeanValues(emp);
        boolean save = r.update(conn);

        if (init && fill && save)
        {
            r.getBeanProperties(emp);
            emp.setNew(false);
        }

        return init && fill && save;
    }
View Full Code Here

        return reader.getBeanList(Department.class);
    }

    public Employee createEmmployee()
    {
        DBRecord r = new DBRecord();
        Employee emp = new Employee();

        // null, so that no IDs are wasted.
        boolean create = r.create(T_EMP, null);
        boolean fill = r.getBeanProperties(emp);

        emp.setNew(true);

        return (create && fill ? emp : null);
    }
View Full Code Here

        return T_EMP.deleteRecord(id, conn);
    }

    public Employee getEmmployee(int id)
    {
        DBRecord r = new DBRecord();
        Employee emp = new Employee();

        boolean read = r.read(T_EMP, id, conn);
        boolean fill = r.getBeanProperties(emp);

        return (read && fill ? emp : null);
    }
View Full Code Here

    @Transactional
    public Integer insertDepartment(String departmentName, String businessUnit) {
        SampleDB db = getDB();
        Connection conn = getConnection();

        DBRecord rec = new DBRecord();
        rec.create(db.DEPARTMENTS);
        rec.setValue(db.DEPARTMENTS.NAME, departmentName);
        rec.setValue(db.DEPARTMENTS.BUSINESS_UNIT, businessUnit);
        rec.update(conn);
        // Return Department ID
        return rec.getInt(db.DEPARTMENTS.DEPARTMENT_ID);
    }
View Full Code Here

    @Transactional
    public Integer insertEmployee(String firstName, String lastName, String gender, int departmentId) {
        SampleDB db = getDB();
        Connection conn = getConnection();

        DBRecord rec = new DBRecord();
        rec.create(db.EMPLOYEES);
        rec.setValue(db.EMPLOYEES.FIRSTNAME, firstName);
        rec.setValue(db.EMPLOYEES.LASTNAME, lastName);
        rec.setValue(db.EMPLOYEES.GENDER, gender);
        rec.setValue(db.EMPLOYEES.DEPARTMENT_ID, departmentId);
        rec.update(conn);
        // Return Employee ID
        return rec.getInt(db.EMPLOYEES.EMPLOYEE_ID);
    }
View Full Code Here

        }

        SampleDB db = getDB();
        Connection conn = getConnection();

        DBRecord rec = new DBRecord();
    rec.read(db.EMPLOYEES, idPers, conn);
    // Set
    rec.setValue(db.EMPLOYEES.PHONE_NUMBER, phoneNumber);
    rec.update(conn);
    }
View Full Code Here

        db.open(driver, hsqldb.getConnection());
        DBSQLScript script = new DBSQLScript();
        db.getCreateDDLScript(db.getDriver(), script);
        script.run(db.getDriver(), hsqldb.getConnection(), false);
       
        DBRecord dep = new DBRecord();
        dep.create(db.DEPARTMENT);
        dep.setValue(db.DEPARTMENT.NAME, "junit");
        dep.setValue(db.DEPARTMENT.BUSINESS_UNIT, "testers");
        dep.update(conn);
       
        Date date = dep.getDateTime(db.DEPARTMENT.UPDATE_TIMESTAMP);
        assertNotNull("Date is null", date);
        assertTrue("No departments", dep.getInt(db.DEPARTMENT.ID) > 0);
       
       
        DBRecord emp = new DBRecord();
        emp.create(db.EMPLOYEE);
        emp.setValue(db.EMPLOYEE.FIRSTNAME, "junit");
        emp.setValue(db.EMPLOYEE.LASTNAME, "test");
        emp.setValue(db.EMPLOYEE.GENDER, "m");
        emp.setValue(db.EMPLOYEE.DEPARTMENT_ID, dep.getInt(db.DEPARTMENT.ID));
        emp.update(conn);
       
        date = emp.getDateTime(db.EMPLOYEE.UPDATE_TIMESTAMP);
        assertNotNull("Date is null", date);
        assertTrue("Employee id O or less", emp.getInt(db.EMPLOYEE.ID) > 0);

        int id = emp.getInt(db.EMPLOYEE.ID);
       
        // Update an Employee
        emp = new DBRecord();
        emp.read(db.EMPLOYEE, id, conn);
        // Set
        emp.setValue(db.EMPLOYEE.PHONE_NUMBER, "123456");
        emp.update(conn);
       
        emp = new DBRecord();
        emp.read(db.EMPLOYEE, id, conn);
       
        assertEquals("123456", emp.getString(db.EMPLOYEE.PHONE_NUMBER));
       
        script = new DBSQLScript();
        db.getDriver().getDDLScript(DBCmdType.DROP, db.EMPLOYEE, script);
        db.getDriver().getDDLScript(DBCmdType.DROP, db.DEPARTMENT, script);
        script.run(db.getDriver(), conn, true);
View Full Code Here

  /*
   * Insert a department
   */
  private int insertDepartmentSampleRecord(Connection conn, String department_name, String businessUnit) {
      // Insert a Department
      DBRecord rec = new DBRecord();
      rec.create(db.T_DEPARTMENTS);
      rec.setValue(db.T_DEPARTMENTS.C_NAME, department_name);
      rec.setValue(db.T_DEPARTMENTS.C_BUSINESS_UNIT, businessUnit);
      if (!rec.update(conn)) {
        log.error(rec.getErrorMessage());
        return 0;
      }
      // Return Department ID
      return rec.getInt(db.T_DEPARTMENTS.C_DEPARTMENT_ID);
    }
View Full Code Here

TOP

Related Classes of org.apache.empire.db.DBRecord

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.