Convert Sparky to Spring-Boot
[aai/sparky-be.git] / sparkybe-onap-service / src / main / java / org / onap / aai / sparky / dal / NetworkTransaction.java
1 /**
2  * ============LICENSE_START===================================================
3  * SPARKY (AAI UI service)
4  * ============================================================================
5  * Copyright © 2017 AT&T Intellectual Property.
6  * Copyright © 2017 Amdocs
7  * All rights reserved.
8  * ============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=====================================================
21  *
22  * ECOMP and OpenECOMP are trademarks
23  * and service marks of AT&T Intellectual Property.
24  */
25 package org.onap.aai.sparky.dal;
26
27 import org.onap.aai.restclient.client.OperationResult;
28 import org.onap.aai.sparky.config.oxm.OxmEntityDescriptor;
29 import org.onap.aai.sparky.dal.rest.HttpMethod;
30
31
32 /**
33  * The Class NetworkTransaction.
34  */
35 public class NetworkTransaction {
36
37   private OperationResult operationResult;
38
39   private String entityType;
40
41   private String link;
42
43   private String queryParameters;
44
45   private HttpMethod operationType;
46
47   private OxmEntityDescriptor descriptor;
48
49   private long createdTimeStampInMs;
50
51   private long opTimeInMs;
52
53   private long taskAgeInMs;
54
55   /**
56    * Instantiates a new network transaction.
57    */
58   public NetworkTransaction() {
59     this.createdTimeStampInMs = System.currentTimeMillis();
60     this.opTimeInMs = 0L;
61   }
62
63   /**
64    * Instantiates a new network transaction.
65    *
66    * @param method the method
67    * @param entityType the entity type
68    * @param or the or
69    */
70   public NetworkTransaction(HttpMethod method, String entityType, OperationResult or) {
71     this();
72     this.operationType = method;
73     this.entityType = entityType;
74     this.operationResult = or;
75     this.opTimeInMs = 0L;
76   }
77
78   public HttpMethod getOperationType() {
79     return operationType;
80   }
81
82   public long getTaskAgeInMs() {
83     return taskAgeInMs;
84   }
85
86   /**
87    * Sets the task age in ms.
88    */
89   public void setTaskAgeInMs() {
90     this.taskAgeInMs = (System.currentTimeMillis() - createdTimeStampInMs);
91   }
92
93   public void setOperationType(HttpMethod operationType) {
94     this.operationType = operationType;
95   }
96
97   public OperationResult getOperationResult() {
98     return operationResult;
99   }
100
101   public void setOperationResult(OperationResult operationResult) {
102     this.operationResult = operationResult;
103   }
104
105   public String getEntityType() {
106     return entityType;
107   }
108
109   public void setEntityType(String entityType) {
110     this.entityType = entityType;
111   }
112
113   public String getLink() {
114     return link;
115   }
116
117   public void setLink(String link) {
118     this.link = link;
119   }
120
121   public String getQueryParameters() {
122     return queryParameters;
123   }
124
125   public void setQueryParameters(String queryParameters) {
126     this.queryParameters = queryParameters;
127   }
128
129   public long getOpTimeInMs() {
130     return opTimeInMs;
131   }
132
133   public void setOpTimeInMs(long opTimeInMs) {
134     this.opTimeInMs = opTimeInMs;
135   }
136
137   public OxmEntityDescriptor getDescriptor() {
138     return descriptor;
139   }
140
141   public void setDescriptor(OxmEntityDescriptor descriptor) {
142     this.descriptor = descriptor;
143   }
144
145   /*
146    * (non-Javadoc)
147    * 
148    * @see java.lang.Object#toString()
149    */
150   @Override
151   public String toString() {
152     return "NetworkTransaction [operationResult=" + operationResult.toString() + ", entityType="
153         + entityType + ", link=" + link + ", operationType=" + operationType + ", descriptor="
154         + descriptor.toString() + ", createdTimeStampInMs=" + createdTimeStampInMs
155         + ", taskAgeInMs=" + taskAgeInMs + "]";
156   }
157
158
159 }