// ============================================================================
// Copyright (C) 2006-2018 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// https://github.com/Talend/data-prep/blob/master/LICENSE
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================

package org.talend.dataprep.dataset;

import javax.annotation.PostConstruct;

import org.slf4j.Logger;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import static org.slf4j.LoggerFactory.getLogger;

@Component
@ConfigurationProperties(prefix = "dataset")
public class DatasetConfiguration {

    private static final Logger LOGGER = getLogger(DatasetConfiguration.class);

    private final Service service = new Service();

    @PostConstruct
    public void init() {
        LOGGER.info("Dataset configuration is retrieved from properties");
    }

    public static class Service {

        private Provider provider = Provider.LEGACY;

        private String url;

        public Provider getProvider() {
            return provider;
        }

        public void setProvider(Provider provider) {
            this.provider = provider;
        }

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }

        public enum Provider {LEGACY, CATALOG}
    }

    public Service getService() {
        return service;
    }

    public String getProvider() {
        return service.getProvider().name().toLowerCase();
    }
}

@@ -519,24 +519,74 @@
 p.dataset;%0A%0A
+import static org.slf4j.LoggerFactory.getLogger;%0A%0A
 import javax
@@ -768,58 +768,8 @@
 t;%0A%0A
-import static org.slf4j.LoggerFactory.getLogger;%0A%0A
 @Com
@@ -1613,25 +1613,24 @@
 ALOG%7D%0A    %7D%0A
-%0A
     public S
@@ -1780,11 +1780,115 @@
 );%0A    %7D
+%0A%0A    public boolean isLegacy() %7B%0A        return service.getProvider() == Service.Provider.LEGACY;%0A    %7D
 %0A%7D%0A

add isLegacy method for DatasetConfiguration (#1515)