Fix su delete degli inventari già scaricati ed eliminati lato server
This commit is contained in:
parent
f0db805c84
commit
4dfa796790
File diff suppressed because it is too large
Load Diff
@ -40,7 +40,7 @@ import it.integry.integrywmsnative.core.data_store.db.entity.SqlMtbColt;
|
|||||||
InventarioRoomDTO.class,
|
InventarioRoomDTO.class,
|
||||||
InventarioRowRoomDTO.class
|
InventarioRowRoomDTO.class
|
||||||
},
|
},
|
||||||
version = 16)
|
version = 17)
|
||||||
@TypeConverters({
|
@TypeConverters({
|
||||||
DateConverter.class,
|
DateConverter.class,
|
||||||
BigDecimalConverter.class,
|
BigDecimalConverter.class,
|
||||||
@ -68,7 +68,8 @@ public abstract class AppDatabase extends RoomDatabase {
|
|||||||
.addMigrations(MIGRATION_12_13)
|
.addMigrations(MIGRATION_12_13)
|
||||||
.addMigrations(MIGRATION_13_14)
|
.addMigrations(MIGRATION_13_14)
|
||||||
.addMigrations(MIGRATION_14_15)
|
.addMigrations(MIGRATION_14_15)
|
||||||
.addMigrations(MIGRATION_15_16);
|
.addMigrations(MIGRATION_15_16)
|
||||||
|
.addMigrations(MIGRATION_16_17);
|
||||||
|
|
||||||
sInstance = builder.build();
|
sInstance = builder.build();
|
||||||
}
|
}
|
||||||
@ -161,4 +162,20 @@ public abstract class AppDatabase extends RoomDatabase {
|
|||||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
static final Migration MIGRATION_16_17 = new Migration(16, 17) {
|
||||||
|
@Override
|
||||||
|
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||||
|
database.execSQL("ALTER TABLE inventario_rows RENAME TO _inventario_rows_old;");
|
||||||
|
database.execSQL("DROP INDEX index_inventario_rows__id;");
|
||||||
|
database.execSQL("DROP INDEX index_inventario_rows_parent_id;");
|
||||||
|
|
||||||
|
database.execSQL("CREATE TABLE inventario_rows (_id INTEGER PRIMARY KEY AUTOINCREMENT, parent_id INTEGER, cod_mart TEXT, partita_mag TEXT, descrizione TEXT, qta REAL NOT NULL DEFAULT 0, num_cnf REAL NOT NULL DEFAULT 0, qta_cnf REAL NOT NULL DEFAULT 0, unt_mis TEXT NOT NULL DEFAULT '0', data_ora_inv INTEGER, scan_cod_barre TEXT, zona TEXT, remote_sync_date INTEGER, FOREIGN KEY(parent_id) REFERENCES inventari(_id) ON UPDATE NO ACTION ON DELETE CASCADE);");
|
||||||
|
|
||||||
|
database.execSQL("INSERT INTO inventario_rows SELECT * FROM _inventario_rows_old;");
|
||||||
|
|
||||||
|
database.execSQL("CREATE INDEX index_inventario_rows__id ON inventario_rows (_id);");
|
||||||
|
database.execSQL("CREATE INDEX index_inventario_rows_parent_id ON inventario_rows (parent_id)");
|
||||||
|
database.execSQL("DROP TABLE _inventario_rows_old;");
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,8 @@ import it.integry.integrywmsnative.core.data_store.db.interfaces.EntityModelInte
|
|||||||
@ForeignKey(
|
@ForeignKey(
|
||||||
entity = InventarioRoomDTO.class,
|
entity = InventarioRoomDTO.class,
|
||||||
parentColumns = {BaseSyncDTO.Columns.ID},
|
parentColumns = {BaseSyncDTO.Columns.ID},
|
||||||
childColumns = {InventarioRowRoomDTO.Columns.PARENT_ID}
|
childColumns = {InventarioRowRoomDTO.Columns.PARENT_ID},
|
||||||
|
onDelete = ForeignKey.CASCADE
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@ -58,7 +58,7 @@ public abstract class _BaseRepository<
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
var dataToDelete = finalLocalData.stream()
|
var dataToDelete = finalLocalData.stream()
|
||||||
.filter(x -> x.isSyncronized() && finalRemoteData.stream().noneMatch(y -> keyComparator.run(y, x)))
|
.filter(x -> finalRemoteData.stream().noneMatch(y -> keyComparator.run(y, x)))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
var dataToInsert = finalRemoteData.stream()
|
var dataToInsert = finalRemoteData.stream()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user