View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements. See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership. The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License. You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied. See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package com.tapas.evidence.entity;
20  
21  import javax.persistence.CascadeType;
22  import javax.persistence.Column;
23  import javax.persistence.Entity;
24  import javax.persistence.EnumType;
25  import javax.persistence.Enumerated;
26  import javax.persistence.FetchType;
27  import javax.persistence.GeneratedValue;
28  import javax.persistence.GenerationType;
29  import javax.persistence.Id;
30  import javax.persistence.JoinColumn;
31  import javax.persistence.Lob;
32  import javax.persistence.NamedQueries;
33  import javax.persistence.NamedQuery;
34  import javax.persistence.OneToOne;
35  import javax.persistence.Table;
36  
37  import lombok.Getter;
38  import lombok.NoArgsConstructor;
39  import lombok.Setter;
40  import lombok.ToString;
41  
42  import com.tapas.evidence.fe.ApplicationConstants;
43  
44  /**
45   * @author Michal Bocek
46   * @since 1.0.0
47   */
48  @Entity
49  @Table(name = "RESPONSIBLE_PERSON")
50  @ToString
51  @NoArgsConstructor
52  @NamedQueries(value = { 
53  	@NamedQuery(name = ResponsiblePerson.QUERY_NAME_FIND_ALL_BY_DELETED_FLAG, query = ResponsiblePerson.QUERY_FIND_ALL_BY_DELETED_FLAG), 
54  	@NamedQuery(name = ResponsiblePerson.QUERY_NAME_FIND_BY_KINDERGARTEN_ID_AND_DELETED_FLAG, query = ResponsiblePerson.QUERY_FIND_BY_KINDERGARTEN_ID_AND_DELETED_FLAG), 
55  	@NamedQuery(name = ResponsiblePerson.QUERY_NAME_FIND_BY_KINDERGARTEN_ID_AND_TYPE_AND_DELETE_FLAG, query = ResponsiblePerson.QUERY_FIND_BY_KINDERGARTEN_ID_AND_TYPE_AND_DELETE_FLAG) 
56  })
57  public class ResponsiblePerson extends Person {
58  
59  	private static final long serialVersionUID = ApplicationConstants.VERSION;
60  	
61  	public static final String QUERY_NAME_FIND_ALL_BY_DELETED_FLAG = "ResponsiblePerson.finaAllByDeletedFlag";   
62  	public static final String QUERY_FIND_ALL_BY_DELETED_FLAG = "SELECT r FROM ResponsiblePerson r " +
63  			"WHERE r.deleted = :deleted AND r.tenant.id = :tenantId";
64  
65  	public static final String QUERY_NAME_FIND_BY_KINDERGARTEN_ID_AND_DELETED_FLAG = "ResponsiblePerson.finaByKindergartenIdAndDeletedFlag";
66  	public static final String QUERY_FIND_BY_KINDERGARTEN_ID_AND_DELETED_FLAG = "SELECT r FROM ResponsiblePerson r " +
67  			"WHERE r.kindergarten.id = :kindergartenId AND r.deleted = :deleted AND r.tenant.id = :tenantId";
68  
69  	public static final String QUERY_NAME_FIND_BY_KINDERGARTEN_ID_AND_TYPE_AND_DELETE_FLAG = "ResponsiblePerson.finalByKindergartenIdAndTypeAndDeletedFlag";
70  	public static final String QUERY_FIND_BY_KINDERGARTEN_ID_AND_TYPE_AND_DELETE_FLAG = "SELECT r FROM ResponsiblePerson r " +
71  			"WHERE r.kindergarten.id = :kindergartenId AND r.type = :type AND r.deleted = :deleted AND r.tenant.id = :tenantId";
72  	
73  	@Getter @Setter
74  	@Id	@GeneratedValue(strategy = GenerationType.AUTO)
75  	private Long id;
76  
77  	@Getter @Setter
78  	@OneToOne(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }, optional = false)
79  	@JoinColumn(name = "CONTACT_ID")
80  	private Contact contact;
81  	
82  	@Getter @Setter
83  	@Enumerated(value = EnumType.STRING)
84  	private ResponsibilityType type;
85  	
86  	@Getter @Setter
87  	@Lob
88  	@Column(name = "PHOTO", length = 102400)
89  	private byte[] photo;
90  	
91  	public ResponsiblePerson(final Long id) {
92  		this.id = id;
93  	}
94  }