Search in sources :

Example 91 with Record

use of nikita.common.model.noark5.v4.Record in project nikita-noark5-core by HiOA-ABI.

the class FileImportService method createRecordAssociatedWithFile.

@Override
public Record createRecordAssociatedWithFile(String fileSystemId, Record record) {
    Record persistedRecord = null;
    File file = fileRepository.findBySystemIdOrderBySystemId(fileSystemId);
    if (file == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " File, using fileSystemId " + fileSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    } else {
        record.setReferenceFile(file);
        persistedRecord = recordImportService.save(record);
    }
    return persistedRecord;
}
Also used : Record(nikita.model.noark5.v4.Record) BasicRecord(nikita.model.noark5.v4.BasicRecord) NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException) File(nikita.model.noark5.v4.File)

Example 92 with Record

use of nikita.common.model.noark5.v4.Record in project nikita-noark5-core by HiOA-ABI.

the class RecordImportService method createDocumentDescriptionAssociatedWithRecord.

@Override
public DocumentDescription createDocumentDescriptionAssociatedWithRecord(String systemID, DocumentDescription documentDescription) {
    DocumentDescription persistedDocumentDescription = null;
    Record record = recordRepository.findBySystemIdOrderBySystemId(systemID);
    if (record == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " Record, using systemID " + systemID;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    } else {
        TreeSet<Record> records = (TreeSet<Record>) documentDescription.getReferenceRecord();
        if (records == null) {
            records = new TreeSet<>();
            documentDescription.setReferenceRecord(records);
        }
        records.add(record);
        persistedDocumentDescription = documentDescriptionImportService.save(documentDescription);
    }
    return persistedDocumentDescription;
}
Also used : DocumentDescription(nikita.model.noark5.v4.DocumentDescription) TreeSet(java.util.TreeSet) Record(nikita.model.noark5.v4.Record) NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException)

Example 93 with Record

use of nikita.common.model.noark5.v4.Record in project nikita-noark5-core by HiOA-ABI.

the class RegistryEntryImportService method createDocumentDescriptionAssociatedWithRegistryEntry.

@Override
public DocumentDescription createDocumentDescriptionAssociatedWithRegistryEntry(String systemID, DocumentDescription documentDescription) {
    DocumentDescription persistedDocumentDescription = null;
    RegistryEntry registryEntry = registryEntryRepository.findBySystemIdOrderBySystemId(systemID);
    if (registryEntry == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " RegistryEntry, using registryEntrySystemId " + systemID;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    } else {
        TreeSet<Record> records = (TreeSet<Record>) documentDescription.getReferenceRecord();
        if (records == null) {
            records = new TreeSet<>();
            documentDescription.setReferenceRecord(records);
        }
        records.add(registryEntry);
        persistedDocumentDescription = documentDescriptionImportService.save(documentDescription);
    }
    return persistedDocumentDescription;
}
Also used : DocumentDescription(nikita.model.noark5.v4.DocumentDescription) TreeSet(java.util.TreeSet) NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException) Record(nikita.model.noark5.v4.Record) RegistryEntry(nikita.model.noark5.v4.casehandling.RegistryEntry)

Example 94 with Record

use of nikita.common.model.noark5.v4.Record in project nikita-noark5-core by HiOA-ABI.

the class BasicRecordHateoasController method deleteRecordBySystemId.

// Delete a Record identified by systemID
// DELETE [contextPath][api]/arkivstruktur/registrering/{systemId}/
@ApiOperation(value = "Deletes a single Record entity identified by systemID", response = HateoasNoarkObject.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent entity (DocumentDescription or Record) returned", response = HateoasNoarkObject.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.DELETE)
public ResponseEntity<HateoasNoarkObject> deleteRecordBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the record to delete", required = true) @PathVariable("systemID") final String systemID) {
    BasicRecord basicRecord = basicRecordService.findBySystemIdOrderBySystemId(systemID);
    NoarkEntity parentEntity = basicRecord.chooseParent();
    HateoasNoarkObject hateoasNoarkObject;
    if (parentEntity instanceof Series) {
        hateoasNoarkObject = new SeriesHateoas(parentEntity);
        seriesHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
    } else if (parentEntity instanceof File) {
        hateoasNoarkObject = new FileHateoas(parentEntity);
        fileHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
    } else if (parentEntity instanceof Class) {
        hateoasNoarkObject = new ClassHateoas(parentEntity);
        classHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
    } else {
        throw new NikitaException("Internal error. Could not process" + request.getRequestURI());
    }
    basicRecordService.deleteEntity(systemID);
    applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, basicRecord));
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(hateoasNoarkObject);
}
Also used : NikitaException(nikita.util.exceptions.NikitaException) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) Class(nikita.model.noark5.v4.Class) AfterNoarkEntityDeletedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityDeletedEvent) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 95 with Record

use of nikita.common.model.noark5.v4.Record in project nikita-noark5-core by HiOA-ABI.

the class ClassHateoasController method deleteClassBySystemId.

// Delete a Class identified by systemID
// DELETE [contextPath][api]/arkivstruktur/dokumentobjekt/{systemId}/
@ApiOperation(value = "Deletes a single Class entity identified by systemID", response = HateoasNoarkObject.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent entity (DocumentDescription or Record) returned", response = HateoasNoarkObject.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.DELETE)
public ResponseEntity<HateoasNoarkObject> deleteClassBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the class to delete", required = true) @PathVariable("systemID") final String systemID) {
    Class klass = classService.findBySystemIdOrderBySystemId(systemID);
    NoarkEntity parentEntity = klass.chooseParent();
    classService.deleteEntity(systemID);
    HateoasNoarkObject hateoasNoarkObject;
    if (parentEntity instanceof Class) {
        hateoasNoarkObject = new ClassHateoas(parentEntity);
        classHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
    } else if (parentEntity instanceof ClassificationSystem) {
        hateoasNoarkObject = new ClassificationSystemHateoas(parentEntity);
        classificationSystemHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
    } else {
        throw new NikitaException("Internal error. Could process" + request.getRequestURI());
    }
    applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, klass));
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(hateoasNoarkObject);
}
Also used : NikitaException(nikita.util.exceptions.NikitaException) ClassificationSystem(nikita.model.noark5.v4.ClassificationSystem) ClassificationSystemHateoas(nikita.model.noark5.v4.hateoas.ClassificationSystemHateoas) NoarkEntity(nikita.model.noark5.v4.NoarkEntity) ClassHateoas(nikita.model.noark5.v4.hateoas.ClassHateoas) HateoasNoarkObject(nikita.model.noark5.v4.hateoas.HateoasNoarkObject) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) Class(nikita.model.noark5.v4.Class) AfterNoarkEntityDeletedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityDeletedEvent) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

Test (org.junit.Test)60 Record (org.orcid.jaxb.model.record_v2.Record)49 Counted (com.codahale.metrics.annotation.Counted)28 ApiOperation (io.swagger.annotations.ApiOperation)27 ApiResponses (io.swagger.annotations.ApiResponses)27 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)21 Person (org.orcid.jaxb.model.record_v2.Person)20 Record (nikita.model.noark5.v4.Record)19 Email (org.orcid.jaxb.model.record_v2.Email)19 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)18 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)18 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)18 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)18 Address (org.orcid.jaxb.model.record_v2.Address)18 Keyword (org.orcid.jaxb.model.record_v2.Keyword)18 OtherName (org.orcid.jaxb.model.record_v2.OtherName)18 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)18 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)18 Name (org.orcid.jaxb.model.record_v2.Name)17 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)16