001/*
002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Nuxeo
018 */
019package org.nuxeo.elasticsearch.web.admin;
020
021/**
022 * @author <a href="mailto:tdelprat@nuxeo.com">Tiry</a>
023 */
024
025public class PageProviderStatus implements Comparable<PageProviderStatus> {
026
027    protected static final String CORE_QUERY_TYPE = "CoreQueryDocumentPageProvider";
028
029    protected static final String ELASTIC_TYPE = "elasticsearch";
030
031    String cvName;
032
033    String ppName;
034
035    String type;
036
037    public PageProviderStatus(String ppName, String klass) {
038        this.ppName = ppName;
039        switch (klass) {
040        case "org.nuxeo.ecm.platform.query.nxql.CoreQueryDocumentPageProvider":
041            this.type = CORE_QUERY_TYPE;
042            break;
043        case "org.nuxeo.elasticsearch.provider.ElasticSearchNxqlPageProvider":
044            this.type = ELASTIC_TYPE;
045            break;
046        default:
047            this.type = klass;
048        }
049    }
050
051    public String getPpName() {
052        return ppName;
053    }
054
055    public String getType() {
056        return type;
057    }
058
059    public String getColor() {
060        if (CORE_QUERY_TYPE.equals(type)) {
061            return "#0c8abb";
062        } else if (ELASTIC_TYPE.equals(type)) {
063            return "#0aca00";
064        } else {
065            return "#444444";
066        }
067    }
068
069    @Override
070    public int compareTo(PageProviderStatus other) {
071        return getPpName().toLowerCase().compareTo(other.getPpName().toLowerCase());
072    }
073
074}