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.MdbName;

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

public class MdbName_Mongo_Impl extends MdbName implements MongoOperations<MdbName> {
    @Override
    public Document createEntity(MdbName entity) {
        Map<String, Object> fields = new HashMap<>();
        fields.put("nachname",     entity.getNachname());
        fields.put("vorname",      entity.getVorname());
        fields.put("ortszusatz",   entity.getOrtszusatz());
        fields.put("adel",         entity.getAdel());
        fields.put("praefix",      entity.getPraefix());
        fields.put("andereTitel",  entity.getAndereTitel());
        fields.put("akadTitel",    entity.getAkadTitel());
        fields.put("historieVon",  entity.getHistorieVon());
        fields.put("historieBis",  entity.getHistorieBis());

        return MongoDBHandler.createDocument(false, fields);
    }

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