Search in sources :

Example 1 with INikitaEntity

use of nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity in project nikita-noark5-core by HiOA-ABI.

the class BasicRecordHateoasController method findAllBasicRecord.

@ApiOperation(value = "Retrieves multiple BasicRecord entities limited by ownership rights", notes = "The field skip" + "tells how many BasicRecord 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 = BasicRecordHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "BasicRecord list found", response = BasicRecordHateoas.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(method = RequestMethod.GET)
public ResponseEntity<BasicRecordHateoas> findAllBasicRecord(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @RequestParam(name = "top", required = false) Integer top, @RequestParam(name = "skip", required = false) Integer skip) {
    BasicRecordHateoas basicRecordHateoas = new BasicRecordHateoas((ArrayList<INikitaEntity>) (ArrayList) basicRecordService.findBasicRecordByOwnerPaginated(top, skip));
    basicRecordHateoasHandler.addLinks(basicRecordHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(basicRecordHateoas);
}
Also used : INikitaEntity(nikita.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) ArrayList(java.util.ArrayList) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 2 with INikitaEntity

use of nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity 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);
}
Also used : DocumentDescription(nikita.model.noark5.v4.DocumentDescription) INikitaEntity(nikita.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) ArrayList(java.util.ArrayList) RecordHateoas(nikita.model.noark5.v4.hateoas.RecordHateoas) Record(nikita.model.noark5.v4.Record) ArrayList(java.util.ArrayList) List(java.util.List) 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 3 with INikitaEntity

use of nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity in project nikita-noark5-core by HiOA-ABI.

the class DocumentObjectHateoasController method findAllDocumentObject.

// Get all documentObject
// GET [contextPath][api]/arkivstruktur/dokumentobjekt/
@ApiOperation(value = "Retrieves multiple DocumentObject entities limited by ownership rights", notes = "The field skip" + "tells how many DocumentObject 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 = DocumentObjectHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentObject list found", response = DocumentObjectHateoas.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(method = RequestMethod.GET, produces = { NOARK5_V4_CONTENT_TYPE_JSON, NOARK5_V4_CONTENT_TYPE_JSON_XML })
public ResponseEntity<DocumentObjectHateoas> findAllDocumentObject(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @RequestParam(name = "top", required = false) Integer top, @RequestParam(name = "skip", required = false) Integer skip, @RequestParam(name = "filter", required = false) String filter) {
    String reg = " ";
    String[] pieces;
    DocumentObjectHateoas documentObjectHateoas = null;
    if (filter != null) {
        pieces = filter.split(reg);
        if (pieces.length == 3 && pieces[1].equalsIgnoreCase("eq")) {
            pieces[2] = pieces[2].replace("\'", "");
            documentObjectHateoas = new DocumentObjectHateoas((ArrayList<INikitaEntity>) (ArrayList) documentObjectService.findDocumentObjectByAnyColumn(pieces[0], pieces[2]));
        }
    }
    if (null == documentObjectHateoas) {
        documentObjectHateoas = new DocumentObjectHateoas((ArrayList<INikitaEntity>) (ArrayList) documentObjectService.findDocumentObjectByOwnerPaginated(top, skip));
    }
    documentObjectHateoasHandler.addLinks(documentObjectHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(documentObjectHateoas);
}
Also used : DocumentObjectHateoas(nikita.model.noark5.v4.hateoas.DocumentObjectHateoas) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) ArrayList(java.util.ArrayList) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 4 with INikitaEntity

use of nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity in project nikita-noark5-core by HiOA-ABI.

the class FondsHateoasController method findAllFonds.

// Get all fonds
// GET [contextPath][api]/arkivstruktur/arkiv/
@ApiOperation(value = "Retrieves multiple Fonds entities limited by ownership rights", notes = "The field skip" + "tells how many Fonds 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 = FondsHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Fonds found", 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(method = RequestMethod.GET, value = FONDS)
public ResponseEntity<FondsHateoas> findAllFonds(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @RequestParam(name = "top", required = false) Integer top, @RequestParam(name = "skip", required = false) Integer skip) {
    FondsHateoas fondsHateoas = new FondsHateoas((ArrayList<INikitaEntity>) (ArrayList) fondsService.findFondsByOwnerPaginated(top, skip));
    fondsHateoasHandler.addLinks(fondsHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(fondsHateoas);
}
Also used : FondsHateoas(nikita.model.noark5.v4.hateoas.FondsHateoas) INikitaEntity(nikita.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) ArrayList(java.util.ArrayList) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 5 with INikitaEntity

use of nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity in project nikita-noark5-core by HiOA-ABI.

the class FondsHateoasController method findAllFonds.

// Find all fonds using elasticsearch ... This is experimental and not part of the standard
// No swagger documentation on this. If we decide to drop db for es, then all re
// GET [contextPath][api]/arkivstruktur/arkiv/all/
@RequestMapping(method = RequestMethod.GET, value = FONDS + SLASH + "all" + SLASH)
public ResponseEntity<FondsHateoas> findAllFonds(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @RequestParam(name = "filter", required = false) String filter) {
    Session session = entityManager.unwrap(Session.class);
    FullTextSession fullTextSession = Search.getFullTextSession(session);
    QueryDescriptor query = ElasticsearchQueries.fromQueryString("title:test fonds");
    List<Fonds> result = fullTextSession.createFullTextQuery(query, Fonds.class).list();
    FondsHateoas fondsHateoas = new FondsHateoas((ArrayList<INikitaEntity>) (ArrayList) result);
    fondsHateoasHandler.addLinks(fondsHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(fondsHateoas);
}
Also used : QueryDescriptor(org.hibernate.search.query.engine.spi.QueryDescriptor) FullTextSession(org.hibernate.search.FullTextSession) FondsHateoas(nikita.model.noark5.v4.hateoas.FondsHateoas) INikitaEntity(nikita.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) ArrayList(java.util.ArrayList) Fonds(nikita.model.noark5.v4.Fonds) FullTextSession(org.hibernate.search.FullTextSession) Session(org.hibernate.Session)

Aggregations

INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)80 Authorisation (nikita.webapp.security.Authorisation)78 List (java.util.List)77 MetadataHateoas (nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas)54 Counted (com.codahale.metrics.annotation.Counted)40 ApiOperation (io.swagger.annotations.ApiOperation)34 ApiResponses (io.swagger.annotations.ApiResponses)34 ArrayList (java.util.ArrayList)20 INikitaEntity (nikita.model.noark5.v4.interfaces.entities.INikitaEntity)19 Timed (com.codahale.metrics.annotation.Timed)16 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)16 Fonds (nikita.common.model.noark5.v4.Fonds)6 NoarkEntityNotFoundException (nikita.common.util.exceptions.NoarkEntityNotFoundException)5 CaseFileHateoas (nikita.common.model.noark5.v4.hateoas.casehandling.CaseFileHateoas)4 DocumentDescription (nikita.common.model.noark5.v4.DocumentDescription)3 Record (nikita.common.model.noark5.v4.Record)3 Fonds (nikita.model.noark5.v4.Fonds)3 FondsCreator (nikita.common.model.noark5.v4.FondsCreator)2 CaseFile (nikita.common.model.noark5.v4.casehandling.CaseFile)2 DocumentObjectHateoas (nikita.common.model.noark5.v4.hateoas.DocumentObjectHateoas)2