From 91d04c64771832a0b8815ffbe1f0f9920320d94d Mon Sep 17 00:00:00 2001 From: Pamela Dragosh Date: Tue, 14 Feb 2017 19:41:00 -0500 Subject: Initial OpenECOMP policy/engine commit Change-Id: I7dbff37733b661643dd4d1caefa3d7dccc361b6e Signed-off-by: Pamela Dragosh --- .../policy/rest/jpa/ActionBodyEntity.java | 198 +++++++ .../org/openecomp/policy/rest/jpa/ActionList.java | 106 ++++ .../policy/rest/jpa/ActionPolicyDict.java | 215 ++++++++ .../openecomp/policy/rest/jpa/AddressGroup.java | 115 +++++ .../org/openecomp/policy/rest/jpa/Attribute.java | 376 ++++++++++++++ .../policy/rest/jpa/AttributeAssignment.java | 93 ++++ .../policy/rest/jpa/BRMSParamTemplate.java | 142 +++++ .../org/openecomp/policy/rest/jpa/Category.java | 219 ++++++++ .../policy/rest/jpa/ClosedLoopD2Services.java | 177 +++++++ .../openecomp/policy/rest/jpa/ClosedLoopSite.java | 178 +++++++ .../policy/rest/jpa/ConfigurationDataEntity.java | 227 ++++++++ .../openecomp/policy/rest/jpa/ConstraintType.java | 117 +++++ .../openecomp/policy/rest/jpa/ConstraintValue.java | 116 +++++ .../org/openecomp/policy/rest/jpa/DCAEUsers.java | 103 ++++ .../org/openecomp/policy/rest/jpa/DCAEuuid.java | 103 ++++ .../policy/rest/jpa/DatabaseLockEntity.java | 47 ++ .../org/openecomp/policy/rest/jpa/Datatype.java | 245 +++++++++ .../policy/rest/jpa/DecisionSettings.java | 245 +++++++++ .../policy/rest/jpa/DescriptiveScope.java | 182 +++++++ .../org/openecomp/policy/rest/jpa/EcompName.java | 178 +++++++ .../openecomp/policy/rest/jpa/EnforcingType.java | 96 ++++ .../policy/rest/jpa/FirewallDictionaryList.java | 185 +++++++ .../policy/rest/jpa/FunctionArgument.java | 122 +++++ .../policy/rest/jpa/FunctionDefinition.java | 219 ++++++++ .../policy/rest/jpa/GlobalRoleSettings.java | 93 ++++ .../org/openecomp/policy/rest/jpa/GroupEntity.java | 276 ++++++++++ .../policy/rest/jpa/GroupPolicyScopeList.java | 114 ++++ .../policy/rest/jpa/GroupServiceList.java | 107 ++++ .../policy/rest/jpa/MicroServiceConfigName.java | 103 ++++ .../policy/rest/jpa/MicroServiceLocation.java | 103 ++++ .../policy/rest/jpa/MicroServiceModels.java | 172 +++++++ .../org/openecomp/policy/rest/jpa/Obadvice.java | 227 ++++++++ .../policy/rest/jpa/ObadviceExpression.java | 126 +++++ .../org/openecomp/policy/rest/jpa/PEPOptions.java | 184 +++++++ .../openecomp/policy/rest/jpa/PIPConfigParam.java | 147 ++++++ .../policy/rest/jpa/PIPConfiguration.java | 572 +++++++++++++++++++++ .../org/openecomp/policy/rest/jpa/PIPResolver.java | 365 +++++++++++++ .../policy/rest/jpa/PIPResolverParam.java | 147 ++++++ .../org/openecomp/policy/rest/jpa/PIPType.java | 131 +++++ .../org/openecomp/policy/rest/jpa/PREFIXLIST.java | 117 +++++ .../org/openecomp/policy/rest/jpa/PdpEntity.java | 247 +++++++++ .../policy/rest/jpa/PolicyAlgorithms.java | 116 +++++ .../policy/rest/jpa/PolicyDBDaoEntity.java | 150 ++++++ .../policy/rest/jpa/PolicyEditorScopes.java | 159 ++++++ .../openecomp/policy/rest/jpa/PolicyEntity.java | 318 ++++++++++++ .../policy/rest/jpa/PolicyManagement.java | 162 ++++++ .../org/openecomp/policy/rest/jpa/PolicyRoles.java | 102 ++++ .../policy/rest/jpa/PolicyScopeClosedLoop.java | 101 ++++ .../policy/rest/jpa/PolicyScopeResource.java | 101 ++++ .../policy/rest/jpa/PolicyScopeService.java | 101 ++++ .../openecomp/policy/rest/jpa/PolicyScopeType.java | 101 ++++ .../org/openecomp/policy/rest/jpa/PolicyScore.java | 109 ++++ .../openecomp/policy/rest/jpa/PolicyVersion.java | 182 +++++++ .../org/openecomp/policy/rest/jpa/PortList.java | 107 ++++ .../openecomp/policy/rest/jpa/ProtocolList.java | 108 ++++ .../policy/rest/jpa/RemoteCatalogValues.java | 103 ++++ .../org/openecomp/policy/rest/jpa/RiskType.java | 178 +++++++ .../openecomp/policy/rest/jpa/RuleAlgorithms.java | 125 +++++ .../policy/rest/jpa/SafePolicyWarning.java | 109 ++++ .../openecomp/policy/rest/jpa/SecurityZone.java | 104 ++++ .../org/openecomp/policy/rest/jpa/ServiceList.java | 157 ++++++ .../org/openecomp/policy/rest/jpa/SystemLogDB.java | 173 +++++++ .../org/openecomp/policy/rest/jpa/TermList.java | 262 ++++++++++ .../org/openecomp/policy/rest/jpa/UserInfo.java | 76 +++ .../java/org/openecomp/policy/rest/jpa/VMType.java | 103 ++++ .../org/openecomp/policy/rest/jpa/VNFType.java | 174 +++++++ .../org/openecomp/policy/rest/jpa/VSCLAction.java | 174 +++++++ .../policy/rest/jpa/VarbindDictionary.java | 185 +++++++ .../rest/jpa/WatchPolicyNotificationTable.java | 80 +++ .../java/org/openecomp/policy/rest/jpa/Zone.java | 104 ++++ .../openecomp/policy/rest/jpa/package-info.java | 27 + 71 files changed, 11286 insertions(+) create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ActionBodyEntity.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ActionList.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ActionPolicyDict.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/AddressGroup.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Attribute.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/AttributeAssignment.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/BRMSParamTemplate.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Category.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ClosedLoopD2Services.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ClosedLoopSite.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConfigurationDataEntity.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConstraintType.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConstraintValue.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DCAEUsers.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DCAEuuid.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DatabaseLockEntity.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Datatype.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DecisionSettings.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DescriptiveScope.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/EcompName.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/EnforcingType.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/FirewallDictionaryList.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/FunctionArgument.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/FunctionDefinition.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GlobalRoleSettings.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GroupEntity.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GroupPolicyScopeList.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GroupServiceList.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/MicroServiceConfigName.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/MicroServiceLocation.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/MicroServiceModels.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Obadvice.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ObadviceExpression.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PEPOptions.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPConfigParam.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPConfiguration.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPResolver.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPResolverParam.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPType.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PREFIXLIST.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PdpEntity.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyAlgorithms.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyDBDaoEntity.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyEditorScopes.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyEntity.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyManagement.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyRoles.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeClosedLoop.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeResource.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeService.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeType.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScore.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyVersion.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PortList.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ProtocolList.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/RemoteCatalogValues.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/RiskType.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/RuleAlgorithms.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/SafePolicyWarning.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/SecurityZone.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ServiceList.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/SystemLogDB.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/TermList.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/UserInfo.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VMType.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VNFType.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VSCLAction.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VarbindDictionary.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/WatchPolicyNotificationTable.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Zone.java create mode 100644 ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/package-info.java (limited to 'ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa') diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ActionBodyEntity.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ActionBodyEntity.java new file mode 100644 index 000000000..d12f6b3e1 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ActionBodyEntity.java @@ -0,0 +1,198 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Lob; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Version; +/* + * The Entity class to persist a policy object Action Body + */ + +import com.fasterxml.jackson.annotation.JsonBackReference; + +@Entity +@Table(name="ActionBodyEntity") +@NamedQueries({ + @NamedQuery(name=" ActionBodyEntity.findAll", query="SELECT e FROM ActionBodyEntity e "), + @NamedQuery(name="ActionBodyEntity.deleteAll", query="DELETE FROM ActionBodyEntity WHERE 1=1") +}) +//@SequenceGenerator(name="seqActBody", initialValue=1, allocationSize=1) + +public class ActionBodyEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqActBody") + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="actionBodyId") + @JsonBackReference + private long actionBodyId; + + @Column(name="actionBodyName", nullable=false, length=255) + private String actionBodyName = ""; + + @Version + @Column(name="version") + private int version; + + @Lob + @Column(name="actionBody", nullable=false, columnDefinition="TEXT") + private String actionBody = "NoBody"; + + @Column(name="created_by", nullable=false, length=255) + private String createdBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="modified_by", nullable=false, length=255) + private String modifiedBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @Column(name="deleted", nullable=false) + private boolean deleted = false; + + public ActionBodyEntity() { + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + } + /** + * @return the configurationDataId + */ + public long getActionBodyId() { + return actionBodyId; + } + /** + * @param configurationDataId the configurationDataId to set + */ + public void setActionBodyName(String name) { + this.actionBodyName = name; + } + public String getActionBodyName(){ + return this.actionBodyName; + } + + /** + * @return the actionBody + */ + public String getActionBody() { + return actionBody; + } + /** + * @param configBody the configBody to set + */ + public void setActionBody(String body) { + this.actionBody = body; + } + /** + * @return the createdBy + */ + public String getCreatedBy() { + return createdBy; + } + /** + * @param createdBy the createdBy to set + */ + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + /** + * @return the modifiedBy + */ + public String getModifiedBy() { + return modifiedBy; + } + /** + * @param modifiedBy the modifiedBy to set + */ + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + /** + * @return the modifiedDate + */ + public Date getModifiedDate() { + return modifiedDate; + } + /** + * @param modifiedDate the modifiedDate to set + */ + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + /** + * @return the version + */ + public int getVersion() { + return version; + } + /** + * @return the createdDate + */ + public Date getCreatedDate() { + return createdDate; + } + + /** + * @return the deleted + */ + public boolean isDeleted() { + return deleted; + } + + /** + * @param deleted the deleted to set + */ + public void setDeleted(boolean deleted) { + this.deleted = deleted; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ActionList.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ActionList.java new file mode 100644 index 000000000..0176c17be --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ActionList.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@Table(name="actionlist") +@NamedQuery(name="ActionList.findAll", query="SELECT e FROM ActionList e ") +public class ActionList implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="actionname", nullable=false) + @OrderBy("asc") + private String actionName; + + @Column(name="description") + private String description; +/* + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate;*/ + + public ActionList() { + + } + public ActionList(String string, String userid) { + this(domain); + + } + public ActionList(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + public String getActionName() { + return this.actionName; + } + + public void setActionName(String actionName) { + this.actionName = actionName; + + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ActionPolicyDict.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ActionPolicyDict.java new file mode 100644 index 000000000..fa7d2af95 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ActionPolicyDict.java @@ -0,0 +1,215 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +/* + */ +package org.openecomp.policy.rest.jpa; +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +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.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + +@Entity +@Table(name="ActionPolicyDict") +//@NamedQuery(name="ActionPolicyDict.findAll", query="SELECT e FROM ActionPolicyDict e ") +@NamedQueries({ + @NamedQuery(name="ActionPolicyDict.findAll", query="SELECT e FROM ActionPolicyDict e") +}) +public class ActionPolicyDict implements Serializable { + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="ATTRIBUTE_NAME", nullable=false) + @OrderBy("asc") + private String attributeName; + + @Column(name="Type", nullable=false) + @OrderBy("asc") + private String type; + + @Column(name="URL", nullable=false) + @OrderBy("asc") + private String url; + + @Column(name="Method", nullable=false) + @OrderBy("asc") + private String method; + + @Column(name="Headers", nullable=true) + @OrderBy("asc") + private String header; + + @Column(name="Body", nullable=true) + @OrderBy("asc") + private String body; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(ActionPolicyDict.class); + public ActionPolicyDict() { + + } + + public ActionPolicyDict(String string, String userid) { + this(string); + } + + public ActionPolicyDict(String domain) { + this.type = domain; + } + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy =XacmlAdminAuthorization.getUserId();; + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "ActionPolicyDict", "Exception caused While adding Modified by Role"); + } + } + public int getId() { + return this.id; + } + public void setId(int id) { + this.id = id; + } + + public Date getCreatedDate() { + return this.createdDate; + } + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + public String getDescription() { + return this.description; + } + public void setDescription(String description) { + this.description = description; + } + + public Date getModifiedDate() { + return this.modifiedDate; + } + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + public String getUrl() { + return url; + } + public void setUrl(String url) { + this.url = url; + } + public String getMethod() { + return method; + } + public void setMethod(String method) { + this.method = method; + } + public String getHeader() { + return header; + } + public void setHeader(String header) { + this.header = header; + } + + public String getBody() { + return body; + } + public void setBody(String body) { + this.body = body; + } + public String getAttributeName() { + return attributeName; + } + public void setAttributeName(String attributeName) { + this.attributeName = attributeName; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/AddressGroup.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/AddressGroup.java new file mode 100644 index 000000000..6418d6bc5 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/AddressGroup.java @@ -0,0 +1,115 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + +@Entity +@Table(name="AddressGroup") +@NamedQuery(name="AddressGroup.findAll", query="SELECT e FROM AddressGroup e ") +public class AddressGroup implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="prefixlist") + private String prefixList; + + + @Column(name="description") + private String description; + + public AddressGroup() { + + } + public AddressGroup(String string, String userid) { + this(domain); + + } + public AddressGroup(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getGroupName() { + return this.name; + } + + public void setGroupName(String serviceName) { + this.name = serviceName; + + } + + public String getPrefixList() { + return this.prefixList; + } + + public void setServiceList(String prefixList) { + this.prefixList = prefixList; + + } + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Attribute.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Attribute.java new file mode 100644 index 000000000..e79126ae2 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Attribute.java @@ -0,0 +1,376 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; +import org.openecomp.policy.rest.jpa.UserInfo; + +import com.att.research.xacml.api.Identifier; +import com.att.research.xacml.std.IdentifierImpl; +import com.fasterxml.jackson.annotation.JsonBackReference; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonManagedReference; + +/** + * The persistent class for the Attribute database table. + * + */ +@Entity +@Table(name="Attribute") +@NamedQuery(name="Attribute.findAll", query="SELECT a FROM Attribute a order by a.priority asc, a.xacmlId asc") +public class Attribute implements Serializable { + private static final long serialVersionUID = 1L; + + public static String ATTRIBUTE_DESIGNATOR = "Attribute Designator"; + public static String ATTRIBUTE_SELECTOR = "Attribute Selector"; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + //bi-directional many-to-one association to Category + @ManyToOne + @JoinColumn(name="constraint_type", nullable=true) + @JsonIgnore + private ConstraintType constraintType; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @Column(name="PRIORITY", nullable=true) + @OrderBy("asc") + private String priority; + + @Column(name="ATTRIBUTE_VALUE", nullable=true) + @OrderBy("asc") + private String attributeValue; + + @Column(name="xacml_id", unique = true, nullable=false) + @OrderBy("asc") + private String xacmlId = "urn"; + + //bi-directional many-to-one association to ConstraintValue + @OneToMany(mappedBy="attribute", orphanRemoval=true, cascade=CascadeType.REMOVE) + @JsonIgnore + private Set constraintValues = new HashSet(); + + //bi-directional many-to-one association to Category + @ManyToOne + @JoinColumn(name="category") + @JsonIgnore + private Category categoryBean; + + //bi-directional many-to-one association to Datatype + @ManyToOne + @JoinColumn(name="datatype") + private Datatype datatypeBean; + + @Column(name="is_designator", nullable=false) + @JsonIgnore + private char isDesignator = '1'; + + @Column(name="selector_path", nullable=true, length=2048) + private String selectorPath; + + + + @Transient + private String issuer = null; + + @Transient + private boolean mustBePresent = false; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(Attribute.class); + public Attribute() { + } + + public Attribute(String domain) { + this.xacmlId = domain; + } + + public Attribute(String domain, String user) { + this(domain); + } + + public Attribute(Attribute copy, String user) { + this(copy.getXacmlId() + ":(0)", user); + this.constraintType = copy.getConstraintType(); + this.categoryBean = copy.getCategoryBean(); + this.datatypeBean = copy.getDatatypeBean(); + this.description = copy.getDescription(); + for (ConstraintValue value : copy.getConstraintValues()) { + ConstraintValue newValue = new ConstraintValue(value); + newValue.setAttribute(this); + this.addConstraintValue(newValue); + } + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy = XacmlAdminAuthorization.getUserId(); + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + //PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "Attribute", "Exception caused While adding Modified by Role"); + } + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public ConstraintType getConstraintType() { + return this.constraintType; + } + + public void setConstraintType(ConstraintType constraintType) { + this.constraintType = constraintType; + } + + public Date getCreatedDate() { + return this.createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getModifiedDate() { + return this.modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + + public String getXacmlId() { + return this.xacmlId; + } + +/* @Transient + public Identifier getXacmlIdentifier() { + return new IdentifierImpl(this.xacmlId); + }*/ + + public void setXacmlId(String xacmlId) { + this.xacmlId = xacmlId; + } + + public Set getConstraintValues() { + return this.constraintValues; + } + + public void setConstraintValues(Set constraintValues) { + for (ConstraintValue value : this.constraintValues) { + value.setAttribute(this); + } + this.constraintValues = constraintValues; + } + + public ConstraintValue addConstraintValue(ConstraintValue constraintValue) { + if (this.constraintValues == null) { + this.constraintValues = new HashSet(); + } + this.constraintValues.add(constraintValue); + constraintValue.setAttribute(this); + + return constraintValue; + } + + public ConstraintValue removeConstraintValue(ConstraintValue constraintValue) { + this.constraintValues.remove(constraintValue); + constraintValue.setAttribute(null); + + return constraintValue; + } + + public void removeAllConstraintValues() { + if (this.constraintValues == null) { + return; + } + for (ConstraintValue value : this.constraintValues) { + value.setAttribute(null); + } + this.constraintValues.clear(); + } + + public Category getCategoryBean() { + return this.categoryBean; + } + + public void setCategoryBean(Category categoryBean) { + this.categoryBean = categoryBean; + } + + public Datatype getDatatypeBean() { + return this.datatypeBean; + } + + public void setDatatypeBean(Datatype datatypeBean) { + this.datatypeBean = datatypeBean; + } + + public char getIsDesignator() { + return this.isDesignator; + } + + public void setIsDesignator(char is) { + this.isDesignator = is; + } + + public String getSelectorPath() { + return this.selectorPath; + } + + public void setSelectorPath(String path) { + this.selectorPath = path; + } + + @Transient + public String getIssuer() { + return issuer; + } + + @Transient + public void setIssuer(String issuer) { + this.issuer = issuer; + } + + @Transient + public boolean isMustBePresent() { + return mustBePresent; + } + + @Transient + public void setMustBePresent(boolean mustBePresent) { + this.mustBePresent = mustBePresent; + } + + @Transient + public boolean isDesignator() { + return (this.isDesignator == '1'); + } + + @Transient + public void setIsDesignator(boolean is) { + if (is) { + this.isDesignator = '1'; + } else { + this.isDesignator = '0'; + } + } + + public String getPriority() { + return priority; + } + + public void setPriority(String priority) { + this.priority = priority; + } + + public String getAttributeValue() { + return attributeValue; + } + + public void setAttributeValue(String attributeValue) { + this.attributeValue = attributeValue; + } +} + diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/AttributeAssignment.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/AttributeAssignment.java new file mode 100644 index 000000000..1e81213d3 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/AttributeAssignment.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ +package org.openecomp.policy.rest.jpa; + +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.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.Table; + + +/** + * The persistent class for the ObadviceExpressions database table. + * + */ +@Entity +@Table(name="AttributeAssignment") +@NamedQuery(name="AttributeAssignment.findAll", query="SELECT a FROM AttributeAssignment a") +public class AttributeAssignment implements Serializable { + private static final long serialVersionUID = 1L; + + public static final String EXPRESSION_APPLY = "Apply"; + public static final String EXPRESSION_SELECTOR = "AttributeSelector"; + public static final String EXPRESSION_VALUE = "AttributeValue"; + public static final String EXPRESSION_FUNCTION = "Function"; + public static final String EXPRESSION_REFERENCE = "VarableReference"; + public static final String EXPRESSION_DESIGNATOR = "AttributeDesignator"; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="attribute_id") + private int attributeId; + + //bi-directional many-to-one association to Obadvice + @Column(name="expression", nullable=false) + private String expression; + + //bi-directional many-to-one association to Obadvice + @ManyToOne + private Obadvice obadvice; + + public AttributeAssignment() { + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public int getAttributeId() { + return this.attributeId; + } + + public void setAttributeId(int attributeId) { + this.attributeId = attributeId; + } + + public String getExpression() { + return expression; + } + + public void setExpression(String expression) { + this.expression = expression; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/BRMSParamTemplate.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/BRMSParamTemplate.java new file mode 100644 index 000000000..54661de0c --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/BRMSParamTemplate.java @@ -0,0 +1,142 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.Lob; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.openecomp.policy.rest.jpa.UserInfo; + +/* + * JPA for the BRMS Param Template. + * + * @version: 0.1 + */ + + +@Entity +@Table(name="BRMSParamTemplate") +@NamedQuery(name="BRMSParamTemplate.findAll", query="SELECT b FROM BRMSParamTemplate b ") +public class BRMSParamTemplate implements Serializable{ + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="param_template_name", nullable=false, unique=true) + @OrderBy("asc") + private String ruleName; + + @Lob + @Column(name="rule",nullable=false) + private String rule; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public BRMSParamTemplate(){ + } + + public BRMSParamTemplate(String userid){ + + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + + public Date getCreatedDate() { + return this.createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getRule(){ + return this.rule; + } + + public void setRule(String rule){ + this.rule = rule; + } + + public String getRuleName(){ + return this.ruleName; + } + + public void setRuleName(String ruleName){ + this.ruleName = ruleName; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Category.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Category.java new file mode 100644 index 000000000..abc06879d --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Category.java @@ -0,0 +1,219 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.persistence.Transient; + +import com.att.research.xacml.api.Identifier; +import com.att.research.xacml.api.XACML3; +import com.att.research.xacml.std.IdentifierImpl; +import com.fasterxml.jackson.annotation.JsonBackReference; +import com.fasterxml.jackson.annotation.JsonIgnore; + + +/** + * The persistent class for the Categories database table. + * + */ +@Entity +@Table(name="Category") +@NamedQuery(name="Category.findAll", query="SELECT c FROM Category c") +public class Category implements Serializable { + private static final long serialVersionUID = 1L; + + public static final char STANDARD = 'S'; + public static final char CUSTOM = 'C'; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="grouping", nullable=false, length=64) + private String grouping; + + @Column(name="is_standard", nullable=false) + private char isStandard; + + @Column(name="xacml_id", nullable=false, unique=true, length=255) + private String xacmlId; + + @Column(name="short_name", nullable=false, length=64) + private String shortName; + + //bi-directional many-to-one association to Attribute + @OneToMany(mappedBy="categoryBean") + @JsonBackReference + private Set attributes = new HashSet<>(); + + public Category() { + this.xacmlId = XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT.stringValue(); + this.grouping = "subject"; + this.isStandard = Category.STANDARD; + this.shortName = "subject"; + } + + public Category(Identifier cat, String grouping, char isStandard) { + if (cat != null) { + this.xacmlId = cat.stringValue(); + } + this.isStandard = isStandard; + if (grouping != null) { + this.grouping = grouping; + } else { + this.grouping = Category.extractGrouping(this.xacmlId); + } + } + + public Category(Identifier cat, String grouping) { + this(cat, grouping, Category.STANDARD); + } + + public Category(Identifier cat, char standard) { + this(cat, null, standard); + } + + public Category(Identifier cat) { + this(cat, Category.STANDARD); + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getGrouping() { + return this.grouping; + } + + public void setGrouping(String grouping) { + this.grouping = grouping; + } + + public char getIsStandard() { + return this.isStandard; + } + + public void setIsStandard(char isStandard) { + this.isStandard = isStandard; + } + + public String getXacmlId() { + return this.xacmlId; + } + + public void setXacmlId(String xacmlId) { + this.xacmlId = xacmlId; + } + + public String getShortName() { + return this.shortName; + } + + public void setShortName(String shortName) { + this.shortName = shortName; + } + + public Set getAttributes() { + return this.attributes; + } + + public void setAttributes(Set attributes) { + this.attributes = attributes; + } + + public Attribute addAttribute(Attribute attribute) { + getAttributes().add(attribute); + attribute.setCategoryBean(this); + + return attribute; + } + + public Attribute removeAttribute(Attribute attribute) { + getAttributes().remove(attribute); + attribute.setCategoryBean(null); + + return attribute; + } + + @Transient + public boolean isStandard() { + return (this.isStandard == Category.STANDARD); + } + + @Transient + public boolean isCustom() { + return (this.isStandard == Category.CUSTOM); + } + + @Transient + public static String extractGrouping(String xacmlId) { + if (xacmlId == null) { + return null; + } + if (xacmlId.matches(".*:attribute\\-category:.*")) { + String[] parts = xacmlId.split("[:]"); + if (parts != null && parts.length > 0) { + return parts[parts.length - 1]; + } + } else if (xacmlId.matches(".*:[a-zA-Z]+[\\-]category:.*")) { + String[] parts = xacmlId.split("[:]"); + if (parts != null && parts.length > 0) { + for (String part : parts) { + int index = part.indexOf("-category"); + if (index > 0) { + return part.substring(0, index); + } + } + } + } + return null; + } + + @Transient + public Identifier getIdentifer() { + return new IdentifierImpl(this.xacmlId); + } + + @Transient + @Override + public String toString() { + return "Category [id=" + id + ", grouping=" + grouping + + ", isStandard=" + isStandard + ", xacmlId=" + xacmlId + + ", attributes=" + attributes + "]"; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ClosedLoopD2Services.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ClosedLoopD2Services.java new file mode 100644 index 000000000..408190ac9 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ClosedLoopD2Services.java @@ -0,0 +1,177 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + * + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + +@Entity +@Table(name = "ClosedLoopD2Services") +@NamedQuery(name="ClosedLoopD2Services.findAll", query="SELECT c FROM ClosedLoopD2Services c ") +public class ClosedLoopD2Services implements Serializable{ + private static final long serialVersionUID = 1L; + + private static String domain; + + + @Id + @Column(name ="id") + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + @Column(name="service_Name", nullable=false, unique=true) + @OrderBy("asc") + private String serviceName; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(ClosedLoopD2Services.class); + + public ClosedLoopD2Services(){ + + } + + public ClosedLoopD2Services(String string, String userid) { + this(domain); + } + + public ClosedLoopD2Services(String domain) { + this.serviceName = domain; + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy = XacmlAdminAuthorization.getUserId();; + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "ClosedLoopD2Services", "Exception caused While adding Modified by Role"); + } + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getServiceName() { + return serviceName; + } + + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public Date getModifiedDate() { + return modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ClosedLoopSite.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ClosedLoopSite.java new file mode 100644 index 000000000..b32091307 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ClosedLoopSite.java @@ -0,0 +1,178 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +/* + * + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + +@Entity +@Table(name = "ClosedLoopSite") +@NamedQuery(name="ClosedLoopSite.findAll", query="SELECT c FROM ClosedLoopSite c ") +public class ClosedLoopSite implements Serializable{ + private static final long serialVersionUID = 1L; + + private static String domain; + + + @Id + @Column(name ="id") + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + @Column(name="site_Name", nullable=false, unique=true) + @OrderBy("asc") + private String siteName; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(ClosedLoopSite.class); + + public ClosedLoopSite(){ + + } + + public ClosedLoopSite(String string, String userid) { + this(domain); + } + + public ClosedLoopSite(String domain) { + this.siteName = domain; + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy = XacmlAdminAuthorization.getUserId();; + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "ClosedLoopSite", "Exception caused While adding Modified by Role"); + } + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getSiteName() { + return siteName; + } + + public void setSiteName(String siteName) { + this.siteName = siteName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public Date getModifiedDate() { + return modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConfigurationDataEntity.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConfigurationDataEntity.java new file mode 100644 index 000000000..71a6d6fb7 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConfigurationDataEntity.java @@ -0,0 +1,227 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Lob; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Version; +/* + * The Entity class to persist a policy object configuration data + */ + +import com.fasterxml.jackson.annotation.JsonBackReference; + +@Entity +@Table(name="ConfigurationDataEntity") +@NamedQueries({ + @NamedQuery(name="ConfigurationDataEntity.findAll", query="SELECT e FROM ConfigurationDataEntity e "), + @NamedQuery(name="ConfigurationDataEntity.deleteAll", query="DELETE FROM ConfigurationDataEntity WHERE 1=1") +}) +//@SequenceGenerator(name="seqConfig", initialValue=1, allocationSize=1) + +public class ConfigurationDataEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqConfig") + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="configurationDataId") + @JsonBackReference + private long configurationDataId; + + @Column(name="configurationName", nullable=false, length=255) + private String configurationName = ""; + + @Version + @Column(name="version") + private int version; + + @Column(name="configType", nullable=false, length=255) + private String configType = "NoType"; + + @Lob + @Column(name="configBody", nullable=false, columnDefinition="TEXT") + private String configBody = "NoBody"; + + @Column(name="created_by", nullable=false, length=255) + private String createdBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="description", nullable=false, length=2048) + private String description = "NoDescription"; + + @Column(name="modified_by", nullable=false, length=255) + private String modifiedBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @Column(name="deleted", nullable=false) + private boolean deleted = false; + + public ConfigurationDataEntity() { + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + } + /** + * @return the configurationDataId + */ + public long getConfigurationDataId() { + return configurationDataId; + } + /** + * @param configurationDataId the configurationDataId to set + */ + public void setConfigurationName(String configurationName) { + this.configurationName = configurationName; + } + public String getConfigurationName(){ + return this.configurationName; + } + /** + * @return the configType + */ + public String getConfigType() { + return configType; + } + /** + * @param configType the configType to set + */ + public void setConfigType(String configType) { + this.configType = configType; + } + /** + * @return the configBody + */ + public String getConfigBody() { + return configBody; + } + /** + * @param configBody the configBody to set + */ + public void setConfigBody(String configBody) { + this.configBody = configBody; + } + /** + * @return the createdBy + */ + public String getCreatedBy() { + return createdBy; + } + /** + * @param createdBy the createdBy to set + */ + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + /** + * @return the description + */ + public String getDescription() { + return description; + } + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + /** + * @return the modifiedBy + */ + public String getModifiedBy() { + return modifiedBy; + } + /** + * @param modifiedBy the modifiedBy to set + */ + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + /** + * @return the modifiedDate + */ + public Date getModifiedDate() { + return modifiedDate; + } + /** + * @param modifiedDate the modifiedDate to set + */ + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + /** + * @return the version + */ + public int getVersion() { + return version; + } + /** + * @return the createdDate + */ + public Date getCreatedDate() { + return createdDate; + } + + /** + * @return the deleted + */ + public boolean isDeleted() { + return deleted; + } + + /** + * @param deleted the deleted to set + */ + public void setDeleted(boolean deleted) { + this.deleted = deleted; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConstraintType.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConstraintType.java new file mode 100644 index 000000000..73e053ce7 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConstraintType.java @@ -0,0 +1,117 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.Table; + +@Entity +@Table(name="ConstraintType") +@NamedQuery(name="ConstraintType.findAll", query="SELECT a FROM ConstraintType a") +public class ConstraintType implements Serializable { + private static final long serialVersionUID = 1L; + + public static String ENUMERATION_TYPE = "Enumeration"; + public static String RANGE_TYPE = "Range"; + public static String REGEXP_TYPE = "Regular Expression"; + + public static Map defaults = new HashMap(); + static { + defaults.put(ENUMERATION_TYPE, "Enumerate a set of values that the attribute may be set to during policy creation."); + defaults.put(RANGE_TYPE, "Set a range of min and/or max integer/double values the attribute can be set to during policy creation."); + defaults.put(REGEXP_TYPE, "Define a regular expression the attribute must match against during policy creation."); + } + public static final String[] RANGE_TYPES = {"minExclusive", "minInclusive", "maxExclusive", "maxInclusive"}; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="constraint_type", nullable=false, length=64) + private String constraintType; + + @Column(name="description", nullable=false, length=255) + private String description; + + //bi-directional many-to-one association to Attribute + @OneToMany(mappedBy="constraintType") + private Set attributes = new HashSet<>(); + + public ConstraintType() { + + } + + public ConstraintType(String constraintType) { + this(); + this.constraintType = constraintType; + } + + public ConstraintType(String constraintType, String description) { + this(constraintType); + this.description = description; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getConstraintType() { + return constraintType; + } + + public void setConstraintType(String constraintType) { + this.constraintType = constraintType; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Set getAttributes() { + return attributes; + } + + public void setAttributes(Set attributes) { + this.attributes = attributes; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConstraintValue.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConstraintValue.java new file mode 100644 index 000000000..65eb6586a --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConstraintValue.java @@ -0,0 +1,116 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +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.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.Table; + + +/** + * The persistent class for the ConstraintValues database table. + * + */ +@Entity +@Table(name="ConstraintValues") +@NamedQuery(name="ConstraintValue.findAll", query="SELECT c FROM ConstraintValue c") +public class ConstraintValue implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="property") + private String property; + + @Column(name="value") + private String value; + + //bi-directional many-to-one association to Attribute + @ManyToOne + @JoinColumn(name="attribute_id") + private Attribute attribute; + + public ConstraintValue() { + } + + public ConstraintValue(String property, String value) { + this.property = property; + this.value = value; + } + + public ConstraintValue(ConstraintValue value) { + this.property = value.getProperty(); + this.value = value.getValue(); + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getProperty() { + return this.property; + } + + public void setProperty(String property) { + this.property = property; + } + + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + public Attribute getAttribute() { + return this.attribute; + } + + public void setAttribute(Attribute attribute) { + this.attribute = attribute; + } + + public ConstraintValue clone() { + ConstraintValue constraint = new ConstraintValue(); + + constraint.property = this.property; + constraint.value = this.value; + constraint.attribute = this.attribute; + + return constraint; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DCAEUsers.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DCAEUsers.java new file mode 100644 index 000000000..eb0c4cc1b --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DCAEUsers.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + + +@Entity +@Table(name="DCAEUsers") +@NamedQuery(name="DCAEUsers.findAll", query="SELECT e FROM DCAEUsers e ") +public class DCAEUsers implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="description ") + private String description ; + + + public DCAEUsers() { + + } + public DCAEUsers(String string, String userid) { + this(domain); + + } + public DCAEUsers(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + + } + public String getDescriptionValue() { + return this.description ; + } + + public void setDescriptionValue(String description ) { + this.description = description ; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DCAEuuid.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DCAEuuid.java new file mode 100644 index 000000000..a71921b5e --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DCAEuuid.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + + +@Entity +@Table(name="DCAEuuid") +@NamedQuery(name="DCAEuuid.findAll", query="SELECT e FROM DCAEuuid e ") +public class DCAEuuid implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="description") + private String description; + + + public DCAEuuid() { + + } + public DCAEuuid(String string, String userid) { + this(domain); + + } + public DCAEuuid(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DatabaseLockEntity.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DatabaseLockEntity.java new file mode 100644 index 000000000..c24b13a0e --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DatabaseLockEntity.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name="DatabaseLockEntity") +public class DatabaseLockEntity implements Serializable { + private static final long serialVersionUID = 1L; + @Id + @Column(name="lock_key") + private int lock_key = 1; + public DatabaseLockEntity(){ + + } + public int getKey(){ + return lock_key; + } + public void setKey(int key){ + this.lock_key = key; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Datatype.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Datatype.java new file mode 100644 index 000000000..b3922f10b --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Datatype.java @@ -0,0 +1,245 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.persistence.Transient; + +import com.att.research.xacml.api.Identifier; +import com.att.research.xacml.api.XACML3; +import com.att.research.xacml.std.IdentifierImpl; +import com.fasterxml.jackson.annotation.JsonBackReference; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonManagedReference; + + +/** + * The persistent class for the Datatype database table. + * + */ +@Entity +@Table(name="Datatype") +@NamedQuery(name="Datatype.findAll", query="SELECT d FROM Datatype d") +public class Datatype implements Serializable { + private static final long serialVersionUID = 1L; + + public static final char STANDARD = 'S'; + public static final char CUSTOM = 'C'; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="is_standard", nullable=false) + private char isStandard; + + @Column(name="xacml_id", nullable=false, unique=true, length=255) + private String xacmlId; + + @Column(name="short_name", nullable=false, length=64) + private String shortName; + + //bi-directional many-to-one association to Attribute + @OneToMany(mappedBy="datatypeBean") + @JsonBackReference + private Set attributes = new HashSet<>(); + + //bi-directional many-to-one association to Attribute + @OneToMany(mappedBy="datatypeBean") + @JsonIgnore + private Set functions = new HashSet<>(); + + //bi-directional many-to-one association to Attribute + @OneToMany(mappedBy="datatypeBean") + @JsonIgnore + private Set arguments = new HashSet<>(); + + public Datatype() { + this.xacmlId = XACML3.ID_DATATYPE_STRING.stringValue(); + this.isStandard = Datatype.STANDARD; + } + + + public Datatype(int id, Datatype dt) { + this.id = id; + this.isStandard = dt.isStandard; + this.xacmlId = dt.xacmlId; + this.shortName = dt.shortName; + // + // Make a copy? + // + this.attributes = new HashSet<>(); + } + + public Datatype(Identifier identifier, char standard) { + if (identifier != null) { + this.xacmlId = identifier.stringValue(); + + } + this.isStandard = standard; + } + + public Datatype(Identifier identifier) { + this(identifier, Datatype.STANDARD); + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public char getIsStandard() { + return this.isStandard; + } + + public void setIsStandard(char isStandard) { + this.isStandard = isStandard; + } + + public String getXacmlId() { + return this.xacmlId; + } + + public void setXacmlId(String xacmlId) { + this.xacmlId = xacmlId; + } + + public String getShortName() { + return shortName; + } + + public void setShortName(String shortName) { + this.shortName = shortName; + } + + public Set getAttributes() { + return this.attributes; + } + + public void setAttributes(Set attributes) { + this.attributes = attributes; + } + + public Attribute addAttribute(Attribute attribute) { + getAttributes().add(attribute); + attribute.setDatatypeBean(this); + + return attribute; + } + + public Attribute removeAttribute(Attribute attribute) { + getAttributes().remove(attribute); + attribute.setDatatypeBean(null); + + return attribute; + } + + public Set getFunctions() { + return this.functions; + } + + public void setFunctions(Set functions) { + this.functions = functions; + } + + public FunctionDefinition addFunction(FunctionDefinition function) { + getFunctions().add(function); + function.setDatatypeBean(this); + + return function; + } + + public FunctionDefinition removeAttribute(FunctionDefinition function) { + getFunctions().remove(function); + function.setDatatypeBean(null); + + return function; + } + + public Set getArguments() { + return this.arguments; + } + + public void setArguments(Set argument) { + this.arguments = argument; + } + + public FunctionArgument addArgument(FunctionArgument argument) { + getArguments().add(argument); + argument.setDatatypeBean(this); + + return argument; + } + + public FunctionArgument removeArgument(FunctionArgument argument) { + getArguments().remove(argument); + argument.setDatatypeBean(null); + + return argument; + } + + @Transient + public Identifier getIdentifer() { + return new IdentifierImpl(this.xacmlId); + } + + @Transient + public Identifier getIdentiferByShortName() { + return new IdentifierImpl(this.shortName); + } + + @Transient + public boolean isStandard() { + return (this.isStandard == Datatype.STANDARD); + } + + @Transient + public boolean isCustom() { + return (this.isStandard == Datatype.CUSTOM); + } + + @Transient + @Override + public String toString() { + return "Datatype [id=" + id + ", isStandard=" + isStandard + + ", xacmlId=" + xacmlId + ", shortName=" + shortName + + ", attributes=" + attributes + ", functions=" + functions + + ", arguments=" + arguments + "]"; + + //return "Datatype [shortName=" + shortName + "]"; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DecisionSettings.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DecisionSettings.java new file mode 100644 index 000000000..1d90af679 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DecisionSettings.java @@ -0,0 +1,245 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import com.att.research.xacml.api.Identifier; +import com.att.research.xacml.std.IdentifierImpl; +import com.fasterxml.jackson.annotation.JsonManagedReference; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + +@Entity +@Table(name="DecisionSettings") +@NamedQuery(name="DecisionSettings.findAll", query="SELECT a FROM DecisionSettings a order by a.priority asc, a.xacmlId asc") +public class DecisionSettings implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @Column(name="PRIORITY", nullable=true) + @OrderBy("asc") + private String priority; + + @Column(name="xacml_id", unique = true, nullable=false) + @OrderBy("asc") + private String xacmlId = "urn"; + + //bi-directional many-to-one association to Datatype + @ManyToOne + @JoinColumn(name="datatype") + private Datatype datatypeBean; + + @Transient + private String issuer = null; + + @Transient + private boolean mustBePresent = false; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(DecisionSettings.class); + public DecisionSettings() { + } + + public DecisionSettings(String domain) { + this.xacmlId = domain; + } + + public DecisionSettings(String domain, String user) { + this(domain); + } + public DecisionSettings(DecisionSettings copy, String user) { + this(copy.getXacmlId() + ":(0)", user); + this.datatypeBean = copy.getDatatypeBean(); + this.description = copy.getDescription(); + + } + + public String getDecisionSettings(){ + return this.xacmlId; + } + + public String setDecisionSettings(){ + return this.xacmlId = xacmlId; + } + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy = XacmlAdminAuthorization.getUserId();; + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "DecisionSettings", "Exception caused While adding Modified by Role"); + } + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + + public Date getCreatedDate() { + return this.createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getModifiedDate() { + return this.modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + + public String getXacmlId() { + return this.xacmlId; + } + +/* @Transient + public Identifier getXacmlIdentifier() { + return new IdentifierImpl(this.xacmlId); + }*/ + + public void setXacmlId(String xacmlId) { + this.xacmlId = xacmlId; + } + + public Datatype getDatatypeBean() { + return this.datatypeBean; + } + + public void setDatatypeBean(Datatype datatypeBean) { + this.datatypeBean = datatypeBean; + } + + @Transient + public String getIssuer() { + return issuer; + } + + @Transient + public void setIssuer(String issuer) { + this.issuer = issuer; + } + + @Transient + public boolean isMustBePresent() { + return mustBePresent; + } + + @Transient + public void setMustBePresent(boolean mustBePresent) { + this.mustBePresent = mustBePresent; + } + + public String getPriority() { + return priority; + } + + public void setPriority(String priority) { + this.priority = priority; + } +} + diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DescriptiveScope.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DescriptiveScope.java new file mode 100644 index 000000000..9f751f7c0 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DescriptiveScope.java @@ -0,0 +1,182 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + +@Entity +@Table(name = "DescriptiveScope") +@NamedQuery(name = "DescriptiveScope.findAll", query= "Select p from DescriptiveScope p") +public class DescriptiveScope implements Serializable { + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "Id") + private int id; + + @Column(name="scopename", nullable=false) + @OrderBy("asc") + private String descriptiveScopeName; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Column(name="search", nullable=true) + @OrderBy("asc") + private String search; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(DescriptiveScope.class); + + public DescriptiveScope(){ + + } + + public DescriptiveScope(String string, String userid) { + this(string); + } + + public DescriptiveScope(String domain) { + this.descriptiveScopeName = domain; + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy =XacmlAdminAuthorization.getUserId();; + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "DescriptiveScope", "Exception caused While adding Modified by Role"); + } + } + + public int getId() { + return this.id; + } + public void setId(int id) { + this.id = id; + } + + public String getScopeName() { + return descriptiveScopeName; + } + + public void setScopeName(String descriptiveScopeName) { + this.descriptiveScopeName = descriptiveScopeName; + } + + public String getSearch() { + return search; + } + + public void setSearch(String search) { + this.search = search; + } + + public Date getCreatedDate() { + return this.createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getModifiedDate() { + return this.modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/EcompName.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/EcompName.java new file mode 100644 index 000000000..599e47818 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/EcompName.java @@ -0,0 +1,178 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; +import org.openecomp.policy.rest.jpa.UserInfo; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonManagedReference; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + +@Entity +@Table(name="EcompName") +@NamedQuery(name="EcompName.findAll", query="SELECT e FROM EcompName e ") +public class EcompName implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="ecomp_Name", nullable=false, unique=true) + @OrderBy("asc") + private String ecompName; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(EcompName.class); + + public EcompName() { + + } + + public EcompName(String string, String userid) { + this(domain); + } + + public EcompName(String domain) { + this.ecompName = domain; + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy =XacmlAdminAuthorization.getUserId(); + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "EcompName", "Exception caused While adding Modified by Role"); + } + } + public String getEcompName() { + return this.ecompName; + } + + public void setEcompName(String ecompName) { + this.ecompName = ecompName; + + } + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public Date getCreatedDate() { + return this.createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getModifiedDate() { + return this.modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/EnforcingType.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/EnforcingType.java new file mode 100644 index 000000000..f293bc0cb --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/EnforcingType.java @@ -0,0 +1,96 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; + +import javax.persistence.*; + +/** + * Entity implementation class for Entity: EnforcingType + * + */ +@Entity +@Table(name="EnforcingType") +@NamedQuery(name="EnforcingType.findAll", query="SELECT e FROM EnforcingType e ") +public class EnforcingType implements Serializable { + + + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + @Column(name="enforcingType", nullable=false, unique=true) + @OrderBy("asc") + private String enforcingType; + @Column(name="script", nullable=false, length=255) + private String script; + @Column(name="connectionQuery", nullable=false, length=255) + private String connectionQuery; + @Column(name="valueQuery", nullable=false, length=255) + private String valueQuery; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getEnforcingType() { + return enforcingType; + } + + public void setEnforcingType(String enforcingType) { + this.enforcingType = enforcingType; + } + + public String getScript() { + return script; + } + + public void setScript(String script) { + this.script = script; + } + + public String getConnectionQuery() { + return connectionQuery; + } + + public void setConnectionQuery(String connectionQuery) { + this.connectionQuery = connectionQuery; + } + + public String getValueQuery() { + return valueQuery; + } + + public void setValueQuery(String valueQuery) { + this.valueQuery = valueQuery; + } + + public EnforcingType() { + super(); + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/FirewallDictionaryList.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/FirewallDictionaryList.java new file mode 100644 index 000000000..3c47de817 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/FirewallDictionaryList.java @@ -0,0 +1,185 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + +@Entity +@Table(name="parentdictionaryitems") +@NamedQuery(name="FirewallDictionaryList.findAll", query="SELECT e FROM FirewallDictionaryList e") +public class FirewallDictionaryList implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="parentItemName", nullable=false) + @OrderBy("asc") + private String parentItemName; + + @Column(name="description") + private String description; + + @Column(name="addressList") + private String addressList; + + @Column(name="serviceList") + private String serviceList; + +/* @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy;*/ + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getParentItemName() { + return parentItemName; + } + + public String getDescription() { + return description; + } + + public String getAddressList() { + return addressList; + } + + public String getServiceList() { + return serviceList; + } + + public void setParentItemName(String parentItemName) { + this.parentItemName = parentItemName; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setAddressList(String addressList) { + this.addressList = addressList; + } + + public void setServiceList(String serviceList) { + this.serviceList = serviceList; + } + + + /*public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + }*/ + + private static Log logger = LogFactory.getLog(FirewallDictionaryList.class); + + public FirewallDictionaryList() { + + } + + private static final Log auditLogger = LogFactory + .getLog("auditLogger"); + + public FirewallDictionaryList(String string, String userid) { + this(domain); + } + public FirewallDictionaryList(String domain) { + this.parentItemName = domain; + } + + /*@PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + auditLogger.debug("Added New Term Name: "+this.parentItemName+" by "+this.userCreatedBy); + + } + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy =XacmlAdminAuthorization.getUserId();; + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "TermList", "Exception caused While adding Modified by Role"); + } + auditLogger.debug("Updated Term Name: "+this.parentItemName+" by "+this.userModifiedBy); + } +*/ +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/FunctionArgument.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/FunctionArgument.java new file mode 100644 index 000000000..c660fde06 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/FunctionArgument.java @@ -0,0 +1,122 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; + +import javax.persistence.*; + + +/** + * The persistent class for the FunctionArguments database table. + * + */ +@Entity +@Table(name="FunctionArguments") +@NamedQuery(name="FunctionArgument.findAll", query="SELECT f FROM FunctionArgument f") +public class FunctionArgument implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="is_bag", nullable=false) + private int isBag; + + //bi-directional many-to-one association to FunctionDefinition + @ManyToOne + @JoinColumn(name="function_id") + private FunctionDefinition functionDefinition; + + @Column(name="arg_index", nullable=false) + private int argIndex; + + //bi-directional many-to-one association to Datatype + @ManyToOne + @JoinColumn(name="datatype_id") + private Datatype datatypeBean; + + public FunctionArgument() { + } + + public FunctionArgument(final FunctionArgument argument) { + this.argIndex = argument.argIndex; + this.datatypeBean = argument.datatypeBean; + this.isBag = argument.isBag; + this.functionDefinition = argument.functionDefinition; + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public int getArgIndex() { + return this.argIndex; + } + + public void setArgIndex(int argIndex) { + this.argIndex = argIndex; + } + + public Datatype getDatatypeBean() { + return this.datatypeBean; + } + + public void setDatatypeBean(Datatype datatypeBean) { + this.datatypeBean = datatypeBean; + } + + public FunctionDefinition getFunctionDefinition() { + return this.functionDefinition; + } + + public int getIsBag() { + return isBag; + } + + public void setIsBag(int isBag) { + this.isBag = isBag; + } + + public void setFunctionDefinition(FunctionDefinition functionDefinition) { + this.functionDefinition = functionDefinition; + } + + @Transient + @Override + public String toString() { + return "FunctionArgument [id=" + id + ", argIndex=" + argIndex + + ", datatypeBean=" + datatypeBean + ", isBag=" + isBag + + ", functionDefinition=" + functionDefinition + "]"; + } + + @Transient + public boolean isBag() { + return this.isBag == 1; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/FunctionDefinition.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/FunctionDefinition.java new file mode 100644 index 000000000..c0ccef99a --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/FunctionDefinition.java @@ -0,0 +1,219 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; + +import javax.persistence.*; + +import java.util.List; + + +/** + * The persistent class for the FunctionDefinition database table. + * + */ +@Entity +@Table(name="FunctionDefinition") +@NamedQueries({ + @NamedQuery(name="FunctionDefinition.findAll", query="SELECT f FROM FunctionDefinition f") +}) +public class FunctionDefinition implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="short_name", nullable=false, length=64) + private String shortname; + + @Column(name="xacml_id", nullable=false, length=255) + private String xacmlid; + + //bi-directional many-to-one association to Datatype + @ManyToOne + @JoinColumn(name="return_datatype", nullable=true) + private Datatype datatypeBean; + + @Column(name="is_bag_return", nullable=false) + private Integer isBagReturn; + + @Column(name="is_higher_order", nullable=false) + private Integer isHigherOrder; + + @Column(name="arg_lb", nullable=false) + private Integer argLb; + + @Column(name="arg_ub", nullable=false) + private Integer argUb; + + @Column(name="ho_arg_lb", nullable=true) + private Integer higherOrderArg_LB; + + @Column(name="ho_arg_ub", nullable=true) + private Integer higherOrderArg_UB; + + @Column(name="ho_primitive", nullable=true) + private Character higherOrderIsPrimitive; + + //bi-directional many-to-one association to FunctionArgument + @OneToMany(mappedBy="functionDefinition") + private List functionArguments; + + public FunctionDefinition() { + } + + public int getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public int getArgLb() { + return this.argLb; + } + + public void setArgLb(Integer argLb) { + this.argLb = argLb; + } + + public int getArgUb() { + return this.argUb; + } + + public void setArgUb(Integer argUb) { + this.argUb = argUb; + } + + public int getIsBagReturn() { + return isBagReturn; + } + + public void setIsBagReturn(Integer isBagReturn) { + this.isBagReturn = isBagReturn; + } + + public int getIsHigherOrder() { + return isHigherOrder; + } + + public void setIsHigherOrder(Integer isHigherOrder) { + this.isHigherOrder = isHigherOrder; + } + + public Datatype getDatatypeBean() { + return this.datatypeBean; + } + + public void setDatatypeBean(Datatype datatypeBean) { + this.datatypeBean = datatypeBean; + } + + public String getShortname() { + return this.shortname; + } + + public void setShortname(String shortname) { + this.shortname = shortname; + } + + public String getXacmlid() { + return this.xacmlid; + } + + public void setXacmlid(String xacmlid) { + this.xacmlid = xacmlid; + } + + public int getHigherOrderArg_LB() { + return higherOrderArg_LB; + } + + public void setHigherOrderArg_LB(Integer higherOrderArg_LB) { + this.higherOrderArg_LB = higherOrderArg_LB; + } + + public int getHigherOrderArg_UB() { + return higherOrderArg_UB; + } + + public void setHigherOrderArg_UB(Integer higherOrderArg_UB) { + this.higherOrderArg_UB = higherOrderArg_UB; + } + + public Character getHigherOrderIsPrimitive() { + return higherOrderIsPrimitive; + } + + public void setHigherOrderIsPrimitive(Character higherOrderIsPrimitive) { + this.higherOrderIsPrimitive = higherOrderIsPrimitive; + } + + public List getFunctionArguments() { + return this.functionArguments; + } + + public void setFunctionArguments(List functionArguments) { + this.functionArguments = functionArguments; + } + + public FunctionArgument addFunctionArgument(FunctionArgument functionArgument) { + getFunctionArguments().add(functionArgument); + functionArgument.setFunctionDefinition(this); + + return functionArgument; + } + + public FunctionArgument removeFunctionArgument(FunctionArgument functionArgument) { + getFunctionArguments().remove(functionArgument); + functionArgument.setFunctionDefinition(null); + + return functionArgument; + } + + @Transient + @Override + public String toString() { + return "FunctionDefinition [id=" + id + ", argLb=" + argLb + ", argUb=" + + argUb + ", isBagReturn=" + isBagReturn + ", isHigherOrder=" + + isHigherOrder + ", datatypeBean=" + datatypeBean + + ", shortname=" + shortname + ", xacmlid=" + xacmlid + + ", higherOrderArg_LB=" + higherOrderArg_LB + + ", higherOrderArg_UB=" + higherOrderArg_UB + + ", higherOrderIsPrimitive=" + higherOrderIsPrimitive + + ", functionArguments=" + functionArguments + "]"; + } + + @Transient + public boolean isBagReturn() { + return this.isBagReturn == 1; + } + + @Transient + public boolean isHigherOrder() { + return this.isHigherOrder == 1; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GlobalRoleSettings.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GlobalRoleSettings.java new file mode 100644 index 000000000..5b69cab32 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GlobalRoleSettings.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.Table; + + +/** + * Entity implementation class for Entity: Administration + * + */ +@Entity +@Table(name="GlobalRoleSettings") +@NamedQuery(name="GlobalRoleSettings.findAll", query="SELECT g FROM GlobalRoleSettings g") +public class GlobalRoleSettings implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @Column(name="role", length=45) + private String role; + + @Column(name="lockdown") + private boolean lockdown; + + public GlobalRoleSettings() { + super(); + } + + public GlobalRoleSettings(boolean lockdown) { + this.role = org.openecomp.policy.rest.XacmlAdminAuthorization.Role.ROLE_SUPERADMIN.toString(); + this.lockdown = lockdown; + } + + /** + * return the role + * + * @return the role + */ + public String getRole() { + return role; + } + + /** + * set role + * + * @param role the role to set + */ + public void setRole(String role) { + this.role = role; + } + + /** + * is the system locked down + * + * @return + */ + public boolean isLockdown() { + return lockdown; + } + + /** + * sets lockdown configuration + * + * @param lockdown + */ + public void setLockdown(boolean lockdown) { + this.lockdown = lockdown; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GroupEntity.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GroupEntity.java new file mode 100644 index 000000000..b3897d0ee --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GroupEntity.java @@ -0,0 +1,276 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +/* + * AT&T - PROPRIETARY + * THIS FILE CONTAINS PROPRIETARY INFORMATION OF + * AT&T AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN + * ACCORDANCE WITH APPLICABLE AGREEMENTS. + * + * Copyright (c) 2013 AT&T Knowledge Ventures + * Unpublished and Not for Publication + * All Rights Reserved + */ +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +import javax.persistence.Column; +import javax.persistence.Entity; +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.Lob; +import javax.persistence.ManyToMany; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToOne; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.UniqueConstraint; +import javax.persistence.Version; + +import com.fasterxml.jackson.annotation.JsonManagedReference; + +/* + * The Entity class to persist a policy object and its configuration data + */ + +/** + * + */ +@Entity +//Add a non-unique index and a constraint that says the combo of policyName and scopeId must be unique +@Table(name="GroupEntity") + +@NamedQueries({ + @NamedQuery(name="GroupEntity.findAll", query="SELECT e FROM GroupEntity e "), + @NamedQuery(name="GroupEntity.deleteAll", query="DELETE FROM GroupEntity WHERE 1=1") +}) + +public class GroupEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @Column (name="groupKey", nullable=false) + //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqGroup") + @GeneratedValue(strategy = GenerationType.AUTO) + private long groupKey; + + @Column (name="groupId", nullable=false) + private String groupId; + + @Column(name="groupName", nullable=false, unique=false, length=255) + private String groupName; + + @Version + @Column(name="version") + private int version; + + @ManyToMany + @JoinTable(name="PolicyGroupEntity",joinColumns={@JoinColumn(name="groupKey", referencedColumnName="groupKey")}, + inverseJoinColumns={@JoinColumn(name="policyId",referencedColumnName="policyId")}) + @JsonManagedReference + private List policies; + + @Column(name="created_by", nullable=false, length=255) + private String createdBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="description", nullable=false, length=2048) + private String description = "NoDescription"; + + @Column(name="modified_by", nullable=false, length=255) + private String modifiedBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @Column(name="defaultGroup", nullable=false) + private boolean defaultGroup = false; + @Column(name="deleted", nullable=false) + private boolean deleted = false; + + public GroupEntity() { + super(); + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + } + + /** + * @return the policyId + */ + public String getGroupId() { + return groupId; + } + public long getGroupKey(){ + return groupKey; + } + + public void setGroupId(String groupId){ + this.groupId = groupId; + } + + /** + * @param policyId cannot be set + */ + + public String getgroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public boolean isDefaultGroup(){ + return defaultGroup; + } + + public void setDefaultGroup(boolean isDefaultGroup){ + this.defaultGroup = isDefaultGroup; + } + + + + /** + * @return the configurationDataEntity + */ + public List getPolicies() { + return policies; + } + + /** + * @param configurationDataEntity the configurationDataEntity to set + */ + public void addPolicyToGroup(PolicyEntity policy) { + if(!this.policies.contains(policy)){ + this.policies.add(policy); + } + } + public void removePolicyFromGroup(PolicyEntity policy){ + this.policies.remove(policy); + } + + + + /** + * @return the createdBy + */ + public String getCreatedBy() { + return createdBy; + } + + /** + * @param createdBy the createdBy to set + */ + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * @return the modifiedBy + */ + public String getModifiedBy() { + return modifiedBy; + } + + /** + * @param modifiedBy the modifiedBy to set + */ + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + + /** + * @return the version + */ + public int getVersion() { + return version; + } + + /** + * @return the createdDate + */ + public Date getCreatedDate() { + return createdDate; + } + + /** + * @return the modifiedDate + */ + public Date getModifiedDate() { + return modifiedDate; + } + + /** + * @return the deleted + */ + public boolean isDeleted() { + return deleted; + } + + /** + * @param deleted the deleted to set + */ + public void setDeleted(boolean deleted) { + this.deleted = deleted; + } + + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GroupPolicyScopeList.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GroupPolicyScopeList.java new file mode 100644 index 000000000..c57d1475a --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GroupPolicyScopeList.java @@ -0,0 +1,114 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + + +@Entity +@Table(name="GroupPolicyScopeList") +@NamedQuery(name="GroupPolicyScopeList.findAll", query="SELECT e FROM GroupPolicyScopeList e ") +public class GroupPolicyScopeList implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="groupList") + private String groupList; + + @Column(name="description") + private String description; + + public GroupPolicyScopeList() { + + } + public GroupPolicyScopeList(String string, String userid) { + this(domain); + + } + public GroupPolicyScopeList(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getGroupName() { + return this.name; + } + + public void setGroupName(String serviceName) { + this.name = serviceName; + + } + + public String getGroupList() { + return this.groupList; + } + + public void setGroupList(String groupList) { + this.groupList = groupList; + + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GroupServiceList.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GroupServiceList.java new file mode 100644 index 000000000..b5fbd9355 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GroupServiceList.java @@ -0,0 +1,107 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + + +@Entity +@Table(name="GroupServiceList") +@NamedQuery(name="GroupServiceList.findAll", query="SELECT e FROM GroupServiceList e ") +public class GroupServiceList implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="serviceList ") + private String serviceList; + + + public GroupServiceList() { + + } + public GroupServiceList(String string, String userid) { + this(domain); + + } + public GroupServiceList(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getGroupName() { + return this.name; + } + + public void setGroupName(String serviceName) { + this.name = serviceName; + + } + + public String getServiceList() { + return this.serviceList; + } + + public void setServiceList(String serviceList) { + this.serviceList = serviceList; + + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/MicroServiceConfigName.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/MicroServiceConfigName.java new file mode 100644 index 000000000..594cacf33 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/MicroServiceConfigName.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + + +@Entity +@Table(name="MicroServiceConfigName") +@NamedQuery(name="MicroServiceConfigName.findAll", query="SELECT e FROM MicroServiceConfigName e ") +public class MicroServiceConfigName implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="description ") + private String description ; + + + public MicroServiceConfigName() { + + } + public MicroServiceConfigName(String string, String userid) { + this(domain); + + } + public MicroServiceConfigName(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + + } + public String getDescriptionValue() { + return this.description ; + } + + public void setDescriptionValue(String description ) { + this.description = description ; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/MicroServiceLocation.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/MicroServiceLocation.java new file mode 100644 index 000000000..8532f81a1 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/MicroServiceLocation.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + + +@Entity +@Table(name="MicroServiceLocation") +@NamedQuery(name="MicroServiceLocation.findAll", query="SELECT e FROM MicroServiceLocation e ") +public class MicroServiceLocation implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="description ") + private String description ; + + + public MicroServiceLocation() { + + } + public MicroServiceLocation(String string, String userid) { + this(domain); + + } + public MicroServiceLocation(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + + } + public String getDescriptionValue() { + return this.description ; + } + + public void setDescriptionValue(String description ) { + this.description = description ; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/MicroServiceModels.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/MicroServiceModels.java new file mode 100644 index 000000000..ca7460640 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/MicroServiceModels.java @@ -0,0 +1,172 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +/* + * AT&T - PROPRIETARY + * THIS FILE CONTAINS PROPRIETARY INFORMATION OF + * AT&T AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN + * ACCORDANCE WITH APPLICABLE AGREEMENTS. + * + * Copyright (c) 2015 AT&T Knowledge Ventures + * Unpublished and Not for Publication + * All Rights Reserved + */ +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.Table; +/* + * JPA for the Micro Service Models. + * + * @version: 0.1 + */ +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.openecomp.policy.rest.jpa.UserInfo; + + +@Entity +@Table(name="MicroServiceModels") +@NamedQuery(name="MicroServiceModels.findAll", query="SELECT b FROM MicroServiceModels b ") +public class MicroServiceModels implements Serializable{ + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="modelName", nullable=false, unique=true) + @OrderBy("asc") + private String modelName; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Column(name="dependency", nullable=true, length=2048) + private String dependency; + + @Column(name="attributes", nullable=false, length=255) + private String attributes; + + @Column(name="ref_attributes", nullable=false, length=255) + private String ref_attributes; + + @Column (name="sub_attributes", nullable=false, length=2000) + private String sub_attributes; + + @Column (name="version", nullable=false, length=2000) + private String version; + + public String getSub_attributes() { + return sub_attributes; + } + + public void setSub_attributes(String sub_attributes) { + this.sub_attributes = sub_attributes; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @ManyToOne + @JoinColumn(name="imported_by") + private UserInfo userCreatedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public MicroServiceModels(){ + } + + public MicroServiceModels(String userid){ + + } + + public String getAttributes() { + return attributes; + } + + public void setAttributes(String attributes) { + this.attributes = attributes; + } + + public String getRef_attributes() { + return ref_attributes; + } + + public void setRef_attributes(String ref_attributes) { + this.ref_attributes = ref_attributes; + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDependency() { + return dependency; + } + + public void setDependency(String dependency) { + this.dependency = dependency; + } + + public String getModelName(){ + return this.modelName; + } + + public void setModelName(String modelName){ + this.modelName = modelName; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Obadvice.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Obadvice.java new file mode 100644 index 000000000..f26fc9d95 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Obadvice.java @@ -0,0 +1,227 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; + +import com.att.research.xacml.api.Identifier; + +/** + * The persistent class for the Obadvice database table. + * + */ +@Entity +@Table(name="Obadvice") +@NamedQuery(name="Obadvice.findAll", query="SELECT o FROM Obadvice o") +public class Obadvice implements Serializable { + private static final long serialVersionUID = 1L; + + public static final String OBLIGATION = "Obligation"; + public static final String ADVICE = "Advice"; + public static final String EFFECT_PERMIT = "Permit"; + public static final String EFFECT_DENY = "Deny"; + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="type", nullable=false) + private String type; + + @Column(name="xacml_id", nullable=false, length=255) + private String xacmlId; + + @Column(name="fulfill_on", nullable=true, length=32) + private String fulfillOn; + + @Column(name="description", nullable=true, length=2048) + private String description; + + //bi-directional one-to-many association to Attribute Assignment + @OneToMany(mappedBy="obadvice", orphanRemoval=true, cascade=CascadeType.REMOVE) + private Set obadviceExpressions = new HashSet(2); + + @Column(name="created_by", nullable=false, length=255) + private String createdBy; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", nullable=false, updatable=false) + private Date createdDate; + + @Column(name="modified_by", nullable=false, length=255) + private String modifiedBy; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + public Obadvice() { + this.type = Obadvice.OBLIGATION; + this.fulfillOn = Obadvice.EFFECT_PERMIT; + } + + public Obadvice(String domain, String userid) { + this.xacmlId = domain; + this.type = Obadvice.OBLIGATION; + this.fulfillOn = Obadvice.EFFECT_PERMIT; + this.createdBy = userid; + this.modifiedBy = userid; + } + + public Obadvice(Identifier id, String userid) { + this(id.stringValue(), userid); + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getCreatedBy() { + return this.createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getFulfillOn() { + return this.fulfillOn; + } + + public void setFulfillOn(String fulfillOn) { + this.fulfillOn = fulfillOn; + } + + public String getModifiedBy() { + return this.modifiedBy; + } + + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; + } + + public String getXacmlId() { + return this.xacmlId; + } + + public void setXacmlId(String xacmlId) { + this.xacmlId = xacmlId; + } + + public Set getObadviceExpressions() { + return this.obadviceExpressions; + } + + public void setObadviceExpressions(Set obadviceExpressions) { + this.obadviceExpressions = obadviceExpressions; + } + + public ObadviceExpression addObadviceExpression(ObadviceExpression obadviceExpression) { + this.obadviceExpressions.add(obadviceExpression); + obadviceExpression.setObadvice(this); + + return obadviceExpression; + } + + public ObadviceExpression removeObadviceExpression(ObadviceExpression obadviceExpression) { + this.obadviceExpressions.remove(obadviceExpression); + obadviceExpression.setObadvice(null); + + return obadviceExpression; + } + + public void removeAllExpressions() { + if (this.obadviceExpressions == null) { + return; + } + for (ObadviceExpression expression : this.obadviceExpressions) { + expression.setObadvice(null); + } + this.obadviceExpressions.clear(); + } + + @Transient + public Obadvice clone() { + Obadvice obadvice = new Obadvice(); + + obadvice.type = this.type; + obadvice.xacmlId = this.xacmlId; + obadvice.fulfillOn = this.fulfillOn; + obadvice.description = this.description; + obadvice.createdBy = this.createdBy; + obadvice.modifiedBy = this.modifiedBy; + for (ObadviceExpression exp: this.obadviceExpressions) { + obadvice.addObadviceExpression(exp.clone()); + } + + return obadvice; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ObadviceExpression.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ObadviceExpression.java new file mode 100644 index 000000000..28957fa85 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ObadviceExpression.java @@ -0,0 +1,126 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +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.JoinColumn; +import javax.persistence.Lob; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OneToOne; +import javax.persistence.Table; + +import org.openecomp.policy.rest.jpa.Attribute; + + +/** + * The persistent class for the ObadviceExpressions database table. + * + */ +@Entity +@Table(name="ObadviceExpressions") +@NamedQuery(name="ObadviceExpression.findAll", query="SELECT o FROM ObadviceExpression o") +public class ObadviceExpression implements Serializable { + private static final long serialVersionUID = 1L; + + public static final String EXPRESSION_APPLY = "Apply"; + public static final String EXPRESSION_SELECTOR = "Attribute Selector"; + public static final String EXPRESSION_VALUE = "Attribute Value"; + public static final String EXPRESSION_FUNCTION = "Function"; + public static final String EXPRESSION_REFERENCE = "Varable Reference"; + public static final String EXPRESSION_DESIGNATOR = "Attribute Designator"; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + //unidirectional one-to-one association to Attribute + @OneToOne + @JoinColumn(name="attribute_id") + private Attribute attribute; + + @Column(name="type", nullable=false) + private String type; + + /* + @Lob + @Column(name="expression", nullable=false) + private byte[] expression; + */ + + //bi-directional many-to-one association to Obadvice + @ManyToOne + @JoinColumn(name="obadvice_id") + private Obadvice obadvice; + + public ObadviceExpression() { + type = EXPRESSION_VALUE; + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public Attribute getAttribute() { + return this.attribute; + } + + public void setAttribute(Attribute attribute) { + this.attribute = attribute; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; + } + + public Obadvice getObadvice() { + return this.obadvice; + } + + public void setObadvice(Obadvice obadvice) { + this.obadvice = obadvice; + } + + public ObadviceExpression clone() { + ObadviceExpression expression = new ObadviceExpression(); + + expression.attribute = this.attribute; + expression.type = this.type; + expression.obadvice = this.obadvice; + + return expression; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PEPOptions.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PEPOptions.java new file mode 100644 index 000000000..8b05e8ffc --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PEPOptions.java @@ -0,0 +1,184 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + * + * */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + +@Entity +@Table(name = "PEPOptions") +@NamedQuery(name = "PEPOptions.findAll", query= "Select p from PEPOptions p") +public class PEPOptions implements Serializable { + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "Id") + private int id; + + @Column(name="PEP_NAME", nullable=false) + @OrderBy("asc") + private String pepName; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Column(name="Actions", nullable=true) + @OrderBy("asc") + private String actions; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(PEPOptions.class); + + public PEPOptions(){ + + } + + public PEPOptions(String string, String userid) { + this(string); + } + + public PEPOptions(String domain) { + this.pepName = domain; + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy =XacmlAdminAuthorization.getUserId();; + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PEPOptions", "Exception caused While adding Modified by Role"); + } + } + + public int getId() { + return this.id; + } + public void setId(int id) { + this.id = id; + } + + public String getPepName() { + return pepName; + } + + public void setPepName(String pepName) { + this.pepName = pepName; + } + + public String getActions() { + return actions; + } + + public void setActions(String actions) { + this.actions = actions; + } + + public Date getCreatedDate() { + return this.createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getModifiedDate() { + return this.modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPConfigParam.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPConfigParam.java new file mode 100644 index 000000000..d3724363f --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPConfigParam.java @@ -0,0 +1,147 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; + +import javax.persistence.*; + + +/** + * The persistent class for the PIPConfigParams database table. + * + */ +@Entity +@Table(name="PIPConfigParams") +@NamedQuery(name="PIPConfigParam.findAll", query="SELECT p FROM PIPConfigParam p") +public class PIPConfigParam implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="PARAM_NAME", nullable=false, length=1024) + private String paramName; + + @Column(name="PARAM_VALUE", nullable=false, length=2048) + private String paramValue; + + @Column(name="PARAM_DEFAULT", nullable=true, length=2048) + private String paramDefault = null; + + @Column(name="REQUIRED", nullable=false) + private char required = '0'; + + //bi-directional many-to-one association to PIPConfiguration + @ManyToOne + @JoinColumn(name="PIP_ID") + private PIPConfiguration pipconfiguration; + + public PIPConfigParam() { + } + + public PIPConfigParam(String param) { + this.paramName = param; + } + + public PIPConfigParam(String param, String value) { + this(param); + this.paramValue = value; + } + + public PIPConfigParam(PIPConfigParam param) { + this(param.getParamName(), param.getParamValue()); + this.paramDefault = param.getParamDefault(); + this.required = param.required; + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getParamName() { + return this.paramName; + } + + public void setParamName(String paramName) { + this.paramName = paramName; + } + + public String getParamValue() { + return this.paramValue; + } + + public void setParamValue(String paramValue) { + this.paramValue = paramValue; + } + + public String getParamDefault() { + return paramDefault; + } + + public void setParamDefault(String paramDefault) { + this.paramDefault = paramDefault; + } + + public char getRequired() { + return required; + } + + public void setRequired(char required) { + this.required = required; + } + + public PIPConfiguration getPipconfiguration() { + return this.pipconfiguration; + } + + public void setPipconfiguration(PIPConfiguration pipconfiguration) { + this.pipconfiguration = pipconfiguration; + } + + @Transient + public boolean isRequired() { + return (this.required == '1'); + } + + @Transient + public void setRequired(boolean required) { + if (required) { + this.setRequired('1'); + } else { + this.setRequired('0'); + } + } + + @Transient + @Override + public String toString() { + return "PIPConfigParam [id=" + id + ", paramName=" + paramName + + ", paramValue=" + paramValue + ", required=" + required + "]"; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPConfiguration.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPConfiguration.java new file mode 100644 index 000000000..8f75bef89 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPConfiguration.java @@ -0,0 +1,572 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.openecomp.policy.xacml.api.XACMLErrorConstants; +import com.att.research.xacml.api.pip.PIPException; +import com.att.research.xacml.std.pip.engines.StdConfigurableEngine; +import com.att.research.xacml.std.pip.engines.csv.CSVEngine; +import com.att.research.xacml.std.pip.engines.csv.HyperCSVEngine; +import com.att.research.xacml.std.pip.engines.jdbc.JDBCEngine; +import com.att.research.xacml.std.pip.engines.ldap.LDAPEngine; +import com.att.research.xacml.util.XACMLProperties; +import com.google.common.base.Joiner; +import com.google.common.base.Splitter; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + +/** + * The persistent class for the PIPConfiguration database table. + * + */ +@Entity +@Table(name="PIPConfiguration") +@NamedQuery(name="PIPConfiguration.findAll", query="SELECT p FROM PIPConfiguration p") +public class PIPConfiguration implements Serializable { + private static final long serialVersionUID = 1L; + private static final Log logger = LogFactory.getLog(PIPConfiguration.class); + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="DESCRIPTION", nullable=true, length=2048) + private String description; + + @Column(name="NAME", nullable=false, length=255) + private String name; + + @Column(name="CLASSNAME", nullable=false, length=2048) + private String classname; + + @Column(name="ISSUER", nullable=true, length=1024) + private String issuer; + + @Column(name="READ_ONLY", nullable=false) + private char readOnly = '0'; + + @Column(name="REQUIRES_RESOLVER", nullable=false) + private char requiresResolvers; + + @Column(name="CREATED_BY", nullable=false, length=255) + private String createdBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="CREATED_DATE", nullable=false, updatable=false) + private Date createdDate; + + @Column(name="MODIFIED_BY", nullable=false, length=255) + private String modifiedBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="MODIFIED_DATE", nullable=false) + private Date modifiedDate; + + //bi-directional many-to-one association to PIPConfigParam + @OneToMany(mappedBy="pipconfiguration", orphanRemoval=true, cascade=CascadeType.REMOVE) + private Set pipconfigParams = new HashSet(); + + //bi-directional many-to-one association to PIPType + @ManyToOne + @JoinColumn(name="TYPE") + private PIPType piptype; + + //bi-directional many-to-one association to PIPResolver + @OneToMany(mappedBy="pipconfiguration", orphanRemoval=true, cascade=CascadeType.REMOVE) + private Set pipresolvers = new HashSet(); + + public PIPConfiguration() { + } + + public PIPConfiguration(PIPConfiguration config, String user) { + this.description = config.description; + this.name = config.name; + this.classname = config.classname; + this.issuer = config.issuer; + this.requiresResolvers = config.requiresResolvers; + this.readOnly = config.readOnly; + this.piptype = config.piptype; + for (PIPConfigParam param : config.pipconfigParams) { + this.addPipconfigParam(new PIPConfigParam(param)); + } + for (PIPResolver resolver : config.pipresolvers) { + this.addPipresolver(new PIPResolver(resolver)); + } + } + + public PIPConfiguration(String id, Properties properties) throws PIPException { + this.readProperties(id, properties); + } + + public PIPConfiguration(String id, Properties properties, String user) throws PIPException { + this.createdBy = user; + this.modifiedBy = user; + this.readProperties(id, properties); + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public String getClassname() { + return classname; + } + + public void setClassname(String classname) { + this.classname = classname; + } + + public String getIssuer() { + return issuer; + } + + public void setIssuer(String issuer) { + this.issuer = issuer; + } + + public char getReadOnly() { + return readOnly; + } + + public void setReadOnly(char readOnly) { + this.readOnly = readOnly; + } + + public char getRequiresResolvers() { + return requiresResolvers; + } + + public void setRequiresResolvers(char requireResolvers) { + this.requiresResolvers = requireResolvers; + } + + public Set getPipconfigParams() { + return this.pipconfigParams; + } + + public void setPipconfigParams(Set pipconfigParams) { + this.pipconfigParams = pipconfigParams; + } + + public PIPConfigParam addPipconfigParam(PIPConfigParam pipconfigParam) { + getPipconfigParams().add(pipconfigParam); + pipconfigParam.setPipconfiguration(this); + + return pipconfigParam; + } + + public PIPConfigParam removePipconfigParam(PIPConfigParam pipconfigParam) { + if (pipconfigParam == null) { + return pipconfigParam; + } + getPipconfigParams().remove(pipconfigParam); + pipconfigParam.setPipconfiguration(null); + + return pipconfigParam; + } + + @Transient + public void clearConfigParams() { + while (this.pipconfigParams.isEmpty() == false) { + this.removePipconfigParam(this.pipconfigParams.iterator().next()); + } + } + + public PIPType getPiptype() { + return this.piptype; + } + + public void setPiptype(PIPType piptype) { + this.piptype = piptype; + } + + public Set getPipresolvers() { + return this.pipresolvers; + } + + public void setPipresolvers(Set pipresolvers) { + this.pipresolvers = pipresolvers; + } + + public PIPResolver addPipresolver(PIPResolver pipresolver) { + getPipresolvers().add(pipresolver); + pipresolver.setPipconfiguration(this); + + return pipresolver; + } + + public PIPResolver removePipresolver(PIPResolver pipresolver) { + getPipresolvers().remove(pipresolver); + pipresolver.setPipconfiguration(null); + + return pipresolver; + } + + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public Date getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getModifiedBy() { + return modifiedBy; + } + + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + + public Date getModifiedDate() { + return modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + + @Transient + public boolean isReadOnly() { + return (this.readOnly == '1'); + } + + @Transient + public void setReadOnly(boolean readOnly) { + if (readOnly) { + this.readOnly = '1'; + } else { + this.readOnly = '0'; + } + } + + @Transient + public boolean requiresResolvers() { + return (this.requiresResolvers == '1'); + } + + @Transient + public void setRequiresResolvers(boolean requires) { + if (requires) { + this.requiresResolvers = '1'; + } else { + this.requiresResolvers = '0'; + } + } + + @Transient + public static Collection importPIPConfigurations(Properties properties) { + Collection configurations = new ArrayList(); + String engines = properties.getProperty(XACMLProperties.PROP_PIP_ENGINES); + if (engines == null || engines.isEmpty()) { + return configurations; + } + for (String id : Splitter.on(',').trimResults().omitEmptyStrings().split(engines)) { + PIPConfiguration configuration; + try { + String user = "super-admin"; + //TODO + //String user = ((XacmlAdminUI)UI.getCurrent()).getUserid(); + configuration = new PIPConfiguration(id, properties, user); + configuration.setCreatedBy(user); + configuration.setModifiedBy(user); + configurations.add(configuration); + } catch (PIPException e) { + logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Import failed: " + e.getLocalizedMessage()); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PIPConfiguration", "Import failed"); + } + } + + return configurations; + } + + @Transient + protected void readProperties(String id, Properties properties) throws PIPException { + // + // Save the id if we don't have one already + // + + if (this.id == 0) { + try { + this.id = Integer.parseInt(id); + } catch (NumberFormatException e) { + logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Convert id to integer failed: " + id); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PIPConfiguration", "Convert id to integer failed"); + } + } + // + // Get its classname, this MUST exist. + // + this.classname = properties.getProperty(id + ".classname"); + if (this.classname == null) { + throw new PIPException("PIP Engine defined without a classname"); + } + // + // These classes we know for sure require resolvers. + // + //TODO: Commented out due to JPAUtils class & As of now we are not using PIP. So, it will not impact any Errors + /*if (this.classname.equals(JDBCEngine.class.getCanonicalName())) { + this.setRequiresResolvers(true); + this.setPiptype(JPAUtils.getPIPType(PIPType.TYPE_SQL)); + } else if (this.classname.equals(LDAPEngine.class.getCanonicalName())) { + this.setRequiresResolvers(true); + this.setPiptype(JPAUtils.getPIPType(PIPType.TYPE_LDAP)); + } else if (this.classname.equals(HyperCSVEngine.class.getCanonicalName())) { + this.setRequiresResolvers(true); + this.setPiptype(JPAUtils.getPIPType(PIPType.TYPE_HYPERCSV)); + } else if (this.classname.equals(CSVEngine.class.getCanonicalName())) { + this.setRequiresResolvers(true); + this.setPiptype(JPAUtils.getPIPType(PIPType.TYPE_CSV)); + } else { + // + // Assume it does not require resolvers for now, if we encounter + // one then we will change it. The user can always change it via the gui. + // + this.setRequiresResolvers(false); + this.setPiptype(JPAUtils.getPIPType(PIPType.TYPE_CUSTOM)); + }*/ + // + // Go through each property + // + for (Object name : properties.keySet()) { + if (name.toString().startsWith(id) == false) { + continue; + } + if (name.equals(id + ".classname")) { + // + // We already saved this + // + } else if (name.equals(id + "." + StdConfigurableEngine.PROP_NAME)) { + this.name = properties.getProperty(name.toString()); + } else if (name.equals(id + "." + StdConfigurableEngine.PROP_DESCRIPTION)) { + this.description = properties.getProperty(name.toString()); + } else if (name.equals(id + "." + StdConfigurableEngine.PROP_ISSUER)) { + this.issuer = properties.getProperty(name.toString()); + } else if (name.equals(id + ".resolvers")) { + // + // It has resolvers, make sure this is set to true if + // it has been already. + // + this.setRequiresResolvers(true); + // + // Parse the resolvers + // + Collection resolvers = PIPResolver.importResolvers(id + ".resolver", + properties.getProperty(name.toString()), + properties,"super-admin" + ); + //TODO: replace with UserId + //((XacmlAdminUI)UI.getCurrent()).getUserid() + for (PIPResolver resolver : resolvers) { + this.addPipresolver(resolver); + } + } else if (name.toString().startsWith(id + ".resolver")) { + // + // Ignore, the PIPResolver will parse these values + // + } else { + // + // Config Parameter + // + this.addPipconfigParam(new PIPConfigParam(name.toString().substring(id.length() + 1), + properties.getProperty(name.toString()))); + } + } + // + // Make sure we have a name at least + // + if (this.name == null) { + this.name = id; + } + } + + + @Transient + public Map getConfiguration(String name) { + String prefix; + if (name == null) { + prefix = Integer.toString(this.id); + } else { + prefix = name; + } + if (prefix.endsWith(".") == false) { + prefix = prefix + "."; + } + Map map = new HashMap(); + map.put(prefix + "classname", this.classname); + map.put(prefix + "name", this.name); + if (this.description != null) { + map.put(prefix + "description", this.description); + } + if (this.issuer != null) { + map.put(prefix + "issuer", this.issuer); + } + + for (PIPConfigParam param : this.pipconfigParams) { + map.put(prefix + param.getParamName(), param.getParamValue()); + } + + List ids = new ArrayList(); + Iterator iter = this.pipresolvers.iterator(); + while (iter.hasNext()) { + PIPResolver resolver = iter.next(); + String id = Integer.toString(resolver.getId()); + Map resolverMap = resolver.getConfiguration(prefix + "resolver." + id); + map.putAll(resolverMap); + ids.add(id); + } + if (ids.size() > 0) { + map.put(prefix + "resolvers", Joiner.on(',').join(ids)); + } + return map; + } + + @Transient + public Properties generateProperties(String name) { + String prefix; + if (name == null) { + prefix = Integer.toString(this.id); + } else { + if (name.endsWith(".")) { + prefix = name; + } else { + prefix = name + "."; + } + } + Properties props = new Properties(); + props.setProperty("xacml.pip.engines", name); + props.setProperty(prefix + "classname", this.classname); + props.setProperty(prefix + "name", this.name); + if (this.description != null) { + props.setProperty(prefix + "description", this.description); + } + if (this.issuer != null && this.issuer.isEmpty() == false) { + props.setProperty(prefix + "issuer", this.issuer); + } + + for (PIPConfigParam param : this.pipconfigParams) { + props.setProperty(prefix + param.getParamName(), param.getParamValue()); + } + + List ids = new ArrayList(); + Iterator iter = this.pipresolvers.iterator(); + while (iter.hasNext()) { + PIPResolver resolver = iter.next(); + String id = Integer.toString(resolver.getId()); + resolver.generateProperties(props, prefix + "resolver." + id); + ids.add(id); + } + if (ids.size() > 0) { + props.setProperty(prefix + "resolvers", Joiner.on(',').join(ids)); + } + return props; + } + + @Transient + @Override + public String toString() { + return "PIPConfiguration [id=" + id + ", piptype=" + piptype + + ", classname=" + classname + ", name=" + name + + ", description=" + description + ", issuer=" + issuer + + ", readOnly=" + readOnly + ", requiresResolvers=" + + requiresResolvers + ", createdBy=" + createdBy + + ", createdDate=" + createdDate + ", modifiedBy=" + modifiedBy + + ", modifiedDate=" + modifiedDate + ", pipconfigParams=" + + pipconfigParams + ", pipresolvers=" + pipresolvers + "]"; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPResolver.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPResolver.java new file mode 100644 index 000000000..634ff3e63 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPResolver.java @@ -0,0 +1,365 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; + +import com.att.research.xacml.api.pip.PIPException; +import com.att.research.xacml.std.pip.engines.StdConfigurableEngine; +import com.google.common.base.Splitter; + + +/** + * The persistent class for the PIPResolver database table. + * + */ +@Entity +@Table(name="PIPResolver") +@NamedQuery(name="PIPResolver.findAll", query="SELECT p FROM PIPResolver p") +public class PIPResolver implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="DESCRIPTION", nullable=true, length=2048) + private String description; + + @Column(name="NAME", nullable=false, length=255) + private String name; + + @Column(name="ISSUER", nullable=true, length=1024) + private String issuer; + + @Column(name="CLASSNAME", nullable=false, length=2048) + private String classname; + + @Column(name="READ_ONLY", nullable=false) + private char readOnly = '0'; + + @Column(name="CREATED_BY", nullable=false, length=255) + private String createdBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="CREATED_DATE", nullable=false, updatable=false) + private Date createdDate; + + @Column(name="MODIFIED_BY", nullable=false, length=255) + private String modifiedBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="MODIFIED_DATE", nullable=false) + private Date modifiedDate; + + //bi-directional many-to-one association to PIPConfiguration + @ManyToOne + @JoinColumn(name="PIP_ID") + private PIPConfiguration pipconfiguration; + + //bi-directional many-to-one association to PIPResolverParam + @OneToMany(mappedBy="pipresolver", orphanRemoval=true, cascade=CascadeType.REMOVE) + private Set pipresolverParams = new HashSet(); + + public PIPResolver() { + } + + public PIPResolver(String prefix, Properties properties, String user) throws PIPException { + this.createdBy = user; + this.modifiedBy = user; + this.readOnly = '0'; + this.readProperties(prefix, properties); + } + + public PIPResolver(PIPResolver resolver) { + this.name = resolver.name; + this.description = resolver.description; + this.issuer = resolver.issuer; + this.classname = resolver.classname; + this.readOnly = resolver.readOnly; + for (PIPResolverParam param : this.pipresolverParams) { + this.addPipresolverParam(new PIPResolverParam(param)); + } + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public String getIssuer() { + return issuer; + } + + public void setIssuer(String issuer) { + this.issuer = issuer; + } + + public String getClassname() { + return classname; + } + + public void setClassname(String classname) { + this.classname = classname; + } + + public char getReadOnly() { + return readOnly; + } + + public void setReadOnly(char readOnly) { + this.readOnly = readOnly; + } + + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public Date getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getModifiedBy() { + return modifiedBy; + } + + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + + public Date getModifiedDate() { + return modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + + public PIPConfiguration getPipconfiguration() { + return this.pipconfiguration; + } + + public void setPipconfiguration(PIPConfiguration pipconfiguration) { + this.pipconfiguration = pipconfiguration; + } + + public Set getPipresolverParams() { + return this.pipresolverParams; + } + + public void setPipresolverParams(Set pipresolverParams) { + this.pipresolverParams = pipresolverParams; + } + + public PIPResolverParam addPipresolverParam(PIPResolverParam pipresolverParam) { + getPipresolverParams().add(pipresolverParam); + pipresolverParam.setPipresolver(this); + + return pipresolverParam; + } + + public PIPResolverParam removePipresolverParam(PIPResolverParam pipresolverParam) { + if (pipresolverParam == null) { + return pipresolverParam; + } + getPipresolverParams().remove(pipresolverParam); + pipresolverParam.setPipresolver(null); + + return pipresolverParam; + } + + @Transient + public void clearParams() { + while (this.pipresolverParams.isEmpty() == false) { + this.removePipresolverParam(this.pipresolverParams.iterator().next()); + } + } + + @Transient + public boolean isReadOnly() { + return (this.readOnly == '1'); + } + + @Transient + public void setReadOnly(boolean readOnly) { + if (readOnly) { + this.readOnly = '1'; + } else { + this.readOnly = '0'; + } + } + + @Transient + public static Collection importResolvers(String prefix, String list, Properties properties, String user) throws PIPException { + Collection resolvers = new ArrayList(); + for (String id : Splitter.on(',').trimResults().omitEmptyStrings().split(list)) { + resolvers.add(new PIPResolver(prefix + "." + id, properties, user)); + } + return resolvers; + } + + @Transient + protected void readProperties(String prefix, Properties properties) throws PIPException { + // + // Get its classname, this MUST exist. + // + this.classname = properties.getProperty(prefix + ".classname"); + if (this.classname == null) { + throw new PIPException("PIP Engine defined without a classname"); + } + // + // Go through each property + // + for (Object name : properties.keySet()) { + if (name.toString().startsWith(prefix) == false) { + continue; + } + if (name.equals(prefix + ".classname")) { + // + // We already saved this + // + } else if (name.equals(prefix + "." + StdConfigurableEngine.PROP_NAME)) { + this.name = properties.getProperty(name.toString()); + } else if (name.equals(prefix + "." + StdConfigurableEngine.PROP_DESCRIPTION)) { + this.description = properties.getProperty(name.toString()); + } else if (name.equals(prefix + "." + StdConfigurableEngine.PROP_ISSUER)) { + this.issuer = properties.getProperty(name.toString()); + } else { + this.addPipresolverParam(new PIPResolverParam(name.toString().substring(prefix.length() + 1), + properties.getProperty(name.toString()))); + } + } + } + + @Transient + public Map getConfiguration(String prefix) { + Map map = new HashMap(); + if (prefix.endsWith(".") == false) { + prefix = prefix + "."; + } + map.put(prefix + "classname", this.classname); + map.put(prefix + "name", this.name); + if (this.description != null) { + map.put(prefix + "description", this.description); + } + if (this.issuer != null && this.issuer.isEmpty() != false) { + map.put(prefix + "issuer", this.issuer); + } + for (PIPResolverParam param : this.pipresolverParams) { + map.put(prefix + param.getParamName(), param.getParamValue()); + } + return map; + } + + @Transient + public void generateProperties(Properties props, String prefix) { + if (prefix.endsWith(".") == false) { + prefix = prefix + "."; + } + props.setProperty(prefix + "classname", this.classname); + props.setProperty(prefix + "name", this.name); + if (this.description != null) { + props.setProperty(prefix + "description", this.description); + } + if (this.issuer != null && this.issuer.isEmpty() != false) { + props.setProperty(prefix + "issuer", this.issuer); + } + for (PIPResolverParam param : this.pipresolverParams) { + props.setProperty(prefix + param.getParamName(), param.getParamValue()); + } + } + + @Transient + @Override + public String toString() { + return "PIPResolver [id=" + id + ", classname=" + classname + ", name=" + + name + ", description=" + description + ", issuer=" + issuer + + ", readOnly=" + readOnly + ", createdBy=" + createdBy + + ", createdDate=" + createdDate + ", modifiedBy=" + modifiedBy + + ", modifiedDate=" + modifiedDate + ", pipresolverParams=" + + pipresolverParams + "]"; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPResolverParam.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPResolverParam.java new file mode 100644 index 000000000..957b105d1 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPResolverParam.java @@ -0,0 +1,147 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; + +import javax.persistence.*; + + +/** + * The persistent class for the PIPResolverParams database table. + * + */ +@Entity +@Table(name="PIPResolverParams") +@NamedQuery(name="PIPResolverParam.findAll", query="SELECT p FROM PIPResolverParam p") +public class PIPResolverParam implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="PARAM_NAME", nullable=false, length=1024) + private String paramName; + + @Column(name="PARAM_VALUE", nullable=false, length=2048) + private String paramValue; + + @Column(name="PARAM_DEFAULT", nullable=true, length=2048) + private String paramDefault; + + @Column(name="REQUIRED", nullable=false) + private char required = '0'; + + //bi-directional many-to-one association to PIPResolver + @ManyToOne + @JoinColumn(name="ID_RESOLVER") + private PIPResolver pipresolver; + + public PIPResolverParam() { + } + + public PIPResolverParam(String name) { + this.paramName = name; + } + + public PIPResolverParam(String name, String value) { + this(name); + this.paramValue = value; + } + + public PIPResolverParam(PIPResolverParam param) { + this(param.getParamName(), param.getParamValue()); + this.paramDefault = param.getParamDefault(); + this.required = param.required; + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getParamName() { + return this.paramName; + } + + public void setParamName(String paramName) { + this.paramName = paramName; + } + + public String getParamValue() { + return this.paramValue; + } + + public void setParamValue(String paramValue) { + this.paramValue = paramValue; + } + + public String getParamDefault() { + return paramDefault; + } + + public void setParamDefault(String paramDefault) { + this.paramDefault = paramDefault; + } + + public char getRequired() { + return required; + } + + public void setRequired(char required) { + this.required = required; + } + + public PIPResolver getPipresolver() { + return this.pipresolver; + } + + public void setPipresolver(PIPResolver pipresolver) { + this.pipresolver = pipresolver; + } + + @Transient + public boolean isRequired() { + return this.required == '1'; + } + + @Transient + public void setRequired(boolean required) { + if (required) { + this.required = '1'; + } else { + this.required = '0'; + } + } + + @Transient + @Override + public String toString() { + return "PIPResolverParam [id=" + id + ", paramName=" + paramName + + ", paramValue=" + paramValue + ", required=" + required + "]"; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPType.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPType.java new file mode 100644 index 000000000..964a15412 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPType.java @@ -0,0 +1,131 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Set; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.persistence.Transient; + + +/** + * The persistent class for the PIPType database table. + * + */ +@Entity +@Table(name="PIPType") +@NamedQuery(name="PIPType.findAll", query="SELECT p FROM PIPType p") +public class PIPType implements Serializable { + private static final long serialVersionUID = 1L; + + public static final String TYPE_SQL = "SQL"; + public static final String TYPE_LDAP = "LDAP"; + public static final String TYPE_CSV = "CSV"; + public static final String TYPE_HYPERCSV = "Hyper-CSV"; + public static final String TYPE_CUSTOM = "Custom"; + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="type", nullable=false, length=45) + private String type; + + //bi-directional many-to-one association to PIPConfiguration + @OneToMany(mappedBy="piptype") + private Set pipconfigurations; + + public PIPType() { + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; + } + + public Set getPipconfigurations() { + return this.pipconfigurations; + } + + public void setPipconfigurations(Set pipconfigurations) { + this.pipconfigurations = pipconfigurations; + } + + public PIPConfiguration addPipconfiguration(PIPConfiguration pipconfiguration) { + getPipconfigurations().add(pipconfiguration); + pipconfiguration.setPiptype(this); + + return pipconfiguration; + } + + public PIPConfiguration removePipconfiguration(PIPConfiguration pipconfiguration) { + getPipconfigurations().remove(pipconfiguration); + pipconfiguration.setPiptype(null); + + return pipconfiguration; + } + + @Transient + public boolean isSQL() { + return this.type.equals(TYPE_SQL); + } + + @Transient + public boolean isLDAP() { + return this.type.equals(TYPE_LDAP); + } + + @Transient + public boolean isCSV() { + return this.type.equals(TYPE_CSV); + } + + @Transient + public boolean isHyperCSV() { + return this.type.equals(TYPE_HYPERCSV); + } + + @Transient + public boolean isCustom() { + return this.type.equals(TYPE_CUSTOM); + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PREFIXLIST.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PREFIXLIST.java new file mode 100644 index 000000000..aac04795c --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PREFIXLIST.java @@ -0,0 +1,117 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@Table(name="PREFIXLIST") +@NamedQuery(name="PREFIXLIST.findAll", query="SELECT e FROM PREFIXLIST e ") +public class PREFIXLIST implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="pl_name", nullable=false) + @OrderBy("asc") + private String prefixListName; + + @Column(name="description", nullable=false) + private String description; + + @Column(name="pl_value", nullable=false) + private String prefixListValue; +/* + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate;*/ + + public PREFIXLIST() { + + } + public PREFIXLIST(String string, String userid) { + this(domain); + + } + public PREFIXLIST(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + public String getPrefixListName() { + return this.prefixListName; + } + + public void setPrefixListName(String prefixListName) { + this.prefixListName = prefixListName; + + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + + } + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getPrefixListValue() { + return this.prefixListValue; + } + + public void setPrefixListValue(String prefixListValue) { + this.prefixListValue = prefixListValue; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PdpEntity.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PdpEntity.java new file mode 100644 index 000000000..191dfde60 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PdpEntity.java @@ -0,0 +1,247 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Index; +import javax.persistence.JoinColumn; +import javax.persistence.Lob; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToOne; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.UniqueConstraint; +import javax.persistence.Version; + +/* + * The Entity class to persist a policy object and its configuration data + */ + +/** + * + */ +@Entity +//Add a non-unique index and a constraint that says the combo of policyName and scopeId must be unique +@Table(name="PdpEntity") +@NamedQueries({ + @NamedQuery(name="PdpEntity.findAll", query="SELECT e FROM PdpEntity e "), + @NamedQuery(name="PdpEntity.deleteAll", query="DELETE FROM PdpEntity WHERE 1=1") +}) + +public class PdpEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqPdp") + @GeneratedValue(strategy = GenerationType.AUTO) + @Column (name="pdpKey") + private long pdpKey; + + @Column (name="pdpId", nullable=false, unique=false, length=255) + private String pdpId; + + @Column(name="pdpName", nullable=false, unique=false, length=255) + private String pdpName; + + @Column(name="jmxPort", nullable=false, unique=false) + private int jmxPort; + + + @ManyToOne(optional=false) + @JoinColumn(name="groupKey", referencedColumnName="groupKey") + private GroupEntity groupEntity; + + @Column(name="created_by", nullable=false, length=255) + private String createdBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="description", nullable=false, length=2048) + private String description = "NoDescription"; + + @Column(name="modified_by", nullable=false, length=255) + private String modifiedBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @Column(name="deleted", nullable=false) + private boolean deleted = false; + + public PdpEntity() { + super(); + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + } + + public long getPdpKey(){ + return pdpKey; + } + /** + * @return the policyId + */ + public String getPdpId() { + return pdpId; + } + + public void setPdpId(String id){ + pdpId = id; + } + /** + * @param policyId cannot be set + */ + + public String getPdpName() { + return pdpName; + } + + public void setPdpName(String groupName) { + this.pdpName = groupName; + } + + + + /** + * @return the configurationDataEntity + */ + public GroupEntity getGroup() { + return groupEntity; + } + + /** + * @param configurationDataEntity the configurationDataEntity to set + */ + public void setGroup(GroupEntity group) { + this.groupEntity = group; + } + + + + /** + * @return the createdBy + */ + public String getCreatedBy() { + return createdBy; + } + + /** + * @param createdBy the createdBy to set + */ + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * @return the modifiedBy + */ + public String getModifiedBy() { + return modifiedBy; + } + + /** + * @param modifiedBy the modifiedBy to set + */ + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + + /** + * @return the version + */ + public int getJmxPort() { + return jmxPort; + } + + public void setJmxPort(int jmxPort){ + this.jmxPort = jmxPort; + } + + /** + * @return the createdDate + */ + public Date getCreatedDate() { + return createdDate; + } + + /** + * @return the modifiedDate + */ + public Date getModifiedDate() { + return modifiedDate; + } + + /** + * @return the deleted + */ + public boolean isDeleted() { + return deleted; + } + + /** + * @param deleted the deleted to set + */ + public void setDeleted(boolean deleted) { + this.deleted = deleted; + } + + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyAlgorithms.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyAlgorithms.java new file mode 100644 index 000000000..eb46ae0dc --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyAlgorithms.java @@ -0,0 +1,116 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +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.NamedQuery; +import javax.persistence.Table; +import javax.persistence.Transient; + +import com.att.research.xacml.api.Identifier; + +@Entity +@Table(name="PolicyAlgorithms") +@NamedQuery(name="PolicyAlgorithms.findAll", query="SELECT d FROM PolicyAlgorithms d") +public class PolicyAlgorithms implements Serializable { + private static final long serialVersionUID = 1L; + + public static final char STANDARD = 'S'; + public static final char CUSTOM = 'C'; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="is_standard", nullable=false) + private char isStandard; + + @Column(name="xacml_id", nullable=false, unique=true, length=255) + private String xacmlId; + + @Column(name="short_name", nullable=false, length=64) + private String shortName; + + public PolicyAlgorithms(Identifier identifier, char standard) { + this.isStandard = standard; + if (identifier != null) { + this.xacmlId = identifier.stringValue(); + } + } + + public PolicyAlgorithms(Identifier identifier) { + this(identifier, PolicyAlgorithms.STANDARD); + } + + public PolicyAlgorithms() { + this(null, PolicyAlgorithms.STANDARD); + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public char getIsStandard() { + return this.isStandard; + } + + public void setIsStandard(char isStandard) { + this.isStandard = isStandard; + } + + @Transient + public boolean isStandard() { + return (this.isStandard == PolicyAlgorithms.STANDARD); + } + + @Transient + public boolean isCustom() { + return (this.isStandard == PolicyAlgorithms.CUSTOM); + } + + public String getXacmlId() { + return this.xacmlId; + } + + public void setXacmlId(String xacmlId) { + this.xacmlId = xacmlId; + } + + public String getShortName() { + return shortName; + } + + public void setShortName(String shortName) { + this.shortName = shortName; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyDBDaoEntity.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyDBDaoEntity.java new file mode 100644 index 000000000..c395ab49a --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyDBDaoEntity.java @@ -0,0 +1,150 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +/* + * The Entity class to persist a PolicyDBDaoEntity object for registration of PolicyDBDao + */ + +/** + * + */ +@Entity +@Table(name="PolicyDBDaoEntity") + +@NamedQueries({ + @NamedQuery(name="PolicyDBDaoEntity.findAll", query="SELECT e FROM PolicyDBDaoEntity e "), + @NamedQuery(name="PolicyDBDaoEntity.deleteAll", query="DELETE FROM PolicyDBDaoEntity WHERE 1=1") +}) + +public class PolicyDBDaoEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @Column(name="policyDBDaoUrl", nullable=false, unique=true) + private String policyDBDaoUrl; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + //username for the pap server that registered this PolicyDBDaoEntity + @Column(name="username") + private String username; + + //AES encrypted password for the pap server that registered this PolicyDBDaoEntity + @Column(name="password") + private String password; + + //A column to allow some descriptive text. For example: Atlanta data center + @Column(name="description", nullable=false, length=2048) + private String description = "NoDescription"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + public PolicyDBDaoEntity() { + super(); + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + } + + /** + * @return the policyDBDaoUrl + */ + public String getPolicyDBDaoUrl() { + return policyDBDaoUrl; + } + + /** + * @param url the policyDBDaoUrl to set + */ + public void setPolicyDBDaoUrl(String url) { + this.policyDBDaoUrl = url; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * @return the createdDate + */ + public Date getCreatedDate() { + return createdDate; + } + + /** + * @return the modifiedDate + */ + public Date getModifiedDate() { + return modifiedDate; + } + + public String getUsername(){ + return this.username; + } + public void setUsername(String username){ + this.username = username; + } + public String getPassword(){ + return this.password; + } + public void setPassword(String password){ + this.password = password; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyEditorScopes.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyEditorScopes.java new file mode 100644 index 000000000..daf97b3ed --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyEditorScopes.java @@ -0,0 +1,159 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + +@Entity +@Table(name="PolicyEditorScopes") +@NamedQuery(name="PolicyEditorScopes.findAll", query="SELECT p FROM PolicyEditorScopes p ") +public class PolicyEditorScopes implements Serializable{ + private static final long serialVersionUID = 1L; + private static Log logger = LogFactory.getLog(PolicyEditorScopes.class); + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="scopeName", nullable=false, unique=true) + @OrderBy("asc") + private String scopeName; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public PolicyEditorScopes() { + } + + public PolicyEditorScopes(String string, String userid) { + this(domain); + } + + public PolicyEditorScopes(String domain) { + this.scopeName = domain; + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy =XacmlAdminAuthorization.getUserId(); + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyEditorScopes", "Exception caused While adding Modified by Role"); + } + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getScopeName() { + return scopeName; + } + + public void setScopeName(String scopeName) { + this.scopeName = scopeName; + } + + public Date getCreatedDate() { + return this.createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public Date getModifiedDate() { + return this.modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyEntity.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyEntity.java new file mode 100644 index 000000000..80869c225 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyEntity.java @@ -0,0 +1,318 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Index; +import javax.persistence.JoinColumn; +import javax.persistence.Lob; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToOne; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.UniqueConstraint; +import javax.persistence.Version; + +import com.fasterxml.jackson.annotation.JsonBackReference; +import com.fasterxml.jackson.annotation.JsonManagedReference; + +/* + * The Entity class to persist a policy object and its configuration data + */ + +/** + * + */ +@Entity +//Add a non-unique index and a constraint that says the combo of policyName and scopeId must be unique +@Table(name="PolicyEntity", indexes = {@Index(name="scope", columnList="scope", unique=false), + @Index(name="policyName", columnList="policyName", unique=false)}, + uniqueConstraints=@UniqueConstraint(columnNames={"policyName", "scope"})) + +//Using a sequence generator because the value is available as soon as the +//the object is persisted. That is, you don't have to flush/commit to the DB. +//@SequenceGenerator(name="seqPolicy", initialValue=1, allocationSize=1) + +@NamedQueries({ + @NamedQuery(name="PolicyEntity.findAll", query="SELECT e FROM PolicyEntity e "), + @NamedQuery(name="PolicyEntity.findAllByDeletedFlag", query="SELECT e FROM PolicyEntity e WHERE e.deleted = :deleted"), + @NamedQuery(name="PolicyEntity.FindById", query="SELECT e FROM PolicyEntity e WHERE e.policyId = :id"), + @NamedQuery(name="PolicyEntity.deleteAll", query="DELETE FROM PolicyEntity WHERE 1=1"), + @NamedQuery(name="PolicyEntity.findByNameAndScope", query="SELECT e FROM PolicyEntity e WHERE e.policyName = :name AND e.scope = :scope") +}) + +public class PolicyEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqPolicy") + @GeneratedValue(strategy = GenerationType.AUTO) + @Column (name="policyId") + @JsonBackReference + private long policyId; + + @Column(name="policyName", nullable=false, unique=false, length=255) + private String policyName; + + //The scope is the directory structure in dot notation. For example: org.openecomp.myproject + @Column(name="scope", nullable=false, unique=false, length=255) + private String scope; + + @Version + @Column(name="version") + private int version; + + //not going to be used + @Column(name="policyVersion") + private int policyVersion = 0; + + @Lob + @Column(name="policyData", nullable=false, columnDefinition="TEXT") + private String policyData = "NoData"; + + @OneToOne(optional=true, orphanRemoval=true) + @JoinColumn(name="configurationDataId", referencedColumnName="configurationDataId") + @JsonManagedReference + private ConfigurationDataEntity configurationDataEntity; + + @OneToOne(optional=true, orphanRemoval=true) + @JoinColumn(name="actionBodyId", referencedColumnName="actionBodyId") + @JsonManagedReference + private ActionBodyEntity actionBodyEntity; + + @Column(name="created_by", nullable=false, length=255) + private String createdBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="description", nullable=false, length=2048) + private String description = "NoDescription"; + + @Column(name="modified_by", nullable=false, length=255) + private String modifiedBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @Column(name="deleted", nullable=false) + private boolean deleted = false; + + public PolicyEntity() { + super(); + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + } + + /* + public void resetPolicyVersion(){ + this.policyVersion = 1; + } + public void advancePolicyVersion(){ + this.policyVersion++; + } + public int getPolicyVersion(){ + return this.policyVersion; + } + public void setPolicyVersion(int polVer){ + this.policyVersion = polVer; + } + */ + + /** + * @return the policyId + */ + public long getPolicyId() { + return policyId; + } + + /** + * @param policyId cannot be set + */ + + public String getPolicyName() { + return policyName; + } + + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + /** + * @return the policyData + */ + public String getPolicyData() { + return policyData; + } + + /** + * @param policyData the policyData to set + */ + public void setPolicyData(String policyData) { + this.policyData = policyData; + } + + /** + * @return the configurationDataEntity + */ + public ConfigurationDataEntity getConfigurationData() { + return configurationDataEntity; + } + + /** + * @param configurationDataEntity the configurationDataEntity to set + */ + public void setConfigurationData(ConfigurationDataEntity configurationDataEntity) { + this.configurationDataEntity = configurationDataEntity; + } + + /** + * @return the actionBodyEntity + */ + public ActionBodyEntity getActionBodyEntity() { + return actionBodyEntity; + } + + /** + * @param actionBodyEntity the actionBodyEntity to set + */ + public void setActionBodyEntity(ActionBodyEntity actionBodyEntity) { + this.actionBodyEntity = actionBodyEntity; + } + + /** + * @return the scope + */ + public String getScope() { + return scope; + } + + /** + * @param scope the scope to set + */ + public void setScope(String scope) { + this.scope = scope; + } + + /** + * @return the createdBy + */ + public String getCreatedBy() { + return createdBy; + } + + /** + * @param createdBy the createdBy to set + */ + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * @return the modifiedBy + */ + public String getModifiedBy() { + return modifiedBy; + } + + /** + * @param modifiedBy the modifiedBy to set + */ + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + + /** + * @return the version + */ + public int getVersion() { + return version; + } + + /** + * @return the createdDate + */ + public Date getCreatedDate() { + return createdDate; + } + + /** + * @return the modifiedDate + */ + public Date getModifiedDate() { + return modifiedDate; + } + + /** + * @return the deleted + */ + public boolean isDeleted() { + return deleted; + } + + /** + * @param deleted the deleted to set + */ + public void setDeleted(boolean deleted) { + this.deleted = deleted; + } + + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyManagement.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyManagement.java new file mode 100644 index 000000000..3f036d555 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyManagement.java @@ -0,0 +1,162 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.sql.Clob; +import java.sql.Timestamp; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.Table; + + +/** + * The persistent class for the roles database table. + * + */ +@Entity +@Table(name="policy_manangement") +@NamedQuery(name="PolicyManagement.findAll", query="SELECT r FROM PolicyManagement r") +public class PolicyManagement implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + + @Column(name="id") + private int id; + + @Column(name="POLICY_NAME", nullable=false, length=45) + private String policyName; + + @Column(name="scope", nullable=false, length=45) + private String scope; + + @Column(name="ECOMP_NAME", nullable=false, length=45) + private String ecompName; + + @Column(name="CONFIG_NAME", nullable=false, length=45) + private String configName; + + @Column(name="XML", nullable=false) + private Clob xml; + + @Column(name="CREATE_DATE_TIME", nullable=false) + private Timestamp createDateTime; + + + @Column(name="CREATED_BY", nullable=false, length=45) + private String createdBy; + + @Column(name="UPDATE_DATE_TIME", nullable=false) + private Timestamp updateDateTime; + + @Column(name="UPDATED_BY", nullable=false, length=45) + private String updatedBy; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getPolicyName() { + return policyName; + } + + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } + + public String getEcompName() { + return ecompName; + } + + public void setEcompName(String ecompName) { + this.ecompName = ecompName; + } + + public String getConfigName() { + return configName; + } + + public void setConfigName(String configName) { + this.configName = configName; + } + + public Clob getXml() { + return xml; + } + + public void setXml(Clob xml) { + this.xml = xml; + } + + public Timestamp getCreateDateTime() { + return createDateTime; + } + + public void setCreateDateTime(Timestamp createDateTime) { + this.createDateTime = createDateTime; + } + + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public Timestamp getUpdateDateTime() { + return updateDateTime; + } + + public void setUpdateDateTime(Timestamp updateDateTime) { + this.updateDateTime = updateDateTime; + } + + public String getUpdatedBy() { + return updatedBy; + } + + public void setUpdatedBy(String updatedBy) { + this.updatedBy = updatedBy; + } + + + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyRoles.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyRoles.java new file mode 100644 index 000000000..71df02b99 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyRoles.java @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +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.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.Table; + +import org.openecomp.policy.rest.jpa.UserInfo; + + +/** + * The persistent class for the roles database table. + * + */ +@Entity +@Table(name="roles") +@NamedQuery(name="PolicyRoles.findAll", query="SELECT r FROM PolicyRoles r ") +public class PolicyRoles implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + + @Column(name="id") + private int id; + + @ManyToOne + @JoinColumn(name="loginid") + @OrderBy("asc") + private UserInfo loginid; + + public UserInfo getLoginId() { + return loginid; + } + + public void setLoginId(UserInfo loginid) { + this.loginid = loginid; + } + + @Column(name="scope", nullable=true, length=45) + private String scope; + + @Column(name="role", nullable=false, length=45) + private String role; + + public PolicyRoles() { + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getScope() { + return this.scope; + } + + public void setScope(String scope) { + this.scope = scope; + + } + public String getRole() { + return this.role; + } + + public void setRole(String role) { + this.role = role; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeClosedLoop.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeClosedLoop.java new file mode 100644 index 000000000..484851d7b --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeClosedLoop.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + + +@Entity +@Table(name="PolicyScopeClosedLoop") +@NamedQuery(name="PolicyScopeClosedLoop.findAll", query="SELECT e FROM PolicyScopeClosedLoop e ") +public class PolicyScopeClosedLoop implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="description ") + private String description ; + + public PolicyScopeClosedLoop() { + + } + public PolicyScopeClosedLoop(String string, String userid) { + this(domain); + + } + public PolicyScopeClosedLoop(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + + } + public String getDescriptionValue() { + return this.description ; + } + + public void setDescriptionValue(String description ) { + this.description = description ; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeResource.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeResource.java new file mode 100644 index 000000000..e126c4118 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeResource.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + + +@Entity +@Table(name="PolicyScopeResource") +@NamedQuery(name="PolicyScopeResource.findAll", query="SELECT e FROM PolicyScopeResource e ") +public class PolicyScopeResource implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="description ") + private String description ; + + public PolicyScopeResource() { + + } + public PolicyScopeResource(String string, String userid) { + this(domain); + + } + public PolicyScopeResource(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + + } + public String getDescriptionValue() { + return this.description ; + } + + public void setDescriptionValue(String description ) { + this.description = description ; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeService.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeService.java new file mode 100644 index 000000000..cc8c11383 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeService.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + + +@Entity +@Table(name="PolicyScopeService") +@NamedQuery(name="PolicyScopeService.findAll", query="SELECT e FROM PolicyScopeService e ") +public class PolicyScopeService implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="description ") + private String description ; + + public PolicyScopeService() { + + } + public PolicyScopeService(String string, String userid) { + this(domain); + + } + public PolicyScopeService(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + + } + public String getDescriptionValue() { + return this.description ; + } + + public void setDescriptionValue(String description ) { + this.description = description ; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeType.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeType.java new file mode 100644 index 000000000..d4ade7fe9 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeType.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + + +@Entity +@Table(name="PolicyScopeType") +@NamedQuery(name="PolicyScopeType.findAll", query="SELECT e FROM PolicyScopeType e ") +public class PolicyScopeType implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="description ") + private String description ; + + public PolicyScopeType() { + + } + public PolicyScopeType(String string, String userid) { + this(domain); + + } + public PolicyScopeType(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + + } + public String getDescriptionValue() { + return this.description ; + } + + public void setDescriptionValue(String description ) { + this.description = description ; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScore.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScore.java new file mode 100644 index 000000000..cae9cfc6a --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScore.java @@ -0,0 +1,109 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + + +@Entity +@Table(name="POLICYSCORE") +@NamedQueries({ + @NamedQuery(name="POLICYSCORE.findAll", query="SELECT p FROM PolicyScore p"), + @NamedQuery(name="POLICYSCORE.deleteAll", query="DELETE FROM PolicyScore WHERE 1=1"), + @NamedQuery(name="POLICYSCORE.findByPolicyName", query="Select p from PolicyScore p where p.PolicyName=:pname") +}) +public class PolicyScore implements Serializable { + + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="POLICY_NAME", nullable=false) + @OrderBy("asc") + private String PolicyName; + + @Column(name="VERSIONEXTENSION", nullable=false) + @OrderBy("asc") + private String VersionExtension; + + @Column(name="POLICY_SCORE", nullable=true) + private String PolicyScore; + + public PolicyScore() { + + } + + public PolicyScore(String pName, String pScore) { + this(domain); + + } + public PolicyScore(String domain) { + + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + public String getPolicyName() { + return PolicyName; + } + public void setPolicyName(String policyName) { + PolicyName = policyName; + } + public String getVersionExtension() { + return VersionExtension; + } + + public void setVersionExtension(String versionExtension) { + VersionExtension = versionExtension; + } + public String getPolicyScore() { + return PolicyScore; + } + public void setPolicyScore(String policyScore) { + PolicyScore = policyScore; + } + + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyVersion.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyVersion.java new file mode 100644 index 000000000..73d39ad8e --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyVersion.java @@ -0,0 +1,182 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +//import java.sql.Clob; +import java.sql.Timestamp; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + + +@Entity +@Table(name="PolicyVersion") +@NamedQueries({ + @NamedQuery(name="PolicyVersion.findAll", query="SELECT p FROM PolicyVersion p"), + @NamedQuery(name="PolicyVersion.deleteAll", query="DELETE FROM PolicyVersion WHERE 1=1"), + @NamedQuery(name="PolicyVersion.findByPolicyName", query="Select p from PolicyVersion p where p.policyName=:pname") +}) +public class PolicyVersion implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + + @Column(name="id") + private int id; + + @Column(name="POLICY_NAME", nullable=false, length=255) + private String policyName; + + @Column(name="ACTIVE_VERSION") + private int activeVersion; + + @Column(name="HIGHEST_VERSION") + private int higherVersion; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", nullable=false) + private Date createdDate; + + + public int getActiveVersion() { + return activeVersion; + } + + public void setActiveVersion(int activeVersion) { + this.activeVersion = activeVersion; + } + + public int getHigherVersion() { + return higherVersion; + } + + public void setHigherVersion(int higherVersion) { + this.higherVersion = higherVersion; + } + + @Column(name="CREATED_BY", nullable=false, length=45) + private String createdBy; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + + @Column(name="modified_by", nullable=false, length=45) + private String modifiedBy; + + public PolicyVersion(String domain, String loginUserId) { + this(domain); + this.createdBy = loginUserId; + this.modifiedBy = loginUserId; + } + + public PolicyVersion(String domain) { + this.policyName = domain; + } + + public PolicyVersion(){ + + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + /* + * The modifiedBy must be set via the setModifiedBy() method since PolicyVersion + * has been moved to XACML-REST module for access from the XACML-PAP-REST module + + String userid = ((XacmlAdminUI) UI.getCurrent()).getLoginUserId(); + this.modifiedBy =userid; + * + */ + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getPolicyName() { + return policyName; + } + + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + public Date getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(Timestamp createdDate) { + this.createdDate = createdDate; + } + + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public Date getModifiedDate() { + return modifiedDate; + } + + public void setModifiedDate(Timestamp modifiedDate) { + this.modifiedDate = modifiedDate; + } + + public String getModifiedBy() { + return modifiedBy; + } + + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + +} + diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PortList.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PortList.java new file mode 100644 index 000000000..88ce58afc --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PortList.java @@ -0,0 +1,107 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@Table(name="portlist") +@NamedQuery(name="PortList.findAll", query="SELECT e FROM PortList e ") +public class PortList implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="portname", nullable=false) + @OrderBy("asc") + private String portName; + + @Column(name="description") + private String description; +/* + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate;*/ + + public PortList() { + + } + public PortList(String string, String userid) { + this(domain); + + } + public PortList(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getPortName() { + return this.portName; + } + + public void setPortName(String portName) { + this.portName = portName; + + } + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ProtocolList.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ProtocolList.java new file mode 100644 index 000000000..a450c2551 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ProtocolList.java @@ -0,0 +1,108 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@Table(name="protocollist") +@NamedQuery(name="ProtocolList.findAll", query="SELECT e FROM ProtocolList e ") +public class ProtocolList implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="protocolname", nullable=false) + @OrderBy("asc") + private String protocolName; + + @Column(name="description") + private String description; +/* + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate;*/ + + public ProtocolList() { + + } + public ProtocolList(String string, String userid) { + this(domain); + + } + public ProtocolList(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + public String getProtocolName() { + return this.protocolName; + } + + public void setProtocolName(String protocolName) { + this.protocolName = protocolName; + + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/RemoteCatalogValues.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/RemoteCatalogValues.java new file mode 100644 index 000000000..c906c79cb --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/RemoteCatalogValues.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + + +@Entity +@Table(name="RemoteCatalogValues") +@NamedQuery(name="RemoteCatalogValues.findAll", query="SELECT e FROM RemoteCatalogValues e ") +public class RemoteCatalogValues implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="value") + private String value; + + + public RemoteCatalogValues() { + + } + public RemoteCatalogValues(String string, String userid) { + this(domain); + + } + public RemoteCatalogValues(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/RiskType.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/RiskType.java new file mode 100644 index 000000000..da18c744e --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/RiskType.java @@ -0,0 +1,178 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; +import org.openecomp.policy.rest.jpa.UserInfo; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonManagedReference; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + +@Entity +@Table(name="RiskType") +@NamedQuery(name="RiskType.findAll", query="SELECT e FROM RiskType e ") +public class RiskType implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false, unique=true) + @OrderBy("asc") + private String name; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(RiskType.class); + + public RiskType() { + + } + + public RiskType(String string, String userid) { + this(domain); + } + + public RiskType(String domain) { + this.name = domain; + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy =XacmlAdminAuthorization.getUserId(); + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "RiskType", "Exception caused While adding Modified by Role"); + } + } + public String getRiskName() { + return this.name; + } + + public void setRiskName(String riskName) { + this.name = riskName; + + } + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public Date getCreatedDate() { + return this.createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getModifiedDate() { + return this.modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/RuleAlgorithms.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/RuleAlgorithms.java new file mode 100644 index 000000000..4ec0dff67 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/RuleAlgorithms.java @@ -0,0 +1,125 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +/* + * AT&T - PROPRIETARY + * THIS FILE CONTAINS PROPRIETARY INFORMATION OF + * AT&T AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN + * ACCORDANCE WITH APPLICABLE AGREEMENTS. + * + * Copyright (c) 2014 AT&T Knowledge Ventures + * Unpublished and Not for Publication + * All Rights Reserved + */ +package org.openecomp.policy.rest.jpa; + +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.NamedQuery; +import javax.persistence.Table; +import javax.persistence.Transient; + +import com.att.research.xacml.api.Identifier; + +@Entity +@Table(name="RuleAlgorithms") +@NamedQuery(name="RuleAlgorithms.findAll", query="SELECT d FROM RuleAlgorithms d") +public class RuleAlgorithms implements Serializable { + private static final long serialVersionUID = 1L; + + public static final char STANDARD = 'S'; + public static final char CUSTOM = 'C'; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="is_standard", nullable=false) + private char isStandard; + + @Column(name="xacml_id", nullable=false, unique=true, length=255) + private String xacmlId; + + @Column(name="short_name", nullable=false, length=64) + private String shortName; + + public RuleAlgorithms(Identifier id, char standard) { + if (id != null) { + this.xacmlId = id.stringValue(); + } + this.isStandard = standard; + } + public RuleAlgorithms(Identifier id) { + this(id, RuleAlgorithms.STANDARD); + } + + public RuleAlgorithms() { + this(null, RuleAlgorithms.STANDARD); + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public char getIsStandard() { + return this.isStandard; + } + + public void setIsStandard(char isStandard) { + this.isStandard = isStandard; + } + + @Transient + public boolean isStandard() { + return (this.isStandard == RuleAlgorithms.STANDARD); + } + + @Transient + public boolean isCustom() { + return (this.isStandard == RuleAlgorithms.CUSTOM); + } + + public String getXacmlId() { + return this.xacmlId; + } + + public void setXacmlId(String xacmlId) { + this.xacmlId = xacmlId; + } + + public String getShortName() { + return shortName; + } + + public void setShortName(String shortName) { + this.shortName = shortName; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/SafePolicyWarning.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/SafePolicyWarning.java new file mode 100644 index 000000000..8d3a0f277 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/SafePolicyWarning.java @@ -0,0 +1,109 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +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.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + + +@Entity +@Table(name="SafePolicyWarning") +@NamedQuery(name="SafePolicyWarning.findAll", query="SELECT e FROM SafePolicyWarning e ") +public class SafePolicyWarning implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="message") + private String message ; + + @Column(name="riskType") + private String riskType ; + + public String getRiskType() { + return riskType; + } + public void setRiskType(String riskType) { + this.riskType = riskType; + } + public SafePolicyWarning() { + + } + public SafePolicyWarning(String string, String userid) { + this(domain); + + } + public SafePolicyWarning(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getName() { + return this.name; + } + + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + public void setName(String name) { + this.name = name; + + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/SecurityZone.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/SecurityZone.java new file mode 100644 index 000000000..2fbd4486d --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/SecurityZone.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@Table(name="securityzone") +@NamedQuery(name="SecurityZone.findAll", query="SELECT e FROM SecurityZone e ") +public class SecurityZone implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String zoneName; + + @Column(name="value") + private String zoneValue; + + + public SecurityZone() { + + } + public SecurityZone(String string, String userid) { + this(domain); + + } + public SecurityZone(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getZoneName() { + return this.zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + + } + public String getZoneValue() { + return this.zoneValue; + } + + public void setZoneValue(String zoneValue) { + this.zoneValue = zoneValue; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ServiceList.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ServiceList.java new file mode 100644 index 000000000..9a72916b1 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ServiceList.java @@ -0,0 +1,157 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@Table(name="servicegroup") +@NamedQuery(name="ServiceList.findAll", query="SELECT e FROM ServiceList e ") +public class ServiceList implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String serviceName; + + @Column(name="description") + private String serviceDesc; + + @Column(name="type") + private String serviceType; + + @Column(name="transportprotocol") + private String serviceTrasProtocol; + + @Column(name="appprotocol ") + private String serviceAppProtocol; + + @Column(name="ports") + private String servicePorts; + + + +/* + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate;*/ + + public ServiceList() { + + } + public ServiceList(String string, String userid) { + this(domain); + + } + public ServiceList(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getServiceName() { + return this.serviceName; + } + + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + + } + + public String getServiceDescription() { + return this.serviceDesc; + } + + public void setServiceDescription(String serviceDesc) { + this.serviceDesc = serviceDesc; + + } + + public String getServiceType() { + return this.serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public String getServiceTransProtocol() { + return this.serviceTrasProtocol; + } + + public void setServiceTransProtocol(String serviceTrasProtocol) { + this.serviceTrasProtocol = serviceTrasProtocol; + + } + + public String getServiceAppProtocol() { + return this.serviceAppProtocol; + } + + public void setServiceAppProtocol(String serviceAppProtocol) { + this.serviceAppProtocol = serviceAppProtocol; + + } + public String getServicePorts() { + return this.servicePorts; + } + + public void setServicePorts(String servicePorts) { + this.servicePorts = servicePorts; + + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/SystemLogDB.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/SystemLogDB.java new file mode 100644 index 000000000..a86857aee --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/SystemLogDB.java @@ -0,0 +1,173 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +/* + * AT&T - PROPRIETARY + * THIS FILE CONTAINS PROPRIETARY INFORMATION OF + * AT&T AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN + * ACCORDANCE WITH APPLICABLE AGREEMENTS. + * + * Copyright (c) 2013 AT&T Knowledge Ventures + * Unpublished and Not for Publication + * All Rights Reserved + */ +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; + +import com.att.research.xacml.api.Identifier; + +/** + * The persistent class for the system log database table. + * +*/ +@Entity +@Table(name="SystemLogDB") +@NamedQuery(name="SystemLogDB.findAll", query="SELECT o FROM SystemLogDB o") +public class SystemLogDB implements Serializable { + private static final long serialVersionUID = 1L; + + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="type", nullable=false) + private String type; + + @Column(name="system", nullable=false, length=255) + private String system; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Column(name="remote", nullable=false, length=255) + private String remote; + + @Column(name="logtype", nullable=false, length=255) + private String logtype; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="date", nullable=false, updatable=false) + private Date date; + + public SystemLogDB() { + super(); + } + + public SystemLogDB(int id, String system, String description, String remote, + String type, String logtype) { + // TODO Auto-generated constructor stub + this.id = id; + this.system = system; + this.description = description; + this.remote = remote; + this.type = type; + this.logtype = logtype; + } + + public void SystemLogB (int id, String system, String description, String remote, String type, Date date, String logtype){ + this.id = id; + this.system = system; + this.description = description; + this.remote = remote; + this.type = type; + this.date = date; + this.logtype = logtype; + + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public Date getDate(){ + return this.date; + } + + public void setDate(Date date){ + this.date = date; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; + + } + + public String getSystem() { + return this.system; + } + + public void setSystem(String system) { + this.system = system; + } + + public String getRemote() { + return this.remote; + } + + public void setRemote(String remote) { + this.remote = remote; + + } + public String getLogtype() { + return this.logtype; + } + + public void setLogtype(String logtype) { + this.logtype = logtype; + + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/TermList.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/TermList.java new file mode 100644 index 000000000..ce94fb8d8 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/TermList.java @@ -0,0 +1,262 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + +@Entity +@Table(name="TERM") +@NamedQuery(name="TermList.findAll", query="SELECT e FROM TermList e") +public class TermList implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="termName", nullable=false) + @OrderBy("asc") + private String termName; + + @Column(name="description") + private String termDescription; + + @Column(name="fromzone") + private String fromZone; + + @Column(name="tozone") + private String toZone; + + @Column(name="srcIPList") + private String srcIPList; + + @Column(name="destIPList") + private String destIPList; + + @Column(name="protocolList") + private String protocolList; + + @Column(name="portList") + private String portList; + + @Column(name="srcPortList") + private String srcPortList; + + @Column(name="destPortList") + private String destPortList; + + @Column(name="action") + private String action; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(TermList.class); + + public TermList() { + + } + + private static final Log auditLogger = LogFactory + .getLog("auditLogger"); + + public TermList(String string, String userid) { + this(domain); + } + public TermList(String domain) { + this.termName = domain; + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + auditLogger.debug("Added New Term Name: "+this.termName+" by "+this.userCreatedBy); + + } + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy =XacmlAdminAuthorization.getUserId();; + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "TermList", "Exception caused While adding Modified by Role"); + } + auditLogger.debug("Updated Term Name: "+this.termName+" by "+this.userModifiedBy); + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getTermName() { + return this.termName; + } + + public void setTermName(String termName) { + this.termName = termName; + } + + public String getTermDescription() { + return this.termDescription; + } + + public void setDescription(String termDescription) { + this.termDescription = termDescription; + } + + public String getFromZone() { + return this.fromZone; + } + + public void setFromZones(String fromZone) { + this.fromZone = fromZone; + } + + public String getToZone() { + return this.toZone; + } + + public void setToZones(String toZone) { + this.toZone = toZone; + } + + public String getSrcIPList() { + return this.srcIPList; + } + + public void setSrcIPList(String srcIPList) { + this.srcIPList = srcIPList; + } + + public String getDestIPList() { + return this.destIPList; + } + + public void setDestIPList(String destIPList) { + this.destIPList = destIPList; + } + + public String getProtocolList() { + return this.protocolList; + } + + public void setProtocolList(String protocolList) { + this.protocolList = protocolList; + } + + public String getPortList() { + return this.portList; + } + + public void setPortList(String portList) { + this.portList = portList; + } + + public String getSrcPortList() { + return this.srcPortList; + } + + public void setSrcPortList(String srcPortList) { + this.srcPortList = srcPortList; + } + + public String getDestPortList() { + return this.destPortList; + } + + public void setDestPortList(String destPortList) { + this.destPortList = destPortList; + } + + + public String getAction() { + return this.action; + } + + public void setAction(String action) { + this.action = action; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/UserInfo.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/UserInfo.java new file mode 100644 index 000000000..6f5982aa8 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/UserInfo.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.persistence.Transient; + +import com.att.research.xacml.api.Identifier; +import com.att.research.xacml.std.IdentifierImpl; +import com.fasterxml.jackson.annotation.JsonBackReference; + +@Entity +@Table(name = "UserInfo") +@NamedQuery(name="UserInfo.findAll", query="SELECT u FROM UserInfo u ") +public class UserInfo implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @Column(name="loginId", nullable=false, length=45) + private String userLoginId; + + @Column(name = "name", nullable = false, unique = true) + private String userName; + + public UserInfo(){ + this.userLoginId = userName; + + } + + public String getUserLoginId() { + return userLoginId; + } + + public void setUserLoginId(String loginid) { + this.userLoginId = loginid; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + @Transient + @JsonBackReference + public Identifier getIdentiferByUserId() { + return new IdentifierImpl(this.userName); + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VMType.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VMType.java new file mode 100644 index 000000000..a1adcd447 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VMType.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + + +@Entity +@Table(name="VMType") +@NamedQuery(name="VMType.findAll", query="SELECT e FROM VMType e ") +public class VMType implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="description") + private String description; + + + public VMType() { + + } + public VMType(String string, String userid) { + this(domain); + + } + public VMType(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VNFType.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VNFType.java new file mode 100644 index 000000000..a2c19da31 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VNFType.java @@ -0,0 +1,174 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + + +@Entity +@Table(name="VNFType") +@NamedQuery(name="VNFType.findAll", query="SELECT v FROM VNFType v ") +public class VNFType implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="vnf_type", nullable=false, unique=true) + @OrderBy("asc") + private String vnftype; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(VNFType.class); + + public VNFType() { + + } + + public String getVnftype() { + return vnftype; + } + + public void setVnftype(String vnftype) { + this.vnftype = vnftype; + } + + public VNFType(String string, String userid) { + this(domain); + } + + public VNFType(String domain) { + this.vnftype = domain; + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy =XacmlAdminAuthorization.getUserId();; + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "VNFType", "Exception caused While adding Modified by Role"); + } + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public Date getCreatedDate() { + return this.createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getModifiedDate() { + return this.modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VSCLAction.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VSCLAction.java new file mode 100644 index 000000000..39d671f1d --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VSCLAction.java @@ -0,0 +1,174 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + +@Entity +@Table(name="VSCLAction") +@NamedQuery(name="VSCLAction.findAll", query="SELECT v FROM VSCLAction v ") +public class VSCLAction implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="vscl_action", nullable=false, unique=true) + @OrderBy("asc") + private String vsclaction; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(VSCLAction.class); + + public VSCLAction() { + + } + + public VSCLAction(String string, String userid) { + this(domain); + } + + public VSCLAction(String domain) { + this.vsclaction = domain; + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy =XacmlAdminAuthorization.getUserId();; + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "VSCLAction", "Exception caused While adding Modified by Role"); + } + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getVsclaction() { + return vsclaction; + } + + public void setVsclaction(String vsclaction) { + this.vsclaction = vsclaction; + } + + + public Date getCreatedDate() { + return this.createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getModifiedDate() { + return this.modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VarbindDictionary.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VarbindDictionary.java new file mode 100644 index 000000000..05e5710d7 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VarbindDictionary.java @@ -0,0 +1,185 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + +@Entity +@Table(name="VarbindDictionary") +@NamedQuery(name = "VarbindDictionary.findAll", query = "Select v FROM VarbindDictionary v") +public class VarbindDictionary implements Serializable{ + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "Id") + private int id; + + @Column(name ="varbind_Name", nullable = false, unique = true) + @OrderBy("asc") + private String varbindName; + + @Column(name = "varbind_Description", nullable = true, length = 2048) + private String varbindDescription; + + @Column(name = "varbind_oid", nullable = false) + private String varbindOID; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(VarbindDictionary.class); + + public VarbindDictionary() { + + } + + public VarbindDictionary(String string, String userid) { + this(domain); + } + + public VarbindDictionary(String domain) { + this.varbindName = domain; + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy =XacmlAdminAuthorization.getUserId();; + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "VarbindDictionary", "Exception caused While adding Modified by Role"); + } + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getVarbindName() { + return varbindName; + } + + public void setVarbindName(String varbindName) { + this.varbindName = varbindName; + } + + public String getVarbindDescription() { + return varbindDescription; + } + + public void setVarbindDescription(String varbindDescription) { + this.varbindDescription = varbindDescription; + } + + public String getVarbindOID() { + return varbindOID; + } + + public void setVarbindOID(String varbindOID) { + this.varbindOID = varbindOID; + } + + public Date getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public Date getModifiedDate() { + return modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/WatchPolicyNotificationTable.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/WatchPolicyNotificationTable.java new file mode 100644 index 000000000..2acc82cce --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/WatchPolicyNotificationTable.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + * + * + * */ + +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.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.Table; + +@Entity +@Table(name = "WatchPolicyNotificationTable") +@NamedQuery(name="WatchPolicyNotificationTable.findAll", query="SELECT e FROM WatchPolicyNotificationTable e ") +public class WatchPolicyNotificationTable implements Serializable{ + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="policyName", nullable=false, unique=true) + @OrderBy("asc") + private String policyName; + + @Column(name="loginIds", nullable=false, unique=true) + @OrderBy("asc") + private String loginIds; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getPolicyName() { + return policyName; + } + + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + public String getLoginIds() { + return loginIds; + } + + public void setLoginIds(String loginIds) { + this.loginIds = loginIds; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Zone.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Zone.java new file mode 100644 index 000000000..e1db124c3 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Zone.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@Table(name="zone") +@NamedQuery(name="Zone.findAll", query="SELECT e FROM Zone e ") +public class Zone implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="zonename", nullable=false) + @OrderBy("asc") + private String zoneName; + + @Column(name="zonevalue") + private String zoneValue; + + + public Zone() { + + } + public Zone(String string, String userid) { + this(domain); + + } + public Zone(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getZoneName() { + return this.zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + + } + public String getZoneValue() { + return this.zoneValue; + } + + public void setZoneValue(String zoneValue) { + this.zoneValue = zoneValue; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/package-info.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/package-info.java new file mode 100644 index 000000000..d5b935077 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/package-info.java @@ -0,0 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file 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. + * ============LICENSE_END========================================================= + */ + +/** + * + */ +/** + * + */ +package org.openecomp.policy.rest.jpa; -- cgit 1.2.3-korg