mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
67611: Import external entry as new entity pt1
This commit is contained in:
@@ -1533,6 +1533,8 @@
|
|||||||
|
|
||||||
"submission.sections.describe.relationship-lookup.external-source.import-modal.cancel": "Cancel",
|
"submission.sections.describe.relationship-lookup.external-source.import-modal.cancel": "Cancel",
|
||||||
|
|
||||||
|
"submission.sections.describe.relationship-lookup.external-source.import-modal.collection": "Select a collection to import new entries to",
|
||||||
|
|
||||||
"submission.sections.describe.relationship-lookup.external-source.import-modal.entities": "Entities",
|
"submission.sections.describe.relationship-lookup.external-source.import-modal.entities": "Entities",
|
||||||
|
|
||||||
"submission.sections.describe.relationship-lookup.external-source.import-modal.entities.new": "Import as a new local entity",
|
"submission.sections.describe.relationship-lookup.external-source.import-modal.entities.new": "Import as a new local entity",
|
||||||
|
@@ -37,6 +37,7 @@ import { HttpOptions } from '../dspace-rest-v2/dspace-rest-v2.service';
|
|||||||
import { Collection } from '../shared/collection.model';
|
import { Collection } from '../shared/collection.model';
|
||||||
import { RemoteData } from './remote-data';
|
import { RemoteData } from './remote-data';
|
||||||
import { PaginatedList } from './paginated-list';
|
import { PaginatedList } from './paginated-list';
|
||||||
|
import { ExternalSourceEntry } from '../shared/external-source-entry.model';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ItemDataService extends DataService<Item> {
|
export class ItemDataService extends DataService<Item> {
|
||||||
@@ -247,4 +248,32 @@ export class ItemDataService extends DataService<Item> {
|
|||||||
map((request: RequestEntry) => request.response)
|
map((request: RequestEntry) => request.response)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import an external source entry into a collection
|
||||||
|
* @param externalSourceEntry
|
||||||
|
* @param collectionId
|
||||||
|
*/
|
||||||
|
public importExternalSourceEntry(externalSourceEntry: ExternalSourceEntry, collectionId: string): Observable<RestResponse> {
|
||||||
|
const options: HttpOptions = Object.create({});
|
||||||
|
let headers = new HttpHeaders();
|
||||||
|
headers = headers.append('Content-Type', 'text/uri-list');
|
||||||
|
options.headers = headers;
|
||||||
|
|
||||||
|
const requestId = this.requestService.generateRequestId();
|
||||||
|
const href$ = this.halService.getEndpoint(this.linkPath).pipe(map((href) => `${href}?owningCollection=${collectionId}`));
|
||||||
|
|
||||||
|
href$.pipe(
|
||||||
|
find((href: string) => hasValue(href)),
|
||||||
|
map((href: string) => {
|
||||||
|
const request = new PostRequest(requestId, href, externalSourceEntry.self, options);
|
||||||
|
this.requestService.configure(request);
|
||||||
|
})
|
||||||
|
).subscribe();
|
||||||
|
|
||||||
|
return this.requestService.getByUUID(requestId).pipe(
|
||||||
|
find((request: RequestEntry) => request.completed),
|
||||||
|
map((request: RequestEntry) => request.response)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -101,6 +101,7 @@ import { ItemSearchResult } from '../../../object-collection/shared/item-search-
|
|||||||
import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model';
|
import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model';
|
||||||
import { MetadataValue } from '../../../../core/shared/metadata.models';
|
import { MetadataValue } from '../../../../core/shared/metadata.models';
|
||||||
import * as uuidv4 from 'uuid/v4';
|
import * as uuidv4 from 'uuid/v4';
|
||||||
|
import { Collection } from '../../../../core/shared/collection.model';
|
||||||
|
|
||||||
export function dsDynamicFormControlMapFn(model: DynamicFormControlModel): Type<DynamicFormControl> | null {
|
export function dsDynamicFormControlMapFn(model: DynamicFormControlModel): Type<DynamicFormControl> | null {
|
||||||
switch (model.type) {
|
switch (model.type) {
|
||||||
@@ -188,6 +189,7 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
|||||||
hasRelationLookup: boolean;
|
hasRelationLookup: boolean;
|
||||||
modalRef: NgbModalRef;
|
modalRef: NgbModalRef;
|
||||||
item: Item;
|
item: Item;
|
||||||
|
collection: Collection;
|
||||||
listId: string;
|
listId: string;
|
||||||
searchConfig: string;
|
searchConfig: string;
|
||||||
selectedValues$: Observable<Array<{
|
selectedValues$: Observable<Array<{
|
||||||
@@ -234,13 +236,18 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
|||||||
this.hasRelationLookup = hasValue(this.model.relationship);
|
this.hasRelationLookup = hasValue(this.model.relationship);
|
||||||
if (this.hasRelationLookup) {
|
if (this.hasRelationLookup) {
|
||||||
this.listId = 'list-' + this.model.relationship.relationshipType;
|
this.listId = 'list-' + this.model.relationship.relationshipType;
|
||||||
const item$ = this.submissionObjectService
|
|
||||||
|
const submissionObject$ = this.submissionObjectService
|
||||||
.findById(this.model.submissionId).pipe(
|
.findById(this.model.submissionId).pipe(
|
||||||
getAllSucceededRemoteData(),
|
getAllSucceededRemoteData(),
|
||||||
getRemoteDataPayload(),
|
getRemoteDataPayload()
|
||||||
switchMap((submissionObject: SubmissionObject) => (submissionObject.item as Observable<RemoteData<Item>>).pipe(getAllSucceededRemoteData(), getRemoteDataPayload())));
|
);
|
||||||
|
|
||||||
|
const item$ = submissionObject$.pipe(switchMap((submissionObject: SubmissionObject) => (submissionObject.item as Observable<RemoteData<Item>>).pipe(getAllSucceededRemoteData(), getRemoteDataPayload())));
|
||||||
|
const collection$ = submissionObject$.pipe(switchMap((submissionObject: SubmissionObject) => (submissionObject.collection as Observable<RemoteData<Collection>>).pipe(getAllSucceededRemoteData(), getRemoteDataPayload())));
|
||||||
|
|
||||||
this.subs.push(item$.subscribe((item) => this.item = item));
|
this.subs.push(item$.subscribe((item) => this.item = item));
|
||||||
|
this.subs.push(collection$.subscribe((collection) => this.collection = collection));
|
||||||
|
|
||||||
this.relationService.getRelatedItemsByLabel(this.item, this.model.relationship.relationshipType).pipe(
|
this.relationService.getRelatedItemsByLabel(this.item, this.model.relationship.relationshipType).pipe(
|
||||||
map((items: RemoteData<PaginatedList<Item>>) => items.payload.page.map((item) => Object.assign(new ItemSearchResult(), { indexableObject: item }))),
|
map((items: RemoteData<PaginatedList<Item>>) => items.payload.page.map((item) => Object.assign(new ItemSearchResult(), { indexableObject: item }))),
|
||||||
@@ -325,6 +332,7 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
|||||||
modalComp.label = this.model.label;
|
modalComp.label = this.model.label;
|
||||||
modalComp.metadataFields = this.model.metadataFields;
|
modalComp.metadataFields = this.model.metadataFields;
|
||||||
modalComp.item = this.item;
|
modalComp.item = this.item;
|
||||||
|
modalComp.collection = this.collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
removeSelection(object: SearchResult<Item>) {
|
removeSelection(object: SearchResult<Item>) {
|
||||||
|
@@ -26,6 +26,8 @@
|
|||||||
<ng-template ngbTabContent>
|
<ng-template ngbTabContent>
|
||||||
<ds-dynamic-lookup-relation-external-source-tab
|
<ds-dynamic-lookup-relation-external-source-tab
|
||||||
[listId]="listId"
|
[listId]="listId"
|
||||||
|
[item]="item"
|
||||||
|
[collection]="collection"
|
||||||
[relationship]="relationshipOptions"
|
[relationship]="relationshipOptions"
|
||||||
[repeatable]="repeatable"
|
[repeatable]="repeatable"
|
||||||
[context]="context"
|
[context]="context"
|
||||||
|
@@ -47,6 +47,7 @@ export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy
|
|||||||
relationshipOptions: RelationshipOptions;
|
relationshipOptions: RelationshipOptions;
|
||||||
listId: string;
|
listId: string;
|
||||||
item;
|
item;
|
||||||
|
collection;
|
||||||
repeatable: boolean;
|
repeatable: boolean;
|
||||||
selection$: Observable<ListableObject[]>;
|
selection$: Observable<ListableObject[]>;
|
||||||
context: Context;
|
context: Context;
|
||||||
|
@@ -20,6 +20,8 @@ import { ExternalSourceEntryImportModalComponent } from './external-source-entry
|
|||||||
import { Subscription } from 'rxjs/internal/Subscription';
|
import { Subscription } from 'rxjs/internal/Subscription';
|
||||||
import { hasValue } from '../../../../../empty.util';
|
import { hasValue } from '../../../../../empty.util';
|
||||||
import { SelectableListService } from '../../../../../object-list/selectable-list/selectable-list.service';
|
import { SelectableListService } from '../../../../../object-list/selectable-list/selectable-list.service';
|
||||||
|
import { Item } from '../../../../../../core/shared/item.model';
|
||||||
|
import { Collection } from '../../../../../../core/shared/collection.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-dynamic-lookup-relation-external-source-tab',
|
selector: 'ds-dynamic-lookup-relation-external-source-tab',
|
||||||
@@ -40,6 +42,8 @@ import { SelectableListService } from '../../../../../object-list/selectable-lis
|
|||||||
export class DsDynamicLookupRelationExternalSourceTabComponent implements OnInit, OnDestroy {
|
export class DsDynamicLookupRelationExternalSourceTabComponent implements OnInit, OnDestroy {
|
||||||
@Input() label: string;
|
@Input() label: string;
|
||||||
@Input() listId: string;
|
@Input() listId: string;
|
||||||
|
@Input() item: Item;
|
||||||
|
@Input() collection: Collection;
|
||||||
@Input() relationship: RelationshipOptions;
|
@Input() relationship: RelationshipOptions;
|
||||||
@Input() repeatable: boolean;
|
@Input() repeatable: boolean;
|
||||||
@Input() context: Context;
|
@Input() context: Context;
|
||||||
@@ -103,6 +107,8 @@ export class DsDynamicLookupRelationExternalSourceTabComponent implements OnInit
|
|||||||
});
|
});
|
||||||
const modalComp = this.modalRef.componentInstance;
|
const modalComp = this.modalRef.componentInstance;
|
||||||
modalComp.externalSourceEntry = entry;
|
modalComp.externalSourceEntry = entry;
|
||||||
|
modalComp.item = this.item;
|
||||||
|
modalComp.collection = this.collection;
|
||||||
modalComp.relationship = this.relationship;
|
modalComp.relationship = this.relationship;
|
||||||
this.importObjectSub = modalComp.importedObject.subscribe((object) => {
|
this.importObjectSub = modalComp.importedObject.subscribe((object) => {
|
||||||
this.selectableListService.selectSingle(this.listId, object);
|
this.selectableListService.selectSingle(this.listId, object);
|
||||||
|
@@ -13,7 +13,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h4>{{ ('submission.sections.describe.relationship-lookup.external-source.import-modal.select' | translate) }}</h4>
|
<h4>{{ ('submission.sections.describe.relationship-lookup.external-source.import-modal.select' | translate) }}</h4>
|
||||||
<div id="external-source-entry-entities" class="mb-2">
|
<div id="external-source-entry-collection" class="mb-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="collection">{{ ('submission.sections.describe.relationship-lookup.external-source.import-modal.collection' | translate) }}</label>
|
||||||
|
<input type="text" class="form-control" id="collection" placeholder="Enter collection ID" [value]="collectionId">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="external-source-entry-entities" class="mb-3">
|
||||||
<h5 class="font-weight-bold">{{ ('submission.sections.describe.relationship-lookup.external-source.import-modal.entities' | translate) }}</h5>
|
<h5 class="font-weight-bold">{{ ('submission.sections.describe.relationship-lookup.external-source.import-modal.entities' | translate) }}</h5>
|
||||||
|
|
||||||
<ds-search-results *ngIf="(localEntitiesRD$ | async)?.payload?.page?.length > 0"
|
<ds-search-results *ngIf="(localEntitiesRD$ | async)?.payload?.page?.length > 0"
|
||||||
@@ -29,7 +35,7 @@
|
|||||||
(deselectObject)="deselectEntity()"
|
(deselectObject)="deselectEntity()"
|
||||||
(selectObject)="selectEntity($event)">
|
(selectObject)="selectEntity($event)">
|
||||||
</ds-search-results>
|
</ds-search-results>
|
||||||
<div class="form-check">
|
<div class="ml-4">
|
||||||
<input class="form-check-input" type="radio" name="new-entity" id="new-entity" value="new-entity" (click)="selectNewEntity()" [checked]="selectedImportType === importType.NewEntity" />
|
<input class="form-check-input" type="radio" name="new-entity" id="new-entity" value="new-entity" (click)="selectNewEntity()" [checked]="selectedImportType === importType.NewEntity" />
|
||||||
<label class="form-check-label" for="new-entity">{{ ('submission.sections.describe.relationship-lookup.external-source.import-modal.entities.new' | translate) }}</label>
|
<label class="form-check-label" for="new-entity">{{ ('submission.sections.describe.relationship-lookup.external-source.import-modal.entities.new' | translate) }}</label>
|
||||||
</div>
|
</div>
|
||||||
@@ -37,7 +43,7 @@
|
|||||||
<div id="external-source-entry-authority">
|
<div id="external-source-entry-authority">
|
||||||
<h5 class="font-weight-bold">{{ ('submission.sections.describe.relationship-lookup.external-source.import-modal.authority' | translate) }}</h5>
|
<h5 class="font-weight-bold">{{ ('submission.sections.describe.relationship-lookup.external-source.import-modal.authority' | translate) }}</h5>
|
||||||
|
|
||||||
<div class="form-check">
|
<div class="ml-4">
|
||||||
<input class="form-check-input" type="radio" name="new-authority" id="new-authority" value="new-authority" (click)="selectNewAuthority()" [checked]="selectedImportType === importType.NewAuthority" />
|
<input class="form-check-input" type="radio" name="new-authority" id="new-authority" value="new-authority" (click)="selectNewAuthority()" [checked]="selectedImportType === importType.NewAuthority" />
|
||||||
<label class="form-check-label" for="new-authority">{{ ('submission.sections.describe.relationship-lookup.external-source.import-modal.authority.new' | translate) }}</label>
|
<label class="form-check-label" for="new-authority">{{ ('submission.sections.describe.relationship-lookup.external-source.import-modal.authority.new' | translate) }}</label>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -15,7 +15,8 @@ import { CollectionElementLinkType } from '../../../../../../object-collection/c
|
|||||||
import { Context } from '../../../../../../../core/shared/context.model';
|
import { Context } from '../../../../../../../core/shared/context.model';
|
||||||
import { SelectableListService } from '../../../../../../object-list/selectable-list/selectable-list.service';
|
import { SelectableListService } from '../../../../../../object-list/selectable-list/selectable-list.service';
|
||||||
import { ListableObject } from '../../../../../../object-collection/shared/listable-object.model';
|
import { ListableObject } from '../../../../../../object-collection/shared/listable-object.model';
|
||||||
import { take } from 'rxjs/operators';
|
import { Collection } from '../../../../../../../core/shared/collection.model';
|
||||||
|
import { ItemDataService } from '../../../../../../../core/data/item-data.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The possible types of import for the external entry
|
* The possible types of import for the external entry
|
||||||
@@ -39,6 +40,21 @@ export class ExternalSourceEntryImportModalComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
externalSourceEntry: ExternalSourceEntry;
|
externalSourceEntry: ExternalSourceEntry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The item in submission
|
||||||
|
*/
|
||||||
|
item: Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The collection the user is submitting in
|
||||||
|
*/
|
||||||
|
collection: Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ID of the collection to import entries to
|
||||||
|
*/
|
||||||
|
collectionId: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current relationship-options used for filtering results
|
* The current relationship-options used for filtering results
|
||||||
*/
|
*/
|
||||||
@@ -106,13 +122,15 @@ export class ExternalSourceEntryImportModalComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(public modal: NgbActiveModal,
|
constructor(public modal: NgbActiveModal,
|
||||||
public lookupRelationService: LookupRelationService,
|
public lookupRelationService: LookupRelationService,
|
||||||
private selectService: SelectableListService) {
|
private selectService: SelectableListService,
|
||||||
|
private itemService: ItemDataService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.uri = Metadata.first(this.externalSourceEntry.metadata, 'dc.identifier.uri');
|
this.uri = Metadata.first(this.externalSourceEntry.metadata, 'dc.identifier.uri');
|
||||||
this.searchOptions = Object.assign(new PaginatedSearchOptions({ query: 'sarah' }));
|
this.searchOptions = Object.assign(new PaginatedSearchOptions({ query: 'sarah' }));
|
||||||
this.localEntitiesRD$ = this.lookupRelationService.getLocalResults(this.relationship, this.searchOptions);
|
this.localEntitiesRD$ = this.lookupRelationService.getLocalResults(this.relationship, this.searchOptions);
|
||||||
|
this.collectionId = this.collection.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -162,7 +180,10 @@ export class ExternalSourceEntryImportModalComponent implements OnInit {
|
|||||||
* Create and import a new entity from the external entry
|
* Create and import a new entity from the external entry
|
||||||
*/
|
*/
|
||||||
importNewEntity() {
|
importNewEntity() {
|
||||||
this.importedObject.emit(this.externalSourceEntry);
|
console.log(this.collection);
|
||||||
|
this.itemService.importExternalSourceEntry(this.externalSourceEntry, this.collectionId).subscribe((response) => {
|
||||||
|
console.log(response);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user