use of nikita.common.model.noark5.v4.Fonds in project nikita-noark5-core by HiOA-ABI.
the class FondsService method getFondsOrThrow.
// 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 Fonds back. If there is no valid
* Fonds, an exception is thrown
*
* @param fondsSystemId
* @return
*/
protected Fonds getFondsOrThrow(@NotNull String fondsSystemId) {
Fonds fonds = fondsRepository.findBySystemIdOrderBySystemId(fondsSystemId);
if (fonds == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Fonds, using systemId " + fondsSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return fonds;
}
use of nikita.common.model.noark5.v4.Fonds in project nikita-noark5-core by HiOA-ABI.
the class FondsService method createFondsCreatorAssociatedWithFonds.
public FondsCreator createFondsCreatorAssociatedWithFonds(String fondsSystemId, FondsCreator fondsCreator) {
Fonds fonds = fondsRepository.findBySystemIdOrderBySystemId(fondsSystemId);
if (fonds == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Fonds, using fondsSystemId " + fondsSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
fondsCreatorService.createNewFondsCreator(fondsCreator);
fondsCreator.addFonds(fonds);
fonds.getReferenceFondsCreator().add(fondsCreator);
return fondsCreator;
}
use of nikita.common.model.noark5.v4.Fonds in project nikita-noark5-core by HiOA-ABI.
the class FondsService method updateFondsSetFinalized.
public Fonds updateFondsSetFinalized(Long id) {
Fonds fonds = fondsRepository.findById(id);
if (fonds == null) {
// TODO throw Object not find
}
String username = SecurityContextHolder.getContext().getAuthentication().getName();
fonds.setFondsStatus(STATUS_CLOSED);
fonds.setFinalisedDate(new Date());
fonds.setFinalisedBy(username);
return fondsRepository.save(fonds);
}
use of nikita.common.model.noark5.v4.Fonds in project nikita-noark5-core by HiOA-ABI.
the class FondsImportService method createSeriesAssociatedWithFonds.
/**
*
* Persists a new series object to the database. Some values are set in the incoming payload (e.g. title)
* and some are set by the core. owner, createdBy, createdDate are automatically set by the core.
*
* First we try to locate the parent fonds. If the parent fonds does not exist a NoarkEntityNotFoundException
* exception is thrown. Next we check that the fonds does not have children fonds. If it does an
* exception is thrown.
*
* @param fondsSystemId
* @param series
* @return the newly persisted series object
*/
@Override
public Series createSeriesAssociatedWithFonds(String fondsSystemId, Series series) {
Series persistedSeries = null;
Fonds fonds = fondsRepository.findBySystemIdOrderBySystemId(fondsSystemId);
if (fonds == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Fonds, using fondsSystemId " + fondsSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else if (fonds.getReferenceChildFonds() != null && fonds.getReferenceChildFonds().size() > 0) {
String info = INFO_INVALID_STRUCTURE + " Cannot associate series with a fonds that has" + "children fonds " + fondsSystemId;
logger.info(info);
throw new NoarkInvalidStructureException(info, "Fonds", "Series");
} else if (fonds.getFondsStatus() != null && fonds.getFondsStatus().equals(STATUS_CLOSED)) {
String info = INFO_CANNOT_ASSOCIATE_WITH_CLOSED_OBJECT + ". Fonds with fondsSystemId " + fondsSystemId + "has status " + STATUS_CLOSED;
logger.info(info);
throw new NoarkEntityEditWhenClosedException(info);
} else {
series.setReferenceFonds(fonds);
persistedSeries = seriesImportService.save(series);
}
return persistedSeries;
}
use of nikita.common.model.noark5.v4.Fonds 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);
}
Aggregations