7437b38920e3814076825fc9a7f01023d4031227
[aai/sparky-be.git] / src / main / java / org / onap / aai / sparky / viewandinspect / entity / NodeProcessingTransaction.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017 Amdocs
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  *
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23 package org.onap.aai.sparky.viewandinspect.entity;
24
25 import org.onap.aai.restclient.client.OperationResult;
26
27 /**
28  * The Class NodeProcessingTransaction.
29  */
30 public class NodeProcessingTransaction {
31
32   private ActiveInventoryNode processingNode;
33   private OperationResult opResult;
34   private String selfLinkWithModifiers;
35   private String requestParameters;
36
37   /**
38    * Instantiates a new node processing transaction.
39    */
40   public NodeProcessingTransaction() {}
41
42   public String getRequestParameters() {
43     return requestParameters;
44   }
45
46   public void setRequestParameters(String requestParameters) {
47     this.requestParameters = requestParameters;
48   }
49
50   public String getSelfLink() {
51     if (processingNode == null) {
52       return null;
53     }
54
55     return processingNode.getSelfLink(); 
56   }
57
58   public String getSelfLinkWithModifiers() {
59     if (processingNode == null) {
60       return null;
61     }
62
63     return processingNode.getSelfLink() + requestParameters;
64   }
65
66   public ActiveInventoryNode getProcessingNode() {
67     return processingNode;
68   }
69
70   public void setProcessingNode(ActiveInventoryNode processingNode) {
71     this.processingNode = processingNode;
72   }
73
74   public OperationResult getOpResult() {
75     return opResult;
76   }
77
78   public void setOpResult(OperationResult opResult) {
79     this.opResult = opResult;
80   }
81
82   /**
83    * Processing error occurred.
84    *
85    * @return true, if successful
86    */
87   public boolean processingErrorOccurred() {
88     if (opResult == null) {
89       return true;
90     }
91
92     return !opResult.wasSuccessful();
93
94   }
95
96   /* (non-Javadoc)
97    * @see java.lang.Object#toString()
98    */
99   @Override
100   public String toString() {
101     return "NodeProcessingTransaction ["
102         + (processingNode != null ? "processingNode=" + processingNode + ", " : "")
103         + (opResult != null ? "opResult=" + opResult + ", " : "") + "processorErrorOccurred="
104         + processingErrorOccurred() + "]";
105   }
106
107 }