Search in sources :

Example 1 with org.haiku.haikudepotserver.dataobjects.auto._Repository

use of org.haiku.haikudepotserver.dataobjects.auto._Repository in project haikudepotserver by haiku.

the class RepositoryDumpExportJobRunner method run.

@Override
public void run(JobService jobService, RepositoryDumpExportJobSpecification specification) throws IOException, JobRunnerException {
    // this will register the outbound data against the job.
    JobDataWithByteSink jobDataWithByteSink = jobService.storeGeneratedData(specification.getGuid(), "download", MediaType.JSON_UTF_8.toString());
    try (final OutputStream outputStream = jobDataWithByteSink.getByteSink().openBufferedStream();
        final GZIPOutputStream gzipOutputStream = new GZIPOutputStream(outputStream);
        final JsonGenerator jsonGenerator = objectMapper.getFactory().createGenerator(gzipOutputStream)) {
        ObjectContext context = serverRuntime.newContext();
        List<Repository> repositories = Repository.getAll(context).stream().filter(_Repository::getActive).collect(Collectors.toList());
        jsonGenerator.writeStartObject();
        writeInfo(jsonGenerator, repositories);
        writeRepositories(jsonGenerator, repositories);
        jsonGenerator.writeEndObject();
    }
}
Also used : JobDataWithByteSink(org.haiku.haikudepotserver.job.model.JobDataWithByteSink) DumpExportRepository(org.haiku.haikudepotserver.repository.model.dumpexport.DumpExportRepository) Repository(org.haiku.haikudepotserver.dataobjects.Repository) org.haiku.haikudepotserver.dataobjects.auto._Repository(org.haiku.haikudepotserver.dataobjects.auto._Repository) GZIPOutputStream(java.util.zip.GZIPOutputStream) OutputStream(java.io.OutputStream) GZIPOutputStream(java.util.zip.GZIPOutputStream) JsonGenerator(com.fasterxml.jackson.core.JsonGenerator) ObjectContext(org.apache.cayenne.ObjectContext)

Aggregations

JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 OutputStream (java.io.OutputStream)1 GZIPOutputStream (java.util.zip.GZIPOutputStream)1 ObjectContext (org.apache.cayenne.ObjectContext)1 Repository (org.haiku.haikudepotserver.dataobjects.Repository)1 org.haiku.haikudepotserver.dataobjects.auto._Repository (org.haiku.haikudepotserver.dataobjects.auto._Repository)1 JobDataWithByteSink (org.haiku.haikudepotserver.job.model.JobDataWithByteSink)1 DumpExportRepository (org.haiku.haikudepotserver.repository.model.dumpexport.DumpExportRepository)1