コード例 #1
0
  public void departTest() {
    Department department1 = depDAO.getDepartment(1);
    Department department2 = depDAO.getDepartment(2);
    Department department3 = depDAO.getDepartment(3);
    Worker worker1 = new Worker("jaku", 18);
    worker1.setWorkerPassword("111111");
    worker1.setDepartment(department1);
    worker1.setWorkerLevel(1);

    Worker worker2 = new Worker("balen", 28);
    worker2.setWorkerPassword("111111");
    worker2.setDepartment(department2);
    worker2.setWorkerLevel(2);

    Worker worker3 = new Worker("admin", 38);
    worker3.setWorkerPassword("111111");
    worker3.setDepartment(department3);
    worker3.setWorkerLevel(3);

    department1.addWorker(worker1);
    department2.addWorker(worker2);
    department3.addWorker(worker3);
    depDAO.saveDepart(department1);
    depDAO.saveDepart(department2);
    depDAO.saveDepart(department3);
  }
コード例 #2
0
  public void planTest() {
    Worker worker = workerDAO.getWorkerById(6);
    Department department = depDAO.getDepartment(2);
    Date date = new Date();
    new Timestamp(date.getTime());

    // plan creating
    Plan plan = new Plan();
    plan.setWorker(worker); // worker
    plan.setDepartment(department); // department
    // set several timestamp attributes
    plan.setCreateTime(new Timestamp(date.getTime()));
    plan.setBeginTime(new Timestamp(date.getTime()));
    plan.setEndTime(new Timestamp(date.getTime()));
    // planCommodityRel creating
    PlanCommodityRel relation1 = new PlanCommodityRel();
    Commodity commodity1 = commoDAO.getCommodityById(1);
    relation1.setCommodity(commodity1);
    relation1.setPlan(plan);
    relation1.setPlanNum(50);
    relation1.setSinglePrice(8);

    PlanCommodityRel relation2 = new PlanCommodityRel();
    Commodity commodity2 = commoDAO.getCommodityById(2);
    relation2.setCommodity(commodity2);
    relation2.setPlan(plan);
    relation2.setPlanNum(50);
    relation2.setSinglePrice(8);

    PlanCommodityRel relation3 = new PlanCommodityRel();
    Commodity commodity3 = commoDAO.getCommodityById(3);
    relation3.setCommodity(commodity3);
    relation3.setPlan(plan);
    relation3.setPlanNum(50);
    relation3.setSinglePrice(8);

    plan.getPlanCommodityRelList().add(relation1);
    plan.getPlanCommodityRelList().add(relation2);
    plan.getPlanCommodityRelList().add(relation3);

    planDAO.createPlan(plan);
  }