1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.exoplatform.commons.search.domain;
18
19 import org.exoplatform.commons.api.persistence.ExoEntity;
20
21 import javax.persistence.*;
22 import java.io.Serializable;
23 import java.util.Date;
24
25
26
27
28
29
30
31 @Entity
32 @ExoEntity
33 @Table(name = "ES_INDEXING_QUEUE")
34 @NamedQueries({
35 @NamedQuery(name = "IndexingOperation.deleteAllIndexingOperationsHavingIdLessThanOrEqual",
36 query = "DELETE FROM IndexingOperation q WHERE q.id <= :id"),
37 @NamedQuery(name = "IndexingOperation.deleteAllByEntityType",
38 query = "DELETE FROM IndexingOperation q WHERE q.entityType = :entityType"),
39 @NamedQuery(name = "IndexingOperation.findAll",
40 query = "SELECT q FROM IndexingOperation q ORDER BY q.id")
41 })
42 public class IndexingOperation implements Serializable {
43
44 @Id
45 @SequenceGenerator(name="SEQ_ES_INDEXING_QUEUE_ID", sequenceName="SEQ_ES_INDEXING_QUEUE_ID")
46 @GeneratedValue(strategy=GenerationType.AUTO, generator="SEQ_ES_INDEXING_QUEUE_ID")
47 @Column(name = "OPERATION_ID")
48 private Long id;
49
50 @Column(name = "ENTITY_TYPE")
51 private String entityType;
52
53 @Column(name = "ENTITY_ID")
54 private String entityId;
55
56 @Column(name = "OPERATION_TYPE")
57 private String operation;
58
59
60
61 @Temporal(TemporalType.TIMESTAMP)
62 @Column(name = "OPERATION_TIMESTAMP", insertable = false, updatable = false)
63 private Date timestamp;
64
65 public IndexingOperation() {
66 }
67
68 public IndexingOperation(String entityId, String entityType, OperationType operation) {
69 this.entityId = entityId;
70 this.entityType = entityType;
71 this.setOperation(operation);
72 }
73
74 public Long getId() {
75 return id;
76 }
77
78 public void setId(Long id) {
79 this.id = id;
80 }
81
82 public String getEntityId() {
83 return entityId;
84 }
85
86 public void setEntityId(String entityId) {
87 this.entityId = entityId;
88 }
89
90 public String getEntityType() {
91 return entityType;
92 }
93
94 public void setEntityType(String entityType) {
95 this.entityType = entityType;
96 }
97
98 public OperationType getOperation() {
99 return this.operation==null?null:OperationType.getById(this.operation);
100 }
101
102 public void setOperation(OperationType operation) {
103 this.operation = operation==null?null:operation.getOperationId();
104 }
105
106 @Override
107 public boolean equals(Object o) {
108 if (this == o) return true;
109 if (o == null || getClass() != o.getClass()) return false;
110
111 IndexingOperation that = (IndexingOperation) o;
112
113 if (entityId != null ? !entityId.equals(that.entityId) : that.entityId != null) return false;
114 if (entityType != null ? !entityType.equals(that.entityType) : that.entityType != null) return false;
115 if (id != null ? !id.equals(that.id) : that.id != null) return false;
116 if (operation != null ? !operation.equals(that.operation) : that.operation != null) return false;
117
118 return true;
119 }
120
121 @Override
122 public int hashCode() {
123 int result = id != null ? id.hashCode() : 0;
124 result = 31 * result + (entityType != null ? entityType.hashCode() : 0);
125 result = 31 * result + (entityId != null ? entityId.hashCode() : 0);
126 result = 31 * result + (operation != null ? operation.hashCode() : 0);
127 return result;
128 }
129 }
130