// Path: core/src/main/java/org/mskcc/cbio/oncokb/serializer/SetGeneInGenesetConverter.java
// public class SetGeneInGenesetConverter extends StdConverter<Set<Gene>, Set<Gene>> {
//     @Override
//     public Set<Gene> convert(Set<Gene> genes) {
//         Set<Gene> newGenes = new HashSet<>();
//         for (Gene gene : genes) {
//             Gene newGene = new Gene();
//             newGene.setGeneAliases(newGene.getGeneAliases());
//             newGene.setHugoSymbol(gene.getHugoSymbol());
//             newGene.setEntrezGeneId(gene.getEntrezGeneId());
//             newGene.setOncogene(gene.getOncogene());
//             newGene.setTSG(gene.getTSG());
//             newGene.setGrch37Isoform(gene.getGrch37Isoform());
//             newGene.setGrch37RefSeq(gene.getGrch37RefSeq());
//             newGene.setGrch38Isoform(gene.getGrch38Isoform());
//             newGene.setGrch38RefSeq(gene.getGrch38RefSeq());
//             newGenes.add(newGene);
//         }
//         return newGenes;
//     }
// }


import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.mskcc.cbio.oncokb.serializer.SetGeneInGenesetConverter;
import javax.persistence.*;
import java.util.Objects;
import java.util.Set;
package org.mskcc.cbio.oncokb.model;



/**
 * Created by Hongxin Zhang on 2019-08-08.
 */

@NamedQueries({
    @NamedQuery(
        name = "findGenesetByName",
        query = "select g from Geneset g where g.name=?"
    ),
    @NamedQuery(
        name = "findGenesetByUUID",
        query = "select g from Geneset g where g.uuid=?"
    ),
})

@Entity
@Table(name = "geneset")
public class Geneset implements java.io.Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Column(nullable = false)
    private String name;

    @Column(length = 40, nullable = false)
    private String uuid;

    @ManyToMany(fetch = FetchType.EAGER)
    @JoinTable(name = "geneset_gene", joinColumns = {
        @JoinColumn(name = "geneset_id", updatable = false, nullable = false)
    }, inverseJoinColumns = {
        @JoinColumn(name = "entrez_gene_id", updatable = false, nullable = false)
    })
// Path: core/src/main/java/org/mskcc/cbio/oncokb/serializer/SetGeneInGenesetConverter.java
// public class SetGeneInGenesetConverter extends StdConverter<Set<Gene>, Set<Gene>> {
//     @Override
//     public Set<Gene> convert(Set<Gene> genes) {
//         Set<Gene> newGenes = new HashSet<>();
//         for (Gene gene : genes) {
//             Gene newGene = new Gene();
//             newGene.setGeneAliases(newGene.getGeneAliases());
//             newGene.setHugoSymbol(gene.getHugoSymbol());
//             newGene.setEntrezGeneId(gene.getEntrezGeneId());
//             newGene.setOncogene(gene.getOncogene());
//             newGene.setTSG(gene.getTSG());
//             newGene.setGrch37Isoform(gene.getGrch37Isoform());
//             newGene.setGrch37RefSeq(gene.getGrch37RefSeq());
//             newGene.setGrch38Isoform(gene.getGrch38Isoform());
//             newGene.setGrch38RefSeq(gene.getGrch38RefSeq());
//             newGenes.add(newGene);
//         }
//         return newGenes;
//     }
// }


// Path: core/src/main/java/org/mskcc/cbio/oncokb/model/Geneset.java
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.mskcc.cbio.oncokb.serializer.SetGeneInGenesetConverter;
import javax.persistence.*;
import java.util.Objects;
import java.util.Set;

package org.mskcc.cbio.oncokb.model;



/**
 * Created by Hongxin Zhang on 2019-08-08.
 */

@NamedQueries({
    @NamedQuery(
        name = "findGenesetByName",
        query = "select g from Geneset g where g.name=?"
    ),
    @NamedQuery(
        name = "findGenesetByUUID",
        query = "select g from Geneset g where g.uuid=?"
    ),
})

@Entity
@Table(name = "geneset")
public class Geneset implements java.io.Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Column(nullable = false)
    private String name;

    @Column(length = 40, nullable = false)
    private String uuid;

    @ManyToMany(fetch = FetchType.EAGER)
    @JoinTable(name = "geneset_gene", joinColumns = {
        @JoinColumn(name = "geneset_id", updatable = false, nullable = false)
    }, inverseJoinColumns = {
        @JoinColumn(name = "entrez_gene_id", updatable = false, nullable = false)
    })
    @JsonSerialize(converter = SetGeneInGenesetConverter.class)