feature/remove-office-data-import #155
@ -4,7 +4,6 @@ import com.opencsv.CSVParserBuilder;
|
||||
import com.opencsv.CSVReader;
|
||||
import com.opencsv.CSVReaderBuilder;
|
||||
import lombok.SneakyThrows;
|
||||
import net.hostsharing.hsadminng.hs.booking.project.HsBookingProject;
|
||||
import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAsset;
|
||||
import net.hostsharing.hsadminng.rbac.context.ContextBasedTest;
|
||||
import net.hostsharing.hsadminng.persistence.BaseEntity;
|
||||
@ -158,10 +157,6 @@ public class CsvDataImport extends ContextBasedTest {
|
||||
|
||||
public <T extends BaseEntity> T persist(final Integer id, final T entity) {
|
||||
try {
|
||||
// if (entity instanceof HsBookingProject bp) { // FIXME: for bookingproject + bookingitem? or not at all?
|
||||
// //noinspection unchecked
|
||||
// return (T) persistViaSql(id, bp);
|
||||
// }
|
||||
if (entity instanceof HsHostingAsset ha) {
|
||||
//noinspection unchecked
|
||||
return (T) persistViaSql(id, ha);
|
||||
@ -189,36 +184,6 @@ public class CsvDataImport extends ContextBasedTest {
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public BaseEntity<HsBookingProject> persistViaSql(final Integer id, final HsBookingProject entity) {
|
||||
if (entity.getUuid() == null) {
|
||||
entity.setUuid(UUID.randomUUID());
|
||||
}
|
||||
|
||||
final var query = em.createNativeQuery("""
|
||||
insert into hs_booking.project(
|
||||
uuid,
|
||||
version,
|
||||
debitorUuid,
|
||||
caption)
|
||||
values (
|
||||
:uuid,
|
||||
:version,
|
||||
:debitorUuid,
|
||||
:caption)
|
||||
""")
|
||||
.setParameter("uuid", entity.getUuid())
|
||||
.setParameter("version", entity.getVersion())
|
||||
.setParameter("debitorUuid", entity.getDebitor().getUuid())
|
||||
.setParameter("caption", entity.getCaption());
|
||||
|
||||
final var count = query.executeUpdate();
|
||||
logError(() -> {
|
||||
assertThat(count).isEqualTo(1);
|
||||
});
|
||||
return entity;
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public BaseEntity<HsHostingAsset> persistViaSql(final Integer id, final HsHostingAsset entity) {
|
||||
if (entity.getUuid() == null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user