Package org.objectweb.speedo.j2eedo.database

Examples of org.objectweb.speedo.j2eedo.database.Employee


    outStr.append("\nAdd project : ").append(p.getProid());
    pollsSync.addInPool(DatabaseImpl.poolOfProjectId, p.getProid());
    pm.setUserObject( pollsSync);

    int nbEmployees = Alea.rand(MIN_MEMBER_PER_PROJECT, MAX_MEMBER_PER_PROJECT);
    Employee e = null;
    for (int i = 0; i < nbEmployees; i++) {
      e = (Employee) pm.getObjectById(
          pm.newObjectIdInstance(
              Employee.class,
              Long.toString(
View Full Code Here


    logger.log(BasicLevel.DEBUG,
        "Create a new department id :" + d.getDeptid());
    int nbEmployees = Alea.rand(MIN_EMPLOYEE_PER_DEPARTMENT, MAX_EMPLOYEE_PER_DEPARTMENT);
        outStr.append("\n\tAdd new Department : ").append(d.getDeptid());
        outStr.append(" with ").append(nbEmployees).append(" employees");
        Employee boss = null;
    for (int i = 0; i < nbEmployees; i++) {
      Calendar cal = Calendar.getInstance();
      cal.set(Alea.rand(1900, 2004), Alea.rand(1, 12), Alea.rand(1, 28));
      Employee e = new Employee(
            "First-" + Alea.randomstring(4, 5),
            "Last-" + Alea.randomstring(8, 10),
            cal.getTime(),
            d);
      e.setSalary(Alea.rand(5000, 45000));
      Address a = new Address();
      a.setCity("City-" + Alea.randomstring(4, 5));
      a.setStreet("Street-" + Alea.randomstring(4, 5));
      a.setState("StateItf-" + Alea.randomstring(4, 5));
      a.setZipcode("ZIP-" + Alea.randomstring(2, 3));
      e.setAddress(a);
      pm.makePersistent(e);
      if (0 == i) {
        boss = e;
                outStr.append("\nThe boss: ");
      } else {
        e.setManager(boss);
      }
            outStr.append(e.getAsString());
      pollsSync.addInPool(DatabaseImpl.poolOfEmployeeId, e.getEmpid());
           
    }
    pm.setUserObject(pollsSync);
  }
View Full Code Here

      outStr.append("\nMove project : ").append(p.getId());
    }

    // move employees
    Iterator persons = initialDepartment.getEmployees().iterator();
    Employee e = null;
    while (persons.hasNext()) {
      e = (Employee) persons.next();
      e.setDepartment(destinationDepartment);
      outStr.append("\nAffect employee : ").append(e.getId());
    }

    // remove department
    pm.deletePersistent(initialDepartment);
  }
View Full Code Here

      outStr.append("\nMove project : " + p.getId());
    }

    // move employees
    Iterator persons = initialDepartment.getEmployees().iterator();
    Employee e = null;
    int nbEmployee = Math.round(initialDepartment.getEmployees().size()/2);
    while (persons.hasNext() && nbEmployee >0) {
      nbEmployee--;
      e = (Employee) persons.next();
      e.setDepartment(d);
      outStr.append("\nAffect employee : " + e.getId());
    }
  }
View Full Code Here

              false);
    logger.log(BasicLevel.DEBUG,
        "Update manager for the department having id :" + d.getDeptid());
    // the first person from a department is the boss;
    Iterator persons = d.getEmployees().iterator();
    Employee boss = null;
    Employee otherEmp = null;
    if (persons.hasNext()) {
      boss = (Employee) persons.next();
      outStr.append("\nThe boss of the department '");
      outStr.append(boss.getDepartment().getName());
      outStr.append("' is now: ").append(boss.getFirstname());
      while (persons.hasNext()) {
        otherEmp = (Employee) persons.next();
        otherEmp.setManager(boss);
                outStr.append("\nThe employee ").append(otherEmp.getEmpid());
                outStr.append(" has a new manager.");
      }
    }
  }
View Full Code Here

    Department d = (Department) pm.getObjectById(
          pm.newObjectIdInstance(Department.class, Long.toString(id)),
          false);
    Calendar cal = Calendar.getInstance();
    cal.set(Alea.rand(1900, 2004), Alea.rand(1, 12), Alea.rand(1, 28));
    Employee e =
      new Employee(
          "First-" + Alea.randomstring(4, 5),
          "Last-" + Alea.randomstring(8, 10),
          cal.getTime(),
          d);
    e.setSalary(Alea.rand(5000, 45000));
    Address a = new Address();
    a.setCity("City-" + Alea.randomstring(4, 5));
    a.setStreet("Street-" + Alea.randomstring(4, 5));
    a.setState("StateItf-" + Alea.randomstring(4, 5));
    a.setZipcode("ZIP-" + Alea.randomstring(2, 3));
    e.setAddress(a);
    pm.makePersistent(e);
        outStr.append("\nCreate a new employee:").append(e.getAsString());
    logger.log(BasicLevel.DEBUG, "Create a new employee having id=" + e.getEmpid());
    pollsSync.addInPool(DatabaseImpl.poolOfEmployeeId, e.getEmpid());
    pm.setUserObject(pollsSync);
  }
View Full Code Here

    // remove id from static pool to avoid other threatment to use it
    pollsSync.removeFromPool(DatabaseImpl.poolOfEmployeeId, id);
    pm.setUserObject( pollsSync);
    outStr.append("\nRemove the employee ").append(id);
    logger.log(BasicLevel.DEBUG, "Delete employee having id=" + id);
    Employee e =
      (Employee) pm.getObjectById(
          pm.newObjectIdInstance(Employee.class, Long.toString(id)),
          false);
    Address a = e.getAddress();
    pm.deletePersistent(a);
    pm.deletePersistent(e);
  }
View Full Code Here

  public void getEmployee(StringBuffer outStr,
            PersistenceManager pm) {
    long id = DatabaseImpl.getEmployeeIdFromPool();
    outStr.append("\nGet the employe id ").append(id);
    logger.log(BasicLevel.DEBUG, "Get employee having id=" + id);
    Employee e = (Employee) (Employee) pm.getObjectById(
          pm.newObjectIdInstance(Employee.class, Long.toString(id)),
          false);
    outStr.append(e.getAsString());
  }
View Full Code Here

   */
  public void increaseSalary(StringBuffer outStr, PersistenceManager pm) {
    long id = DatabaseImpl.getEmployeeIdFromPool();
    outStr.append("\nIncrease salary for the employe ").append(id);
    logger.log(BasicLevel.DEBUG, "Increase the salary for the employee having id=" + id);
    Employee e = (Employee) pm.getObjectById(
          pm.newObjectIdInstance(Employee.class, Long.toString(id)),
          false);
    e.setSalary(e.getSalary() + 1);
  }
View Full Code Here

    try {
            Collection col = (Collection) query.execute(new Long(id));
        Iterator iter = col.iterator();
        if (!iter.hasNext())
          throw new RuntimeException("TestInheritanceBasic query on employee does not return any row");
        Employee e = (Employee) iter.next();
        if (e.getEmpid() != id)
          throw new RuntimeException("TestInheritanceBasic query on employee returns an other row");
        if (iter.hasNext())
          throw new RuntimeException("TestInheritanceBasic query on a employee returns to many rows");
            outStr.append("\nGet Employee").append(id);
        outStr.append(", full name ").append(e.getFirstname());
        outStr.append(" ").append(e.getLastname());
        } finally  {
            query.closeAll();
        }
  }
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.j2eedo.database.Employee

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.