package br.uem.din.architectureEvolution.representation;

import static br.uem.din.architectureEvolution.helpers.ElementTypeNames.DEPENDENCY;

import com.sdmetrics.model.ModelElement;

public class DependencyInterClassRelationship extends InterClassRelationship {

	private Class client;
	private Class supplier;
	
	public DependencyInterClassRelationship(ModelElement element, Architecture architecture) throws Exception {
		super(element);
		
		ModelElement modelClient = getModelElement().getRefAttribute("depclient");
		ModelElement modelSupplier = getModelElement().getRefAttribute("depsupplier");
		
		setClient(architecture.findClassByXMIID(modelClient.getXMIID()));
		setSupplier(architecture.findClassByXMIID(modelSupplier.getXMIID()));
	}
	
	public DependencyInterClassRelationship(Class supplierClass, Class clientClass, Architecture architecture) throws Exception {
		super(new ModelElement(architecture.getMetaModel().getType(DEPENDENCY)));

		getModelElement().setRefAttribute("depsupplier", supplierClass.getModelElement());
		getModelElement().setRefAttribute("depclient", clientClass.getModelElement());
		
		setSupplier(supplierClass);
		setClient(clientClass);
	}

	public Class getClient() {
		return client;
	}

	private void setClient(Class client) {
		this.client = client;
	}

	public Class getSupplier() {
		return supplier;
	}

	private void setSupplier(Class supplier) {
		this.supplier = supplier;
	}

}
