package models;

import com.avaje.ebean.Ebean;
import play.data.validation.Constraints;
import play.db.ebean.Model;
import play.db.ebean.Transactional;
import play.twirl.api.Html;
import powerups.*;
import powerups.Powerup;
import powerups.core.descriptionpowerup.DescriptionPowerup;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

@Entity
public class Club extends Model {
    public static Finder<Long, Club> find = new Finder<>(Long.class, Club.class);

    @Transactional
    public static void update(Club club) {
        Ebean.update(club);
    }

    @Id
    public Long id;

    @Constraints.Required
    public String name;

    @Constraints.Required
    public String shortName;

    @ManyToOne
    public Location location;

    @OneToMany(cascade = CascadeType.PERSIST, mappedBy = "club")
    public List<Membership> members = new ArrayList<>();

    @OneToMany(cascade = CascadeType.PERSIST)
    public List<Activation> activations = new ArrayList<>();

    @Transient
    public List<Powerup> powerups;

}

@@ -1044,10 +1044,625 @@
 erups;%0A%0A
+    @Transient%0A    private Html listDesc;%0A%0A    // TODO FIND MORE LOGICAL WAY TO IMPLEMENT%0A    public void setDescriptions() %7B%0A        for(Activation activation : activations) %7B%0A            Powerup powerup = activation.getPowerup();%0A            if(powerup instanceof DescriptionPowerup) %7B%0A                setListDesc(((DescriptionPowerup) powerup).renderList());%0A            %7D%0A        %7D%0A    %7D%0A%0A    public Html getListDesc() %7B%0A        if(listDesc == null) %7B%0A            setDescriptions();%0A        %7D%0A        return listDesc;%0A    %7D%0A%0A    private void setListDesc(Html listDesc) %7B%0A        this.listDesc = listDesc;%0A    %7D%0A
 %7D%0A

Revert "Remove unneeded references"