package ua.be.wee.model.pt;

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

import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import ua.be.wee.model.nodes.ports.ControlInputPort;

@Entity
public class StartActivityEvent extends Event {
	
	@OneToOne
	private ControlInputPort relatesTo;
	
	@OneToMany
	private List<TraceArtifact> consumedArtifacts;
	
	public StartActivityEvent() {
		consumedArtifacts = new ArrayList<TraceArtifact>();
	}

	public ControlInputPort getRelatesTo() {
		return relatesTo;
	}

	public void setRelatesTo(ControlInputPort relatesTo) {
		this.relatesTo = relatesTo;
	}
	
	public void addTraceArtifact(TraceArtifact art) {
		consumedArtifacts.add(art);
	}
	
	public List<TraceArtifact> getConsumedArtifacts() {
		return consumedArtifacts;
	}
	
	public void setConsumedArtifacts(List<TraceArtifact> arts) {
		consumedArtifacts = arts;
	}
	
	public TraceArtifact getArtifact(String iri) {
		for (TraceArtifact traceArtifact : consumedArtifacts) {
			if (iri.equals(traceArtifact.getIri())) {
				return traceArtifact;
			}
		}
		return null;
	}
	
	

}
