use of io.lumeer.api.model.Perspective in project engine by Lumeer.
the class ViewCodec method decode.
@Override
public View decode(final BsonReader reader, final DecoderContext decoderContext) {
Document bson = documentCodec.decode(reader, decoderContext);
SimpleResource resource = decodeResource(bson, ResourceType.VIEW);
Query query = QueryCodec.convertFromDocument(bson.get(QUERY, Document.class));
Perspective perspective = decodePerspective(bson);
Object config = bson.get(CONFIG);
Object settings = bson.get(SETTINGS);
String authorId = bson.getString(AUTHOR_ID);
Date lastTimeUsed = bson.getDate(LAST_TIME_USED);
List<String> folders = bson.getList(FOLDERS, String.class);
List<Query> additionalQueries = Collections.emptyList();
List queriesList = bson.get(ADDITIONAL_QUERIES, List.class);
if (queriesList != null) {
additionalQueries = new ArrayList<Document>(queriesList).stream().map(QueryCodec::convertFromDocument).collect(Collectors.toList());
}
View view = new View(resource, query, additionalQueries, perspective, config, settings, authorId, folders);
view.setVersion(resource.getVersion());
if (lastTimeUsed != null) {
view.setLastTimeUsed(ZonedDateTime.ofInstant(lastTimeUsed.toInstant(), ZoneOffset.UTC));
}
return view;
}
Aggregations