Search in sources :

Example 11 with FondsCreator

use of nikita.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();
}
Also used : FondsCreator(nikita.model.noark5.v4.FondsCreator)

Example 12 with FondsCreator

use of nikita.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 13 with FondsCreator

use of nikita.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 14 with FondsCreator

use of nikita.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 15 with FondsCreator

use of nikita.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)

Aggregations

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