Search in sources :

Example 26 with FondsCreator

use of nikita.common.model.noark5.v4.FondsCreator in project nikita-noark5-core by HiOA-ABI.

the class FondsCreatorService method getFondsCreatorOrThrow.

// 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 FondsCreator back. If there is no valid
     * FondsCreator, an exception is thrown
     *
     * @param fondsCreatorSystemId
     * @return
     */
protected FondsCreator getFondsCreatorOrThrow(@NotNull String fondsCreatorSystemId) {
    FondsCreator fondsCreator = fondsCreatorRepository.findBySystemIdOrderBySystemId(fondsCreatorSystemId);
    if (fondsCreator == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " FondsCreator, using systemId " + fondsCreatorSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    }
    return fondsCreator;
}
Also used : NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException) FondsCreator(nikita.model.noark5.v4.FondsCreator)

Example 27 with FondsCreator

use of nikita.common.model.noark5.v4.FondsCreator in project nikita-noark5-core by HiOA-ABI.

the class CorrespondencePartService method deleteCorrespondencePartInternal.

@Override
public void deleteCorrespondencePartInternal(@NotNull String code) {
    CorrespondencePartInternal correspondencePartInternal = (CorrespondencePartInternal) getCorrespondencePartOrThrow(code);
    /*
        // Disassociate the link between Fonds and FondsCreator
        // https://github.com/HiOA-ABI/nikita-noark5-core/issues/82
        Query q = entityManager.createNativeQuery("DELETE FROM fonds_fonds_creator WHERE f_pk_fonds_id  = :id ;");
        q.setParameter("id", fonds.getId());
        q.executeUpdate();
        entityManager.remove(fonds);
        entityManager.flush();
        entityManager.clear();*/
    correspondencePartRepository.delete(correspondencePartInternal);
}
Also used : CorrespondencePartInternal(nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal)

Example 28 with FondsCreator

use of nikita.common.model.noark5.v4.FondsCreator in project nikita-noark5-core by HiOA-ABI.

the class FondsCreatorHateoasController method findOne.

// API - All GET Requests (CRUD - READ)
// Get a FondsCreator identified by a systemId
// GET [contextPath][api]/arkivstruktur/arkivskaper/{systemId}
@ApiOperation(value = "Retrieves a single FondsCreator entity given a systemId", response = FondsCreator.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "FondsCreator returned", response = FondsCreator.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 = FONDS_CREATOR + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<FondsCreatorHateoas> findOne(HttpServletRequest request, @ApiParam(name = "systemId", value = "systemId of FondsCreator to retrieve.", required = true) @PathVariable("systemID") final String fondsCreatorSystemId) {
    FondsCreator fondsCreator = fondsCreatorService.findBySystemIdOrderBySystemId(fondsCreatorSystemId);
    if (fondsCreator == null) {
        throw new NoarkEntityNotFoundException("Could not find FondsCreator object with systemID " + fondsCreatorSystemId);
    }
    FondsCreatorHateoas fondsCreatorHateoas = new FondsCreatorHateoas(fondsCreator);
    fondsCreatorHateoasHandler.addLinks(fondsCreatorHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(fondsCreator.getVersion().toString()).body(fondsCreatorHateoas);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException) FondsCreatorHateoas(nikita.model.noark5.v4.hateoas.FondsCreatorHateoas) FondsCreator(nikita.model.noark5.v4.FondsCreator) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 29 with FondsCreator

use of nikita.common.model.noark5.v4.FondsCreator in project nikita-noark5-core by HiOA-ABI.

the class FondsCreatorHateoasController method deleteSeriesBySystemId.

// Delete a FondsCreator identified by systemID
// DELETE [contextPath][api]/arkivstruktur/arkivskaper/{systemId}/
@ApiOperation(value = "Deletes a single FondsCreator entity identified by systemID", response = FondsHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent Fonds returned", response = FondsHateoas.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 + FONDS_CREATOR + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.DELETE)
public ResponseEntity<String> deleteSeriesBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the fondsCreator to delete", required = true) @PathVariable("systemID") final String seriesSystemId) {
    FondsCreator fondsCreator = fondsCreatorService.findBySystemIdOrderBySystemId(seriesSystemId);
    fondsCreatorService.deleteEntity(seriesSystemId);
    applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, fondsCreator));
    /*        List<Fonds> fonds = new ArrayList<>();
        fonds.addAll(fondsCreator.getReferenceFonds());
        FondsHateoas fondsHateoas = new FondsHateoas((List<INikitaEntity>) (List)fonds);
        fondsHateoasHandler.addLinks(fondsHateoas, request, new Authorisation());
  */
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body("{\"status\" : \"Success\"}");
}
Also used : FondsCreator(nikita.model.noark5.v4.FondsCreator) AfterNoarkEntityDeletedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityDeletedEvent) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 30 with FondsCreator

use of nikita.common.model.noark5.v4.FondsCreator in project nikita-noark5-core by HiOA-ABI.

the class FondsCreatorHateoasController method createFondsCreator.

// API - All POST Requests (CRUD - CREATE)
// Create a new FondsCreator
// POST [contextPath][api]/arkivstruktur/ny-arkivskaper
@ApiOperation(value = "Persists a FondsCreator object", notes = "Returns the newly" + " created FondsCreator object after it is persisted to the database", response = FondsCreatorHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "FondsCreator " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = FondsCreatorHateoas.class), @ApiResponse(code = 201, message = "FondsCreator " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = FondsCreatorHateoas.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 404, message = API_MESSAGE_PARENT_DOES_NOT_EXIST + " of type FondsCreator"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(method = { RequestMethod.POST }, value = NEW_FONDS_CREATOR, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<FondsCreatorHateoas> createFondsCreator(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "FondsCreator", value = "Incoming FondsCreator object", required = true) @RequestBody FondsCreator fondsCreator) throws NikitaException {
    fondsCreatorService.createNewFondsCreator(fondsCreator);
    FondsCreatorHateoas fondsCreatorHateoas = new FondsCreatorHateoas(fondsCreator);
    fondsCreatorHateoasHandler.addLinks(fondsCreatorHateoas, request, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, fondsCreator));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(fondsCreator.getVersion().toString()).body(fondsCreatorHateoas);
}
Also used : AfterNoarkEntityCreatedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityCreatedEvent) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) FondsCreatorHateoas(nikita.model.noark5.v4.hateoas.FondsCreatorHateoas) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)16 ApiOperation (io.swagger.annotations.ApiOperation)16 ApiResponses (io.swagger.annotations.ApiResponses)16 FondsCreator (nikita.model.noark5.v4.FondsCreator)11 FondsCreator (nikita.common.model.noark5.v4.FondsCreator)10 Authorisation (nikita.webapp.security.Authorisation)9 Timed (com.codahale.metrics.annotation.Timed)8 FondsCreatorHateoas (nikita.common.model.noark5.v4.hateoas.FondsCreatorHateoas)8 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)7 FondsCreatorHateoas (nikita.model.noark5.v4.hateoas.FondsCreatorHateoas)6 Query (javax.persistence.Query)4 Fonds (nikita.common.model.noark5.v4.Fonds)4 TypedQuery (javax.persistence.TypedQuery)3 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)3 NoarkEntityNotFoundException (nikita.util.exceptions.NoarkEntityNotFoundException)3 AfterNoarkEntityUpdatedEvent (nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 List (java.util.List)2 FondsHateoas (nikita.common.model.noark5.v4.hateoas.FondsHateoas)2 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)2