@ -7,16 +7,16 @@ import static de.srsoftware.tools.jdbc.Condition.isNull;
@@ -7,16 +7,16 @@ import static de.srsoftware.tools.jdbc.Condition.isNull;
import static de.srsoftware.tools.jdbc.Query.* ;
import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL ;
import static de.srsoftware.umbrella.core.Constants.* ;
import static de.srsoftware.umbrella.core.ModuleRegistry.noteService ;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.databaseException ;
import static de.srsoftware.umbrella.stock.Constants.* ;
import static java.lang.System.Logger.Level.ERROR ;
import static java.lang.System.Logger.Level.WARNING ;
import static java.text.MessageFormat.format ;
import de.srsoftware.tools.Mappable ;
import de.srsoftware.umbrella.core.BaseDb ;
import de.srsoftware.umbrella.core.model.Location ;
import de.srsoftware.umbrella.core.model.* ;
import de.srsoftware.umbrella.core.model.Location ;
import java.sql.Connection ;
import java.sql.ResultSet ;
import java.sql.SQLException ;
@ -403,6 +403,7 @@ public class SqliteDb extends BaseDb implements StockDb {
@@ -403,6 +403,7 @@ public class SqliteDb extends BaseDb implements StockDb {
createIntermediatePropsTable ( ) ;
var oldLocationIdsToNew = transformLocations ( ) ;
var oldItemIdsToNew = transformItems ( oldLocationIdsToNew ) ;
updateNotes ( oldItemIdsToNew ) ;
transformProperties ( oldItemIdsToNew ) ;
replaceLocationsTable ( ) ;
replaceItemsTable ( ) ;
@ -417,4 +418,19 @@ public class SqliteDb extends BaseDb implements StockDb {
@@ -417,4 +418,19 @@ public class SqliteDb extends BaseDb implements StockDb {
throw databaseException ( "Failed to transform {0} table!" , TABLE_LOCATIONS ) ;
}
}
private void updateNotes ( HashMap < String , Long > oldItemIdsToNew ) {
var noteService = noteService ( ) ;
Map < Long , Note > notes = noteService . getNotes ( "stock" , null ) ;
for ( var entry : notes . entrySet ( ) ) {
var note = entry . getValue ( ) ;
var oldEntityId = note . entityId ( ) ;
var newEntityId = oldItemIdsToNew . get ( oldEntityId ) ;
if ( newEntityId ! = null ) {
noteService . save ( note . entityId ( "" + newEntityId ) ) ;
}
}
}
}