relationship-type.service.ts (dspace-angular-dspace-7.0) | : | relationship-type.service.ts (dspace-angular-dspace-7.1) | ||
---|---|---|---|---|
skipping to change at line 18 | skipping to change at line 18 | |||
import { NotificationsService } from '../../shared/notifications/notifications.s ervice'; | import { NotificationsService } from '../../shared/notifications/notifications.s ervice'; | |||
import { followLink } from '../../shared/utils/follow-link-config.model'; | import { followLink } from '../../shared/utils/follow-link-config.model'; | |||
import { dataService } from '../cache/builders/build-decorators'; | import { dataService } from '../cache/builders/build-decorators'; | |||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.serv ice'; | import { RemoteDataBuildService } from '../cache/builders/remote-data-build.serv ice'; | |||
import { ObjectCacheService } from '../cache/object-cache.service'; | import { ObjectCacheService } from '../cache/object-cache.service'; | |||
import { CoreState } from '../core.reducers'; | import { CoreState } from '../core.reducers'; | |||
import { HALEndpointService } from '../shared/hal-endpoint.service'; | import { HALEndpointService } from '../shared/hal-endpoint.service'; | |||
import { ItemType } from '../shared/item-relationships/item-type.model'; | import { ItemType } from '../shared/item-relationships/item-type.model'; | |||
import { RelationshipType } from '../shared/item-relationships/relationship-type .model'; | import { RelationshipType } from '../shared/item-relationships/relationship-type .model'; | |||
import { RELATIONSHIP_TYPE } from '../shared/item-relationships/relationship-typ e.resource-type'; | import { RELATIONSHIP_TYPE } from '../shared/item-relationships/relationship-typ e.resource-type'; | |||
import { getFirstSucceededRemoteData, getFirstCompletedRemoteData } from '../sha red/operators'; | import { getFirstSucceededRemoteData, getFirstCompletedRemoteData, getRemoteData Payload } from '../shared/operators'; | |||
import { DataService } from './data.service'; | import { DataService } from './data.service'; | |||
import { DefaultChangeAnalyzer } from './default-change-analyzer.service'; | import { DefaultChangeAnalyzer } from './default-change-analyzer.service'; | |||
import { ItemDataService } from './item-data.service'; | import { ItemDataService } from './item-data.service'; | |||
import { PaginatedList } from './paginated-list.model'; | import { PaginatedList } from './paginated-list.model'; | |||
import { RemoteData } from './remote-data'; | import { RemoteData } from './remote-data'; | |||
import { RequestService } from './request.service'; | import { RequestService } from './request.service'; | |||
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model'; | ||||
/** | /** | |||
* Check if one side of a RelationshipType is the ItemType with the given label | * Check if one side of a RelationshipType is the ItemType with the given label | |||
* | * | |||
* @param typeRd the RemoteData for an ItemType | * @param typeRd the RemoteData for an ItemType | |||
* @param label the label to check. e.g. Author | * @param label the label to check. e.g. Author | |||
*/ | */ | |||
const checkSide = (typeRd: RemoteData<ItemType>, label: string): boolean => | const checkSide = (typeRd: RemoteData<ItemType>, label: string): boolean => | |||
typeRd.hasSucceeded && typeRd.payload.label === label; | typeRd.hasSucceeded && typeRd.payload.label === label; | |||
skipping to change at line 123 | skipping to change at line 124 | |||
map(([leftTypeRD, rightTypeRD]: [RemoteData<ItemType>, RemoteData<ItemType >]) => { | map(([leftTypeRD, rightTypeRD]: [RemoteData<ItemType>, RemoteData<ItemType >]) => { | |||
if (checkSide(leftTypeRD, leftItemType) && checkSide(rightTypeRD, rightI temType) | if (checkSide(leftTypeRD, leftItemType) && checkSide(rightTypeRD, rightI temType) | |||
) { | ) { | |||
return type; | return type; | |||
} else { | } else { | |||
return null; | return null; | |||
} | } | |||
}) | }) | |||
); | ); | |||
} | } | |||
/** | ||||
* Search of the given RelationshipType if has the given itemTypes on its left | ||||
and right sides. | ||||
* Returns an observable of the given RelationshipType if it matches, null if | ||||
it doesn't | ||||
* | ||||
* @param type The RelationshipType to check | ||||
*/ | ||||
searchByEntityType(type: string,useCachedVersionIfAvailable = true, reRequestO | ||||
nStale = true, ...linksToFollow: FollowLinkConfig<RelationshipType>[]): Observab | ||||
le<PaginatedList<RelationshipType>> { | ||||
return this.searchBy( | ||||
'byEntityType', | ||||
{ | ||||
searchParams: [ | ||||
{ | ||||
fieldName: 'type', | ||||
fieldValue: type | ||||
}, | ||||
{ | ||||
fieldName: 'size', | ||||
fieldValue: 100 | ||||
}, | ||||
] | ||||
}, useCachedVersionIfAvailable,reRequestOnStale,...linksToFollow).pipe( | ||||
getFirstSucceededRemoteData(), | ||||
getRemoteDataPayload(), | ||||
) as Observable<PaginatedList<RelationshipType>>; | ||||
} | ||||
} | } | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 34 lines changed or added |