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);
  }
Exemple #2
0
  public static void setEntity(Plan ent, Map attributes) {
    Map currentMap =
        (Map) RenderComponentManager.retrieveIDs("Plan", ent.getPrefs(attributes).getView());
    current = ent.getPrefs(attributes).getView();
    if (ent != null
        && currentMap.get("_attributes_") != null
        && currentMap.get("_attributes_") instanceof ingenias.editor.rendererxml.AttributesPanel) {

      ((ingenias.editor.rendererxml.AttributesPanel) currentMap.get("_attributes_")).setEntity(ent);
    }

    if (currentMap.get("Tasks") != null
        && currentMap.get("Tasks") instanceof ingenias.editor.rendererxml.CollectionPanel) {
      try {
        ((ingenias.editor.rendererxml.CollectionPanel) currentMap.get("Tasks"))
            .setCollection("Tasks", ent.Tasks, ent.Tasks.getType());
      } catch (IllegalArgumentException ex) {
        ex.printStackTrace();
      } catch (IllegalAccessException ex) {
        ex.printStackTrace();
      }
    }

    if (currentMap.get("Tasks") != null
        && currentMap.get("Tasks") instanceof ingenias.editor.rendererxml.CollectionPanel) {
      try {
        ((ingenias.editor.rendererxml.CollectionPanel) currentMap.get("Tasks"))
            .setCollection("Tasks", ent.Tasks, ent.Tasks.getType());
      } catch (IllegalArgumentException ex) {
        ex.printStackTrace();
      } catch (IllegalAccessException ex) {
        ex.printStackTrace();
      }
    }

    if (currentMap.get("Tasks") != null) {
      if (ent != null && ent.getTasks() != null) {
        if (currentMap.get("Tasks") instanceof javax.swing.JLabel) {
          ((javax.swing.JLabel) (currentMap).get("Tasks")).setText(ent.getTasks().toString());
        } else {
          if (currentMap.get("Tasks") instanceof javax.swing.text.JTextComponent)
            ((javax.swing.text.JTextComponent) (currentMap).get("Tasks"))
                .setText(ent.getTasks().toString());
        }
      } else {
        if (currentMap.get("Tasks") instanceof javax.swing.JLabel)
          ((javax.swing.JLabel) (currentMap).get("Tasks")).setText("");
        else {
          if (!(currentMap.get("Tasks") instanceof ingenias.editor.rendererxml.CollectionPanel))
            ((javax.swing.text.JTextComponent) (currentMap).get("Tasks")).setText("");
        }
      }
    }

    if (currentMap.get("Id") != null) {
      if (ent != null && ent.getId() != null) {
        if (currentMap.get("Id") instanceof javax.swing.JLabel) {
          ((javax.swing.JLabel) (currentMap).get("Id")).setText(ent.getId().toString());
        } else {
          if (currentMap.get("Id") instanceof javax.swing.text.JTextComponent)
            ((javax.swing.text.JTextComponent) (currentMap).get("Id"))
                .setText(ent.getId().toString());
        }
      } else {
        if (currentMap.get("Id") instanceof javax.swing.JLabel)
          ((javax.swing.JLabel) (currentMap).get("Id")).setText("");
        else {
          if (!(currentMap.get("Id") instanceof ingenias.editor.rendererxml.CollectionPanel))
            ((javax.swing.text.JTextComponent) (currentMap).get("Id")).setText("");
        }
      }
    }
  }