Mercurial > lada > lada-server
view src/main/java/de/intevation/lada/validation/LMesswertValidator.java @ 409:183f8116d9a6
Added license header to source files.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Mon, 20 Jan 2014 12:27:00 +0100 |
parents | 2098db2e8fbd |
children |
line wrap: on
line source
/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz * Software engineering by Intevation GmbH * * This file is Free Software under the GNU GPL (v>=3) * and comes with ABSOLUTELY NO WARRANTY! Check out * the documentation coming with IMIS-Labordaten-Application for details. */ package de.intevation.lada.validation; import java.util.HashMap; import java.util.Map; import javax.enterprise.context.ApplicationScoped; import javax.inject.Named; import de.intevation.lada.model.LMesswert; @Named("lmesswertvalidator") @ApplicationScoped public class LMesswertValidator implements Validator { /** * Validate a LMesswert object. * * @param object The LMesswert object. * @param update The database operation. * TRUE indicates that the object should be updated, FALSE * if the object is a new Object. * @return Map containing warnings. */ @Override public Map<String, Integer> validate(Object object, boolean update) throws ValidationException { Map<String, Integer> warnings = new HashMap<String, Integer>(); if (!(object instanceof LMesswert)) { Map<String, Integer> errors = new HashMap<String, Integer>(); errors.put("lmesswert", 610); throw new ValidationException(errors); } LMesswert messwert = (LMesswert)object; validateMessunsicherheit(messwert, warnings); return null; } /** * Check if the LMesswert has a 'Messunsicherheit' or if the the value * is lower than the 'Nachweisgrenze'. * * @param messwert The LMesswert object. * @param warnings The map containing warnings. * @throws ValidationException */ private void validateMessunsicherheit( LMesswert messwert, Map<String, Integer> warnings) throws ValidationException { Float unsicherheit = messwert.getMessfehler(); Float nachweisgrenze = messwert.getNwgZuMesswert(); Float wert = messwert.getMesswert(); if (unsicherheit != null && unsicherheit > 0f) { return; } else if (nachweisgrenze != null && wert < nachweisgrenze) { return; } else { warnings.put("messwert", 631); } } }