mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 22:13:02 +00:00
removed remaining normalized models and related services
This commit is contained in:
@@ -12,13 +12,12 @@ import { BaseResponseParsingService } from '../data/base-response-parsing.servic
|
||||
import { GLOBAL_CONFIG } from '../../../config';
|
||||
import { GlobalConfig } from '../../../config/global-config.interface';
|
||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||
import { NormalizedObjectSerializer } from '../dspace-rest-v2/normalized-object.serializer';
|
||||
import { Serializer } from '../serializer';
|
||||
import { GenericConstructor } from '../shared/generic-constructor';
|
||||
import { NormalizedWorkspaceItem } from './models/normalized-workspaceitem.model';
|
||||
import { NormalizedWorkflowItem } from './models/normalized-workflowitem.model';
|
||||
import { FormFieldMetadataValueObject } from '../../shared/form/builder/models/form-field-metadata-value.model';
|
||||
import { SubmissionObject } from './models/submission-object.model';
|
||||
import { WorkflowItem } from './models/workflowitem.model';
|
||||
import { WorkspaceItem } from './models/workspaceitem.model';
|
||||
|
||||
/**
|
||||
* Export a function to check if object has same properties of FormFieldMetadataValueObject
|
||||
@@ -81,8 +80,6 @@ export class SubmissionResponseParsingService extends BaseResponseParsingService
|
||||
protected toCache = false;
|
||||
protected shouldDirectlyAttachEmbeds = true;
|
||||
|
||||
protected serializerConstructor: GenericConstructor<Serializer<any>> = NormalizedObjectSerializer;
|
||||
|
||||
constructor(@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig,
|
||||
protected objectCache: ObjectCacheService,
|
||||
protected dsoParser: DSOResponseParsingService
|
||||
@@ -125,15 +122,15 @@ export class SubmissionResponseParsingService extends BaseResponseParsingService
|
||||
*/
|
||||
protected processResponse<ObjectDomain>(data: any, request: RestRequest): any[] {
|
||||
const dataDefinition = this.process<ObjectDomain>(data, request);
|
||||
const normalizedDefinition = Array.of();
|
||||
const definition = Array.of();
|
||||
const processedList = Array.isArray(dataDefinition) ? dataDefinition : Array.of(dataDefinition);
|
||||
|
||||
processedList.forEach((item) => {
|
||||
|
||||
let normalizedItem = Object.assign({}, item);
|
||||
// In case data is an Instance of NormalizedWorkspaceItem normalize field value of all the section of type form
|
||||
if (item instanceof NormalizedWorkspaceItem
|
||||
|| item instanceof NormalizedWorkflowItem) {
|
||||
item = Object.assign({}, item);
|
||||
// In case data is an Instance of WorkspaceItem normalize field value of all the section of type form
|
||||
if (item instanceof WorkspaceItem
|
||||
|| item instanceof WorkflowItem) {
|
||||
if (item.sections) {
|
||||
const precessedSection = Object.create({});
|
||||
// Iterate over all workspaceitem's sections
|
||||
@@ -143,35 +140,35 @@ export class SubmissionResponseParsingService extends BaseResponseParsingService
|
||||
// When Upload section is disabled, add to submission only if there are files
|
||||
(!item.sections[sectionId].hasOwnProperty('files') || isNotEmpty((item.sections[sectionId] as any).files)))) {
|
||||
|
||||
const normalizedSectionData = Object.create({});
|
||||
const sectiondata = Object.create({});
|
||||
// Iterate over all sections property
|
||||
Object.keys(item.sections[sectionId])
|
||||
.forEach((metdadataId) => {
|
||||
const entry = item.sections[sectionId][metdadataId];
|
||||
// If entry is not an array, for sure is not a section of type form
|
||||
if (Array.isArray(entry)) {
|
||||
normalizedSectionData[metdadataId] = [];
|
||||
sectiondata[metdadataId] = [];
|
||||
entry.forEach((valueItem, index) => {
|
||||
// Parse value and normalize it
|
||||
const normValue = normalizeSectionData(valueItem, index);
|
||||
if (isNotEmpty(normValue)) {
|
||||
normalizedSectionData[metdadataId].push(normValue);
|
||||
sectiondata[metdadataId].push(normValue);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
normalizedSectionData[metdadataId] = entry;
|
||||
sectiondata[metdadataId] = entry;
|
||||
}
|
||||
});
|
||||
precessedSection[sectionId] = normalizedSectionData;
|
||||
precessedSection[sectionId] = sectiondata;
|
||||
}
|
||||
});
|
||||
normalizedItem = Object.assign({}, item, { sections: precessedSection });
|
||||
item = Object.assign({}, item, { sections: precessedSection });
|
||||
}
|
||||
}
|
||||
normalizedDefinition.push(normalizedItem);
|
||||
definition.push(item);
|
||||
});
|
||||
|
||||
return normalizedDefinition;
|
||||
return definition;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user