Ticket #629 (closed Enhancement: fixed)
The Facets service should be RESTful
Reported by: | jri | Owned by: | jri |
---|---|---|---|
Priority: | Major | Milestone: | Release 4.3 |
Component: | DeepaMehta Standard Distribution | Version: | 4.2 |
Keywords: | Cc: | dgf, Malte | |
Complexity: | 3 | Area: | Application Framework / API |
Module: | deepamehta-facets |
Description
We need that for the Kiezatlas 1 -> 2 migrator.
Change History
comment:2 Changed 11 years ago by Jörg Richter
Make the Facets service RESTful (#629).
Get facet values (single + multi):
Topic getFacet(long topicId, String facetTypeUri) GET /facet/{facet_type_uri}/topic/{id} List<RelatedTopic> getFacets(long topicId, String facetTypeUri) # new method GET /facet/multi/{facet_type_uri}/topic/{id}
Update facet values (single + multi):
void updateFacet(long topicId, String facetTypeUri, TopicModel facetValue, ClientState clientState) # new method PUT /facet/{facet_type_uri}/topic/{id} {topic model in message body} void updateFacets(long topicId, String facetTypeUri, List<TopicModel> facetValues, ClientState clientState) # new method PUT /facet/multi/{facet_type_uri}/topic/{id} [array of topic models in message body]
Multi-facet update via REST not yet functional
Attach facet type:
void addFacetTypeToTopic(long topicId, String facetTypeUri) POST /facet/{facet_type_uri}/topic/{id}
See #629
comment:3 Changed 11 years ago by Jörg Richter
RESTful Facets service: multi-facets (#629).
Updating multi-facets is now functional.
BREAKING CHANGE
Facets API and REST API has changed.
New class:
de.deepamehta.plugins.facets.model.FacetValues?
void updateFacets(long topicId, String facetTypeUri, FacetValues facetValues, ClientState clientState) PUT /facet/multi/{facet_type_uri}/topic/{id} {JSON object in message body} void updateFacets(DeepaMehtaObject object, String facetTypeUri, FacetValues facetValues, ClientState clientState, Directives directives)
The JSON object in the message body is a composite value with exactly one entry. Key is the child type URI, value is an array. Syntax is exactly like in an update request. All types of array elements are supported: topic values (compact format, strings), entire topic models, or topic references (by ID or by URI).
Example (topic references):
PUT /facet/multi/ka2.criteria.zielgruppe.facet/topic/3575
{
"ka2.criteria.zielgruppe": ["ref_uri:ka2.category.erwachsene", "ref_uri:ka2.category.jugendliche"]
}
See #629
comment:4 Changed 11 years ago by Jörg Richter
RESTful Facets service: fix topic refs (#629).
Update facet requests via REST: topic refs are handled properly for single-value facets.
BREAKING CHANGE
Facets API and REST API has changed.
Single-value facets and multi-value facets are updated with the same calls.
Also for single-value facets a FacetValue object is involved.
Class renamed:
FacetValues -> FacetValue
2 forms (1 with ID param, 1 with object param), the 1st is RESTful:
void updateFacet(long topicId, String facetTypeUri, FacetValue value, ClientState clientState) void updateFacet(DeepaMehtaObject object, String facetTypeUri, FacetValue value, ClientState clientState, Directives directives)
REST API:
PUT /facet/{facet_type_uri}/topic/{id} {JSON object in message body}
Note: the request format is the same for single-value facets and multi-value facets.
/multi/ does not appear anymore in the request URI.
The JSON object in the message body is a composite value with exactly one entry. Syntax is the same as in an update request. All value formats are supported: topic value (compact format, strings), entire topic model (simple or composite), or topic reference (by ID or by URI), or an array of these (for multi-value facet).
Example (single-value, create new child):
PUT /facet/ka2.bezirk.facet/topic/3575 {"ka2.bezirk": "Friedrichshain"}
Example (single-value, refer to existing child):
PUT /facet/ka2.bezirk.facet/topic/3575 {"ka2.bezirk": "ref_uri:ka2.bezirk.mitte"}
Example (multi-value, create 1 new child and refer 1 existing child):
PUT /facet/ka2.criteria.zielgruppe.facet/topic/3575 {"ka2.criteria.zielgruppe": ["AktivistInnen", "ref_uri:ka2.category.jugendliche"]}
See #629.
comment:5 Changed 11 years ago by Jörg Richter
- Status changed from accepted to closed
- Resolution set to fixed
Facets service: add methods to FacetValue? (#629).
FacetValue has 2 new methods:
FacetValue put(TopicModel value) FacetValue addAll(List<TopicModel> values)
Close #629.
comment:6 Changed 11 years ago by Jörg Richter
Facets service: add method to FacetValue? (#629).
FacetValue has new method:
FacetValue addDeletionRef(long refTopicId)
It adds a by-ID topic deletion reference to a multiple-valued facet
See #629.