class WorkflowActionBBTasks {

    protected void setInstanceName(String resourceId, WorkflowType resourceType, InfraActiveRequests request) {
        logger.debug("Setting instanceName in infraActiveRequest");
        try {
            if (resourceType == WorkflowType.SERVICE && request.getServiceInstanceName() == null) {
                ServiceInstance service = bbInputSetupUtils.getAAIServiceInstanceById(resourceId);
                if (service != null) {
                    request.setServiceInstanceName(service.getServiceInstanceName());
                }
            } else if (resourceType == WorkflowType.VNF && request.getVnfName() == null) {
                GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(resourceId);
                if (vnf != null) {
                    request.setVnfName(vnf.getVnfName());
                }
            } else if (resourceType == WorkflowType.VFMODULE && request.getVfModuleName() == null) {
                VfModule vfModule = bbInputSetupUtils.getAAIVfModule(request.getVnfId(), resourceId);
                if (vfModule != null) {
                    request.setVfModuleName(vfModule.getVfModuleName());
                }
            } else if (resourceType == WorkflowType.VOLUMEGROUP && request.getVolumeGroupName() == null) {
                Optional<VolumeGroup> volumeGroup =
                        bbInputSetupUtils.getRelatedVolumeGroupByIdFromVnf(request.getVnfId(), resourceId);
                volumeGroup.ifPresent(group -> request.setVolumeGroupName(group.getVolumeGroupName()));
            } else if (resourceType == WorkflowType.NETWORK && request.getNetworkName() == null) {
                L3Network network = bbInputSetupUtils.getAAIL3Network(resourceId);
                if (network != null) {
                    request.setNetworkName(network.getNetworkName());
                }
            } else if (resourceType == WorkflowType.CONFIGURATION && request.getConfigurationName() == null) {
                org.onap.aai.domain.yang.Configuration configuration =
                        bbInputSetupUtils.getAAIConfiguration(resourceId);
                if (configuration != null) {
                    request.setConfigurationName(configuration.getConfigurationName());
                }
            } else if (resourceType == WorkflowType.INSTANCE_GROUP && request.getInstanceGroupName() == null) {
                InstanceGroup instanceGroup = bbInputSetupUtils.getAAIInstanceGroup(resourceId);
                if (instanceGroup != null) {
                    request.setInstanceGroupName(instanceGroup.getInstanceGroupName());
                }
            }
        } catch (Exception ex) {
            logger.error("Exception in setInstanceName", ex);
        }
    }

}