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 org.texttechnologylab.project.gruppe_05_1.domain.mdb.Wahlperiode;
import org.texttechnologylab.project.gruppe_05_1.domain.speaker.Membership;
import org.texttechnologylab.project.gruppe_05_1.domain.speaker.Speaker;

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

public class Membership_Mongo_Impl extends Membership implements MongoOperations<Membership> {
    @Override
    public Document createEntity(Membership entity) {
        Map<String, Object> fields = new HashMap<>();

        fields.put("begin",        entity.getBegin());
        fields.put("end",          entity.getEnd());
        fields.put("role",         entity.getRole());
        fields.put("label",        entity.getLabel());
        fields.put("member",       entity.getMember());      // TODO: wahrscheinlich nicht nötig
        fields.put("wp",           entity.getWp());

        return MongoDBHandler.createDocument(false, fields);
    }

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