use of nikita.common.model.noark5.v4.DocumentDescription in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryHateoasController method deleteRecordBySystemId.
// Delete a Record identified by systemID
// DELETE [contextPath][api]/casehandling/journalpost/{systemId}/
@ApiOperation(value = "Deletes a single RegistryEntry entity identified by systemID", response = String.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent entity (DocumentDescription or Record) returned", response = String.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<String> deleteRecordBySystemId(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemID of the record to delete", required = true) @PathVariable("systemID") final String systemID) {
RegistryEntry registryEntry = registryEntryService.findBySystemId(systemID);
registryEntryService.deleteEntity(systemID);
applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, registryEntry));
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(CommonUtils.WebUtils.getSuccessStatusStringForDelete());
}
use of nikita.common.model.noark5.v4.DocumentDescription in project nikita-noark5-core by HiOA-ABI.
the class DocumentDescriptionService method deleteEntity.
// All DELETE operations
@Override
public void deleteEntity(@NotNull String documentDescriptionSystemId) {
// See issue for a description of why this code was written this way
// https://github.com/HiOA-ABI/nikita-noark5-core/issues/82
DocumentDescription documentDescription = getDocumentDescriptionOrThrow(documentDescriptionSystemId);
Query q = entityManager.createNativeQuery("DELETE FROM record_document_description WHERE F_PK_DOCUMENT_DESCRIPTION_ID = :id ;");
q.setParameter("id", documentDescription.getId());
q.executeUpdate();
entityManager.remove(documentDescription);
entityManager.flush();
entityManager.clear();
}
use of nikita.common.model.noark5.v4.DocumentDescription in project nikita-noark5-core by HiOA-ABI.
the class DocumentDescriptionService method createDocumentObjectAssociatedWithDocumentDescription.
// All CREATE operations
@Override
public DocumentObject createDocumentObjectAssociatedWithDocumentDescription(String documentDescriptionSystemId, DocumentObject documentObject) {
DocumentObject persistedDocumentObject = null;
DocumentDescription documentDescription = documentDescriptionRepository.findBySystemIdOrderBySystemId(documentDescriptionSystemId);
if (documentDescription == null) {
String info = INFO_CANNOT_FIND_OBJECT + " DocumentDescription, using documentDescriptionSystemId " + documentDescriptionSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else {
documentObject.setReferenceDocumentDescription(documentDescription);
Set<DocumentObject> documentObjects = documentDescription.getReferenceDocumentObject();
documentObjects.add(documentObject);
persistedDocumentObject = documentObjectService.save(documentObject);
}
return persistedDocumentObject;
}
use of nikita.common.model.noark5.v4.DocumentDescription in project nikita-noark5-core by HiOA-ABI.
the class DocumentDescriptionService method updateDocumentDescriptionSetFinalized.
public DocumentDescription updateDocumentDescriptionSetFinalized(Long id) {
DocumentDescription documentDescription = documentDescriptionRepository.findById(id);
if (documentDescription == null) {
// TODO throw Object not find
}
String username = SecurityContextHolder.getContext().getAuthentication().getName();
return documentDescriptionRepository.save(documentDescription);
}
use of nikita.common.model.noark5.v4.DocumentDescription in project nikita-noark5-core by HiOA-ABI.
the class DocumentDescriptionService method getDocumentDescriptionOrThrow.
// 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 DocumentDescription back. If there is no valid
* DocumentDescription, an exception is thrown
*
* @param documentDescriptionSystemId
* @return
*/
protected DocumentDescription getDocumentDescriptionOrThrow(@NotNull String documentDescriptionSystemId) {
DocumentDescription documentDescription = documentDescriptionRepository.findBySystemIdOrderBySystemId(documentDescriptionSystemId);
if (documentDescription == null) {
String info = INFO_CANNOT_FIND_OBJECT + " DocumentDescription, using systemId " + documentDescriptionSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return documentDescription;
}
Aggregations