Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Dspace7 Angular
Manage
Activity
Members
Labels
Plan
Issues
42
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vtechworks
Dspace7 Angular
Commits
0207aa14
Commit
0207aa14
authored
6 years ago
by
Art Lowel
Browse files
Options
Downloads
Patches
Plain Diff
Added PIDService
parent
98966bd0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/app/core/core.module.ts
+2
-0
2 additions, 0 deletions
src/app/core/core.module.ts
src/app/core/data/pid.service.spec.ts
+73
-0
73 additions, 0 deletions
src/app/core/data/pid.service.spec.ts
src/app/core/data/pid.service.ts
+36
-0
36 additions, 0 deletions
src/app/core/data/pid.service.ts
with
111 additions
and
0 deletions
src/app/core/core.module.ts
+
2
−
0
View file @
0207aa14
...
@@ -20,6 +20,7 @@ import { CollectionDataService } from './data/collection-data.service';
...
@@ -20,6 +20,7 @@ import { CollectionDataService } from './data/collection-data.service';
import
{
CommunityDataService
}
from
'
./data/community-data.service
'
;
import
{
CommunityDataService
}
from
'
./data/community-data.service
'
;
import
{
DebugResponseParsingService
}
from
'
./data/debug-response-parsing.service
'
;
import
{
DebugResponseParsingService
}
from
'
./data/debug-response-parsing.service
'
;
import
{
DSOResponseParsingService
}
from
'
./data/dso-response-parsing.service
'
;
import
{
DSOResponseParsingService
}
from
'
./data/dso-response-parsing.service
'
;
import
{
PIDService
}
from
'
./data/pid.service
'
;
import
{
SearchResponseParsingService
}
from
'
./data/search-response-parsing.service
'
;
import
{
SearchResponseParsingService
}
from
'
./data/search-response-parsing.service
'
;
import
{
DSpaceRESTv2Service
}
from
'
./dspace-rest-v2/dspace-rest-v2.service
'
;
import
{
DSpaceRESTv2Service
}
from
'
./dspace-rest-v2/dspace-rest-v2.service
'
;
import
{
HostWindowService
}
from
'
../shared/host-window.service
'
;
import
{
HostWindowService
}
from
'
../shared/host-window.service
'
;
...
@@ -110,6 +111,7 @@ const PROVIDERS = [
...
@@ -110,6 +111,7 @@ const PROVIDERS = [
SubmissionFormsConfigService
,
SubmissionFormsConfigService
,
SubmissionSectionsConfigService
,
SubmissionSectionsConfigService
,
UUIDService
,
UUIDService
,
PIDService
,
// register AuthInterceptor as HttpInterceptor
// register AuthInterceptor as HttpInterceptor
{
{
provide
:
HTTP_INTERCEPTORS
,
provide
:
HTTP_INTERCEPTORS
,
...
...
This diff is collapsed.
Click to expand it.
src/app/core/data/pid.service.spec.ts
0 → 100644
+
73
−
0
View file @
0207aa14
import
{
cold
,
getTestScheduler
}
from
'
jasmine-marbles
'
;
import
{
TestScheduler
}
from
'
../../../../node_modules/rxjs
'
;
import
{
RemoteDataBuildService
}
from
'
../cache/builders/remote-data-build.service
'
;
import
{
DSpaceObject
}
from
'
../shared/dspace-object.model
'
;
import
{
HALEndpointService
}
from
'
../shared/hal-endpoint.service
'
;
import
{
PIDService
}
from
'
./pid.service
'
;
import
{
FindByIDRequest
}
from
'
./request.models
'
;
import
{
RequestService
}
from
'
./request.service
'
;
fdescribe
(
'
PIDService
'
,
()
=>
{
let
scheduler
:
TestScheduler
;
let
service
:
PIDService
;
let
halService
:
HALEndpointService
;
let
requestService
:
RequestService
;
let
rdbService
:
RemoteDataBuildService
;
const
testObject
=
{
id
:
'
9b4f22f4-164a-49db-8817-3316b6ee5746
'
}
as
DSpaceObject
;
const
pidLink
=
'
https://rest.api/rest/api/pid/find{?id}
'
;
const
requestURL
=
`https://rest.api/rest/api/pid/find?id=
${
testObject
.
id
}
`
;
const
requestUUID
=
'
34cfed7c-f597-49ef-9cbe-ea351f0023c2
'
;
beforeEach
(()
=>
{
scheduler
=
getTestScheduler
();
halService
=
jasmine
.
createSpyObj
(
'
halService
'
,
{
getEndpoint
:
cold
(
'
a
'
,
{
a
:
pidLink
})
});
requestService
=
jasmine
.
createSpyObj
(
'
requestService
'
,
{
generateRequestId
:
requestUUID
,
configure
:
true
});
rdbService
=
jasmine
.
createSpyObj
(
'
rdbService
'
,
{
buildSingle
:
cold
(
'
a
'
,
{
a
:
{
payload
:
testObject
}
})
});
service
=
new
PIDService
(
requestService
,
rdbService
,
halService
)
});
describe
(
'
findById
'
,
()
=>
{
it
(
'
should call HALEndpointService with the path to the pid endpoint
'
,
()
=>
{
scheduler
.
schedule
(()
=>
service
.
findById
(
testObject
.
id
));
scheduler
.
flush
();
expect
(
halService
.
getEndpoint
).
toHaveBeenCalledWith
(
'
pid
'
);
});
it
(
'
should configure the proper FindByIDRequest
'
,
()
=>
{
scheduler
.
schedule
(()
=>
service
.
findById
(
testObject
.
id
));
scheduler
.
flush
();
expect
(
requestService
.
configure
).
toHaveBeenCalledWith
(
new
FindByIDRequest
(
requestUUID
,
requestURL
,
testObject
.
id
));
});
it
(
'
should return a RemoteData<DSpaceObject> for the object with the given ID
'
,
()
=>
{
const
result
=
service
.
findById
(
testObject
.
id
);
const
expected
=
cold
(
'
a
'
,
{
a
:
{
payload
:
testObject
}
});
expect
(
result
).
toBeObservable
(
expected
);
});
});
});
This diff is collapsed.
Click to expand it.
src/app/core/data/pid.service.ts
0 → 100644
+
36
−
0
View file @
0207aa14
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
Observable
}
from
'
rxjs/Observable
'
;
import
{
hasValue
}
from
'
../../shared/empty.util
'
;
import
{
RemoteDataBuildService
}
from
'
../cache/builders/remote-data-build.service
'
;
import
{
NormalizedDSpaceObject
}
from
'
../cache/models/normalized-dspace-object.model
'
;
import
{
DSpaceObject
}
from
'
../shared/dspace-object.model
'
;
import
{
HALEndpointService
}
from
'
../shared/hal-endpoint.service
'
;
import
{
RemoteData
}
from
'
./remote-data
'
;
import
{
FindByIDRequest
}
from
'
./request.models
'
;
import
{
RequestService
}
from
'
./request.service
'
;
@
Injectable
()
export
class
PIDService
{
protected
linkPath
=
'
pid
'
;
constructor
(
protected
requestService
:
RequestService
,
protected
rdbService
:
RemoteDataBuildService
,
protected
halService
:
HALEndpointService
)
{
}
findById
(
id
:
string
):
Observable
<
RemoteData
<
DSpaceObject
>>
{
const
hrefObs
=
this
.
halService
.
getEndpoint
(
this
.
linkPath
)
.
map
((
endpoint
:
string
)
=>
endpoint
.
replace
(
/
\{\?
id
\}
/
,
`?id=
${
id
}
`
));
hrefObs
.
filter
((
href
:
string
)
=>
hasValue
(
href
))
.
take
(
1
)
.
subscribe
((
href
:
string
)
=>
{
const
request
=
new
FindByIDRequest
(
this
.
requestService
.
generateRequestId
(),
href
,
id
);
this
.
requestService
.
configure
(
request
);
});
return
this
.
rdbService
.
buildSingle
<
NormalizedDSpaceObject
,
DSpaceObject
>
(
hrefObs
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment