diff options
author | liamfallon <liam.fallon@est.tech> | 2019-11-13 14:08:14 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2019-11-13 22:16:10 +0000 |
commit | 2f3ca9fc5edc5a52659b3486605e0db508143318 (patch) | |
tree | 0511aa5f0d117fa78032f5b91b2024b57dba5913 /ONAP-REST/src/main/java | |
parent | 0c20d1c294fe146e1018f14b07a8d861c29fe527 (diff) |
Unit/SONAR/Checkstyle in ONAP-REST
Fourth batch of JPA pojos (N-P), with JUnit added and SONAR/Checkstyle
issues addressed. In cases where a class name change caused an update in
another package, the license header on files for those knock on changes
are not updated.
Issue-ID: POLICY-2131
Change-Id: I9319b514b5c19e6837c34566dde770673d16bca3
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'ONAP-REST/src/main/java')
40 files changed, 1463 insertions, 2563 deletions
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java index 97e6e9ef6..e7879a855 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java @@ -23,7 +23,9 @@ package org.onap.policy.rest.adapter; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; + import javax.persistence.EntityManagerFactory; + import org.onap.policy.rest.jpa.OnapName; public class PolicyRestAdapter { @@ -1160,7 +1162,7 @@ public class PolicyRestAdapter { case "ONAPName": this.setOnapName(value); OnapName tempOnapName = new OnapName(); - tempOnapName.setOnapName(value); + tempOnapName.setName(value); this.setOnapNameField(tempOnapName); return true; case "RiskType": diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintType.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintType.java index a79866a36..10394ae6f 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintType.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintType.java @@ -73,7 +73,7 @@ public class ConstraintType implements Serializable { private int id; @Column(name = "constraint_type", nullable = false, length = 64) - private String constraintType; + private String theConstraintType; @Column(name = "description", nullable = false, length = 255) private String description; @@ -84,7 +84,7 @@ public class ConstraintType implements Serializable { public ConstraintType(String constraintType) { this(); - this.constraintType = constraintType; + this.theConstraintType = constraintType; } public ConstraintType(String constraintType, String description) { @@ -96,4 +96,11 @@ public class ConstraintType implements Serializable { return RANGE_TYPES; } + public String getConstraintType() { + return theConstraintType; + } + + public void setConstraintType(final String theConstraintType) { + this.theConstraintType = theConstraintType; + } } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupPolicyScopeList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupPolicyScopeList.java index 394b6dc59..71eb19ec5 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupPolicyScopeList.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupPolicyScopeList.java @@ -21,8 +21,6 @@ package org.onap.policy.rest.jpa; -/* - */ import java.io.Serializable; import javax.persistence.Column; diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupServiceList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupServiceList.java index e97a26ebc..6d1120307 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupServiceList.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupServiceList.java @@ -21,8 +21,6 @@ package org.onap.policy.rest.jpa; -/* - */ import java.io.Serializable; import javax.persistence.Column; diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceAttribute.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceAttribute.java index 574212097..8ae81b9c0 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceAttribute.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceAttribute.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -31,54 +32,30 @@ import javax.persistence.NamedQuery; import javax.persistence.OrderBy; import javax.persistence.Table; +import lombok.Getter; +import lombok.Setter; + @Entity -@Table(name="MicroServiceAttribute") -@NamedQuery(name="MicroServiceAttribute.findAll", query="SELECT e FROM MicroServiceAttribute e ") +@Table(name = "MicroServiceAttribute") +@NamedQuery(name = "MicroServiceAttribute.findAll", query = "SELECT e FROM MicroServiceAttribute e ") +@Getter +@Setter + public class MicroServiceAttribute implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="name", nullable=false) + @Column(name = "name", nullable = false) @OrderBy("asc") private String name; - @Column(name="value") - private String value ; + @Column(name = "value") + private String value; - @Column(name="modelName") + @Column(name = "modelName") private String modelName; - - 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 getValue() { - return this.value ; - } - - public void setValue(String value ) { - this.value = value ; - } - public String getModelName() { - return modelName; - } - public void setModelName(String modelName) { - this.modelName = modelName; - } - }
\ No newline at end of file diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceConfigName.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceConfigName.java index 9719abbed..ab80c582b 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceConfigName.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceConfigName.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -19,8 +20,7 @@ */ package org.onap.policy.rest.jpa; -/* - */ + import java.io.Serializable; import javax.persistence.Column; @@ -32,46 +32,27 @@ import javax.persistence.NamedQuery; import javax.persistence.OrderBy; import javax.persistence.Table; +import lombok.Getter; +import lombok.Setter; @Entity -@Table(name="MicroServiceConfigName") -@NamedQuery(name="MicroServiceConfigName.findAll", query="SELECT e FROM MicroServiceConfigName e ") +@Table(name = "MicroServiceConfigName") +@NamedQuery(name = "MicroServiceConfigName.findAll", query = "SELECT e FROM MicroServiceConfigName e ") +@Getter +@Setter + public class MicroServiceConfigName implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="name", nullable=false) + @Column(name = "name", nullable = false) @OrderBy("asc") private String name; - @Column(name="description ") - private String 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; - - } - public String getDescriptionValue() { - return this.description ; - } - - public void setDescriptionValue(String description ) { - this.description = description ; - } - + @Column(name = "description ") + private String description; } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceLocation.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceLocation.java index 669b191e7..84962d551 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceLocation.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceLocation.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -19,8 +20,7 @@ */ package org.onap.policy.rest.jpa; -/* - */ + import java.io.Serializable; import javax.persistence.Column; @@ -32,46 +32,26 @@ import javax.persistence.NamedQuery; import javax.persistence.OrderBy; import javax.persistence.Table; +import lombok.Getter; +import lombok.Setter; @Entity -@Table(name="MicroServiceLocation") -@NamedQuery(name="MicroServiceLocation.findAll", query="SELECT e FROM MicroServiceLocation e ") +@Table(name = "MicroServiceLocation") +@NamedQuery(name = "MicroServiceLocation.findAll", query = "SELECT e FROM MicroServiceLocation e ") +@Getter +@Setter public class MicroServiceLocation implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="name", nullable=false) + @Column(name = "name", nullable = false) @OrderBy("asc") private String name; - @Column(name="description ") - private String 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; - - } - public String getDescriptionValue() { - return this.description ; - } - - public void setDescriptionValue(String description ) { - this.description = description ; - } - + @Column(name = "description ") + private String description; } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceModels.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceModels.java index 1c6d811e1..ccedd6b8b 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceModels.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceModels.java @@ -3,6 +3,7 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +22,7 @@ package org.onap.policy.rest.jpa; import java.io.Serializable; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -38,12 +40,23 @@ import javax.persistence.Table; * @version: 0.1 */ +import lombok.Getter; +import lombok.Setter; +// @formatter:off @Entity @Table(name = "MicroServiceModels") -@NamedQueries({@NamedQuery(name = "MicroServiceModels.findAll", query = "SELECT b FROM MicroServiceModels b "), - @NamedQuery(name = "MicroServiceModels.findAllDecision", - query = "SELECT b FROM MicroServiceModels b WHERE b.decisionModel=1")}) +@NamedQueries( + { + @NamedQuery(name = "MicroServiceModels.findAll", query = "SELECT b FROM MicroServiceModels b "), + @NamedQuery( + name = "MicroServiceModels.findAllDecision", + query = "SELECT b FROM MicroServiceModels b WHERE b.decisionModel=1") + } +) +@Getter +@Setter +// @formatter:on public class MicroServiceModels implements Serializable { private static final long serialVersionUID = 1L; @@ -66,10 +79,10 @@ public class MicroServiceModels implements Serializable { private String attributes; @Column(name = "ref_attributes", nullable = false, length = 255) - private String ref_attributes; + private String refAttributes; @Column(name = "sub_attributes", nullable = false, length = 2000) - private String sub_attributes; + private String subAttributes; @Column(name = "dataOrderInfo", nullable = true, length = 2000) private String dataOrderInfo; @@ -89,120 +102,11 @@ public class MicroServiceModels implements Serializable { @Column(name = "ruleFormation", nullable = true) private String ruleFormation; - public String getRuleFormation() { - return ruleFormation; - } - - public void setRuleFormation(String ruleFormation) { - this.ruleFormation = ruleFormation; - } - - public String getSub_attributes() { - return sub_attributes; - } - - public void setSub_attributes(String sub_attributes) { - this.sub_attributes = sub_attributes; - } - - public String getDataOrderInfo() { - return dataOrderInfo; - } - - public void setDataOrderInfo(String dataOrderInfo) { - this.dataOrderInfo = dataOrderInfo; - } - - 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 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; - } - - public String getEnumValues() { - return enumValues; - } - - public void setEnumValues(String enumValues) { - this.enumValues = enumValues; - } - - public String getAnnotation() { - return annotation; - } - - public void setAnnotation(String annotation) { - this.annotation = annotation; - } - - public Boolean isDecisionModel() { + public boolean isDecisionModel() { return decisionModel; } - - public void setDecisionModel(boolean decisionModel) { - this.decisionModel = decisionModel; - } } - diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroserviceHeaderdeFaults.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroserviceHeaderdeFaults.java index 5098628b0..c7708abb3 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroserviceHeaderdeFaults.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroserviceHeaderdeFaults.java @@ -3,6 +3,7 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,89 +34,55 @@ import javax.persistence.PrePersist; import javax.persistence.PreUpdate; import javax.persistence.Table; +import lombok.Getter; +import lombok.Setter; + @Entity -@Table(name="MicroserviceHeaderdeFaults") -@NamedQuery(name="MicroserviceHeaderdeFaults.findAll", query="SELECT e FROM MicroserviceHeaderdeFaults e ") +@Table(name = "MicroserviceHeaderdeFaults") +@NamedQuery(name = "MicroserviceHeaderdeFaults.findAll", query = "SELECT e FROM MicroserviceHeaderdeFaults e ") +@Getter +@Setter public class MicroserviceHeaderdeFaults implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="onapName") + @Column(name = "onapName") private String onapName; - @Column(name="guard") - private String guard ; + @Column(name = "guard") + private String guard; - @Column(name="priority") + @Column(name = "priority") private String priority; - @Column(name="riskType") - private String riskType ; + @Column(name = "riskType") + private String riskType; - @Column(name="riskLevel") + @Column(name = "riskLevel") private String riskLevel; - @Column(name="modelName", nullable=false) + @Column(name = "modelName", nullable = false) @OrderBy("asc") private String modelName; + /** + * Called before persisting the object. + */ @PrePersist - public void prePersist() { - + public void prePersist() { + // Required for testing } + + /** + * Called before updating the object. + */ @PreUpdate public void preUpdate() { + // Required for testing } - - - public int getId() { - return this.id; - } - - public void setId(int id) { - this.id = id; - } - - public String getModelName() { - return modelName; - } - public void setModelName(String modelName) { - this.modelName = modelName; - } - public String getOnapName() { - return onapName; - } - public void setOnapName(String onapName) { - this.onapName = onapName; - } - public String getGuard() { - return guard; - } - public void setGuard(String guard) { - this.guard = guard; - } - public String getPriority() { - return priority; - } - public void setPriority(String priority) { - this.priority = priority; - } - public String getRiskType() { - return riskType; - } - public void setRiskType(String riskType) { - this.riskType = riskType; - } - public String getRiskLevel() { - return riskLevel; - } - public void setRiskLevel(String riskLevel) { - this.riskLevel = riskLevel; - } - }
\ No newline at end of file diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Obadvice.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Obadvice.java index 1c6b75d25..0734203e4 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Obadvice.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Obadvice.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -20,6 +21,8 @@ package org.onap.policy.rest.jpa; +import com.att.research.xacml.api.Identifier; + import java.io.Serializable; import java.util.Date; import java.util.HashSet; @@ -40,15 +43,17 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; -import com.att.research.xacml.api.Identifier; +import lombok.Getter; +import lombok.Setter; /** * The persistent class for the Obadvice database table. - * */ @Entity -@Table(name="Obadvice") -@NamedQuery(name="Obadvice.findAll", query="SELECT o FROM Obadvice o") +@Table(name = "Obadvice") +@NamedQuery(name = "Obadvice.findAll", query = "SELECT o FROM Obadvice o") +@Getter +@Setter public class Obadvice implements Serializable { private static final long serialVersionUID = 1L; @@ -58,44 +63,53 @@ public class Obadvice implements Serializable { public static final String EFFECT_DENY = "Deny"; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="type", nullable=false) + @Column(name = "type", nullable = false) private String type; - @Column(name="xacml_id", nullable=false, length=255) + @Column(name = "xacml_id", nullable = false, length = 255) private String xacmlId; - @Column(name="fulfill_on", nullable=true, length=32) + @Column(name = "fulfill_on", nullable = true, length = 32) private String fulfillOn; - @Column(name="description", nullable=true, length=2048) + @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) + // bi-directional one-to-many association to Attribute Assignment + @OneToMany(mappedBy = "obadvice", orphanRemoval = true, cascade = CascadeType.REMOVE) private Set<ObadviceExpression> obadviceExpressions = new HashSet<>(2); - @Column(name="created_by", nullable=false, length=255) + @Column(name = "created_by", nullable = false, length = 255) private String createdBy; @Temporal(TemporalType.TIMESTAMP) - @Column(name="created_date", nullable=false, updatable=false) + @Column(name = "created_date", nullable = false, updatable = false) private Date createdDate; - @Column(name="modified_by", nullable=false, length=255) + @Column(name = "modified_by", nullable = false, length = 255) private String modifiedBy; @Temporal(TemporalType.TIMESTAMP) - @Column(name="modified_date", nullable=false) + @Column(name = "modified_date", nullable = false) private Date modifiedDate; + /** + * Instantiates a new obadvice. + */ public Obadvice() { this.type = Obadvice.OBLIGATION; this.fulfillOn = Obadvice.EFFECT_PERMIT; } + /** + * Instantiates a new obadvice. + * + * @param domain the domain + * @param userid the userid + */ public Obadvice(String domain, String userid) { this.xacmlId = domain; this.type = Obadvice.OBLIGATION; @@ -104,86 +118,40 @@ public class Obadvice implements Serializable { this.modifiedBy = userid; } + /** + * Instantiates a new obadvice. + * + * @param id the id + * @param userid the userid + */ public Obadvice(Identifier id, String userid) { this(id.stringValue(), userid); } + /** + * Pre persist. + */ @PrePersist - public void prePersist() { + public void prePersist() { Date date = new Date(); this.createdDate = date; this.modifiedDate = date; } + /** + * Pre update. + */ @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<ObadviceExpression> getObadviceExpressions() { - return this.obadviceExpressions; - } - - public void setObadviceExpressions(Set<ObadviceExpression> obadviceExpressions) { - this.obadviceExpressions = obadviceExpressions; - } - + /** + * Adds the obadvice expression. + * + * @param obadviceExpression the obadvice expression + * @return the obadvice expression + */ public ObadviceExpression addObadviceExpression(ObadviceExpression obadviceExpression) { this.obadviceExpressions.add(obadviceExpression); obadviceExpression.setObadvice(this); @@ -191,6 +159,12 @@ public class Obadvice implements Serializable { return obadviceExpression; } + /** + * Removes the obadvice expression. + * + * @param obadviceExpression the obadvice expression + * @return the obadvice expression + */ public ObadviceExpression removeObadviceExpression(ObadviceExpression obadviceExpression) { this.obadviceExpressions.remove(obadviceExpression); obadviceExpression.setObadvice(null); @@ -198,6 +172,9 @@ public class Obadvice implements Serializable { return obadviceExpression; } + /** + * Removes the all expressions. + */ public void removeAllExpressions() { if (this.obadviceExpressions == null) { return; @@ -208,6 +185,11 @@ public class Obadvice implements Serializable { this.obadviceExpressions.clear(); } + /** + * Clone. + * + * @return the obadvice + */ @Transient @Override public Obadvice clone() { @@ -219,7 +201,7 @@ public class Obadvice implements Serializable { obadvice.description = this.description; obadvice.createdBy = this.createdBy; obadvice.modifiedBy = this.modifiedBy; - for (ObadviceExpression exp: this.obadviceExpressions) { + for (ObadviceExpression exp : this.obadviceExpressions) { obadvice.addObadviceExpression(exp.clone()); } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ObadviceExpression.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ObadviceExpression.java index 9d82b7325..db437095c 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ObadviceExpression.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ObadviceExpression.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -33,14 +34,17 @@ import javax.persistence.NamedQuery; import javax.persistence.OneToOne; import javax.persistence.Table; +import lombok.Getter; +import lombok.Setter; /** * The persistent class for the ObadviceExpressions database table. - * */ @Entity -@Table(name="ObadviceExpressions") -@NamedQuery(name="ObadviceExpression.findAll", query="SELECT o FROM ObadviceExpression o") +@Table(name = "ObadviceExpressions") +@NamedQuery(name = "ObadviceExpression.findAll", query = "SELECT o FROM ObadviceExpression o") +@Getter +@Setter public class ObadviceExpression implements Serializable { private static final long serialVersionUID = 1L; @@ -53,58 +57,26 @@ public class ObadviceExpression implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - //unidirectional one-to-one association to Attribute + // unidirectional one-to-one association to Attribute @OneToOne - @JoinColumn(name="attribute_id") + @JoinColumn(name = "attribute_id") private Attribute attribute; - @Column(name="type", nullable=false) + @Column(name = "type", nullable = false) private String type; - //bi-directional many-to-one association to Obadvice + // bi-directional many-to-one association to Obadvice @ManyToOne - @JoinColumn(name="obadvice_id") + @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; - } - @Override public ObadviceExpression clone() { ObadviceExpression expression = new ObadviceExpression(); diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OnapName.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OnapName.java index 0b39129a8..e128241ec 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OnapName.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OnapName.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -19,8 +20,7 @@ */ package org.onap.policy.rest.jpa; -/* - */ + import java.io.Serializable; import java.util.Date; @@ -39,106 +39,63 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import lombok.Getter; +import lombok.Setter; +/** + * The Class OnapName. + */ @Entity -@Table(name="OnapName") -@NamedQuery(name="OnapName.findAll", query="SELECT e FROM OnapName e ") +@Table(name = "OnapName") +@NamedQuery(name = "OnapName.findAll", query = "SELECT e FROM OnapName e ") +@Getter +@Setter public class OnapName implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="onap_Name", nullable=false, unique=true) + @Column(name = "onap_Name", nullable = false, unique = true) @OrderBy("asc") - private String onapName; + private String name; @Temporal(TemporalType.TIMESTAMP) - @Column(name="created_date", updatable=false) + @Column(name = "created_date", updatable = false) private Date createdDate; - @Column(name="description", nullable=true, length=2048) + @Column(name = "description", nullable = true, length = 2048) private String description; @Temporal(TemporalType.TIMESTAMP) - @Column(name="modified_date", nullable=false) + @Column(name = "modified_date", nullable = false) private Date modifiedDate; @ManyToOne(optional = false) - @JoinColumn(name="created_by") + @JoinColumn(name = "created_by") private UserInfo userCreatedBy; @ManyToOne(optional = false) - @JoinColumn(name="modified_by") + @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; - } - + /** + * Pre persist. + */ @PrePersist - public void prePersist() { + public void prePersist() { Date date = new Date(); this.createdDate = date; this.modifiedDate = date; } + /** + * Pre update. + */ @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); } - public String getOnapName() { - return this.onapName; - } - - public void setOnapName(String onapName) { - this.onapName = onapName; - - } - 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/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OptimizationModels.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OptimizationModels.java index 60b360029..457ca7382 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OptimizationModels.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OptimizationModels.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -17,6 +18,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.policy.rest.jpa; import java.io.Serializable; @@ -32,151 +34,59 @@ import javax.persistence.NamedQuery; import javax.persistence.OrderBy; import javax.persistence.Table; /* - * JPA for the OOF Models. - * + * JPA for the OOF Models. + * * @version: 0.1 */ +import lombok.Getter; +import lombok.Setter; @Entity -@Table(name="OptimizationModels") -@NamedQuery(name="OptimizationModels.findAll", query="SELECT b FROM OptimizationModels b ") -public class OptimizationModels implements Serializable{ +@Table(name = "OptimizationModels") +@NamedQuery(name = "OptimizationModels.findAll", query = "SELECT b FROM OptimizationModels b ") +@Getter +@Setter +public class OptimizationModels implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="modelName", nullable=false, unique=true) + @Column(name = "modelName", nullable = false, unique = true) @OrderBy("asc") private String modelName; - @Column(name="description", nullable=true, length=2048) + @Column(name = "description", nullable = true, length = 2048) private String description; - @Column(name="dependency", nullable=true, length=2048) + @Column(name = "dependency", nullable = true, length = 2048) private String dependency; - @Column(name="attributes", nullable=false, length=255) + @Column(name = "attributes", nullable = false, length = 255) private String attributes; - @Column(name="ref_attributes", nullable=false, length=255) + @Column(name = "ref_attributes", nullable = false, length = 255) private String refattributes; - @Column (name="sub_attributes", nullable=false, length=2000) + @Column(name = "sub_attributes", nullable = false, length = 2000) private String subattributes; - @Column (name="dataOrderInfo", nullable=true, length=2000) + @Column(name = "dataOrderInfo", nullable = true, length = 2000) private String dataOrderInfo; - @Column (name="version", nullable=false, length=2000) + @Column(name = "version", nullable = false, length = 2000) private String version; - @Column (name="enumValues", nullable=false, length=2000) + @Column(name = "enumValues", nullable = false, length = 2000) private String enumValues; - @Column (name="annotation", nullable=false, length=2000) + @Column(name = "annotation", nullable = false, length = 2000) private String annotation; - public String getSubattributes() { - return subattributes; - } - - public void setSubattributes(String subattributes) { - this.subattributes = subattributes; - } - - public String getDataOrderInfo() { - return dataOrderInfo; - } - - public void setDataOrderInfo(String dataOrderInfo) { - this.dataOrderInfo = dataOrderInfo; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - @ManyToOne - @JoinColumn(name="imported_by") + @JoinColumn(name = "imported_by") private UserInfo userCreatedBy; - - public UserInfo getUserCreatedBy() { - return userCreatedBy; - } - - public void setUserCreatedBy(UserInfo userCreatedBy) { - this.userCreatedBy = userCreatedBy; - } - - public String getAttributes() { - return attributes; - } - - public void setAttributes(String attributes) { - this.attributes = attributes; - } - - public String getRefattributes() { - return refattributes; - } - - public void setRefattributes(String refattributes) { - this.refattributes = refattributes; - } - - 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; - } - - public String getEnumValues() { - return enumValues; - } - - public void setEnumValues(String enumValues) { - this.enumValues = enumValues; - } - - public String getAnnotation() { - return annotation; - } - - public void setAnnotation(String annotation) { - this.annotation = annotation; - } } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPConfigParam.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPConfigParam.java deleted file mode 100644 index 0f32de6d3..000000000 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPConfigParam.java +++ /dev/null @@ -1,148 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP-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.onap.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() { - //An empty constructor - } - - 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/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPResolverParam.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPResolverParam.java deleted file mode 100644 index 7356eebf8..000000000 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPResolverParam.java +++ /dev/null @@ -1,148 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP-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.onap.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() { - // Empty constructor - } - - 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/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PdpEntity.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PdpEntity.java index 92c0c9dbe..69ad3f572 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PdpEntity.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PdpEntity.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -19,8 +20,7 @@ */ package org.onap.policy.rest.jpa; -/* - */ + import java.io.Serializable; import java.util.Date; @@ -39,108 +39,95 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; -/* - * The Entity class to persist a policy object and its configuration data - */ +import lombok.Getter; +import lombok.Setter; /** - * + * The Entity class to persist a policy object and its configuration data. */ +// @formatter:off @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") -}) - +// 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") + } +) +@Getter +@Setter +// @formatter:on public class PdpEntity implements Serializable { private static final long serialVersionUID = 1L; @Id - //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqPdp") + // @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqPdp") @GeneratedValue(strategy = GenerationType.AUTO) - @Column (name="pdpKey") + @Column(name = "pdpKey") private long pdpKey; - @Column (name="pdpId", nullable=false, unique=false, length=255) + @Column(name = "pdpId", nullable = false, unique = false, length = 255) private String pdpId; - @Column(name="pdpName", nullable=false, unique=false, length=255) + @Column(name = "pdpName", nullable = false, unique = false, length = 255) private String pdpName; - @Column(name="jmxPort", nullable=false, unique=false) + @Column(name = "jmxPort", nullable = false, unique = false) private int jmxPort; - - @ManyToOne(optional=false) - @JoinColumn(name="groupKey", referencedColumnName="groupKey") + @ManyToOne(optional = false) + @JoinColumn(name = "groupKey", referencedColumnName = "groupKey") private GroupEntity groupEntity; - @Column(name="created_by", nullable=false, length=255) + @Column(name = "created_by", nullable = false, length = 255) private String createdBy = "guest"; @Temporal(TemporalType.TIMESTAMP) - @Column(name="created_date", updatable=false) + @Column(name = "created_date", updatable = false) private Date createdDate; - @Column(name="description", nullable=false, length=2048) + @Column(name = "description", nullable = false, length = 2048) private String description = "NoDescription"; - @Column(name="modified_by", nullable=false, length=255) + @Column(name = "modified_by", nullable = false, length = 255) private String modifiedBy = "guest"; @Temporal(TemporalType.TIMESTAMP) - @Column(name="modified_date", nullable=false) + @Column(name = "modified_date", nullable = false) private Date modifiedDate; - @Column(name="deleted", nullable=false) + @Column(name = "deleted", nullable = false) private boolean deleted = false; + /** + * Instantiates a new pdp entity. + */ public PdpEntity() { super(); } + /** + * Pre persist. + */ @PrePersist - public void prePersist() { + public void prePersist() { Date date = new Date(); this.createdDate = date; this.modifiedDate = date; } + /** + * Pre update. + */ @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; - } - - - /** + * Gets the group. + * * @return the configurationDataEntity */ public GroupEntity getGroup() { @@ -148,94 +135,11 @@ public class PdpEntity implements Serializable { } /** - * @param configurationDataEntity the configurationDataEntity to set + * Sets the group. + * + * @param group the new group */ 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/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PEPOptions.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PepOptions.java index f9413b860..3a5f791de 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PEPOptions.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PepOptions.java @@ -3,6 +3,7 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,11 +20,13 @@ */ package org.onap.policy.rest.jpa; + /* * * */ import java.io.Serializable; import java.util.Date; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -39,121 +42,73 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import lombok.Getter; +import lombok.Setter; +/** + * The Class PepOptions. + */ @Entity -@Table(name = "PEPOptions") -@NamedQuery(name = "PEPOptions.findAll", query= "Select p from PEPOptions p") -public class PEPOptions implements Serializable { +@Table(name = "PepOptions") +@NamedQuery(name = "PepOptions.findAll", query = "Select p from PepOptions p") +@Getter +@Setter +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) + @Column(name = "PEP_NAME", nullable = false) @OrderBy("asc") private String pepName; - @Column(name="description", nullable=true, length=2048) + @Column(name = "description", nullable = true, length = 2048) private String description; - @Column(name="Actions", nullable=true) + @Column(name = "Actions", nullable = true) @OrderBy("asc") private String actions; @Temporal(TemporalType.TIMESTAMP) - @Column(name="created_date", updatable=false) + @Column(name = "created_date", updatable = false) private Date createdDate; @Temporal(TemporalType.TIMESTAMP) - @Column(name="modified_date", nullable=false) + @Column(name = "modified_date", nullable = false) private Date modifiedDate; @ManyToOne(optional = false) - @JoinColumn(name="created_by") + @JoinColumn(name = "created_by") private UserInfo userCreatedBy; @ManyToOne(optional = false) - @JoinColumn(name="modified_by") + @JoinColumn(name = "modified_by") private UserInfo userModifiedBy; - public PEPOptions() { + /** + * Instantiates a new PEP options. + */ + public PepOptions() { this.modifiedDate = new Date(); } - 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; - } - + /** + * Pre persist. + */ @PrePersist - public void prePersist() { + public void prePersist() { Date date = new Date(); this.createdDate = date; this.modifiedDate = date; } + /** + * Pre update. + */ @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); } - - 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/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipConfigParam.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipConfigParam.java new file mode 100644 index 000000000..06f6bef61 --- /dev/null +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipConfigParam.java @@ -0,0 +1,135 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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.onap.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; +import javax.persistence.Transient; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +/** + * The persistent class for the PipConfigParams database table. + * + */ +@Entity +@Table(name = "PipConfigParams") +@NamedQuery(name = "PipConfigParam.findAll", query = "SELECT p FROM PipConfigParam p") +@Getter +@Setter +@ToString +/** + * Instantiates a new PIP config param. + */ +@NoArgsConstructor +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; + + /** + * Instantiates a new PIP config param. + * + * @param param the param + */ + public PipConfigParam(String param) { + this.paramName = param; + } + + /** + * Instantiates a new PIP config param. + * + * @param param the param + * @param value the value + */ + public PipConfigParam(String param, String value) { + this(param); + this.paramValue = value; + } + + /** + * Instantiates a new PIP config param. + * + * @param param the param + */ + public PipConfigParam(PipConfigParam param) { + this(param.getParamName(), param.getParamValue()); + this.paramDefault = param.getParamDefault(); + this.required = param.required; + } + + /** + * Checks if is required. + * + * @return true, if is required + */ + @Transient + public boolean isRequired() { + return this.required == '1'; + } + + /** + * Sets the required flag. + * + * @param required the new required flag + */ + @Transient + public void setRequiredFlag(boolean required) { + if (required) { + this.setRequired('1'); + } else { + this.setRequired('0'); + } + } +} diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPConfiguration.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipConfiguration.java index d34c4bd0b..99bd613e8 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPConfiguration.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipConfiguration.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -20,6 +21,12 @@ package org.onap.policy.rest.jpa; +import com.att.research.xacml.api.pip.PIPException; +import com.att.research.xacml.std.pip.engines.StdConfigurableEngine; +import com.att.research.xacml.util.XACMLProperties; +import com.google.common.base.Joiner; +import com.google.common.base.Splitter; + import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; @@ -49,85 +56,89 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.onap.policy.common.logging.eelf.MessageCodes; import org.onap.policy.common.logging.eelf.PolicyLogger; import org.onap.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.util.XACMLProperties; -import com.google.common.base.Joiner; -import com.google.common.base.Splitter; - - /** - * The persistent class for the PIPConfiguration database table. - * + * 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 { +@Table(name = "PipConfiguration") +@NamedQuery(name = "PipConfiguration.findAll", query = "SELECT p FROM PipConfiguration p") +@Getter +@Setter +@NoArgsConstructor +@ToString +public class PipConfiguration implements Serializable { private static final long serialVersionUID = 1L; - private static final Log logger = LogFactory.getLog(PIPConfiguration.class); + private static final Log logger = LogFactory.getLog(PipConfiguration.class); @Id - @GeneratedValue(strategy=GenerationType.AUTO) - @Column(name="id") + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "id") private int id; - @Column(name="DESCRIPTION", nullable=true, length=2048) + @Column(name = "DESCRIPTION", nullable = true, length = 2048) private String description; - @Column(name="NAME", nullable=false, length=255) + @Column(name = "NAME", nullable = false, length = 255) private String name; - @Column(name="CLASSNAME", nullable=false, length=2048) + @Column(name = "CLASSNAME", nullable = false, length = 2048) private String classname; - @Column(name="ISSUER", nullable=true, length=1024) + @Column(name = "ISSUER", nullable = true, length = 1024) private String issuer; - @Column(name="READ_ONLY", nullable=false) + @Column(name = "READ_ONLY", nullable = false) private char readOnly = '0'; - @Column(name="REQUIRES_RESOLVER", nullable=false) + @Column(name = "REQUIRES_RESOLVER", nullable = false) private char requiresResolvers; - @Column(name="CREATED_BY", nullable=false, length=255) + @Column(name = "CREATED_BY", nullable = false, length = 255) private String createdBy = "guest"; @Temporal(TemporalType.TIMESTAMP) - @Column(name="CREATED_DATE", nullable=false, updatable=false) + @Column(name = "CREATED_DATE", nullable = false, updatable = false) private Date createdDate; - @Column(name="MODIFIED_BY", nullable=false, length=255) + @Column(name = "MODIFIED_BY", nullable = false, length = 255) private String modifiedBy = "guest"; @Temporal(TemporalType.TIMESTAMP) - @Column(name="MODIFIED_DATE", nullable=false) + @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<PIPConfigParam> pipconfigParams = new HashSet<>(); + // bi-directional many-to-one association to PipConfigParam + @OneToMany(mappedBy = "pipconfiguration", orphanRemoval = true, cascade = CascadeType.REMOVE) + private Set<PipConfigParam> pipconfigParams = new HashSet<>(); - //bi-directional many-to-one association to PIPType + // 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<PIPResolver> pipresolvers = new HashSet<>(); - - public PIPConfiguration() { - //An empty constructor - } - - public PIPConfiguration(PIPConfiguration config, String user) { + @JoinColumn(name = "TYPE") + private PipType piptype; + + // bi-directional many-to-one association to PipResolver + @OneToMany(mappedBy = "pipconfiguration", orphanRemoval = true, cascade = CascadeType.REMOVE) + private Set<PipResolver> pipresolvers = new HashSet<>(); + + /** + * Instantiates a new PIP configuration. + * + * @param config the config + * @param user the user + */ + public PipConfiguration(PipConfiguration config, String user) { this.description = config.description; this.name = config.name; this.classname = config.classname; @@ -135,108 +146,77 @@ public class PIPConfiguration implements Serializable { this.requiresResolvers = config.requiresResolvers; this.readOnly = config.readOnly; this.piptype = config.piptype; - for (PIPConfigParam param : config.pipconfigParams) { - this.addPipconfigParam(new PIPConfigParam(param)); + for (PipConfigParam param : config.pipconfigParams) { + this.addPipconfigParam(new PipConfigParam(param)); } - for (PIPResolver resolver : config.pipresolvers) { - this.addPipresolver(new PIPResolver(resolver)); + for (PipResolver resolver : config.pipresolvers) { + this.addPipresolver(new PipResolver(resolver)); } } - public PIPConfiguration(String id, Properties properties) throws PIPException { + /** + * Instantiates a new PIP configuration. + * + * @param id the id + * @param properties the properties + * @throws PIPException the PIP exception + */ + public PipConfiguration(String id, Properties properties) throws PIPException { this.readProperties(id, properties); } - public PIPConfiguration(String id, Properties properties, String user) throws PIPException { + /** + * Instantiates a new PIP configuration. + * + * @param id the id + * @param properties the properties + * @param user the user + * @throws PIPException the PIP exception + */ + public PipConfiguration(String id, Properties properties, String user) throws PIPException { this.createdBy = user; this.modifiedBy = user; this.readProperties(id, properties); } + /** + * Pre persist. + */ @PrePersist - public void prePersist() { + public void prePersist() { Date date = new Date(); this.createdDate = date; this.modifiedDate = date; } + /** + * Pre update. + */ @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<PIPConfigParam> getPipconfigParams() { - return this.pipconfigParams; - } - - public void setPipconfigParams(Set<PIPConfigParam> pipconfigParams) { - this.pipconfigParams = pipconfigParams; - } - - public PIPConfigParam addPipconfigParam(PIPConfigParam pipconfigParam) { + /** + * Adds the pipconfig param. + * + * @param pipconfigParam the pipconfig param + * @return the PIP config param + */ + public PipConfigParam addPipconfigParam(PipConfigParam pipconfigParam) { getPipconfigParams().add(pipconfigParam); pipconfigParam.setPipconfiguration(this); return pipconfigParam; } - public PIPConfigParam removePipconfigParam(PIPConfigParam pipconfigParam) { + /** + * Removes the pipconfig param. + * + * @param pipconfigParam the pipconfig param + * @return the PIP config param + */ + public PipConfigParam removePipconfigParam(PipConfigParam pipconfigParam) { if (pipconfigParam == null) { return pipconfigParam; } @@ -246,6 +226,9 @@ public class PIPConfiguration implements Serializable { return pipconfigParam; } + /** + * Clear config params. + */ @Transient public void clearConfigParams() { while (!this.pipconfigParams.isEmpty()) { @@ -253,75 +236,49 @@ public class PIPConfiguration implements Serializable { } } - public PIPType getPiptype() { - return this.piptype; - } - - public void setPiptype(PIPType piptype) { - this.piptype = piptype; - } - - public Set<PIPResolver> getPipresolvers() { - return this.pipresolvers; - } - - public void setPipresolvers(Set<PIPResolver> pipresolvers) { - this.pipresolvers = pipresolvers; - } - - public PIPResolver addPipresolver(PIPResolver pipresolver) { + /** + * Adds the pipresolver. + * + * @param pipresolver the pipresolver + * @return the PIP resolver + */ + public PipResolver addPipresolver(PipResolver pipresolver) { getPipresolvers().add(pipresolver); pipresolver.setPipconfiguration(this); return pipresolver; } - public PIPResolver removePipresolver(PIPResolver pipresolver) { + /** + * Removes the pipresolver. + * + * @param pipresolver the pipresolver + * @return the PIP resolver + */ + 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; - } - + /** + * Checks if is read only. + * + * @return true, if is read only + */ @Transient public boolean isReadOnly() { return this.readOnly == '1'; } + /** + * Sets the read only flag. + * + * @param readOnly the new read only flag + */ @Transient - public void setReadOnly(boolean readOnly) { + public void setReadOnlyFlag(boolean readOnly) { if (readOnly) { this.readOnly = '1'; } else { @@ -329,13 +286,23 @@ public class PIPConfiguration implements Serializable { } } + /** + * Requires resolvers. + * + * @return true, if successful + */ @Transient public boolean requiresResolvers() { return this.requiresResolvers == '1'; } + /** + * Sets the requires resolvers flag. + * + * @param requires the new requires resolvers flag + */ @Transient - public void setRequiresResolvers(boolean requires) { + public void setRequiresResolversFlag(boolean requires) { if (requires) { this.requiresResolvers = '1'; } else { @@ -343,32 +310,45 @@ public class PIPConfiguration implements Serializable { } } + /** + * Import PIP configurations. + * + * @param properties the properties + * @return the collection + */ @Transient - public static Collection<PIPConfiguration> importPIPConfigurations(Properties properties) { - Collection<PIPConfiguration> configurations = new ArrayList<>(); + public static Collection<PipConfiguration> importPipConfigurations(Properties properties) { + Collection<PipConfiguration> 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; + PipConfiguration configuration; try { String user = "super-admin"; - configuration = new PIPConfiguration(id, properties, user); + 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()); - PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PIPConfiguration", "Import failed"); + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PipConfiguration", "Import failed"); } } return configurations; } + /** + * Read properties. + * + * @param id the id + * @param properties the properties + * @throws PIPException the PIP exception + */ @Transient - protected void readProperties(String id, Properties properties) throws PIPException { + protected void readProperties(String id, Properties properties) throws PIPException { // // Save the id if we don't have one already // @@ -378,7 +358,7 @@ public class PIPConfiguration implements Serializable { this.id = Integer.parseInt(id); } catch (NumberFormatException e) { logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Convert id to integer failed: " + id); - PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PIPConfiguration", "Convert id to integer failed"); + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PipConfiguration", "Convert id to integer failed"); } } // @@ -391,47 +371,8 @@ public class PIPConfiguration implements Serializable { // // Go through each property // - for (Object nme : properties.keySet()) { - if (!nme.toString().startsWith(id)) { - continue; - } - if (nme.equals(id + ".classname")) { - // - // We already saved this - // - } else if (nme.equals(id + "." + StdConfigurableEngine.PROP_NAME)) { - this.name = properties.getProperty(nme.toString()); - } else if (nme.equals(id + "." + StdConfigurableEngine.PROP_DESCRIPTION)) { - this.description = properties.getProperty(nme.toString()); - } else if (nme.equals(id + "." + StdConfigurableEngine.PROP_ISSUER)) { - this.issuer = properties.getProperty(nme.toString()); - } else if (nme.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<PIPResolver> resolvers = PIPResolver.importResolvers(id + ".resolver", - properties.getProperty(nme.toString()), - properties,"super-admin" - ); - for (PIPResolver resolver : resolvers) { - this.addPipresolver(resolver); - } - } else if (nme.toString().startsWith(id + ".resolver")) { - // - // Ignore, the PIPResolver will parse these values - // - } else { - // - // Config Parameter - // - this.addPipconfigParam(new PIPConfigParam(nme.toString().substring(id.length() + 1), - properties.getProperty(nme.toString()))); - } + for (Object propertyKey : properties.keySet()) { + readProperty(id, properties, propertyKey); } // // Make sure we have a name at least @@ -441,7 +382,61 @@ public class PIPConfiguration implements Serializable { } } + /** + * Read a property into the PIP configuration. + * + * @param id the ID of the property + * @param properties the properties object to read from + * @param key the key of the property being checked + * @throws PIPException on exceptions thrown on reading the property + */ + private void readProperty(String id, Properties properties, Object key) throws PIPException { + if (!key.toString().startsWith(id)) { + return; + } + if (key.equals(id + ".classname")) { + // + // We already saved this + // + } else if (key.equals(id + "." + StdConfigurableEngine.PROP_NAME)) { + this.name = properties.getProperty(key.toString()); + } else if (key.equals(id + "." + StdConfigurableEngine.PROP_DESCRIPTION)) { + this.description = properties.getProperty(key.toString()); + } else if (key.equals(id + "." + StdConfigurableEngine.PROP_ISSUER)) { + this.issuer = properties.getProperty(key.toString()); + } else if (key.equals(id + ".resolvers")) { + // + // It has resolvers, make sure this is set to true if + // it has been already. + // + this.setRequiresResolversFlag(true); + // + // Parse the resolvers + // + Collection<PipResolver> resolvers = PipResolver.importResolvers(id + ".resolver", + properties.getProperty(key.toString()), properties, "super-admin"); + for (PipResolver resolver : resolvers) { + this.addPipresolver(resolver); + } + } else if (key.toString().startsWith(id + ".resolver")) { + // + // Ignore, the PipResolver will parse these values + // + } else { + // + // Config Parameter + // + this.addPipconfigParam(new PipConfigParam(key.toString().substring(id.length() + 1), + properties.getProperty(key.toString()))); + } + } + /** + * Gets the configuration. + * + * @param name the name + * @return the configuration + */ @Transient public Map<String, String> getConfiguration(String name) { String prefix; @@ -463,14 +458,14 @@ public class PIPConfiguration implements Serializable { map.put(prefix + "issuer", this.issuer); } - for (PIPConfigParam param : this.pipconfigParams) { + for (PipConfigParam param : this.pipconfigParams) { map.put(prefix + param.getParamName(), param.getParamValue()); } List<String> ids = new ArrayList<>(); - Iterator<PIPResolver> iter = this.pipresolvers.iterator(); + Iterator<PipResolver> iter = this.pipresolvers.iterator(); while (iter.hasNext()) { - PIPResolver resolver = iter.next(); + PipResolver resolver = iter.next(); String idd = Integer.toString(resolver.getId()); Map<String, String> resolverMap = resolver.getConfiguration(prefix + "resolver." + idd); map.putAll(resolverMap); @@ -482,8 +477,14 @@ public class PIPConfiguration implements Serializable { return map; } + /** + * Generate properties. + * + * @param name the name + * @return the properties + */ @Transient - public Properties generateProperties(String name) { + public Properties generateProperties(String name) { String prefix; if (name == null) { prefix = Integer.toString(this.id); @@ -492,10 +493,14 @@ public class PIPConfiguration implements Serializable { prefix = name; } else { prefix = name + "."; + /** + * Instantiates a new PIP configuration. + */ + } } Properties props = new Properties(); - props.setProperty("xacml.pip.engines", name); + props.setProperty("xacml.pip.engines", prefix); props.setProperty(prefix + "classname", this.classname); props.setProperty(prefix + "name", this.name); if (this.description != null) { @@ -505,14 +510,14 @@ public class PIPConfiguration implements Serializable { props.setProperty(prefix + "issuer", this.issuer); } - for (PIPConfigParam param : this.pipconfigParams) { + for (PipConfigParam param : this.pipconfigParams) { props.setProperty(prefix + param.getParamName(), param.getParamValue()); } List<String> ids = new ArrayList<>(); - Iterator<PIPResolver> iter = this.pipresolvers.iterator(); + Iterator<PipResolver> iter = this.pipresolvers.iterator(); while (iter.hasNext()) { - PIPResolver resolver = iter.next(); + PipResolver resolver = iter.next(); String idd = Integer.toString(resolver.getId()); resolver.generateProperties(props, prefix + "resolver." + idd); ids.add(idd); @@ -522,17 +527,4 @@ public class PIPConfiguration implements Serializable { } 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/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPResolver.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipResolver.java index a8b02580d..74e24b3db 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPResolver.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipResolver.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -20,6 +21,10 @@ package org.onap.policy.rest.jpa; +import com.att.research.xacml.api.pip.PIPException; +import com.att.research.xacml.std.pip.engines.StdConfigurableEngine; +import com.google.common.base.Splitter; + import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; @@ -47,202 +52,135 @@ 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; - +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; /** - * The persistent class for the PIPResolver database table. - * + * 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 { +@Table(name = "PipResolver") +@NamedQuery(name = "PipResolver.findAll", query = "SELECT p FROM PipResolver p") +@Getter +@Setter +@NoArgsConstructor +public class PipResolver implements Serializable { private static final long serialVersionUID = 1L; @Id - @GeneratedValue(strategy=GenerationType.AUTO) - @Column(name="id") + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "id") private int id; - @Column(name="DESCRIPTION", nullable=true, length=2048) + @Column(name = "DESCRIPTION", nullable = true, length = 2048) private String description; - @Column(name="NAME", nullable=false, length=255) + @Column(name = "NAME", nullable = false, length = 255) private String name; - @Column(name="ISSUER", nullable=true, length=1024) + @Column(name = "ISSUER", nullable = true, length = 1024) private String issuer; - @Column(name="CLASSNAME", nullable=false, length=2048) + @Column(name = "CLASSNAME", nullable = false, length = 2048) private String classname; - @Column(name="READ_ONLY", nullable=false) + @Column(name = "READ_ONLY", nullable = false) private char readOnly = '0'; - @Column(name="CREATED_BY", nullable=false, length=255) + @Column(name = "CREATED_BY", nullable = false, length = 255) private String createdBy = "guest"; @Temporal(TemporalType.TIMESTAMP) - @Column(name="CREATED_DATE", nullable=false, updatable=false) + @Column(name = "CREATED_DATE", nullable = false, updatable = false) private Date createdDate; - @Column(name="MODIFIED_BY", nullable=false, length=255) + @Column(name = "MODIFIED_BY", nullable = false, length = 255) private String modifiedBy = "guest"; @Temporal(TemporalType.TIMESTAMP) - @Column(name="MODIFIED_DATE", nullable=false) + @Column(name = "MODIFIED_DATE", nullable = false) private Date modifiedDate; - //bi-directional many-to-one association to PIPConfiguration + // 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<PIPResolverParam> pipresolverParams = new HashSet<>(); - - public PIPResolver() { - //An empty constructor - } - - public PIPResolver(String prefix, Properties properties, String user) throws PIPException { + @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<PipResolverParam> pipresolverParams = new HashSet<>(); + + /** + * Instantiates a new PIP resolver. + * + * @param prefix the prefix + * @param properties the properties + * @param user the user + * @throws PIPException the PIP exception + */ + 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) { + /** + * Instantiates a new PIP resolver. + * + * @param resolver the resolver + */ + 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)); + for (PipResolverParam param : resolver.pipresolverParams) { + this.addPipresolverParam(new PipResolverParam(param)); } } + /** + * Pre persist. + */ @PrePersist - public void prePersist() { + public void prePersist() { Date date = new Date(); this.createdDate = date; this.modifiedDate = date; } + /** + * Pre update. + */ @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<PIPResolverParam> getPipresolverParams() { - return this.pipresolverParams; - } - - public void setPipresolverParams(Set<PIPResolverParam> pipresolverParams) { - this.pipresolverParams = pipresolverParams; - } - - public PIPResolverParam addPipresolverParam(PIPResolverParam pipresolverParam) { + /** + * Adds the pipresolver param. + * + * @param pipresolverParam the pipresolver param + * @return the PIP resolver param + */ + public PipResolverParam addPipresolverParam(PipResolverParam pipresolverParam) { getPipresolverParams().add(pipresolverParam); pipresolverParam.setPipresolver(this); return pipresolverParam; } - public PIPResolverParam removePipresolverParam(PIPResolverParam pipresolverParam) { + /** + * Removes the pipresolver param. + * + * @param pipresolverParam the pipresolver param + * @return the PIP resolver param + */ + public PipResolverParam removePipresolverParam(PipResolverParam pipresolverParam) { if (pipresolverParam == null) { return pipresolverParam; } @@ -252,6 +190,9 @@ public class PIPResolver implements Serializable { return pipresolverParam; } + /** + * Clear params. + */ @Transient public void clearParams() { while (!this.pipresolverParams.isEmpty()) { @@ -259,11 +200,21 @@ public class PIPResolver implements Serializable { } } + /** + * Checks if is read only. + * + * @return true, if is read only + */ @Transient public boolean isReadOnly() { return this.readOnly == '1'; } + /** + * Sets the read only. + * + * @param readOnly the new read only + */ @Transient public void setReadOnly(boolean readOnly) { if (readOnly) { @@ -273,15 +224,33 @@ public class PIPResolver implements Serializable { } } + /** + * Import resolvers. + * + * @param prefix the prefix + * @param list the list + * @param properties the properties + * @param user the user + * @return the collection + * @throws PIPException the PIP exception + */ @Transient - public static Collection<PIPResolver> importResolvers(String prefix, String list, Properties properties, String user) throws PIPException { - Collection<PIPResolver> resolvers = new ArrayList<>(); + public static Collection<PipResolver> importResolvers(String prefix, String list, Properties properties, + String user) throws PIPException { + Collection<PipResolver> resolvers = new ArrayList<>(); for (String id : Splitter.on(',').trimResults().omitEmptyStrings().split(list)) { - resolvers.add(new PIPResolver(prefix + "." + id, properties, user)); + resolvers.add(new PipResolver(prefix + "." + id, properties, user)); } return resolvers; } + /** + * Read properties. + * + * @param prefix the prefix + * @param properties the properties + * @throws PIPException the PIP exception + */ @Transient protected void readProperties(String prefix, Properties properties) throws PIPException { // @@ -309,12 +278,18 @@ public class PIPResolver implements Serializable { } else if (nme.equals(prefix + "." + StdConfigurableEngine.PROP_ISSUER)) { this.issuer = properties.getProperty(nme.toString()); } else { - this.addPipresolverParam(new PIPResolverParam(nme.toString().substring(prefix.length() + 1), - properties.getProperty(nme.toString()))); + this.addPipresolverParam(new PipResolverParam(nme.toString().substring(prefix.length() + 1), + properties.getProperty(nme.toString()))); } } } + /** + * Gets the configuration. + * + * @param prefix the prefix + * @return the configuration + */ @Transient public Map<String, String> getConfiguration(String prefix) { String pref = prefix; @@ -330,14 +305,20 @@ public class PIPResolver implements Serializable { if (this.issuer != null && this.issuer.isEmpty()) { map.put(pref + "issuer", this.issuer); } - for (PIPResolverParam param : this.pipresolverParams) { + for (PipResolverParam param : this.pipresolverParams) { map.put(pref + param.getParamName(), param.getParamValue()); } return map; } + /** + * Generate properties. + * + * @param props the props + * @param prefix the prefix + */ @Transient - public void generateProperties(Properties props, String prefix) { + public void generateProperties(Properties props, String prefix) { String pref = prefix; if (!prefix.endsWith(".")) { pref = prefix + "."; @@ -350,19 +331,22 @@ public class PIPResolver implements Serializable { if (this.issuer != null && this.issuer.isEmpty()) { props.setProperty(pref + "issuer", this.issuer); } - for (PIPResolverParam param : this.pipresolverParams) { + for (PipResolverParam param : this.pipresolverParams) { props.setProperty(pref + param.getParamName(), param.getParamValue()); } } + /** + * To string. + * + * @return the string + */ @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 + "]"; + 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/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipResolverParam.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipResolverParam.java new file mode 100644 index 000000000..3dd096862 --- /dev/null +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipResolverParam.java @@ -0,0 +1,132 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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.onap.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; +import javax.persistence.Transient; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +/** + * The persistent class for the PipResolverParam database table. + * + */ +@Entity +@Table(name = "PipResolverParams") +@NamedQuery(name = "PipResolverParam.findAll", query = "SELECT p FROM PipResolverParam p") +@Getter +@Setter +@NoArgsConstructor +@ToString +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; + + /** + * Instantiates a new PIP resolver param. + * + * @param name the name + */ + public PipResolverParam(String name) { + this.paramName = name; + } + + /** + * Instantiates a new PIP resolver param. + * + * @param name the name + * @param value the value + */ + public PipResolverParam(String name, String value) { + this(name); + this.paramValue = value; + } + + /** + * Instantiates a new PIP resolver param. + * + * @param param the param + */ + public PipResolverParam(PipResolverParam param) { + this(param.getParamName(), param.getParamValue()); + this.paramDefault = param.getParamDefault(); + this.required = param.required; + } + + /** + * Checks if is required. + * + * @return true, if is required + */ + @Transient + public boolean isRequired() { + return this.required == '1'; + } + + /** + * Sets the required. + * + * @param required the new required + */ + @Transient + public void setRequired(boolean required) { + if (required) { + this.required = '1'; + } else { + this.required = '0'; + } + } +} diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPType.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipType.java index aa8c45ef2..0179d0d33 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPType.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipType.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -33,15 +34,21 @@ import javax.persistence.OneToMany; import javax.persistence.Table; import javax.persistence.Transient; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; /** - * The persistent class for the PIPType database table. - * + * 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 { +@Table(name = "PipType") +@NamedQuery(name = "PipType.findAll", query = "SELECT p FROM PipType p") +@Getter +@Setter +@NoArgsConstructor +public class PipType implements Serializable { private static final long serialVersionUID = 1L; public static final String TYPE_SQL = "SQL"; @@ -51,81 +58,90 @@ public class PIPType implements Serializable { public static final String TYPE_CUSTOM = "Custom"; @Id - @GeneratedValue(strategy=GenerationType.AUTO) - @Column(name="id") + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "id") private int id; - @Column(name="type", nullable=false, length=45) + @Column(name = "type", nullable = false, length = 45) private String type; - //bi-directional many-to-one association to PIPConfiguration - @OneToMany(mappedBy="piptype") - private Set<PIPConfiguration> pipconfigurations; - - public PIPType() { - // Empty constructor - } - - 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<PIPConfiguration> getPipconfigurations() { - return this.pipconfigurations; - } - - public void setPipconfigurations(Set<PIPConfiguration> pipconfigurations) { - this.pipconfigurations = pipconfigurations; - } - - public PIPConfiguration addPipconfiguration(PIPConfiguration pipconfiguration) { + // bi-directional many-to-one association to PipConfiguration + @OneToMany(mappedBy = "piptype") + private Set<PipConfiguration> pipconfigurations; + + /** + * Adds the pipconfiguration. + * + * @param pipconfiguration the pipconfiguration + * @return the PIP configuration + */ + public PipConfiguration addPipconfiguration(PipConfiguration pipconfiguration) { getPipconfigurations().add(pipconfiguration); pipconfiguration.setPiptype(this); return pipconfiguration; } - public PIPConfiguration removePipconfiguration(PIPConfiguration pipconfiguration) { + /** + * Removes the pipconfiguration. + * + * @param pipconfiguration the pipconfiguration + * @return the PIP configuration + */ + public PipConfiguration removePipconfiguration(PipConfiguration pipconfiguration) { getPipconfigurations().remove(pipconfiguration); pipconfiguration.setPiptype(null); return pipconfiguration; } + /** + * Checks if is sql. + * + * @return true, if is sql + */ @Transient - public boolean isSQL() { + public boolean isSql() { return this.type.equals(TYPE_SQL); } + /** + * Checks if is ldap. + * + * @return true, if is ldap + */ @Transient - public boolean isLDAP() { + public boolean isLdap() { return this.type.equals(TYPE_LDAP); } + /** + * Checks if is csv. + * + * @return true, if is csv + */ @Transient - public boolean isCSV() { + public boolean isCsv() { return this.type.equals(TYPE_CSV); } + /** + * Checks if is hyper CSV. + * + * @return true, if is hyper CSV + */ @Transient - public boolean isHyperCSV() { + public boolean isHyperCsv() { return this.type.equals(TYPE_HYPERCSV); } + /** + * Checks if is custom. + * + * @return true, if is custom + */ @Transient - public boolean isCustom() { + public boolean isCustom() { return this.type.equals(TYPE_CUSTOM); } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAlgorithms.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAlgorithms.java index ba1097500..0f23f55da 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAlgorithms.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAlgorithms.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -20,6 +21,8 @@ package org.onap.policy.rest.jpa; +import com.att.research.xacml.api.Identifier; + import java.io.Serializable; import javax.persistence.Column; @@ -31,11 +34,17 @@ import javax.persistence.NamedQuery; import javax.persistence.Table; import javax.persistence.Transient; -import com.att.research.xacml.api.Identifier; +import lombok.Getter; +import lombok.Setter; +/** + * The Class PolicyAlgorithms. + */ @Entity -@Table(name="PolicyAlgorithms") -@NamedQuery(name="PolicyAlgorithms.findAll", query="SELECT d FROM PolicyAlgorithms d") +@Table(name = "PolicyAlgorithms") +@NamedQuery(name = "PolicyAlgorithms.findAll", query = "SELECT d FROM PolicyAlgorithms d") +@Getter +@Setter public class PolicyAlgorithms implements Serializable { private static final long serialVersionUID = 1L; @@ -44,18 +53,24 @@ public class PolicyAlgorithms implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="is_standard", nullable=false) + @Column(name = "is_standard", nullable = false) private char isStandard; - @Column(name="xacml_id", nullable=false, unique=true, length=255) + @Column(name = "xacml_id", nullable = false, unique = true, length = 255) private String xacmlId; - @Column(name="short_name", nullable=false, length=64) + @Column(name = "short_name", nullable = false, length = 64) private String shortName; + /** + * Instantiates a new policy algorithms. + * + * @param identifier the identifier + * @param standard the standard + */ public PolicyAlgorithms(Identifier identifier, char standard) { this.isStandard = standard; if (identifier != null) { @@ -63,54 +78,39 @@ public class PolicyAlgorithms implements Serializable { } } + /** + * Instantiates a new policy algorithms. + * + * @param identifier the identifier + */ public PolicyAlgorithms(Identifier identifier) { this(identifier, PolicyAlgorithms.STANDARD); } + /** + * Instantiates a new policy algorithms. + */ 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; - } - + /** + * Checks if is standard. + * + * @return true, if is standard + */ @Transient public boolean isStandard() { return this.isStandard == PolicyAlgorithms.STANDARD; } + /** + * Checks if is custom. + * + * @return true, if is custom + */ @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/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAuditlog.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAuditlog.java index bfd7769b4..75924e867 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAuditlog.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAuditlog.java @@ -3,6 +3,7 @@ * ONAP-PAP-REST * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +22,7 @@ package org.onap.policy.rest.jpa; import java.util.Date; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -29,11 +31,15 @@ import javax.persistence.Id; import javax.persistence.NamedQuery; import javax.persistence.Table; +import lombok.Getter; +import lombok.Setter; + @Entity @Table(name = "policyAuditlog") @NamedQuery(name = "policyAuditlog.findAll", query = "SELECT v FROM PolicyAuditlog v ") +@Getter +@Setter public class PolicyAuditlog { - private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id", nullable = false, unique = true) @@ -50,44 +56,4 @@ public class PolicyAuditlog { @Column(name = "dateAndTime", nullable = false) private Date dateAndTime; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getPolicyName() { - return policyName; - } - - public void setPolicyName(String policyName) { - this.policyName = policyName; - } - - public String getActions() { - return actions; - } - - public void setActions(String actions) { - this.actions = actions; - } - - public Date getDateAndTime() { - return dateAndTime; - } - - public void setDateAndTime(Date dateAndTime) { - this.dateAndTime = dateAndTime; - } } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyDBDaoEntity.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyDBDaoEntity.java deleted file mode 100644 index 7a0c2fe2f..000000000 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyDBDaoEntity.java +++ /dev/null @@ -1,150 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP-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.onap.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/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyDbDaoEntity.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyDbDaoEntity.java new file mode 100644 index 000000000..fbad21763 --- /dev/null +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyDbDaoEntity.java @@ -0,0 +1,107 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP-REST + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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.onap.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; + +import lombok.Getter; +import lombok.Setter; + +/** + * The Entity class to persist a PolicyDbDaoEntity object for registration of PolicyDBDao. + */ +// @formatter:off +@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") + } +) +@Getter +@Setter +//@formatter:on +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; + + /** + * Instantiates a new policy DB dao entity. + */ + public PolicyDbDaoEntity() { + super(); + } + + /** + * Pre persist. + */ + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + /** + * Pre update. + */ + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + } +} diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEditorScopes.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEditorScopes.java index 62fd0266e..7642a1417 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEditorScopes.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEditorScopes.java @@ -3,6 +3,7 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +23,7 @@ package org.onap.policy.rest.jpa; import java.io.Serializable; import java.util.Date; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -37,99 +39,67 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import lombok.Getter; +import lombok.Setter; + +/** + * The Class PolicyEditorScopes. + */ @Entity -@Table(name="PolicyEditorScopes") -@NamedQuery(name="PolicyEditorScopes.findAll", query="SELECT p FROM PolicyEditorScopes p ") -public class PolicyEditorScopes implements Serializable{ +@Table(name = "PolicyEditorScopes") +@NamedQuery(name = "PolicyEditorScopes.findAll", query = "SELECT p FROM PolicyEditorScopes p ") +@Getter +@Setter +public class PolicyEditorScopes implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="scopeName", nullable=false, unique=true) + @Column(name = "scopeName", nullable = false, unique = true) @OrderBy("asc") private String scopeName; @Temporal(TemporalType.TIMESTAMP) - @Column(name="created_date", updatable=false) + @Column(name = "created_date", updatable = false) private Date createdDate; @Temporal(TemporalType.TIMESTAMP) - @Column(name="modified_date", nullable=false) + @Column(name = "modified_date", nullable = false) private Date modifiedDate; @ManyToOne(optional = false) - @JoinColumn(name="created_by") + @JoinColumn(name = "created_by") private UserInfo userCreatedBy; @ManyToOne(optional = false) - @JoinColumn(name="modified_by") + @JoinColumn(name = "modified_by") private UserInfo userModifiedBy; + /** + * Instantiates a new policy editor scopes. + */ public PolicyEditorScopes() { this.modifiedDate = new Date(); } + /** + * Pre persist. + */ @PrePersist - public void prePersist() { + public void prePersist() { Date date = new Date(); this.createdDate = date; this.modifiedDate = date; } + /** + * Pre update. + */ @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); } - - 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/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEntity.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEntity.java index 40ddb4308..8fa80e635 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEntity.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEntity.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -24,9 +25,10 @@ package org.onap.policy.rest.jpa; */ import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonManagedReference; + import java.io.Serializable; import java.util.Date; -import java.util.Objects; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -44,23 +46,45 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Version; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; -/* - * The Entity class to persist a policy object and its configuration data +/** + * The Entity class to persist a policy object and its configuration data. */ - +// @formatter:off @Entity // Add a non-unique index and a constraint that says the combo of policyName and scopeId must be unique @Table(name = "PolicyEntity") -@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") -}) +@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" + ) + } +) +@Getter +@Setter +@EqualsAndHashCode +// @formatter:on public class PolicyEntity implements Serializable { private static final long serialVersionUID = 1L; @@ -145,43 +169,8 @@ public class PolicyEntity implements Serializable { } /** - * Returns Policy Id. - * @return the policyId - */ - public long getPolicyId() { - return policyId; - } - - /** - * Returns policy name. - * @return the policy name - */ - public String getPolicyName() { - return policyName; - } - - public void setPolicyName(String policyName) { - this.policyName = policyName; - } - - /** - * Returns policy data. - * @return the policyData - */ - public String getPolicyData() { - return policyData; - } - - /** - * Set policy data. - * @param policyData the policyData to set - */ - public void setPolicyData(String policyData) { - this.policyData = policyData; - } - - /** * Returns configurationDataEntity. + * * @return the configurationDataEntity */ public ConfigurationDataEntity getConfigurationData() { @@ -190,200 +179,10 @@ public class PolicyEntity implements Serializable { /** * Set configurationDataEntity. + * * @param configurationDataEntity the configurationDataEntity to set */ public void setConfigurationData(ConfigurationDataEntity configurationDataEntity) { this.configurationDataEntity = configurationDataEntity; } - - /** - * Returns actionBodyEntity. - * @return the actionBodyEntity - */ - public ActionBodyEntity getActionBodyEntity() { - return actionBodyEntity; - } - - /** - * Set actionBodyEntity. - * @param actionBodyEntity the actionBodyEntity to set - */ - public void setActionBodyEntity(ActionBodyEntity actionBodyEntity) { - this.actionBodyEntity = actionBodyEntity; - } - - /** - * Returns scope. - * @return the scope - */ - public String getScope() { - return scope; - } - - /** - * Set scope. - * @param scope the scope to set - */ - public void setScope(String scope) { - this.scope = scope; - } - - /** - * Returns createdBy. - * @return the createdBy - */ - public String getCreatedBy() { - return createdBy; - } - - /** - * Set createdBy. - * @param createdBy the createdBy to set - */ - public void setCreatedBy(String createdBy) { - this.createdBy = createdBy; - } - - /** - * Returns description. - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Set description. - * @param description the description to set - */ - public void setDescription(String description) { - this.description = description; - } - - /** - * Returns modifiedBy. - * @return the modifiedBy - */ - public String getModifiedBy() { - return modifiedBy; - } - - /** - * Set modifiedBy. - * @param modifiedBy the modifiedBy to set - */ - public void setModifiedBy(String modifiedBy) { - this.modifiedBy = modifiedBy; - } - - /** - * Returns version. - * @return version - */ - public int getVersion() { - return version; - } - - /** - * Returns createdDate. - * @return the createdDate - */ - public Date getCreatedDate() { - return createdDate; - } - - /** - * Returns modifiedDate. - * @return the modifiedDate - */ - public Date getModifiedDate() { - return modifiedDate; - } - - /** - * Return deleted. - * @return the deleted - */ - public boolean isDeleted() { - return deleted; - } - - /** - * Set deleted. - * @param deleted the deleted to set - */ - public void setDeleted(boolean deleted) { - this.deleted = deleted; - } - - /** - * Return the reason code. - * @return deleted reason code - */ - public String getDeleteReasonCode() { - return deleteReasonCode; - } - - /** - * Set the reason of deletion. - * @param deleteReasonCode String object - */ - public void setDeleteReasonCode(String deleteReasonCode) { - this.deleteReasonCode = deleteReasonCode; - } - - /** - * Return deleted By. - * @return deletedBy - */ - public String getDeletedBy() { - return deletedBy; - } - - /** - * Set deleted By. - * @param deletedBy String object - */ - public void setDeletedBy(String deletedBy) { - this.deletedBy = deletedBy; - } - - @Override - public int hashCode() { - return Objects.hash(policyId, policyName, scope, version, policyVersion, policyData, configurationDataEntity, - actionBodyEntity, createdBy, createdDate, description, modifiedBy, modifiedDate, deleted); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (obj == this) { - return true; - } - if (!(obj instanceof PolicyEntity)) { - return false; - } - - PolicyEntity p = (PolicyEntity) obj; - - return policyId == p.policyId - && policyName.equals(p.policyName) - && scope.equals(p.scope) - && version == p.version - && policyVersion == p.policyVersion - && policyData.equals(p.policyData) - && ((configurationDataEntity == null && p.configurationDataEntity == null) - || (configurationDataEntity != null - && configurationDataEntity - .equals(p.configurationDataEntity))) - && ((actionBodyEntity == null && p.actionBodyEntity == null) || (actionBodyEntity != null - && actionBodyEntity - .equals(p.actionBodyEntity))) && createdBy.equals(p.createdBy) - && createdDate.equals(p.createdDate) && description.equals(p.description) - && modifiedBy.equals(p.modifiedBy) && modifiedDate.equals(p.modifiedDate) && deleted == p.deleted; - } - - } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyGroupEntity.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyGroupEntity.java index 52f8177f3..175db577c 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyGroupEntity.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyGroupEntity.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -17,6 +18,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.policy.rest.jpa; import java.io.Serializable; @@ -27,34 +29,23 @@ import javax.persistence.Id; import javax.persistence.NamedQuery; import javax.persistence.Table; +import lombok.Getter; +import lombok.Setter; + @Entity -@Table(name="PolicyGroupEntity") -@NamedQuery(name="PolicyGroupEntity.findAll", query="SELECT p FROM PolicyGroupEntity p ") -public class PolicyGroupEntity implements Serializable{ +@Table(name = "PolicyGroupEntity") +@NamedQuery(name = "PolicyGroupEntity.findAll", query = "SELECT p FROM PolicyGroupEntity p ") +@Getter +@Setter +public class PolicyGroupEntity implements Serializable { private static final long serialVersionUID = 1L; @Id - @Column(name="groupKey") + @Column(name = "groupKey") private int groupKey; @Id - @Column(name="policyid") + @Column(name = "policyid") private int policyid; - - public int getGroupKey() { - return groupKey; - } - - public void setGroupKey(int groupKey) { - this.groupKey = groupKey; - } - - public int getPolicyid() { - return policyid; - } - - public void setPolicyid(int policyid) { - this.policyid = policyid; - } } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyRoles.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyRoles.java index f220570bd..10680313b 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyRoles.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyRoles.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -19,6 +20,7 @@ */ package org.onap.policy.rest.jpa; + /* */ import java.io.Serializable; @@ -34,70 +36,44 @@ import javax.persistence.NamedQuery; import javax.persistence.OrderBy; import javax.persistence.Table; -import org.onap.policy.rest.jpa.UserInfo; - +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; /** * The persistent class for the roles database table. - * */ @Entity -@Table(name="roles") -@NamedQuery(name="PolicyRoles.findAll", query="SELECT r FROM PolicyRoles r ") +@Table(name = "roles") +@NamedQuery(name = "PolicyRoles.findAll", query = "SELECT r FROM PolicyRoles r ") +@Getter +@Setter +@NoArgsConstructor public class PolicyRoles implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; @ManyToOne - @JoinColumn(name="loginid") + @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) + @Column(name = "scope", nullable = true, length = 45) private String scope; - @Column(name="role", nullable=false, length=45) + @Column(name = "role", nullable = false, length = 45) private String role; - public PolicyRoles() { - // Empty constructor - } - - 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 UserInfo getLoginId() { + return loginId; } - public void setRole(String role) { - this.role = role; + public void setLoginId(UserInfo loginId) { + this.loginId = loginId; } - } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeClosedLoop.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeClosedLoop.java index c1597741e..7e0bba3be 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeClosedLoop.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeClosedLoop.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -19,8 +20,7 @@ */ package org.onap.policy.rest.jpa; -/* - */ + import java.io.Serializable; import javax.persistence.Column; @@ -32,46 +32,26 @@ import javax.persistence.NamedQuery; import javax.persistence.OrderBy; import javax.persistence.Table; +import lombok.Getter; +import lombok.Setter; @Entity -@Table(name="PolicyScopeClosedLoop") -@NamedQuery(name="PolicyScopeClosedLoop.findAll", query="SELECT e FROM PolicyScopeClosedLoop e ") +@Table(name = "PolicyScopeClosedLoop") +@NamedQuery(name = "PolicyScopeClosedLoop.findAll", query = "SELECT e FROM PolicyScopeClosedLoop e ") +@Getter +@Setter public class PolicyScopeClosedLoop implements Serializable { private static final long serialVersionUID = 1L; - @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="name", nullable=false) + @Column(name = "name", nullable = false) @OrderBy("asc") private String name; - @Column(name="description ") - private String 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; - - } - public String getDescriptionValue() { - return this.description ; - } - - public void setDescriptionValue(String description ) { - this.description = description ; - } + @Column(name = "description ") + private String description; } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeResource.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeResource.java index 323275624..ebc570fa8 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeResource.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeResource.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -19,8 +20,7 @@ */ package org.onap.policy.rest.jpa; -/* - */ + import java.io.Serializable; import javax.persistence.Column; @@ -32,45 +32,26 @@ import javax.persistence.NamedQuery; import javax.persistence.OrderBy; import javax.persistence.Table; +import lombok.Getter; +import lombok.Setter; @Entity -@Table(name="PolicyScopeResource") -@NamedQuery(name="PolicyScopeResource.findAll", query="SELECT e FROM PolicyScopeResource e ") +@Table(name = "PolicyScopeResource") +@NamedQuery(name = "PolicyScopeResource.findAll", query = "SELECT e FROM PolicyScopeResource e ") +@Getter +@Setter public class PolicyScopeResource implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="name", nullable=false) + @Column(name = "name", nullable = false) @OrderBy("asc") private String name; - @Column(name="description ") - private String 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; - - } - public String getDescriptionValue() { - return this.description ; - } - - public void setDescriptionValue(String description ) { - this.description = description ; - } + @Column(name = "description ") + private String description; } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeService.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeService.java index 8238110f0..7af22e338 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeService.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeService.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -19,8 +20,7 @@ */ package org.onap.policy.rest.jpa; -/* - */ + import java.io.Serializable; import javax.persistence.Column; @@ -32,46 +32,26 @@ import javax.persistence.NamedQuery; import javax.persistence.OrderBy; import javax.persistence.Table; +import lombok.Getter; +import lombok.Setter; @Entity -@Table(name="PolicyScopeService") -@NamedQuery(name="PolicyScopeService.findAll", query="SELECT e FROM PolicyScopeService e ") +@Table(name = "PolicyScopeService") +@NamedQuery(name = "PolicyScopeService.findAll", query = "SELECT e FROM PolicyScopeService e ") +@Getter +@Setter public class PolicyScopeService implements Serializable { private static final long serialVersionUID = 1L; - @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="name", nullable=false) + @Column(name = "name", nullable = false) @OrderBy("asc") private String name; - @Column(name="description ") - private String 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; - - } - public String getDescriptionValue() { - return this.description ; - } - - public void setDescriptionValue(String description ) { - this.description = description ; - } + @Column(name = "description ") + private String description; } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeType.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeType.java index 04f20c330..e53a1acbf 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeType.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeType.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -19,8 +20,7 @@ */ package org.onap.policy.rest.jpa; -/* - */ + import java.io.Serializable; import javax.persistence.Column; @@ -32,45 +32,26 @@ import javax.persistence.NamedQuery; import javax.persistence.OrderBy; import javax.persistence.Table; +import lombok.Getter; +import lombok.Setter; @Entity -@Table(name="PolicyScopeType") -@NamedQuery(name="PolicyScopeType.findAll", query="SELECT e FROM PolicyScopeType e ") +@Table(name = "PolicyScopeType") +@NamedQuery(name = "PolicyScopeType.findAll", query = "SELECT e FROM PolicyScopeType e ") +@Getter +@Setter public class PolicyScopeType implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="name", nullable=false) + @Column(name = "name", nullable = false) @OrderBy("asc") private String name; - @Column(name="description ") - private String 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; - - } - public String getDescriptionValue() { - return this.description ; - } - - public void setDescriptionValue(String description ) { - this.description = description ; - } + @Column(name = "description ") + private String description; } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScore.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScore.java index 3bb0919b7..74b53babb 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScore.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScore.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -19,6 +20,7 @@ */ package org.onap.policy.rest.jpa; + import java.io.Serializable; import javax.persistence.Column; @@ -31,60 +33,45 @@ import javax.persistence.NamedQuery; import javax.persistence.OrderBy; import javax.persistence.Table; +import lombok.Getter; +import lombok.Setter; +// @formatter:off @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") -}) +@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" + ) + } +) +@Getter +@Setter +// @formatter:on public class PolicyScore implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="POLICY_NAME", nullable=false) + @Column(name = "POLICY_NAME", nullable = false) @OrderBy("asc") - private String PolicyName; + private String policyName; - @Column(name="VERSIONEXTENSION", nullable=false) + @Column(name = "VERSIONEXTENSION", nullable = false) @OrderBy("asc") - private String VersionExtension; - - @Column(name="POLICY_SCORE", nullable=true) - private String PolicyScore; - - 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; - } - + private String versionExtension; + @Column(name = "POLICY_SCORE", nullable = true) + private String score; } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyVersion.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyVersion.java index f6512af88..0332dcbfd 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyVersion.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyVersion.java @@ -3,6 +3,7 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +23,7 @@ package org.onap.policy.rest.jpa; import java.io.Serializable; import java.util.Date; -import java.util.Objects; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -36,169 +37,112 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +/** + * The Class PolicyVersion. + */ +// @formatter:off @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"), - @NamedQuery(name="PolicyVersion.findAllCount", query="SELECT COUNT(p) FROM PolicyVersion p") -}) +@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" + ), + @NamedQuery( + name = "PolicyVersion.findAllCount", query = "SELECT COUNT(p) FROM PolicyVersion p" + ) + } +) +@Getter +@Setter +@EqualsAndHashCode +// @formatter:on public class PolicyVersion implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="POLICY_NAME", nullable=false, length=255) + @Column(name = "POLICY_NAME", nullable = false, length = 255) private String policyName; - @Column(name="ACTIVE_VERSION") + @Column(name = "ACTIVE_VERSION") private int activeVersion; - @Column(name="HIGHEST_VERSION") + @Column(name = "HIGHEST_VERSION") private int higherVersion; @Temporal(TemporalType.TIMESTAMP) - @Column(name="created_date", nullable=false) + @Column(name = "created_date", nullable = false) private Date createdDate; - @Column(name="CREATED_BY", nullable=false, length=45) + @Column(name = "CREATED_BY", nullable = false, length = 45) private String createdBy; @Temporal(TemporalType.TIMESTAMP) - @Column(name="modified_date", nullable=false) + @Column(name = "modified_date", nullable = false) private Date modifiedDate; - - @Column(name="modified_by", nullable=false, length=45) + @Column(name = "modified_by", nullable = false, length = 45) private String modifiedBy; + /** + * Instantiates a new policy version. + */ public PolicyVersion() { this.modifiedDate = new Date(); this.createdDate = new Date(); } + /** + * Instantiates a new policy version. + * + * @param domain the domain + * @param loginUserId the login user id + */ public PolicyVersion(String domain, String loginUserId) { this(domain); this.createdBy = loginUserId; this.modifiedBy = loginUserId; } + /** + * Instantiates a new policy version. + * + * @param domain the domain + */ public PolicyVersion(String domain) { this.policyName = domain; } - 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; - } - - + /** + * Pre persist. + */ @PrePersist - public void prePersist() { + public void prePersist() { Date date = new Date(); this.createdDate = date; this.modifiedDate = date; } + /** + * Pre update. + */ @PreUpdate public void preUpdate() { - this.modifiedDate = new Date(); - } - - 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(Date 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(Date modifiedDate) { - this.modifiedDate = modifiedDate; - } - - public String getModifiedBy() { - return modifiedBy; - } - - public void setModifiedBy(String modifiedBy) { - this.modifiedBy = modifiedBy; - } - - @Override - public int hashCode() { - return Objects.hash(id, policyName, activeVersion, higherVersion, createdDate, - createdBy, modifiedDate, modifiedBy); - } - - @Override - public boolean equals(Object obj) { - if(obj == null){ - return false; - } - if(obj == this){ - return true; - } - if(!(obj instanceof PolicyVersion)){ - return false; - } - - PolicyVersion p = (PolicyVersion) obj; - - return id == p.id && - policyName.equals(p.policyName) && - activeVersion == p.activeVersion && - higherVersion == p.higherVersion && - createdDate.equals(p.createdDate) && - createdBy.equals(p.createdBy) && - modifiedDate.equals(p.modifiedDate) && - modifiedBy.equals(p.modifiedBy); + this.modifiedDate = new Date(); } - } - diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PortList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PortList.java index 93732ffcd..6e26ed93f 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PortList.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PortList.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -19,8 +20,7 @@ */ package org.onap.policy.rest.jpa; -/* - */ + import java.io.Serializable; import javax.persistence.Column; @@ -32,45 +32,26 @@ import javax.persistence.NamedQuery; import javax.persistence.OrderBy; import javax.persistence.Table; +import lombok.Getter; +import lombok.Setter; + @Entity -@Table(name="portlist") -@NamedQuery(name="PortList.findAll", query="SELECT e FROM PortList e ") +@Table(name = "portlist") +@NamedQuery(name = "PortList.findAll", query = "SELECT e FROM PortList e ") +@Getter +@Setter public class PortList implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="portname", nullable=false) + @Column(name = "portname", nullable = false) @OrderBy("asc") private String portName; - @Column(name="description") + @Column(name = "description") private String description; - - 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/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PrefixList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PrefixList.java index 9a0e8aec0..c723ebe39 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PrefixList.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PrefixList.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -19,8 +20,7 @@ */ package org.onap.policy.rest.jpa; -/* - */ + import java.io.Serializable; import javax.persistence.Column; @@ -32,57 +32,29 @@ import javax.persistence.NamedQuery; import javax.persistence.OrderBy; import javax.persistence.Table; +import lombok.Getter; +import lombok.Setter; + @Entity -@Table(name="PrefixList") -@NamedQuery(name="PrefixList.findAll", query="SELECT e FROM PrefixList e ") +@Table(name = "PrefixList") +@NamedQuery(name = "PrefixList.findAll", query = "SELECT e FROM PrefixList e ") +@Getter +@Setter public class PrefixList implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="pl_name", nullable=false) + @Column(name = "pl_name", nullable = false) @OrderBy("asc") private String prefixListName; - @Column(name="description", nullable=false) + @Column(name = "description", nullable = false) private String description; - @Column(name="pl_value", nullable=false) + @Column(name = "pl_value", nullable = false) private String prefixListValue; - - 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/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ProtocolList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ProtocolList.java index 5e79e6785..edb514b3f 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ProtocolList.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ProtocolList.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -19,8 +20,7 @@ */ package org.onap.policy.rest.jpa; -/* - */ + import java.io.Serializable; import javax.persistence.Column; @@ -32,48 +32,26 @@ import javax.persistence.NamedQuery; import javax.persistence.OrderBy; import javax.persistence.Table; +import lombok.Getter; +import lombok.Setter; + @Entity -@Table(name="protocollist") -@NamedQuery(name="ProtocolList.findAll", query="SELECT e FROM ProtocolList e ") +@Table(name = "protocollist") +@NamedQuery(name = "ProtocolList.findAll", query = "SELECT e FROM ProtocolList e ") +@Getter +@Setter public class ProtocolList implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="protocolname", nullable=false) + @Column(name = "protocolname", nullable = false) @OrderBy("asc") private String protocolName; - @Column(name="description") + @Column(name = "description") private String description; - - 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/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java index de20cd3f8..da54b05bd 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java @@ -1089,8 +1089,8 @@ public class PolicyValidation { if (returnModel != null) { String annotation = returnModel.getAnnotation(); - String refAttributes = returnModel.getRef_attributes(); - String subAttributes = returnModel.getSub_attributes(); + String refAttributes = returnModel.getRefAttributes(); + String subAttributes = returnModel.getSubAttributes(); String modelAttributes = returnModel.getAttributes(); if (!Strings.isNullOrEmpty(annotation)) { @@ -1384,4 +1384,4 @@ public class PolicyValidation { } -}
\ No newline at end of file +} |