Search in sources :

Example 86 with Record

use of org.orcid.jaxb.model.record_rc3.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 87 with Record

use of org.orcid.jaxb.model.record_rc3.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 88 with Record

use of org.orcid.jaxb.model.record_rc3.Record in project nikita-noark5-core by HiOA-ABI.

the class DocumentObjectHateoasController method deleteDocumentObjectBySystemId.

// Delete a DocumentObject identified by systemID
// DELETE [contextPath][api]/arkivstruktur/dokumentobjekt/{systemId}/
@ApiOperation(value = "Deletes a single DocumentObject 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> deleteDocumentObjectBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the documentObject to delete", required = true) @PathVariable("systemID") final String systemID) {
    DocumentObject documentObject = documentObjectService.findBySystemIdOrderBySystemId(systemID);
    NoarkEntity parentEntity = documentObject.chooseParent();
    documentObjectService.deleteEntity(systemID);
    HateoasNoarkObject hateoasNoarkObject;
    if (parentEntity instanceof DocumentDescription) {
        hateoasNoarkObject = new DocumentDescriptionHateoas(parentEntity);
        documentDescriptionHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
    } else if (parentEntity instanceof Record) {
        hateoasNoarkObject = new RecordHateoas(parentEntity);
        recordHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
    } else {
        throw new NikitaException("Internal error. Could process" + request.getRequestURI());
    }
    applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, documentObject));
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(hateoasNoarkObject);
}
Also used : NikitaException(nikita.util.exceptions.NikitaException) NoarkEntity(nikita.model.noark5.v4.NoarkEntity) DocumentDescription(nikita.model.noark5.v4.DocumentDescription) HateoasNoarkObject(nikita.model.noark5.v4.hateoas.HateoasNoarkObject) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) DocumentDescriptionHateoas(nikita.model.noark5.v4.hateoas.DocumentDescriptionHateoas) RecordHateoas(nikita.model.noark5.v4.hateoas.RecordHateoas) DocumentObject(nikita.model.noark5.v4.DocumentObject) Record(nikita.model.noark5.v4.Record) 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 89 with Record

use of org.orcid.jaxb.model.record_rc3.Record in project nikita-noark5-core by HiOA-ABI.

the class RecordHateoasController 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<String> 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) {
    Record record = recordService.findBySystemIdOrderBySystemId(systemID);
    /*  NoarkEntity parentEntity = record.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 no.arkivlab.hioa.nikita.webapp.util.exceptions.NikitaException("Internal error. Could not process"
                    + request.getRequestURI());
        } */
    recordService.deleteEntity(systemID);
    applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, record));
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body("{\"status\": \"deleted\"}");
}
Also used : Record(nikita.model.noark5.v4.Record) 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 90 with Record

use of org.orcid.jaxb.model.record_rc3.Record in project nikita-noark5-core by HiOA-ABI.

the class RecordHateoasController method findOneRecordbySystemId.

// API - All GET Requests (CRUD - READ)
// Retrieve a Record identified by a systemId
// GET [contextPath][api]/arkivstruktur/registrering/{systemId}
// http://rel.kxml.no/noark5/v4/api/arkivstruktur/registrering/
@ApiOperation(value = "Retrieves a single Record entity given a systemId", response = Record.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Record returned", response = Record.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.GET)
public ResponseEntity<RecordHateoas> findOneRecordbySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the record to retrieve", required = true) @PathVariable("systemID") final String systemID) {
    Record record = recordService.findBySystemIdOrderBySystemId(systemID);
    RecordHateoas recordHateoas = new RecordHateoas(record);
    recordHateoasHandler.addLinks(recordHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(record.getVersion().toString()).body(recordHateoas);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) Record(nikita.model.noark5.v4.Record) 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)61 Record (org.orcid.jaxb.model.record_v2.Record)49 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 Emails (org.orcid.jaxb.model.record_v2.Emails)16 Addresses (org.orcid.jaxb.model.record_v2.Addresses)15 Biography (org.orcid.jaxb.model.record_v2.Biography)15