예제 #1
0
  @SuppressWarnings("unchecked")
  @RequestMapping(
      value = "/component/save",
      method = {RequestMethod.GET, RequestMethod.POST})
  @ResponseBody
  public Object saveComponent(@RequestBody AreaComponentEntity componentEntity) {

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

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

    return componentEntity;
  }
예제 #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;
  }