package ua.be.wee.model.pt;


import java.util.List;

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

import ua.be.wee.model.pm.PM;

@Entity
public class PT {
	
	public static String TRACE_GRAPH_IRI = "http://ua.be/sdo2l/description/traces";
	
	@Id
	private String iri;
	
	private String name;
	
	@OneToMany
	private List<Event> events;
	
	@OneToMany
	private List<TraceArtifact> inputs;
	
	@OneToOne
	private PM pmEnacted;

	public PM getPmEnacted() {
		return pmEnacted;
	}

	public void setPmEnacted(PM pmEnacted) {
		this.pmEnacted = pmEnacted;
	}

	public String getIri() {
		return iri;
	}

	public void setIri(String iri) {
		this.iri = iri;
		this.name = iri.split("#")[1];
	}

	public String getName() {
		return name;
	}

	public List<Event> getEvents() {
		return events;
	}

	public void setEvents(List<Event> events) {
		this.events = events;
	}
	
	public Event getLastEvent() {
		if (events != null && events.size() > 0) {
			return events.get(events.size()-1); 
		}
		return null;
	}

	public void addEvent(Event ev) {
		events.add(ev);
	}

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

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

}
