From 9f7f9801f6623eb3292006c921e5f0b31f208227 Mon Sep 17 00:00:00 2001 From: gnanaprakash-ravi Date: Mon, 4 Mar 2024 14:25:17 +0530 Subject: [PATCH 1/2] cols and FieldDefinition.java code changes --- .../zingg/common/client/FieldDefinition.java | 18 ++++++++- .../client/cols/FieldDefSelectedCols.java | 33 +++++++++++++++++ .../common/client/cols/ISelectedCols.java | 16 ++++++++ .../java/zingg/common/client/cols/Named.java | 8 ++++ .../common/client/cols/SelectedCols.java | 37 +++++++++++++++++++ .../client/cols/ZidAndFieldDefSelector.java | 14 +++++++ 6 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 common/client/src/main/java/zingg/common/client/cols/FieldDefSelectedCols.java create mode 100644 common/client/src/main/java/zingg/common/client/cols/ISelectedCols.java create mode 100644 common/client/src/main/java/zingg/common/client/cols/Named.java create mode 100644 common/client/src/main/java/zingg/common/client/cols/SelectedCols.java create mode 100644 common/client/src/main/java/zingg/common/client/cols/ZidAndFieldDefSelector.java diff --git a/common/client/src/main/java/zingg/common/client/FieldDefinition.java b/common/client/src/main/java/zingg/common/client/FieldDefinition.java index 55c0c52f6..0adbd9e1a 100644 --- a/common/client/src/main/java/zingg/common/client/FieldDefinition.java +++ b/common/client/src/main/java/zingg/common/client/FieldDefinition.java @@ -22,6 +22,7 @@ import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import zingg.common.client.cols.Named; import zingg.common.py.annotations.PythonClass; import zingg.common.py.annotations.PythonMethod; @@ -34,7 +35,7 @@ * */ @PythonClass(module = "client", outputDirectory = "python/zinggGenerated") -public class FieldDefinition implements +public class FieldDefinition implements Named, Serializable { private static final long serialVersionUID = 1L; @@ -125,6 +126,21 @@ public void setFieldName(String fieldName) { this.fieldName = fieldName; } + public boolean isDontUse() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'isDontUse'"); + } + + @Override + public String getName() { + return getFieldName(); + } + + @Override + public void setName(String name) { + setFieldName(name); + } + @Override public int hashCode() { final int prime = 31; diff --git a/common/client/src/main/java/zingg/common/client/cols/FieldDefSelectedCols.java b/common/client/src/main/java/zingg/common/client/cols/FieldDefSelectedCols.java new file mode 100644 index 000000000..d359b6c0f --- /dev/null +++ b/common/client/src/main/java/zingg/common/client/cols/FieldDefSelectedCols.java @@ -0,0 +1,33 @@ +package zingg.common.client.cols; + +import java.util.ArrayList; +import java.util.List; + +import zingg.common.client.FieldDefinition; + +public class FieldDefSelectedCols extends SelectedCols { + + public FieldDefSelectedCols(List fieldDefs, boolean showConcise) { + + List namedList = new ArrayList<>(); + + for (FieldDefinition fieldDef : fieldDefs) { + if (showConcise && fieldDef.isDontUse()) { + continue; + } + namedList.add(fieldDef); + } + + namedList.add(new FieldDefinition()); + List stringList = convertNamedListToStringList(namedList); + setCols(stringList); + } + + private List convertNamedListToStringList(List namedList) { + List stringList = new ArrayList<>(); + for (FieldDefinition named : namedList) { + stringList.add(named.getName()); + } + return stringList; + } +} \ No newline at end of file diff --git a/common/client/src/main/java/zingg/common/client/cols/ISelectedCols.java b/common/client/src/main/java/zingg/common/client/cols/ISelectedCols.java new file mode 100644 index 000000000..1d48fc945 --- /dev/null +++ b/common/client/src/main/java/zingg/common/client/cols/ISelectedCols.java @@ -0,0 +1,16 @@ +package zingg.common.client.cols; + +import java.util.List; + +public interface ISelectedCols { + + String[] getCols(List n); + + String[] getCols(); + + void setCols(List cols); + + void setNamedCols(List n); + + void setStringCols(List cols); +} \ No newline at end of file diff --git a/common/client/src/main/java/zingg/common/client/cols/Named.java b/common/client/src/main/java/zingg/common/client/cols/Named.java new file mode 100644 index 000000000..1fbe2a0a6 --- /dev/null +++ b/common/client/src/main/java/zingg/common/client/cols/Named.java @@ -0,0 +1,8 @@ +package zingg.common.client.cols; + +public interface Named { + + String getName(); + + void setName(String name); +} \ No newline at end of file diff --git a/common/client/src/main/java/zingg/common/client/cols/SelectedCols.java b/common/client/src/main/java/zingg/common/client/cols/SelectedCols.java new file mode 100644 index 000000000..106afa534 --- /dev/null +++ b/common/client/src/main/java/zingg/common/client/cols/SelectedCols.java @@ -0,0 +1,37 @@ +package zingg.common.client.cols; + +import java.util.List; + +public class SelectedCols implements ISelectedCols { + + private String[] cols; + + @Override + public String[] getCols(List n) { + String[] result = new String[n.size()]; + for (int i = 0; i < n.size(); i++) { + result[i] = n.get(i).getName(); + } + return result; + } + + @Override + public String[] getCols() { + return cols; + } + + @Override + public void setCols(List strings) { + this.cols = strings.toArray(new String[0]); + } + + @Override + public void setNamedCols(List n) { + this.cols = getCols(n); + } + + @Override + public void setStringCols(List columnNames) { + this.cols = columnNames.toArray(new String[0]); + } +} \ No newline at end of file diff --git a/common/client/src/main/java/zingg/common/client/cols/ZidAndFieldDefSelector.java b/common/client/src/main/java/zingg/common/client/cols/ZidAndFieldDefSelector.java new file mode 100644 index 000000000..3031c5bac --- /dev/null +++ b/common/client/src/main/java/zingg/common/client/cols/ZidAndFieldDefSelector.java @@ -0,0 +1,14 @@ +package zingg.common.client.cols; + +import java.util.Arrays; +import java.util.List; + +public class ZidAndFieldDefSelector extends SelectedCols { + + public ZidAndFieldDefSelector(String[] fieldDefs) { + + List fieldDefList = Arrays.asList(fieldDefs); + fieldDefList.add(0, "zid"); + setCols(fieldDefList); + } +} \ No newline at end of file From 6e812ae36bd04f283612a42ebab039fb84713b27 Mon Sep 17 00:00:00 2001 From: gnanaprakash-ravi Date: Mon, 4 Mar 2024 14:29:59 +0530 Subject: [PATCH 2/2] colName.ID_COL constant --- .../java/zingg/common/client/cols/ZidAndFieldDefSelector.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/client/src/main/java/zingg/common/client/cols/ZidAndFieldDefSelector.java b/common/client/src/main/java/zingg/common/client/cols/ZidAndFieldDefSelector.java index 3031c5bac..8511ea43e 100644 --- a/common/client/src/main/java/zingg/common/client/cols/ZidAndFieldDefSelector.java +++ b/common/client/src/main/java/zingg/common/client/cols/ZidAndFieldDefSelector.java @@ -3,12 +3,14 @@ import java.util.Arrays; import java.util.List; +import zingg.common.client.util.ColName; + public class ZidAndFieldDefSelector extends SelectedCols { public ZidAndFieldDefSelector(String[] fieldDefs) { List fieldDefList = Arrays.asList(fieldDefs); - fieldDefList.add(0, "zid"); + fieldDefList.add(0, ColName.ID_COL); setCols(fieldDefList); } } \ No newline at end of file