You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/06/02 04:38:14 UTC

[GitHub] [incubator-inlong] healchow commented on a diff in pull request #4294: [INLONG-4273][Manager] Support MongoDB source

healchow commented on code in PR #4294:
URL: https://github.com/apache/incubator-inlong/pull/4294#discussion_r887550979


##########
inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/source/mongo/MongoSource.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.inlong.manager.common.pojo.source.mongo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import lombok.experimental.SuperBuilder;
+import org.apache.inlong.manager.common.enums.SourceType;
+import org.apache.inlong.manager.common.pojo.source.SourceRequest;
+import org.apache.inlong.manager.common.pojo.source.StreamSource;
+import org.apache.inlong.manager.common.util.CommonBeanUtils;
+import org.apache.inlong.manager.common.util.JsonTypeDefine;
+
+/**
+ *  Mongo source info
+ */
+@Data
+@SuperBuilder
+@AllArgsConstructor
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "Mongo source info")
+@JsonTypeDefine(value = SourceType.SOURCE_MONGO)
+public class MongoSource extends StreamSource {

Review Comment:
   It is recommended to call the `MongoDB`, which is the official name.



##########
inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/source/mongo/MongoSourceDTO.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * 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.inlong.manager.common.pojo.source.mongo;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.apache.inlong.manager.common.enums.ErrorCodeEnum;
+import org.apache.inlong.manager.common.exceptions.BusinessException;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * mongo source information data transfer object.
+ */
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class MongoSourceDTO {
+
+    private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+    @ApiModelProperty("Mongo primaryKey")
+    private String primaryKey;
+
+    @ApiModelProperty("Mongo hosts")
+    private String hosts;
+
+    @ApiModelProperty("Mongo username")
+    private String username;
+
+    @ApiModelProperty("Mongo password")
+    private String password;
+
+    @ApiModelProperty("Mongo database")
+    private String database;
+
+    @ApiModelProperty("Mongo collection")
+    private String collection;
+
+    /**
+     * Get the dto instance from the request
+     */
+    public static MongoSourceDTO getFromRequest(MongoSourceRequest request) {
+        return MongoSourceDTO.builder()
+                .primaryKey(request.getPrimaryKey())
+                .hosts(request.getHosts())
+                .username(request.getUsername())
+                .password(request.getPassword())
+                .database(request.getDatabase())
+                .collection(request.getCollection())
+                .build();
+    }
+
+    public static MongoSourceDTO getFromJson(@NotNull String extParams) {

Review Comment:
   Add java doc please.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org