package org.pdxfinder.admin.pojos;

import java.util.TreeMap;

/*
 * Created by csaba on 18/06/2018.
 */
public class MappingContainer {

    private int size;

    /**
     * A container holding mapped and unmapped entities
     */
    private TreeMap<Long, MappingEntity> mappings;



    public MappingContainer(TreeMap<Long, MappingEntity> mappings) {
        this.mappings = new TreeMap<>();
        this.mappings = mappings;
        size = mappings.size();
    }

    public MappingContainer() {

        mappings = new TreeMap<>();
        size = 0;
    }

    public TreeMap<Long, MappingEntity> getMappings() {
        return mappings;
    }

    public void setMappings(TreeMap<Long, MappingEntity> mappings) {
        this.mappings = mappings;
    }



    public MappingEntity getEntityById(Long id){

        if(mappings.containsKey(id)) return mappings.get(id);

        return null;
    }

    public Long getNextAvailableId(){


        return (long) size +1;
    }


    public void add(MappingEntity me){

        mappings.put(me.getEntityId(), me);
        size += 1;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }
}

@@ -46,23 +46,130 @@
 va.util.
-TreeMap
+HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;%0Aimport java.util.TreeMap;%0Aimport java.util.stream.Collectors
 ;%0A%0A/*%0A *
@@ -1317,10 +1317,395 @@
 ;%0A    %7D%0A
+%0A%0A    //method to transform the container something more processable by the frontend%0A    public Map%3CString, List%3CMappingEntity%3E%3E getEntityList()%7B%0A%0A        List%3CMappingEntity%3E list = mappings.values().stream().collect(Collectors.toList());%0A%0A        Map%3CString, List%3CMappingEntity%3E%3E entityMap = new HashMap%3C%3E();%0A        entityMap.put(%22mappings%22, list);%0A%0A%0A        return entityMap;%0A    %7D%0A
 %7D%0A

Add getEntityList