package gr.iti.mklab.simmo.core.cluster;

import org.bson.types.ObjectId;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
import org.mongodb.morphia.annotations.Reference;

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

/**
 * A Cluster class
 *
 * @author kandreadou
 * @version 1.0.0
 * @since March 26, 2015
 */
@Entity
public class Cluster {

    @Id
    protected String id = new ObjectId().toString();

    @Reference
    protected List<Clusterable> members = new ArrayList<>();

    protected int size;

    protected Date startDate;
    
    protected Date endDate;
    
    public Clusterable getCentroid() {
		return centroid;
	}

	public void setCentroid(Clusterable centroid) {
		this.centroid = centroid;
	}

	protected Clusterable centroid;
    
    public Cluster() {
    }

    public void addMember(Clusterable c) {
        members.add(c);
    }

    public void removeMember(Clusterable c) {
        members.remove(c);
    }

    public int getSize() {
        return size;
    }

    public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public void setSize(int size) {
        this.size = size;
    }

    public List<Clusterable> getMembers() {
        return members;
    }

    public void setMembers(List<Clusterable> members){
        this.members = members;
    }

    public String getId() {
        return id;
    }
    
    public void setId(String id) {
        this.id = id;
    }
}

@@ -276,19 +276,67 @@
 va.util.
-Lis
+HashSet;%0Aimport java.util.List;%0Aimport java.util.Se
 t;%0A%0A/**%0A
@@ -694,30 +694,131 @@
    %0A
-    public Clusterable
+%09protected Clusterable centroid;%0A%09%0A    protected Set%3CString%3E centroids = new HashSet%3CString%3E();%0A    %0A    public Set%3CString%3E
  get
@@ -825,16 +825,17 @@
 Centroid
+s
 () %7B%0A%09%09r
@@ -840,32 +840,33 @@
 %09return centroid
+s
 ;%0A%09%7D%0A%0A%09public vo
@@ -879,28 +879,108 @@
 Centroid
-(Clusterable
+s(Set%3CString%3E centroids) %7B%0A%09%09this.centroids = centroids;%0A%09%7D%0A%0A%09public void addCentroid(String
  centroi
@@ -999,27 +999,30 @@
 centroid
- = 
+s.add(
 centroid
 ;%0A%09%7D%0A%0A%09p
@@ -1017,46 +1017,158 @@
 roid
+)
 ;%0A%09%7D%0A
+%09
 %0A%09p
-rotected Clusterable centroid;
+ublic Clusterable getCentroid() %7B%0A%09%09return centroid;%0A%09%7D%0A    %0A%09public void setCentroid(Clusterable centroid) %7B%0A%09%09this.centroid = centroid;%0A%09%7D
 %0A   

Add set of centroids in cluster