Search in sources :

Example 71 with Record

use of nikita.model.noark5.v4.Record in project ORCID-Source by ORCID.

the class RecordManagerTest method testGetPublicRecord.

@Test
public void testGetPublicRecord() {
    Record record = RecordManager.getPublicRecord(ORCID);
    assertNotNull(record);
    assertNotNull(record.getActivitiesSummary());
    assertNotNull(record.getPerson());
    Person person = record.getPerson();
    assertNotNull(person);
    assertNotNull(person.getExternalIdentifiers());
    assertNotNull(person.getExternalIdentifiers().getExternalIdentifiers());
    assertEquals(1, person.getExternalIdentifiers().getExternalIdentifiers().size());
    assertEquals(Long.valueOf(13), person.getExternalIdentifiers().getExternalIdentifiers().get(0).getPutCode());
    assertNotNull(person.getResearcherUrls());
    assertNotNull(person.getResearcherUrls().getResearcherUrls());
    assertEquals(1, person.getResearcherUrls().getResearcherUrls().size());
    assertEquals(Long.valueOf(13), person.getResearcherUrls().getResearcherUrls().get(0).getPutCode());
    assertNotNull(person.getOtherNames());
    assertNotNull(person.getOtherNames().getOtherNames());
    assertEquals(1, person.getOtherNames().getOtherNames().size());
    assertEquals(Long.valueOf(13), person.getOtherNames().getOtherNames().get(0).getPutCode());
    assertNotNull(person.getAddresses());
    assertNotNull(person.getAddresses().getAddress());
    assertEquals(1, person.getAddresses().getAddress().size());
    assertEquals(Long.valueOf(9), person.getAddresses().getAddress().get(0).getPutCode());
    assertNotNull(person.getKeywords());
    assertNotNull(person.getKeywords().getKeywords());
    assertEquals(1, person.getKeywords().getKeywords().size());
    assertEquals(Long.valueOf(9), person.getKeywords().getKeywords().get(0).getPutCode());
    assertNotNull(person.getEmails());
    assertNotNull(person.getEmails().getEmails());
    assertEquals(1, person.getEmails().getEmails().size());
    assertEquals("public_0000-0000-0000-0003@test.orcid.org", person.getEmails().getEmails().get(0).getEmail());
    assertNotNull(person.getBiography());
    assertEquals(Visibility.PUBLIC, person.getBiography().getVisibility());
    assertEquals("Biography for 0000-0000-0000-0003", person.getBiography().getContent());
    assertNotNull(person.getName());
    assertNotNull(person.getName().getCreditName());
    assertEquals("Credit Name", person.getName().getCreditName().getContent());
    assertNotNull(person.getName().getFamilyName());
    assertEquals("Family Name", person.getName().getFamilyName().getContent());
    assertNotNull(person.getName().getGivenNames());
    assertEquals("Given Names", person.getName().getGivenNames().getContent());
    assertEquals(Visibility.PUBLIC, person.getName().getVisibility());
    ActivitiesSummary activities = record.getActivitiesSummary();
    assertNotNull(activities.getEducations());
    assertNotNull(activities.getEducations().getSummaries());
    assertEquals(1, activities.getEducations().getSummaries().size());
    assertEquals(Long.valueOf(20), activities.getEducations().getSummaries().get(0).getPutCode());
    assertNotNull(activities.getEmployments());
    assertNotNull(activities.getEmployments().getSummaries());
    assertEquals(1, activities.getEmployments().getSummaries().size());
    assertEquals(Long.valueOf(17), activities.getEmployments().getSummaries().get(0).getPutCode());
    assertNotNull(activities.getFundings());
    assertNotNull(activities.getFundings().getFundingGroup());
    assertEquals(1, activities.getFundings().getFundingGroup().size());
    assertEquals(Long.valueOf(10), activities.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getPutCode());
    assertNotNull(activities.getPeerReviews());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup());
    assertEquals(1, activities.getPeerReviews().getPeerReviewGroup().size());
    assertEquals(Long.valueOf(9), activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getPutCode());
    assertNotNull(activities.getWorks());
    assertNotNull(activities.getWorks().getWorkGroup());
    assertEquals(1, activities.getWorks().getWorkGroup().size());
    assertEquals(Long.valueOf(11), activities.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getPutCode());
}
Also used : Record(org.orcid.jaxb.model.record_v2.Record) Person(org.orcid.jaxb.model.record_v2.Person) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) Test(org.junit.Test) DBUnitTest(org.orcid.test.DBUnitTest)

Example 72 with Record

use of nikita.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
@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.findBySystemId(systemID);
    NoarkEntity parentEntity = basicRecord.chooseParent();
    HateoasNoarkObject hateoasNoarkObject;
    if (parentEntity instanceof Series) {
        hateoasNoarkObject = new SeriesHateoas(parentEntity);
        seriesHateoasHandler.addLinks(hateoasNoarkObject, new Authorisation());
    } else if (parentEntity instanceof File) {
        hateoasNoarkObject = new FileHateoas(parentEntity);
        fileHateoasHandler.addLinks(hateoasNoarkObject, new Authorisation());
    } else if (parentEntity instanceof Class) {
        hateoasNoarkObject = new ClassHateoas(parentEntity);
        classHateoasHandler.addLinks(hateoasNoarkObject, 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.common.util.exceptions.NikitaException) Authorisation(nikita.webapp.security.Authorisation) Class(nikita.common.model.noark5.v4.Class) AfterNoarkEntityDeletedEvent(nikita.webapp.web.events.AfterNoarkEntityDeletedEvent) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 73 with Record

use of nikita.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
@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.findBySystemId(systemID);
    NoarkEntity parentEntity = klass.chooseParent();
    classService.deleteEntity(systemID);
    HateoasNoarkObject hateoasNoarkObject;
    if (parentEntity instanceof Class) {
        hateoasNoarkObject = new ClassHateoas(parentEntity);
        classHateoasHandler.addLinks(hateoasNoarkObject, new Authorisation());
    } else if (parentEntity instanceof ClassificationSystem) {
        hateoasNoarkObject = new ClassificationSystemHateoas(parentEntity);
        classificationSystemHateoasHandler.addLinks(hateoasNoarkObject, 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.common.util.exceptions.NikitaException) ClassificationSystem(nikita.common.model.noark5.v4.ClassificationSystem) ClassificationSystemHateoas(nikita.common.model.noark5.v4.hateoas.ClassificationSystemHateoas) NoarkEntity(nikita.common.model.noark5.v4.NoarkEntity) ClassHateoas(nikita.common.model.noark5.v4.hateoas.ClassHateoas) HateoasNoarkObject(nikita.common.model.noark5.v4.hateoas.HateoasNoarkObject) Authorisation(nikita.webapp.security.Authorisation) Class(nikita.common.model.noark5.v4.Class) AfterNoarkEntityDeletedEvent(nikita.webapp.web.events.AfterNoarkEntityDeletedEvent) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 74 with Record

use of nikita.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
@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.findBySystemId(systemID);
    List<Record> record = new ArrayList<>();
    record.addAll(documentDescription.getReferenceRecord());
    documentDescriptionService.deleteEntity(systemID);
    RecordHateoas recordHateoas = new RecordHateoas((List) record);
    /*RecordHateoas recordHateoas = new RecordHateoas(
                (List<INikitaEntity>)
                        (List)record); */
    // RecordHateoas recordHateoas = new RecordHateoas(
    // (List<INikitaEntity>) (List)record);
    recordHateoasHandler.addLinks(recordHateoas, 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.common.model.noark5.v4.DocumentDescription) Authorisation(nikita.webapp.security.Authorisation) ArrayList(java.util.ArrayList) RecordHateoas(nikita.common.model.noark5.v4.hateoas.RecordHateoas) Record(nikita.common.model.noark5.v4.Record) AfterNoarkEntityDeletedEvent(nikita.webapp.web.events.AfterNoarkEntityDeletedEvent) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 75 with Record

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

the class RecordService method deleteEntity.

// All DELETE operations
@Override
public void deleteEntity(@NotNull String systemID) {
    Record record = getRecordOrThrow(systemID);
    // See issue for a description of why this code was written this way
    // https://github.com/HiOA-ABI/nikita-noark5-core/issues/82
    // Query q = entityManager.createNativeQuery("DELETE FROM fonds_fonds_creator WHERE pk_fonds_creator_id  = :id ;");
    // q.setParameter("id", record.getId());
    // q.executeUpdate();
    entityManager.remove(record);
    entityManager.flush();
    entityManager.clear();
}
Also used : Record(nikita.common.model.noark5.v4.Record)

Aggregations

Test (org.junit.Test)72 Record (org.orcid.jaxb.model.record_v2.Record)62 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)25 Person (org.orcid.jaxb.model.record_v2.Person)22 Email (org.orcid.jaxb.model.record_v2.Email)20 Record (nikita.model.noark5.v4.Record)19 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)19 Address (org.orcid.jaxb.model.record_v2.Address)19 Name (org.orcid.jaxb.model.record_v2.Name)19 OtherName (org.orcid.jaxb.model.record_v2.OtherName)19 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)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 Keyword (org.orcid.jaxb.model.record_v2.Keyword)18 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)18 Record (org.neo4j.driver.v1.Record)17