/** * */ package org.sportscoring.ssv.xc.core; import java.util.ArrayList; import java.util.UUID; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.PrePersist; import javax.persistence.Transient; import org.sportscoring.openscorercp.core.CoreObjectEvent; import org.sportscoring.openscorercp.core.CoreObjectListener; import org.sportscoring.openscorercp.core.interfaces.IConstraint; import org.sportscoring.openscorercp.core.interfaces.ICoreObject; import org.sportscoring.openscorercp.core.interfaces.IDiscipline; /** * @author my * */ @Entity public class XCCompetitorCount implements ICoreObject { @Transient private ArrayList listeners; private IDiscipline discipline; private IConstraint constraint; private Integer numberOfCompetitors; // the number of competitors who score in a team private Integer numberInTeam; // the number of competitors comprising a team private Integer numberOfTeamsToQualify; //the number of teams who qualify to the next round private Integer numberOfIndividualsToQualify;// the number of individuals who qualify to the next round @Id private String externalSyncID; public XCCompetitorCount() { this.listeners = new ArrayList(); this.fireEvent(CoreObjectEvent.Action.CREATED); } public XCCompetitorCount(IDiscipline discipline,IConstraint constraint,Integer numberOfCompetitors){ this(); this.discipline = discipline; this.constraint = constraint; this.numberOfCompetitors = numberOfCompetitors; this.fireEvent(CoreObjectEvent.Action.CREATED); } /** * @return the discipline */ public synchronized IDiscipline getDiscipline() { return this.discipline; } /** * @param discipline the discipline to set */ public synchronized void setDiscipline(IDiscipline discipline) { this.discipline = discipline; this.fireEvent(CoreObjectEvent.Action.MODIFIED); } /** * @return the constraint */ public synchronized IConstraint getConstraint() { return this.constraint; } /** * @param constraint the constraint to set */ public synchronized void setConstraint(IConstraint constraint) { this.constraint = constraint; this.fireEvent(CoreObjectEvent.Action.MODIFIED); } /** * @return the numberOfCompetitors */ public synchronized Integer getNumberOfCompetitors() { return this.numberOfCompetitors; } /** * @param numberOfCompetitors the numberOfCompetitors to set */ public synchronized void setNumberOfCompetitors(Integer numberOfCompetitors) { this.numberOfCompetitors = numberOfCompetitors; this.fireEvent(CoreObjectEvent.Action.MODIFIED); } public synchronized void addListener(CoreObjectListener listener) { this.listeners.add(listener); } public synchronized void removeListener(CoreObjectListener listener) { this.listeners.remove(listener); } protected void fireEvent(CoreObjectEvent.Action action) { CoreObjectEvent e = new CoreObjectEvent(action, this, this); for (CoreObjectListener listener : this.listeners) { listener.objectChanged(e); } } public String toString() { return ("TODO: DistrictDisciplineScoringCount.toString()"); } public String identifierString() { return ("TODO: DistrictDisciplineScoringCount.identifierString()"); } public synchronized boolean complete() { if (this.discipline == null) return(false); if (this.constraint == null) return(false); if (this.numberOfCompetitors == null) return(false); return(true); } public void dispose() { } /** * @return the numberInTeam */ public synchronized Integer getNumberInTeam() { return numberInTeam; } /** * @param numberInTeam the numberInTeam to set */ public synchronized void setNumberInTeam(Integer numberInTeam) { this.numberInTeam = numberInTeam; this.fireEvent(CoreObjectEvent.Action.MODIFIED); } /** * @param numberOfTeamsToQualify the numberOfTeamsToQualify to set */ public synchronized void setNumberOfTeamsToQualify(Integer numberOfTeamsToQualify) { this.numberOfTeamsToQualify = numberOfTeamsToQualify; this.fireEvent(CoreObjectEvent.Action.MODIFIED); } /** * @return the numberOfTeamsToQualify */ public synchronized Integer getNumberOfTeamsToQualify() { return numberOfTeamsToQualify; } /** * @param numberOfIndividualsToQualify the numberOfIndividualsToQualify to set */ public synchronized void setNumberOfIndividualsToQualify( Integer numberOfIndividualsToQualify) { this.numberOfIndividualsToQualify = numberOfIndividualsToQualify; this.fireEvent(CoreObjectEvent.Action.MODIFIED); } /** * @return the numberOfIndividualsToQualify */ public synchronized Integer getNumberOfIndividualsToQualify() { return numberOfIndividualsToQualify; } public void setExternalSyncID(String id) { this.externalSyncID = id; this.fireEvent(CoreObjectEvent.Action.MODIFIED); } public String getExternalSyncID() { return externalSyncID; } @PrePersist public void createId() { this.externalSyncID = UUID.randomUUID().toString(); } }