/*
 * Copyright (C) 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.entity.widget;

import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Optional;

/**
 * @author Pavel Bortnik
 */
public enum WidgetType {

	OLD_LINE_CHART("oldLineChart"),
	INVESTIGATED_TREND("investigatedTrend"),
	LAUNCH_STATISTICS("launchStatistics"),
	STATISTIC_TREND("statisticTrend"),
	CASES_TREND("casesTrend"),
	NOT_PASSED("notPassed"),
	OVERALL_STATISTICS("overallStatistics"),
	UNIQUE_BUG_TABLE("uniqueBugTable"),
	BUG_TREND("bugTrend"),
	ACTIVITY("activityStream"),
	LAUNCHES_COMPARISON_CHART("launchesComparisonChart"),
	LAUNCHES_DURATION_CHART("launchesDurationChart"),
	LAUNCHES_TABLE("launchesTable"),
	TOP_TEST_CASES("topTestCases"),
	FLAKY_TEST_CASES("flakyTestCases"),
	PASSING_RATE_SUMMARY("passingRateSummary"),
	PASSING_RATE_PER_LAUNCH("passingRatePerLaunch"),
	PRODUCT_STATUS("productStatus"),
	MOST_TIME_CONSUMING("mostTimeConsuming"),
	CUMULATIVE("cumulative");

	private final String type;

	WidgetType(String type) {
		this.type = type;
	}

	public String getType() {
		return this.type;
	}

	public static WidgetType getByName(String type) {
		return WidgetType.valueOf(type);
	}

	public static Optional<WidgetType> findByName(@Nullable String name) {
		return Arrays.stream(WidgetType.values()).filter(gadgetTypes -> gadgetTypes.getType().equalsIgnoreCase(name)).findAny();
	}

}

@@ -811,24 +811,31 @@
 ldLineChart%22
+, false
 ),%0A%09INVESTIG
@@ -860,24 +860,31 @@
 igatedTrend%22
+, false
 ),%0A%09LAUNCH_S
@@ -907,24 +907,31 @@
 hStatistics%22
+, false
 ),%0A%09STATISTI
@@ -950,24 +950,31 @@
 tisticTrend%22
+, false
 ),%0A%09CASES_TR
@@ -985,24 +985,31 @@
 %22casesTrend%22
+, false
 ),%0A%09NOT_PASS
@@ -1022,16 +1022,23 @@
 tPassed%22
+, false
 ),%0A%09OVER
@@ -1071,16 +1071,23 @@
 tistics%22
+, false
 ),%0A%09UNIQ
@@ -1111,24 +1111,31 @@
 queBugTable%22
+, false
 ),%0A%09BUG_TREN
@@ -1146,16 +1146,23 @@
 ugTrend%22
+, false
 ),%0A%09ACTI
@@ -1182,16 +1182,23 @@
 yStream%22
+, false
 ),%0A%09LAUN
@@ -1236,32 +1236,39 @@
 ComparisonChart%22
+, false
 ),%0A%09LAUNCHES_DUR
@@ -1302,16 +1302,23 @@
 onChart%22
+, false
 ),%0A%09LAUN
@@ -1343,16 +1343,23 @@
 esTable%22
+, false
 ),%0A%09TOP_
@@ -1379,24 +1379,31 @@
 opTestCases%22
+, false
 ),%0A%09FLAKY_TE
@@ -1427,16 +1427,23 @@
 stCases%22
+, false
 ),%0A%09PASS
@@ -1479,16 +1479,23 @@
 Summary%22
+, false
 ),%0A%09PASS
@@ -1536,16 +1536,23 @@
 rLaunch%22
+, false
 ),%0A%09PROD
@@ -1577,16 +1577,23 @@
 tStatus%22
+, false
 ),%0A%09MOST
@@ -1627,19 +1627,27 @@
 nsuming%22
+, false
 ),%0A
+%0A
 %09CUMULAT
@@ -1662,16 +1662,22 @@
 ulative%22
+, true
 );%0A%0A%09pri
@@ -1706,102 +1706,344 @@
 ;%0A%0A%09
-WidgetType(String type) %7B%0A%09%09this.type = type;%0A%09%7D%0A%0A%09public String getType() %7B%0A%09%09return this.typ
+private final boolean supportMultilevelStructure;%0A%0A%09WidgetType(String type, boolean supportMultilevelStructure) %7B%0A%09%09this.type = type;%0A%09%09this.supportMultilevelStructure = supportMultilevelStructure;%0A%09%7D%0A%0A%09public String getType() %7B%0A%09%09return this.type;%0A%09%7D%0A%0A%09public boolean isSupportMultilevelStructure() %7B%0A%09%09return supportMultilevelStructur
 e;%0A%09

update widget type enum