public Componentsources findExistOrCreateNewComponentSources(String code) { Componentsources result = null; if (StringUtils.isNotBlank(code)) { result = checkExistComponentSource(code); if (null == result) { result = new Componentsources(0, Auth.getCurrentUser(), code, Auth.getCurrentDate()); save(result); } } return result; }
public Chemicals findExistOrCreateNewChemical(String code) { Chemicals result = null; if (StringUtils.isNotBlank(code)) { List<Chemicals> sourcesList = findAll(Chemicals.class); for (Chemicals chemical : sourcesList) { if (code.equals(chemical.getCode())) { return chemical; } } result = new Chemicals(0, Auth.getCurrentUser(), code, Auth.getCurrentDate()); save(result); } return result; }