Search in sources :

Example 6 with ClassificationSystem

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

the class ClassificationSystemHateoasController method deleteClassificationSystemBySystemId.

// Delete a ClassificationSystem identified by systemID
// DELETE [contextPath][api]/arkivstruktur/klassifikasjonsystem/{systemId}/
@ApiOperation(value = "Deletes a single ClassificationSystem entity identified by systemID", response = FondsStructureDetails.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent ApplicationDetails returned", response = FondsStructureDetails.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(value = SLASH + CLASSIFICATION_SYSTEM + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.DELETE)
public ResponseEntity<FondsStructureDetails> deleteClassificationSystemBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the ClassificationSystem to delete", required = true) @PathVariable("systemID") final String systemID) {
    ClassificationSystem classificationSystem = classificationSystemService.findBySystemId(systemID);
    classificationSystemService.deleteEntity(systemID);
    applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, classificationSystem));
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(applicationService.getFondsStructureDetails());
}
Also used : ClassificationSystem(nikita.common.model.noark5.v4.ClassificationSystem) AfterNoarkEntityDeletedEvent(nikita.webapp.web.events.AfterNoarkEntityDeletedEvent) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 7 with ClassificationSystem

use of nikita.common.model.noark5.v4.ClassificationSystem 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.findBySystemId(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.common.model.noark5.v4.ClassificationSystem) Class(nikita.common.model.noark5.v4.Class) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException)

Example 8 with ClassificationSystem

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

the class ClassificationSystemService method findClassificationSystemByOwnerPaginated.

// All READ operations
@Override
public List<ClassificationSystem> findClassificationSystemByOwnerPaginated(Integer top, Integer skip) {
    if (top == null || top > maxPageSize) {
        top = maxPageSize;
    }
    if (skip == null) {
        skip = 0;
    }
    String loggedInUser = SecurityContextHolder.getContext().getAuthentication().getName();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<ClassificationSystem> criteriaQuery = criteriaBuilder.createQuery(ClassificationSystem.class);
    Root<ClassificationSystem> from = criteriaQuery.from(ClassificationSystem.class);
    CriteriaQuery<ClassificationSystem> select = criteriaQuery.select(from);
    criteriaQuery.where(criteriaBuilder.equal(from.get("ownedBy"), loggedInUser));
    TypedQuery<ClassificationSystem> typedQuery = entityManager.createQuery(select);
    typedQuery.setFirstResult(skip);
    typedQuery.setMaxResults(top);
    return typedQuery.getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) ClassificationSystem(nikita.common.model.noark5.v4.ClassificationSystem)

Example 9 with ClassificationSystem

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

the class ClassificationSystemService method handleUpdate.

// All UPDATE operations
@Override
public ClassificationSystem handleUpdate(@NotNull String systemId, @NotNull Long version, @NotNull ClassificationSystem incomingClassificationSystem) {
    ClassificationSystem existingClassificationSystem = getClassificationSystemOrThrow(systemId);
    // Copy all the values you are allowed to copy ....
    if (null != incomingClassificationSystem.getDescription()) {
        existingClassificationSystem.setDescription(incomingClassificationSystem.getDescription());
    }
    if (null != incomingClassificationSystem.getTitle()) {
        existingClassificationSystem.setTitle(incomingClassificationSystem.getTitle());
    }
    existingClassificationSystem.setVersion(version);
    classificationSystemRepository.save(existingClassificationSystem);
    return existingClassificationSystem;
}
Also used : ClassificationSystem(nikita.common.model.noark5.v4.ClassificationSystem)

Example 10 with ClassificationSystem

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

the class ClassifiactionSystemDeserializer method deserialize.

@Override
public ClassificationSystem deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
    StringBuilder errors = new StringBuilder();
    ClassificationSystem classificationSystem = new ClassificationSystem();
    ObjectNode objectNode = mapper.readTree(jsonParser);
    // Deserialise general properties
    CommonUtils.Hateoas.Deserialize.deserialiseNoarkEntity(classificationSystem, objectNode, errors);
    // If there are additional throw a malformed input exception
    if (objectNode.size() != 0) {
        errors.append("The klassifikasjonssystem you tried to create is " + "malformed. The following fields are not recognised as klassifikasjonssystem fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]. ");
    }
    if (0 < errors.length())
        throw new NikitaMalformedInputDataException(errors.toString());
    return classificationSystem;
}
Also used : ClassificationSystem(nikita.common.model.noark5.v4.ClassificationSystem) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) NikitaMalformedInputDataException(nikita.common.util.exceptions.NikitaMalformedInputDataException)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)14 ApiOperation (io.swagger.annotations.ApiOperation)14 ApiResponses (io.swagger.annotations.ApiResponses)14 ClassificationSystem (nikita.common.model.noark5.v4.ClassificationSystem)11 ClassificationSystem (nikita.model.noark5.v4.ClassificationSystem)11 Timed (com.codahale.metrics.annotation.Timed)7 Authorisation (nikita.webapp.security.Authorisation)7 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)7 ClassificationSystemHateoas (nikita.common.model.noark5.v4.hateoas.ClassificationSystemHateoas)5 ClassificationSystemHateoas (nikita.model.noark5.v4.hateoas.ClassificationSystemHateoas)5 Class (nikita.common.model.noark5.v4.Class)4 Class (nikita.model.noark5.v4.Class)4 ClassHateoas (nikita.common.model.noark5.v4.hateoas.ClassHateoas)3 NoarkEntityNotFoundException (nikita.common.util.exceptions.NoarkEntityNotFoundException)3 ClassHateoas (nikita.model.noark5.v4.hateoas.ClassHateoas)3 NoarkEntityNotFoundException (nikita.util.exceptions.NoarkEntityNotFoundException)3 AfterNoarkEntityCreatedEvent (nikita.webapp.web.events.AfterNoarkEntityCreatedEvent)3 AfterNoarkEntityCreatedEvent (no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityCreatedEvent)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)2