Skip to content

Commit

Permalink
Merge pull request #68 from zeenea/ZEE-6403/change_fields_identificat…
Browse files Browse the repository at this point in the history
…ions_in_dataset

[ZEE-6403] Change Fields identification in Dataset
  • Loading branch information
martin-guerre authored Nov 28, 2024
2 parents cfeabf0 + 58fb460 commit 569ece8
Show file tree
Hide file tree
Showing 5 changed files with 295 additions and 216 deletions.
98 changes: 62 additions & 36 deletions src/main/java/zeenea/connector/dataset/Dataset.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Objects;
import org.jetbrains.annotations.NotNull;
import zeenea.connector.Item;
import zeenea.connector.common.ItemIdentifier;
import zeenea.connector.common.ItemReference;
import zeenea.connector.exception.ExceptionUtils;
import zeenea.connector.field.Field;
Expand All @@ -16,14 +17,19 @@ public final class Dataset extends Item {
@NotNull private final List<Field> fields;

/** The list of primary keys in the dataset. */
@NotNull private final List<String> primaryKeys;
@Deprecated(
since =
"Deprecated since version 2.1.0, use primaryKeyIdentifiers instead. Scheduled for removal in version 3.0.0.",
forRemoval = true)
@NotNull
private final List<String> primaryKeys;

/** The list of identifiers for primary keys in the dataset. */
@NotNull private final List<ItemIdentifier> primaryKeyIdentifiers;

/** The list of foreign keys in the dataset. */
@NotNull private final List<ForeignKey> foreignKeys;

/** The list of partitions in the dataset. */
@NotNull private final List<Partitioning> partitions;

/**
* The list of source datasets associated with the dataset.
*
Expand All @@ -39,10 +45,14 @@ public final class Dataset extends Item {
private Dataset(Builder builder) {
super(builder);
ExceptionUtils.requireNonNull("fields", builder.fields);
ExceptionUtils.requireNonNull("primaryKeys", builder.primaryKeys);
ExceptionUtils.requireNonNull("primaryKeyIdentifiers", builder.primaryKeyIdentifiers);
ExceptionUtils.requireNonNull("foreignKeys", builder.foreignKeys);
ExceptionUtils.requireNonNull("sourceDatasets", builder.sourceDatasets);
this.fields = List.copyOf(builder.fields);
this.primaryKeys = List.copyOf(builder.primaryKeys);
this.primaryKeyIdentifiers = List.copyOf(builder.primaryKeyIdentifiers);
this.foreignKeys = List.copyOf(builder.foreignKeys);
this.partitions = List.copyOf(builder.partitions);
this.sourceDatasets = List.copyOf(builder.sourceDatasets);
}

Expand All @@ -65,21 +75,25 @@ private Dataset(Builder builder) {
}

/**
* Gets the list of partitions in the dataset.
* Gets the list of primary keys in the dataset.
*
* @return the list of partitions
* @return the list of primary keys
*/
public @NotNull List<Partitioning> getPartitions() {
return partitions;
@Deprecated(
since =
"Deprecated since version 2.1.0, use getPrimaryKeyIdentifiers instead. Scheduled for removal in version 3.0.0.",
forRemoval = true)
public @NotNull List<String> getPrimaryKeys() {
return primaryKeys;
}

/**
* Gets the list of primary keys in the dataset.
* Gets the list of identifiers for primary keys in the dataset.
*
* @return the list of primary keys
* @return the list of identifiers for primary keys
*/
public @NotNull List<String> getPrimaryKeys() {
return primaryKeys;
public @NotNull List<ItemIdentifier> getPrimaryKeyIdentifiers() {
return primaryKeyIdentifiers;
}

/**
Expand Down Expand Up @@ -109,8 +123,8 @@ public boolean equals(Object o) {
&& Objects.equals(getProperties(), dataset.getProperties())
&& Objects.equals(fields, dataset.fields)
&& Objects.equals(primaryKeys, dataset.primaryKeys)
&& Objects.equals(primaryKeyIdentifiers, dataset.primaryKeyIdentifiers)
&& Objects.equals(foreignKeys, dataset.foreignKeys)
&& Objects.equals(partitions, dataset.partitions)
&& Objects.equals(sourceDatasets, dataset.sourceDatasets);
}

Expand All @@ -129,8 +143,8 @@ public int hashCode() {
getProperties(),
fields,
primaryKeys,
primaryKeyIdentifiers,
foreignKeys,
partitions,
sourceDatasets);
}

Expand All @@ -156,10 +170,10 @@ public String toString() {
+ fields
+ ", primaryKeys="
+ primaryKeys
+ ", primaryKeyIdentifiers="
+ primaryKeyIdentifiers
+ ", foreignKeys="
+ foreignKeys
+ ", partitions="
+ partitions
+ ", sourceDatasets="
+ sourceDatasets
+ '}';
Expand All @@ -181,14 +195,18 @@ public static class Builder extends Item.Builder<Dataset, Builder> {
private List<Field> fields = new ArrayList<>();

/** The list of primary keys in the dataset. */
@Deprecated(
since =
"Deprecated since version 2.1.0, use primaryKeyIdentifiers instead. Scheduled for removal in version 3.0.0.",
forRemoval = true)
private List<String> primaryKeys = new ArrayList<>();

/** The list of identifiers for primary keys in the dataset. */
private List<ItemIdentifier> primaryKeyIdentifiers = new ArrayList<>();

/** The list of foreign keys in the dataset. */
private List<ForeignKey> foreignKeys = new ArrayList<>();

/** The list of partitions in the dataset. */
private List<Partitioning> partitions = new ArrayList<>();

/** The list of source datasets for the dataset. */
private List<ItemReference> sourceDatasets = new ArrayList<>();

Expand Down Expand Up @@ -220,6 +238,10 @@ public Builder fields(Field... fields) {
* @param primaryKeys the list of primary keys
* @return the builder instance
*/
@Deprecated(
since =
"Deprecated since version 2.1.0, use primaryKeyIdentifiers instead. Scheduled for removal in version 3.0.0.",
forRemoval = true)
public Builder primaryKeys(@NotNull List<String> primaryKeys) {
this.primaryKeys = List.copyOf(primaryKeys);
return this;
Expand All @@ -231,52 +253,56 @@ public Builder primaryKeys(@NotNull List<String> primaryKeys) {
* @param primaryKeys the list of primary keys
* @return the builder instance
*/
@Deprecated(
since =
"Deprecated since version 2.1.0, use primaryKeyIdentifiers instead. Scheduled for removal in version 3.0.0.",
forRemoval = true)
public Builder primaryKeys(String... primaryKeys) {
this.primaryKeys = List.of(primaryKeys);
return this;
}

/**
* Sets the list of foreign keys in the dataset.
* Sets the list of identifiers for primary keys in the dataset.
*
* @param foreignKeys the list of foreign keys
* @param primaryKeyIdentifiers the list of identifiers for primary keys
* @return the builder instance
*/
public Builder foreignKeys(@NotNull List<ForeignKey> foreignKeys) {
this.foreignKeys = List.copyOf(foreignKeys);
public Builder primaryKeyIdentifiers(@NotNull List<ItemIdentifier> primaryKeyIdentifiers) {
this.primaryKeyIdentifiers = List.copyOf(primaryKeyIdentifiers);
return this;
}

/**
* Sets the list of foreign keys in the dataset.
* Sets the list of identifiers for primary keys in the dataset.
*
* @param foreignKeys the list of foreign keys
* @param primaryKeyIdentifiers the list of identifiers for primary keys
* @return the builder instance
*/
public Builder foreignKeys(ForeignKey... foreignKeys) {
this.foreignKeys = List.of(foreignKeys);
public Builder primaryKeyIdentifiers(ItemIdentifier... primaryKeyIdentifiers) {
this.primaryKeyIdentifiers = List.of(primaryKeyIdentifiers);
return this;
}

/**
* Sets the list of partitions in the dataset.
* Sets the list of foreign keys in the dataset.
*
* @param partitions the list of partitions
* @param foreignKeys the list of foreign keys
* @return the builder instance
*/
public Builder partitions(@NotNull List<Partitioning> partitions) {
this.partitions = List.copyOf(partitions);
public Builder foreignKeys(@NotNull List<ForeignKey> foreignKeys) {
this.foreignKeys = List.copyOf(foreignKeys);
return this;
}

/**
* Sets the list of partitions in the dataset.
* Sets the list of foreign keys in the dataset.
*
* @param partitions the list of partitions
* @param foreignKeys the list of foreign keys
* @return the builder instance
*/
public Builder partitions(Partitioning... partitions) {
this.partitions = List.of(partitions);
public Builder foreignKeys(ForeignKey... foreignKeys) {
this.foreignKeys = List.of(foreignKeys);
return this;
}

Expand Down
Loading

0 comments on commit 569ece8

Please sign in to comment.