Initial commit for AAI-UI(sparky-backend)
[aai/sparky-be.git] / src / main / java / org / openecomp / 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
26 package org.openecomp.sparky.dal;
27
28 import org.openecomp.sparky.config.oxm.OxmEntityDescriptor;
29 import org.openecomp.sparky.dal.rest.HttpMethod;
30 import org.openecomp.sparky.dal.rest.OperationResult;
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 HttpMethod operationType;
44
45   private OxmEntityDescriptor descriptor;
46
47   private long createdTimeStampInMs;
48
49   private long taskAgeInMs;
50
51   /**
52    * Instantiates a new network transaction.
53    */
54   public NetworkTransaction() {
55     this.createdTimeStampInMs = System.currentTimeMillis();
56   }
57
58   /**
59    * Instantiates a new network transaction.
60    *
61    * @param method the method
62    * @param entityType the entity type
63    * @param or the or
64    */
65   public NetworkTransaction(HttpMethod method, String entityType, OperationResult or) {
66     this();
67     this.operationType = method;
68     this.entityType = entityType;
69     this.operationResult = or;
70   }
71
72   public HttpMethod getOperationType() {
73     return operationType;
74   }
75
76   public long getTaskAgeInMs() {
77     return taskAgeInMs;
78   }
79
80   /**
81    * Sets the task age in ms.
82    */
83   public void setTaskAgeInMs() {
84     this.taskAgeInMs = (System.currentTimeMillis() - createdTimeStampInMs);
85   }
86
87   public void setOperationType(HttpMethod operationType) {
88     this.operationType = operationType;
89   }
90
91   public OperationResult getOperationResult() {
92     return operationResult;
93   }
94
95   public void setOperationResult(OperationResult operationResult) {
96     this.operationResult = operationResult;
97   }
98
99   public String getEntityType() {
100     return entityType;
101   }
102
103   public void setEntityType(String entityType) {
104     this.entityType = entityType;
105   }
106
107   public String getLink() {
108     return link;
109   }
110
111   public void setLink(String link) {
112     this.link = link;
113   }
114
115   public OxmEntityDescriptor getDescriptor() {
116     return descriptor;
117   }
118
119   public void setDescriptor(OxmEntityDescriptor descriptor) {
120     this.descriptor = descriptor;
121   }
122
123   /* (non-Javadoc)
124    * @see java.lang.Object#toString()
125    */
126   @Override
127   public String toString() {
128     return "NetworkTransaction [operationResult=" + operationResult.toString() + ", entityType="
129         + entityType + ", link=" + link + ", operationType=" + operationType + ", descriptor="
130         + descriptor.toString() + ", createdTimeStampInMs=" + createdTimeStampInMs
131         + ", taskAgeInMs=" + taskAgeInMs + "]";
132   }
133
134
135 }