@Override public Malfunction getMalfunctionById(Integer malfunctionId) { LOGGER.info("DAO:Get malfunction by id=" + malfunctionId.toString()); HashMap<String, Object> hashMap = new HashMap<String, Object>(); hashMap.put(MALFUNCTION_ID.getValue(), malfunctionId); return namedParameterJdbcTemplate.queryForObject(getMalfunction, hashMap, malfunctionMapper); }
@Override public void deleteMalfunction(Integer malfunctionId) { LOGGER.info("DAO:Delete malfunction by id=" + malfunctionId.toString()); HashMap<String, Object> hashMap = new HashMap<String, Object>(); hashMap.put(MALFUNCTION_ID.getValue(), malfunctionId); namedParameterJdbcTemplate.update(deleteMalfunctionById, hashMap); }
private MapSqlParameterSource getParametersMap(Malfunction malfunction) { MapSqlParameterSource parameterSource = new MapSqlParameterSource(); parameterSource.addValue(MALFUNCTION_ID.getValue(), malfunction.getMalfunctionId()); parameterSource.addValue(NAME.getValue(), malfunction.getName()); parameterSource.addValue(AUTO.getValue(), malfunction.getAuto()); parameterSource.addValue(DESCRIPTION.getValue(), malfunction.getDescription()); parameterSource.addValue(APPLICATION_ID.getValue(), malfunction.getApplicationId()); return parameterSource; }
@Override public void updateMalfunction(Malfunction malfunction) { LOGGER.info("DAO:Update malfunction by id=" + malfunction.getMalfunctionId().toString()); HashMap<String, Object> hashMap = new HashMap<String, Object>(); hashMap.put(MALFUNCTION_ID.getValue(), malfunction.getMalfunctionId()); hashMap.put(NAME.getValue(), malfunction.getName()); hashMap.put(AUTO.getValue(), malfunction.getAuto()); hashMap.put(DESCRIPTION.getValue(), malfunction.getDescription()); namedParameterJdbcTemplate.update(updateMalfunctionById, hashMap); }
@Override public void addCostsToMalfunction( Integer malfunctionId, Integer costRepair, Integer costService, Integer additionalExpenses) { LOGGER.info("DAO:Add all costs for malfunction with id=" + malfunctionId.toString()); HashMap<String, Object> hashMap = new HashMap<String, Object>(); hashMap.put(MALFUNCTION_ID.getValue(), malfunctionId); hashMap.put(COST_REPAIR.getValue(), costRepair); hashMap.put(COST_SERVICE.getValue(), costService); hashMap.put(ADDITIONAL_EXPENSES.getValue(), additionalExpenses); namedParameterJdbcTemplate.update(addCosts, hashMap); }