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());
}
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);
}
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);
}
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);
}
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();
}
Aggregations