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

[ZEE-6082] Add specification to DataProduct #69

Merged
merged 1 commit into from
Dec 2, 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
50 changes: 47 additions & 3 deletions src/main/java/zeenea/connector/dataproduct/DataProduct.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import zeenea.connector.Item;
import zeenea.connector.dataset.Dataset;
import zeenea.connector.exception.ExceptionUtils;
Expand All @@ -19,6 +20,9 @@ public final class DataProduct extends Item {
/** The list of internal components for the data product. */
@NotNull private final List<Item> internalComponents;

/** The specification of the data product. */
@Nullable private final String specification;

/**
* Constructs a DataProduct instance using the provided builder.
*
Expand All @@ -32,6 +36,7 @@ private DataProduct(Builder builder) {
inputPorts = List.copyOf(builder.inputPorts);
outputPorts = List.copyOf(builder.outputPorts);
internalComponents = List.copyOf(builder.internalComponents);
specification = builder.specification;
}

/**
Expand Down Expand Up @@ -61,6 +66,15 @@ private DataProduct(Builder builder) {
return internalComponents;
}

/**
* Gets the specification of the data product.
*
* @return the specification of the data product
*/
public @NotNull Optional<String> getSpecification() {
return Optional.ofNullable(specification);
}

/**
* Checks if this DataProduct is equal to another object.
*
Expand All @@ -72,9 +86,15 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DataProduct that = (DataProduct) o;
return Objects.equals(inputPorts, that.inputPorts)
return Objects.equals(getId(), that.getId())
&& Objects.equals(getName(), that.getName())
&& Objects.equals(getDescription(), that.getDescription())
&& Objects.equals(getContacts(), that.getContacts())
&& Objects.equals(getProperties(), that.getProperties())
&& Objects.equals(inputPorts, that.inputPorts)
&& Objects.equals(outputPorts, that.outputPorts)
&& Objects.equals(internalComponents, that.internalComponents);
&& Objects.equals(internalComponents, that.internalComponents)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je ne suis pas extrêmement fan de ces méthodes equals car elle ne comparent pas les champs du type parent.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'avais corrigé les classes Dataset, Vizualisation et DataProcess sur les fonctions equals, hashcode et toString mais j'ai oublié de passer sur les classes de DataProduct :/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je suis passé sur DataProduct.

&& Objects.equals(specification, that.specification);
}

/**
Expand All @@ -84,7 +104,16 @@ public boolean equals(Object o) {
*/
@Override
public int hashCode() {
return Objects.hash(inputPorts, outputPorts, internalComponents);
return Objects.hash(
getId(),
getName(),
getDescription(),
getContacts(),
getProperties(),
inputPorts,
outputPorts,
internalComponents,
specification);
}

/**
Expand All @@ -111,6 +140,8 @@ public String toString() {
+ internalComponents
+ ", outputPorts="
+ outputPorts
+ ", specification="
+ specification
+ "}";
}

Expand Down Expand Up @@ -151,6 +182,8 @@ public static class Builder extends Item.Builder<DataProduct, Builder> {

private List<Item> internalComponents = Collections.emptyList();

private String specification;

/**
* Set a collection of input ports to the data product.
*
Expand Down Expand Up @@ -217,6 +250,17 @@ public Builder internalComponents(Item... items) {
return this;
}

/**
* Sets the specification of the data product.
*
* @param specification the specification of the data product
* @return the builder instance
*/
public Builder specification(@Nullable String specification) {
this.specification = specification;
return this;
}

/**
* Builds and returns a DataProduct instance.
*
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0
2.2.0
Loading