* * org.onap.dcae
* * ================================================================================
* * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * Copyright (c) 2021 Nokia. All rights reserved.
* * ================================================================================
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
/**
* @author : Ravi Mantena
- * @date 10/16/2020
- * Application: ONAP - Blueprint Generator
- * Common ONAP Service used by ONAP and DMAAP Blueprint to add Start Inputs Node under Start
+ * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service to add Start Inputs
+ * Node under Start
*/
-
-
@Service
public class StartInputsService {
@Autowired
private PgaasNodeService pgaasNodeService;
- //Method to create Start Inputs for Start in Interfaces
- public Map<String, Object> createStartInputs(Map<String, LinkedHashMap<String, Object>> inputs, OnapComponentSpec onapComponentSpec){
-
- Map<String,Object> response = new HashMap<>();
+ /**
+ * Creates Start Inputs for Start in Interfaces
+ *
+ * @param inputs Inputs
+ * @param onapComponentSpec OnapComponentSpec
+ * @return
+ */
+ public Map<String, Object> createStartInputs(
+ Map<String, Map<String, Object>> inputs, OnapComponentSpec onapComponentSpec) {
+
+ Map<String, Object> response = new HashMap<>();
StartInputs startInputs = new StartInputs();
int count = 0;
OnapAuxilary aux = onapComponentSpec.getAuxilary();
if (aux.getPorts() != null) {
- for(Object p : aux.getPorts()) {
+ for (Object p : aux.getPorts()) {
String[] ports = p.toString().split(":");
- portList.add(String.format("concat: [\"%s:\", {get_input: external_port_%d}]" , ports[0], count));
+ portList.add(
+ String.format("concat: [\"%s:\", {get_input: external_port_%d}]", ports[0],
+ count));
- LinkedHashMap<String, Object> portType = new LinkedHashMap();
+ Map<String, Object> portType = new LinkedHashMap();
portType.put("type", "string");
portType.put("default", ports[1]);
inputs.put("external_port_" + count, portType);
startInputs.setPorts(portList);
- LinkedHashMap<String, Object> envMap = new LinkedHashMap();
- if(onapComponentSpec.getAuxilary().getDatabases() != null){
- Map<String, Object> envVars = pgaasNodeService.getEnvVariables(onapComponentSpec.getAuxilary().getDatabases());
+ Map<String, Object> envMap = new LinkedHashMap();
+ if (onapComponentSpec.getAuxilary().getDatabases() != null) {
+ Map<String, Object> envVars =
+ pgaasNodeService.getEnvVariables(onapComponentSpec.getAuxilary().getDatabases());
startInputs.setEnvs(envVars);
envMap.put("default", "&envs {}");
- }
- else {
+ } else {
GetInput env = new GetInput();
env.setBpInputName("envs");
startInputs.setEnvs(env);
response.put("inputs", inputs);
return response;
}
-
}