fabric8-ui / fabric8-planner

https://fabric8-ui.github.io/fabric8-planner/
Apache License 2.0
26 stars 62 forks source link

Create Category API on the Backend #898

Open michaelkleinhenz opened 7 years ago

michaelkleinhenz commented 7 years ago

For #882 and #884, we need an API on the backend that allows to query entities based on a given category. Check with the Platform team if a full CRUD is needed. In the context of #882 and #884, we need at least query WITs and LTs from the backend. Aslak has details on how to implement that.

pranavgore09 commented 7 years ago

@DhritiShikhar As discussed, please verify content below

Every space will have pre-defined categories. Categories are statically created by system (as of now). A category will contain one or many WIT in it. A WIT can be in multiple categories at a time. Categories are retrieved from a space. Categories can be in one or many spaces at a time.

  1. API endpoint to get all categories of a space GET /api/spaces/space_id/ jsonapi response should contain links of all categories in that space

  2. Get all work items in a category GET /api/spaces/space_id/category_name_or_id/

@aslakknutsen @michaelkleinhenz Please verify once.

DhritiShikhar commented 7 years ago

So can a workitemtype exist without being associated with any category?

pranavgore09 commented 7 years ago

IMO yes @DhritiShikhar

DhritiShikhar commented 7 years ago

@aslakknutsen @pranavgore09 What actions are required for categories?

Does this look good? ->

var _ = a.Resource("space-categories", func() {
    a.Parent("space")
    a.Action("list", func() {
        ...
    })
    a.Action("create", func() {
        ...
    })
}
var _ = a.Resource("categories", func() {   
    a.Action("show", func() {
    })
    a.Action("update", func() {
    })
    a.Action("delete", func() {
    })  
}
pranavgore09 commented 7 years ago

@DhritiShikhar : As per recent discussion with @michaelkleinhenz , we need to think of categories that can embed Link Types too along with Work Item Type.

DhritiShikhar commented 7 years ago

@pranavgore09 yes

pranavgore09 commented 7 years ago

@aslakknutsen As @baijum mentioned, can we read categories from space_template -> work_item_type_categories ?

aslakknutsen commented 7 years ago

@DhritiShikhar Categories has no REST API.

There is a hardcoded list of possible categories; A category can have many WITs and a WIT can be in many categories; The relation between WIT and Category is defined in the Space Template. A Category is exposed in REST only as something like 'planner_[category]' WI Lists links on the Space API and act as a predefined Filter[workitemtype]=x for the WIT's that belong to given Category.

DhritiShikhar commented 7 years ago

@aslakknutsen got it.

DhritiShikhar commented 7 years ago

Sum of all the information that I have on categories based on discussion with @aslakknutsen and @sbose78 :

[1] We need a table in database that has all the category names. [2] Space Template will setup relation between WorkItemTypes in the current space and categories. [3] Space should have a link which UI could use and call GET on the link. [4] The link should be implemented as a filter [5] Category table should have following columns:

ID
Name
Space_ID -> ForeignKey Relation

[6] work_item_types table should have a field called categories which will contain the IDs of all the categories the work item type belongs to. It should have Foreign Key Relationship.

[7] It is a many to many relationship. A workItemType can belong to many categories. A category can belong to many workItemTypes.

A workItemType can belong to many spaces. A category can belong to many spaces.

[8] The relationship is like this: category(category_id) --> wit_category(category_id, wit_id) ---> wit(wit_id, wi_id)

Questions

1) Since, a category can belong to more than one space, so, should a category get deleted when all the associated spaces with that particular category gets deleted?

If all the spaces associated with a category are deleted, then the category should not delete. Categories are like system configuration.

2) Can a workItemType exist without belonging to any category?

Yes

3) Is Space template used to create categories by defining the workitem types? OR the space template will just list the pre-defined categories that should be used in this space?

The Space template is used to create categories.

michaelkleinhenz commented 7 years ago

A workItemType can belong to many spaces. A category can belong to many spaces.

isn't that too complex for the model? Spaces are completely isolated and should not share anything imho, even on the model side. That would make modifying or deleting categories or WITs unneccessary complex.

aslakknutsen commented 7 years ago

A workItemType can belong to many spaces. A category can belong to many spaces.

That model is wrong.

A Space can contain many WorkItemTypes, a WorkItemType can only be in one Space. (beyond the top level ones that are closer to system configuration then a WIT)

A Category is a system wide 'configuration', A WorkItemType can belong to many Categories and a Category can contain many WorkItemTypes.

aslakknutsen commented 7 years ago

3) Is Space template used to create categories by defining the workitem types? OR the space template will just list the pre-defined categories that should be used in this space?

The Categories are predefined. The Space Template defines the WITs and which WITs belong to which Categories.

DhritiShikhar commented 7 years ago

The Categories are predefined. The Space Template defines the WITs and which WITs belong to which Categories.

@aslakknutsen The person who would be writing the space template. How would that person know that these categories are available?

aslakknutsen commented 7 years ago

For now, documentation.

On Sat, Mar 11, 2017, 06:37 Dhriti Shikhar notifications@github.com wrote:

The Categories are predefined. The Space Template defines the WITs and which WITs belong to which Categories.

The person who would be writing the space template. How would that person know that these categories are available?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/fabric8io/fabric8-planner/issues/898#issuecomment-285844878, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIEPnRMcVSAfSeZ99H_ZrI3p-50Jgoaks5rkjMTgaJpZM4L36jV .