/*
 * Copyright 2018 EPAM Systems
 *
 * 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 com.epam.ta.reportportal.info;

import com.epam.ta.reportportal.dao.ServerSettingsRepository;
import com.epam.ta.reportportal.entity.ServerSettings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

/**
 * Shows list of supported analytics providers and other server settings.
 *
 * @author Pavel Bortnik
 */

@Component
public class ServerSettingsInfoContributor implements ExtensionContributor {

	private static final String ANALYTICS_KEY = "analytics";
	private static final String INSTANCE_ID_KEY = "instanceId";

	private final ServerSettingsRepository settingsRepository;

	@Autowired
	@SuppressWarnings("SpringJavaAutowiringInspection")
	public ServerSettingsInfoContributor(ServerSettingsRepository settingsRepository) {
		this.settingsRepository = settingsRepository;
	}

	@Override
	public Map<String, ?> contribute() {
		Map<String, Object> info = new HashMap<>();
		Optional<ServerSettings> analyticsDetails = settingsRepository.findByKey("server.analytics.all");
		analyticsDetails.ifPresent(it -> info.put(ANALYTICS_KEY, it));
		return info;

	}
}

@@ -746,16 +746,131 @@
 ttings;%0A
+import com.epam.ta.reportportal.ws.model.settings.AnalyticsResource;%0Aimport org.apache.commons.lang3.BooleanUtils;%0A
 import o
@@ -1863,16 +1863,202 @@
 t(it -%3E 
+%7B%0A%09%09%09AnalyticsResource analyticsResource = new AnalyticsResource();%0A%09%09%09analyticsResource.setType(it.getKey());%0A%09%09%09analyticsResource.setEnabled(BooleanUtils.toBoolean(it.getValue()));%0A%09%09%09
 info.put
@@ -2077,11 +2077,31 @@
 EY, 
-it)
+analyticsResource);%0A%09%09%7D
 );%0A%09

add converting analytics details