Skip to content

Commit

Permalink
feat(api): add getNodeFromSearchIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Lübbemeier committed Apr 14, 2022
1 parent bf85e57 commit 015e0cd
Show file tree
Hide file tree
Showing 7 changed files with 244 additions and 7 deletions.
127 changes: 123 additions & 4 deletions Frontend/projects/edu-sharing-api/build/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -20179,6 +20179,106 @@
}
}
},
"/search/v1/metadata/{repository}" : {
"get" : {
"tags" : [ "SEARCH v1" ],
"summary" : "get nodes with metadata and collections",
"operationId" : "getMetdata",
"parameters" : [ {
"name" : "repository",
"in" : "path",
"description" : "ID of repository (or \"-home-\" for home repository)",
"required" : true,
"schema" : {
"type" : "string",
"default" : "-home-"
}
}, {
"name" : "nodeIds",
"in" : "query",
"description" : "nodeIds",
"schema" : {
"type" : "array",
"items" : {
"type" : "string"
}
}
}, {
"name" : "propertyFilter",
"in" : "query",
"description" : "property filter for result nodes (or \"-all-\" for all properties)",
"schema" : {
"type" : "array",
"items" : {
"type" : "string",
"default" : "-all-"
}
}
} ],
"responses" : {
"200" : {
"description" : "OK.",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/NodeEntries"
}
}
}
},
"400" : {
"description" : "Preconditions are not present.",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/ErrorResponse"
}
}
}
},
"401" : {
"description" : "Authorization failed.",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/ErrorResponse"
}
}
}
},
"403" : {
"description" : "Session user has insufficient rights to perform this operation.",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/ErrorResponse"
}
}
}
},
"404" : {
"description" : "Ressources are not found.",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/ErrorResponse"
}
}
}
},
"500" : {
"description" : "Fatal error occured.",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/search/v1/relevant/{repository}" : {
"get" : {
"tags" : [ "SEARCH v1" ],
Expand Down Expand Up @@ -25164,16 +25264,16 @@
"key" : {
"$ref" : "#/components/schemas/Key"
},
"requestsRecovery" : {
"type" : "boolean",
"writeOnly" : true
},
"durable" : {
"type" : "boolean"
},
"stateful" : {
"type" : "boolean"
},
"requestsRecovery" : {
"type" : "boolean",
"writeOnly" : true
},
"jobListenerNames" : {
"type" : "array",
"items" : {
Expand Down Expand Up @@ -26440,6 +26540,12 @@
},
"organizationFilter" : {
"type" : "string"
},
"licenses" : {
"type" : "array",
"items" : {
"type" : "string"
}
}
}
},
Expand Down Expand Up @@ -26542,6 +26648,9 @@
"type" : "string"
}
},
"workspaceSharedToMeDefaultAll" : {
"type" : "boolean"
},
"hideMainMenu" : {
"type" : "array",
"items" : {
Expand Down Expand Up @@ -27315,9 +27424,19 @@
"url" : {
"type" : "string"
},
"registeredAppId" : {
"type" : "string"
},
"tsCreated" : {
"type" : "integer",
"format" : "int64"
},
"tsExpiry" : {
"type" : "integer",
"format" : "int64"
},
"valid" : {
"type" : "boolean"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/* tslint:disable */
/* eslint-disable */
export interface DynamicRegistrationToken {
registeredAppId?: string;
token?: string;
tsCreated?: number;
tsExpiry?: number;
url?: string;
valid?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { SimpleEditGlobalGroups } from './simple-edit-global-groups';
import { SimpleEditOrganization } from './simple-edit-organization';
export interface SimpleEdit {
globalGroups?: Array<SimpleEditGlobalGroups>;
licenses?: Array<string>;
organization?: SimpleEditOrganization;
organizationFilter?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,6 @@ export interface Values {
whatsNewUrl?: string;
workflow?: ConfigWorkflow;
workspaceColumns?: Array<string>;
workspaceSharedToMeDefaultAll?: boolean;
workspaceViewType?: number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { map, filter } from 'rxjs/operators';

import { MdsQueryCriteria } from '../models/mds-query-criteria';
import { Node } from '../models/node';
import { NodeEntries } from '../models/node-entries';
import { NodeEntry } from '../models/node-entry';
import { SearchParameters } from '../models/search-parameters';
import { SearchParametersFacets } from '../models/search-parameters-facets';
Expand All @@ -24,6 +25,90 @@ export class SearchV1Service extends BaseService {
super(config, http);
}

/**
* Path part for operation getMetdata
*/
static readonly GetMetdataPath = '/search/v1/metadata/{repository}';

/**
* get nodes with metadata and collections.
*
*
*
* This method provides access to the full `HttpResponse`, allowing access to response headers.
* To access only the response body, use `getMetdata()` instead.
*
* This method doesn't expect any request body.
*/
getMetdata$Response(params: {
/**
* ID of repository (or &quot;-home-&quot; for home repository)
*/
repository: string;

/**
* nodeIds
*/
nodeIds?: Array<string>;

/**
* property filter for result nodes (or &quot;-all-&quot; for all properties)
*/
propertyFilter?: Array<string>;
}): Observable<StrictHttpResponse<NodeEntries>> {
const rb = new RequestBuilder(this.rootUrl, SearchV1Service.GetMetdataPath, 'get');
if (params) {
rb.path('repository', params.repository, {});
rb.query('nodeIds', params.nodeIds, {});
rb.query('propertyFilter', params.propertyFilter, {});
}

return this.http
.request(
rb.build({
responseType: 'json',
accept: 'application/json',
}),
)
.pipe(
filter((r: any) => r instanceof HttpResponse),
map((r: HttpResponse<any>) => {
return r as StrictHttpResponse<NodeEntries>;
}),
);
}

/**
* get nodes with metadata and collections.
*
*
*
* This method provides access to only to the response body.
* To access the full response (for headers, for example), `getMetdata$Response()` instead.
*
* This method doesn't expect any request body.
*/
getMetdata(params: {
/**
* ID of repository (or &quot;-home-&quot; for home repository)
*/
repository: string;

/**
* nodeIds
*/
nodeIds?: Array<string>;

/**
* property filter for result nodes (or &quot;-all-&quot; for all properties)
*/
propertyFilter?: Array<string>;
}): Observable<NodeEntries> {
return this.getMetdata$Response(params).pipe(
map((r: StrictHttpResponse<NodeEntries>) => r.body as NodeEntries),
);
}

/**
* Path part for operation getRelevantNodes
*/
Expand Down
1 change: 1 addition & 0 deletions Frontend/projects/edu-sharing-api/src/lib/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export {
MdsWidgetCondition,
MetadataSetInfo,
Node,
NodeEntries,
NodeRef,
Organization,
Person,
Expand Down
33 changes: 30 additions & 3 deletions Frontend/projects/edu-sharing-api/src/lib/wrappers/node.service.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { NodeV1Service } from '../api/services';
import { Node } from '../models';
import { NodeV1Service, SearchV1Service } from '../api/services';
import { HOME_REPOSITORY } from '../constants';
import { Node, NodeEntries } from '../models';

@Injectable({
providedIn: 'root',
})
export class NodeService {
constructor(private nodeV1: NodeV1Service) {}
constructor(private nodeV1: NodeV1Service, private searchV1: SearchV1Service) {}

getNode(repository: string, id: string): Observable<Node> {
return this.nodeV1
Expand All @@ -19,4 +20,30 @@ export class NodeService {
})
.pipe(map((nodeEntry) => nodeEntry.node));
}

/**
* Fetches the metadata as indexed for search.
*
* The search index includes some additional information like collections in which the node is
* used, however, it may not always be in sync with the database and requested nodes might not
* be included in the response.
*/
getNodeFromSearchIndex(
nodeId: string,
{ repository = HOME_REPOSITORY } = {},
): Observable<Node | null> {
return this.getNodesFromSearchIndex([nodeId], { repository }).pipe(
map((nodeEntries) => nodeEntries.nodes[0] ?? null),
);
}

/**
* Like `getNodeFromSearchIndex`, but fetches multiple nodes.
*/
getNodesFromSearchIndex(
nodeIds: string[],
{ repository = HOME_REPOSITORY } = {},
): Observable<NodeEntries> {
return this.searchV1.getMetdata({ repository, nodeIds, propertyFilter: ['-all-'] });
}
}

0 comments on commit 015e0cd

Please sign in to comment.