Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cols and FieldDefinition.java code changes #800

Merged
merged 2 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<FieldDefinition> fieldDefs, boolean showConcise) {

List<FieldDefinition> namedList = new ArrayList<>();

for (FieldDefinition fieldDef : fieldDefs) {
if (showConcise && fieldDef.isDontUse()) {
continue;
}
namedList.add(fieldDef);
}

namedList.add(new FieldDefinition());
List<String> stringList = convertNamedListToStringList(namedList);
setCols(stringList);
}

private List<String> convertNamedListToStringList(List<FieldDefinition> namedList) {
List<String> stringList = new ArrayList<>();
for (FieldDefinition named : namedList) {
stringList.add(named.getName());
}
return stringList;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package zingg.common.client.cols;

import java.util.List;

public interface ISelectedCols {

String[] getCols(List<? extends Named> n);

String[] getCols();

void setCols(List<String> cols);

void setNamedCols(List<? extends Named> n);

void setStringCols(List<String> cols);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package zingg.common.client.cols;

public interface Named {

String getName();

void setName(String name);
}
Original file line number Diff line number Diff line change
@@ -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<? extends Named> 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<String> strings) {
this.cols = strings.toArray(new String[0]);
}

@Override
public void setNamedCols(List<? extends Named> n) {
this.cols = getCols(n);
}

@Override
public void setStringCols(List<String> columnNames) {
this.cols = columnNames.toArray(new String[0]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package zingg.common.client.cols;

import java.util.Arrays;
import java.util.List;

import zingg.common.client.util.ColName;

public class ZidAndFieldDefSelector extends SelectedCols {

public ZidAndFieldDefSelector(String[] fieldDefs) {

List<String> fieldDefList = Arrays.asList(fieldDefs);
fieldDefList.add(0, ColName.ID_COL);
setCols(fieldDefList);
}
}
Loading