diff options
Diffstat (limited to 'portal-BE/src/main/java/org/onap/portal/domain/db')
81 files changed, 1815 insertions, 1091 deletions
diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/DomainVo.java b/portal-BE/src/main/java/org/onap/portal/domain/db/DomainVo.java new file mode 100644 index 00000000..477d915b --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/DomainVo.java @@ -0,0 +1,178 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portal.domain.db; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.Set; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Index; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.validation.constraints.Digits; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.onap.portal.domain.db.fn.FnUser; +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; + +@Table(name = "domain") +@Getter +@Setter +@Entity +@NoArgsConstructor +@AllArgsConstructor +@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) +public class DomainVo implements Serializable, Cloneable, Comparable { + + private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(DomainVo.class); + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "id", length = 11, nullable = false, columnDefinition = "bigint AUTO_INCREMENT") + @Digits(integer = 11, fraction = 0) + private Long id; + private LocalDateTime created; + private LocalDateTime modified; + private Long rowNum; + private Serializable auditUserId; + + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "created_id", columnDefinition = "bigint") + private DomainVo createdId; + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "modified_id", columnDefinition = "bigint") + private DomainVo modifiedId; + + @OneToMany( + targetEntity = DomainVo.class, + mappedBy = "createdId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<DomainVo> fnUsersCreatedId; + @OneToMany( + targetEntity = DomainVo.class, + mappedBy = "modifiedId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<DomainVo> fnUsersModifiedId; + + public DomainVo(Long id) { + this.id = id; + } + + @Override + public int compareTo(Object obj) { + Long c1 = this.getId(); + Long c2 = ((org.onap.portalsdk.core.domain.support.DomainVo) obj).getId(); + return c1 != null && c2 != null ? c1.compareTo(c2) : 1; + } + + public Object copy(boolean isIdNull) { + ByteArrayOutputStream baos = null; + ByteArrayInputStream bais = null; + ObjectOutputStream oos = null; + ObjectInputStream ois = null; + DomainVo newVo = null; + + try { + baos = new ByteArrayOutputStream(); + oos = new ObjectOutputStream(baos); + oos.writeObject(this); + bais = new ByteArrayInputStream(baos.toByteArray()); + ois = new ObjectInputStream(bais); + newVo = (DomainVo) ois.readObject(); + if (isIdNull) { + newVo.setId(null); + } + } catch (Exception var8) { + logger.error("exception occured", var8); + } + + return newVo; + } + + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + public boolean equals(Object other) { + if (this == other) { + return true; + } else if (other == null) { + return false; + } else if (!(other instanceof DomainVo)) { + return false; + } else { + DomainVo castOther = (DomainVo) other; + return this.getId().equals(castOther.getId()) + && this.getCreated().equals(castOther.getCreated()) + && this.getModified().equals(castOther.getModified()); + } + } + + public DomainVo(DomainVo domainVo) { + this.id = domainVo.id; + this.created = domainVo.created; + this.modified = domainVo.modified; + this.rowNum = domainVo.rowNum; + this.auditUserId = domainVo.auditUserId; + } +} diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/VUrlAccess.java b/portal-BE/src/main/java/org/onap/portal/domain/db/VUrlAccess.java index 9f50f3bd..34e22c45 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/VUrlAccess.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/VUrlAccess.java @@ -46,6 +46,7 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import lombok.Getter; import lombok.NoArgsConstructor; @@ -69,7 +70,8 @@ import org.hibernate.annotations.Subselect; @NoArgsConstructor public class VUrlAccess implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", nullable = false) private Long id; @Column(name = "url", length = 200) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFavoriteReports.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFavoriteReports.java index 6c8296a7..ce47c2e6 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFavoriteReports.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFavoriteReports.java @@ -43,8 +43,11 @@ package org.onap.portal.domain.db.cr; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.IdClass; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.constraints.Digits; import javax.validation.constraints.Positive; @@ -77,6 +80,8 @@ CREATE TABLE `cr_favorite_reports` ( public class CrFavoriteReports implements Serializable{ @Id @Column(name = "user_id", length = 11, nullable = false) + + @GeneratedValue(strategy = GenerationType.AUTO) @Digits(integer = 11, fraction = 0) @Positive private Long userId; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFilehistLog.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFilehistLog.java index 3dec4ee1..f6b8a650 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFilehistLog.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFilehistLog.java @@ -43,7 +43,10 @@ package org.onap.portal.domain.db.cr; import java.time.LocalDateTime; 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.Table; import javax.validation.constraints.Digits; import javax.validation.constraints.Size; @@ -73,6 +76,8 @@ CREATE TABLE `cr_filehist_log` ( @Entity public class CrFilehistLog { @Id + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "schedule_id", length = 11, nullable = false) @Digits(integer = 11, fraction = 0) private Long scheduledId; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFolder.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFolder.java index 44e3902f..741258be 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFolder.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFolder.java @@ -54,6 +54,7 @@ import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; @@ -93,7 +94,8 @@ CREATE TABLE `cr_folder` ( @Entity public class CrFolder implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "folder_id", length = 11, nullable = false) @Digits(integer = 11, fraction = 0) @Positive @@ -114,7 +116,7 @@ public class CrFolder implements Serializable { @Column(name = "create_date", nullable = false, columnDefinition = "datetime DEFAULT current_timestamp() ON UPDATE current_timestamp()") @NotNull private LocalDateTime createDate; - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) @JoinColumn(name = "parent_Folder_Id") private CrFolder parentFolderId; @Column(name = "public_Yn", length = 1, nullable = false, columnDefinition = "varchar(1) DEFAULT 'n'") @@ -125,7 +127,7 @@ public class CrFolder implements Serializable { @OneToMany( targetEntity = CrFolder.class, mappedBy = "parentFolderId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<CrFolder> crFolders; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFolderAccess.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFolderAccess.java index 05ec2465..7a99359a 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFolderAccess.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrFolderAccess.java @@ -47,6 +47,7 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; @@ -80,7 +81,8 @@ CREATE TABLE `cr_folder_access` ( @Entity public class CrFolderAccess implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "folder_access_id", length = 11, nullable = false) @Digits(integer = 11, fraction = 0) @Positive diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrLuFileType.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrLuFileType.java index 94201c58..e4393d93 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrLuFileType.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrLuFileType.java @@ -46,8 +46,11 @@ import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; @@ -81,6 +84,8 @@ CREATE TABLE `cr_lu_file_type` ( public class CrLuFileType implements Serializable { @Id @Column(name = "lookup_id", length = 2, nullable = false) + + @GeneratedValue(strategy = GenerationType.AUTO) @Digits(integer = 2, fraction = 0) @Positive private Long lookupId; @@ -101,7 +106,7 @@ public class CrLuFileType implements Serializable { @OneToMany( targetEntity = CrReportFileHistory.class, mappedBy = "fileTypeId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<CrReportFileHistory> crReportFileHistories; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReport.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReport.java index 791518d2..a7e6fdc4 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReport.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReport.java @@ -201,35 +201,35 @@ public class CrReport implements Serializable { @OneToMany( targetEntity = CrReportSchedule.class, mappedBy = "repId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<CrReportSchedule> crReportSchedules; @OneToMany( targetEntity = CrReportAccess.class, mappedBy = "repId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<CrReportAccess> crReportAccesses; @OneToMany( targetEntity = CrReportLog.class, mappedBy = "repId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<CrReportLog> crReportLogs; @OneToMany( targetEntity = CrReportEmailSentLog.class, mappedBy = "repId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<CrReportEmailSentLog> crReportEmailSentLogs; @OneToMany( targetEntity = CrReportFileHistory.class, mappedBy = "repId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<CrReportFileHistory> crReportFileHistories; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportAccess.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportAccess.java index 2eb50c74..15aaf027 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportAccess.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportAccess.java @@ -87,7 +87,7 @@ CREATE TABLE `cr_report_access` ( @IdClass(CrReportAccessId.class) public class CrReportAccess implements Serializable{ @Id - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) @JoinColumn(name = "rep_id") @Valid private CrReport repId; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportEmailSentLog.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportEmailSentLog.java index e43c5c76..7a63890d 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportEmailSentLog.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportEmailSentLog.java @@ -103,7 +103,7 @@ public class CrReportEmailSentLog implements Serializable { @SafeHtml @NotNull private String genKey; - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) @JoinColumn(name = "rep_id", nullable = false) @NotNull @Valid diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportFileHistory.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportFileHistory.java index 05696ab6..63aafa77 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportFileHistory.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportFileHistory.java @@ -47,12 +47,15 @@ import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.ManyToOne; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.Valid; import javax.validation.constraints.Digits; @@ -108,6 +111,7 @@ CREATE TABLE `cr_report_file_history` ( public class CrReportFileHistory implements Serializable { @Id @Column(name = "hist_id", nullable = false, length = 11) + @GeneratedValue(strategy = GenerationType.AUTO) @Digits(integer = 11, fraction = 0) private Long histId; @Column(name = "sched_user_id", nullable = false) @@ -122,7 +126,7 @@ public class CrReportFileHistory implements Serializable { @Digits(integer = 11, fraction = 0) @NotNull private Long userId; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) @JoinColumn(name = "rep_id") @Valid private CrReport repId; @@ -133,7 +137,7 @@ public class CrReportFileHistory implements Serializable { @Size(max = 50) @SafeHtml private String recurrence; - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) @JoinColumn(name = "file_type_id") @Valid private CrLuFileType fileTypeId; @@ -170,11 +174,11 @@ public class CrReportFileHistory implements Serializable { @Digits(integer = 38, fraction = 0) private Long deletedBy; - @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) @JoinTable( name = "cr_hist_user_map", joinColumns = {@JoinColumn(name = "hist_id", referencedColumnName = "hist_id")}, - inverseJoinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "user_id")} + inverseJoinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "id", columnDefinition = "bigint not null")} ) private Set<FnUser> fnUserList; } diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportLog.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportLog.java index 30a0b27f..2c05fa50 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportLog.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportLog.java @@ -52,6 +52,7 @@ import javax.persistence.Id; import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.Valid; import javax.validation.constraints.Digits; @@ -87,10 +88,11 @@ CREATE TABLE `cr_report_log` ( @Entity public class CrReportLog implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @JoinColumn(name = "id") private Long id; - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) @JoinColumn(name = "rep_id") @NotNull @Valid diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportSchedule.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportSchedule.java index 611dd194..0920f186 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportSchedule.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportSchedule.java @@ -53,6 +53,7 @@ import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.Valid; import javax.validation.constraints.Digits; @@ -102,7 +103,8 @@ CREATE TABLE `cr_report_schedule` ( @Entity public class CrReportSchedule implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "schedule_id", length = 11, nullable = false) @Digits(integer = 11, fraction = 0) @Positive @@ -112,7 +114,7 @@ public class CrReportSchedule implements Serializable { @Positive @NotNull private Long schedUserId; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) @JoinColumn(name = "rep_id", nullable = false) @Valid @NotNull @@ -180,7 +182,7 @@ public class CrReportSchedule implements Serializable { @OneToMany( targetEntity = CrReportScheduleUsers.class, mappedBy = "scheduleId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<CrReportScheduleUsers> crReportScheduleUsers; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportScheduleUsers.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportScheduleUsers.java index 237956c1..8c6d761e 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportScheduleUsers.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportScheduleUsers.java @@ -84,7 +84,7 @@ CREATE TABLE `cr_report_schedule_users` ( @IdClass(CrReportScheduleUsersId.class) public class CrReportScheduleUsers implements Serializable{ @Id - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) @JoinColumn(name = "schedule_id", nullable = false) @Valid @NotNull diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportTemplateMap.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportTemplateMap.java index a886bfd4..466902aa 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportTemplateMap.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrReportTemplateMap.java @@ -43,7 +43,10 @@ package org.onap.portal.domain.db.cr; import java.io.Serializable; 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.Table; import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; @@ -72,6 +75,8 @@ public class CrReportTemplateMap implements Serializable { @Id @Column(name = "report_id", nullable = false) @NotNull + + @GeneratedValue(strategy = GenerationType.AUTO) private Long reportId; @Column(name = "template_file", length = 200) @Pattern(regexp = "[YNyn]") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableJoin.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableJoin.java index eb1117cb..c894bf00 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableJoin.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableJoin.java @@ -51,6 +51,7 @@ import javax.persistence.Id; import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.Valid; import javax.validation.constraints.NotNull; @@ -86,15 +87,16 @@ CREATE TABLE `cr_table_join` ( public class CrTableJoin implements Serializable { //TODO Unique constrains {srcTableName, destTableName}? @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", nullable = false, columnDefinition = "int(11) auto_increment") private Long id; - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) @JoinColumn(name = "src_table_name", nullable = false) @Valid @NotNull private CrTableSource srcTableName; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) @JoinColumn(name = "dest_table_name", nullable = false) @Valid @NotNull diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableRole.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableRole.java index 7b6a3013..8042c414 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableRole.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableRole.java @@ -82,7 +82,7 @@ public class CrTableRole implements Serializable{ @Id @Valid @JoinColumn(name = "table_name", nullable = false) - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) private CrTableSource tableName; @Id @Digits(integer = 11, fraction = 0) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableSource.java b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableSource.java index 791e5617..078b5385 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableSource.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/cr/CrTableSource.java @@ -113,21 +113,21 @@ public class CrTableSource implements Serializable { @OneToMany( targetEntity = CrTableJoin.class, mappedBy = "srcTableName", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<CrTableJoin> crTableJoins; @OneToMany( targetEntity = CrTableJoin.class, mappedBy = "destTableName", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<CrTableJoin> crTableJoins1; @OneToMany( targetEntity = CrTableRole.class, mappedBy = "tableName", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<CrTableRole> crTableRoles; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpAppFunction.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpAppFunction.java index d37c71ec..2c23c3d7 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpAppFunction.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpAppFunction.java @@ -41,28 +41,30 @@ package org.onap.portal.domain.db.ep; import java.io.Serializable; +import java.time.LocalDateTime; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.IdClass; import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; import javax.persistence.OneToMany; import javax.persistence.Table; import javax.validation.Valid; +import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; -import lombok.EqualsAndHashCode; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import org.hibernate.validator.constraints.SafeHtml; -import org.onap.portal.domain.db.ep.EpAppFunction.EpAppFunctionId; +import org.onap.portal.domain.db.DomainVo; import org.onap.portal.domain.db.fn.FnApp; /* @@ -76,51 +78,90 @@ CREATE TABLE `ep_app_function` ( ) */ -@Table(name = "ep_app_function", indexes = {@Index(name = "fk_ep_app_function_app_id", columnList = "app_id")}) +@NamedQueries({ + @NamedQuery( + name = "EpAppFunction.getAppRoleFunctionList", + query = "from\n" + + " EpAppRoleFunction rf,\n" + + " EpAppFunction f\n" + + " where\n" + + " rf.fnRole.id = :roleId\n" + + " and rf.appId.id = :appId\n" + + " and rf.appId.id = f.appId.id\n" + + " and rf.epAppFunction.functionCd = f.functionCd" + ) +}) + +@Table(name = "ep_app_function", indexes = { + @Index(name = "fk_ep_app_function_app_id", columnList = "app_id"), + @Index(name = "fk_ep_app_id_function_cd", columnList = "app_id, function_cd", unique = true)}) @Getter @Setter @Entity -@IdClass(EpAppFunctionId.class) @NoArgsConstructor @AllArgsConstructor -public class EpAppFunction implements Serializable{ - @Id - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinColumn(name = "app_id") - @Valid - private FnApp appId; - @Id - @Column(name = "function_cd", length = 250, nullable = false) - @Size(max = 250) - @NotNull - @SafeHtml - private String functionCd; - @Column(name = "function_name", length = 250, nullable = false) - @Size(max = 250) - @NotNull - @SafeHtml - private String functionName; - @OneToMany( - targetEntity = EpAppRoleFunction.class, - mappedBy = "epAppFunction", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<EpAppRoleFunction> epAppRoleFunctions; +public class EpAppFunction extends DomainVo implements Serializable { + + @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) + @JoinColumn(name = "app_id", columnDefinition = "bigint") + @Valid + private FnApp appId; + @Column(name = "function_cd", length = 250, nullable = false) + @Size(max = 250) + @NotNull + @SafeHtml + private String functionCd; + @Column(name = "function_name", length = 250, nullable = false) + @Size(max = 250) + @NotNull + @SafeHtml + private String functionName; + + private Long roleId; + private String type; + @SafeHtml + private String action; + @SafeHtml + private String editUrl; + + @OneToMany( + targetEntity = EpAppRoleFunction.class, + mappedBy = "epAppFunction", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<EpAppRoleFunction> epAppRoleFunctions; + + public EpAppFunction(Long id, String code, String name, FnApp appId, String type, String action, String editUrl) { + super(); + super.setId(id); + this.functionCd = code; + this.functionName = name; + this.appId = appId; + this.type = type; + this.action = action; + this.editUrl = editUrl; + } - @Getter - @Setter - @EqualsAndHashCode - @NoArgsConstructor - @AllArgsConstructor - public static class EpAppFunctionId implements Serializable { - @Valid - private FnApp appId; - @Size(max = 250) - @NotNull - @SafeHtml - private String functionCd; - } + @Builder + public EpAppFunction(@Digits(integer = 11, fraction = 0) Long id, + LocalDateTime created, LocalDateTime modified, Long rowNum, Serializable auditUserId, + DomainVo createdId, DomainVo modifiedId, Set<DomainVo> fnUsersCreatedId, + Set<DomainVo> fnUsersModifiedId, @Valid FnApp appId, + @Size(max = 250) @NotNull @SafeHtml String functionCd, + @Size(max = 250) @NotNull @SafeHtml String functionName, Long roleId, String type, + @SafeHtml String action, @SafeHtml String editUrl, + Set<EpAppRoleFunction> epAppRoleFunctions) { + super(id, created, modified, rowNum, auditUserId, createdId, modifiedId, fnUsersCreatedId, fnUsersModifiedId); + this.appId = appId; + this.functionCd = functionCd; + this.functionName = functionName; + this.roleId = roleId; + this.type = type; + this.action = action; + this.editUrl = editUrl; + this.epAppRoleFunctions = epAppRoleFunctions; + } } diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpAppRoleFunction.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpAppRoleFunction.java index 8a60688b..3cb219a3 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpAppRoleFunction.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpAppRoleFunction.java @@ -58,6 +58,7 @@ import javax.validation.Valid; import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -83,41 +84,43 @@ CREATE TABLE `ep_app_role_function` ( */ @Table(name = "ep_app_role_function", indexes = { - @Index(name = "fk_ep_app_role_function_ep_app_func_role_id", columnList = "app_id, role_id, function_cd", unique = true), - @Index(name = "fk_ep_app_role_function_ep_app_func", columnList = "app_id, function_cd"), - @Index(name = "fk_ep_app_role_function_role_id", columnList = "role_id") + @Index(name = "fk_ep_app_role_function_ep_app_func_role_id", columnList = "app_id, role_id, function_cd", unique = true), + @Index(name = "fk_ep_app_role_function_ep_app_func", columnList = "app_id, function_cd"), + @Index(name = "fk_ep_app_role_function_role_id", columnList = "role_id") }) @NoArgsConstructor @AllArgsConstructor @Getter @Setter @Entity +@Builder public class EpAppRoleFunction implements Serializable { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "id", length = 11, nullable = false, columnDefinition = "int(11) NOT NULL AUTO_INCREMENT") - @Digits(integer = 11, fraction = 0) - private Integer id; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "app_id", insertable = false, updatable = false) - @Valid - @NotNull - private FnApp appId; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "role_id") - @Valid - @NotNull - private FnRole fnRole; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumns({ - @JoinColumn(name = "app_id", referencedColumnName = "app_id"), - @JoinColumn(name = "function_cd", referencedColumnName = "function_cd") - }) - @Valid - @NotNull - private EpAppFunction epAppFunction; - @Column(name = "role_app_id", length = 20) - @Digits(integer = 20, fraction = 0) - @SafeHtml - private String roleAppId; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") + @Digits(integer = 11, fraction = 0) + private Integer id; + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "app_id", insertable = false, updatable = false, columnDefinition = "bigint") + @Valid + @NotNull + private FnApp appId; + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "role_id", columnDefinition = "bigint") + @Valid + @NotNull + private FnRole fnRole; + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumns({ + @JoinColumn(name = "app_id", referencedColumnName = "app_id"), + @JoinColumn(name = "function_cd", referencedColumnName = "function_cd") + }) + @Valid + @NotNull + private EpAppFunction epAppFunction; + @Column(name = "role_app_id", length = 20) + @Digits(integer = 20, fraction = 0) + @SafeHtml + private String roleAppId; } diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpBasicAuthAccount.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpBasicAuthAccount.java index c65c0d34..7f42a0f1 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpBasicAuthAccount.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpBasicAuthAccount.java @@ -56,6 +56,7 @@ import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -75,40 +76,38 @@ CREATE TABLE `ep_basic_auth_account` ( @Table(name = "ep_basic_auth_account") @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity public class EpBasicAuthAccount implements Serializable { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") - @Digits(integer = 11, fraction = 0) - private Long id; - @Column(name = "ext_app_name", length = 50, nullable = false) - @Size(max = 50) - @SafeHtml - @NotNull - private String extAppName; - @Column(name = "username", length = 50, nullable = false) - @Size(max = 50) - @SafeHtml - @NotNull - private String username; - @Column(name = "password", length = 50) - @Size(max = 50) - @SafeHtml - private String password; - @Column(name = "active_yn", length = 1, nullable = false, columnDefinition = "char(1) NOT NULL default 'Y'") - @Pattern(regexp = "[YNyn]") - @Size(max = 1) - @NotNull - @SafeHtml - private String activeYn; - @OneToMany( - targetEntity = EpEndpointsBasicAuthAccount.class, - mappedBy = "accountId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<EpEndpointsBasicAuthAccount> epEndpointsBasicAuthAccounts; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") + @Digits(integer = 11, fraction = 0) + private Long id; + @Column(name = "ext_app_name", length = 50, nullable = false) + @Size(max = 50) + @SafeHtml + @NotNull + private String extAppName; + @Column(name = "username", length = 50, nullable = false) + @Size(max = 50) + @SafeHtml + @NotNull + private String username; + @Column(name = "password", length = 50) + @Size(max = 50) + @SafeHtml + private String password; + @Column(name = "active_yn", nullable = false, columnDefinition = "boolean default true") + private Boolean activeYn; + @OneToMany( + targetEntity = EpEndpointsBasicAuthAccount.class, + mappedBy = "accountId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<EpEndpointsBasicAuthAccount> epEndpointsBasicAuthAccounts; } diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpEndpoints.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpEndpoints.java index ccb1bb29..a1766115 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpEndpoints.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpEndpoints.java @@ -50,6 +50,7 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; @@ -77,7 +78,8 @@ CREATE TABLE `ep_endpoints` ( @Entity public class EpEndpoints implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") @Digits(integer = 11, fraction = 0) private Long id; @@ -92,7 +94,7 @@ public class EpEndpoints implements Serializable { @OneToMany( targetEntity = EpEndpointsBasicAuthAccount.class, mappedBy = "epId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<EpEndpointsBasicAuthAccount> epEndpointsBasicAuthAccounts; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpEndpointsBasicAuthAccount.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpEndpointsBasicAuthAccount.java index 9cf7d36b..2f36b1a2 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpEndpointsBasicAuthAccount.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpEndpointsBasicAuthAccount.java @@ -53,6 +53,7 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.Valid; import javax.validation.constraints.Digits; @@ -95,15 +96,16 @@ CREATE TABLE `ep_endpoints_basic_auth_account` ( @Entity public class EpEndpointsBasicAuthAccount implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") @Digits(integer = 11, fraction = 0) private Long id; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) @JoinColumn(name = "ep_id", columnDefinition = "INT(11) DEFAULT NULL") @Valid private EpEndpoints epId; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) @JoinColumn(name = "account_id", columnDefinition = "INT(11) DEFAULT NULL") @Valid private EpBasicAuthAccount accountId; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMicroservice.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMicroservice.java index 6c6b39cc..69e28dc3 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMicroservice.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMicroservice.java @@ -54,12 +54,14 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToMany; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.Valid; import javax.validation.constraints.Digits; import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -89,6 +91,7 @@ CREATE TABLE `ep_microservice` ( }) @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity @@ -106,8 +109,8 @@ public class EpMicroservice implements Serializable { @Size(max = 50) @SafeHtml private String description; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "app_Id") + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "app_Id", columnDefinition = "bigint") @Valid private FnApp appId; @Column(name = "endpoint_url", length = 200) @@ -128,17 +131,14 @@ public class EpMicroservice implements Serializable { @Size(max = 50) @SafeHtml private String password; - @Column(name = "active", length = 1, columnDefinition = "CHAR(1) DEFAULT 'Y'") - @Pattern(regexp = "[YNyn]") - @Size(max = 1) - @SafeHtml - private String active; - @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @Column(name = "active", length = 1, columnDefinition = "boolean DEFAULT true") + private Boolean active = true; + @ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) private Set<EpWidgetCatalog> epWidgetCatalogList; @OneToMany( targetEntity = EpMicroserviceParameter.class, mappedBy = "serviceId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<EpMicroserviceParameter> epMicroserviceParameters; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMicroserviceParameter.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMicroserviceParameter.java index 36c073ac..74b051fe 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMicroserviceParameter.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMicroserviceParameter.java @@ -98,11 +98,11 @@ CREATE TABLE `ep_microservice_parameter` ( public class EpMicroserviceParameter implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", length = 11, nullable = false) @Digits(integer = 11, fraction = 0) private Long id; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) @JoinColumn(name = "service_id") private EpMicroservice serviceId; @Column(name = "para_key", length = 50) @@ -116,7 +116,7 @@ public class EpMicroserviceParameter implements Serializable { @OneToMany( targetEntity = EpWidgetCatalogParameter.class, mappedBy = "paramId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<EpWidgetCatalogParameter> epWidgetCatalogParameter; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpNotification.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpNotification.java index 424f61b8..a10cc3e3 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpNotification.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpNotification.java @@ -51,6 +51,7 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.constraints.Digits; import javax.validation.constraints.FutureOrPresent; @@ -91,7 +92,8 @@ CREATE TABLE `ep_notification` ( @Entity public class EpNotification implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "notification_ID", length = 11, nullable = false) @Digits(integer = 11, fraction = 0) private Long notificationID; @@ -145,14 +147,14 @@ public class EpNotification implements Serializable { @OneToMany( targetEntity = EpRoleNotification.class, mappedBy = "notificationID", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<EpRoleNotification> epRoleNotifications; @OneToMany( targetEntity = EpUserNotification.class, mappedBy = "notificationId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<EpUserNotification> epUserNotifications; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserAppSort.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserAppSort.java index 1976533e..a6bf71a2 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserAppSort.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserAppSort.java @@ -53,12 +53,14 @@ import javax.persistence.JoinColumn; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToOne; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.Valid; import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -88,23 +90,23 @@ CREATE TABLE `ep_pers_user_app_sort` ( }) @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity public class EpPersUserAppSort implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") @Digits(integer = 11, fraction = 0) private Long id; - @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "user_id", unique = true, nullable = false) + @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "user_id", unique = true, nullable = false, columnDefinition = "bigint") @NotNull @Valid private FnUser userID; - @Column(name = "sort_pref", length = 1, nullable = false) - @Size(max = 1) + @Column(name = "sort_pref", nullable = false) @NotNull - @SafeHtml - private String sortPref; + private Integer sortPref; } diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserWidgetPlacement.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserWidgetPlacement.java index b1e472f8..7dbb4831 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserWidgetPlacement.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserWidgetPlacement.java @@ -53,6 +53,7 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.Valid; import javax.validation.constraints.Digits; @@ -83,7 +84,7 @@ CREATE TABLE `ep_pers_user_widget_placement` ( @NamedQueries({ @NamedQuery( name = "EpPersUserWidgetPlacement.retrieveByUserId", - query = "from EpPersUserWidgetPlacement where USER_ID =:userId" + query = "from EpPersUserWidgetPlacement where userId =:userId" ) }) @@ -98,16 +99,17 @@ CREATE TABLE `ep_pers_user_widget_placement` ( @Entity public class EpPersUserWidgetPlacement implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") @Digits(integer = 11, fraction = 0) private Long id; - @ManyToOne(fetch = FetchType.LAZY,cascade = CascadeType.ALL) - @JoinColumn(name = "user_id", nullable = false) + @ManyToOne(fetch = FetchType.LAZY,cascade = CascadeType.MERGE) + @JoinColumn(name = "user_id", nullable = false, columnDefinition = "bigint") @NotNull @Valid private FnUser userId; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) @JoinColumn(name = "widget_id", nullable = false) @NotNull @Valid diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserWidgetSel.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserWidgetSel.java index 4b2785f1..2d4c76f3 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserWidgetSel.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpPersUserWidgetSel.java @@ -45,9 +45,6 @@ import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.NamedQueries; @@ -55,7 +52,6 @@ import javax.persistence.NamedQuery; import javax.persistence.Table; import javax.persistence.UniqueConstraint; import javax.validation.Valid; -import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; @@ -64,7 +60,7 @@ import lombok.NoArgsConstructor; import lombok.Setter; import org.hibernate.validator.constraints.SafeHtml; import org.onap.portal.domain.db.fn.FnUser; -import org.onap.portal.domain.dto.DomainVo; +import org.onap.portal.domain.db.DomainVo; /* CREATE TABLE `ep_pers_user_widget_sel` ( @@ -82,7 +78,7 @@ CREATE TABLE `ep_pers_user_widget_sel` ( @NamedQueries({ @NamedQuery( name = "EpPersUserWidgetSel.getEpPersUserWidgetSelForUserIdAndWidgetId", - query = "FROM EpPersUserWidgetSel WHERE userId.userId = :USERID and widgetId.widgetId = :WIDGETID") + query = "FROM EpPersUserWidgetSel WHERE userId.id = :USERID and widgetId.widgetId = :WIDGETID") }) @Table(name = "ep_pers_user_widget_sel", uniqueConstraints = { @UniqueConstraint(columnNames = {"user_id", "widget_id"}) @@ -94,17 +90,12 @@ CREATE TABLE `ep_pers_user_widget_sel` ( @Entity public class EpPersUserWidgetSel extends DomainVo implements Serializable { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "id", length = 11, nullable = false) - @Digits(integer = 11, fraction = 0) - private Long id; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "user_id", nullable = false) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "user_id", nullable = false, columnDefinition = "bigint") @NotNull @Valid private FnUser userId; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) @JoinColumn(name = "widget_id", nullable = false) @NotNull @Valid diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpRoleNotification.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpRoleNotification.java index 94df52d5..53e48073 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpRoleNotification.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpRoleNotification.java @@ -51,6 +51,7 @@ import javax.persistence.Id; import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.Valid; import javax.validation.constraints.Digits; @@ -87,16 +88,17 @@ CREATE TABLE `ep_role_notification` ( @Entity public class EpRoleNotification implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "ID", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") @Digits(integer = 11, fraction = 0) private Long id; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) @JoinColumn(name = "notification_ID") @Valid private EpNotification notificationID; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "role_ID") + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "role_ID", columnDefinition = "bigint") @Valid private FnRole roleID; @Column(name = "recv_user_id", length = 11, columnDefinition = "int(11) DEFAULT NULL") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserNotification.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserNotification.java index 15bb2b9a..441eb524 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserNotification.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserNotification.java @@ -52,6 +52,7 @@ import javax.persistence.Id; import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.Valid; import javax.validation.constraints.Digits; @@ -91,15 +92,16 @@ CREATE TABLE `ep_user_notification` ( @Entity public class EpUserNotification implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "ID", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") @Digits(integer = 11, fraction = 0) private Integer id; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "User_ID") + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "User_ID", columnDefinition = "bigint") @Valid private FnUser userId; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) @JoinColumn(name = "notification_ID") @Valid private EpNotification notificationId; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserRolesRequest.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserRolesRequest.java index 52d06b2a..113863c3 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserRolesRequest.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserRolesRequest.java @@ -52,7 +52,10 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; import javax.persistence.OneToMany; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.Valid; import javax.validation.constraints.Digits; @@ -83,6 +86,13 @@ CREATE TABLE `ep_user_roles_request` ( ) */ +@NamedQueries({ + @NamedQuery( + name = "EpUserRolesRequest.userAppRolesRequestList", + query = "FROM EpUserRolesRequest where userId.id =:userId and appId.id =:appId and requestStatus = 'P'" + ) +}) + @Table(name = "ep_user_roles_request") @NoArgsConstructor @AllArgsConstructor @@ -91,17 +101,18 @@ CREATE TABLE `ep_user_roles_request` ( @Entity public class EpUserRolesRequest implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "req_id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") @Digits(integer = 11, fraction = 0) private Long reqId; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "user_id", nullable = false) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "user_id", nullable = false, columnDefinition = "bigint") @NotNull @Valid private FnUser userId; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "app_id", nullable = false) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "app_id", nullable = false, columnDefinition = "bigint") @NotNull @Valid private FnApp appId; @@ -119,8 +130,12 @@ public class EpUserRolesRequest implements Serializable { @OneToMany( targetEntity = EpUserRolesRequestDet.class, mappedBy = "reqId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<EpUserRolesRequestDet> epUserRolesRequestDets; + + public void setEpRequestIdDetail(Set<EpUserRolesRequestDet> epMyLoginsDetail) { + this.epUserRolesRequestDets = epMyLoginsDetail; + } } diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserRolesRequestDet.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserRolesRequestDet.java index 76044530..4d2fcaea 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserRolesRequestDet.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpUserRolesRequestDet.java @@ -51,7 +51,10 @@ import javax.persistence.Id; import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; import javax.persistence.OneToOne; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.Valid; import javax.validation.constraints.Digits; @@ -78,6 +81,13 @@ CREATE TABLE `ep_user_roles_request_det` ( ) */ +@NamedQueries({ + @NamedQuery( + name = "EpUserRolesRequestDet.appRolesRequestDetailList", + query = "FROM EpUserRolesRequestDet where reqId.reqId = :reqId" + ) +}) + @Table(name = "ep_user_roles_request_det", indexes = { @Index(name = "fk_user_roles_req_fn_req_id", columnList = "req_id"), @Index(name = "fk_user_roles_req_fn_role_id", columnList = "requested_role_id") @@ -90,16 +100,17 @@ CREATE TABLE `ep_user_roles_request_det` ( public class EpUserRolesRequestDet implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") @Digits(integer = 11, fraction = 0) private Long id; - @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) @JoinColumn(name = "req_id", columnDefinition = "int(11) default null") @Valid private EpUserRolesRequest reqId; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "requested_role_id", nullable = false) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "requested_role_id", nullable = false, columnDefinition = "bigint") @NotNull @Valid private FnRole requestedRoleId; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWebAnalyticsSource.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWebAnalyticsSource.java index 429bac1b..4b27a21b 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWebAnalyticsSource.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWebAnalyticsSource.java @@ -51,6 +51,7 @@ import javax.persistence.Id; import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.Valid; import javax.validation.constraints.Digits; @@ -85,12 +86,13 @@ CREATE TABLE `ep_web_analytics_source` ( @Entity public class EpWebAnalyticsSource implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "resource_id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") @Digits(integer = 11, fraction = 0) private Integer resourceId; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "app_id", nullable = false) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "app_id", nullable = false, columnDefinition = "bigint") @NotNull @Valid private FnApp appId; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalog.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalog.java index 061aafc4..0aee6155 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalog.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalog.java @@ -57,7 +57,6 @@ import javax.persistence.OneToMany; import javax.persistence.Table; import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; import lombok.Builder; @@ -87,7 +86,7 @@ CREATE TABLE `ep_widget_catalog` ( @Builder public class EpWidgetCatalog implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "widget_id", nullable = false) private Long widgetId; @Column(name = "wdg_name", length = 100, columnDefinition = "varchar(100) default '?'", nullable = false) @@ -107,10 +106,10 @@ public class EpWidgetCatalog implements Serializable { @NotNull @SafeHtml private String wdgFileLoc; - @Column(name = "all_user_flag", length = 1, columnDefinition = "boolean default '0'", nullable = false) + @Column(name = "all_user_flag", length = 1, columnDefinition = "boolean default false", nullable = false) @NotNull private Boolean allUserFlag; - @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) @JoinTable( name = "ep_widget_microservice", joinColumns = {@JoinColumn(name = "widget_id", referencedColumnName = "widget_id")}, @@ -124,35 +123,35 @@ public class EpWidgetCatalog implements Serializable { @OneToMany( targetEntity = EpWidgetCatalogRole.class, mappedBy = "widgetId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<EpWidgetCatalogRole> widgetCatalogRoles; @OneToMany( targetEntity = EpPersUserWidgetSel.class, mappedBy = "widgetId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<EpPersUserWidgetSel> epPersUserWidgetSels; @OneToMany( targetEntity = EpPersUserWidgetSel.class, mappedBy = "widgetId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<EpPersUserWidgetSel> persUserWidgetSels; @OneToMany( targetEntity = EpPersUserWidgetPlacement.class, mappedBy = "widgetId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<EpPersUserWidgetPlacement> epPersUserWidgetPlacements; @OneToMany( targetEntity = EpWidgetCatalogParameter.class, mappedBy = "widgetId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<EpWidgetCatalogParameter> epWidgetCatalogParameters; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogFiles.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogFiles.java index fe91d235..82ee9f1a 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogFiles.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogFiles.java @@ -46,11 +46,13 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -72,12 +74,14 @@ CREATE TABLE `ep_widget_catalog_files` ( @Table(name = "ep_widget_catalog_files") @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity public class EpWidgetCatalogFiles implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "file_id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") @Digits(integer = 11, fraction = 0) private Long fileId; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogParameter.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogParameter.java index ec6bb563..ababeab6 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogParameter.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogParameter.java @@ -45,9 +45,6 @@ import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; @@ -55,7 +52,6 @@ import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.Table; import javax.validation.Valid; -import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; @@ -65,7 +61,7 @@ import lombok.NoArgsConstructor; import lombok.Setter; import org.hibernate.validator.constraints.SafeHtml; import org.onap.portal.domain.db.fn.FnUser; -import org.onap.portal.domain.dto.DomainVo; +import org.onap.portal.domain.db.DomainVo; /* CREATE TABLE `ep_widget_catalog_parameter` ( @@ -94,7 +90,7 @@ CREATE TABLE `ep_widget_catalog_parameter` ( query = "DELETE FROM EpWidgetCatalogParameter WHERE paramId.id = :PARAMID"), @NamedQuery( name = "EpWidgetCatalogParameter.getUserParamById", - query = "FROM EpWidgetCatalogParameter WHERE paramId.id = :PARAMID and userId.userId = :USERID and widgetId.widgetId = :WIDGETID" + query = "FROM EpWidgetCatalogParameter WHERE paramId.id = :PARAMID and userId.id = :USERID and widgetId.widgetId = :WIDGETID" ) }) @@ -111,23 +107,17 @@ CREATE TABLE `ep_widget_catalog_parameter` ( @NoArgsConstructor @AllArgsConstructor public class EpWidgetCatalogParameter extends DomainVo implements Serializable { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") - @Digits(integer = 11, fraction = 0) - private Long id; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) @JoinColumn(name = "widget_id", nullable = false) @NotNull @Valid private EpWidgetCatalog widgetId; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "user_id", nullable = false) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "user_id", nullable = false, columnDefinition = "bigint") @NotNull @Valid private FnUser userId; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) @JoinColumn(name = "param_id", nullable = false) @NotNull @Valid diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogRole.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogRole.java index b226b92d..f5124297 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogRole.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogRole.java @@ -89,17 +89,17 @@ public class EpWidgetCatalogRole implements Serializable { @Column(name = "id", length = 11, nullable = false) @Digits(integer = 11, fraction = 0) private Long id; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) @JoinColumn(name = "widget_id", nullable = false) @NotNull @Valid private EpWidgetCatalog widgetId; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) @JoinColumn(name = "app_id", columnDefinition = "bigint default '1'") @Valid private FnApp appId; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "role_id", nullable = false) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "role_id", nullable = false, columnDefinition = "bigint") @NotNull @Valid private FnRole roleId; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetPreviewFiles.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetPreviewFiles.java index d96524e1..ece3896b 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetPreviewFiles.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetPreviewFiles.java @@ -46,6 +46,7 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.constraints.Digits; import lombok.AllArgsConstructor; @@ -72,6 +73,7 @@ CREATE TABLE `ep_widget_preview_files` ( @Entity public class EpWidgetPreviewFiles implements Serializable { @Id + @SequenceGenerator(name="portal_generator", sequenceName = "portal_generator", initialValue = 1000) @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "preview_id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") @Digits(integer = 11, fraction = 0) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnApp.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnApp.java index bada8e14..307abebd 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnApp.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnApp.java @@ -41,15 +41,12 @@ package org.onap.portal.domain.db.fn; import java.io.Serializable; +import java.time.LocalDateTime; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; -import javax.persistence.Embeddable; import javax.persistence.Entity; import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; @@ -59,6 +56,7 @@ import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; @@ -71,7 +69,7 @@ import org.onap.portal.domain.db.ep.EpMicroservice; import org.onap.portal.domain.db.ep.EpUserRolesRequest; import org.onap.portal.domain.db.ep.EpWebAnalyticsSource; import org.onap.portal.domain.db.ep.EpWidgetCatalogRole; -import org.onap.portal.domain.dto.DomainVo; +import org.onap.portal.domain.db.DomainVo; /* CREATE TABLE `fn_app` ( @@ -102,177 +100,236 @@ CREATE TABLE `fn_app` ( */ @NamedQueries({ - @NamedQuery( - name = "FnApp.retrieveWhereAuthCentralIsYAndOpenIsNAndAuthNamespaceIsNotNull", - query = "from FnApp where auth_central = 'Y' and open = 'N' and auth_namespace is not null") + @NamedQuery( + name = "FnApp.retrieveWhereAuthCentralIsYAndOpenIsNAndAuthNamespaceIsNotNull", + query = "from FnApp where authCentral = 'Y' and open = 'N' and authNamespace is not null"), + @NamedQuery( + name = "FnApp.getByUebKey", + query = "from FnApp where uebKey = :uebKey"), + @NamedQuery( + name = "FnApp.getCentralizedApps", + query = "from FnApp where authCentral = 'Y' and open = 'N' and authNamespace is not null" + ) }) @Table(name = "fn_app") @NoArgsConstructor @AllArgsConstructor @EqualsAndHashCode(callSuper = true) -@Embeddable @Getter @Setter @Entity public class FnApp extends DomainVo implements Serializable { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "app_Id", length = 11, nullable = false) - @Digits(integer = 11, fraction = 0) - private Long appId; - @Column(name = "app_name", length = 100, nullable = false, columnDefinition = "varchar(100) not null default '?'") - @Size(max = 100) - @SafeHtml - @NotNull - private String appName; - @Column(name = "app_image_url", length = 256) - @Size(max = 256) - @SafeHtml - private String appImageUrl; - @Column(name = "app_description", length = 512) - @Size(max = 256) - @SafeHtml - private String appDescription; - @Column(name = "app_notes", length = 4096) - @Size(max = 4096) - @SafeHtml - private String appNotes; - @Column(name = "app_url", length = 256) - @Size(max = 256) - @SafeHtml - //TODO URL - @URL - private String appUrl; - @Column(name = "app_alternate_url", length = 256) - @Size(max = 256) - @SafeHtml - private String appAlternateUrl; - @Column(name = "app_rest_endpoint", length = 2000) - @Size(max = 2000) - @SafeHtml - private String appRestEndpoint; - @Column(name = "ml_app_name", length = 50, nullable = false, columnDefinition = "varchar(50) not null default '?'") - @Size(max = 50) - @SafeHtml - @NotNull - private String ml_app_name; - @Column(name = "ml_app_admin_id", length = 7, nullable = false, columnDefinition = "varchar(7) not null default '?'") - @Size(max = 7) - @SafeHtml - @NotNull - private String mlAppAdminId; - @Column(name = "mots_id", length = 11) - @Digits(integer = 11, fraction = 0) - private Long motsId; - @Column(name = "app_password", length = 256, nullable = false, columnDefinition = "varchar(256) not null default '?'") - @Size(max = 256) - @SafeHtml - @NotNull - private String appPassword; - @Column(name = "_open", length = 1, columnDefinition = "char(1) default 'N'") - private Boolean open; - @Column(name = "_enabled", length = 1, columnDefinition = "char(1) default 'N'") - private Boolean enabled; - @Column(name = "active_yn", length = 1, columnDefinition = "char(1) default 'Y'") - @Pattern(regexp = "[YNyn]") - @Size(max = 1) - @NotNull - @SafeHtml - private String activeYn; - @Column(name = "_thumbnail", columnDefinition = "mediumblob null default null") - private byte[] thumbnail; - @Column(name = "app_username", length = 50) - @Size(max = 50) - @SafeHtml - private String appUsername; - @Column(name = "ueb_key", length = 256) - @Size(max = 256) - @SafeHtml - private String uebKey; - @Column(name = "ueb_secret", length = 256) - @Size(max = 256) - @SafeHtml - private String uebSecret; - @Column(name = "ueb_topic_name", length = 256) - @Size(max = 256) - @SafeHtml - private String uebTopicName; - @Column(name = "app_type", length = 11, columnDefinition = "int(11) not null default 1") - @Digits(integer = 11, fraction = 0) - private Long appType; - @Column(name = "auth_central", length = 1, columnDefinition = "char(1) not null default 'N'", nullable = false) - private Boolean authCentral; - @Column(name = "auth_namespace", length = 100) - @Size(max = 100) - @SafeHtml - private String authNamespace; - @OneToMany( - targetEntity = FnMenuFunctionalRoles.class, - mappedBy = "appId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<FnMenuFunctionalRoles> fnMenuFunctionalRoles; - @OneToMany( - targetEntity = EpUserRolesRequest.class, - mappedBy = "appId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<EpUserRolesRequest> epUserRolesRequests; - @OneToMany( - targetEntity = EpAppFunction.class, - mappedBy = "appId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<EpAppFunction> epAppFunctions; - @OneToMany( - targetEntity = EpAppRoleFunction.class, - mappedBy = "appId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<EpAppRoleFunction> epAppRoleFunctions; - @OneToMany( - targetEntity = FnUserRole.class, - mappedBy = "appId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<FnUserRole> fnUserRoles; - @OneToMany( - targetEntity = EpWebAnalyticsSource.class, - mappedBy = "appId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<EpWebAnalyticsSource> epWebAnalyticsSources; - @OneToMany( - targetEntity = EpWidgetCatalogRole.class, - mappedBy = "appId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<EpWidgetCatalogRole> epWidgetCatalogRoles; - @OneToMany( - targetEntity = EpMicroservice.class, - mappedBy = "appId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<EpMicroservice> epMicroservices; - @OneToMany( - targetEntity = FnPersUserAppSel.class, - mappedBy = "appId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<FnPersUserAppSel> fnPersUserAppSels; + @Column(name = "app_name", length = 100, nullable = false, columnDefinition = "varchar(100) not null default '?'") + @Size(max = 100) + @SafeHtml + @NotNull + private String appName = "?"; + @Column(name = "app_image_url", length = 256) + @Size(max = 256) + @SafeHtml + private String appImageUrl; + @Column(name = "app_description", length = 512) + @Size(max = 256) + @SafeHtml + private String appDescription; + @Column(name = "app_notes", length = 4096) + @Size(max = 4096) + @SafeHtml + private String appNotes; + @Column(name = "app_url", length = 256) + @Size(max = 256) + @SafeHtml + //TODO URL + @URL + private String appUrl; + @Column(name = "app_alternate_url", length = 256) + @Size(max = 256) + @SafeHtml + private String appAlternateUrl; + @Column(name = "app_rest_endpoint", length = 2000) + @Size(max = 2000) + @SafeHtml + private String appRestEndpoint; + @Column(name = "ml_app_name", length = 50, nullable = false, columnDefinition = "varchar(50) not null default '?'") + @Size(max = 50) + @SafeHtml + @NotNull + private String mlAppName = "?"; + @Column(name = "ml_app_admin_id", length = 7, nullable = false, columnDefinition = "varchar(7) not null default '?'") + @Size(max = 7) + @SafeHtml + private String mlAppAdminId = "?"; + @Column(name = "mots_id", length = 11) + @Digits(integer = 11, fraction = 0) + private Long motsId; + @Column(name = "app_password", length = 256, nullable = false, columnDefinition = "varchar(256) not null default '?'") + @Size(max = 256) + @SafeHtml + @NotNull + private String appPassword = "?"; + @Column(name = "open") + private Boolean open = false; + @Column(name = "enabled") + private Boolean enabled = false; + @Column(name = "active_yn") + @NotNull + private Boolean activeYn = true; + @Column(name = "_thumbnail", columnDefinition = "mediumblob null default null") + private byte[] thumbnail; + @Column(name = "app_username", length = 50) + @Size(max = 50) + @SafeHtml + private String appUsername; + @Column(name = "ueb_key", length = 256) + @Size(max = 256) + @SafeHtml + private String uebKey; + @Column(name = "ueb_secret", length = 256) + @Size(max = 256) + @SafeHtml + private String uebSecret; + @Column(name = "ueb_topic_name", length = 256) + @Size(max = 256) + @SafeHtml + private String uebTopicName; + @Column(name = "app_type", length = 11, columnDefinition = "int(11) not null default 1") + @Digits(integer = 11, fraction = 0) + private Long appType = 1L; + @Column(name = "auth_central", length = 1, nullable = false) + private Boolean authCentral; + @Column(name = "auth_namespace", length = 100) + @Size(max = 100) + @SafeHtml + private String authNamespace; + @OneToMany( + targetEntity = FnMenuFunctionalRoles.class, + mappedBy = "appId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<FnMenuFunctionalRoles> fnMenuFunctionalRoles; + @OneToMany( + targetEntity = EpUserRolesRequest.class, + mappedBy = "appId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<EpUserRolesRequest> epUserRolesRequests; + @OneToMany( + targetEntity = EpAppFunction.class, + mappedBy = "appId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<EpAppFunction> epAppFunctions; + @OneToMany( + targetEntity = EpAppRoleFunction.class, + mappedBy = "appId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<EpAppRoleFunction> epAppRoleFunctions; + @OneToMany( + targetEntity = FnUserRole.class, + mappedBy = "fnAppId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<FnUserRole> fnUserRoles; + @OneToMany( + targetEntity = EpWebAnalyticsSource.class, + mappedBy = "appId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<EpWebAnalyticsSource> epWebAnalyticsSources; + @OneToMany( + targetEntity = EpWidgetCatalogRole.class, + mappedBy = "appId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<EpWidgetCatalogRole> epWidgetCatalogRoles; + @OneToMany( + targetEntity = EpMicroservice.class, + mappedBy = "appId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<EpMicroservice> epMicroservices; + @OneToMany( + targetEntity = FnPersUserAppSel.class, + mappedBy = "appId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<FnPersUserAppSel> fnPersUserAppSels; - public Boolean isRestrictedApp() { - return (this.appType == 2); - } + public Boolean isRestrictedApp() { + return (this.appType == 2); + } + + @Builder + public FnApp(@Digits(integer = 11, fraction = 0) Long id, LocalDateTime created, + LocalDateTime modified, Long rowNum, Serializable auditUserId, + DomainVo createdId, DomainVo modifiedId, Set<DomainVo> fnUsersCreatedId, + Set<DomainVo> fnUsersModifiedId, + @Size(max = 100) @SafeHtml @NotNull String appName, + @Size(max = 256) @SafeHtml String appImageUrl, + @Size(max = 256) @SafeHtml String appDescription, + @Size(max = 4096) @SafeHtml String appNotes, + @Size(max = 256) @SafeHtml @URL String appUrl, + @Size(max = 256) @SafeHtml String appAlternateUrl, + @Size(max = 2000) @SafeHtml String appRestEndpoint, + @Size(max = 50) @SafeHtml @NotNull String mlAppName, + @Size(max = 7) @SafeHtml @NotNull String mlAppAdminId, + @Digits(integer = 11, fraction = 0) Long motsId, + @Size(max = 256) @SafeHtml @NotNull String appPassword, Boolean open, Boolean enabled, Boolean activeYn, byte[] thumbnail, + @Size(max = 50) @SafeHtml String appUsername, + @Size(max = 256) @SafeHtml String uebKey, + @Size(max = 256) @SafeHtml String uebSecret, + @Size(max = 256) @SafeHtml String uebTopicName, + @Digits(integer = 11, fraction = 0) Long appType, Boolean authCentral, + @Size(max = 100) @SafeHtml String authNamespace, + Set<FnMenuFunctionalRoles> fnMenuFunctionalRoles, + Set<EpUserRolesRequest> epUserRolesRequests, + Set<EpAppFunction> epAppFunctions, Set<EpAppRoleFunction> epAppRoleFunctions, + Set<FnUserRole> fnUserRoles, Set<EpWebAnalyticsSource> epWebAnalyticsSources, + Set<EpWidgetCatalogRole> epWidgetCatalogRoles, + Set<EpMicroservice> epMicroservices, Set<FnPersUserAppSel> fnPersUserAppSels) { + super(id, created, modified, rowNum, auditUserId, createdId, modifiedId, fnUsersCreatedId, fnUsersModifiedId); + this.appName = appName; + this.appImageUrl = appImageUrl; + this.appDescription = appDescription; + this.appNotes = appNotes; + this.appUrl = appUrl; + this.appAlternateUrl = appAlternateUrl; + this.appRestEndpoint = appRestEndpoint; + this.mlAppName = mlAppName; + this.mlAppAdminId = mlAppAdminId; + this.motsId = motsId; + this.appPassword = appPassword; + this.open = open; + this.enabled = enabled; + this.activeYn = activeYn; + this.thumbnail = thumbnail; + this.appUsername = appUsername; + this.uebKey = uebKey; + this.uebSecret = uebSecret; + this.uebTopicName = uebTopicName; + this.appType = appType; + this.authCentral = authCentral; + this.authNamespace = authNamespace; + this.fnMenuFunctionalRoles = fnMenuFunctionalRoles; + this.epUserRolesRequests = epUserRolesRequests; + this.epAppFunctions = epAppFunctions; + this.epAppRoleFunctions = epAppRoleFunctions; + this.fnUserRoles = fnUserRoles; + this.epWebAnalyticsSources = epWebAnalyticsSources; + this.epWidgetCatalogRoles = epWidgetCatalogRoles; + this.epMicroservices = epMicroservices; + this.fnPersUserAppSels = fnPersUserAppSels; + } } diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAppContactUs.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAppContactUs.java index 26fd4668..ef51b7e7 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAppContactUs.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAppContactUs.java @@ -47,7 +47,6 @@ import javax.persistence.Entity; import javax.persistence.EntityResult; import javax.persistence.FetchType; import javax.persistence.FieldResult; -import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.MapsId; import javax.persistence.NamedNativeQueries; @@ -59,13 +58,14 @@ import javax.validation.Valid; import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import org.hibernate.validator.constraints.SafeHtml; import org.hibernate.validator.constraints.URL; -import org.onap.portal.domain.dto.DomainVo; +import org.onap.portal.domain.db.DomainVo; /* CREATE TABLE `fn_app_contact_us` ( @@ -137,17 +137,14 @@ CREATE TABLE `fn_app_contact_us` ( @NoArgsConstructor @AllArgsConstructor @EqualsAndHashCode(callSuper = true) +@Builder @Getter @Setter @Entity public class FnAppContactUs extends DomainVo implements Serializable { - @Id - @Column(name = "app_id") - private Long appId; - @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinColumn(name = "app_id") - @MapsId + @OneToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) + @JoinColumn(name = "app_id", columnDefinition = "bigint") @Valid private FnApp fnApp; @Column(name = "contact_name", length = 128, columnDefinition = "varchar(128) default null") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditAction.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditAction.java index da60049b..1ae1898a 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditAction.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditAction.java @@ -46,6 +46,7 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; @@ -76,7 +77,8 @@ CREATE TABLE `fn_audit_action` ( @Entity public class FnAuditAction implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "role_id", nullable = false) private Integer roleId; @Column(name = "class_name", length = 500, nullable = false) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditActionLog.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditActionLog.java index df73f42c..f7f07ea2 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditActionLog.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditActionLog.java @@ -47,6 +47,7 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.constraints.Digits; import javax.validation.constraints.PastOrPresent; @@ -80,7 +81,8 @@ CREATE TABLE `fn_audit_action_log` ( public class FnAuditActionLog implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "audit_log_id", nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") private Integer auditLogId; @Column(name = "audit_action_cd", length = 200) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditLog.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditLog.java index 911f32a2..1094462f 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditLog.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnAuditLog.java @@ -52,12 +52,14 @@ import javax.persistence.Id; import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.Valid; import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -86,6 +88,7 @@ CREATE TABLE `fn_audit_log` ( }) @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity @@ -95,12 +98,12 @@ public class FnAuditLog implements Serializable { @Column(name = "log_id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") @Digits(integer = 11, fraction = 0) private Integer logId; - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinColumn(name = "user_id", nullable = false) + @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) + @JoinColumn(name = "user_id", nullable = false, columnDefinition = "bigint") @NotNull @Valid private FnUser userId; - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) @JoinColumn(name = "activity_cd", nullable = false) @NotNull @Valid diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnBroadcastMessage.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnBroadcastMessage.java index e9cfc20d..9d5d6d70 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnBroadcastMessage.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnBroadcastMessage.java @@ -47,6 +47,7 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; @@ -81,7 +82,8 @@ CREATE TABLE `fn_broadcast_message` ( public class FnBroadcastMessage implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "message_id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") @Digits(integer = 11, fraction = 0) private Long messageId; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnChatRoom.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnChatRoom.java index abf96539..a663c1cd 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnChatRoom.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnChatRoom.java @@ -47,6 +47,7 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.constraints.NotNull; import javax.validation.constraints.PastOrPresent; @@ -77,7 +78,8 @@ CREATE TABLE `fn_chat_room` ( @Entity public class FnChatRoom implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "chat_room_id", nullable = false) @NotNull private Integer chatRoomId; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnCommonWidgetData.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnCommonWidgetData.java index 1255aa1d..5215acf3 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnCommonWidgetData.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnCommonWidgetData.java @@ -46,11 +46,13 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.constraints.Digits; import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -71,6 +73,7 @@ CREATE TABLE `fn_common_widget_data` ( @Table(name = "fn_common_widget_data") @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnDatasource.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnDatasource.java index 87ee3592..ec045cfb 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnDatasource.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnDatasource.java @@ -46,6 +46,7 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.constraints.Digits; import javax.validation.constraints.Max; @@ -84,7 +85,8 @@ CREATE TABLE `fn_datasource` ( @Entity public class FnDatasource implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "message_id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") @Digits(integer = 11, fraction = 0) private Long messageId; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnDisplayText.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnDisplayText.java index 348cf9ec..8946e83d 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnDisplayText.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnDisplayText.java @@ -46,11 +46,13 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -69,13 +71,15 @@ CREATE TABLE `fn_display_text` ( @Table(name = "fn_display_text") @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity public class FnDisplayText implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") @Digits(integer = 11, fraction = 0) private Long id; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnFunction.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnFunction.java index 3375fd09..8ceb12fd 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnFunction.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnFunction.java @@ -52,6 +52,7 @@ import javax.persistence.Table; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -68,38 +69,41 @@ CREATE TABLE `fn_function` ( @Table(name = "fn_function") @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity public class FnFunction implements Serializable { @Id - @Column(name = "function_cd", length = 30, nullable = false) - @Size(max = 30) - @SafeHtml + @Column(name = "function_cd", nullable = false) private String functionCd; @Column(name = "function_name", length = 50, nullable = false) @Size(max = 50) @SafeHtml @NotNull private String functionName; + private String code; + private String name; + private String type; + private String action; @OneToMany( targetEntity = FnRestrictedUrl.class, mappedBy = "functionCd", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<FnRestrictedUrl> fnRestrictedUrls; @OneToMany( targetEntity = FnRoleFunction.class, mappedBy = "functionCd", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<FnRoleFunction> fnRoleFunctions; @OneToMany( targetEntity = FnTab.class, mappedBy = "functionCd", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<FnTab> fnTabs; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLanguage.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLanguage.java index ad976fc6..531157fe 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLanguage.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLanguage.java @@ -51,10 +51,9 @@ import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.NamedQuery; import javax.persistence.OneToMany; -import javax.persistence.SequenceGenerator; import javax.persistence.Table; -import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; @@ -73,6 +72,10 @@ CREATE TABLE `fn_language` ( */ @Table(name = "fn_language") + +@NamedQuery(name = "FnLanguage.getByLanguageAlias", +query = "FROM FnLanguage WHERE languageAlias =: alias") + @NoArgsConstructor @AllArgsConstructor @Builder @@ -83,7 +86,7 @@ CREATE TABLE `fn_language` ( public class FnLanguage implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "language_id", length = 11, nullable = false) private Long languageId; @Column(name = "language_name", length = 100, nullable = false) @@ -99,7 +102,7 @@ public class FnLanguage implements Serializable { @OneToMany( targetEntity = FnUser.class, mappedBy = "languageId", - cascade = CascadeType.PERSIST, + cascade = CascadeType.MERGE, fetch = FetchType.EAGER ) private Set<FnUser> fnUsers = new HashSet<>(); @@ -112,4 +115,11 @@ public class FnLanguage implements Serializable { + '}'; return sb; } + + public FnLanguage( + @Size(max = 100) @NotNull(message = "languageName must not be null") @SafeHtml String languageName, + @Size(max = 100) @NotNull(message = "languageAlias must not be null") @SafeHtml String languageAlias) { + this.languageName = languageName; + this.languageAlias = languageAlias; + } } diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuActivity.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuActivity.java index f4d0d709..ad8e627e 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuActivity.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuActivity.java @@ -52,6 +52,7 @@ import javax.persistence.Table; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -68,6 +69,7 @@ CREATE TABLE `fn_lu_activity` ( @Table(name = "fn_lu_activity") @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity @@ -86,7 +88,7 @@ public class FnLuActivity implements Serializable { @OneToMany( targetEntity = FnAuditLog.class, mappedBy = "activityCd", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<FnAuditLog> fnAuditLogs; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuAlertMethod.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuAlertMethod.java index 740f052b..b9b40b36 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuAlertMethod.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuAlertMethod.java @@ -52,6 +52,7 @@ import javax.persistence.Table; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -68,6 +69,7 @@ CREATE TABLE `fn_lu_alert_method` ( @Table(name = "fn_lu_alert_method") @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity @@ -86,7 +88,7 @@ public class FnLuAlertMethod implements Serializable { @OneToMany( targetEntity = FnUser.class, mappedBy = "alertMethodCd", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<FnUser> fnUsers; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuMenuSet.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuMenuSet.java index ff5e4736..5e71405b 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuMenuSet.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuMenuSet.java @@ -54,6 +54,7 @@ import javax.persistence.Table; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -70,13 +71,13 @@ CREATE TABLE `fn_lu_menu_set` ( @Table(name = "fn_lu_menu_set") @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity public class FnLuMenuSet implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "menu_set_cd", length = 10, nullable = false) @Size(max = 10) @NotNull @@ -90,7 +91,7 @@ public class FnLuMenuSet implements Serializable { @OneToMany( targetEntity = FnMenu.class, mappedBy = "menuSetCd", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<FnMenu> fnMenus; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuPriority.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuPriority.java index 4e5e2335..e1e46bd9 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuPriority.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuPriority.java @@ -46,12 +46,14 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -70,6 +72,7 @@ CREATE TABLE `fn_lu_priority` ( @Table(name = "fn_lu_priority") @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity @@ -84,12 +87,9 @@ public class FnLuPriority implements Serializable { @NotNull @SafeHtml private String priority; - @Column(name = "active_yn", length = 1, columnDefinition = "character varying(1) default 'y'", nullable = false) - @Pattern(regexp = "[YNyn]") - @Size(max = 1) + @Column(name = "active_yn", length = 1, columnDefinition = "boolean default true", nullable = false) @NotNull - @SafeHtml - private String activeYn; + private Boolean activeYn; @Column(name = "sort_order", nullable = false, length = 5) @Digits(integer = 5, fraction = 0) private Long sortOrder; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuTabSet.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuTabSet.java index 06e982ca..fe59c749 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuTabSet.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuTabSet.java @@ -52,6 +52,7 @@ import javax.persistence.Table; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -68,6 +69,7 @@ CREATE TABLE `fn_lu_tab_set` ( @Table(name = "fn_lu_tab_set") @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity @@ -84,8 +86,8 @@ public class FnLuTabSet implements Serializable { private String tabSetName; @OneToMany( targetEntity = FnTab.class, - mappedBy = "fnLuTabSet", - cascade = CascadeType.ALL, + mappedBy = "tabSetCd", + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<FnTab> fnTabs; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuTimezone.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuTimezone.java index 54b4bc5c..c3b8843c 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuTimezone.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLuTimezone.java @@ -50,10 +50,12 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -71,6 +73,7 @@ CREATE TABLE `fn_lu_timezone` ( @Table(name = "fn_lu_timezone") @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity @@ -83,17 +86,17 @@ public class FnLuTimezone implements Serializable { @Size(max = 100) @SafeHtml @NotNull - private String timezone_name; + private String timezoneName; @Column(name = "timezone_value", length = 100, nullable = false) @Size(max = 100) @SafeHtml @NotNull - private String timezone_value; + private String timezoneValue; @OneToMany( targetEntity = FnUser.class, mappedBy = "timezone", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<FnUser> fnUsers; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenu.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenu.java index 7407213c..8e146259 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenu.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenu.java @@ -54,6 +54,7 @@ import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.Valid; import javax.validation.constraints.Digits; @@ -61,6 +62,7 @@ import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -99,6 +101,7 @@ CREATE TABLE `fn_menu` ( }) @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity @@ -112,7 +115,7 @@ public class FnMenu implements Serializable { @Size(max = 100) @SafeHtml private String label; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) @JoinColumn(name = "parent_Id", columnDefinition = "int(11) DEFAULT NULL") @Valid private FnMenu parentId; @@ -127,12 +130,9 @@ public class FnMenu implements Serializable { @Size(max = 30) @SafeHtml private String functionCd; - @Column(name = "active_yn", length = 1, columnDefinition = "character varying(1) default 'y'", nullable = false) - @Pattern(regexp = "[YNyn]") - @Size(max = 1) + @Column(name = "active_yn", length = 1, columnDefinition = "boolean default true", nullable = false) @NotNull - @SafeHtml - private String activeYn; + private Boolean activeYn = true; @Column(name = "servlet", length = 50, columnDefinition = "varchar(50) DEFAULT NULL") @Size(max = 50) @SafeHtml @@ -151,16 +151,13 @@ public class FnMenu implements Serializable { @Size(max = 25) @SafeHtml private String target; - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) @JoinColumn(name = "menu_set_cd", columnDefinition = "character varying(10) default 'app'", foreignKey = @ForeignKey(name = "fk_fn_menu_menu_set_cd")) @Valid private FnLuMenuSet menuSetCd; - @Column(name = "separator_yn", length = 1, columnDefinition = "character varying(1) default 'n'") - @Pattern(regexp = "[YNyn]") - @Size(max = 1) + @Column(name = "separator_yn", length = 1, columnDefinition = "boolean default false") @NotNull - @SafeHtml - private String separatorYn; + private Boolean separatorYn = false; @Column(name = "image_src", length = 100, columnDefinition = "varchar(100) DEFAULT NULL") @Size(max = 100) @SafeHtml @@ -168,7 +165,7 @@ public class FnMenu implements Serializable { @OneToMany( targetEntity = FnMenu.class, mappedBy = "parentId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<FnMenu> fnMenus; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctional.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctional.java index e348a01f..0e376f7a 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctional.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctional.java @@ -54,7 +54,10 @@ import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; import javax.persistence.OneToMany; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.Valid; import javax.validation.constraints.Digits; @@ -62,6 +65,7 @@ import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -83,10 +87,19 @@ CREATE TABLE `fn_menu_functional` ( ) */ +@NamedQueries({ + @NamedQuery( + name = "FnMenuFunctional.retrieveByMenuId", + query = "from FnMenuFunctionalRoles where menuId =:menuId" + ) +} +) + @Table(name = "fn_menu_functional", indexes = {@Index(columnList = "parent_menu_id", name = "fk_fn_menu_func_parent_menu_id_idx") }) @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity @@ -104,7 +117,7 @@ public class FnMenuFunctional implements Serializable { @SafeHtml @NotNull private String text; - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) @JoinColumn(name = "parent_menu_id") @Valid private FnMenuFunctional parentMenuId; @@ -115,21 +128,18 @@ public class FnMenuFunctional implements Serializable { //TODO URL @URL private String url; - @Column(name = "active_yn", length = 1, columnDefinition = "varchar(1) default 'Y'", nullable = false) - @Pattern(regexp = "[YNyn]") - @Size(max = 1) + @Column(name = "active_yn", length = 1, columnDefinition = "boolean default true", nullable = false) @NotNull - @SafeHtml - private String activeYn; + private Boolean activeYn = true; @Column(name = "image_src", length = 100, columnDefinition = "varchar(100) default null") @Size(max = 100) @SafeHtml private String imageSrc; - @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) @JoinTable( name = "fn_menu_favorites", joinColumns = {@JoinColumn(name = "menu_id", referencedColumnName = "menu_id")}, - inverseJoinColumns = {@JoinColumn(name = "role_Id", referencedColumnName = "user_id")}, + inverseJoinColumns = {@JoinColumn(name = "role_Id", referencedColumnName = "id", columnDefinition = "bigint")}, indexes = { @Index(name = "sys_c0014619", columnList = "menu_id") } @@ -138,21 +148,21 @@ public class FnMenuFunctional implements Serializable { @OneToMany( targetEntity = FnMenuFunctionalAncestors.class, mappedBy = "menuId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<FnMenuFunctionalAncestors> fnMenuFunctionalAncestorsMenuId; @OneToMany( targetEntity = FnMenuFunctionalAncestors.class, mappedBy = "ancestorMenuId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<FnMenuFunctionalAncestors> fnMenuFunctionalsAncestorMenuId; @OneToMany( targetEntity = FnMenuFunctionalRoles.class, mappedBy = "menuId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<FnMenuFunctionalRoles> fnMenuFunctionalRoles; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctionalAncestors.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctionalAncestors.java index 309f11ea..00eddf0a 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctionalAncestors.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctionalAncestors.java @@ -51,10 +51,12 @@ import javax.persistence.Id; import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -79,6 +81,7 @@ CREATE TABLE `fn_menu_functional_ancestors` ( }) @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity @@ -88,11 +91,11 @@ public class FnMenuFunctionalAncestors implements Serializable { @Column(name = "id", nullable = false, length = 11, columnDefinition = "int(11) AUTO_INCREMENT") @Digits(integer = 11, fraction = 0) private Integer id; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) @JoinColumn(name = "menu_id", nullable = false) @NotNull private FnMenuFunctional menuId; - @ManyToOne(fetch = FetchType.LAZY, cascade =CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade =CascadeType.MERGE) @JoinColumn(name = "ancestor_menu_id", nullable = false) @NotNull private FnMenuFunctional ancestorMenuId; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctionalRoles.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctionalRoles.java index 3e9ae0e0..373f1ac6 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctionalRoles.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnMenuFunctionalRoles.java @@ -51,11 +51,15 @@ import javax.persistence.Id; import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.Valid; import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -76,6 +80,17 @@ CREATE TABLE `fn_menu_functional_roles` ( ) */ +@NamedQueries({ + @NamedQuery( + name = "FnMenuFunctionalRoles.retrieveByRoleId", + query = "from FnMenuFunctionalRoles where roleId.id =:roleId"), + @NamedQuery( + name = "FnMenuFunctionalRoles.retrieveByMenuId", + query = "from FnMenuFunctionalRoles where menuId.menuId =:menuId" + ) +} +) + @Table(name = "fn_menu_functional_roles", indexes = { @Index(columnList = "menu_id", name = "fk_fn_menu_func_roles_menu_id_idx"), @Index(columnList = "app_id", name = "fk_fn_menu_func_roles_app_id_idx"), @@ -83,27 +98,29 @@ CREATE TABLE `fn_menu_functional_roles` ( }) @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity public class FnMenuFunctionalRoles implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", nullable = false, length = 11, columnDefinition = "int(11) AUTO_INCREMENT") @Digits(integer = 11, fraction = 0) private Long id; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) @JoinColumn(name = "menu_id", nullable = false) @Valid @NotNull private FnMenuFunctional menuId; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "role_id", nullable = false) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "role_id", nullable = false, columnDefinition = "bigint") @Valid @NotNull private FnRole roleId; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "app_Id", nullable = false) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "app_Id", nullable = false, columnDefinition = "bigint") @Valid @NotNull private FnApp appId; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnOrg.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnOrg.java index 9dea65ed..0fd61b72 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnOrg.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnOrg.java @@ -51,6 +51,7 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Index; import javax.persistence.OneToMany; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; @@ -81,7 +82,8 @@ CREATE TABLE `fn_org` ( @Entity public class FnOrg implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "org_id", nullable = false, length = 11) @Digits(integer = 11, fraction = 0) private Long orgId; @@ -98,7 +100,7 @@ public class FnOrg implements Serializable { @OneToMany( targetEntity = FnUser.class, mappedBy = "orgId", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<FnUser> fnUsers; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnPersUserAppSel.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnPersUserAppSel.java index 1da9c219..2a3fd9bd 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnPersUserAppSel.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnPersUserAppSel.java @@ -45,23 +45,20 @@ import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.validation.Valid; -import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; 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.dto.DomainVo; +import org.onap.portal.domain.db.DomainVo; /* CREATE TABLE `fn_pers_user_app_sel` ( @@ -83,22 +80,19 @@ CREATE TABLE `fn_pers_user_app_sel` ( }) @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity public class FnPersUserAppSel extends DomainVo implements Serializable { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") - @Digits(integer = 11, fraction = 0) - private Long id; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "user_id", nullable = false) + + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "user_id", nullable = false, columnDefinition = "bigint") @NotNull @Valid private FnUser userId; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "app_id", nullable = false) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "app_id", nullable = false, columnDefinition = "bigint") @Valid private FnApp appId; @Column(name = "status_cd", length = 1, nullable = false) @@ -108,9 +102,9 @@ public class FnPersUserAppSel extends DomainVo implements Serializable { private String statusCd; public FnPersUserAppSel(final Long id, final Long userId, final Long appId, final String statusCode) { - super.id = id; - this.userId.setUserId(userId); - this.appId.setAppId(appId); + super.setId(id); + this.userId.setId(userId); + this.appId.setId(appId); this.statusCd = statusCode; } } diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzCronTriggers.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzCronTriggers.java index 84c11629..6db1fb0b 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzCronTriggers.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzCronTriggers.java @@ -52,6 +52,7 @@ import javax.persistence.Table; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -73,7 +74,7 @@ CREATE TABLE `fn_qz_cron_triggers` ( @Table(name = "fn_qz_cron_triggers") @NoArgsConstructor @AllArgsConstructor - +@Builder @Getter @Setter @Entity diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzJobDetails.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzJobDetails.java index 5da7b4fa..0ea12455 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzJobDetails.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzJobDetails.java @@ -54,6 +54,7 @@ import javax.persistence.Table; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; @@ -85,7 +86,7 @@ CREATE TABLE `fn_qz_job_details` ( }) @NoArgsConstructor @AllArgsConstructor - +@Builder @Getter @Setter @Entity @@ -115,33 +116,25 @@ public class FnQzJobDetails implements Serializable{ @SafeHtml @NotNull private String jobClassName; - @Column(name = "IS_DURABLE", length = 1, nullable = false) - @Size(max = 1) - @SafeHtml + @Column(name = "IS_DURABLE", nullable = false) @NotNull - private String isDurable; - @Column(name = "IS_NONCONCURRENT", length = 1, nullable = false) - @Size(max = 1) - @SafeHtml + private Boolean isDurable; + @Column(name = "IS_NONCONCURRENT", nullable = false) @NotNull - private String isNonconcurrent; - @Column(name = "IS_UPDATE_DATA", length = 1, nullable = false) - @Size(max = 1) - @SafeHtml + private Boolean isNonconcurrent; + @Column(name = "IS_UPDATE_DATA", nullable = false) @NotNull - private String isUpdateData; - @Column(name = "REQUESTS_RECOVERY", length = 1, nullable = false) - @Size(max = 1) - @SafeHtml + private Boolean isUpdateData; + @Column(name = "REQUESTS_RECOVERY", nullable = false) @NotNull - private String requestsRecovery; + private Boolean requestsRecovery; @Column(name = "JOB_DATA", columnDefinition = "blob DEFAULT NULL") private byte[] jobData; @OneToMany( targetEntity = FnQzTriggers.class, mappedBy = "fnQzJobDetails", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<FnQzTriggers> selectedTabCd; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzSchedulerState.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzSchedulerState.java index 3c00f959..1ce373ba 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzSchedulerState.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzSchedulerState.java @@ -51,6 +51,7 @@ import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; @@ -71,7 +72,7 @@ CREATE TABLE `fn_qz_scheduler_state` ( @Table(name = "fn_qz_scheduler_state") @NoArgsConstructor @AllArgsConstructor - +@Builder @Getter @Setter @Entity diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzTriggers.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzTriggers.java index 35fb1307..d7f3dec9 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzTriggers.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzTriggers.java @@ -56,6 +56,7 @@ import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -113,6 +114,7 @@ CREATE TABLE `fn_qz_triggers` ( }) @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity @@ -124,7 +126,6 @@ public class FnQzTriggers implements Serializable { @JoinColumn(name = "JOB_NAME", referencedColumnName = "JOB_NAME"), @JoinColumn(name = "JOB_GROUP", referencedColumnName = "JOB_GROUP") }) - @NotNull private FnQzJobDetails fnQzJobDetails; @Id @Valid diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRestrictedUrl.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRestrictedUrl.java index 74e81ebe..43238181 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRestrictedUrl.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRestrictedUrl.java @@ -53,6 +53,7 @@ import javax.validation.Valid; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; @@ -75,7 +76,7 @@ CREATE TABLE `fn_restricted_url` ( }) @NoArgsConstructor @AllArgsConstructor - +@Builder @Getter @Setter @Entity @@ -85,11 +86,9 @@ public class FnRestrictedUrl implements Serializable{ @Size(max = 250) @SafeHtml @Id - private String restricted_url; + private String restrictedUrl; @ManyToOne() - @JoinColumn(name = "function_cd", nullable = false) - @Valid - @NotNull + @JoinColumn(name = "function_cd") @Id private FnFunction functionCd; @@ -101,8 +100,7 @@ public class FnRestrictedUrl implements Serializable{ public static class FnRestrictedUrlId implements Serializable { @Size(max = 250) @SafeHtml - private String restricted_url; - @Valid + private String restrictedUrl; @NotNull private FnFunction functionCd; } diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRole.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRole.java index edd843ac..2c16d00a 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRole.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRole.java @@ -41,9 +41,11 @@ package org.onap.portal.domain.db.fn; import java.io.Serializable; +import java.time.LocalDateTime; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; +import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; @@ -53,26 +55,25 @@ import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; -import javax.persistence.NamedNativeQueries; -import javax.persistence.NamedNativeQuery; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; import javax.persistence.Table; -import javax.persistence.UniqueConstraint; import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; 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; import org.onap.portal.domain.db.ep.EpAppRoleFunction; import org.onap.portal.domain.db.ep.EpRoleNotification; import org.onap.portal.domain.db.ep.EpUserRolesRequestDet; import org.onap.portal.domain.db.ep.EpWidgetCatalogRole; -import org.onap.portal.domain.dto.DomainVo; +import org.onap.portal.domain.dto.transport.Role; /* CREATE TABLE `fn_role` ( @@ -88,136 +89,149 @@ CREATE TABLE `fn_role` ( */ @NamedQueries({ - @NamedQuery( - name = "FnRole.retrieveAppRolesByRoleNameAndByAppId", - query = "FROM FnRole where role_name =:roleName and app_id =:appId"), - @NamedQuery( - name = "FnRole.retrieveAppRolesByAppId", - query = "FROM FnRole where app_id =:appId"), - @NamedQuery( - name = "FnRole.retrieveAppRolesWhereAppIdIsNull", - query = "FROM FnRole where app_id is null"), - @NamedQuery( - name = "FnRole.retrieveAppRoleByRoleIdWhereAppIdIsNull", - query = "FROM FnRole where role_id =:roleId and app_id is null"), - @NamedQuery( - name = "FnRole.retrieveAppRoleByAppRoleIdAndByAppId", - query = "FROM FnRole where appRoleId =:appRoleId and appId =:appId"), - @NamedQuery( - name = "FnRole.retrieveAppRoleByRoleIdAndAppId", - query = "FROM FnRole where role_id =:roleId and app_id =:appId"), - @NamedQuery( - name = "FnRole.retrieveAppRolesByRoleNameAndWhereAppIdIsNull", - query = "FROM FnRole where role_name =:roleName and app_id is null"), - @NamedQuery( - name = "FnRole.retrieveActiveRolesOfApplication", - query = "from FnRole where active_yn = 'Y' and app_id=:appId"), - @NamedQuery(name = "FnRole.retrieveRoleToUpdateInExternalAuthSystem", - query = "FROM FnRole where role_name =:roleName and app_id =:appId") + @NamedQuery( + name = "FnRole.retrieveAppRolesByRoleNameAndByAppId", + query = "FROM FnRole where roleName =:roleName and appId =:appId"), + @NamedQuery( + name = "FnRole.retrieveAppRolesByAppId", + query = "FROM FnRole where appId =:appId"), + @NamedQuery( + name = "FnRole.retrieveAppRolesWhereAppIdIsNull", + query = "FROM FnRole where appId is null"), + @NamedQuery( + name = "FnRole.retrieveAppRoleByRoleIdWhereAppIdIsNull", + query = "FROM FnRole where id =:roleId and appId is null"), + @NamedQuery( + name = "FnRole.retrieveAppRoleByAppRoleIdAndByAppId", + query = "FROM FnRole where appRoleId =:appRoleId and appId =:appId"), + @NamedQuery( + name = "FnRole.retrieveAppRoleByRoleIdAndAppId", + query = "FROM FnRole where id =:roleId and appId =:appId"), + @NamedQuery( + name = "FnRole.retrieveAppRolesByRoleNameAndWhereAppIdIsNull", + query = "FROM FnRole where roleName =:roleName and appId is null"), + @NamedQuery( + name = "FnRole.retrieveActiveRolesOfApplication", + query = "from FnRole where activeYn = 'Y' and appId=:appId"), + @NamedQuery( + name = "FnRole.getUserRoleOnUserIdAndAppId", + query = " FROM" + + " FnRole fr,\n" + + " FnUserRole fur\n" + + " WHERE\n" + + " fr.id = fur.roleId\n" + + " AND fur.userId = :userId" + + " AND fur.fnAppId.id = :appId\n" + + " AND fr.activeYn = 'y'"), + @NamedQuery( + name = "FnRole.getGlobalRolesOfPortal", + query = "from" + + " FnRole" + + " where" + + " roleName like 'global_%'" + + " and appId is null" + + " and activeYn = 'Y'"), + @NamedQuery( + name = "FnRole.getSysAdminRoleId", + query = "FROM FnRole WHERE roleName = 'System_Administrator' and activeYn = 'true' and priority = 1 and appId is null and appRoleId is null" + ) }) -@Table(name = "fn_role", indexes = { - @Index(name = "fn_role_name_app_id_idx", columnList = "role_name, app_id", unique = true) -}) +@Table(name = "fn_role") @NoArgsConstructor -@AllArgsConstructor @Getter @Setter @Entity -public class FnRole extends DomainVo implements Serializable { +public class FnRole extends Role { + + @Column(name = "app_role_id", length = 11, columnDefinition = "int(11) default null") + @Digits(integer = 11, fraction = 0) + private Long appRoleId; + @ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) + @JoinTable( + name = "fn_user_pseudo_role", + joinColumns = {@JoinColumn(name = "pseudo_role_Id", referencedColumnName = "id", columnDefinition = "bigint not null")}, + inverseJoinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "id", columnDefinition = "bigint not null")}, + indexes = { + @Index(name = "fk_pseudo_role_user_id", columnList = "user_id") + } + ) + private Set<FnUser> fnUsers; + @ManyToMany(cascade = CascadeType.MERGE, + fetch = FetchType.LAZY, mappedBy = "role") + private Set<FnRoleFunction> roleFunctions; + @OneToMany( + targetEntity = EpRoleNotification.class, + mappedBy = "notificationID", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<EpRoleNotification> epRoleNotifications; + @OneToMany( + targetEntity = FnMenuFunctionalRoles.class, + mappedBy = "roleId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<FnMenuFunctionalRoles> fnMenuFunctionalRoles; + @OneToMany( + targetEntity = EpWidgetCatalogRole.class, + mappedBy = "roleId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<EpWidgetCatalogRole> epWidgetCatalogRoles; + @OneToMany( + targetEntity = EpAppRoleFunction.class, + mappedBy = "fnRole", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<EpAppRoleFunction> epAppRoleFunctions; + @OneToMany( + targetEntity = EpUserRolesRequestDet.class, + mappedBy = "requestedRoleId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<EpUserRolesRequestDet> epUserRolesRequestDets; + @OneToMany( + targetEntity = FnUserRole.class, + mappedBy = "roleId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<FnUserRole> fnUserRoles; - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "role_id", length = 11, nullable = false) - @Digits(integer = 11, fraction = 0) - private Long roleId; - @Column(name = "role_name", length = 300, nullable = false) - @Size(max = 300) - @NotNull - @SafeHtml - private String roleName; - @Column(name = "active_yn", length = 1, columnDefinition = "character varying(1) default 'y'", nullable = false) - @NotNull - private Boolean activeYn; - @Column(name = "priority", length = 4, columnDefinition = "decimal(4,0) DEFAULT NULL") - @Digits(integer = 4, fraction = 0) - private Long priority; - @Column(name = "app_Id", length = 11, columnDefinition = "int(11) default null") - @Digits(integer = 11, fraction = 0) - private Long appId; - @Column(name = "app_role_id", length = 11, columnDefinition = "int(11) default null") - @Digits(integer = 11, fraction = 0) - private Long appRoleId; - @OneToMany( - targetEntity = FnRoleFunction.class, - mappedBy = "roleId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<FnRoleFunction> fnRoleFunctions; - @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinTable( - name = "fn_user_pseudo_role", - joinColumns = {@JoinColumn(name = "pseudo_role_Id", referencedColumnName = "role_id")}, - inverseJoinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "user_id")}, - indexes = { - @Index(name = "fk_pseudo_role_user_id", columnList = "user_id") - } - ) - private Set<FnUser> fnUsers; - @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinTable( - name = "fn_role_composite", - joinColumns = {@JoinColumn(name = "parent_role_id", referencedColumnName = "role_id")}, - inverseJoinColumns = {@JoinColumn(name = "child_role_id", referencedColumnName = "role_id")}, - indexes = { - @Index(name = "fk_fn_role_composite_child", columnList = "child_role_id") - } - ) - private Set<FnRole> fnRoles; - @ManyToMany(cascade = CascadeType.ALL, - fetch = FetchType.LAZY) - private Set<FnRole> fnRoleList; - @OneToMany( - targetEntity = EpRoleNotification.class, - mappedBy = "notificationID", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<EpRoleNotification> epRoleNotifications; - @OneToMany( - targetEntity = FnMenuFunctionalRoles.class, - mappedBy = "roleId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<FnMenuFunctionalRoles> fnMenuFunctionalRoles; - @OneToMany( - targetEntity = EpWidgetCatalogRole.class, - mappedBy = "roleId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<EpWidgetCatalogRole> epWidgetCatalogRoles; - @OneToMany( - targetEntity = EpAppRoleFunction.class, - mappedBy = "fnRole", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<EpAppRoleFunction> epAppRoleFunctions; - @OneToMany( - targetEntity = EpUserRolesRequestDet.class, - mappedBy = "requestedRoleId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<EpUserRolesRequestDet> epUserRolesRequestDets; - @OneToMany( - targetEntity = FnUserRole.class, - mappedBy = "roleId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<FnUserRole> fnUserRoles; + @Builder + public FnRole(@Digits(integer = 11, fraction = 0) Long id, LocalDateTime created, + LocalDateTime modified, Long rowNum, Serializable auditUserId, + DomainVo createdId, DomainVo modifiedId, + Set<DomainVo> fnUsersCreatedId, + Set<DomainVo> fnUsersModifiedId, + @Size(max = 300) @NotNull @SafeHtml String roleName, + @Digits(integer = 11, fraction = 0) Long appId, @NotNull Boolean activeYn, + @Digits(integer = 4, fraction = 0) Integer priority, + Set<FnRoleFunction> fnRoleFunctions, Set<FnRoleComposite> childRoles, + Set<FnRoleComposite> parentRoles, + @Digits(integer = 11, fraction = 0) Long appRoleId, Set<FnUser> fnUsers, + Set<FnRoleFunction> roleFunctions, + Set<EpRoleNotification> epRoleNotifications, + Set<FnMenuFunctionalRoles> fnMenuFunctionalRoles, + Set<EpWidgetCatalogRole> epWidgetCatalogRoles, + Set<EpAppRoleFunction> epAppRoleFunctions, + Set<EpUserRolesRequestDet> epUserRolesRequestDets, + Set<FnUserRole> fnUserRoles) { + super(id, created, modified, rowNum, auditUserId, createdId, modifiedId, fnUsersCreatedId, fnUsersModifiedId, + roleName, appId, activeYn, priority, fnRoleFunctions, childRoles, parentRoles); + this.appRoleId = appRoleId; + this.fnUsers = fnUsers; + this.roleFunctions = roleFunctions; + this.epRoleNotifications = epRoleNotifications; + this.fnMenuFunctionalRoles = fnMenuFunctionalRoles; + this.epWidgetCatalogRoles = epWidgetCatalogRoles; + this.epAppRoleFunctions = epAppRoleFunctions; + this.epUserRolesRequestDets = epUserRolesRequestDets; + this.fnUserRoles = fnUserRoles; + } } diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRoleComposite.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRoleComposite.java new file mode 100644 index 00000000..a729e76c --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRoleComposite.java @@ -0,0 +1,85 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portal.domain.db.fn; + +import java.io.Serializable; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.Index; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.validation.Valid; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.onap.portal.domain.db.fn.compositePK.FnRoleCompositeId; +import org.onap.portal.domain.dto.transport.Role; + +@Table(name = "fn_role_composite", indexes = { + @Index(name = "fk_fn_role_composite_child", columnList = "child_role_id") +}) +@Getter +@Setter +@Entity +@Builder +@NoArgsConstructor +@AllArgsConstructor +@IdClass(FnRoleCompositeId.class) +public class FnRoleComposite implements Serializable{ + + @Id + @Valid + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "parent_role_id", nullable = false, columnDefinition = "bigint") + private Role parentRoles; + @Id + @Valid + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "child_role_id", nullable = false, columnDefinition = "bigint") + private Role childRoles; + +} diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRoleFunction.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRoleFunction.java index 944d7395..d98687a5 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRoleFunction.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRoleFunction.java @@ -41,23 +41,25 @@ package org.onap.portal.domain.db.fn; import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.IdClass; import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.validation.Valid; +import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; import lombok.AllArgsConstructor; -import lombok.EqualsAndHashCode; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; -import org.onap.portal.domain.db.fn.FnRoleFunction.FnRoleFunctionId; +import org.onap.portal.domain.db.DomainVo; +import org.onap.portal.domain.dto.transport.Role; /* CREATE TABLE `fn_role_function` ( @@ -72,39 +74,37 @@ CREATE TABLE `fn_role_function` ( */ @Table(name = "fn_role_function", indexes = { - @Index(name = "fn_role_function_function_cd", columnList = "function_cd"), - @Index(name = "fn_role_function_role_id", columnList = "role_id") -}) + @Index(name = "fn_role_function_function_cd", columnList = "function_cd"), + @Index(name = "fn_role_function_role_id", columnList = "role"), + @Index(name = "fn_role_function_roleId_functionCd", columnList = "role, function_cd", unique = true)}) + @NoArgsConstructor @AllArgsConstructor @Getter @Setter @Entity -@IdClass(FnRoleFunctionId.class) -public class FnRoleFunction implements Serializable{ +public class FnRoleFunction extends DomainVo implements Serializable { - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "role_Id", nullable = false) - @Valid - @NotNull - @Id - private FnRole roleId; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "function_cd", nullable = false) - @Valid - @NotNull - @Id - private FnFunction functionCd; + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "role", nullable = false, columnDefinition = "bigint") + @Valid + @NotNull + private FnRole role; + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "function_cd", nullable = false, columnDefinition = "varchar(255) not null") + @Valid + @NotNull + private FnFunction functionCd; - @Getter - @Setter - @NoArgsConstructor - @EqualsAndHashCode - @AllArgsConstructor - public static class FnRoleFunctionId implements Serializable { - @Valid - private FnRole roleId; - @Valid - private FnFunction functionCd; - } + @Builder + public FnRoleFunction(@Digits(integer = 11, fraction = 0) Long id, + LocalDateTime created, LocalDateTime modified, Long rowNum, Serializable auditUserId, + DomainVo createdId, DomainVo modifiedId, Set<DomainVo> fnUsersCreatedId, + Set<DomainVo> fnUsersModifiedId, + @Valid @NotNull FnRole role, + @Valid @NotNull FnFunction functionCd) { + super(id, created, modified, rowNum, auditUserId, createdId, modifiedId, fnUsersCreatedId, fnUsersModifiedId); + this.role = role; + this.functionCd = functionCd; + } } diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRoleV.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRoleV.java index e1c4cded..ad9c2ccd 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRoleV.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRoleV.java @@ -70,7 +70,7 @@ public class FnRoleV implements Serializable { @Column(name = "role_name") private String roleName; @Column(name = "active_yn") - private String activeYn; + private Boolean activeYn; @Column(name = "priority") private BigInteger priority; @Column(name = "app_Id") diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnScheduleWorkflows.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnScheduleWorkflows.java index 620532ee..d4e2dd31 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnScheduleWorkflows.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnScheduleWorkflows.java @@ -48,6 +48,7 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; @@ -82,7 +83,8 @@ CREATE TABLE `fn_schedule_workflows` ( @Entity public class FnScheduleWorkflows implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id_schedule_workflows", nullable = false, length = 25, columnDefinition = "bigint(25) AUTO_INCREMENT") @Digits(integer = 25, fraction = 0) private BigInteger idScheduleWorkflows; 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..ca16d343 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 @@ -47,6 +47,7 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.persistence.UniqueConstraint; import javax.validation.constraints.Digits; @@ -54,6 +55,7 @@ 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; @@ -76,6 +78,7 @@ CREATE TABLE `fn_shared_context` ( }) @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnTab.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnTab.java index 634fb649..fa4be7f5 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnTab.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnTab.java @@ -59,6 +59,7 @@ import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -89,6 +90,7 @@ CREATE TABLE `fn_tab` ( }) @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity @@ -112,34 +114,31 @@ public class FnTab implements Serializable { @SafeHtml @NotNull private String action; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) @JoinColumn(name = "function_cd", nullable = false) @NotNull @Valid private FnFunction functionCd; - @Column(name = "active_yn", length = 1, nullable = false) - @Pattern(regexp = "[YNyn]") - @Size(max = 1) + @Column(name = "active_yn", nullable = false) @NotNull - @SafeHtml - private String activeYn; + private Boolean activeYn; @Column(name = "sort_order", length = 11, nullable = false) @Digits(integer = 11, fraction = 0) @NotNull - private BigInteger sortDrder; + private Long sortDrder; @Column(name = "parent_tab_cd", length = 30, columnDefinition = "varchar(30) DEFAULT NULL") @Size(max = 30) @SafeHtml private String parentTabCd; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) @JoinColumn(name = "tab_set_cd", nullable = false) @NotNull @Valid - private FnLuTabSet fnLuTabSet; + private FnLuTabSet tabSetCd; @OneToMany( targetEntity = FnTabSelected.class, mappedBy = "selectedTabCd", - cascade = CascadeType.ALL, + cascade = CascadeType.MERGE, fetch = FetchType.LAZY ) private Set<FnTabSelected> selectedTabCd; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnTabSelected.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnTabSelected.java index 14b243dd..1369fbd5 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnTabSelected.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnTabSelected.java @@ -54,6 +54,7 @@ import javax.validation.Valid; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; @@ -73,13 +74,13 @@ CREATE TABLE `fn_tab_selected` ( @Table(name = "fn_tab_selected") @NoArgsConstructor @AllArgsConstructor - +@Builder @Getter @Setter @Entity @IdClass(FnTabSelectedId.class) public class FnTabSelected implements Serializable{ - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) @JoinColumn(name = "selected_tab_cd", nullable = false) @NotNull @Valid diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUser.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUser.java index c5a97195..277b04d8 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUser.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUser.java @@ -44,15 +44,15 @@ import java.io.Serializable; import java.time.LocalDateTime; import java.util.Collection; import java.util.HashSet; +import java.util.Iterator; import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; import java.util.stream.Collectors; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.ManyToMany; @@ -60,7 +60,6 @@ import javax.persistence.ManyToOne; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; -import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.persistence.UniqueConstraint; import javax.validation.constraints.Digits; @@ -75,13 +74,14 @@ import lombok.NoArgsConstructor; import lombok.Setter; import org.hibernate.annotations.DynamicUpdate; import org.hibernate.validator.constraints.SafeHtml; +import org.onap.portal.domain.db.DomainVo; import org.onap.portal.domain.db.cr.CrReportFileHistory; import org.onap.portal.domain.db.ep.EpPersUserWidgetPlacement; import org.onap.portal.domain.db.ep.EpPersUserWidgetSel; import org.onap.portal.domain.db.ep.EpUserNotification; import org.onap.portal.domain.db.ep.EpUserRolesRequest; import org.onap.portal.domain.db.ep.EpWidgetCatalogParameter; -import org.onap.portal.domain.dto.DomainVo; +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; @@ -151,327 +151,477 @@ CREATE TABLE `fn_user` ( */ @NamedQueries({ - @NamedQuery( - name = "FnUser.getUserWithOrgUserId", - query = "FROM FnUser WHERE orgUserId = :orgId"), - @NamedQuery( - name = "FnUser.getActiveUsers", - query = "FROM FnUser WHERE activeYn = 'Y'"), - @NamedQuery( - name = "FnUser.getUsersByOrgIds", - query = "FROM FnUser WHERE orgUserId IN :orgIds" - ) + @NamedQuery( + name = "FnUser.getUserWithOrgUserId", + query = "FROM FnUser WHERE orgUserId = :orgId"), + @NamedQuery( + name = "FnUser.findByLoginId", + query = "FROM FnUser WHERE loginId = :loginId"), + @NamedQuery( + name = "FnUser.getActiveUsers", + query = "FROM FnUser WHERE activeYn = 'Y'"), + @NamedQuery( + name = "FnUser.getUsersByOrgIds", + query = "FROM FnUser WHERE orgUserId IN :orgIds" + ) }) + @Table(name = "fn_user", indexes = { - @Index(name = "fn_user_address_id", columnList = "address_id"), - @Index(name = "fn_user_alert_method_cd", columnList = "alert_method_cd"), - @Index(name = "fn_user_org_id", columnList = "org_id"), - @Index(name = "fk_fn_user_ref_197_fn_user", columnList = "manager_id"), - @Index(name = "fk_fn_user_ref_198_fn_user", columnList = "created_id"), - @Index(name = "fk_fn_user_ref_199_fn_user", columnList = "modified_id"), - @Index(name = "fk_timezone", columnList = "timezone") + @Index(name = "fn_user_address_id", columnList = "address_id"), + @Index(name = "fn_user_alert_method_cd", columnList = "alert_method_cd"), + @Index(name = "fn_user_org_id", columnList = "org_id"), +// @Index(name = "fk_fn_user_ref_197_fn_user", columnList = "manager_id"), + @Index(name = "fk_fn_user_ref_198_fn_user", columnList = "created_id"), + @Index(name = "fk_fn_user_ref_199_fn_user", columnList = "modified_id"), + @Index(name = "fk_timezone", columnList = "timezone") }, - uniqueConstraints = { - @UniqueConstraint(name = "fn_user_hrid", columnNames = "hrid"), - @UniqueConstraint(name = "fn_user_login_id", columnNames = "login_id") + uniqueConstraints = { + @UniqueConstraint(name = "fn_user_hrid", columnNames = "hrid"), + @UniqueConstraint(name = "fn_user_login_id", columnNames = "login_id") - }) + }) @Getter @Setter @Entity -@Builder @NoArgsConstructor @AllArgsConstructor @DynamicUpdate public class FnUser extends DomainVo implements UserDetails, Serializable { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "user_id", nullable = false) - private Long userId; - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinColumn(name = "org_id") - private FnOrg orgId; - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinColumn(name = "manager_id") - private FnUser managerId; - @Column(name = "first_name", length = 50) - @Size(max = 50) - @SafeHtml - private String firstName; - @Column(name = "middle_name", length = 50) - @Size(max = 50) - @SafeHtml - private String middleName; - @Column(name = "last_name", length = 50) - @Size(max = 50) - @SafeHtml - private String lastName; - @Column(name = "phone", length = 25) - @Size(max = 25) - @SafeHtml - private String phone; - @Column(name = "fax", length = 25) - @Size(max = 25) - @SafeHtml - private String fax; - @Column(name = "cellular", length = 25) - @Size(max = 25) - @SafeHtml - private String cellular; - @Column(name = "email", length = 50) - @Size(max = 50) - @Email - @SafeHtml - private String email; - @Column(name = "address_id") - @Digits(integer = 11, fraction = 0) - private Long addressId; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "alert_method_cd") - private FnLuAlertMethod alertMethodCd; - @Column(name = "hrid", length = 20) - @Size(max = 20) - @SafeHtml - private String hrid; - @Column(name = "org_user_id", length = 20) - @Size(max = 20) - @SafeHtml - private String orgUserId; - @Column(name = "org_code", length = 30) - @Size(max = 30) - @SafeHtml - private String org_code; - @Column(name = "login_id", length = 25) - @Size(max = 25) - @SafeHtml - private String loginId; - @Column(name = "login_pwd", length = 100) - @Size(max = 100) - @SafeHtml - private String loginPwd; - @Column(name = "last_login_date", nullable = false, columnDefinition = "datetime DEFAULT current_timestamp() ON UPDATE current_timestamp()") - @PastOrPresent - protected LocalDateTime lastLoginDate; - @Column(name = "active_yn", nullable = false) - private Boolean activeYn; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "created_id") - private FnUser createdId; - @Column(name = "created_date", columnDefinition = "datetime DEFAULT current_timestamp()", nullable = false) - @PastOrPresent - protected LocalDateTime createdDate; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "modified_id") - private FnUser modifiedId; - @Column(name = "modified_date", nullable = false, columnDefinition = "datetime default now()") - @PastOrPresent - protected LocalDateTime modifiedDate; - @Column(name = "is_internal_yn", nullable = false, columnDefinition = "bit DEFAULT 0") - private Boolean isInternalYn; - @Column(name = "address_line_1", length = 100) - @Size(max = 100) - @SafeHtml - private String addressLine1; - @Column(name = "address_line_2", length = 100) - @Size(max = 100) - @SafeHtml - private String addressLine2; - @Column(name = "city", length = 50) - @Size(max = 50) - @SafeHtml - private String city; - @Column(name = "state_cd", length = 3) - @Size(max = 3) - @SafeHtml - private String stateCd; - @Column(name = "zip_code", length = 11) - @Size(max = 11) - @SafeHtml - private String zipCode; - @Column(name = "country_cd", length = 3) - @Size(max = 3) - @SafeHtml - private String countryCd; - @Column(name = "location_clli", length = 8) - @Size(max = 8) - @SafeHtml - private String locationClli; - @Column(name = "org_manager_userid", length = 20) - @Size(max = 20) - @SafeHtml - private String orgManagerUserId; - @Column(name = "company", length = 100) - @Size(max = 100) - @SafeHtml - private String company; - @Column(name = "department_name", length = 200) - @Size(max = 200) - @SafeHtml - private String departmentName; - @Column(name = "job_title", length = 100) - @Size(max = 100) - @SafeHtml - private String jobTitle; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "timezone") - private FnLuTimezone timezone; - @Column(name = "department", length = 25) - @Size(max = 25) - @SafeHtml - private String department; - @Column(name = "business_unit", length = 25) - @Size(max = 25) - @SafeHtml - private String businessUnit; - @Column(name = "business_unit_name", length = 100) - @Size(max = 100) - @SafeHtml - private String businessUnitName; - @Column(name = "cost_center", length = 25) - @Size(max = 25) - @SafeHtml - private String cost_center; - @Column(name = "fin_loc_code", length = 10) - @Size(max = 10) - @SafeHtml - private String finLocCode; - @Column(name = "silo_status", length = 10) - @Size(max = 10) - @SafeHtml - private String siloStatus; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "language_id", nullable = false, columnDefinition = "bigint DEFAULT 1") - @NotNull(message = "languageId must not be null") - private FnLanguage languageId; - @Column(name = "is_guest", nullable = false, columnDefinition = "bit DEFAULT 0") - @NotNull(message = "guest must not be null") - private Boolean guest; - @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "fnUserList") - private Set<CrReportFileHistory> crReportFileHistorie; - @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) - private Set<FnRole> fnRoles; - @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - private Set<FnMenuFunctional> fnRoleList; - @OneToMany( - targetEntity = FnAuditLog.class, - mappedBy = "userId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<FnAuditLog> fnAuditLogs; - @OneToMany( - targetEntity = FnUser.class, - mappedBy = "createdId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<FnUser> fnUsersCreatedId; - @OneToMany( - targetEntity = FnUser.class, - mappedBy = "managerId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<FnUser> fnUsersManagerId; - @OneToMany( - targetEntity = FnUser.class, - mappedBy = "modifiedId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<FnUser> fnUsersModifiedId; - @OneToMany( - targetEntity = EpUserRolesRequest.class, - mappedBy = "userId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<EpUserRolesRequest> epUserRolesRequests; - @OneToMany( - targetEntity = FnPersUserAppSel.class, - mappedBy = "userId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<FnPersUserAppSel> persUserAppSels; - @OneToMany( - targetEntity = EpWidgetCatalogParameter.class, - mappedBy = "userId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<EpWidgetCatalogParameter> epWidgetCatalogParameters; - @OneToMany( - targetEntity = EpPersUserWidgetPlacement.class, - mappedBy = "userId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<EpPersUserWidgetPlacement> epPersUserWidgetPlacements; - @OneToMany( - targetEntity = EpPersUserWidgetSel.class, - mappedBy = "userId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<EpPersUserWidgetSel> epPersUserWidgetSels; - @OneToMany( - targetEntity = FnUserRole.class, - mappedBy = "userId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<FnUserRole> fnUserRoles; - @OneToMany( - targetEntity = EpUserNotification.class, - mappedBy = "userId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set<EpUserNotification> epUserNotifications; - - @Override - public Collection<? extends GrantedAuthority> getAuthorities() { - return fnRoles - .stream() - .map(fnRole -> new SimpleGrantedAuthority("ROLE_" + fnRole.getRoleName())) - .collect(Collectors.toList()); - } - - @Override - public String getPassword() { - return this.getLoginPwd(); - } - - @Override - public String getUsername() { - return this.getLoginId(); - } - - @Override - public boolean isAccountNonExpired() { - return true; - } - - @Override - public boolean isAccountNonLocked() { - return true; - } - - @Override - public boolean isCredentialsNonExpired() { - return true; - } - - @Override - public boolean isEnabled() { - return true; - } - - public String getFullName() { - return this.firstName + " " + this.lastName; - } + private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FnUser.class); + +/* @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) + @JoinColumn(name = "manager_id") + private FnUser managerId;*/ + @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) + @JoinColumn(name = "org_id") + private FnOrg orgId; + @Column(name = "first_name", length = 50) + @Size(max = 50) + @SafeHtml + private String firstName; + @Column(name = "middle_name", length = 50) + @Size(max = 50) + @SafeHtml + private String middleName; + @Column(name = "last_name", length = 50) + @Size(max = 50) + @SafeHtml + private String lastName; + @Column(name = "phone", length = 25) + @Size(max = 25) + @SafeHtml + private String phone; + @Column(name = "fax", length = 25) + @Size(max = 25) + @SafeHtml + private String fax; + @Column(name = "cellular", length = 25) + @Size(max = 25) + @SafeHtml + private String cellular; + @Column(name = "email", length = 50) + @Size(max = 50) + @Email + @SafeHtml + private String email; + @Column(name = "address_id") + @Digits(integer = 11, fraction = 0) + private Long addressId; + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "alert_method_cd") + private FnLuAlertMethod alertMethodCd; + @Column(name = "hrid", length = 20) + @Size(max = 20) + @SafeHtml + private String hrid; + @Column(name = "org_user_id", length = 20) + @Size(max = 20) + @SafeHtml + private String orgUserId; + @Column(name = "org_code", length = 30) + @Size(max = 30) + @SafeHtml + private String org_code; + @Column(name = "login_id", length = 25) + @Size(max = 25) + @SafeHtml + private String loginId; + @Column(name = "login_pwd", length = 100) + @Size(max = 100) + @SafeHtml + private String loginPwd; + @Column(name = "last_login_date", nullable = false, columnDefinition = "datetime DEFAULT current_timestamp() ON UPDATE current_timestamp()") + @PastOrPresent + protected LocalDateTime lastLoginDate; + @Column(name = "active_yn", nullable = false) + private Boolean activeYn; + @Column(name = "created_date", columnDefinition = "datetime DEFAULT current_timestamp()", nullable = false) + @PastOrPresent + protected LocalDateTime createdDate; + @Column(name = "modified_date", nullable = false, columnDefinition = "datetime default now()") + @PastOrPresent + protected LocalDateTime modifiedDate; + @Column(name = "is_internal_yn", nullable = false, columnDefinition = "boolean DEFAULT false") + private Boolean isInternalYn = false; + @Column(name = "is_system_user", nullable = false, columnDefinition = "boolean DEFAULT false") + private Boolean isSystemUser = false; + @Column(name = "address_line_1", length = 100) + @Size(max = 100) + @SafeHtml + private String addressLine1; + @Column(name = "address_line_2", length = 100) + @Size(max = 100) + @SafeHtml + private String addressLine2; + @Column(name = "city", length = 50) + @Size(max = 50) + @SafeHtml + private String city; + @Column(name = "state_cd", length = 3) + @Size(max = 3) + @SafeHtml + private String stateCd; + @Column(name = "zip_code", length = 11) + @Size(max = 11) + @SafeHtml + private String zipCode; + @Column(name = "country_cd", length = 3) + @Size(max = 3) + @SafeHtml + private String countryCd; + @Column(name = "location_clli", length = 8) + @Size(max = 8) + @SafeHtml + private String locationClli; + @Column(name = "org_manager_userid", length = 20) + @Size(max = 20) + @SafeHtml + private String orgManagerUserId; + @Column(name = "company", length = 100) + @Size(max = 100) + @SafeHtml + private String company; + @Column(name = "department_name", length = 200) + @Size(max = 200) + @SafeHtml + private String departmentName; + @Column(name = "job_title", length = 100) + @Size(max = 100) + @SafeHtml + private String jobTitle; + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "timezone") + private FnLuTimezone timezone; + @Column(name = "department", length = 25) + @Size(max = 25) + @SafeHtml + private String department; + @Column(name = "business_unit", length = 25) + @Size(max = 25) + @SafeHtml + private String businessUnit; + @Column(name = "business_unit_name", length = 100) + @Size(max = 100) + @SafeHtml + private String businessUnitName; + @Column(name = "cost_center", length = 25) + @Size(max = 25) + @SafeHtml + private String cost_center; + @Column(name = "fin_loc_code", length = 10) + @Size(max = 10) + @SafeHtml + private String finLocCode; + @Column(name = "silo_status", length = 10) + @Size(max = 10) + @SafeHtml + private String siloStatus; + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "language_id", nullable = false) + @NotNull(message = "languageId must not be null") + private FnLanguage languageId; + @Column(name = "is_guest", nullable = false, columnDefinition = "boolean DEFAULT false") + @NotNull(message = "guest must not be null") + private Boolean guest = false; + @ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY, mappedBy = "fnUserList") + private Set<CrReportFileHistory> crReportFileHistorie; + @ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.EAGER, mappedBy = "fnUsers") + private Set<FnRole> fnRoles; + @ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) + private Set<FnMenuFunctional> fnRoleList; + @OneToMany( + targetEntity = FnAuditLog.class, + mappedBy = "userId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<FnAuditLog> fnAuditLogs; + @OneToMany( + targetEntity = EpUserRolesRequest.class, + mappedBy = "userId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<EpUserRolesRequest> epUserRolesRequests; + @OneToMany( + targetEntity = FnPersUserAppSel.class, + mappedBy = "userId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<FnPersUserAppSel> persUserAppSels; + @OneToMany( + targetEntity = EpWidgetCatalogParameter.class, + mappedBy = "userId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<EpWidgetCatalogParameter> epWidgetCatalogParameters; + @OneToMany( + targetEntity = EpPersUserWidgetPlacement.class, + mappedBy = "userId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<EpPersUserWidgetPlacement> epPersUserWidgetPlacements; + @OneToMany( + targetEntity = EpPersUserWidgetSel.class, + mappedBy = "userId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<EpPersUserWidgetSel> epPersUserWidgetSels; + @OneToMany( + targetEntity = FnUserRole.class, + mappedBy = "userId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<FnUserRole> userApps; + @OneToMany( + targetEntity = EpUserNotification.class, + mappedBy = "userId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<EpUserNotification> epUserNotifications; +/* @OneToMany( + targetEntity = FnUser.class, + mappedBy = "managerId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set<FnUser> fnUsersManagerId;*/ + + @Override + public Collection<? extends GrantedAuthority> getAuthorities() { + return fnRoles + .stream() + .map(fnRole -> new SimpleGrantedAuthority("ROLE_" + fnRole.getRoleName())) + .collect(Collectors.toList()); + } + + @Override + public String getPassword() { + return this.getLoginPwd(); + } + + @Override + public String getUsername() { + return this.getLoginId(); + } + + @Override + public boolean isAccountNonExpired() { + return true; + } + + @Override + public boolean isAccountNonLocked() { + return true; + } + + @Override + public boolean isCredentialsNonExpired() { + return true; + } + + @Override + public boolean isEnabled() { + return true; + } + + public String getFullName() { + return this.firstName + " " + this.lastName; + } + + public SortedSet<FnRole> getAppEPRoles(FnApp app) { + + logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - app = {}", app.getAppName()); + + SortedSet<FnRole> roles = new TreeSet<>(); + Set<FnUserRole> userAppRoles = getUserApps(); + + logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - userApps = {} ", userAppRoles.size()); + + Iterator<FnUserRole> userAppRolesIterator = userAppRoles.iterator(); + + FnUserRole userAppRole; + // getting default app + while (userAppRolesIterator.hasNext()) { + FnUserRole tempUserApp = userAppRolesIterator.next(); + if (tempUserApp.getFnAppId().getId().equals(app.getId())) { + + logger.debug(EELFLoggerDelegate.debugLogger, + "In EPUser.getAppEPRoles() - for user {}, found application {}", this.getFullName(), + app.getAppName()); + + userAppRole = tempUserApp; + + FnRole role = userAppRole.getRoleId(); + if (role.getActiveYn()) { + logger.debug(EELFLoggerDelegate.debugLogger, + "In EPUser.getAppEPRoles() - Role {} is active - adding for user {} and app {}", + role.getRoleName(), this.getFullName(), app.getAppName()); + roles.add(role); + } else { + logger.debug(EELFLoggerDelegate.debugLogger, + "In EPUser.getAppEPRoles() - Role {} is NOT active - NOT adding for user {} and app {}", + role.getRoleName(), this.getFullName(), app.getAppName()); + } + } + } + logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - roles = {}", roles.size()); + + return roles; + } + + public void setRoles(Set<FnRole> roles) { + FnApp app = new FnApp(); + app.setId(1L); + app.setAppName("Default"); + this.addAppRoles(app, roles); + } + + private void addAppRoles(FnApp app, Set<FnRole> roles) { + if (roles != null) { + Set<FnUserRole> newUserApps = new HashSet<>(); + for (FnRole role : roles) { + FnUserRole userApp = new FnUserRole(); + userApp.setUserId(this); + userApp.setFnAppId(app); + userApp.setRoleId(role); + newUserApps.add(userApp); + } + + this.setUserApps(newUserApps); + } else { + this.userApps.clear(); + } + } + + @Builder + public FnUser(@Digits(integer = 11, fraction = 0) Long id, LocalDateTime created, LocalDateTime modified, + Long rowNum, Serializable auditUserId, DomainVo createdId, DomainVo modifiedId, + Set<DomainVo> fnUsersCreatedId, Set<DomainVo> fnUsersModifiedId, FnOrg orgId, + @Size(max = 50) @SafeHtml String firstName, + @Size(max = 50) @SafeHtml String middleName, + @Size(max = 50) @SafeHtml String lastName, + @Size(max = 25) @SafeHtml String phone, + @Size(max = 25) @SafeHtml String fax, + @Size(max = 25) @SafeHtml String cellular, + @Size(max = 50) @Email @SafeHtml String email, + @Digits(integer = 11, fraction = 0) Long addressId, FnLuAlertMethod alertMethodCd, + @Size(max = 20) @SafeHtml String hrid, + @Size(max = 20) @SafeHtml String orgUserId, + @Size(max = 30) @SafeHtml String org_code, + @Size(max = 25) @SafeHtml String loginId, + @Size(max = 100) @SafeHtml String loginPwd, + @PastOrPresent LocalDateTime lastLoginDate, Boolean activeYn, + @PastOrPresent LocalDateTime createdDate, + @PastOrPresent LocalDateTime modifiedDate, Boolean isInternalYn, Boolean isSystemUser, + @Size(max = 100) @SafeHtml String addressLine1, + @Size(max = 100) @SafeHtml String addressLine2, + @Size(max = 50) @SafeHtml String city, + @Size(max = 3) @SafeHtml String stateCd, + @Size(max = 11) @SafeHtml String zipCode, + @Size(max = 3) @SafeHtml String countryCd, + @Size(max = 8) @SafeHtml String locationClli, + @Size(max = 20) @SafeHtml String orgManagerUserId, + @Size(max = 100) @SafeHtml String company, + @Size(max = 200) @SafeHtml String departmentName, + @Size(max = 100) @SafeHtml String jobTitle, FnLuTimezone timezone, + @Size(max = 25) @SafeHtml String department, + @Size(max = 25) @SafeHtml String businessUnit, + @Size(max = 100) @SafeHtml String businessUnitName, + @Size(max = 25) @SafeHtml String cost_center, + @Size(max = 10) @SafeHtml String finLocCode, + @Size(max = 10) @SafeHtml String siloStatus, + @NotNull(message = "languageId must not be null") FnLanguage languageId, + @NotNull(message = "guest must not be null") Boolean guest, + Set<CrReportFileHistory> crReportFileHistorie, Set<FnRole> fnRoles, + Set<FnMenuFunctional> fnRoleList, Set<FnAuditLog> fnAuditLogs, + Set<EpUserRolesRequest> epUserRolesRequests, + Set<FnPersUserAppSel> persUserAppSels, + Set<EpWidgetCatalogParameter> epWidgetCatalogParameters, + Set<EpPersUserWidgetPlacement> epPersUserWidgetPlacements, + Set<EpPersUserWidgetSel> epPersUserWidgetSels, Set<FnUserRole> userApps, + Set<EpUserNotification> epUserNotifications) { + super(id, created, modified, rowNum, auditUserId, createdId, modifiedId, fnUsersCreatedId, fnUsersModifiedId); + this.orgId = orgId; + this.firstName = firstName; + this.middleName = middleName; + this.lastName = lastName; + this.phone = phone; + this.fax = fax; + this.cellular = cellular; + this.email = email; + this.addressId = addressId; + this.alertMethodCd = alertMethodCd; + this.hrid = hrid; + this.orgUserId = orgUserId; + this.org_code = org_code; + this.loginId = loginId; + this.loginPwd = loginPwd; + this.lastLoginDate = lastLoginDate; + this.activeYn = activeYn; + this.createdDate = createdDate; + this.modifiedDate = modifiedDate; + this.isInternalYn = isInternalYn; + this.isSystemUser = isSystemUser; + this.addressLine1 = addressLine1; + this.addressLine2 = addressLine2; + this.city = city; + this.stateCd = stateCd; + this.zipCode = zipCode; + this.countryCd = countryCd; + this.locationClli = locationClli; + this.orgManagerUserId = orgManagerUserId; + this.company = company; + this.departmentName = departmentName; + this.jobTitle = jobTitle; + this.timezone = timezone; + this.department = department; + this.businessUnit = businessUnit; + this.businessUnitName = businessUnitName; + this.cost_center = cost_center; + this.finLocCode = finLocCode; + this.siloStatus = siloStatus; + this.languageId = languageId; + this.guest = guest; + this.crReportFileHistorie = crReportFileHistorie; + this.fnRoles = fnRoles; + this.fnRoleList = fnRoleList; + this.fnAuditLogs = fnAuditLogs; + this.epUserRolesRequests = epUserRolesRequests; + this.persUserAppSels = persUserAppSels; + this.epWidgetCatalogParameters = epWidgetCatalogParameters; + this.epPersUserWidgetPlacements = epPersUserWidgetPlacements; + this.epPersUserWidgetSels = epPersUserWidgetSels; + this.userApps = userApps; + this.epUserNotifications = epUserNotifications; + } } diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUserRole.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUserRole.java index 06320c4c..e2913e05 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUserRole.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUserRole.java @@ -58,6 +58,7 @@ import javax.persistence.NamedNativeQuery; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToOne; +import javax.persistence.SequenceGenerator; import javax.persistence.SqlResultSetMapping; import javax.persistence.Table; import javax.persistence.UniqueConstraint; @@ -87,76 +88,80 @@ CREATE TABLE `fn_user_role` ( */ @NamedNativeQueries({ - @NamedNativeQuery( - name = "FnUserRole.retrieveUserRoleOnUserIdAndRoleIdAndAppId", - query = "FROM FnUserRole where user_id= :userId" - + " and role_id= :roleId" - + " and app_id= :appId"), - @NamedNativeQuery( - name = "FnUserRole.retrieveCachedAppRolesForUser", - query = "FROM FnUserRole where user_id= :userId" - + " and user_id= :userId" - + " and app_id= :appId"), - @NamedNativeQuery( - name = "FnUserRole.isSuperAdmin", - query = "SELECT" - + " user.USER_ID as userId," - + " user.org_user_id as orgUserId," - + " userrole.ROLE_ID as roleId," - + " userrole.APP_ID as appId" - + " FROM" - + " fn_user_role userrole" - + " INNER JOIN fn_user user ON user.USER_ID = userrole.USER_ID" - + " WHERE" - + " user.org_user_id = :orgUserId" - + " AND userrole.ROLE_ID =:roleId" - + " AND userrole.APP_ID =:appId", - resultSetMapping = "UserRole", - resultClass = UserRole.class - ) + @NamedNativeQuery( + name = "FnUserRole.retrieveUserRoleOnUserIdAndRoleIdAndAppId", + query = "FROM FnUserRole where userId= :userId" + + " and role_id= :roleId" + + " and app_id= :appId"), + @NamedNativeQuery( + name = "FnUserRole.retrieveCachedAppRolesForUser", + query = "FROM FnUserRole where userId= :userId" + + " and userId= :userId" + + " and app_id= :appId"), + @NamedNativeQuery( + name = "FnUserRole.isSuperAdmin", + query = "SELECT" + + " userId.id as userId," + + " userId.org_user_id as orgUserId," + + " userrole.ROLE_ID as roleId," + + " userrole.APP_ID as appId" + + " FROM" + + " fn_user_role userrole" + + " INNER JOIN fn_user user ON user.USER_ID = userrole.USER_ID" + + " WHERE" + + " user.org_user_id = :orgUserId" + + " AND userrole.ROLE_ID =:roleId" + + " AND userrole.APP_ID =:appId", + resultSetMapping = "UserRole", + resultClass = UserRole.class + ) }) @SqlResultSetMapping( - name = "UserRole", - classes = { - @ConstructorResult( - targetClass = UserRole.class, - columns = { - @ColumnResult(name = "userId", type = Long.class), - @ColumnResult(name = "orgUserId", type = String.class), - @ColumnResult(name = "roleId", type = Long.class), - @ColumnResult(name = "appId", type = Long.class) - } - ) - } + name = "UserRole", + classes = { + @ConstructorResult( + targetClass = UserRole.class, + columns = { + @ColumnResult(name = "userId", type = Long.class), + @ColumnResult(name = "orgUserId", type = String.class), + @ColumnResult(name = "roleId", type = Long.class), + @ColumnResult(name = "appId", type = Long.class) + } + ) + } ) @NamedQueries({ - @NamedQuery( - name = "FnUserRole.getAdminUserRoles", - query = "FROM FnUserRole fn " - + "WHERE fn.userId.userId = :userId " - + "AND fn.roleId.roleId = :roleId " - + "AND fn.appId.appId = :appId"), - @NamedQuery( - name = "FnUserRole.getUserRolesForRoleIdAndAppId", - query = "FROM\n" - + " FnUserRole userrole\n" - + "WHERE\n" - + " userrole.roleId.roleId = :roleId\n" - + " AND userrole.appId.appId = :appId" - ) + @NamedQuery( + name = "FnUserRole.getAdminUserRoles", + query = "FROM FnUserRole " + + " WHERE userId.id = :userId " + + " AND roleId.id = :roleId " + + " AND fnAppId.id = :appId"), + @NamedQuery( + name = "FnUserRole.retrieveByAppIdAndUserId", + query = "from FnUserRole where fnAppId.id =:appId and userId.id =:userId" + ), + @NamedQuery( + name = "FnUserRole.retrieveByAppIdAndRoleId", + query = "from FnUserRole where fnAppId.id =:appId and roleId.id =:roleId" + ), + @NamedQuery( + name = "FnUserRole.retrieveByUserIdAndRoleId", + query = "from FnUserRole where userId.id =:userId and roleId.id =:roleId" + ) }) @Table( - name = "fn_user_role", - indexes = { - @Index(name = "fn_user_role_role_id", columnList = "role_id"), - @Index(name = "fn_user_role_user_id", columnList = "user_id"), - @Index(name = "fk_fn_user__ref_178_fn_app_idx", columnList = "app_id")}, - uniqueConstraints = { - @UniqueConstraint(name = "fn_user_role_id", columnNames = {"role_id", "user_id", "app_id"}) - }) + name = "fn_user_role", + indexes = { + @Index(name = "fn_user_role_role_id", columnList = "role_id"), + @Index(name = "fn_user_role_user_id", columnList = "user_id"), + @Index(name = "fk_fn_user__ref_178_fn_app_idx", columnList = "fn_App_Id")}, + uniqueConstraints = { + @UniqueConstraint(name = "fn_user_role_id", columnNames = {"role_id", "user_id", "fn_App_Id"}) + }) @NoArgsConstructor @AllArgsConstructor @Builder @@ -164,24 +169,24 @@ CREATE TABLE `fn_user_role` ( @Setter @Entity public class FnUserRole implements Serializable { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "id", columnDefinition = "int(11) auto_increment") - private Long id; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "user_id") - @Valid - private FnUser userId; - @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "role_id") - @Valid - private FnRole roleId; - @Column(name = "priority", length = 4, columnDefinition = "decimal(4,0) DEFAULT NULL") - @Digits(integer = 4, fraction = 0) - private Long priority; - @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinColumn(name = "app_Id") - @Valid - private FnApp appId; + @Id + @SequenceGenerator(name = "portal_generator", sequenceName = "portal_generator", initialValue = 1000) + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "id", columnDefinition = "int(11) auto_increment") + private Long id; + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "user_id", columnDefinition = "bigint") + @Valid + private FnUser userId; + @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @JoinColumn(name = "role_id", columnDefinition = "bigint") + @Valid + private FnRole roleId; + @Column(name = "priority", length = 4, columnDefinition = "decimal(4,0) DEFAULT NULL") + @Digits(integer = 4, fraction = 0) + private Long priority; + @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) + @JoinColumn(name = "fn_App_Id", columnDefinition = "bigint") + @Valid + private FnApp fnAppId; }
\ No newline at end of file diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnWidget.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnWidget.java index f595536f..b42100d3 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnWidget.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnWidget.java @@ -45,8 +45,6 @@ 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; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnWorkflow.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnWorkflow.java index b5a4ecb6..0baaa74c 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnWorkflow.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnWorkflow.java @@ -46,6 +46,7 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.persistence.UniqueConstraint; import javax.validation.constraints.Digits; @@ -85,7 +86,8 @@ CREATE TABLE `fn_workflow` ( @Entity public class FnWorkflow implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", nullable = false, length = 9, columnDefinition = "mediumint(9) AUTO_INCREMENT") @Digits(integer = 9, fraction = 0) private Integer id; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/compositePK/FnRoleCompositeId.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/compositePK/FnRoleCompositeId.java new file mode 100644 index 00000000..a03c9cfc --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/compositePK/FnRoleCompositeId.java @@ -0,0 +1,65 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portal.domain.db.fn.compositePK; + +import java.io.Serializable; +import javax.validation.Valid; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.onap.portal.domain.dto.transport.Role; + +@Getter +@Setter +@EqualsAndHashCode +@NoArgsConstructor +@AllArgsConstructor +public class FnRoleCompositeId implements Serializable { + + @Valid + private Role parentRoles; + @Valid + private Role childRoles; + + +} |