sv2000 commented on a change in pull request #2577: GOBBLIN-708: Create SqlDatasetDescriptor for JDBC-sourced datasets. URL: https://github.com/apache/incubator-gobblin/pull/2577#discussion_r275626238
########## File path: gobblin-service/src/main/java/org/apache/gobblin/service/modules/dataset/BaseDatasetDescriptor.java ########## @@ -0,0 +1,92 @@ +/* + * 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 + * + * 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.apache.gobblin.service.modules.dataset; + +import java.io.IOException; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import com.typesafe.config.Config; +import com.typesafe.config.ConfigFactory; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.ToString; + +import org.apache.gobblin.service.modules.flowgraph.DatasetDescriptorConfigKeys; +import org.apache.gobblin.util.ConfigUtils; + +@EqualsAndHashCode (exclude = {"description", "rawConfig"}) +@ToString (exclude = {"description", "rawConfig"}) +public abstract class BaseDatasetDescriptor implements DatasetDescriptor { + @Getter + private final String platform; + @Getter + private final FormatConfig formatConfig; + @Getter + private final boolean isRetentionApplied; + @Getter + private final String description; + @Getter + private final Config rawConfig; + + private static final Config DEFAULT_FALLBACK = + ConfigFactory.parseMap(ImmutableMap.<String, Object>builder() + .put(DatasetDescriptorConfigKeys.PATH_KEY, DatasetDescriptorConfigKeys.DATASET_DESCRIPTOR_CONFIG_ANY) + .put(DatasetDescriptorConfigKeys.IS_RETENTION_APPLIED_KEY, false) + .build()); + + public BaseDatasetDescriptor(Config config) throws IOException { + Preconditions.checkArgument(config.hasPath(DatasetDescriptorConfigKeys.PLATFORM_KEY), "Dataset descriptor config must specify platform"); + this.platform = config.getString(DatasetDescriptorConfigKeys.PLATFORM_KEY).toLowerCase(); + this.formatConfig = new FormatConfig(config); + this.isRetentionApplied = ConfigUtils.getBoolean(config, DatasetDescriptorConfigKeys.IS_RETENTION_APPLIED_KEY, false); + this.description = ConfigUtils.getString(config, DatasetDescriptorConfigKeys.DESCRIPTION_KEY, ""); + this.rawConfig = config.withFallback(this.formatConfig.getRawConfig()).withFallback(DEFAULT_FALLBACK); Review comment: That should not make a difference, since the formatConfig is derived from the input config. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services