package ua.be.wee.model.nodes;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;

import com.fasterxml.jackson.annotation.JsonBackReference;

import ua.be.wee.model.nodes.ports.ControlInputPort;
import ua.be.wee.model.nodes.ports.ControlOutputPort;
import ua.be.wee.model.nodes.ports.DataInputPort;
import ua.be.wee.model.nodes.ports.DataOutputPort;

@Entity
public class Activity extends Node {
	
	@ManyToMany
	private List<Artifact> inputs;
	
	@ManyToMany
	private List<Artifact> outputs;
	
	@OneToMany
	@JsonBackReference
	private List<ControlOutputPort> ctrlOutPorts;
	
	@OneToMany
	@JsonBackReference
	private List<ControlInputPort> ctrlInPorts;
	
	@OneToMany
	@JsonBackReference
	private List<DataOutputPort> dataOutPorts;
	
	@OneToMany
	@JsonBackReference
	private List<DataInputPort> datalInPorts;
	
	private String transformationName;
	
	public Activity() {
		inputs = new ArrayList<Artifact>();
		outputs = new ArrayList<Artifact>();
	}

	public List<Artifact> getInputs() {
		return inputs;
	}

	public void setInputs(List<Artifact> inputs) {
		this.inputs = inputs;
	}

	public List<Artifact> getOutputs() {
		return outputs;
	}

	public void setOutputs(List<Artifact> outputs) {
		this.outputs = outputs;
	}

	public List<ControlOutputPort> getCtrlOutPorts() {
		return ctrlOutPorts;
	}

	public void setCtrlOutPorts(List<ControlOutputPort> ctrlOutPorts) {
		this.ctrlOutPorts = ctrlOutPorts;
	}

	public List<ControlInputPort> getCtrlInPorts() {
		return ctrlInPorts;
	}

	public void setCtrlInPorts(List<ControlInputPort> ctrlInPorts) {
		this.ctrlInPorts = ctrlInPorts;
	}

	public String getTransformationName() {
		return transformationName;
	}

	public void setTransformationName(String transformationName) {
		this.transformationName = transformationName;
	}

	public List<DataOutputPort> getDataOutPorts() {
		return dataOutPorts;
	}

	public void setDataOutPorts(List<DataOutputPort> dataOutPorts) {
		this.dataOutPorts = dataOutPorts;
	}

	public List<DataInputPort> getDatalInPorts() {
		return datalInPorts;
	}

	public void setDatalInPorts(List<DataInputPort> datalInPorts) {
		this.datalInPorts = datalInPorts;
	}
	
	public void addInputArtifact(Artifact art) {
		if (inputs != null) {
			inputs.add(art);
		}
	}
	
	public void addOutputArtifact(Artifact art) {
		if (outputs != null) {
			outputs.add(art);
		}
	}

	

}
