summaryrefslogtreecommitdiffstats
path: root/applications/common/src/main/java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-05-29 11:43:49 -0400
committerJim Hahn <jrh3@att.com>2020-06-01 10:06:25 -0400
commit3c703e2e48c0e74cb580b8afafb212fb9728aeeb (patch)
tree70b0aa73da0949457998b4101547026e39060740 /applications/common/src/main/java
parent9213cdfc854115fb427ca22c1d04f2b3051f806f (diff)
Use OperationsHistory from models
Deleted Dbao and replaced it with the shared class in policy-models. Also had to update the queries and the persistence.xml accordingly. Issue-ID: POLICY-2581 Change-Id: I59dfa2f37c272796ccebc0f578c9f4e8e1b9c8ab Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'applications/common/src/main/java')
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/CountRecentOperationsPip.java2
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/Dbao.java79
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java3
3 files changed, 2 insertions, 82 deletions
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/CountRecentOperationsPip.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/CountRecentOperationsPip.java
index f2d79804..3d7270e1 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/CountRecentOperationsPip.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/CountRecentOperationsPip.java
@@ -145,7 +145,7 @@ public class CountRecentOperationsPip extends StdOnapPip {
//
// We are expecting a single result
//
- return em.createQuery("select count(e) from Dbao e"
+ return em.createQuery("select count(e) from OperationsHistory e"
+ " where e.outcome<>'Failure_Guard'"
+ " and e.actor= ?1"
+ " and e.operation= ?2"
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/Dbao.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/Dbao.java
deleted file mode 100644
index b4ee5594..00000000
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/Dbao.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * Copyright (C) 2019-2020 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.pdp.xacml.application.common.operationshistory;
-
-import java.io.Serializable;
-import java.util.Date;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Index;
-import javax.persistence.Table;
-import lombok.Data;
-
-@Entity
-@Table(name = "operationshistory",
- indexes = {@Index(name = "operationshistory_clreqid_index", columnList = "closedLoopName,requestId"),
- @Index(name = "operationshistory_target_index", columnList = "target,operation,actor")})
-@Data
-public class Dbao implements Serializable {
-
- private static final long serialVersionUID = -551420180714993577L;
-
- @Id
- @GeneratedValue
- @Column(name = "id")
- private Long id;
-
- @Column(name = "closedLoopName", length = 255)
- private String closedLoopName;
-
- @Column(name = "requestId", length = 50)
- private String requestId;
-
- @Column(name = "subrequestId", length = 50)
- private String subrequestId;
-
- @Column(name = "actor", length = 50)
- private String actor;
-
- @Column(name = "operation", length = 50)
- private String operation;
-
- @Column(name = "target", length = 50)
- private String target;
-
- @Column(name = "starttime")
- private Date starttime;
-
- @Column(name = "outcome", length = 50)
- private String outcome;
-
- @Column(name = "message", length = 255)
- private String message;
-
- @Column(name = "endtime")
- private Date endtime;
-
-}
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java
index 60e26a2e..95595986 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java
@@ -28,7 +28,6 @@ import com.att.research.xacml.std.pip.StdPIPResponse;
import com.google.common.base.Strings;
import java.util.Arrays;
import java.util.Collection;
-
import javax.persistence.NoResultException;
import org.onap.policy.pdp.xacml.application.common.ToscaDictionary;
import org.onap.policy.pdp.xacml.application.common.std.StdOnapPip;
@@ -117,7 +116,7 @@ public class GetOperationOutcomePip extends StdOnapPip {
// We are expecting a single result
//
String result = em
- .createQuery("select e.outcome from Dbao e" + " where e.closedLoopName= ?1"
+ .createQuery("select e.outcome from OperationsHistory e" + " where e.closedLoopName= ?1"
+ " order by e.starttime desc", String.class)
.setParameter(1, clname).setMaxResults(1).getSingleResult();