package org.texttechnologylab.project.gruppe_05_1.database.domainimpl.mdb;

import org.bson.Document;
import org.texttechnologylab.project.gruppe_05_1.database.MongoDBHandler;
import org.texttechnologylab.project.gruppe_05_1.database.MongoOperations;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.Institution;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Institution_Mongo_Impl extends Institution implements MongoOperations<Institution> {
    @Override
    public Document createEntity(Institution entity) {
        Map<String, Object> fields = new HashMap<>();
        fields.put("insartLang", entity.getInsartLang());
        fields.put("insLang", entity.getInsLang());
        fields.put("mdbinsVon", entity.getMdbinsVon());
        fields.put("mdbinsBis", entity.getMdbinsBis());
        fields.put("fktLang", entity.getFktLang());
        fields.put("fktinsVon", entity.getFktinsVon());
        fields.put("fktinsBis", entity.getFktinsBis());

        return MongoDBHandler.createDocument(false, fields);
    }

    @Override
    public List<Document> createList(List<Institution> list) {
        List<Document> result = new ArrayList<>();
        for (Institution inst : list) {
            result.add(createEntity(inst));
        }
        return result;
    }
}
