コード例 #1
0
  /**
   * Creates a Department instance
   *
   * @param employees number of employees which are not freelances in the department
   * @param freelances the number of freelances in the department
   * @param maxJuniors the value for the maxJunior attribute
   * @param budget the value for the budget attribute
   */
  private DepartmentImpl createDepartment(
      int employees, int freelances, int maxNumJuniors, int budget) {

    DepartmentImpl dep = (DepartmentImpl) CompanyFactory.eINSTANCE.createDepartment();
    dep.setName("Dep" + this.curDepartmentID);
    dep.setMaxJuniors(maxNumJuniors);
    dep.setBudget(budget);
    this.curDepartmentID++;
    EmployeeImpl e = null;
    FreelanceImpl f = null;
    for (int i = 0; i < employees; i++) {
      e = createEmployee();
      dep.getEmployee().add(e);
      e.setEmployer(dep);
    }
    for (int i = 0; i < freelances; i++) {
      f = createFreelance();
      dep.getEmployee().add(f);
      f.setEmployer(dep);
    }
    this.allDepartments.add(dep);
    if (this.comp.eResource() != null) {
      this.comp.eResource().getContents().add(dep);
    }
    return dep;
  }
コード例 #2
0
  /** @return an instance of {@link Employee} */
  private EmployeeImpl createEmployee() {

    EmployeeImpl e = (EmployeeImpl) CompanyFactory.eINSTANCE.createEmployee();
    e.setName("empl" + this.curImployeeID);
    e.setAge(42);
    e.setSalary(2345);
    this.curImployeeID++;
    this.allEmployees.add(e);
    if (this.comp.eResource() != null) {
      this.comp.eResource().getContents().add(e);
    }
    return e;
  }