Commit 37ec7da7 authored by Michael Ritter's avatar Michael Ritter
Browse files

Merge 'bug/spring-page-serialization'

rest-models/
  - Update SpringPage to be in line with PageImpl updates
parent 3f2dd170
package org.chronopolis.ingest.config;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.module.kotlin.KotlinModule;
import org.apache.catalina.connector.Connector;
import org.chronopolis.common.concurrent.TrackingThreadPoolExecutor;
import org.chronopolis.common.storage.TokenStagingProperties;
......@@ -14,38 +12,7 @@ import org.chronopolis.ingest.repository.dao.ReplicationDao;
import org.chronopolis.ingest.repository.dao.StagingDao;
import org.chronopolis.ingest.repository.dao.TokenDao;
import org.chronopolis.ingest.support.BagFileCSVProcessor;
import org.chronopolis.rest.entities.AceToken;
import org.chronopolis.rest.entities.Bag;
import org.chronopolis.rest.entities.BagFile;
import org.chronopolis.rest.entities.Replication;
import org.chronopolis.rest.entities.TokenStore;
import org.chronopolis.rest.entities.depositor.Depositor;
import org.chronopolis.rest.entities.depositor.DepositorContact;
import org.chronopolis.rest.entities.projections.CompleteBag;
import org.chronopolis.rest.entities.projections.PartialBag;
import org.chronopolis.rest.entities.projections.ReplicationView;
import org.chronopolis.rest.entities.repair.Repair;
import org.chronopolis.rest.entities.serializers.AceTokenSerializer;
import org.chronopolis.rest.entities.serializers.BagSerializer;
import org.chronopolis.rest.entities.serializers.CompleteBagSerializer;
import org.chronopolis.rest.entities.serializers.DataFileSerializer;
import org.chronopolis.rest.entities.serializers.DepositorContactSerializer;
import org.chronopolis.rest.entities.serializers.DepositorSerializer;
import org.chronopolis.rest.entities.serializers.PartialBagSerializer;
import org.chronopolis.rest.entities.serializers.RepairSerializer;
import org.chronopolis.rest.entities.serializers.ReplicationSerializer;
import org.chronopolis.rest.entities.serializers.ReplicationViewSerializer;
import org.chronopolis.rest.entities.serializers.StagingStorageSerializer;
import org.chronopolis.rest.entities.serializers.StorageRegionSerializer;
import org.chronopolis.rest.entities.storage.StagingStorage;
import org.chronopolis.rest.entities.storage.StorageRegion;
import org.chronopolis.rest.models.FulfillmentStrategy;
import org.chronopolis.rest.models.enums.FixityAlgorithm;
import org.chronopolis.rest.models.serializers.FixityAlgorithmDeserializer;
import org.chronopolis.rest.models.serializers.FixityAlgorithmSerializer;
import org.chronopolis.rest.models.serializers.FulfillmentStrategyDeserializer;
import org.chronopolis.rest.models.serializers.ZonedDateTimeDeserializer;
import org.chronopolis.rest.models.serializers.ZonedDateTimeSerializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
......@@ -54,11 +21,9 @@ import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.validation.Validator;
import javax.persistence.EntityManager;
import java.time.ZonedDateTime;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
......
......@@ -8,26 +8,34 @@ package org.chronopolis.rest.models.page
* @author shake
*/
data class SpringPage<out T>(val content: List<T>,
val pageable: Pageable,
val last: Boolean,
val first: Boolean,
val totalPages: Int,
val totalElements: Long,
val sort: List<Sort>,
val first: Boolean,
val sort: Sort,
val numberOfElements: Int,
val size: Int,
val number: Int) : Iterable<T> {
val number: Int,
val empty: Boolean) : Iterable<T> {
override fun iterator(): Iterator<T> {
return content.iterator()
}
}
fun <T> List<T>.wrap(): SpringPage<T> {
return SpringPage(this, true, true, 1, this.size.toLong(), listOf(), this.size, this.size, 1)
val sort = Sort(true, false, false)
val page = Pageable(sort, this.size, 1, 0, false, true)
return SpringPage(this, page, true, 1, 1L, true, sort, this.size, this.size, 1, this.isEmpty())
}
data class Sort(val direction: String,
val property: String,
val ignoreCase: Boolean,
val nullHandling: String,
val ascending: Boolean,
val descending: Boolean)
\ No newline at end of file
data class Pageable(val sort: Sort,
val pageSize: Int,
val pageNumber: Int,
val offset: Int,
val unpaged: Boolean,
val paged: Boolean)
data class Sort(val sorted: Boolean,
val unsorted: Boolean,
val empty: Boolean)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment