@@ -4,16 +4,18 @@ import { Observable } from 'rxjs';
44import { filter , map , switchMap , take } from 'rxjs/operators' ;
55import { NotificationsService } from '../../shared/notifications/notifications.service' ;
66import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service' ;
7+ import { RequestParam } from '../cache/models/request-param.model' ;
78import { ObjectCacheService } from '../cache/object-cache.service' ;
89import { Community } from '../shared/community.model' ;
910import { COMMUNITY } from '../shared/community.resource-type' ;
1011import { HALEndpointService } from '../shared/hal-endpoint.service' ;
12+ import { getAllCompletedRemoteData } from '../shared/operators' ;
13+ import { BitstreamDataService } from './bitstream-data.service' ;
1114import { ComColDataService } from './comcol-data.service' ;
1215import { DSOChangeAnalyzer } from './dso-change-analyzer.service' ;
1316import { PaginatedList } from './paginated-list.model' ;
1417import { RemoteData } from './remote-data' ;
1518import { RequestService } from './request.service' ;
16- import { BitstreamDataService } from './bitstream-data.service' ;
1719import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model' ;
1820import { isNotEmpty } from '../../shared/empty.util' ;
1921import { FindListOptions } from './find-list-options.model' ;
@@ -36,6 +38,92 @@ export class CommunityDataService extends ComColDataService<Community> {
3638 super ( 'communities' , requestService , rdbService , objectCache , halService , comparator , notificationsService , bitstreamDataService ) ;
3739 }
3840
41+ /**
42+ * Get all communities the user is admin of
43+ *
44+ * @param query limit the returned collection to those with metadata values
45+ * matching the query terms.
46+ * @param options The [[FindListOptions]] object
47+ * @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
48+ * no valid cached version. Defaults to true
49+ * @param reRequestOnStale Whether or not the request should automatically be re-
50+ * requested after the response becomes stale
51+ * @param linksToFollow List of {@link FollowLinkConfig} that indicate which
52+ * {@link HALLink}s should be automatically resolved
53+ * @return Observable<RemoteData<PaginatedList<Community>>>
54+ * community list
55+ */
56+ getAdminAuthorizedCommunity ( query : string , options : FindListOptions = { } , useCachedVersionIfAvailable = true , reRequestOnStale = true , ...linksToFollow : FollowLinkConfig < Community > [ ] ) : Observable < RemoteData < PaginatedList < Community > > > {
57+ const searchHref = 'findAdminAuthorized' ;
58+ return this . getAuthorizedCommunity ( query , options , useCachedVersionIfAvailable , reRequestOnStale , searchHref , ...linksToFollow ) ;
59+ }
60+
61+ /**
62+ * Get all communities the user is authorized to add a new subcommunity or collection to
63+ *
64+ * @param query limit the returned collection to those with metadata values
65+ * matching the query terms.
66+ * @param options The [[FindListOptions]] object
67+ * @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
68+ * no valid cached version. Defaults to true
69+ * @param reRequestOnStale Whether or not the request should automatically be re-
70+ * requested after the response becomes stale
71+ * @param linksToFollow List of {@link FollowLinkConfig} that indicate which
72+ * {@link HALLink}s should be automatically resolved
73+ * @return Observable<RemoteData<PaginatedList<Community>>>
74+ * community list
75+ */
76+ getAddAuthorizedCommunity ( query : string , options : FindListOptions = { } , useCachedVersionIfAvailable = true , reRequestOnStale = true , ...linksToFollow : FollowLinkConfig < Community > [ ] ) : Observable < RemoteData < PaginatedList < Community > > > {
77+ const searchHref = 'findAddAuthorized' ;
78+ return this . getAuthorizedCommunity ( query , options , useCachedVersionIfAvailable , reRequestOnStale , searchHref , ...linksToFollow ) ;
79+ }
80+
81+ /**
82+ * Get all communities the user is authorized to edit
83+ *
84+ * @param query limit the returned collection to those with metadata values
85+ * matching the query terms.
86+ * @param options The [[FindListOptions]] object
87+ * @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
88+ * no valid cached version. Defaults to true
89+ * @param reRequestOnStale Whether or not the request should automatically be re-
90+ * requested after the response becomes stale
91+ * @param linksToFollow List of {@link FollowLinkConfig} that indicate which
92+ * {@link HALLink}s should be automatically resolved
93+ * @return Observable<RemoteData<PaginatedList<Community>>>
94+ * community list
95+ */
96+ getEditAuthorizedCommunity ( query : string , options : FindListOptions = { } , useCachedVersionIfAvailable = true , reRequestOnStale = true , ...linksToFollow : FollowLinkConfig < Community > [ ] ) : Observable < RemoteData < PaginatedList < Community > > > {
97+ const searchHref = 'findEditAuthorized' ;
98+ return this . getAuthorizedCommunity ( query , options , useCachedVersionIfAvailable , reRequestOnStale , searchHref , ...linksToFollow ) ;
99+ }
100+
101+ /**
102+ * Get all communities the user is authorized to submit to
103+ *
104+ * @param query limit the returned community to those with metadata values
105+ * matching the query terms.
106+ * @param options The [[FindListOptions]] object
107+ * @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
108+ * no valid cached version. Defaults to true
109+ * @param reRequestOnStale Whether or not the request should automatically be re-
110+ * requested after the response becomes stale
111+ * @param searchHref The search endpoint to use, defaults to 'findAdminAuthorized'
112+ * @param linksToFollow List of {@link FollowLinkConfig} that indicate which
113+ * {@link HALLink}s should be automatically resolved
114+ * @return Observable<RemoteData<PaginatedList<Community>>>
115+ * community list
116+ */
117+ getAuthorizedCommunity ( query : string , options : FindListOptions = { } , useCachedVersionIfAvailable = true , reRequestOnStale = true , searchHref : string = 'findAdminAuthorized' , ...linksToFollow : FollowLinkConfig < Community > [ ] ) : Observable < RemoteData < PaginatedList < Community > > > {
118+ options = Object . assign ( { } , options , {
119+ searchParams : [ new RequestParam ( 'query' , query ) ] ,
120+ } ) ;
121+
122+ return this . searchBy ( searchHref , options , useCachedVersionIfAvailable , reRequestOnStale , ...linksToFollow ) . pipe (
123+ getAllCompletedRemoteData ( ) ,
124+ ) ;
125+ }
126+
39127 // this method is overridden in order to make it public
40128 getEndpoint ( ) {
41129 return this . halService . getEndpoint ( this . linkPath ) ;
0 commit comments