Search in sources :

Example 1 with Perspective

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;
}
Also used : Query(io.lumeer.api.model.Query) ArrayList(java.util.ArrayList) Document(org.bson.Document) View(io.lumeer.api.model.View) Date(java.util.Date) Perspective(io.lumeer.api.model.Perspective) SimpleResource(io.lumeer.api.model.common.SimpleResource) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

Perspective (io.lumeer.api.model.Perspective)1 Query (io.lumeer.api.model.Query)1 View (io.lumeer.api.model.View)1 SimpleResource (io.lumeer.api.model.common.SimpleResource)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 Document (org.bson.Document)1