public void updateCompany(CompanyDTO dto) throws Exception {
   Company company = getCompany(dto.id);
   validate(dto);
   List<String> beneficiaryIds =
       company
           .getBeneficiaries()
           .stream()
           .map(beneficiary -> beneficiary.getId().toString())
           .collect(Collectors.toList());
   for (BeneficiaryDTO beneDTO : dto.beneficiaries) {
     Beneficiary bene = new Beneficiary(beneDTO.name, company);
     Integer id = beneDTO.id;
     if (id != null) {
       bene.setId(id);
       String idString = id.toString();
       if (!beneDao.idExists(idString)) {
         throw new RequestException("beneficiary with id %s does not exist", id);
       }
       beneDao.update(bene);
       beneficiaryIds.remove(idString);
     } else {
       beneDao.create(bene);
     }
   }
   if (beneficiaryIds.size() > 0) {
     beneDao.deleteIds(beneficiaryIds);
   }
   company = JsonUtil.fromJson(dto.toJson(), Company.class);
   dao.update(company);
 }
Esempio n. 2
0
 public void update(Notebook notebook) {
   try {
     notebookDaoOpe.update(notebook);
   } catch (SQLException e) {
     e.printStackTrace();
   }
 }
Esempio n. 3
0
 public void update(Lecture lecture) {
   try {
     Dao<Lecture, Integer> dao = getDao();
     dao.update(lecture);
   } catch (SQLException e) {
     throw new RuntimeException(e);
   }
 }
Esempio n. 4
0
  public void update(Remind item) {
    try {
      remindDao.update(item);

      Log.i(TAG, String.format("%s: %d", "update at base, id", item.getId()));
    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
Esempio n. 5
0
 /**
  * 更新专辑信息
  *
  * @param pDiggerAlbum 要修改的专辑对象
  */
 public void update(DiggerAlbum pDiggerAlbum) {
   if (pDiggerAlbum != null) {
     DiggerAlbum existAlbum = queryById(pDiggerAlbum.getAlbum_id());
     if (existAlbum != null) {
       try {
         mDiggerAlbumDao.update(pDiggerAlbum);
       } catch (SQLException e) {
         e.printStackTrace();
         Logger.e(
             TAG, "update " + DiggerAlbum.class.getSimpleName() + " failure >>>" + e.getMessage());
       }
     }
   }
 }
 private KnouNoticeInfo setChangeKnouNoticeInfo(KnouNoticeInfo knouNoticeInfo) {
   try {
     Dao<KnouNoticeInfo, Long> knouNoticeInfoDao = this.getHelper().getKnouNoticeInfoDao();
     if (knouNoticeInfo == null) {
       throw new Exception("null 이 나오면 안된다구요 ");
     }
     int result = knouNoticeInfoDao.update(knouNoticeInfo);
     System.out.println("setChangeKnouNoticeInfo:" + result);
     knouNoticeInfo = knouNoticeInfoDao.queryForId(knouNoticeInfo._ID);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return knouNoticeInfo;
 }
  public void endElement(String uri, String localName, String qName) throws SAXException {
    super.endElement(uri, localName, qName);

    if (qName.equals("available")) {
      available = Integer.parseInt(current.toString());
      infoStation.setAvailable(available);
    } else if (qName.equals("free")) {
      free = Integer.parseInt(current.toString());
      infoStation.setFree(free);
    } else if (qName.equals("total")) {
      total = Integer.parseInt(current.toString());
      infoStation.setTotal(total);
    } else if (qName.equals("ticket")) {
      if (Integer.parseInt(current.toString()) == 1) ticket = true;
      else ticket = false;
      infoStation.setTicket(ticket);
    } else if (qName.equals("open")) {
      if (Integer.parseInt(current.toString()) == 1) open = true;
      else open = false;
      infoStation.setOpen(open);

      infoStation.setStationVelibId(station.getId());
    } else if (qName.equals("updated")) {

      int updated = Integer.parseInt(current.toString());
      infoStation.setUpdated(updated);

      infoStation.setStationVelibId(station.getId());
      try {

        infoStationDao = DatabaseHelper.getInstance(context).getDao(InfoStation.class);
        QueryBuilder<InfoStation, ?> queryBuilder = infoStationDao.queryBuilder();
        queryBuilder.where().eq(InfoStation.COLUMN_INFO_ID_STATION, station.getId());
        PreparedQuery<InfoStation> preparedQuery = queryBuilder.prepare();
        List<InfoStation> infoList = infoStationDao.query(preparedQuery);

        if (infoList.size() == 0) infoStationDao.create(infoStation);
        else if (infoStation.getUpdated() != updated) infoStationDao.update(infoStation);
      } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    /*
     * if(qName.equals("ticket")){ ticket = current.toString() != null;
     * }
     */

  }
 @Override
 public StatusBean update(JsonNode updateddata) {
   ProjectBean projectBean = null;
   Gson projectData = new GsonBuilder().setDateFormat("yyyy'-'MM'-'dd HH':'mm':'ss").create();
   projectBean = projectData.fromJson(updateddata.toString(), ProjectBean.class);
   StatusBean statusBean = new StatusBean();
   try {
     projectDao.update(projectBean);
   } catch (SQLException e) {
     logger.error("Error updating a  project : " + e.getMessage());
     statusBean.setStatusCode(1);
     statusBean.setStatusMessage("Error updating a project : " + e.getMessage());
     e.printStackTrace();
   }
   statusBean.setStatusCode(0);
   statusBean.setStatusMessage("Project updated successfully");
   return statusBean;
 }
Esempio n. 9
0
 protected void removeOldAppointments(RecurringAction recurringAction) {
   Collection<Event> events = recurringAction.getEvents();
   for (Event event : events) {
     eventRepository.deleteEvent(event.getUri());
     recurringAction.removeEvent(event);
     event.setRecurringAction(null);
     try {
       eventDao.delete(event);
     } catch (SQLException e) {
       e.printStackTrace();
     }
   }
   try {
     recurringActionDao.update(recurringAction);
   } catch (SQLException e) {
     e.printStackTrace();
   }
 }
  @Override
  public void create(Movement movement, Account account) throws Exception {

    OrmLiteAccount ormLiteAccount = accountDao.queryForId(account.getNumber());

    if (account.canProcessMovement(movement)) {
      if (movement.getType() == MOVEMENT_TYPE.CREDIT) {
        ormLiteAccount.setValue(ormLiteAccount.getValue() + movement.getValue());
      } else {
        ormLiteAccount.setValue(ormLiteAccount.getValue() - movement.getValue());
      }
      accountDao.update(ormLiteAccount);

      OrmLiteMovement ormLiteMovement = new OrmLiteMovement();
      ormLiteMovement.setDate(new Date());
      ormLiteMovement.setValue(movement.getValue());
      ormLiteMovement.setType(movement.getType().toString());
      ormLiteMovement.setAccount(ormLiteAccount);
      movementDao.create(ormLiteMovement);
    }
  }
Esempio n. 11
0
  public StatusBean delete(JsonNode projectData) {
    StatusBean statusBean = new StatusBean();
    Integer userID = Integer.parseInt(projectData.get("userID").getTextValue());
    Integer projectID = Integer.parseInt(projectData.get("projectID").getTextValue());
    String location = Utilities.getInstance().fetchActiveProjectDirectory(userID);

    try {
      ProjectBean project = projectDao.queryForId(projectID);
      project.setIsDisabled(true);
      projectDao.update(project);
      List<MachineConfigurationBean> machineConfigList =
          MachineConfigDAOManager.getInstance().retireveBoxesForProject(projectID.toString());

      for (MachineConfigurationBean machineConfig : machineConfigList) {
        MachineConfigDAOManager.getInstance().delete(machineConfig.getMachineID().toString());
        String vagrantCommand = "vagrant destroy " + machineConfig.getVagrantID();
        VagrantCommandProcessor shellProcessor = new VagrantCommandProcessor();
        try {
          shellProcessor.executeVagrantFile(
              location, vagrantCommand, userID, new VagrantOutputStream());
        } catch (IOException e) {
          statusBean.setStatusCode(1);
          statusBean.setStatusMessage("error in destroting box" + e.getMessage());
        } catch (InterruptedException e) {
          statusBean.setStatusCode(1);
          statusBean.setStatusMessage("error in destroting box" + e.getMessage());
        }
      }

    } catch (SQLException e) {
      logger.error("Error deleting a project : " + e.getMessage());
      statusBean.setStatusCode(1);
      statusBean.setStatusMessage("Error deleting  a project : " + e.getMessage());
      e.printStackTrace();
    }
    statusBean.setStatusCode(0);
    statusBean.setStatusMessage("Project deleted successfully");
    return statusBean;
  }
Esempio n. 12
0
 public int update(RedmineRole item) throws SQLException {
   int count = dao.update(item);
   return count;
 }
 public int update(RedmineAttachment item) throws SQLException {
   int count = dao.update(item);
   return count;
 }