package eu.eudat.logic.security.customproviders.ConfigurableProvider.models;

import eu.eudat.logic.security.customproviders.ConfigurableProvider.entities.ConfigurableProvider;
import eu.eudat.logic.security.customproviders.ConfigurableProvider.entities.ConfigurableProviders;

import java.util.LinkedList;
import java.util.List;

public class ConfigurableProvidersModel {
	private List<ConfigurableProviderModel> providers;

	public List<ConfigurableProviderModel> getProviders() {
		return providers;
	}
	public void setProviders(List<ConfigurableProviderModel> providers) {
		this.providers = providers;
	}

	public ConfigurableProvidersModel fromDataModel(ConfigurableProviders entity) {
		ConfigurableProvidersModel model = new ConfigurableProvidersModel();
		List<ConfigurableProviderModel> providerModelList = new LinkedList<>();
		if (entity != null) {
			for (ConfigurableProvider entityProvider : entity.getProviders()) {
				if (entityProvider.getEnabled())
					providerModelList.add(new ConfigurableProviderModel().fromDataModel(entityProvider));
			}
		}
		model.setProviders(providerModelList);
		return model;
	}
}
