/*
 *  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.enums;

import com.epam.ta.reportportal.entity.AnalyzeMode;
import com.epam.ta.reportportal.entity.project.ProjectAnalyzerConfig;

import java.util.Arrays;
import java.util.Optional;

import static com.epam.ta.reportportal.entity.project.ProjectUtils.INIT_FROM;

/**
 * Enum with a list of basic required project parameters
 *
 * @author Andrey Plisunov
 */
public enum ProjectAttributeEnum {

	INTERRUPT_JOB_TIME("job.interruptJobTime", InterruptionJobDelay.ONE_DAY.getValue()),
	KEEP_LOGS("job.keepLogs", KeepLogsDelay.THREE_MONTHS.getValue()),
	KEEP_SCREENSHOTS("job.keepScreenshots", KeepScreenshotsDelay.TWO_WEEKS.getValue()),

	MIN_DOC_FREQ("analyzer.minDocFreq", String.valueOf(ProjectAnalyzerConfig.MIN_DOC_FREQ)),
	MIN_TERM_FREQ("analyzer.minTermFreq", String.valueOf(ProjectAnalyzerConfig.MIN_TERM_FREQ)),
	MIN_SHOULD_MATCH("analyzer.minShouldMatch", String.valueOf(ProjectAnalyzerConfig.MIN_SHOULD_MATCH)),
	NUMBER_OF_LOG_LINES("analyzer.numberOfLogLines", String.valueOf(ProjectAnalyzerConfig.NUMBER_OF_LOG_LINES)),
	INDEXING_RUNNING("analyzer.indexingRunning", String.valueOf(false)),
	AUTO_ANALYZER_ENABLED("analyzer.isAutoAnalyzerEnabled", String.valueOf(false)),
	AUTO_ANALYZER_MODE("analyzer.autoAnalyzerMode", AnalyzeMode.BY_LAUNCH_NAME.getValue()),

	EMAIL_ENABLED("email.enabled", String.valueOf(false)),
	EMAIL_FROM("email.from", INIT_FROM);

	private String attribute;
	private String defaultValue;

	ProjectAttributeEnum(String attribute, String defaultValue) {
		this.attribute = attribute;
		this.defaultValue = String.valueOf(defaultValue);
	}

	public String getAttribute() {
		return attribute;
	}

	public String getDefaultValue() {
		return defaultValue;
	}

	public static Optional<ProjectAttributeEnum> findByAttributeName(String attributeName) {
		return Arrays.stream(ProjectAttributeEnum.values()).filter(v -> v.getAttribute().equalsIgnoreCase(attributeName)).findAny();
	}

	public static boolean isPresent(String name) {
		return findByAttributeName(name).isPresent();
	}
}



@@ -1,14 +1,13 @@
 /*%0A *
- 
  Copyrig
@@ -36,17 +36,16 @@
 ms%0A *%0A *
- 
  License
@@ -103,17 +103,16 @@
 se%22);%0A *
- 
  you may
@@ -171,17 +171,16 @@
 ense.%0A *
- 
  You may
@@ -217,17 +217,16 @@
 at%0A *%0A *
- 
  http://
@@ -266,17 +266,16 @@
 .0%0A *%0A *
- 
  Unless 
@@ -337,17 +337,16 @@
 tware%0A *
- 
  distrib
@@ -406,17 +406,16 @@
 ASIS,%0A *
- 
  WITHOUT
@@ -482,17 +482,16 @@
 lied.%0A *
- 
  See the
@@ -553,17 +553,16 @@
 s and%0A *
- 
  limitat
@@ -818,87 +818,8 @@
 l;%0A%0A
-import static com.epam.ta.reportportal.entity.project.ProjectUtils.INIT_FROM;%0A%0A
 /**%0A
@@ -1821,103 +1821,8 @@
 e())
-,%0A%0A%09EMAIL_ENABLED(%22email.enabled%22, String.valueOf(false)),%0A%09EMAIL_FROM(%22email.from%22, INIT_FROM)
 ;%0A%0A%09
@@ -2465,12 +2465,13 @@
 t();%0A%09%7D%0A
+%09
 %7D%0A%0A%0A

remove email from project attributes