<commit_before>/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * 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.apache.eagle.metadata.model;

import org.apache.eagle.metadata.persistence.PersistenceEntity;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 * Site app management entity
 */

@JsonIgnoreProperties(ignoreUnknown = true)
public class ApplicationEntity extends PersistenceEntity {
    private String appId;
    private SiteEntity site;

    /**
     * TODO: Think about keeping ApplicationDesc as a reference or deep clone into current instance
     */
    private ApplicationDesc descriptor;

    private Map<String,Object> configuration = new HashMap<>();
    private Map<String,String> context = new HashMap<>();
    private Collection<StreamDesc> streams;
    private Mode mode = Mode.CLUSTER;
    private Status status = Status.INITIAILIZED;

    public SiteEntity getSite() {
        return site;
    }

    public void setSite(SiteEntity site) {
        this.site = site;
    }

    public ApplicationDesc getDescriptor() {
        return descriptor;
    }

    public void setDescriptor(ApplicationDesc descriptor) {
        this.descriptor = descriptor;
    }

    public Map<String, Object> getConfiguration() {
        return configuration;
    }

    public void setConfiguration(Map<String, Object> configuration) {
        this.configuration = configuration;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    @Override
    public void ensureDefault() {
        super.ensureDefault();
        if(this.appId == null){
            this.appId = String.format("EAGLE_APP[TYPE=%s,SITE=%s]",this.getDescriptor().getType(),this.getSite().getSiteId());
        }
        if(this.status == null){
            this.status = Status.INITIAILIZED;
        }
    }

    public Map<String, String> getContext() {
        return context;
    }

    public void setContext(Map<String, String> context) {
        this.context = context;
    }

    public Mode getMode() {
        return mode;
    }

    public void setMode(Mode mode) {
        this.mode = mode;
    }

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public Collection<StreamDesc> getStreams() {
        return streams;
    }

    public void setStreams(Collection<StreamDesc> streams) {
        this.streams = streams;
    }

    public static enum Status{
        INITIAILIZED("INITIAILIZED"),
        STARTING("STARTING"),
        RUNNING("RUNNING"),
        STOPPPING("STOPPPING"),
        STOPPED("STOPPED");

        private final String status;
        Status(String status){
            this.status = status;
        }

        @Override
        public String toString() {
            return status;
        }
    }

    public static enum Mode{
        LOCAL("LOCAL"),
        CLUSTER("CLUSTER");<commit_msg>[EAGLE-403] Fix bad status text<commit_after>/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * 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.apache.eagle.metadata.model;

import org.apache.eagle.metadata.persistence.PersistenceEntity;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 * Site app management entity
 */

@JsonIgnoreProperties(ignoreUnknown = true)
public class ApplicationEntity extends PersistenceEntity {
    private String appId;
    private SiteEntity site;

    /**
     * TODO: Think about keeping ApplicationDesc as a reference or deep clone into current instance
     */
    private ApplicationDesc descriptor;

    private Map<String,Object> configuration = new HashMap<>();
    private Map<String,String> context = new HashMap<>();
    private Collection<StreamDesc> streams;
    private Mode mode = Mode.CLUSTER;
    private Status status = Status.INITIALIZED;

    public SiteEntity getSite() {
        return site;
    }

    public void setSite(SiteEntity site) {
        this.site = site;
    }

    public ApplicationDesc getDescriptor() {
        return descriptor;
    }

    public void setDescriptor(ApplicationDesc descriptor) {
        this.descriptor = descriptor;
    }

    public Map<String, Object> getConfiguration() {
        return configuration;
    }

    public void setConfiguration(Map<String, Object> configuration) {
        this.configuration = configuration;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    @Override
    public void ensureDefault() {
        super.ensureDefault();
        if(this.appId == null){
            this.appId = String.format("EAGLE_APP[TYPE=%s,SITE=%s]",this.getDescriptor().getType(),this.getSite().getSiteId());
        }
        if(this.status == null){
            this.status = Status.INITIALIZED;
        }
    }

    public Map<String, String> getContext() {
        return context;
    }

    public void setContext(Map<String, String> context) {
        this.context = context;
    }

    public Mode getMode() {
        return mode;
    }

    public void setMode(Mode mode) {
        this.mode = mode;
    }

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public Collection<StreamDesc> getStreams() {
        return streams;
    }

    public void setStreams(Collection<StreamDesc> streams) {
        this.streams = streams;
    }

    public static enum Status{
        INITIALIZED("INITIALIZED"),
        STARTING("STARTING"),
        RUNNING("RUNNING"),
        STOPPING("STOPPING"),
        STOPPED("STOPPED");

        private final String status;
        Status(String status){
            this.status = status;
        }

        @Override
        public String toString() {
            return status;
        }
    }

    public static enum Mode{
        LOCAL("LOCAL"),
        CLUSTER("CLUSTER");
{'fraction_non_alphanumeric': 0.09201890259910737, 'fraction_numerical': 0.001443948542924652, 'mean_word_length': 2.7165853658536587, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '4561386', 'n_tokens_mistral': 2041, 'n_tokens_neox': 1981, 'n_words': 635}