644f8140a6f3bfdecbd58984c48b944c59482375
[holmes/common.git] / holmes-actions / src / main / java / org / onap / holmes / common / msb / entity / MicroServiceFullInfo.java
1 /**
2  * Copyright 2023 ZTE Corporation.
3  * <p>
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * <p>
8  * http://www.apache.org/licenses/LICENSE-2.0
9  * <p>
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.holmes.common.msb.entity;
18
19 import java.io.Serializable;
20 import java.util.Iterator;
21
22 public class MicroServiceFullInfo extends Service<NodeInfo> implements Serializable {
23     private static final long serialVersionUID = 1L;
24     private String status = "1";
25
26     public MicroServiceFullInfo() {
27     }
28
29     public String getStatus() {
30         return this.status;
31     }
32
33     public void setStatus(String status) {
34         this.status = status;
35     }
36
37     public String toString() {
38         StringBuffer buf = new StringBuffer();
39         buf.append("MicroService List:").append("\r\n");
40         buf.append("serviceName:").append(this.getServiceName()).append("\r\n");
41         buf.append("version:").append(this.getVersion()).append("\r\n");
42         buf.append("url:").append(this.getUrl()).append("\r\n");
43         buf.append("protocol:").append(this.getProtocol()).append("\r\n");
44         buf.append("visualRange:").append(this.getVisualRange()).append("\r\n");
45         buf.append("nodes:").append("\r\n");
46         Iterator nodes = this.getNodes().iterator();
47
48         while (nodes.hasNext()) {
49             NodeInfo nodeInstace = (NodeInfo) nodes.next();
50             buf.append("  nodeId-").append(nodeInstace.getNodeId()).append("\r\n");
51             buf.append("  ip-").append(nodeInstace.getIp()).append("\r\n");
52             buf.append("  port-").append(nodeInstace.getPort()).append("\r\n");
53             buf.append("  ttl-").append(nodeInstace.getTtl()).append("\r\n");
54             buf.append("  Created_at-").append(nodeInstace.getCreated_at()).append("\r\n");
55             buf.append("  Updated_at-").append(nodeInstace.getUpdated_at()).append("\r\n");
56             buf.append("  Expiration-").append(nodeInstace.getExpiration()).append("\r\n");
57         }
58
59         buf.append("metadata:").append("\r\n");
60         if (this.getMetadata() != null && this.getMetadata().size() > 0) {
61             nodes = this.getMetadata().iterator();
62             while (nodes.hasNext()) {
63                 KeyValuePair keyValuePair = (KeyValuePair) nodes.next();
64                 buf.append("  key-").append(keyValuePair.getKey()).append("\r\n");
65                 buf.append("  value-").append(keyValuePair.getValue()).append("\r\n");
66             }
67         }
68
69         return buf.toString();
70     }
71 }