X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=portal-BE%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportal%2Fdomain%2Fdb%2Ffn%2FFnApp.java;h=307abebd018749ab5d7b60c52a240dcf17594fab;hb=ffd9af970318c1f5a0bad46d7aad5d4611414aae;hp=cdc20897822d056a9846f207ea4093e46e80e56c;hpb=682a90dad9795a3fa9aaffbf43c488057b8529e7;p=portal.git 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 cdc20897..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,185 +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'") - @Pattern(regexp = "[YNyn]") - @Size(max = 1) - @NotNull - @SafeHtml - private String open; - @Column(name = "ENABLED", length = 1, columnDefinition = "char(1) default 'N'") - @Pattern(regexp = "[YNyn]") - @Size(max = 1) - @NotNull - @SafeHtml - private String 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) - @Pattern(regexp = "[YNyn]") - @Size(max = 1) - @NotNull - @SafeHtml - private String 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; - @OneToMany( - targetEntity = EpUserRolesRequest.class, - mappedBy = "appId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set epUserRolesRequests; - @OneToMany( - targetEntity = EpAppFunction.class, - mappedBy = "appId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set epAppFunctions; - @OneToMany( - targetEntity = EpAppRoleFunction.class, - mappedBy = "appId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set epAppRoleFunctions; - @OneToMany( - targetEntity = FnUserRole.class, - mappedBy = "appId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set fnUserRoles; - @OneToMany( - targetEntity = EpWebAnalyticsSource.class, - mappedBy = "appId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set epWebAnalyticsSources; - @OneToMany( - targetEntity = EpWidgetCatalogRole.class, - mappedBy = "appId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set epWidgetCatalogRoles; - @OneToMany( - targetEntity = EpMicroservice.class, - mappedBy = "appId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set epMicroservices; - @OneToMany( - targetEntity = FnPersUserAppSel.class, - mappedBy = "appId", - cascade = CascadeType.ALL, - fetch = FetchType.LAZY - ) - private Set 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; + @OneToMany( + targetEntity = EpUserRolesRequest.class, + mappedBy = "appId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set epUserRolesRequests; + @OneToMany( + targetEntity = EpAppFunction.class, + mappedBy = "appId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set epAppFunctions; + @OneToMany( + targetEntity = EpAppRoleFunction.class, + mappedBy = "appId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set epAppRoleFunctions; + @OneToMany( + targetEntity = FnUserRole.class, + mappedBy = "fnAppId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set fnUserRoles; + @OneToMany( + targetEntity = EpWebAnalyticsSource.class, + mappedBy = "appId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set epWebAnalyticsSources; + @OneToMany( + targetEntity = EpWidgetCatalogRole.class, + mappedBy = "appId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set epWidgetCatalogRoles; + @OneToMany( + targetEntity = EpMicroservice.class, + mappedBy = "appId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set epMicroservices; + @OneToMany( + targetEntity = FnPersUserAppSel.class, + mappedBy = "appId", + cascade = CascadeType.MERGE, + fetch = FetchType.LAZY + ) + private Set fnPersUserAppSels; + + 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 fnUsersCreatedId, + Set 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, + Set epUserRolesRequests, + Set epAppFunctions, Set epAppRoleFunctions, + Set fnUserRoles, Set epWebAnalyticsSources, + Set epWidgetCatalogRoles, + Set epMicroservices, Set 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; + } }