<commit_before>/*
 * Copyright 2012 Shared Learning Collaborative, LLC
 *
 * 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 org.slc.sli.dashboard.entity;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import javax.validation.Valid;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

import org.slc.sli.dashboard.util.DashboardException;
import org.slc.sli.dashboard.web.util.NoBadChars;

/**
 * Config unit for all dashboard components including panels and layouts
 * Immutable
 *
 * @author agrebneva
 *
 */
public class Config implements Cloneable, Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * Type of components
     *
     * @author agrebneva
     *
     */
    public enum Type {
        LAYOUT(true), PANEL(true), GRID(true), TAB(false), WIDGET(true), FIELD(false), EXPAND(false), REPEAT_HEADER_GRID(false);

        private boolean hasOwnConfig;

        private Type(boolean hasOwnConfig) {
            this.hasOwnConfig = hasOwnConfig;
        }

        public boolean hasOwnConfig() {
            return hasOwnConfig;
        }

        public boolean isLayoutItem() {
            return this == LAYOUT;
        }
    }

    /**
     * Subcomponent of the config
     *
     * @author agrebneva
     *
     */
    public static class Item extends Config {
        private static final long serialVersionUID = 1L;
        @Pattern(regexp = "[a-zA-Z0-9 \\-/\\+()\"':]{0,150}")
        protected String description;
        // Field is a json hierarchy with nodes delimited by period and can use optional single quote
        @Pattern(regexp = "[a-zA-Z0-9 \\.\\-_\\\\]{0,100}")
        protected String field;
        @Pattern(regexp = "[a-zA-Z0-9 -/\\+()\"':]{0,150}")<commit_msg>US1032: Updated config for attendance history in JSON<commit_after>/*
 * Copyright 2012 Shared Learning Collaborative, LLC
 *
 * 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 org.slc.sli.dashboard.entity;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import javax.validation.Valid;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

import org.slc.sli.dashboard.util.DashboardException;
import org.slc.sli.dashboard.web.util.NoBadChars;

/**
 * Config unit for all dashboard components including panels and layouts
 * Immutable
 *
 * @author agrebneva
 *
 */
public class Config implements Cloneable, Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * Type of components
     * set true: it will look up outside config file.
     * set false: it does not have outside config.
     * @author agrebneva
     *
     */
    public enum Type {
        LAYOUT(true), PANEL(true), GRID(true), TAB(false), WIDGET(true), FIELD(false), EXPAND(false), REPEAT_HEADER_GRID(true);

        private boolean hasOwnConfig;

        private Type(boolean hasOwnConfig) {
            this.hasOwnConfig = hasOwnConfig;
        }

        public boolean hasOwnConfig() {
            return hasOwnConfig;
        }

        public boolean isLayoutItem() {
            return this == LAYOUT;
        }
    }

    /**
     * Subcomponent of the config
     *
     * @author agrebneva
     *
     */
    public static class Item extends Config {
        private static final long serialVersionUID = 1L;
        @Pattern(regexp = "[a-zA-Z0-9 \\-/\\+()\"':]{0,150}")
        protected String description;
        // Field is a json hierarchy with nodes delimited by period and can use optional single quote
        @Pattern(regexp = "[a-zA-Z0-9 \\.\\-_\\\\]{0,100}")
        protected String field;
        @Pattern(regexp = "[a-zA-Z0-9 -/\\+()\"':]{0,150}")
{'fraction_non_alphanumeric': 0.10511188667624717, 'fraction_numerical': 0.012317799219872716, 'mean_word_length': 2.857482185273159, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7151375', 'n_tokens_mistral': 1433, 'n_tokens_neox': 1384, 'n_words': 455}