add Connection Type (aka connection facet to the stored connection)
@@ -13,6 +13,7 @@ export function parseConnection(jsonldConnection) {
uri: undefined,
state: undefined,
messages: Immutable.Map(),
+ facet: generateFacetType(jsonldConnectionImm.get("hasFacet")),
agreementData: {
agreementUris: Immutable.Set(),
pendingProposalUris: Immutable.Set(),
@@ -87,3 +88,17 @@ export function parseConnection(jsonldConnection) {
return undefined;
}
}
+/*
+ This method is solely used to define a common facetType (aka connection Type for the connection)
+ because the facet is [needUri]#[type]
+ */
+function generateFacetType(uri) {
+ if (uri) {
+ const indexOfLastSharp = uri.lastIndexOf("#");
+
+ if (indexOfLastSharp != -1 && indexOfLastSharp + 1 < uri.length) {
+ return uri.substr(indexOfLastSharp + 1);
+ }
+ }
+ return uri;
+}
