1
0
mirror of https://github.com/pcvolkmer/onkostar-plugin-dnpm.git synced 2025-07-04 18:12:55 +00:00

refactor: use package name following Java guidelines

This commit is contained in:
2024-09-21 22:10:24 +02:00
parent 93215825f5
commit cc27edc544
93 changed files with 199 additions and 200 deletions

View File

@ -0,0 +1,37 @@
package dev.dnpm.services;
import dev.dnpm.exceptions.FormException;
import org.springframework.jdbc.core.JdbcTemplate;
import javax.sql.DataSource;
import java.util.List;
/**
* Standardimplementierung zum Ermitteln von Unter- und Hauptformularen
*
* @since 0.0.2
*/
public class DefaultFormService implements FormService {
private final JdbcTemplate jdbcTemplate;
public DefaultFormService(final DataSource dataSource) {
this.jdbcTemplate = new JdbcTemplate(dataSource);
}
@Override
public int getMainFormProcedureId(int procedureId) throws FormException {
var sql = "SELECT hauptprozedur_id FROM prozedur WHERE id = ?";
try {
return jdbcTemplate.queryForObject(sql, (resultSet, i) -> resultSet.getInt("hauptprozedur_id"), procedureId);
} catch (Exception e) {
throw new FormException(String.format("No main form found for subform with ID '%d'", procedureId));
}
}
@Override
public List<Integer> getSubFormProcedureIds(int procedureId) {
var sql = "SELECT id FROM prozedur WHERE hauptprozedur_id = ?";
return jdbcTemplate.queryForList(sql, Integer.class, procedureId);
}
}