Update license and poms
[aai/sparky-be.git] / sparkybe-onap-service / src / main / java / org / onap / aai / sparky / dal / NetworkTransaction.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017-2018 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 package org.onap.aai.sparky.dal;
22
23 import org.onap.aai.restclient.client.OperationResult;
24 import org.onap.aai.sparky.config.oxm.OxmEntityDescriptor;
25 import org.onap.aai.sparky.dal.rest.HttpMethod;
26
27
28 /**
29  * The Class NetworkTransaction.
30  */
31 public class NetworkTransaction {
32
33   private OperationResult operationResult;
34
35   private String entityType;
36
37   private String link;
38
39   private String queryParameters;
40
41   private HttpMethod operationType;
42
43   private OxmEntityDescriptor descriptor;
44
45   private long createdTimeStampInMs;
46
47   private long opTimeInMs;
48
49   private long taskAgeInMs;
50
51   /**
52    * Instantiates a new network transaction.
53    */
54   public NetworkTransaction() {
55     this.createdTimeStampInMs = System.currentTimeMillis();
56     this.opTimeInMs = 0L;
57   }
58
59   /**
60    * Instantiates a new network transaction.
61    *
62    * @param method the method
63    * @param entityType the entity type
64    * @param or the or
65    */
66   public NetworkTransaction(HttpMethod method, String entityType, OperationResult or) {
67     this();
68     this.operationType = method;
69     this.entityType = entityType;
70     this.operationResult = or;
71     this.opTimeInMs = 0L;
72   }
73
74   public HttpMethod getOperationType() {
75     return operationType;
76   }
77
78   public long getTaskAgeInMs() {
79     return taskAgeInMs;
80   }
81
82   /**
83    * Sets the task age in ms.
84    */
85   public void setTaskAgeInMs() {
86     this.taskAgeInMs = (System.currentTimeMillis() - createdTimeStampInMs);
87   }
88
89   public void setOperationType(HttpMethod operationType) {
90     this.operationType = operationType;
91   }
92
93   public OperationResult getOperationResult() {
94     return operationResult;
95   }
96
97   public void setOperationResult(OperationResult operationResult) {
98     this.operationResult = operationResult;
99   }
100
101   public String getEntityType() {
102     return entityType;
103   }
104
105   public void setEntityType(String entityType) {
106     this.entityType = entityType;
107   }
108
109   public String getLink() {
110     return link;
111   }
112
113   public void setLink(String link) {
114     this.link = link;
115   }
116
117   public String getQueryParameters() {
118     return queryParameters;
119   }
120
121   public void setQueryParameters(String queryParameters) {
122     this.queryParameters = queryParameters;
123   }
124
125   public long getOpTimeInMs() {
126     return opTimeInMs;
127   }
128
129   public void setOpTimeInMs(long opTimeInMs) {
130     this.opTimeInMs = opTimeInMs;
131   }
132
133   public OxmEntityDescriptor getDescriptor() {
134     return descriptor;
135   }
136
137   public void setDescriptor(OxmEntityDescriptor descriptor) {
138     this.descriptor = descriptor;
139   }
140
141   /*
142    * (non-Javadoc)
143    * 
144    * @see java.lang.Object#toString()
145    */
146   @Override
147   public String toString() {
148     return "NetworkTransaction [operationResult=" + operationResult.toString() + ", entityType="
149         + entityType + ", link=" + link + ", operationType=" + operationType + ", descriptor="
150         + descriptor.toString() + ", createdTimeStampInMs=" + createdTimeStampInMs
151         + ", taskAgeInMs=" + taskAgeInMs + "]";
152   }
153
154
155 }