Category Rules

This post is primarily for developers using the NixMash Blog App, as we've added Categories and here are the rules. It may also be interesting to developers who appreciate the level of detail that can go into seemingly simple data points.

First a screenshot of the Categories Administration page. The two checkboxes represent the properties IS_ACTIVE and IS_DEFAULT. More on those in a second.

The Rules

  1. While WordPress supports multiple categories per Post, only a single category can be assigned per post in the NixMash Blog app.
  2. All posts not assigned a category are assigned UNCATEGORIZED, or Category_Id 1L. Posts imported from WordPress and not assigned a category will have this Id already assigned, otherwise the posts' first assigned WordPress category
  3. As the focus of Blogs often change over time, we support an ACTIVE status. When INACTIVE, categories will not appear in the Post Editor Category Selection.
  4. A single category is assigned the DEFAULT CATEGORY status, which simply means it appears first in the Post Editor Category Selection for ease of use
  5. When a category is deleted, all posts assigned that category are assigned the UNCATEGORIZED category.
  6. The UNCATEGORIZED category cannot be changed or deleted.

The Tests

The tests to confirm the Category Rules are primarily found in the PostServiceTests Class of the JPA Module, as the PostService layer is where the rules are enforced.

Source Code Notes for this Post

Source code discussed in this post can be found in my NixMash Blog project located on GitHub.

Posted March 06, 2017 02:14 PM EST

More Like This Post