Search in sources :

Example 6 with Series

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

the class SeriesService method updateSeriesSetTitle.

public Series updateSeriesSetTitle(Long id, String newTitle) {
    Series series = seriesRepository.findById(id);
    if (series == null) {
    // TODO throw Object not find
    } else if (series.getSeriesStatus().equals(STATUS_CLOSED)) {
    // TODO throw Object finalises, cannot be edited
    }
    series.setTitle(newTitle);
    return seriesRepository.save(series);
}
Also used : Series(nikita.model.noark5.v4.Series)

Example 7 with Series

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

the class SeriesService method updateSeriesSetFinalized.

public Series updateSeriesSetFinalized(Long id) {
    Series series = seriesRepository.findById(id);
    if (series == null) {
    // TODO throw Object not find
    }
    String username = SecurityContextHolder.getContext().getAuthentication().getName();
    series.setSeriesStatus(STATUS_CLOSED);
    series.setFinalisedDate(new Date());
    series.setFinalisedBy(username);
    return seriesRepository.save(series);
}
Also used : Series(nikita.model.noark5.v4.Series) Date(java.util.Date)

Example 8 with Series

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

the class FondsImportService method createSeriesAssociatedWithFonds.

/**
     *
     * Persists a new series object to the database. Some values are set in the incoming payload (e.g. title)
     * and some are set by the core. owner, createdBy, createdDate are automatically set by the core.
     *
     * First we try to locate the parent fonds. If the parent fonds does not exist a NoarkEntityNotFoundException
     * exception is thrown. Next  we check that the fonds does not have children fonds. If it does an
     * exception is thrown.
     *
     * @param fondsSystemId
     * @param series
     * @return the newly persisted series object
     */
@Override
public Series createSeriesAssociatedWithFonds(String fondsSystemId, Series series) {
    Series persistedSeries = null;
    Fonds fonds = fondsRepository.findBySystemIdOrderBySystemId(fondsSystemId);
    if (fonds == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " Fonds, using fondsSystemId " + fondsSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    } else if (fonds.getReferenceChildFonds() != null && fonds.getReferenceChildFonds().size() > 0) {
        String info = INFO_INVALID_STRUCTURE + " Cannot associate series with a fonds that has" + "children fonds " + fondsSystemId;
        logger.info(info);
        throw new NoarkInvalidStructureException(info, "Fonds", "Series");
    } else if (fonds.getFondsStatus() != null && fonds.getFondsStatus().equals(STATUS_CLOSED)) {
        String info = INFO_CANNOT_ASSOCIATE_WITH_CLOSED_OBJECT + ". Fonds with fondsSystemId " + fondsSystemId + "has status " + STATUS_CLOSED;
        logger.info(info);
        throw new NoarkEntityEditWhenClosedException(info);
    } else {
        series.setReferenceFonds(fonds);
        persistedSeries = seriesImportService.save(series);
    }
    return persistedSeries;
}
Also used : Series(nikita.model.noark5.v4.Series) NoarkInvalidStructureException(nikita.util.exceptions.NoarkInvalidStructureException) Fonds(nikita.model.noark5.v4.Fonds) NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException) NoarkEntityEditWhenClosedException(nikita.util.exceptions.NoarkEntityEditWhenClosedException)

Example 9 with Series

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

the class SeriesImportService method createFileAssociatedWithSeries.

@Override
public File createFileAssociatedWithSeries(String seriesSystemId, File file) {
    File persistedFile = null;
    Series series = seriesRepository.findBySystemIdOrderBySystemId(seriesSystemId);
    if (series == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " Series, using seriesSystemId " + seriesSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    } else if (series.getSeriesStatus() != null && series.getSeriesStatus().equals(STATUS_CLOSED)) {
        String info = INFO_CANNOT_ASSOCIATE_WITH_CLOSED_OBJECT + ". Series with seriesSystemId " + seriesSystemId + "has status " + STATUS_CLOSED;
        logger.info(info);
        throw new NoarkEntityEditWhenClosedException(info);
    } else {
        file.setReferenceSeries(series);
        persistedFile = fileImportService.createFile(file);
    }
    return persistedFile;
}
Also used : Series(nikita.model.noark5.v4.Series) NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException) File(nikita.model.noark5.v4.File) CaseFile(nikita.model.noark5.v4.casehandling.CaseFile) NoarkEntityEditWhenClosedException(nikita.util.exceptions.NoarkEntityEditWhenClosedException)

Example 10 with Series

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

the class FondsHateoasController method findSeriesAssociatedWithFonds.

// Get all Series associated with Fonds identified by systemId
// GET [contextPath][api]/arkivstruktur/arkiv/{systemId}/arkivdel/
@ApiOperation(value = "Retrieves the Series associated with a Fonds identified by a systemId", response = Series.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Series returned", response = Series.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 + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + SERIES + SLASH, method = RequestMethod.GET)
public ResponseEntity<SeriesHateoas> findSeriesAssociatedWithFonds(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of Fonds that has Series associated with it.", required = true) @PathVariable("systemID") final String systemID) {
    Fonds fonds = fondsService.findBySystemIdOrderBySystemId(systemID);
    if (fonds == null) {
        throw new NoarkEntityNotFoundException("Could not find series object with systemID " + systemID);
    }
    SeriesHateoas seriesHateoas = new SeriesHateoas(new ArrayList<>(fonds.getReferenceSeries()));
    seriesHateoasHandler.addLinks(seriesHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(seriesHateoas);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) SeriesHateoas(nikita.model.noark5.v4.hateoas.SeriesHateoas) Fonds(nikita.model.noark5.v4.Fonds) NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

Series (nikita.model.noark5.v4.Series)20 Counted (com.codahale.metrics.annotation.Counted)16 Timed (com.codahale.metrics.annotation.Timed)16 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)13 ApiOperation (io.swagger.annotations.ApiOperation)11 ApiResponses (io.swagger.annotations.ApiResponses)11 NoarkEntityNotFoundException (nikita.util.exceptions.NoarkEntityNotFoundException)11 CaseFile (nikita.model.noark5.v4.casehandling.CaseFile)8 Fonds (nikita.model.noark5.v4.Fonds)6 NoarkEntityEditWhenClosedException (nikita.util.exceptions.NoarkEntityEditWhenClosedException)6 SeriesHateoas (nikita.model.noark5.v4.hateoas.SeriesHateoas)5 CaseFileHateoas (nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas)5 AfterNoarkEntityCreatedEvent (no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityCreatedEvent)5 Date (java.util.Date)4 AfterNoarkEntityDeletedEvent (no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityDeletedEvent)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 Class (nikita.model.noark5.v4.Class)3 File (nikita.model.noark5.v4.File)3 NikitaException (nikita.util.exceptions.NikitaException)3