writeOverWrite method

Future<RemoteDto> writeOverWrite()

Implementation

Future<RemoteDto> writeOverWrite() async {
  if (!initialized) throw ArgumentError(AbstractDao.C_MUST_INIT);
  bool success = false;

  try {
    await tableTransactions.forced_overwrite();
    success = true;
  } on SqlException catch (e) {
    if (e.sqlExceptionEnum == SqlExceptionEnum.DUPLICATE_ENTRY) {
      waterLine.setWaterError(WaterError.DUPLICATE_ENTRY);
      print("$C_CLASSNAME:writeOverWrite(DUPLICATE_ENTRY):$e");
    } else if (e.sqlExceptionEnum == SqlExceptionEnum.PARTITION_NOT_FOUND) {
      waterLine.setWaterError(WaterError.PARTITION_NOT_FOUND);
      print("$C_CLASSNAME:writeOverWrite(PARTITION_NOT_FOUND):$e");
    } else if (e.sqlExceptionEnum == SqlExceptionEnum.FAILED_SELECT) {
      waterLine.setWaterError(WaterError.INVALID_ENTRY);
      print("$C_CLASSNAME:writeOverWrite(INVALID_ENTRY):$e");
    } else {
      waterLine.setWaterError(WaterError.FAILED_UPDATE);
      print("$C_CLASSNAME:writeOverWrite(FAILED_UPDATE):$e");
    }
  }
  if (success) {
    setStates();
    wroteDto = true;
  }
  RemoteDto remoteDto = await commitChanges(null);
  return remoteDto;
}