Search in sources :

Example 21 with Class

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

the class ClassService method handleUpdate.

// All UPDATE operations
@Override
public Class handleUpdate(@NotNull String systemId, @NotNull Long version, @NotNull Class incomingClass) {
    Class existingClass = getClassOrThrow(systemId);
    // Copy all the values you are allowed to copy ....
    if (null != incomingClass.getDescription()) {
        existingClass.setDescription(incomingClass.getDescription());
    }
    if (null != incomingClass.getTitle()) {
        existingClass.setTitle(incomingClass.getTitle());
    }
    classRepository.save(existingClass);
    return existingClass;
}
Also used : Class(nikita.model.noark5.v4.Class)

Example 22 with Class

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

the class ClassificationSystemService method createClassAssociatedWithClassificationSystem.

@Override
public Class createClassAssociatedWithClassificationSystem(String classificationSystemSystemId, Class klass) {
    Class persistedClass = null;
    ClassificationSystem classificationSystem = classificationSystemRepository.findBySystemIdOrderBySystemId(classificationSystemSystemId);
    if (classificationSystem == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " ClassificationSystem, using classificationSystemSystemId " + classificationSystemSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    } else {
        klass.setReferenceClassificationSystem(classificationSystem);
        persistedClass = classService.save(klass);
    }
    return persistedClass;
}
Also used : ClassificationSystem(nikita.model.noark5.v4.ClassificationSystem) Class(nikita.model.noark5.v4.Class) NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException)

Example 23 with Class

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

the class RecordService method handleUpdate.

// All UPDATE operations
@Override
public Record handleUpdate(@NotNull String systemId, @NotNull Long version, @NotNull Record incomingRecord) {
    Record existingRecord = getRecordOrThrow(systemId);
    // Here copy all the values you are allowed to copy ....
    // TODO: FIND ALL VALUES
    // This might be a class that can only have values set via parameter values rather than request bodies
    existingRecord.setVersion(version);
    recordRepository.save(existingRecord);
    return existingRecord;
}
Also used : Record(nikita.model.noark5.v4.Record)

Example 24 with Class

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

the class BasicRecordHateoasController method deleteRecordBySystemId.

// Delete a Record identified by systemID
// DELETE [contextPath][api]/arkivstruktur/registrering/{systemId}/
@ApiOperation(value = "Deletes a single Record entity identified by systemID", response = HateoasNoarkObject.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent entity (DocumentDescription or Record) returned", response = HateoasNoarkObject.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<HateoasNoarkObject> deleteRecordBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the record to delete", required = true) @PathVariable("systemID") final String systemID) {
    BasicRecord basicRecord = basicRecordService.findBySystemIdOrderBySystemId(systemID);
    NoarkEntity parentEntity = basicRecord.chooseParent();
    HateoasNoarkObject hateoasNoarkObject;
    if (parentEntity instanceof Series) {
        hateoasNoarkObject = new SeriesHateoas(parentEntity);
        seriesHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
    } else if (parentEntity instanceof File) {
        hateoasNoarkObject = new FileHateoas(parentEntity);
        fileHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
    } else if (parentEntity instanceof Class) {
        hateoasNoarkObject = new ClassHateoas(parentEntity);
        classHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
    } else {
        throw new NikitaException("Internal error. Could not process" + request.getRequestURI());
    }
    basicRecordService.deleteEntity(systemID);
    applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, basicRecord));
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(hateoasNoarkObject);
}
Also used : NikitaException(nikita.util.exceptions.NikitaException) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) Class(nikita.model.noark5.v4.Class) 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 25 with Class

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

the class ClassHateoasController method findAllClass.

@ApiOperation(value = "Retrieves multiple Class entities limited by ownership rights", notes = "The field skip" + "tells how many Class 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 = ClassHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Class list found", response = ClassHateoas.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<ClassHateoas> findAllClass(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @RequestParam(name = "top", required = false) Integer top, @RequestParam(name = "skip", required = false) Integer skip) {
    ClassHateoas classHateoas = new ClassHateoas((ArrayList<INikitaEntity>) (ArrayList) classService.findClassByOwnerPaginated(top, skip));
    classHateoasHandler.addLinks(classHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(classHateoas);
}
Also used : ClassHateoas(nikita.model.noark5.v4.hateoas.ClassHateoas) 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)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)18 ApiOperation (io.swagger.annotations.ApiOperation)18 ApiResponses (io.swagger.annotations.ApiResponses)18 Class (nikita.model.noark5.v4.Class)17 Class (nikita.common.model.noark5.v4.Class)16 Timed (com.codahale.metrics.annotation.Timed)9 Authorisation (nikita.webapp.security.Authorisation)9 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)9 ClassHateoas (nikita.common.model.noark5.v4.hateoas.ClassHateoas)7 ClassHateoas (nikita.model.noark5.v4.hateoas.ClassHateoas)7 AfterNoarkEntityDeletedEvent (nikita.webapp.web.events.AfterNoarkEntityDeletedEvent)5 AfterNoarkEntityDeletedEvent (no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityDeletedEvent)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 NikitaException (nikita.common.util.exceptions.NikitaException)4 NoarkEntityNotFoundException (nikita.common.util.exceptions.NoarkEntityNotFoundException)4 NikitaException (nikita.util.exceptions.NikitaException)4 NoarkEntityNotFoundException (nikita.util.exceptions.NoarkEntityNotFoundException)4 Date (java.util.Date)2 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)2