Esempio n. 1
0
  public void run() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
    EmployeeManager employeeManager = context.getBean(EmployeeManagerImpl.class);
    ProjectManager projectManager = context.getBean(ProjectManagerImpl.class);
    UnitManager unitManager = context.getBean(UnitManagerImpl.class);

    Employee employeeOleksii =
        createEmployee("Junior Java Developer", "Oleksii", EmployeeStatus.NIIGER, 27);
    Employee employeeXZ = createEmployee("Middle Java Developer", "XZ", EmployeeStatus.NIIGER, 27);
    Long employeeOleksiiID = employeeManager.save(employeeOleksii);
    Long employeeXZID = employeeManager.save(employeeXZ);
    logger.info("Employee Oleksii saved with ID: " + employeeOleksiiID);
    logger.info("Employee XZ saved with ID: " + employeeXZID);
    //
    Project project = createProject();
    Long projectID = projectManager.save(project);
    logger.info("Project CTrack saved with ID: " + projectID);

    Unit unit = createUnit();
    Long unitID = unitManager.save(unit);
    logger.info("Unit CTrack saved with ID: " + unitID);

    employeeManager.addToUnit(employeeOleksiiID, unitID);
    employeeManager.addToUnit(employeeXZID, unitID);
    logger.info("Employee with ID: " + employeeOleksiiID + " added to Unit with ID: " + unitID);
    logger.info("Employee with ID: " + employeeXZID + " added to Unit with ID: " + unitID);

    employeeManager.assignToProject(employeeOleksiiID, projectID);
    logger.info(
        "Employee with ID: " + employeeOleksiiID + " assigned to Project with ID: " + projectID);

    // close resources
    context.close();
  }