PG1204 commented on code in PR #4217: URL: https://github.com/apache/texera/pull/4217#discussion_r2851209932
########## common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/radarChart/RadarChartOpDesc.scala: ########## @@ -0,0 +1,196 @@ +/* + * 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.texera.amber.operator.visualization.radarChart // namespace for operator + +// Jackson annotations - for JSON serialization (form fields → JSON → backend) +import com.fasterxml.jackson.annotation.{JsonProperty, JsonPropertyDescription} +import com.kjetland.jackson.jsonSchema.annotations.{JsonSchemaInject, JsonSchemaTitle} + +// Core Texera types +import org.apache.texera.amber.core.tuple.{AttributeType, Schema} // for defining output schema +import org.apache.texera.amber.core.workflow.OutputPort.OutputMode // for SINGLE_SNAPSHOT mode +import org.apache.texera.amber.core.workflow.{InputPort, OutputPort, PortIdentity} // ports + +// Base class and metadata +import org.apache.texera.amber.operator.PythonOperatorDescriptor // base class extend +import org.apache.texera.amber.operator.metadata.annotations.{ + AutofillAttributeName, + AutofillAttributeNameList +} // auto-fills column names in UI +import org.apache.texera.amber.operator.metadata.{ + OperatorGroupConstants, + OperatorInfo +} // for operator metadata + +import javax.validation.constraints.NotNull + +// type constraint: value can only be numeric +@JsonSchemaInject(json = """ +{ + "attributeTypeRules": { + "valueColumns": { + "enum": ["integer", "long", "double"] + } + } +} +""") +class RadarChartOpDesc extends PythonOperatorDescriptor { + private def validateConfig(): Unit = { + require(nameColumn != null && nameColumn.nonEmpty, "nameColumn must be specified and non-empty") + require( + valueColumns != null && valueColumns.nonEmpty, + "valueColumns must be specified and non-empty" + ) + require(!valueColumns.contains(nameColumn), "nameColumn must not be included in valueColumns") + require( + valueColumns.distinct.size == valueColumns.size, + "valueColumns must not contain duplicates" + ) + } + + @JsonProperty(value = "nameColumn", required = true) + @JsonSchemaTitle("Name Column") + @JsonPropertyDescription("Column containing entity names for each radar") + @AutofillAttributeName + @NotNull(message = "Name column cannot be empty") + var nameColumn: String = "entity_name" Review Comment: Is EncodableString defined anywhere in the project so I can import it? -- 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]
