blob: 8d29c03f4d2c55158e3568b8ac72995a564f5f7d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
/*
* Copyright 2019 Huawei Technologies Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onap.cli.fw.cmd.execution;
import java.util.ArrayList;
import java.util.List;
import org.onap.cli.fw.cmd.OnapCommand;
import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.error.OnapCommandExecutionNotFound;
import org.onap.cli.fw.output.OnapCommandResultType;
import org.onap.cli.fw.schema.OnapCommandSchema;
import org.onap.cli.fw.store.OnapCommandExecutionStore;
import org.onap.cli.fw.store.OnapCommandExecutionStore.Execution;
/**
* List available schemas.
*
*/
@OnapCommandSchema(schema = "execution-show.yaml")
public class OnapCommandExceutionShowCommand extends OnapCommand {
@Override
protected void run() throws OnapCommandException {
String requestId = getParametersMap().get("execution-id").getValue().toString();
OnapCommandExecutionStore.Execution e= OnapCommandExecutionStore.getStore().getExecution(requestId);
this.getResult().getRecordsMap().get("product").getValues().add(e.getProduct());
this.getResult().getRecordsMap().get("service").getValues().add(e.getService());
this.getResult().getRecordsMap().get("command").getValues().add(e.getCommand());
this.getResult().getRecordsMap().get("profile").getValues().add(e.getProfile());
this.getResult().getRecordsMap().get("input").getValues().add(String.valueOf(e.getInput()));
this.getResult().getRecordsMap().get("request-id").getValues().add(e.getId());
this.getResult().getRecordsMap().get("status").getValues().add(e.getStatus());
this.getResult().getRecordsMap().get("start-time").getValues().add(e.getStartTime());
this.getResult().getRecordsMap().get("end-time").getValues().add(e.getEndTime());
this.getResult().getRecordsMap().get("output").getValues().add(String.valueOf(e.getOutput()));
if (this.getResult().getType().equals(OnapCommandResultType.TEXT)) {
List<Execution> list = new ArrayList<>();
list.add(e);
this.getResult().setOutput(this.printExecution(list));
}
}
public String printExecution(List<OnapCommandExecutionStore.Execution> executions) throws OnapCommandExecutionNotFound {
String msg = "<oclip-execution-list>\n";
for (OnapCommandExecutionStore.Execution e: executions) {
msg += "<oclip-execution>\n";
if ( e.getId() != null)
msg += "<oclip-request-id>\n" + e.getId() + "</oclip-request-id>\n";
msg += "<oclip-request-product>\n" + e.getProduct() + "</oclip-request-product>\n";
msg += "<oclip-request-service>\n" + e.getService() + "</oclip-request-service>\n";
msg += "<oclip-request-command>\n" + e.getCommand() + "</oclip-request-command>\n";
if ( e.getProfile() != null)
msg += "<oclip-request-profile>\n" + e.getProfile() + "</oclip-request-profile>\n";
msg += "<oclip-request-input>\n" + e.getInput() + "</oclip-request-input>\n";
if ( e.getOutput() != null)
msg += "<oclip-request-output>\n" + e.getOutput() + "</oclip-request-output>\n";
msg += "<oclip-request-start-time>\n" + e.getStartTime() + "</oclip-request-start-time>\n";
msg += "<oclip-request-end-time>\n" + e.getEndTime() + "</oclip-request-end-time>\n";
msg += "<oclip-request-status>\n" + e.getStatus() + "</oclip-request-status>\n";
msg += "</oclip-execution>";
}
msg += "</oclip-execution-list>";
return msg;
}
}
|