use of nikita.common.model.noark5.v4.FondsCreator in project nikita-noark5-core by HiOA-ABI.
the class FondsService method findSingleFonds.
/**
* Retrieve a list of StorageLocation objects associated with a given Fonds
* from the database. First we try to locate the Fonds object. If the
* Fonds object does not exist a NoarkEntityNotFoundException exception
* is thrown that the caller has to deal with.
*
* If any StorageLocation objects exist, they are wrapped in a
* StorageLocationHateoas object and returned to the caller.
*
* @param fondsSystemId The systemId of the Fonds object that you want to
* retrieve associated StorageLocation objects
*
* @return the newly persisted fondsCreator object wrapped as a
* StorageLocationHateoas object
*/
/*@Override
TODO: Finish implementing this.
public StorageLocationHateoas findStorageLocationAssociatedWithFonds(
@NotNull String fondsSystemId) {
Fonds fonds = getFondsOrThrow(fondsSystemId);
StorageLocationHateoas stroageLocationHateoas = new
StorageLocationHateoas((List<INikitaEntity>)
(List) fonds.getReferenceStorageLocation());
fondsCreatorHateoasHandler.addLinks(stroageLocationHateoas,
new Authorisation());
return stroageLocationHateoas;
} */
/**
* Retrieve a single Fonds objects from the database.
*
* @param fondsSystemId The systemId of the Fonds object you wish to
* retrieve
* @return the Fonds object wrapped as a FondsHateoas object
*/
@Override
public FondsHateoas findSingleFonds(String fondsSystemId) {
Fonds existingFonds = getFondsOrThrow(fondsSystemId);
FondsHateoas fondsHateoas = new FondsHateoas(fondsRepository.save(existingFonds));
fondsHateoasHandler.addLinks(fondsHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, existingFonds));
return fondsHateoas;
}
use of nikita.common.model.noark5.v4.FondsCreator in project nikita-noark5-core by HiOA-ABI.
the class FondsService method createFondsCreatorAssociatedWithFonds.
/**
* Persists a new FondsCreator object to the database. Some values are set
* in the incoming payload (e.g. fonds_creator_name) and some are set by
* the core. owner,createdBy, createdDate are automatically set by the core.
* <p>
* First we try to locate the fonds to associate the FondsCreator with. If
* the fonds does not exist a NoarkEntityNotFoundException exception is
* thrown. After that we check that the Fonds object is not already closed.
*
* @param fondsSystemId The systemId of the fonds object you wish to
* associate the fondsCreator object with
* @param fondsCreator incoming fondsCreator object with some values set
* @return the newly persisted fondsCreator object wrapped as a
* FondsCreatorHateoas object
*/
@Override
public FondsCreatorHateoas createFondsCreatorAssociatedWithFonds(@NotNull String fondsSystemId, @NotNull FondsCreator fondsCreator) {
Fonds fonds = getFondsOrThrow(fondsSystemId);
checkFondsNotClosed(fonds);
fondsCreatorService.createNewFondsCreator(fondsCreator);
// add references to objects in both directions
fondsCreator.addFonds(fonds);
fonds.getReferenceFondsCreator().add(fondsCreator);
// create the hateoas object with links
FondsCreatorHateoas fondsCreatorHateoas = new FondsCreatorHateoas(fondsCreator);
fondsCreatorHateoasHandler.addLinks(fondsCreatorHateoas, new Authorisation());
return fondsCreatorHateoas;
}
use of nikita.common.model.noark5.v4.FondsCreator in project nikita-noark5-core by HiOA-ABI.
the class FondsCreatorDeserializer method deserialize.
@Override
public FondsCreator deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
StringBuilder errors = new StringBuilder();
FondsCreator fondsCreator = new FondsCreator();
ObjectNode objectNode = mapper.readTree(jsonParser);
// Deserialise general properties
CommonUtils.Hateoas.Deserialize.deserialiseFondsCreator(fondsCreator, objectNode, errors);
// If there are additional throw a malformed input exception
if (objectNode.size() != 0) {
errors.append("The arkivskaper you tried to create is malformed. The " + "following fields are not recognised as arkivskaper fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]. ");
}
if (0 < errors.length())
throw new NikitaMalformedInputDataException(errors.toString());
return fondsCreator;
}
use of nikita.common.model.noark5.v4.FondsCreator in project nikita-noark5-core by HiOA-ABI.
the class FondsCreatorHateoasSerializer method serializeNoarkEntity.
@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject fondsCreatorHateoas, JsonGenerator jgen) throws IOException {
FondsCreator fondsCreator = (FondsCreator) noarkSystemIdEntity;
jgen.writeStartObject();
CommonUtils.Hateoas.Serialize.printFondsCreator(jgen, fondsCreator);
CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, fondsCreatorHateoas.getLinks(fondsCreator));
jgen.writeEndObject();
}
use of nikita.common.model.noark5.v4.FondsCreator in project nikita-noark5-core by HiOA-ABI.
the class FondsCreatorHateoasController method findAllFondsCreator.
// Get all FondsCreator
// GET [contextPath][api]/arkivstruktur/arkivskaper/
@ApiOperation(value = "Retrieves multiple FondsCreator entities limited by ownership rights", notes = "The field skip" + "tells how many FondsCreator rows of the result set to ignore (starting at 0), while top tells how many rows" + " after skip to return. Note if the value of top is greater than system value " + " nikita-noark5-core.pagination.maxPageSize, then nikita-noark5-core.pagination.maxPageSize is used. ", response = FondsCreatorHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "FondsCreator found", response = FondsCreatorHateoas.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(method = RequestMethod.GET, value = FONDS_CREATOR)
public ResponseEntity<FondsCreatorHateoas> findAllFondsCreator(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @RequestParam(name = "top", required = false) Integer top, @RequestParam(name = "skip", required = false) Integer skip) {
String ownedBy = SecurityContextHolder.getContext().getAuthentication().getName();
FondsCreatorHateoas fondsCreatorHateoas = new FondsCreatorHateoas((List<INikitaEntity>) (List) fondsCreatorService.findByOwnedBy(ownedBy));
fondsCreatorHateoasHandler.addLinks(fondsCreatorHateoas, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(fondsCreatorHateoas);
}
Aggregations