001/*
002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl-2.1.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo
016 */
017package org.nuxeo.elasticsearch.web.admin;
018
019/**
020 * @author <a href="mailto:tdelprat@nuxeo.com">Tiry</a>
021 */
022
023public class PageProviderStatus implements Comparable<PageProviderStatus> {
024
025    protected static final String CORE_QUERY_TYPE = "CoreQueryDocumentPageProvider";
026
027    protected static final String ELASTIC_TYPE = "elasticsearch";
028
029    String cvName;
030
031    String ppName;
032
033    String type;
034
035    public PageProviderStatus(String ppName, String klass) {
036        this.ppName = ppName;
037        switch (klass) {
038        case "org.nuxeo.ecm.platform.query.nxql.CoreQueryDocumentPageProvider":
039            this.type = CORE_QUERY_TYPE;
040            break;
041        case "org.nuxeo.elasticsearch.provider.ElasticSearchNxqlPageProvider":
042            this.type = ELASTIC_TYPE;
043            break;
044        default:
045            this.type = klass;
046        }
047    }
048
049    public String getPpName() {
050        return ppName;
051    }
052
053    public String getType() {
054        return type;
055    }
056
057    public String getColor() {
058        if (CORE_QUERY_TYPE.equals(type)) {
059            return "#0c8abb";
060        } else if (ELASTIC_TYPE.equals(type)) {
061            return "#0aca00";
062        } else {
063            return "#444444";
064        }
065    }
066
067    @Override
068    public int compareTo(PageProviderStatus other) {
069        return getPpName().toLowerCase().compareTo(other.getPpName().toLowerCase());
070    }
071
072}