use of org.neo4j.driver.v1.Record in project nikita-noark5-core by HiOA-ABI.
the class FileService method createRecordAssociatedWithFile.
@Override
public Record createRecordAssociatedWithFile(String fileSystemId, Record record) {
Record persistedRecord;
File file = fileRepository.findBySystemId(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 = recordService.save(record);
}
return persistedRecord;
}
use of org.neo4j.driver.v1.Record in project nikita-noark5-core by HiOA-ABI.
the class RecordService method getRecordOrThrow.
// All HELPER operations
/**
* Internal helper method. Rather than having a find and try catch in multiple methods, we have it here once.
* If you call this, be aware that you will only ever get a valid Record back. If there is no valid
* Record, an exception is thrown
*
* @param systemID
* @return
*/
protected Record getRecordOrThrow(@NotNull String systemID) {
Record record = recordRepository.findBySystemId(systemID);
if (record == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Record, using systemId " + systemID;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return record;
}
use of org.neo4j.driver.v1.Record in project nikita-noark5-core by HiOA-ABI.
the class RecordService method handleUpdate.
// All UPDATE operations
@Override
public Record handleUpdate(@NotNull String systemId, @NotNull Long version, @NotNull Record incomingRecord) {
Record existingRecord = getRecordOrThrow(systemId);
// Here copy all the values you are allowed to copy ....
// TODO: FIND ALL VALUES
// This might be a class that can only have values set via parameter values rather than request bodies
existingRecord.setVersion(version);
recordRepository.save(existingRecord);
return existingRecord;
}
use of org.neo4j.driver.v1.Record in project nikita-noark5-core by HiOA-ABI.
the class RecordService method createDocumentDescriptionAssociatedWithRecord.
@Override
public DocumentDescription createDocumentDescriptionAssociatedWithRecord(String systemID, DocumentDescription documentDescription) {
DocumentDescription persistedDocumentDescription = null;
Record record = recordRepository.findBySystemId(systemID);
if (record == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Record, using systemID " + systemID;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else {
ArrayList<Record> records = (ArrayList<Record>) documentDescription.getReferenceRecord();
if (records == null) {
records = new ArrayList<>();
documentDescription.setReferenceRecord(records);
}
records.add(record);
List<DocumentDescription> documentDescriptions = record.getReferenceDocumentDescription();
documentDescriptions.add(documentDescription);
persistedDocumentDescription = documentDescriptionService.save(documentDescription);
}
return persistedDocumentDescription;
}
use of org.neo4j.driver.v1.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
@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.findBySystemId(systemID);
NoarkEntity parentEntity = documentObject.chooseParent();
documentObjectService.deleteEntity(systemID);
HateoasNoarkObject hateoasNoarkObject;
if (parentEntity instanceof DocumentDescription) {
hateoasNoarkObject = new DocumentDescriptionHateoas(parentEntity);
documentDescriptionHateoasHandler.addLinks(hateoasNoarkObject, new Authorisation());
} else if (parentEntity instanceof Record) {
hateoasNoarkObject = new RecordHateoas(parentEntity);
recordHateoasHandler.addLinks(hateoasNoarkObject, 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);
}
Aggregations