UNPKG

@dasch-swiss/dsp-js

Version:

JavaScript library that handles API requests to Knora

582 lines 30.4 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { catchError, map, mergeMap } from "rxjs/operators"; import { DataError } from "../../../models/data-error"; import { Constants } from "../../../models/v2/Constants"; import { CreateResourceClassPayload } from "../../../models/v2/ontologies/create/create-resource-class"; import { CreateResourcePropertyPayload } from "../../../models/v2/ontologies/create/create-resource-property"; import { DeleteOntologyResponse } from "../../../models/v2/ontologies/delete/delete-ontology-response"; import { OntologyMetadata } from "../../../models/v2/ontologies/ontology-metadata"; import { OntologyConversionUtil } from "../../../models/v2/ontologies/OntologyConversionUtil"; import { CanDoResponse } from "../../../models/v2/ontologies/read/can-do-response"; import { CardinalityUtil } from "../../../models/v2/resources/cardinality-util"; import { Endpoint } from "../../endpoint"; var jsonld = require("jsonld/dist/jsonld.js"); /** * Handles requests to the ontologies route of the Knora API. * * @category Endpoint V2 */ var OntologiesEndpointV2 = /** @class */ (function (_super) { __extends(OntologiesEndpointV2, _super); function OntologiesEndpointV2() { return _super !== null && _super.apply(this, arguments) || this; } /** * Requests metadata about all ontologies from Knora. */ OntologiesEndpointV2.prototype.getOntologiesMetadata = function () { var _this = this; return this.httpGet("/metadata").pipe(mergeMap(function (ajaxResponse) { // TODO: @rosenth Adapt context object // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return OntologyConversionUtil.convertOntologiesList(jsonldobj, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Requests an ontology from Knora. * * @param ontologyIri the IRI of the ontology to be requested. * @param allLanguages gets labels and comments in all languages, if set to true. */ OntologiesEndpointV2.prototype.getOntology = function (ontologyIri, allLanguages) { var _this = this; if (allLanguages === void 0) { allLanguages = false; } var allLangSegment = ""; if (allLanguages) { allLangSegment = "?allLanguages=true"; } // TODO: Do not hard-code the URL and http call params, generate this from Knora return this.httpGet("/allentities/" + encodeURIComponent(ontologyIri) + allLangSegment).pipe(mergeMap(function (ajaxResponse) { // TODO: @rosenth Adapt context object // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return OntologyConversionUtil.convertOntology(jsonldobj, _this.jsonConvert, _this.knoraApiConfig, allLanguages); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Requests metadata about all ontologies from a specific project. * * @param projectIri the IRI of the project. */ OntologiesEndpointV2.prototype.getOntologiesByProjectIri = function (projectIri) { var _this = this; return this.httpGet("/metadata/" + encodeURIComponent(projectIri)).pipe(mergeMap(function (ajaxResponse) { // TODO: @rosenth Adapt context object // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return OntologyConversionUtil.convertOntologiesList(jsonldobj, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Creates a new ontology. * * @param ontology The ontology to be created */ OntologiesEndpointV2.prototype.createOntology = function (ontology) { var _this = this; var onto = this.jsonConvert.serializeObject(ontology); return this.httpPost("", onto).pipe(mergeMap(function (ajaxResponse) { // TODO: @rosenth Adapt context object // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return _this.jsonConvert.deserializeObject(jsonldobj, OntologyMetadata); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Checks whether an existing ontology can be deleted. * * @param ontologyIri the Iri of the ontology to be checked. */ OntologiesEndpointV2.prototype.canDeleteOntology = function (ontologyIri) { var _this = this; return this.httpGet("/candeleteontology/" + encodeURIComponent(ontologyIri)).pipe(mergeMap(function (ajaxResponse) { // TODO: @rosenth Adapt context object // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return _this.jsonConvert.deserializeObject(jsonldobj, CanDoResponse); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Deletes an ontology. * * @param ontology the ontology to be deleted. */ OntologiesEndpointV2.prototype.deleteOntology = function (ontology) { var _this = this; var path = "/" + encodeURIComponent(ontology.id) + "?lastModificationDate=" + encodeURIComponent(ontology.lastModificationDate); return this.httpDelete(path).pipe(mergeMap(function (ajaxResponse) { // TODO: @rosenth Adapt context object // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return _this.jsonConvert.deserializeObject(jsonldobj, DeleteOntologyResponse); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Updates the metadata of an ontology. * * @param ontologyMetadata The ontology metadata to be updated */ OntologiesEndpointV2.prototype.updateOntology = function (ontologyMetadata) { var _this = this; // label and comment cannot both be undefined if (ontologyMetadata.label === undefined && ontologyMetadata.comment === undefined) { throw new Error("Label and comment cannot both be undefined. At least one must be defined."); } // label cannot be an empty string if (ontologyMetadata.label !== undefined && ontologyMetadata.label.trim() === "") { throw new Error("Label cannot be an empty string."); } // comment can be an empty string but we must make an additional API request to remove the comment if (ontologyMetadata.comment !== undefined && ontologyMetadata.comment.trim() === "") { // set the comment to undefined because the API will not accept an empty string ontologyMetadata.comment = undefined; // request to remove the comment return this.deleteOntologyComment(ontologyMetadata).pipe(mergeMap(function (res) { // update the lastModificationDate since the DELETE request changed it ontologyMetadata.lastModificationDate = res.lastModificationDate; // update the metadata, which in this case is only the label return _this.updateOntologyMetadata(ontologyMetadata); })); } else { // if label and/or comment are defined and not empty strings, make the API request to update the metadata return this.updateOntologyMetadata(ontologyMetadata); } }; /** * Removes the comment from the metadata of an ontology. * * @param ontologyMetadata The ontology metadata to be updated */ OntologiesEndpointV2.prototype.deleteOntologyComment = function (ontologyMetadata) { var _this = this; if (ontologyMetadata.id === undefined || ontologyMetadata.lastModificationDate === undefined) { throw new Error('Missing IRI or lastModificationDate'); } return this.httpDelete("/comment/".concat(encodeURIComponent(ontologyMetadata.id), "?lastModificationDate=").concat(encodeURIComponent(ontologyMetadata.lastModificationDate))).pipe(mergeMap(function (ajaxResponse) { // TODO: @rosenth Adapt context object // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return _this.jsonConvert.deserializeObject(jsonldobj, OntologyMetadata); })); }; /** * The PUT request for updating the metadata of an ontology. * * @param ontologyMetadata The ontology metadata to be updated */ OntologiesEndpointV2.prototype.updateOntologyMetadata = function (ontologyMetadata) { var _this = this; var onto = this.jsonConvert.serializeObject(ontologyMetadata); return this.httpPut("/metadata", onto).pipe(mergeMap(function (ajaxResponse) { // TODO: @rosenth Adapt context object // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return _this.jsonConvert.deserializeObject(jsonldobj, OntologyMetadata); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Creates a resource class without cardinalities. * * @param resourceClass The resource class to be created. */ OntologiesEndpointV2.prototype.createResourceClass = function (resourceClass) { var _this = this; var _a; var resClassPay = new CreateResourceClassPayload(); resClassPay.id = resourceClass.id + Constants.HashDelimiter + resourceClass.entity.name; resClassPay.label = resourceClass.entity.label; resClassPay.comment = (((_a = resourceClass.entity.comment) === null || _a === void 0 ? void 0 : _a.length) ? resourceClass.entity.comment : undefined); resClassPay.subClassOf = resourceClass.entity.subClassOf; resClassPay.type = Constants.Class; var ontoPayload = this.jsonConvert.serializeObject(resourceClass); ontoPayload["@graph"] = [this.jsonConvert.serializeObject(resClassPay)]; return this.httpPost("/classes", ontoPayload).pipe(mergeMap(function (ajaxResponse) { // TODO: @rosenth Adapt context object // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return OntologyConversionUtil.convertResourceClassResponse(jsonldobj, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Updates a resource class's label or comment. * * @param updateResourceClass the new label or comment. */ OntologiesEndpointV2.prototype.updateResourceClass = function (updateResourceClass) { var _this = this; var ontoPayload = this.jsonConvert.serializeObject(updateResourceClass); ontoPayload["@graph"] = [this.jsonConvert.serializeObject(updateResourceClass.entity)]; return this.httpPut("/classes", ontoPayload).pipe(mergeMap(function (ajaxResponse) { // TODO: @rosenth Adapt context object // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return OntologyConversionUtil.convertResourceClassResponse(jsonldobj, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Updates a property's label or comment. * * @param updateProperty the new label or comment. */ OntologiesEndpointV2.prototype.updateResourceProperty = function (updateProperty) { var _this = this; var ontoPayload = this.jsonConvert.serializeObject(updateProperty); ontoPayload["@graph"] = [this.jsonConvert.serializeObject(updateProperty.entity)]; return this.httpPut("/properties", ontoPayload).pipe(mergeMap(function (ajaxResponse) { // TODO: @rosenth Adapt context object // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return OntologyConversionUtil.convertResourcePropertyResponse(jsonldobj, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Checks whether an existing resource class can be deleted. * * @param resourceClassIri the iri of the resource class to be checked. */ OntologiesEndpointV2.prototype.canDeleteResourceClass = function (resourceClassIri) { var _this = this; return this.httpGet("/candeleteclass/" + encodeURIComponent(resourceClassIri)).pipe(mergeMap(function (ajaxResponse) { // TODO: @rosenth Adapt context object // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return _this.jsonConvert.deserializeObject(jsonldobj, CanDoResponse); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Deletes a resource class. * * @param deleteResourceClass with class IRI. */ OntologiesEndpointV2.prototype.deleteResourceClass = function (deleteResourceClass) { var _this = this; var path = "/classes/" + encodeURIComponent(deleteResourceClass.id) + "?lastModificationDate=" + encodeURIComponent(deleteResourceClass.lastModificationDate); return this.httpDelete(path).pipe(mergeMap(function (ajaxResponse) { // TODO: @rosenth Adapt context object // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return _this.jsonConvert.deserializeObject(jsonldobj, OntologyMetadata); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Deletes a resource class's comment * * @param deleteResourceClassComment with class IRI and lastModificationDate */ OntologiesEndpointV2.prototype.deleteResourceClassComment = function (deleteResourceClassComment) { var _this = this; var path = "/classes/comment/" + encodeURIComponent(deleteResourceClassComment.id) + "?lastModificationDate=" + encodeURIComponent(deleteResourceClassComment.lastModificationDate); return this.httpDelete(path).pipe(mergeMap(function (ajaxResponse) { return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return OntologyConversionUtil.convertResourceClassResponse(jsonldobj, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Creates a resource property. * * @param resourceProperties the resource property to be created. */ OntologiesEndpointV2.prototype.createResourceProperty = function (resourceProperties) { var _this = this; var _a; var resPropPay = new CreateResourcePropertyPayload(); resPropPay.id = resourceProperties.id + Constants.HashDelimiter + resourceProperties.entity.name; resPropPay.label = resourceProperties.entity.label; resPropPay.comment = (((_a = resourceProperties.entity.comment) === null || _a === void 0 ? void 0 : _a.length) ? resourceProperties.entity.comment : undefined); resPropPay.subPropertyOf = resourceProperties.entity.subPropertyOf; resPropPay.subjectType = resourceProperties.entity.subjectType; resPropPay.objectType = resourceProperties.entity.objectType; if (resourceProperties.entity.guiElement) { resPropPay.guiElement = resourceProperties.entity.guiElement; } if (resourceProperties.entity.guiAttributes) { resPropPay.guiAttributes = resourceProperties.entity.guiAttributes; } var ontoPayload = this.jsonConvert.serializeObject(resourceProperties); ontoPayload["@graph"] = [this.jsonConvert.serializeObject(resPropPay)]; return this.httpPost("/properties", ontoPayload).pipe(mergeMap(function (ajaxResponse) { // TODO: @rosenth Adapt context object // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return OntologyConversionUtil.convertResourcePropertyResponse(jsonldobj, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Updates the GUI element and/or the GUI attributes of a property * @param replaceGuiElement */ OntologiesEndpointV2.prototype.replaceGuiElementOfProperty = function (replaceGuiElement) { var _this = this; var ontoPayload = this.jsonConvert.serializeObject(replaceGuiElement); ontoPayload["@graph"] = [this.jsonConvert.serializeObject(replaceGuiElement.entity)]; return this.httpPut("/properties/guielement", ontoPayload).pipe(mergeMap(function (ajaxResponse) { return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return OntologyConversionUtil.convertResourcePropertyResponse(jsonldobj, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Checks whether an existing property can be deleted. * * @param propertyIri the iri of the property to be checked. */ OntologiesEndpointV2.prototype.canDeleteResourceProperty = function (propertyIri) { var _this = this; return this.httpGet("/candeleteproperty/" + encodeURIComponent(propertyIri)).pipe(mergeMap(function (ajaxResponse) { // TODO: @rosenth Adapt context object // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return _this.jsonConvert.deserializeObject(jsonldobj, CanDoResponse); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Deletes a resource property. * * @param deleteResourceProperty with property IRI. */ OntologiesEndpointV2.prototype.deleteResourceProperty = function (deleteResourceProperty) { var _this = this; var path = "/properties/" + encodeURIComponent(deleteResourceProperty.id) + "?lastModificationDate=" + encodeURIComponent(deleteResourceProperty.lastModificationDate); return this.httpDelete(path).pipe(mergeMap(function (ajaxResponse) { // TODO: @rosenth Adapt context object // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return _this.jsonConvert.deserializeObject(jsonldobj, OntologyMetadata); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Deletes a resource property's comment * * @param deleteResourcePropertyComment with property IRI and lastModificationDate */ OntologiesEndpointV2.prototype.deleteResourcePropertyComment = function (deleteResourcePropertyComment) { var _this = this; var path = "/properties/comment/" + encodeURIComponent(deleteResourcePropertyComment.id) + "?lastModificationDate=" + encodeURIComponent(deleteResourcePropertyComment.lastModificationDate); return this.httpDelete(path).pipe(mergeMap(function (ajaxResponse) { return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return OntologyConversionUtil.convertResourcePropertyResponse(jsonldobj, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Adds cardinalities for properties to a resource class. * * @param addCardinalityToResourceClass the cardinalities to be added. */ OntologiesEndpointV2.prototype.addCardinalityToResourceClass = function (addCardinalityToResourceClass) { var _this = this; if (addCardinalityToResourceClass.entity.cardinalities.length === 0) { throw new Error("At least one cardinality must be defined."); } var onto = this.jsonConvert.serializeObject(addCardinalityToResourceClass); var cardinalities = this.jsonConvert.serializeObject(addCardinalityToResourceClass.entity); onto["@graph"] = [cardinalities]; return this.httpPost("/cardinalities", onto).pipe(mergeMap(function (ajaxResponse) { // TODO: @rosenth Adapt context object // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return OntologyConversionUtil.convertResourceClassResponse(jsonldobj, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Checks whether existing cardinalities can be replaced for a given resource class. * * @deprecated use canReplaceCardinalityOfResourceClassWith instead * @param resourceClassIri the iri of the resource class to be checked. */ OntologiesEndpointV2.prototype.canReplaceCardinalityOfResourceClass = function (resourceClassIri) { var _this = this; return this.httpGet("/canreplacecardinalities/" + encodeURIComponent(resourceClassIri)).pipe(mergeMap(function (ajaxResponse) { // TODO: @rosenth Adapt context object // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return _this.jsonConvert.deserializeObject(jsonldobj, CanDoResponse); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Checks whether existing cardinalities can be replaced for a given resource class, propertyIri, and desired cardinality * * @param resourceClassIri the iri of the resource class to be checked. * @param propertyIri the iri of the property to be checked. * @param desiredCardinality the desired cardinality. */ OntologiesEndpointV2.prototype.canReplaceCardinalityOfResourceClassWith = function (resourceClassIri, propertyIri, desiredCardinality) { var _this = this; var card = CardinalityUtil.cardinalities.get(desiredCardinality); return this.httpGet("/canreplacecardinalities/" + encodeURIComponent(resourceClassIri) + "?propertyIri=" + encodeURIComponent(propertyIri) + "&newCardinality=" + card).pipe(mergeMap(function (ajaxResponse) { return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return _this.jsonConvert.deserializeObject(jsonldobj, CanDoResponse); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Replaces cardinalities for properties to a resource class. * * @param replaceCardinalityOfResourceClass the cardinalities to be added. */ OntologiesEndpointV2.prototype.replaceCardinalityOfResourceClass = function (replaceCardinalityOfResourceClass) { var _this = this; var onto = this.jsonConvert.serializeObject(replaceCardinalityOfResourceClass); var numberOfCards = replaceCardinalityOfResourceClass.entity.cardinalities.length; var cardinalities = this.jsonConvert.serializeObject(replaceCardinalityOfResourceClass.entity); // remove subClassOf if no cards are provided // all cards will be removed from resource class if (numberOfCards === 0) { delete cardinalities[Constants.SubClassOf]; } onto["@graph"] = [cardinalities]; return this.httpPut("/cardinalities", onto).pipe(mergeMap(function (ajaxResponse) { // TODO: @rosenth Adapt context object // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return OntologyConversionUtil.convertResourceClassResponse(jsonldobj, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Checks wether a cardinality can be removed from a class even in presence of resources of this class. * A cardinality can be removed in the case that the property is not used in any resources. * For now, DSP-API allows only one cardinality at a time to delete. * @param deleteCardinalitiesFromClass the cardinalities that need to be checked. */ OntologiesEndpointV2.prototype.canDeleteCardinalityFromResourceClass = function (deleteCardinalityFromClass) { var _this = this; var deleteCardinalityFromClassRequest = this.jsonConvert.serializeObject(deleteCardinalityFromClass); var numberOfCardinalities = deleteCardinalityFromClass.entity.cardinalities.length; if (numberOfCardinalities > 1) { // only one cardinality at a time can be deleted; return an error return this._badCardinalityRequest("canDeleteCardinalityFromClass"); } var cardinalities = this.jsonConvert.serializeObject(deleteCardinalityFromClass.entity); deleteCardinalityFromClassRequest["@graph"] = [cardinalities]; return this.httpPost("/candeletecardinalities", deleteCardinalityFromClassRequest).pipe(mergeMap(function (ajaxResponse) { return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return _this.jsonConvert.deserializeObject(jsonldobj, CanDoResponse); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Deletes cardinalities from a class even in presence of resources of this class. * A cardinality can be removed in the case that the property is not used in any resources. * For now, DSP-API allows only one cardinality at a time to be deleted. * @param deleteCardinalitiesFromClass the cardinalities that need to be checked. */ OntologiesEndpointV2.prototype.deleteCardinalityFromResourceClass = function (deleteCardinalityFromClass) { var _this = this; var deleteCardinalityFromClassRequest = this.jsonConvert.serializeObject(deleteCardinalityFromClass); var numberOfCardinalities = deleteCardinalityFromClass.entity.cardinalities.length; if (numberOfCardinalities > 1) { // only one cardinality at a time can be deleted; return an error return this._badCardinalityRequest("deleteCardinalityFromClass"); } var cardinalities = this.jsonConvert.serializeObject(deleteCardinalityFromClass.entity); deleteCardinalityFromClassRequest["@graph"] = [cardinalities]; return this.httpPatch("/cardinalities", deleteCardinalityFromClassRequest).pipe(mergeMap(function (ajaxResponse) { return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return OntologyConversionUtil.convertResourceClassResponse(jsonldobj, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Updates gui order of cardinalities * @param replaceGuiOrder */ OntologiesEndpointV2.prototype.replaceGuiOrderOfCardinalities = function (replaceGuiOrder) { var _this = this; var onto = this.jsonConvert.serializeObject(replaceGuiOrder); var cardinalities = this.jsonConvert.serializeObject(replaceGuiOrder.entity); onto["@graph"] = [cardinalities]; return this.httpPut("/guiorder", onto).pipe(mergeMap(function (ajaxResponse) { return jsonld.compact(ajaxResponse.response, {}); }), map(function (jsonldobj) { return OntologyConversionUtil.convertResourceClassResponse(jsonldobj, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; OntologiesEndpointV2.prototype._badCardinalityRequest = function (method) { var response = { error: "Only one cardinality can be deleted at a time.", url: "/cardinalities", status: 400, method: method }; var error = new DataError("Bad request", response); return this.handleError(error); }; return OntologiesEndpointV2; }(Endpoint)); export { OntologiesEndpointV2 }; //# sourceMappingURL=ontologies-endpoint-v2.js.map