Exemplo n.º 1
0
  @SuppressWarnings("unchecked")
  @RequestMapping(
      value = "/component/save",
      method = {RequestMethod.GET, RequestMethod.POST})
  @ResponseBody
  public Object saveComponent(@RequestBody PieceworkComponentEntity componentEntity) {

    if (componentEntity.getId() == null) {
      DoorTemplateEntity doorTemplateEntity =
          (DoorTemplateEntity)
              baseService.getObject(
                  DoorTemplateEntity.class, componentEntity.getDoor_template_id());
      componentEntity.setDoorTemplateEntity(doorTemplateEntity);
      doorTemplateEntity.getPieceworkComponentEntities().add(componentEntity);
      baseService.saveEntity(componentEntity);

    } else {
      PieceworkComponentEntity entity =
          (PieceworkComponentEntity)
              baseService.getObject(PieceworkComponentEntity.class, componentEntity.getId());
      entity.setName(componentEntity.getName());
      entity.setFnumber(componentEntity.getFnumber());
      baseService.updateEntity(entity);
    }

    return componentEntity;
  }
Exemplo n.º 2
0
  @SuppressWarnings("unchecked")
  @RequestMapping(
      value = "/components/tree/{templateId}",
      method = {RequestMethod.GET, RequestMethod.POST})
  @ResponseBody
  public Object getComponentsTree(@PathVariable Long templateId) {
    DoorTemplateEntity doorTemplateEntity =
        (DoorTemplateEntity) baseService.getObject(DoorTemplateEntity.class, templateId);
    List<AreaComponentEntity> componentEntities = doorTemplateEntity.getAreaComponentEntities();

    List<TreeNode> roots = getCompoentTree(componentEntities, null);

    return roots;
  }