Пример #1
0
 @Nullable
 private static CountryScheme findExisting(
     @NonNull DatabaseCompartment request, @NonNull String serverId) {
   return request
       .query(CountryScheme.class)
       .withSelection(Strings.createSelectionWithAndEqual(CountryScheme.FIELD_SERVER_ID), serverId)
       .get();
 }
Пример #2
0
  public static void updateCountry(
      @NonNull Long id, @NonNull Country country, @NonNull DatabaseCompartment request) {

    ContentValues values = new ContentValues();
    values.put(CountryScheme.FIELD_SERVER_ID, country.serverId);
    values.put(CountryScheme.FIELD_NAME, country.name);
    values.put(CountryScheme.FIELD_IMAGE_LINK, country.imageLink);

    request.update(
        CountryScheme.class,
        values,
        Strings.createSelectionWithAndEqual(CountryScheme.FIELD_ID),
        String.valueOf(id));

    City.deleteByCountryServerId(request, country.serverId);
    City.saveAll(request, country.cities);
  }
Пример #3
0
 public static int deleteByCountryServerId(DatabaseCompartment request, Long countryServerId) {
   return request.delete(
       CityScheme.class,
       Strings.createSelectionWithAndEqual(CityScheme.FIELD_SERVER_COUNTRY_ID),
       String.valueOf(countryServerId));
 }