Search in sources :

Example 36 with Record

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

the class DocumentDescriptionHateoasController method deleteDocumentDescriptionBySystemId.

// Delete a DocumentDescription identified by systemID
// DELETE [contextPath][api]/arkivstruktur/dokumentobjekt/{systemId}/
@ApiOperation(value = "Deletes a single DocumentDescription entity identified by systemID", response = RecordHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent Fonds returned", response = RecordHateoas.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<RecordHateoas> deleteDocumentDescriptionBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the documentDescription to delete", required = true) @PathVariable("systemID") final String systemID) {
    DocumentDescription documentDescription = documentDescriptionService.findBySystemIdOrderBySystemId(systemID);
    List<Record> record = new ArrayList<>();
    record.addAll(documentDescription.getReferenceRecord());
    documentDescriptionService.deleteEntity(systemID);
    RecordHateoas recordHateoas = new RecordHateoas((List<INikitaEntity>) (List) record);
    recordHateoasHandler.addLinks(recordHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, documentDescription));
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(recordHateoas);
}
Also used : DocumentDescription(nikita.model.noark5.v4.DocumentDescription) INikitaEntity(nikita.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) ArrayList(java.util.ArrayList) RecordHateoas(nikita.model.noark5.v4.hateoas.RecordHateoas) Record(nikita.model.noark5.v4.Record) ArrayList(java.util.ArrayList) List(java.util.List) 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 37 with Record

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

the class RecordHateoasController method createDocumentDescriptionAssociatedWithRecord.

// API - All POST Requests (CRUD - CREATE)
// Create a new DocumentDescription and associate it with the given Record
// POST [contextPath][api]/arkivstruktur/registrering/{systemId}/ny-dokumentobjekt
// http://rel.kxml.no/noark5/v4/api/arkivstruktur/ny-dokumentobjekt/
@ApiOperation(value = "Persists a DocumentDescription object associated with the given Record systemId", notes = "Returns the newly created DocumentDescription object after it was associated with a " + "Record object and persisted to the database", response = DocumentDescriptionHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentDescription " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = DocumentDescriptionHateoas.class), @ApiResponse(code = 201, message = "DocumentDescription " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = DocumentDescriptionHateoas.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 404, message = API_MESSAGE_PARENT_DOES_NOT_EXIST + " of type DocumentDescription"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(method = RequestMethod.POST, value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_DOCUMENT_DESCRIPTION, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<DocumentDescriptionHateoas> createDocumentDescriptionAssociatedWithRecord(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of record to associate the documentDescription with.", required = true) @PathVariable String systemID, @ApiParam(name = "documentDescription", value = "Incoming documentDescription object", required = true) @RequestBody DocumentDescription documentDescription) throws NikitaException {
    DocumentDescription createdDocumentDescription = recordService.createDocumentDescriptionAssociatedWithRecord(systemID, documentDescription);
    DocumentDescriptionHateoas documentDescriptionHateoas = new DocumentDescriptionHateoas(createdDocumentDescription);
    documentDescriptionHateoasHandler.addLinks(documentDescriptionHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, createdDocumentDescription));
    return ResponseEntity.status(HttpStatus.CREATED).eTag(createdDocumentDescription.getVersion().toString()).body(documentDescriptionHateoas);
}
Also used : DocumentDescription(nikita.model.noark5.v4.DocumentDescription) AfterNoarkEntityCreatedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityCreatedEvent) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 38 with Record

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

the class RecordHateoasController method findAllDocumentDescriptionAssociatedWithRecord.

// Retrieve all DocumentDescriptions associated with a Record identified by systemId
// GET [contextPath][api]/arkivstruktur/resgistrering/{systemId}/dokumentbeskrivelse
@ApiOperation(value = "Retrieves a lit of DocumentDescriptions associated with a Record", response = DocumentDescriptionHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentDescription returned", response = DocumentDescriptionHateoas.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 + SLASH + DOCUMENT_DESCRIPTION, method = RequestMethod.GET)
public ResponseEntity<DocumentDescriptionHateoas> findAllDocumentDescriptionAssociatedWithRecord(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the file to retrieve associated Record", required = true) @PathVariable("systemID") final String systemID) {
    Record record = recordService.findBySystemIdOrderBySystemId(systemID);
    if (record == null) {
        throw new NoarkEntityNotFoundException("Could not find File object with systemID " + systemID);
    }
    DocumentDescriptionHateoas documentDescriptionHateoas = new DocumentDescriptionHateoas(new ArrayList<>(record.getReferenceDocumentDescription()));
    documentDescriptionHateoasHandler.addLinks(documentDescriptionHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(documentDescriptionHateoas);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) Record(nikita.model.noark5.v4.Record) NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 39 with Record

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

the class CaseFileHateoasController method createRegistryEntryAssociatedWithFile.

// API - All POST Requests (CRUD - CREATE)
// Create a RegistryEntry entity
// POST [contextPath][api]/casehandling/{systemId}/ny-journalpost
@ApiOperation(value = "Persists a RegistryEntry object associated with the given Series systemId", notes = "Returns the newly created record object after it was associated with a File object and " + "persisted to the database", response = RegistryEntryHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "RegistryEntry " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = RegistryEntryHateoas.class), @ApiResponse(code = 201, message = "RegistryEntry " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = RegistryEntryHateoas.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 404, message = API_MESSAGE_PARENT_DOES_NOT_EXIST + " of type RegistryEntry"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(method = RequestMethod.POST, value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_REGISTRY_ENTRY, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<RegistryEntryHateoas> createRegistryEntryAssociatedWithFile(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemId of file to associate the record with", required = true) @PathVariable("systemID") final String systemID, @ApiParam(name = "RegistryEntry", value = "Incoming registryEntry object", required = true) @RequestBody RegistryEntry registryEntry) throws NikitaException {
    RegistryEntry createdRegistryEntry = caseFileService.createRegistryEntryAssociatedWithCaseFile(systemID, registryEntry);
    RegistryEntryHateoas registryEntryHateoas = new RegistryEntryHateoas(createdRegistryEntry);
    registryEntryHateoasHandler.addLinks(registryEntryHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, createdRegistryEntry));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(createdRegistryEntry.getVersion().toString()).body(registryEntryHateoas);
}
Also used : RegistryEntryHateoas(nikita.model.noark5.v4.hateoas.casehandling.RegistryEntryHateoas) AfterNoarkEntityCreatedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityCreatedEvent) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) RegistryEntry(nikita.model.noark5.v4.casehandling.RegistryEntry) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 40 with Record

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

the class BasicRecordDeserializer method deserialize.

@Override
public BasicRecord deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
    BasicRecord basicRecord = new BasicRecord();
    ObjectNode objectNode = mapper.readTree(jsonParser);
    // Deserialise general record properties
    CommonUtils.Hateoas.Deserialize.deserialiseNoarkSystemIdEntity(basicRecord, objectNode);
    CommonUtils.Hateoas.Deserialize.deserialiseNoarkCreateEntity(basicRecord, objectNode);
    // Deserialize archivedBy
    JsonNode currentNode = objectNode.get(RECORD_ARCHIVED_BY);
    if (null != currentNode) {
        basicRecord.setArchivedBy(currentNode.textValue());
        objectNode.remove(RECORD_ARCHIVED_BY);
    }
    // Deserialize archivedDate
    currentNode = objectNode.get(RECORD_ARCHIVED_DATE);
    if (null != currentNode) {
        try {
            Date parsedDate = Deserialize.parseDateTimeFormat(currentNode.textValue());
            basicRecord.setArchivedDate(parsedDate);
            objectNode.remove(RECORD_ARCHIVED_DATE);
        } catch (ParseException e) {
            throw new NikitaMalformedInputDataException("The basisregistrering you tried to create " + "has a malformed arkivertDato. Make sure format is " + NOARK_DATE_FORMAT_PATTERN);
        }
    }
    // Deserialize general basicRecord properties
    // Deserialize recordId
    currentNode = objectNode.get(BASIC_RECORD_ID);
    if (null != currentNode) {
        basicRecord.setRecordId(currentNode.textValue());
        objectNode.remove(BASIC_RECORD_ID);
    }
    // Deserialize title (not using utils to preserve order)
    currentNode = objectNode.get(TITLE);
    if (null != currentNode) {
        basicRecord.setTitle(currentNode.textValue());
        objectNode.remove(TITLE);
    }
    // Deserialize  officialTitle
    currentNode = objectNode.get(FILE_PUBLIC_TITLE);
    if (null != currentNode) {
        basicRecord.setOfficialTitle(currentNode.textValue());
        objectNode.remove(FILE_PUBLIC_TITLE);
    }
    // Deserialize description
    currentNode = objectNode.get(DESCRIPTION);
    if (null != currentNode) {
        basicRecord.setDescription(currentNode.textValue());
        objectNode.remove(DESCRIPTION);
    }
    CommonUtils.Hateoas.Deserialize.deserialiseDocumentMedium(basicRecord, objectNode);
    CommonUtils.Hateoas.Deserialize.deserialiseAuthor(basicRecord, objectNode);
    // If there are additional throw a malformed input exception
    if (objectNode.size() != 0) {
        throw new NikitaMalformedInputDataException("The basisregistrering you tried to create is malformed. The " + "following fields are not recognised as basisregistrering fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]");
    }
    return basicRecord;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) BasicRecord(nikita.model.noark5.v4.BasicRecord) JsonNode(com.fasterxml.jackson.databind.JsonNode) ParseException(java.text.ParseException) Date(java.util.Date) NikitaMalformedInputDataException(nikita.util.exceptions.NikitaMalformedInputDataException)

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