X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=portal-BE%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportal%2Fdomain%2Fdb%2Ffn%2FFnSharedContext.java;fp=portal-BE%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportal%2Fdomain%2Fdb%2Ffn%2FFnSharedContext.java;h=a348ef43739fc2937163ca0fbd94d98585f6bb69;hb=f7e300301a4a5f01585677657b96a80338cdf03d;hp=ca16d343a0d68dd10697736b33b307dbfb6d7a16;hpb=cbc896f277fcf24dc52fcd591667e4ede1e9a9ab;p=portal.git diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnSharedContext.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnSharedContext.java index ca16d343..a348ef43 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnSharedContext.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnSharedContext.java @@ -42,17 +42,17 @@ package org.onap.portal.domain.db.fn; import java.io.Serializable; import java.time.LocalDateTime; +import java.util.Set; import javax.persistence.Column; import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.SequenceGenerator; +import javax.persistence.NamedNativeQueries; +import javax.persistence.NamedNativeQuery; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; import javax.persistence.Table; import javax.persistence.UniqueConstraint; import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; -import javax.validation.constraints.PastOrPresent; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; import lombok.Builder; @@ -60,6 +60,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import org.hibernate.validator.constraints.SafeHtml; +import org.onap.portal.domain.db.DomainVo; /* CREATE TABLE `fn_shared_context` ( @@ -73,25 +74,32 @@ CREATE TABLE `fn_shared_context` ( ) */ +@NamedQueries({ + @NamedQuery( + name = "FnSharedContext.getByContextId", + query = "FROM FnSharedContext WHERE contextId = :contextId"), + @NamedQuery( + name = "FnSharedContext.getByContextIdAndCkey", + query = "FROM FnSharedContext WHERE contextId = :contextId and ckey = :ckey") +}) + +@NamedNativeQueries({ + @NamedNativeQuery( + name = "FnSharedContext.deleteByCreated", + query = "delete FnSharedContext where created < :created" + ) +}) + @Table(name = "fn_shared_context", uniqueConstraints ={ @UniqueConstraint(columnNames = {"context_Id", "ckey"}) }) @NoArgsConstructor @AllArgsConstructor -@Builder @Getter @Setter @Entity -public class FnSharedContext implements Serializable { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "id", nullable = false, length = 11, columnDefinition = "int(11) AUTO_INCREMENT") - @Digits(integer = 11, fraction = 0) - private Long id; - @Column(name = "create_time", nullable = false, columnDefinition = "timestamp DEFAULT current_timestamp() ON UPDATE current_timestamp()") - @PastOrPresent - @NotNull - private LocalDateTime createTime; +public class FnSharedContext extends DomainVo implements Serializable { + @Column(name = "context_id", length = 64, nullable = false) @Size(max = 64) @SafeHtml @@ -107,4 +115,19 @@ public class FnSharedContext implements Serializable { @SafeHtml @NotNull private String cvalue; + + @Builder + public FnSharedContext(@Digits(integer = 11, fraction = 0) Long id, + LocalDateTime created, LocalDateTime modified, Long rowNum, Serializable auditUserId, + DomainVo createdId, DomainVo modifiedId, Set fnUsersCreatedId, + Set fnUsersModifiedId, + @Size(max = 64) @NotNull String contextId, + @Size(max = 128) @NotNull String ckey, + @Size(max = 1024) @NotNull String cvalue) { + super(id, created, modified, rowNum, auditUserId, createdId, modifiedId, fnUsersCreatedId, + fnUsersModifiedId); + this.contextId = contextId; + this.ckey = ckey; + this.cvalue = cvalue; + } }