All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.etlunit.feature.informatica.InformaticaConfiguration Maven / Gradle / Ivy

There is a newer version: 1.6.9
Show newest version
package org.etlunit.feature.informatica;

import org.etlunit.RuntimeSupport;
import org.etlunit.parser.ETLTestValueObject;

import java.io.File;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/*
		default-domain: 'Domain_etldev01',
		domains: {
			Domain_etldev01: {
				client-version: '9.1.0hf3',
				connectivity-host: 'etldev01',
				connectivity-port: 6005,
				username: 'bsmith',
				password-encrypted: '',
				repositories: {
					dev_pc_repo: {
						integration-services: [
							'dev_ci_is',
							'dev_is',
							'dev_java_is'
						]
					}
				}
			}
			(
			,
			Domain_etlqa01: {
				client-version: '9.1.0hf3',
				connectivity-host: 'etlqa01',
				connectivity-port: 6005,
				username: 'bsmith',
				password-encrypted: '',
				repositories: {
					qa_pc_repo: {
						integration-services: [
							'qa_is'
						]
					}
				}
			}
			)*
		}
*/
public class InformaticaConfiguration {
	private final InformaticaDomain defaultDomain;
	private final Map domains = new HashMap();

	public InformaticaConfiguration(InformaticaFeatureModule mod, ETLTestValueObject value, RuntimeSupport runtimeSupport, File domainsFile)
	{
		ETLTestValueObject edomains = value.query("domains");

		if (edomains == null)
		{
			throw new IllegalArgumentException("Missing domains");
		}

		Map dlist = edomains.getValueAsMap();

		if (dlist.size() == 0)
		{
			throw new IllegalArgumentException("Domains element does not contain any entries");
		}

		Iterator> dit = dlist.entrySet().iterator();

		InformaticaDomain firstInformaticaDomain = null;

		while (dit.hasNext())
		{
			Map.Entry dom = dit.next();

			InformaticaDomain informaticaDomain = new InformaticaDomain(mod, dom.getKey(), dom.getValue(), runtimeSupport, domainsFile);

			if (domains.containsKey(dom.getKey()))
			{
				throw new IllegalArgumentException("Domains element contains the same domain repeated: " + dom.getKey());
			}
			else
			{
				domains.put(dom.getKey(), informaticaDomain);
			}

			if (firstInformaticaDomain == null)
			{
				firstInformaticaDomain = informaticaDomain;
			}
		}

		ETLTestValueObject idefDomain = value.query("default-domain");

		if (idefDomain == null)
		{
			defaultDomain = firstInformaticaDomain;
		}
		else
		{
			String name = idefDomain.getValueAsString();

			defaultDomain = domains.get(name);

			if (defaultDomain == null)
			{
				throw new IllegalArgumentException("Default domain " + name + " not found in domains list");
			}
		}
	}

	public InformaticaDomain getDefaultDomain() {
		return defaultDomain;
	}

	public Map getDomains() {
		return domains;
	}

	public InformaticaDomain getDomain(String name) {
		InformaticaDomain dom = domains.get(name);

		if (dom == null)
		{
			throw new IllegalArgumentException("Domain not found " + name);
		}

		return dom;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy