mirror of
https://github.com/pcvolkmer/onkostar-plugin-dnpm.git
synced 2025-07-03 09:42:54 +00:00
Issue #7: Übernahme von MTB und MTB-Datum aus Hauptformular
This commit is contained in:
34
src/main/java/DNPM/services/DefaultFormService.java
Normal file
34
src/main/java/DNPM/services/DefaultFormService.java
Normal file
@ -0,0 +1,34 @@
|
||||
package DNPM.services;
|
||||
|
||||
import DNPM.exceptions.FormException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
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);
|
||||
}
|
||||
}
|
29
src/main/java/DNPM/services/FormService.java
Normal file
29
src/main/java/DNPM/services/FormService.java
Normal file
@ -0,0 +1,29 @@
|
||||
package DNPM.services;
|
||||
|
||||
import DNPM.exceptions.FormException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface FormService {
|
||||
|
||||
/**
|
||||
* Diese Methode übergibt die Prozedur-ID des zugehörigen Hauptformulars zu einem Unterformular
|
||||
* Siehe auch: <a href="https://github.com/CCC-MF/onkostar-plugin-forminfo/blob/master/src/main/java/de/ukw/ccc/onkostar/forminfo/services/FormInfoService.java">FormInfoService.java</a>
|
||||
*
|
||||
* @param procedureId Die Prozedur-ID des Unterformulars
|
||||
* @return Die Prozedur-ID des zugehörigen Hauptformulars
|
||||
* @throws FormException
|
||||
*/
|
||||
int getMainFormProcedureId(int procedureId) throws FormException;
|
||||
|
||||
/**
|
||||
* Diese Methode übergibt die Prozedur-IDs von Unterformularen zu einem Formular
|
||||
* Siehe auch: <a href="https://github.com/CCC-MF/onkostar-plugin-forminfo/blob/master/src/main/java/de/ukw/ccc/onkostar/forminfo/services/FormInfoService.java">FormInfoService.java</a>
|
||||
*
|
||||
* @param procedureId Die Prozedur-ID des Formulars
|
||||
* @return Eine Liste mit Prozedur-IDs der Unterformulare
|
||||
* @throws FormException
|
||||
*/
|
||||
List<Integer> getSubFormProcedureIds(int procedureId);
|
||||
|
||||
}
|
Reference in New Issue
Block a user