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;h=a348ef43739fc2937163ca0fbd94d98585f6bb69;hb=786310021cda6f7cd181da7aed8afa38e3f10efa;hp=7c02183780a21b3a95b22f0baa09acb7a95ea321;hpb=0dd6f1189815079526c3f5211f01650bbe5e665b;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 7c021837..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,22 +42,25 @@ 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.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; 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` ( @@ -71,6 +74,22 @@ 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"}) }) @@ -79,16 +98,8 @@ CREATE TABLE `fn_shared_context` ( @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 @@ -104,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; + } }