mchades commented on code in PR #8724:
URL: https://github.com/apache/gravitino/pull/8724#discussion_r2420329245


##########
common/src/main/java/org/apache/gravitino/dto/requests/JobTemplateUpdateRequest.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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.gravitino.dto.requests;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonSubTypes;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.google.common.base.Preconditions;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.dto.job.TemplateUpdateDTO;
+import org.apache.gravitino.job.JobTemplateChange;
+import org.apache.gravitino.rest.RESTRequest;
+
+/**
+ * Represents a request to update a job template. This can include renaming 
the template, updating
+ * its comment, or changing its content.
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY)
+@JsonSubTypes({
+  @JsonSubTypes.Type(
+      value = JobTemplateUpdateRequest.RenameJobTemplateRequest.class,
+      name = "rename"),
+  @JsonSubTypes.Type(
+      value = JobTemplateUpdateRequest.UpdateJobTemplateCommentRequest.class,
+      name = "updateComment"),
+  @JsonSubTypes.Type(
+      value = JobTemplateUpdateRequest.UpdateJobTemplateContentRequest.class,
+      name = "updateTemplate")
+})
+public interface JobTemplateUpdateRequest extends RESTRequest {
+
+  /**
+   * Get the job template change that is requested.
+   *
+   * @return the job template change
+   */
+  JobTemplateChange jobTemplateChange();
+
+  /** The request to rename a job template. */
+  @EqualsAndHashCode
+  @ToString
+  class RenameJobTemplateRequest implements JobTemplateUpdateRequest {
+
+    @Getter
+    @JsonProperty("newName")
+    private final String newName;
+
+    /**
+     * Constructor for RenameJobTemplateRequest.
+     *
+     * @param newName the new name for the job template
+     */
+    public RenameJobTemplateRequest(String newName) {
+      this.newName = newName;
+    }
+
+    /** Default constructor for Jackson. */
+    public RenameJobTemplateRequest() {

Review Comment:
   Should this be private?



##########
common/src/main/java/org/apache/gravitino/dto/requests/JobTemplateUpdateRequest.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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.gravitino.dto.requests;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonSubTypes;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.google.common.base.Preconditions;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.gravitino.dto.job.TemplateUpdateDTO;
+import org.apache.gravitino.job.JobTemplateChange;
+import org.apache.gravitino.rest.RESTRequest;
+
+/**
+ * Represents a request to update a job template. This can include renaming 
the template, updating
+ * its comment, or changing its content.
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY)
+@JsonSubTypes({
+  @JsonSubTypes.Type(
+      value = JobTemplateUpdateRequest.RenameJobTemplateRequest.class,
+      name = "rename"),
+  @JsonSubTypes.Type(
+      value = JobTemplateUpdateRequest.UpdateJobTemplateCommentRequest.class,
+      name = "updateComment"),
+  @JsonSubTypes.Type(
+      value = JobTemplateUpdateRequest.UpdateJobTemplateContentRequest.class,
+      name = "updateTemplate")
+})
+public interface JobTemplateUpdateRequest extends RESTRequest {
+
+  /**
+   * Get the job template change that is requested.
+   *
+   * @return the job template change
+   */
+  JobTemplateChange jobTemplateChange();
+
+  /** The request to rename a job template. */
+  @EqualsAndHashCode
+  @ToString
+  class RenameJobTemplateRequest implements JobTemplateUpdateRequest {
+
+    @Getter
+    @JsonProperty("newName")
+    private final String newName;
+
+    /**
+     * Constructor for RenameJobTemplateRequest.
+     *
+     * @param newName the new name for the job template
+     */
+    public RenameJobTemplateRequest(String newName) {
+      this.newName = newName;
+    }
+
+    /** Default constructor for Jackson. */
+    public RenameJobTemplateRequest() {
+      this(null);
+    }
+
+    @Override
+    public void validate() throws IllegalArgumentException {
+      Preconditions.checkArgument(
+          StringUtils.isNotBlank(newName), "\"newName\" is required and cannot 
be empty");
+    }
+
+    @Override
+    public JobTemplateChange jobTemplateChange() {
+      return JobTemplateChange.rename(newName);
+    }
+  }
+
+  /** The request to update the comment of a job template. */
+  @EqualsAndHashCode
+  @ToString
+  class UpdateJobTemplateCommentRequest implements JobTemplateUpdateRequest {
+
+    @Getter
+    @JsonProperty("newComment")
+    private final String newComment;
+
+    /**
+     * Constructor for UpdateJobTemplateCommentRequest.
+     *
+     * @param newComment the new comment for the job template
+     */
+    public UpdateJobTemplateCommentRequest(String newComment) {
+      this.newComment = newComment;
+    }
+
+    /** Default constructor for Jackson. */
+    public UpdateJobTemplateCommentRequest() {

Review Comment:
   Should this be private?



##########
common/src/main/java/org/apache/gravitino/dto/job/TemplateUpdateDTO.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.gravitino.dto.job;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonSubTypes;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Nullable;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.SuperBuilder;
+import org.apache.gravitino.job.JobTemplateChange;
+
+/** DTO for updating a Job Template. */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY)
+@JsonSubTypes({
+  @JsonSubTypes.Type(value = ShellTemplateUpdateDTO.class, name = "shell"),
+  @JsonSubTypes.Type(value = SparkTemplateUpdateDTO.class, name = "spark")
+})
+@Getter
+@EqualsAndHashCode
+@SuperBuilder(setterPrefix = "with")
+@ToString
+public abstract class TemplateUpdateDTO {
+
+  @Nullable
+  @JsonProperty("newExecutable")
+  private String newExecutable;
+
+  @Nullable
+  @JsonProperty("newArguments")
+  private List<String> newArguments;
+
+  @Nullable
+  @JsonProperty("newEnvironments")
+  private Map<String, String> newEnvironments;
+
+  @Nullable
+  @JsonProperty("newCustomFields")
+  private Map<String, String> newCustomFields;
+
+  /**
+   * The default constructor for Jackson. This constructor is required for 
deserialization of the
+   * DTO.
+   */
+  protected TemplateUpdateDTO() {

Review Comment:
   why not be private?



##########
common/src/main/java/org/apache/gravitino/dto/job/SparkTemplateUpdateDTO.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.gravitino.dto.job;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Nullable;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.SuperBuilder;
+import org.apache.gravitino.job.JobTemplateChange;
+
+/** DTO for updating a Spark Job Template. */
+@Getter
+@EqualsAndHashCode(callSuper = true)
+@SuperBuilder(setterPrefix = "with")
+@ToString(callSuper = true)
+public class SparkTemplateUpdateDTO extends TemplateUpdateDTO {
+
+  @Nullable
+  @JsonProperty("newClassName")
+  private String newClassName;
+
+  @Nullable
+  @JsonProperty("newJars")
+  private List<String> newJars;
+
+  @Nullable
+  @JsonProperty("newFiles")
+  private List<String> newFiles;
+
+  @Nullable
+  @JsonProperty("newArchives")
+  private List<String> newArchives;
+
+  @Nullable

Review Comment:
   What if all fields are null?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to