|
| 1 | +/* |
| 2 | + * |
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | + * you may not use this file except in compliance with the License. |
| 5 | + * You may obtain a copy of the License at |
| 6 | + * |
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + * |
| 9 | + * Unless required by applicable law or agreed to in writing, software |
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | + * See the License for the specific language governing permissions and |
| 13 | + * limitations under the License. |
| 14 | + */ |
| 15 | +package org.ohdsi.webapi.cohortdefinition; |
| 16 | + |
| 17 | +import java.io.Serializable; |
| 18 | +import java.util.Date; |
| 19 | +import javax.persistence.CascadeType; |
| 20 | +import javax.persistence.Column; |
| 21 | +import javax.persistence.Entity; |
| 22 | +import javax.persistence.EnumType; |
| 23 | +import javax.persistence.Enumerated; |
| 24 | +import javax.persistence.FetchType; |
| 25 | +import javax.persistence.GeneratedValue; |
| 26 | +import javax.persistence.Id; |
| 27 | +import javax.persistence.JoinColumn; |
| 28 | +import javax.persistence.NamedAttributeNode; |
| 29 | +import javax.persistence.NamedEntityGraph; |
| 30 | +import javax.persistence.NamedSubgraph; |
| 31 | +import javax.persistence.OneToOne; |
| 32 | + |
| 33 | +/** |
| 34 | + * JPA Entity for Cohort Definitions |
| 35 | + * @author cknoll1 |
| 36 | + */ |
| 37 | +@Entity(name = "cohort_definition") |
| 38 | +@NamedEntityGraph( |
| 39 | + name = "CohortDefinition.withDetail", |
| 40 | + attributeNodes = { @NamedAttributeNode(value = "details", subgraph = "detailsGraph") }, |
| 41 | + subgraphs = {@NamedSubgraph(name = "detailsGraph", type = CohortDefinitionDetails.class, attributeNodes = { @NamedAttributeNode(value="expression")})} |
| 42 | +) |
| 43 | +public class CohortDefinition implements Serializable{ |
| 44 | + |
| 45 | + private static final long serialVersionUID = 1L; |
| 46 | + |
| 47 | + @Id |
| 48 | + @GeneratedValue |
| 49 | + private Integer id; |
| 50 | + |
| 51 | + private String name; |
| 52 | + |
| 53 | + private String description; |
| 54 | + |
| 55 | + @Enumerated(EnumType.STRING) |
| 56 | + @Column(name="expression_type") |
| 57 | + private ExpressionType expressionType; |
| 58 | + |
| 59 | + @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, optional=false, orphanRemoval = true) |
| 60 | + @JoinColumn(name="id") |
| 61 | + CohortDefinitionDetails details; |
| 62 | + |
| 63 | + @Column(name="created_by") |
| 64 | + private String createdBy; |
| 65 | + |
| 66 | + @Column(name="created_date") |
| 67 | + private Date createdDate; |
| 68 | + |
| 69 | + @Column(name="modified_by") |
| 70 | + private String modifiedBy; |
| 71 | + |
| 72 | + @Column(name="modified_date") |
| 73 | + private Date modifiedDate; |
| 74 | + |
| 75 | + public Integer getId() { |
| 76 | + return id; |
| 77 | + } |
| 78 | + |
| 79 | + public void setId(Integer id) { |
| 80 | + this.id = id; |
| 81 | + } |
| 82 | + |
| 83 | + public String getName() { |
| 84 | + return name; |
| 85 | + } |
| 86 | + |
| 87 | + public CohortDefinition setName(String name) { |
| 88 | + this.name = name; |
| 89 | + return this; |
| 90 | + } |
| 91 | + |
| 92 | + public String getDescription() { |
| 93 | + return description; |
| 94 | + } |
| 95 | + |
| 96 | + public CohortDefinition setDescription(String description) { |
| 97 | + this.description = description; |
| 98 | + return this; |
| 99 | + } |
| 100 | + |
| 101 | + public ExpressionType getExpressionType() { |
| 102 | + return expressionType; |
| 103 | + } |
| 104 | + |
| 105 | + public CohortDefinition setExpressionType(ExpressionType expressionType) { |
| 106 | + this.expressionType = expressionType; |
| 107 | + return this; |
| 108 | + } |
| 109 | + |
| 110 | + public CohortDefinitionDetails getDetails() { |
| 111 | + return this.details; |
| 112 | + } |
| 113 | + |
| 114 | + public CohortDefinition setDetails(CohortDefinitionDetails details) { |
| 115 | + this.details = details; |
| 116 | + return this; |
| 117 | + } |
| 118 | + |
| 119 | + public String getCreatedBy() { |
| 120 | + return createdBy; |
| 121 | + } |
| 122 | + |
| 123 | + public CohortDefinition setCreatedBy(String createdBy) { |
| 124 | + this.createdBy = createdBy; |
| 125 | + return this; |
| 126 | + } |
| 127 | + |
| 128 | + public Date getCreatedDate() { |
| 129 | + return createdDate; |
| 130 | + } |
| 131 | + |
| 132 | + public CohortDefinition setCreatedDate(Date createdDate) { |
| 133 | + this.createdDate = createdDate; |
| 134 | + return this; |
| 135 | + } |
| 136 | + |
| 137 | + public String getModifiedBy() { |
| 138 | + return modifiedBy; |
| 139 | + } |
| 140 | + |
| 141 | + public CohortDefinition setModifiedBy(String modifiedBy) { |
| 142 | + this.modifiedBy = modifiedBy; |
| 143 | + return this; |
| 144 | + } |
| 145 | + |
| 146 | + public Date getModifiedDate() { |
| 147 | + return modifiedDate; |
| 148 | + } |
| 149 | + |
| 150 | + public CohortDefinition setModifiedDate(Date modifiedDate) { |
| 151 | + this.modifiedDate = modifiedDate; |
| 152 | + return this; |
| 153 | + } |
| 154 | +} |
0 commit comments