Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.IPreference


    int value1 = 10;
    int value2 = 15;
    int value3 = 20;

    IPreference pref = fFactory.createPreference(key1);
    pref.putIntegers(value1);
    fDao.save(pref);

    pref = fFactory.createPreference(key2);
    pref.putIntegers(value2);
    fDao.save(pref);

    pref = fFactory.createPreference(key3);
    pref.putIntegers(value3);
    fDao.save(pref);

    assertEquals(Integer.valueOf(value1), fDao.load(key1).getInteger());
    assertEquals(Integer.valueOf(value2), fDao.load(key2).getInteger());
    assertEquals(Integer.valueOf(value3), fDao.load(key3).getInteger());

    value3 = 5;
    pref.putIntegers(value3);
    fDao.save(pref);

    assertEquals(Integer.valueOf(value1), fDao.load(key1).getInteger());
    assertEquals(Integer.valueOf(value2), fDao.load(key2).getInteger());
    assertEquals(Integer.valueOf(value3), fDao.load(key3).getInteger());
View Full Code Here


    boolean value1 = true;
    String value2 = "value2";
    int value3 = 34;
    String[] value4 = new String[] { "value4.1", "value4.2", "value4.3" };

    IPreference pref = fFactory.createPreference(key1);
    pref.putBooleans(value1);
    fDao.save(pref);

    pref = fFactory.createPreference(key2);
    pref.putStrings(value2);
    fDao.save(pref);

    pref = fFactory.createPreference(key3);
    pref.putIntegers(value3);
    fDao.save(pref);

    pref = fFactory.createPreference(key4);
    pref.putStrings(value4);
    fDao.save(pref);

    assertEquals(Boolean.valueOf(value1), fDao.load(key1).getBoolean());
    assertEquals(value2, fDao.load(key2).getString());
    assertEquals(Integer.valueOf(value3), fDao.load(key3).getInteger());
View Full Code Here

        }
      };
      fDao.addEntityListener(prefListener);

      /* Add some Preferences */
      IPreference pref = fFactory.createPreference(key1);
      pref.putBooleans(value1);
      fDao.save(pref);

      pref = fFactory.createPreference(key2);
      pref.putIntegers(value2);
      fDao.save(pref);

      pref = fFactory.createPreference(key3);
      pref.putStrings(value3);
      fDao.save(pref);

      pref = fFactory.createPreference(key4);
      pref.putStrings(value4);
      fDao.save(pref);

      /* Update some Preferences */
      pref = fDao.loadOrCreate(key1);
      pref.putBooleans(false);
      fDao.save(pref);

      pref = fDao.loadOrCreate(key2);
      pref.putIntegers(0);
      fDao.save(pref);

      pref = fDao.loadOrCreate(key3);
      pref.putStrings("updated_value");
      fDao.save(pref);

      pref = fDao.loadOrCreate(key4);
      pref.putStrings("4", "3", "2", "1");
      fDao.save(pref);

      /* Delete some Preferences */
      fDao.delete(key1);
      fDao.delete(key2);
View Full Code Here

   *
   * @throws Exception
   */
  @Test
  public void testSaveSingleEntryStringArray() throws Exception {
    IPreference pref = fFactory.createPreference("Foo");
    pref.putStrings("Bar");
    fDao.save(pref);
    fDao.load(pref.getKey()).getStrings();
  }
View Full Code Here

   *
   * @throws Exception
   */
  @Test
  public void testSaveStringsDuplicate() throws Exception {
    IPreference pref = fFactory.createPreference("Foo");
    pref.putStrings("1", "2", "3", "1", "2", "3");
    fDao.save(pref);
    pref = fDao.loadOrCreate("Foo");
    pref.putStrings("1", "2", "3", "1", "2", "3");
    fDao.save(pref);
  }
View Full Code Here

   *
   * @throws Exception
   */
  @Test
  public void testSaveArrayWithDuplicateStrings() throws Exception {
    IPreference pref = fFactory.createPreference("Foo");
    pref.putStrings("1", "2", "3", "1", "2", "3");
    fDao.save(pref);
  }
View Full Code Here

   * @throws Exception
   */
  @Test
  public void testUpdateArray() throws Exception {
    String key = "Foo";
    IPreference pref = fFactory.createPreference(key);
    pref.putStrings("1", "2", "3", "1", "2", "3");
    fDao.save(pref);
    String[] updatedStrings = new String[] { "1", "3", "2" };
    pref.putStrings(updatedStrings);
    fDao.save(pref);
    String[] savedStrings = fDao.load(key).getStrings();
    assertArrayEquals(updatedStrings, savedStrings);
  }
View Full Code Here

      query.descend("fId").constrain(Long.valueOf(preference.getId())); //$NON-NLS-1$

      List<IPreference> result = query.execute();
      assertEquals(1, result.size());

      IPreference otherPreference = result.get(0);

      assertEquals(preference.getKey(), otherPreference.getKey());
      if ("string".equals(preference.getKey()))
        assertEquals(preference.getString(), otherPreference.getString());

      if ("strings".equals(preference.getKey()))
        assertTrue(Arrays.equals(preference.getStrings(), otherPreference.getStrings()));

      if ("boolean".equals(preference.getKey()))
        assertEquals(preference.getBoolean(), otherPreference.getBoolean());

      if ("booleans".equals(preference.getKey()))
        assertTrue(Arrays.equals(preference.getBooleans(), otherPreference.getBooleans()));

      if ("integer".equals(preference.getKey()))
        assertEquals(preference.getInteger(), otherPreference.getInteger());

      if ("integers".equals(preference.getKey()))
        assertTrue(Arrays.equals(preference.getIntegers(), otherPreference.getIntegers()));

      if ("long".equals(preference.getKey()))
        assertEquals(preference.getLong(), otherPreference.getLong());

      if ("longs".equals(preference.getKey()))
        assertTrue(Arrays.equals(preference.getLongs(), otherPreference.getLongs()));
    }

    /* Assert Label */
    List<ILabel> labels = db.query(ILabel.class);
    assertEquals(labels.size(), defragmentedDb.query(ILabel.class).size());
View Full Code Here

    super(Preference.class, true);
  }

  @Override
  protected void doSave(IPreference entity) {
    IPreference pref = load(entity.getKey());
    if (pref != null && pref != entity)
      throw new UniqueConstraintException("key", entity); //$NON-NLS-1$

    super.doSave(entity);
  }
View Full Code Here

    super.doSave(entity);
  }

  public boolean delete(String key) throws PersistenceException {
    IPreference pref = load(key);
    if (pref == null)
      return false;

    delete(pref);
    return true;
View Full Code Here

TOP

Related Classes of org.rssowl.core.persist.IPreference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.