aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
blob: ed6345c6073d2c05a5c62a82d3b80104f16c74ae (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
/*-
 * ============LICENSE_START=======================================================
 * sdc-distribution-client
 * ================================================================================
 * Copyright (C) 2017 AT&T Intellectual Property. 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.
 * 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.
 * ============LICENSE_END=========================================================
 */

package org.onap.sdc.tosca.parser.impl;

import static java.util.stream.Collectors.toList;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.config.ConfigurationManager;
import org.onap.sdc.tosca.parser.utils.GeneralUtility;
import org.onap.sdc.tosca.parser.utils.SdcToscaUtility;
import org.onap.sdc.toscaparser.api.CapabilityAssignment;
import org.onap.sdc.toscaparser.api.CapabilityAssignments;
import org.onap.sdc.toscaparser.api.Group;
import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.Policy;
import org.onap.sdc.toscaparser.api.Property;
import org.onap.sdc.toscaparser.api.RequirementAssignment;
import org.onap.sdc.toscaparser.api.RequirementAssignments;
import org.onap.sdc.toscaparser.api.SubstitutionMappings;
import org.onap.sdc.toscaparser.api.TopologyTemplate;
import org.onap.sdc.toscaparser.api.ToscaTemplate;
import org.onap.sdc.toscaparser.api.elements.InterfacesDef;
import org.onap.sdc.toscaparser.api.elements.Metadata;
import org.onap.sdc.toscaparser.api.elements.NodeType;
import org.onap.sdc.toscaparser.api.functions.Function;
import org.onap.sdc.toscaparser.api.parameters.Input;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SdcCsarHelperImpl implements ISdcCsarHelper {

    private static final String PATH_DELIMITER = "#";
    private static final String CUSTOMIZATION_UUID = "customizationUUID";
    private ToscaTemplate toscaTemplate;
    private ConfigurationManager configurationManager;
    private static Logger log = LoggerFactory.getLogger(SdcCsarHelperImpl.class.getName());

    public SdcCsarHelperImpl(ToscaTemplate toscaTemplate) {
        this.toscaTemplate = toscaTemplate;
    }

    public SdcCsarHelperImpl(ToscaTemplate toscaTemplate, ConfigurationManager configurationManager) {
        this.toscaTemplate = toscaTemplate;
        this.configurationManager = configurationManager;
    }
    
    @Override
    public List<Policy> getPoliciesOfTarget(NodeTemplate nodeTemplate) {
    	return getPoliciesOfNodeTemplate(nodeTemplate.getName())
    	.stream()
    	.sorted(Policy::compareTo)
    	.collect(toList());
    }
    
    @Override
	public List<Policy> getPoliciesOfOriginOfNodeTemplate(NodeTemplate nodeTemplate) {
    	if(StringUtils.isNotEmpty(nodeTemplate.getName())){
    		return getNodeTemplateByName(nodeTemplate.getName()).getOriginComponentTemplate().getPolicies();
    	}
    	return new ArrayList<>();
    }
    
    @Override
    public List<Policy> getPoliciesOfTargetByToscaPolicyType(NodeTemplate nodeTemplate, String policyTypeName) {
    	return getPoliciesOfNodeTemplate(nodeTemplate.getName())
    	.stream()
    	.filter(p->p.getType().equals(policyTypeName))
    	.sorted(Policy::compareTo)
    	.collect(toList());
    }
    
    @Override
    public List<Policy> getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(NodeTemplate nodeTemplate, String policyTypeName) {
    	return getPoliciesOfOriginOfNodeTemplate(nodeTemplate)
    	.stream()
    	.filter(p->p.getType().equals(policyTypeName))
    	.sorted(Policy::compareTo)
    	.collect(toList());
    }

    @Override
    public List<NodeTemplate> getPolicyTargetsFromTopologyTemplate(String policyName) {
    	if(toscaTemplate.getNodeTemplates() == null){
    		return new ArrayList<>();
    	}
    	List<String> targetNames = getPolicyTargets(policyName);
    	return toscaTemplate.getNodeTemplates().stream()
    			.filter(nt->targetNames.contains(nt.getName()))
    			.collect(toList());
    }
	
	@Override
	public List<NodeTemplate> getPolicyTargetsFromOrigin(NodeTemplate nodeTemplate, String policyName) {
		Optional<Policy> policyOpt = null;
    	if(StringUtils.isNotEmpty(nodeTemplate.getName())){
    		policyOpt = getNodeTemplateByName(nodeTemplate.getName()).getOriginComponentTemplate().getPolicies().stream().filter(p -> p.getName().equals(policyName)).findFirst();
    	}
    	if(policyOpt.isPresent()){
    		List<String> targets = policyOpt.get().getTargets();
    		return nodeTemplate.getOriginComponentTemplate().getNodeTemplates()
    				.stream()
    				.filter(nt -> targets.contains(nt.getName())).collect(Collectors.toList());
    	}
    	return new ArrayList<>();
    }
	
	@Override
	public List<Policy> getPoliciesOfTopologyTemplate(){
    	if(toscaTemplate.getPolicies() == null)
    		return new ArrayList<>();
    	return toscaTemplate.getPolicies()
    	.stream()
    	.sorted(Policy::compareTo)
    	.collect(toList());
	}
	
	@Override
	public List<Policy> getPoliciesOfTopologyTemplateByToscaPolicyType(String policyTypeName){
    	if(toscaTemplate.getPolicies() == null)
    		return new ArrayList<>();
    	return toscaTemplate.getPolicies()
    	.stream()
    	.filter(p->p.getType().equals(policyTypeName))
    	.sorted(Policy::compareTo)
    	.collect(toList());
	}
	
    public NodeTemplate getNodeTemplateByName(String nodeTemplateName) {
    	if(toscaTemplate.getNodeTemplates() == null)
    		return null;
    	return toscaTemplate.getNodeTemplates()
    	.stream()
    	.filter(nt -> nt.getName().equals(nodeTemplateName))
    	.findFirst().orElse(null);
    }
    
    private List<Policy> getPoliciesOfNodeTemplate(String nodeTemplateName) {
    	if(toscaTemplate.getPolicies() == null)
    		return new ArrayList<>();
    	return toscaTemplate.getPolicies()
    	.stream()
    	.filter(p -> p.getTargets().contains(nodeTemplateName))
    	.collect(toList());
    }
    
    private List<String> getPolicyTargets(String policyName) {
    	return getPolicyByName(policyName).map(Policy::getTargets).orElse(new ArrayList<>());
    }
    
    private List<String> getGroupMembers(String groupName) {
    	return getGroupByName(groupName).map(Group::getMembers).orElse(new ArrayList<>());
    }
    
    private Optional<Policy> getPolicyByName(String policyName) {
    	if(toscaTemplate.getPolicies() == null)
    		return Optional.empty();
    	return toscaTemplate.getPolicies()
    	.stream()
    	.filter(p -> p.getName().equals(policyName)).findFirst();
    }
    
    private Optional<Group> getGroupByName(String groupName) {
    	if(toscaTemplate.getGroups() == null)
    		return Optional.empty();
    	return toscaTemplate.getGroups()
    	.stream()
    	.filter(g -> g.getName().equals(groupName)).findFirst();
    }
    
    @Override
    //Sunny flow  - covered with UT, flat and nested
    public String getNodeTemplatePropertyLeafValue(NodeTemplate nodeTemplate, String leafValuePath) {
        if (nodeTemplate == null) {
            log.error("getNodeTemplatePropertyLeafValue - nodeTemplate is null");
            return null;
        }
        if (GeneralUtility.isEmptyString(leafValuePath)) {
            log.error("getNodeTemplatePropertyLeafValue - leafValuePath is null or empty");
            return null;
        }
        String[] split = getSplittedPath(leafValuePath);
        LinkedHashMap<String, Property> properties = nodeTemplate.getProperties();
        Object property = processProperties(split, properties);
        return property == null || property instanceof Function ? null : String.valueOf(property);
    }

    @Override
    public Object getNodeTemplatePropertyAsObject(NodeTemplate nodeTemplate, String leafValuePath) {
        if (nodeTemplate == null) {
            log.error("getNodeTemplatePropertyAsObject - nodeTemplate is null");
            return null;
        }
        if (GeneralUtility.isEmptyString(leafValuePath)) {
            log.error("getNodeTemplatePropertyAsObject - leafValuePath is null or empty");
            return null;
        }
        String[] split = getSplittedPath(leafValuePath);
        LinkedHashMap<String, Property> properties = nodeTemplate.getProperties();
        return processProperties(split, properties);
    }
    
    public Map<String, Map<String, Object>> getCpPropertiesFromVfcAsObject(NodeTemplate vfc) {
        if (vfc == null) {
            log.error("getCpPropertiesFromVfc - vfc is null");
            return new HashMap<>();
        }

        String presetProperty = "_ip_requirements";
        Map<String, Map<String, Object>> cps = new HashMap<>();

        Map<String, Property> props = vfc.getProperties();
        if (props != null) {
            // find all port names by pre-set property (ip_requirements)
            for (Map.Entry<String, Property> entry : props.entrySet()) {
                if (entry.getKey().endsWith(presetProperty)) {
                    String portName = entry.getKey().replaceAll(presetProperty, "");
                    cps.put(portName, new HashMap<>());
                }
            }

            findPutAllPortsProperties(cps, props);
        }

        return cps;
    }

	private void findPutAllPortsProperties(Map<String, Map<String, Object>> cps, Map<String, Property> props) {
		if (!cps.isEmpty()) {
		    for (Entry<String, Map<String, Object>> port : cps.entrySet()) {
		        for (Map.Entry<String, Property> property: props.entrySet()) {
		            if (property.getKey().startsWith(port.getKey())) {
		                String portProperty = property.getKey().replaceFirst(port.getKey() + "_", "");
		                if (property.getValue() != null) {
		                    cps.get(port.getKey()).put(portProperty, property.getValue().getValue());
		                }
		            }
		        }
		    }
		}
	}

    public Map<String, Map<String, Object>> getCpPropertiesFromVfc(NodeTemplate vfc) {

        if (vfc == null) {
            log.error("getCpPropertiesFromVfc - vfc is null");
            return new HashMap<>();
        }

        String presetProperty = "_ip_requirements";
        Map<String, Map<String, Object>> cps = new HashMap<>();

        Map<String, Property> props = vfc.getProperties();
        if (props != null) {
            // find all port names by pre-set property (ip_requirements)
            for (Map.Entry<String, Property> entry : props.entrySet()) {
                if (entry.getKey().endsWith(presetProperty)) {
                    String portName = entry.getKey().replaceAll(presetProperty, "");
                    cps.put(portName, new HashMap<>());
                }
            }
            findBuildPutAllPortsProperties(cps, props);
        }

        return cps;
    }

	private void findBuildPutAllPortsProperties(Map<String, Map<String, Object>> cps, Map<String, Property> props) {
		if (!cps.isEmpty()) {
		    for (Entry<String, Map<String, Object>> port : cps.entrySet()) {
		        for (Map.Entry<String, Property> property: props.entrySet()) {
		            if (property.getKey().startsWith(port.getKey())) {
		                Map<String, Object> portPaths = new HashMap<>();
		                String portProperty = property.getKey().replaceFirst(port.getKey() + "_", "");
		                buildPathMappedToValue(portProperty, property.getValue().getValue(), portPaths);
		                cps.get(port.getKey()).putAll(portPaths);
		            }
		        }
		    }
		}
	}

    @SuppressWarnings("unchecked")
    private void buildPathMappedToValue(String path, Object property, Map<String, Object> pathsMap) {
        if (property instanceof Map) {
            for (Map.Entry<String, Object> item : ((Map<String, Object>) property).entrySet()) {
                if (item.getValue() instanceof Map || item.getValue() instanceof List) {
                    buildPathMappedToValue(path + PATH_DELIMITER + item.getKey(), item.getValue(), pathsMap);
                } else {
                    pathsMap.put(path + PATH_DELIMITER + item.getKey(), item.getValue());
                }
            }
        } else if (property instanceof List) {
            for (Object item: (List<Object>)property) {
                buildPathMappedToValue(path, item, pathsMap);
            }
        } else {
            pathsMap.put(path, property);
        }

    }

    @Override
    //Sunny flow - covered with UT
    public List<NodeTemplate> getServiceVlList() {
        return getNodeTemplateBySdcType(toscaTemplate.getTopologyTemplate(), SdcTypes.VL);
    }

    @Override
    //Sunny flow - covered with UT
    public List<NodeTemplate> getServiceVfList() {
        return getNodeTemplateBySdcType(toscaTemplate.getTopologyTemplate(), SdcTypes.VF);
    }

    @Override
    //Sunny flow - covered with UT
    public String getMetadataPropertyValue(Metadata metadata, String metadataPropertyName) {
        if (GeneralUtility.isEmptyString(metadataPropertyName)) {
            log.error("getMetadataPropertyValue - the metadataPropertyName is null or empty");
            return null;
        }
        if (metadata == null) {
            log.error("getMetadataPropertyValue - the metadata is null");
            return null;
        }
        return metadata.getValue(metadataPropertyName);
    }


    @Override
    //Sunny flow - covered with UT
    public List<NodeTemplate> getServiceNodeTemplatesByType(String nodeType) {
        if (GeneralUtility.isEmptyString(nodeType)) {
            log.error("getServiceNodeTemplatesByType - nodeType - is null or empty");
            return new ArrayList<>();
        }

        List<NodeTemplate> res = new ArrayList<>();
        List<NodeTemplate> nodeTemplates = toscaTemplate.getNodeTemplates();
        for (NodeTemplate nodeTemplate : nodeTemplates) {
            if (nodeType.equals(nodeTemplate.getTypeDefinition().getType())) {
                res.add(nodeTemplate);
            }
        }

        return res;
    }


    @Override
    public List<NodeTemplate> getServiceNodeTemplates() {
        return toscaTemplate.getNodeTemplates();
    }

    @Override
    //Sunny flow - covered with UT
    public List<NodeTemplate> getVfcListByVf(String vfCustomizationId) {
        if (GeneralUtility.isEmptyString(vfCustomizationId)) {
            log.error("getVfcListByVf - vfCustomizationId - is null or empty");
            return new ArrayList<>();
        }

        List<NodeTemplate> serviceVfList = getServiceVfList();
        NodeTemplate vfInstance = getNodeTemplateByCustomizationUuid(serviceVfList, vfCustomizationId);
        List<NodeTemplate> vfcs = getNodeTemplateBySdcType(vfInstance, SdcTypes.VFC);
        vfcs.addAll(getNodeTemplateBySdcType(vfInstance, SdcTypes.CVFC));

        return vfcs;
    }

    @Override
    //Sunny flow - covered with UT
    public List<Group> getVfModulesByVf(String vfCustomizationUuid) {
        List<NodeTemplate> serviceVfList = getServiceVfList();
        NodeTemplate nodeTemplateByCustomizationUuid = getNodeTemplateByCustomizationUuid(serviceVfList, vfCustomizationUuid);
        if (nodeTemplateByCustomizationUuid != null) {
            String name = nodeTemplateByCustomizationUuid.getName();
            String normaliseComponentInstanceName = SdcToscaUtility.normaliseComponentInstanceName(name);
            List<Group> serviceLevelGroups = toscaTemplate.getTopologyTemplate().getGroups();
            log.debug("getVfModulesByVf - VF node template name {}, normalized name {}. Searching groups on service level starting with VF normalized name...", name, normaliseComponentInstanceName);
            if (serviceLevelGroups != null) {
                return serviceLevelGroups
                        .stream()
                        .filter(x -> "org.openecomp.groups.VfModule".equals(x.getTypeDefinition().getType()) && x.getName().startsWith(normaliseComponentInstanceName))
                        .collect(toList());
            }
        }
        return new ArrayList<>();
    }

    @Override
    //Sunny flow - covered with UT
    public String getServiceInputLeafValueOfDefault(String inputLeafValuePath) {
        if (GeneralUtility.isEmptyString(inputLeafValuePath)) {
            log.error("getServiceInputLeafValueOfDefault - inputLeafValuePath is null or empty");
            return null;
        }

        String[] split = getSplittedPath(inputLeafValuePath);
        if (split.length < 2 || !split[1].equals("default")) {
            log.error("getServiceInputLeafValue - inputLeafValuePath should be of format <input name>#default[optionally #<rest of path>] ");
            return null;
        }

        List<Input> inputs = toscaTemplate.getInputs();
        if (inputs != null) {
            Optional<Input> findFirst = inputs.stream().filter(x -> x.getName().equals(split[0])).findFirst();
            if (findFirst.isPresent()) {
                Input input = findFirst.get();
                Object current = input.getDefault();
                Object property = iterateProcessPath(2, current, split);
                return property == null || property instanceof Function? null : String.valueOf(property);
            }
        }
        log.error("getServiceInputLeafValue - value not found");
        return null;
    }

    @Override
    public Object getServiceInputLeafValueOfDefaultAsObject(String inputLeafValuePath) {
        if (GeneralUtility.isEmptyString(inputLeafValuePath)) {
            log.error("getServiceInputLeafValueOfDefaultAsObject - inputLeafValuePath is null or empty");
            return null;
        }

        String[] split = getSplittedPath(inputLeafValuePath);
        if (split.length < 2 || !split[1].equals("default")) {
            log.error("getServiceInputLeafValueOfDefaultAsObject - inputLeafValuePath should be of format <input name>#default[optionally #<rest of path>] ");
            return null;
        }

        List<Input> inputs = toscaTemplate.getInputs();
        if (inputs != null) {
            Optional<Input> findFirst = inputs.stream().filter(x -> x.getName().equals(split[0])).findFirst();
            if (findFirst.isPresent()) {
                Input input = findFirst.get();
                Object current = input.getDefault();
                return iterateProcessPath(2, current, split);
            }
        }
        log.error("getServiceInputLeafValueOfDefaultAsObject - value not found");
        return null;
    }

    @SuppressWarnings({ "unchecked", "rawtypes" })
    private Object iterateProcessPath(Integer index, Object current, String[] split) {
        if (current == null) {
            log.error("iterateProcessPath - this input has no default");
            return null;
        }
        if (split.length > index) {
            for (int i = index; i < split.length; i++) {
                if (current instanceof Map) {
                    current = ((Map<String, Object>) current).get(split[i]);
                } else if (current instanceof List) {
                    current = ((List) current).get(0);
                    i--;
                }
                 else {
                        log.error("iterateProcessPath - found an unexpected leaf where expected to find a complex type");
                        return null;
                }
            }
        }
        if (current != null) {
            return current;
        }
        log.error("iterateProcessPath - Path not Found");
        return null;
    }

    private String[] getSplittedPath(String inputLeafValuePath) {
        return inputLeafValuePath.split(PATH_DELIMITER);
    }


    @Override
    //Sunny flow - covered with UT
    public String getServiceSubstitutionMappingsTypeName() {
        SubstitutionMappings substitutionMappings = toscaTemplate.getTopologyTemplate().getSubstitutionMappings();
        if (substitutionMappings == null) {
            log.debug("getServiceSubstitutionMappingsTypeName - No Substitution Mappings defined");
            return null;
        }

        NodeType nodeType = substitutionMappings.getNodeDefinition();
        if (nodeType == null) {
            log.debug("getServiceSubstitutionMappingsTypeName - No Substitution Mappings node defined");
            return null;
        }

        return nodeType.getType();
    }

    @Override
    //Sunny flow - covered with UT
    public Metadata getServiceMetadata() {
        return toscaTemplate.getMetaData();
    }

    @Override
    //Sunny flow - covered with UT
    public Map<String, Object> getServiceMetadataProperties() {
        if (toscaTemplate.getMetaData() == null){
            return null;
        }
        return new HashMap<>(toscaTemplate.getMetaData().getAllProperties());
    }

    @Override
    public Map<String, String> getServiceMetadataAllProperties() {
        if (toscaTemplate.getMetaData() == null){
            return null;
        }
        return toscaTemplate.getMetaData().getAllProperties();
    }

    @Override
    //Sunny flow - covered with UT
    public List<Input> getServiceInputs() {
        return toscaTemplate.getInputs();
    }

    @Override
    //Sunny flow - covered with UT
    public String getGroupPropertyLeafValue(Group group, String leafValuePath) {
        if (group == null) {
            log.error("getGroupPropertyLeafValue - group is null");
            return null;
        }

        if (GeneralUtility.isEmptyString(leafValuePath)) {
            log.error("getGroupPropertyLeafValue - leafValuePath is null or empty");
            return null;
        }

        String[] split = getSplittedPath(leafValuePath);
        LinkedHashMap<String, Property> properties = group.getProperties();
        Object property = processProperties(split, properties);
        return property == null || property instanceof Function? null : String.valueOf(property);
    }

    @Override
    public Object getGroupPropertyAsObject(Group group, String leafValuePath) {
        if (group == null) {
            log.error("getGroupPropertyAsObject - group is null");
            return null;
        }

        if (GeneralUtility.isEmptyString(leafValuePath)) {
            log.error("getGroupPropertyAsObject - leafValuePath is null or empty");
            return null;
        }

        String[] split = getSplittedPath(leafValuePath);
        LinkedHashMap<String, Property> properties = group.getProperties();
        return processProperties(split, properties);
    }

    @Override
    //Sunny flow - covered with UT
    public List<NodeTemplate> getCpListByVf(String vfCustomizationId) {
        List<NodeTemplate> cpList = new ArrayList<>();
        if (GeneralUtility.isEmptyString(vfCustomizationId)) {
            log.error("getCpListByVf vfCustomizationId string is empty");
            return cpList;
        }

        List<NodeTemplate> serviceVfList = getServiceVfList();
        if (serviceVfList == null || serviceVfList.isEmpty()) {
            log.error("getCpListByVf Vfs not exist for vfCustomizationId {}", vfCustomizationId);
            return cpList;
        }
        NodeTemplate vfInstance = getNodeTemplateByCustomizationUuid(serviceVfList, vfCustomizationId);
        if (vfInstance == null) {
            log.debug("getCpListByVf vf list is null");
            return cpList;
        }
        cpList = getNodeTemplateBySdcType(vfInstance, SdcTypes.CP);
        if (cpList == null || cpList.isEmpty())
            log.debug("getCpListByVf cps not exist for vfCustomizationId {}", vfCustomizationId);
        return cpList;
    }

    @Override
    //Sunny flow - covered with UT
    public List<NodeTemplate> getMembersOfVfModule(NodeTemplate vf, Group serviceLevelVfModule) {
        if (vf == null) {
            log.error("getMembersOfVfModule - vf is null");
            return new ArrayList<>();
        }

        if (serviceLevelVfModule == null || serviceLevelVfModule.getMetadata() == null || serviceLevelVfModule.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID) == null) {
            log.error("getMembersOfVfModule - vfModule or its metadata is null. Cannot match a VF group based on invariantUuid from missing metadata.");
            return new ArrayList<>();
        }


        SubstitutionMappings substitutionMappings = vf.getSubMappingToscaTemplate();
        if (substitutionMappings != null) {
            List<Group> groups = substitutionMappings.getGroups();
            if (groups != null) {
                Optional<Group> findFirst = groups
                        .stream()
                        .filter(x -> (x.getMetadata() != null && serviceLevelVfModule.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID).equals(x.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)))).findFirst();
                if (findFirst.isPresent()) {
                    List<String> members = findFirst.get().getMembers();
                    if (members != null) {
                        return substitutionMappings.getNodeTemplates().stream().filter(x -> members.contains(x.getName())).collect(toList());
                    }
                }
            }
        }
        return new ArrayList<>();
    }

    @Override
    public List<Pair<NodeTemplate, NodeTemplate>> getNodeTemplatePairsByReqName(
            List<NodeTemplate> listOfReqNodeTemplates, List<NodeTemplate> listOfCapNodeTemplates, String reqName) {

        if (listOfReqNodeTemplates == null) {
            log.error("getNodeTemplatePairsByReqName - listOfReqNodeTemplates is null");
            return new ArrayList<>();
        }

        if (listOfCapNodeTemplates == null) {
            log.error("getNodeTemplatePairsByReqName - listOfCapNodeTemplates is null");
            return new ArrayList<>();
        }

        if (GeneralUtility.isEmptyString(reqName)) {
            log.error("getNodeTemplatePairsByReqName - reqName is null or empty");
            return new ArrayList<>();
        }

        List<Pair<NodeTemplate, NodeTemplate>> pairsList = new ArrayList<>();

        for (NodeTemplate reqNodeTemplate : listOfReqNodeTemplates) {
            List<RequirementAssignment> requirements = reqNodeTemplate.getRequirements().getRequirementsByName(reqName).getAll();
            for (RequirementAssignment reqEntry : requirements) {
                String node = reqEntry.getNodeTemplateName();
                if (node != null) {
                    Optional<NodeTemplate> findFirst = listOfCapNodeTemplates.stream().filter(x -> x.getName().equals(node)).findFirst();
                    if (findFirst.isPresent()) {
                        pairsList.add(new ImmutablePair<NodeTemplate, NodeTemplate>(reqNodeTemplate, findFirst.get()));
                    }
                }
            }
        }

        return pairsList;
    }

    @Override
    //Sunny flow - covered with UT
    public List<NodeTemplate> getAllottedResources() {
        List<NodeTemplate> nodeTemplates = null;
        nodeTemplates = toscaTemplate.getTopologyTemplate().getNodeTemplates();
        if (nodeTemplates.isEmpty()) {
            log.error("getAllottedResources nodeTemplates not exist");
        }
        nodeTemplates = nodeTemplates.stream().filter(
                x -> x.getMetaData() != null && x.getMetaData().getValue("category").equals("Allotted Resource"))
                .collect(toList());
        if (nodeTemplates.isEmpty()) {
            log.debug("getAllottedResources -  allotted resources not exist");
        }
        return nodeTemplates;
    }

    @Override
    //Sunny flow - covered with UT
    public String getTypeOfNodeTemplate(NodeTemplate nodeTemplate) {
        if (nodeTemplate == null) {

            log.error("getTypeOfNodeTemplate nodeTemplate is null");
            return null;
        }
        return nodeTemplate.getTypeDefinition().getType();
    }

    /**
     * This methdd is returning the csarConformanceLevel for input CSAR
     * When csarConformanceLevel is configured with failOnError as False in Error Configuration; it
     * assigns the default value to csarConformanceLevel which is the max level provided in
     * Configuration file
     * @return csarConformanceLevel
     */
    @Override
    public String getConformanceLevel() {
      LinkedHashMap<String, Object> csarMeta = toscaTemplate.getMetaProperties("csar.meta");
      if (csarMeta == null){
        log.warn("No csar.meta file is found in CSAR - this file should hold the conformance level of the CSAR. This might be OK for older CSARs.");
        if (configurationManager != null && !configurationManager.getErrorConfiguration()
            .getErrorInfo("CONFORMANCE_LEVEL_ERROR").getFailOnError()){
          String csarConLevel = configurationManager.getConfiguration().getConformanceLevel().getMaxVersion();
          log.warn("csarConformanceLevel is not found in input csar; defaulting to max version {}" , csarConLevel);
          return csarConLevel;
        }
        else {
          log.warn("csarConformanceLevel is not found in input csar; returning null as no defaults defined in error configuration");
          return null;
        }
      }

      Object conformanceLevel = csarMeta.get("SDC-TOSCA-Definitions-Version");
      if (conformanceLevel != null){
        String confLevelStr = conformanceLevel.toString();
        log.debug("CSAR conformance level is {}", confLevelStr);
        return confLevelStr;
      } else {
        log.error("Invalid csar.meta file - no entry found for SDC-TOSCA-Definitions-Version key. This entry should hold the conformance level.");
        return null;
      }
    }
	
	
	@Override
	public String getNodeTemplateCustomizationUuid(NodeTemplate nt) {
		String res = null;
		if (nt != null && nt.getMetaData() != null){
			res = nt.getMetaData().getValue(CUSTOMIZATION_UUID);
		} else {
			log.error("Node template or its metadata is null");
		}
		return res;
	}

    public List<NodeTemplate> getNodeTemplateBySdcType(NodeTemplate parentNodeTemplate, SdcTypes sdcType) {
    	return getNodeTemplateBySdcType(parentNodeTemplate, sdcType, false); 
    }
    
    private List<NodeTemplate> getNodeTemplateBySdcType(NodeTemplate parentNodeTemplate, SdcTypes sdcType, boolean isVNF)  {
    	
    	if (parentNodeTemplate == null) {
            log.error("getNodeTemplateBySdcType - nodeTemplate is null or empty");
            return new ArrayList<>();
        }

        if (sdcType == null) {
            log.error("getNodeTemplateBySdcType - sdcType is null or empty");
            return new ArrayList<>();
        }

        SubstitutionMappings substitutionMappings = parentNodeTemplate.getSubMappingToscaTemplate();

        if (substitutionMappings != null) {
            List<NodeTemplate> nodeTemplates = substitutionMappings.getNodeTemplates();
            if (nodeTemplates != null && !nodeTemplates.isEmpty()) {
            	if (sdcType.equals(SdcTypes.VFC) && isVNF)  {
            		return nodeTemplates.stream()
                    		.filter(x -> (x.getMetaData() != null &&
                    			sdcType.getValue().equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE))) &&  isVNFType(x))
                    		.collect(toList());
            	}
            	else {
                    return nodeTemplates.stream()
                    		.filter(x -> (x.getMetaData() != null &&
                    			sdcType.getValue().equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE))) &&  !isVNFType(x))
                    		.collect(toList());
            	}
            }
            else {
                log.debug("getNodeTemplateBySdcType - SubstitutionMappings' node Templates not exist");
            }
        } else
            log.debug("getNodeTemplateBySdcType - SubstitutionMappings not exist");

        return new ArrayList<>();
    }

    public Map<String, String> filterNodeTemplatePropertiesByValue(NodeTemplate nodeTemplate, FilterType filterType, String pattern) {
        Map<String, String> filterMap = new HashMap<>();

        if (nodeTemplate == null) {
            log.error("filterNodeTemplatePropertiesByValue nodeTemplate is null");
            return filterMap;
        }

        if (filterType == null) {
            log.error("filterNodeTemplatePropertiesByValue filterType is null");
            return filterMap;
        }

        if (GeneralUtility.isEmptyString(pattern)) {
            log.error("filterNodeTemplatePropertiesByValue pattern string is empty");
            return filterMap;
        }

        Map<String, Property> ntProperties = nodeTemplate.getProperties();

        if (ntProperties != null && ntProperties.size() > 0) {

            for (Property current : ntProperties.values()) {
                filterProperties(current.getValue(), current.getName(), filterType, pattern, filterMap);
            }
        }

        log.trace("filterNodeTemplatePropertiesByValue - filterMap value: {}", filterMap);

        return filterMap;
    }
    
	public NodeTemplate getVnfConfig(String vfCustomizationUuid) {
		
		if (GeneralUtility.isEmptyString(vfCustomizationUuid)) {
            log.error("getVnfConfig - vfCustomizationId - is null or empty");
            return null;
        }

        List<NodeTemplate> serviceVfList = getServiceVfList();
        NodeTemplate vfInstance = getNodeTemplateByCustomizationUuid(serviceVfList, vfCustomizationUuid);
        return getNodeTemplateBySdcType(vfInstance, SdcTypes.VFC, true).stream().findAny().orElse(null);
	}

    @Override
    public boolean hasTopology(NodeTemplate nodeTemplate) {
        if (nodeTemplate == null) {
            log.error("hasTopology - nodeTemplate - is null");
            return false;
        }

        if (nodeTemplate.getMetaData() != null) {
            String type = nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE);
            log.debug("hasTopology - node template {} is a {} type", nodeTemplate.getName(), type);
            return SdcTypes.isComplex(type);
        }

        return false;
    }

    @Override
    public List<NodeTemplate> getNodeTemplateChildren(NodeTemplate nodeTemplate) {
        if (nodeTemplate == null) {
            log.error("getNodeTemplateChildren - nodeTemplate - is null");
            return new ArrayList<>();
        }

        SubstitutionMappings substitutionMappings = nodeTemplate.getSubMappingToscaTemplate();
        if (substitutionMappings != null) {
            List<NodeTemplate> nodeTemplates = substitutionMappings.getNodeTemplates();
            if (nodeTemplates != null && !nodeTemplates.isEmpty()) {

                return nodeTemplates.stream()
                        .filter(x -> !isVNFType(x))
                        .collect(toList());
            }
            else {
                log.debug("getNodeTemplateChildren - SubstitutionMappings' node Templates not exist");
            }
        } else
            log.debug("getNodeTemplateChildren - SubstitutionMappings not exist");

        return new ArrayList<>();
    }

    @Override
    public NodeTemplate getServiceNodeTemplateByNodeName(String nodeName) {
        if (GeneralUtility.isEmptyString(nodeName)) {
            log.error("getServiceNodeTemplateByNodeName - nodeName - is null or empty");
            return null;
        }

        List<NodeTemplate> nodeTemplates = getServiceNodeTemplates();
        Optional<NodeTemplate> findFirst =  nodeTemplates.stream().filter(nt -> nt.getName().equals(nodeName)).findFirst();

        return findFirst.isPresent() ? findFirst.get() : null;
    }

    @Override
    public Metadata getNodeTemplateMetadata(NodeTemplate nt) {
        if (nt == null) {
            log.error("getNodeTemplateMetadata - nt (node template) - is null");
            return null;
        }

        return nt.getMetaData();
    }

    @Override
    public CapabilityAssignments getCapabilitiesOf(NodeTemplate nt) {
        if (nt == null) {
            log.error("getCapabilitiesOf - nt (node template) - is null");
            return null;
        }

        return nt.getCapabilities();
    }

    @Override
    public RequirementAssignments getRequirementsOf(NodeTemplate nt) {
        if (nt == null) {
            log.error("getRequirementsOf - nt (node template) - is null");
            return null;
        }

        return nt.getRequirements();
    }

    @Override
    public String getCapabilityPropertyLeafValue(CapabilityAssignment capability, String pathToPropertyLeafValue) {
        if (capability == null) {
            log.error("getCapabilityPropertyLeafValue - capability is null");
            return null;
        }

        if (GeneralUtility.isEmptyString(pathToPropertyLeafValue)) {
            log.error("getCapabilityPropertyLeafValue - pathToPropertyLeafValue is null or empty");
            return null;
        }

        String[] split = getSplittedPath(pathToPropertyLeafValue);
        LinkedHashMap<String, Property> properties = capability.getProperties();
        Object property = processProperties(split, properties);
        return property == null || property instanceof Function ? null : String.valueOf(property);
    }
    
    @Override
    public ArrayList<Group> getGroupsOfOriginOfNodeTemplate(NodeTemplate nodeTemplate) {
    	if(StringUtils.isNotEmpty(nodeTemplate.getName())){
    		return getNodeTemplateByName(nodeTemplate.getName()).getSubMappingToscaTemplate().getGroups();
    	}
    	return new ArrayList<>();
    }

    @Override
    public ArrayList<Group> getGroupsOfTopologyTemplateByToscaGroupType(String groupType) {
       	if(toscaTemplate.getGroups() == null)
       		return new ArrayList<>();
       	return (ArrayList<Group>) toscaTemplate.getGroups()
       	.stream()
       	.filter(g->g.getType().equals(groupType))
       	.sorted(Group::compareTo)
       	.collect(toList());
    }
    
    @Override
    public ArrayList<Group> getGroupsOfTopologyTemplate() {
    	return toscaTemplate.getGroups() == null ? new ArrayList<>() : toscaTemplate.getGroups();
    }
    
    @Override
    public ArrayList<Group> getGroupsOfOriginOfNodeTemplateByToscaGroupType(NodeTemplate nodeTemplate, String groupType) {
    	return (ArrayList<Group>) getGroupsOfOriginOfNodeTemplate(nodeTemplate)
    	.stream()
    	.filter(g->g.getType().equals(groupType))
    	.sorted(Group::compareTo)
    	.collect(toList());
    }

    @Override
    public List<NodeTemplate> getGroupMembersFromTopologyTemplate(String groupName) {
       	if(toscaTemplate.getNodeTemplates() == null){
       		return new ArrayList<>();
       	}
       	List<String> membersNames = getGroupMembers(groupName);
       	return toscaTemplate.getNodeTemplates().stream()
      			.filter(nt->membersNames.contains(nt.getName()))
     			.collect(toList());
    }
    

    @Override
    public List<NodeTemplate> getGroupMembersOfOriginOfNodeTemplate(NodeTemplate nodeTemplate, String groupName) {
		ArrayList<Group> groups = getGroupsOfOriginOfNodeTemplate(nodeTemplate);
		if(!groups.isEmpty()){
			Optional<Group> group = groups.stream().filter(g -> g.getName().equals(groupName)).findFirst();
			if(group.isPresent()){
				return nodeTemplate.getSubMappingToscaTemplate().getNodeTemplates().stream()
				.filter(nt -> group.get().getMembers().contains(nt.getName()))
				.collect(toList());
			}
		}
		return new ArrayList<>();
    }
    
    public List<NodeTemplate> getServiceNodeTemplateBySdcType(SdcTypes sdcType) {
    	if (sdcType == null) {
    		log.error("getServiceNodeTemplateBySdcType - sdcType is null or empty");
    		return new ArrayList<>();
    	}
    	
    	TopologyTemplate topologyTemplate = toscaTemplate.getTopologyTemplate();
    	return getNodeTemplateBySdcType(topologyTemplate, sdcType);
    }

	/************************************* helper functions ***********************************/
    private boolean isVNFType(NodeTemplate nt) {
        return nt.getType().endsWith("VnfConfiguration");
    }

    @SuppressWarnings("unchecked")
    private Map<String, String> filterProperties(Object property, String path, FilterType filterType, String pattern, Map<String, String> filterMap) {

        if (property instanceof Map) {
            for (Map.Entry<String, Object> item: ((Map<String, Object>) property).entrySet()) {
                String itemPath = path + PATH_DELIMITER + item.getKey();
                filterProperties(item.getValue(), itemPath, filterType, pattern, filterMap);
            }
        } else if (property instanceof List) {
            for (Object item: (List<Object>)property) {
                filterProperties(item, path, filterType, pattern, filterMap);
            }
        } else {
            if (filterType.isMatch(property.toString(), pattern)) {
                filterMap.put(path, property.toString());
            }
        }

        return filterMap;
    }
 
    /************************************* helper functions ***********************************/
    private List<NodeTemplate> getNodeTemplateBySdcType(TopologyTemplate topologyTemplate, SdcTypes sdcType) {
        if (sdcType == null) {
            log.error("getNodeTemplateBySdcType - sdcType is null or empty");
            return new ArrayList<>();
        }

        if (topologyTemplate == null) {
            log.error("getNodeTemplateBySdcType - topologyTemplate is null");
            return new ArrayList<>();
        }

        List<NodeTemplate> nodeTemplates = topologyTemplate.getNodeTemplates();

        if (nodeTemplates != null && !nodeTemplates.isEmpty())
            return nodeTemplates.stream().filter(x -> (x.getMetaData() != null && sdcType.getValue().equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)))).collect(toList());

        log.debug("getNodeTemplateBySdcType - topologyTemplate's nodeTemplates not exist");
        return new ArrayList<>();
    }

    //Assumed to be unique property for the list
    private NodeTemplate getNodeTemplateByCustomizationUuid(List<NodeTemplate> nodeTemplates, String customizationId) {
       if (customizationId != null) {
            Optional<NodeTemplate> findFirst = nodeTemplates.stream().filter(x -> (x.getMetaData() != null && customizationId.equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)))).findFirst();
            return findFirst.isPresent() ? findFirst.get() : null;
        }
        else {
            log.error("getNodeTemplateByCustomizationUuid - customizationId is null");
            return null;
        }
    }

    private Object processProperties(String[] split, LinkedHashMap<String, Property> properties) {
        Optional<Entry<String, Property>> findFirst = properties.entrySet().stream().filter(x -> x.getKey().equals(split[0])).findFirst();
        if (findFirst.isPresent()) {
            Property property = findFirst.get().getValue();
            Object current = property.getValue();
            return iterateProcessPath(1, current, split);
        }
        String propName = (split != null && split.length > 0 ? split[0] : null);
        log.error("processProperties - property {} not found", propName);
        return null;
    }

  @Override
  public Map<String, List<InterfacesDef>> getInterfacesOf(NodeTemplate nt){
    if (nt == null) {
      return null;
    }
    return nt.getAllInterfaceDetailsForNodeType();
  }

  @Override
  public List<String> getInterfaces(NodeTemplate nt){
    Map<String, List<InterfacesDef>> interfaceDetails = nt.getAllInterfaceDetailsForNodeType();
    return new ArrayList<>(interfaceDetails.keySet());
  }

  @Override
  public List<InterfacesDef> getInterfaceDetails(NodeTemplate nt, String interfaceName){
    Map<String, List<InterfacesDef>> interfaceDetails = nt.getAllInterfaceDetailsForNodeType();
    return interfaceDetails.get(interfaceName);
  }

  @Override
  public List<String> getAllInterfaceOperations(NodeTemplate nt, String interfaceName){
    Map<String, List<InterfacesDef>> interfaceDetails = nt.getAllInterfaceDetailsForNodeType();
    return interfaceDetails.values().stream().flatMap(List::stream).map(val -> val.getOperationName()).collect(
        Collectors.toList());
  }

  @Override
  public InterfacesDef getInterfaceOperationDetails(NodeTemplate nt, String interfaceName, String operationName){
    Map<String, List<InterfacesDef>> interfaceDetails = nt.getAllInterfaceDetailsForNodeType();
    if(!interfaceDetails.isEmpty()){
      List<InterfacesDef> interfaceDefs = interfaceDetails.get(interfaceName);
      return interfaceDefs.stream().filter(val -> val.getOperationName().equals(operationName)).findFirst().orElse(null);
    }
    return null;
  }

	@Override
	public List<Input> getInputsWithAnnotations() {
		return toscaTemplate.getInputs(true);
	}

}