- private <T extends PropertyDefinition> void validateToscaGetFunction(T property, Component parentComponent) {
- final ToscaGetFunctionDataDefinition toscaGetFunction = (ToscaGetFunctionDataDefinition) property.getToscaFunction();
- validateGetToscaFunctionAttributes(toscaGetFunction);
- validateGetPropertySource(toscaGetFunction.getFunctionType(), toscaGetFunction.getPropertySource());
- if (toscaGetFunction.getFunctionType() == ToscaGetFunctionType.GET_INPUT) {
- validateGetFunction(property, parentComponent.getInputs(), parentComponent.getModel());
- return;
- }
- if (toscaGetFunction.getFunctionType() == ToscaGetFunctionType.GET_PROPERTY) {
- if (toscaGetFunction.getPropertySource() == PropertySource.SELF) {
- validateGetFunction(property, parentComponent.getProperties(), parentComponent.getModel());
- } else if (toscaGetFunction.getPropertySource() == PropertySource.INSTANCE) {
- final ComponentInstance componentInstance =
- parentComponent.getComponentInstanceById(toscaGetFunction.getSourceUniqueId())
- .orElseThrow(ToscaGetFunctionExceptionSupplier.instanceNotFound(toscaGetFunction.getSourceName()));
- validateGetFunction(property, componentInstance.getProperties(), parentComponent.getModel());
- }
-
- return;
- }
- if (toscaGetFunction.getFunctionType() == ToscaGetFunctionType.GET_ATTRIBUTE) {
- if (toscaGetFunction.getPropertySource() == PropertySource.SELF) {
- validateGetFunction(property, parentComponent.getAttributes(), parentComponent.getModel());
- } else if (toscaGetFunction.getPropertySource() == PropertySource.INSTANCE) {
- final ComponentInstance componentInstance =
- parentComponent.getComponentInstanceById(toscaGetFunction.getSourceUniqueId())
- .orElseThrow(ToscaGetFunctionExceptionSupplier.instanceNotFound(toscaGetFunction.getSourceName()));
- validateGetFunction(property, componentInstance.getAttributes(), parentComponent.getModel());
- }
-
- return;
- }
-
- throw ToscaGetFunctionExceptionSupplier.functionNotSupported(toscaGetFunction.getFunctionType()).get();
- }
-