Beispiel #1
0
 /**
  * Updates or insert a new a category
  *
  * @param category Category to be updated or inserted
  * @return Rows affected or new inserted category id
  */
 public Category updateCategory(Category category) {
   ContentValues values = new ContentValues();
   values.put(
       KEY_CATEGORY_ID,
       category.getId() != null ? category.getId() : Calendar.getInstance().getTimeInMillis());
   values.put(KEY_CATEGORY_NAME, category.getName());
   values.put(KEY_CATEGORY_DESCRIPTION, category.getDescription());
   values.put(KEY_CATEGORY_COLOR, category.getColor());
   getDatabase(true)
       .insertWithOnConflict(
           TABLE_CATEGORY, KEY_CATEGORY_ID, values, SQLiteDatabase.CONFLICT_REPLACE);
   return category;
 }
Beispiel #2
0
  public int getCategorizedCount(Category category) {
    int count = 0;
    String sql =
        "SELECT COUNT(*)"
            + " FROM "
            + TABLE_NOTES
            + " WHERE "
            + KEY_CATEGORY
            + " = "
            + category.getId();

    Cursor cursor = null;
    try {
      cursor = getDatabase().rawQuery(sql, null);

      // Looping through all rows and adding to list
      if (cursor.moveToFirst()) {
        count = cursor.getInt(0);
      }

    } finally {
      if (cursor != null) cursor.close();
    }
    return count;
  }
 @Factory("category9List")
 public void initCategory9List() {
   log.info("initCategory9List");
   category9List = new HashMap<String, String>();
   for (Object o : em.createQuery("from " + "Category").getResultList()) {
     Category p = (Category) o;
     category9List.put(p.getName(), p.getId().toString());
   }
 }
Beispiel #4
0
  /**
   * Deletion of a category
   *
   * @param category Category to be deleted
   * @return Number 1 if category's record has been deleted, 0 otherwise
   */
  public long deleteCategory(Category category) {
    long deleted;

    SQLiteDatabase db = getDatabase(true);
    // Un-categorize notes associated with this category
    ContentValues values = new ContentValues();
    values.put(KEY_CATEGORY, "");

    // Updating row
    db.update(
        TABLE_NOTES,
        values,
        KEY_CATEGORY + " = ?",
        new String[] {String.valueOf(category.getId())});

    // Delete category
    deleted =
        db.delete(
            TABLE_CATEGORY,
            KEY_CATEGORY_ID + " = ?",
            new String[] {String.valueOf(category.getId())});
    return deleted;
  }
 public QuestsView(final long characterId, final ClientAchievementsContext context) {
   super(characterId);
   this.m_achievementsContext = context;
   final ArrayList<Category> rootCategories = AchievementsModel.INSTANCE.getRootCategories();
   Category questCategory = null;
   for (final Category category : rootCategories) {
     final int id = category.getId();
     if (id == 4) {
       questCategory = category;
       break;
     }
   }
   if (questCategory == null) {
     QuestsView.m_logger.error(
         (Object) "Probl\u00e8me d'export, pas de cat\u00e9gorie des qu\u00eates !!!");
     return;
   }
   final ArrayList<Category> children = questCategory.getChildren();
   if (children == null) {
     QuestsView.m_logger.error(
         (Object) "Probl\u00e8me d'export, la cat\u00e9gorie des qu\u00eates est vide !!!");
     return;
   }
   for (final Category subCategory : children) {
     final int subId = subCategory.getId();
     final boolean visible =
         !ArrayUtils.contains(AchievementConstants.HIDDEN_QUEST_CATEGORIES, subId);
     AchievementsViewManager.INSTANCE.createCategoryView(this.m_characterId, subCategory, null);
     if (visible) {
       final AchievementCategoryView categoryView =
           AchievementsViewManager.INSTANCE.getCategory(this.m_characterId, subCategory.getId());
       this.m_rootCategories.put(subId, categoryView);
       this.m_sortedRootCategories.add(categoryView);
     }
   }
   this.m_selectedRootCategory = this.m_sortedRootCategories.get(0);
 }