Esempio n. 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;
  }
Esempio n. 2
0
  @SuppressWarnings("unchecked")
  @RequestMapping(
      value = "/component/remove/{componentId}",
      method = {RequestMethod.GET, RequestMethod.POST})
  @ResponseBody
  public Object delComponentEntity(@PathVariable Long componentId) {
    AreaComponentEntity componentEntity =
        (AreaComponentEntity) baseService.getObject(AreaComponentEntity.class, componentId);
    componentEntity.getDoorTemplateEntity().getAreaComponentEntities().remove(componentEntity);
    componentEntity.setDoorTemplateEntity(null);
    baseService.deleteEntity(componentEntity);

    List<AreaComponentEntity> result = new ArrayList<AreaComponentEntity>();
    findComponentTree(result, componentId);
    for (AreaComponentEntity _entity : result) {
      _entity.getDoorTemplateEntity().getAreaComponentEntities().remove(_entity);
      _entity.setDoorTemplateEntity(null);
      baseService.deleteEntity(_entity);
    }

    return componentEntity;
  }