/*
 * Copyright (C) 2021 favdb
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package storybook.model;

import storybook.tools.StringUtil;

/**
 *
 * @author favdb
 */
public class DB {

	public enum DATA {
		ID, NAME, ASPECT,
		DATE_CREATION, DATE_MAJ,
		DESCRIPTION, NOTES, ASSISTANT,
		NUMBER, DURATION, DATE,
		WORDS, CHARACTERS, CCSS, INFORMATIVE, ABBREVIATION,
		ATTRIBUTE, ATTRIBUTES, ATTRIBUTE_KEY, ATTRIBUTE_VALUE,
		CATEGORY, CATEGORY_SUP,
		CHAPTER, CHAPTER_CHAPTERNO,
		CHAPTER_NBSCENES, CHAPTER_NBWORDS, CHAPTER_NBCHARS,
		CHAPTERS,
		COLOR,
		ENDNOTE, ENDNOTE_NUMBER, ENDNOTE_SCENE, ENDNOTE_TYPE,
		GENDER, GENDER_CHILDHOOD, GENDER_ADOLESCENCE, GENDER_ADULTHOOD, GENDER_RETIREMENT,
		ICON_FILE,
		IDEA, IDEA_STATUS, IDEA_CATEGORY, UUID,
		INTERNAL, INTERNAL_KEY, INTERNAL_VALUE,
		ITEM, ITEMS, ITEM_CATEGORY,
		ITEMLINK, ITEMLINKS, ITEMLINK_ITEM,
		ITEMLINK_LOCATION, ITEMLINK_PERSON, ITEMLINK_SCENESTART, ITEMLINK_SCENEEND,
		LOCATION, LOCATIONS, LOCATION_ADDRESS, LOCATION_CITY, LOCATION_COUNTRY,
		LOCATION_ALTITUDE, LOCATION_GPS, LOCATION_SITE,
		MEMO,
		NBCHAPTERS, NBPARTS,
		OBJECTIVE, OBJECTIVE_DATE, OBJECTIVE_SIZE, OBJECTIVE_DONE, OBJECTIVE_REALIZED,
		PART, PART_NUMBER, PART_SUP,
		PERSON, PERSONS, PERSON_GENDER, PERSON_FIRSTNAME, PERSON_LASTNAME,
		PERSON_BIRTHDAY, PERSON_DEATH, PERSON_OCCUPATION, PERSON_COLOR,
		PERSON_CATEGORY, PERSON_CATEGORIES, PERSON_ATTRIBUTES,
		PLOT, PLOTS, PLOT_CATEGORY,
		RELATIONSHIP, RELATIONSHIPS, RELATIONSHIP_PERSON1, RELATIONSHIP_PERSON2,
		RELATIONSHIP_STARTSCENE, RELATIONSHIP_ENDSCENE,
		RELATIONSHIP_PERSONS, RELATIONSHIP_ITEMS, RELATIONSHIP_LOCATIONS,
		SCENARIO_PITCH, SCENARIO_MOMENT, SCENARIO_LOC, SCENARIO_START,
		SCENARIO_END, SCENARIO_STAGE,
		SCENE, SCENE_CHAPTER, SCENE_SEPARATOR, SCENE_STRAND, SCENE_SCENENO,
		SCENE_SCENETS, SCENE_SUMMARY,
		SCENE_STATUS, SCENE_DURATION, SCENE_RELATIVETIME, SCENE_RELATIVESCENEID,
		SCENE_ODF, SCENE_INFORMATIVE, SCENE_PERSONS, SCENE_ITEMS, SCENE_LOCATIONS,
		SCENE_PLOTS, SCENE_STRANDS, SCENE_NARRATOR,
		SCENE_CCSS, SCENE_WORDS, SCENE_CHARS, SCENE_START, SCENE_END, SCENE_XEDITOR,
		SCENES,
		INTENSITY,
		SCENE_SCENARIOPITCH, SCENE_SCENARIOMOMENT, SCENE_SCENARIOLOC, SCENE_SCENARIOSTART,
		SCENE_SCENARIOEND, SCENE_SCENARIOSTAGE,
		STATUS, STATUS_ICONFILE, STATUS_SUP,
		STRAND, STRANDS, STRAND_COLOR, SORT,
		TAG, TAGS, TAG_CATEGORY,
		TAGLINK, TAGLINKS, TAGLINK_TAG,
		TAGLINK_LOCATION, TAGLINK_PERSON, TAGLINK_SCENESTART, TAGLINK_SCENEEND,
		TITLE,
		EVENT, EVENT_TIME, EVENT_DURATION, EVENT_TIMESTEP, EVENT_CATEGORY, EVENT_COLOR,
		NIL;

		public String i18n() {
			return name().toLowerCase().replace("_", ".");
		}

		public String n() {
			String r = name().toLowerCase();
			return r.substring(i18n().indexOf('.') + 1);
		}

		public String c() {
			String r = n();
			return StringUtil.capitalize(r);
		}
	}

	public static DATA getData(String key) {
		for (DATA d : DATA.values()) {
			if (key.equals(d.i18n())) {
				return d;
			}
		}
		return DATA.NIL;
	}

}
