Search in sources :

Example 1 with AdministrativeUnitHateoas

use of nikita.model.noark5.v4.hateoas.admin.AdministrativeUnitHateoas in project nikita-noark5-core by HiOA-ABI.

the class AdministrativeUnitController method findBySystemIdOrderBySystemId.

// Retrieves a given administrativeUnit identified by a systemId
// GET [contextPath][api]/admin/administrativtenhet/{systemId}/
@ApiOperation(value = "Gets administrativeUnit identified by its systemId", notes = "Returns the requested " + " administrativeUnit object", response = AdministrativeUnit.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "AdministrativeUnit " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = AdministrativeUnit.class), @ApiResponse(code = 201, message = "AdministrativeUnit " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = AdministrativeUnit.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 404, message = API_MESSAGE_MALFORMED_PAYLOAD), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR), @ApiResponse(code = 501, message = API_MESSAGE_NOT_IMPLEMENTED) })
@Counted
@Timed
@RequestMapping(value = ADMINISTRATIVE_UNIT + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH, method = RequestMethod.GET)
public ResponseEntity<AdministrativeUnitHateoas> findBySystemIdOrderBySystemId(@PathVariable("systemID") final String systemId, HttpServletRequest request) {
    AdministrativeUnit administrativeUnit = administrativeUnitService.findBySystemIdOrderBySystemId(systemId);
    AdministrativeUnitHateoas adminHateoas = new AdministrativeUnitHateoas(administrativeUnit);
    administrativeUnitHateoasHandler.addLinks(adminHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(administrativeUnit.getVersion().toString()).body(adminHateoas);
}
Also used : AdministrativeUnit(nikita.model.noark5.v4.admin.AdministrativeUnit) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) AdministrativeUnitHateoas(nikita.model.noark5.v4.hateoas.admin.AdministrativeUnitHateoas) 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 AdministrativeUnitHateoas

use of nikita.model.noark5.v4.hateoas.admin.AdministrativeUnitHateoas in project nikita-noark5-core by HiOA-ABI.

the class AdministrativeUnitHateoasSerializer method serializeNoarkEntity.

@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject administrativeUnitHateoas, JsonGenerator jgen) throws IOException {
    AdministrativeUnit administrativeUnit = (AdministrativeUnit) noarkSystemIdEntity;
    jgen.writeStartObject();
    CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, administrativeUnit);
    if (administrativeUnit.getAdministrativeUnitName() != null) {
        jgen.writeStringField(ADMINISTRATIVE_UNIT_NAME, administrativeUnit.getAdministrativeUnitName());
    }
    if (administrativeUnit.getShortName() != null) {
        jgen.writeStringField(SHORT_NAME, administrativeUnit.getShortName());
    }
    CommonUtils.Hateoas.Serialize.printCreateEntity(jgen, administrativeUnit);
    CommonUtils.Hateoas.Serialize.printFinaliseEntity(jgen, administrativeUnit);
    if (administrativeUnit.getAdministrativeUnitStatus() != null) {
        jgen.writeStringField(ADMINISTRATIVE_UNIT_STATUS, administrativeUnit.getAdministrativeUnitStatus());
    }
    if (administrativeUnit.getParentAdministrativeUnit() != null) {
        jgen.writeStringField(ADMINISTRATIVE_UNIT_PARENT_REFERENCE, administrativeUnit.getParentAdministrativeUnit().getSystemId());
    }
    CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, administrativeUnitHateoas.getLinks(administrativeUnit));
    jgen.writeEndObject();
}
Also used : AdministrativeUnit(nikita.model.noark5.v4.admin.AdministrativeUnit)

Example 3 with AdministrativeUnitHateoas

use of nikita.model.noark5.v4.hateoas.admin.AdministrativeUnitHateoas in project nikita-noark5-core by HiOA-ABI.

the class AdministrativeUnitController method createAdministrativeUnit.

// API - All POST Requests (CRUD - CREATE)
// Creates a new administrativtenhet
// POST [contextPath][api]/admin/ny-administrativtenhet
@ApiOperation(value = "Persists a new AdministrativeUnit object", notes = "Returns the newly" + " created AdministrativeUnit object after it is persisted to the database", response = AdministrativeUnit.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "AdministrativeUnit " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = AdministrativeUnit.class), @ApiResponse(code = 201, message = "AdministrativeUnit " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = AdministrativeUnit.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 404, message = API_MESSAGE_MALFORMED_PAYLOAD), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR), @ApiResponse(code = 501, message = API_MESSAGE_NOT_IMPLEMENTED) })
@Counted
@Timed
@RequestMapping(method = RequestMethod.POST, value = NEW_ADMINISTRATIVE_UNIT)
public ResponseEntity<AdministrativeUnitHateoas> createAdministrativeUnit(HttpServletRequest request, @RequestBody AdministrativeUnit administrativeUnit) throws NikitaException {
    administrativeUnitService.createNewAdministrativeUnit(administrativeUnit);
    AdministrativeUnitHateoas adminHateoas = new AdministrativeUnitHateoas(administrativeUnit);
    administrativeUnitHateoasHandler.addLinks(adminHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(administrativeUnit.getVersion().toString()).body(adminHateoas);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) AdministrativeUnitHateoas(nikita.model.noark5.v4.hateoas.admin.AdministrativeUnitHateoas) 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 AdministrativeUnitHateoas

use of nikita.model.noark5.v4.hateoas.admin.AdministrativeUnitHateoas in project nikita-noark5-core by HiOA-ABI.

the class AdministrativeUnitController method findAll.

// API - All GET Requests (CRUD - READ)
// Retrieves all administrativeUnit
// GET [contextPath][api]/admin/administrativtenhet/
@ApiOperation(value = "Retrieves all AdministrativeUnit ", response = AdministrativeUnit.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "AdministrativeUnit found", response = AdministrativeUnit.class), @ApiResponse(code = 404, message = "No AdministrativeUnit found"), @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 = ADMINISTRATIVE_UNIT)
public ResponseEntity<AdministrativeUnitHateoas> findAll(HttpServletRequest request) {
    AdministrativeUnitHateoas adminHateoas = new AdministrativeUnitHateoas((ArrayList<INikitaEntity>) (ArrayList) administrativeUnitService.findAll());
    administrativeUnitHateoasHandler.addLinks(adminHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(adminHateoas);
}
Also used : INikitaEntity(nikita.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) ArrayList(java.util.ArrayList) AdministrativeUnitHateoas(nikita.model.noark5.v4.hateoas.admin.AdministrativeUnitHateoas) 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 AdministrativeUnitHateoas

use of nikita.model.noark5.v4.hateoas.admin.AdministrativeUnitHateoas in project nikita-noark5-core by HiOA-ABI.

the class AdministrativeUnitController method getAdministrativeUnitTemplate.

// Create a suggested administrativeUnit(like a template) with default values (nothing persisted)
// GET [contextPath][api]/admin/ny-administrativtenhet
@ApiOperation(value = "Creates a suggested AdministrativeUnit", response = AdministrativeUnit.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "AdministrativeUnit codes found", response = AdministrativeUnit.class), @ApiResponse(code = 404, message = "No AdministrativeUnit found"), @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 = NEW_ADMINISTRATIVE_UNIT)
public ResponseEntity<AdministrativeUnitHateoas> getAdministrativeUnitTemplate(HttpServletRequest request) {
    AdministrativeUnit administrativeUnit = new AdministrativeUnit();
    administrativeUnit.setShortName("kortnavn på administrativtenhet");
    administrativeUnit.setAdministrativeUnitName("Formell navn på administrativtenhet");
    AdministrativeUnitHateoas adminHateoas = new AdministrativeUnitHateoas(administrativeUnit);
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(adminHateoas);
}
Also used : AdministrativeUnit(nikita.model.noark5.v4.admin.AdministrativeUnit) AdministrativeUnitHateoas(nikita.model.noark5.v4.hateoas.admin.AdministrativeUnitHateoas) 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)5 Timed (com.codahale.metrics.annotation.Timed)5 ApiOperation (io.swagger.annotations.ApiOperation)5 ApiResponses (io.swagger.annotations.ApiResponses)5 AdministrativeUnitHateoas (nikita.model.noark5.v4.hateoas.admin.AdministrativeUnitHateoas)5 AdministrativeUnit (nikita.model.noark5.v4.admin.AdministrativeUnit)4 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)4 ArrayList (java.util.ArrayList)1 INikitaEntity (nikita.model.noark5.v4.interfaces.entities.INikitaEntity)1