You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.3 KiB
Java
61 lines
1.3 KiB
Java
package eu.eudat.elastic.entities;
|
|
|
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
|
|
import java.io.IOException;
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* Created by ikalyvas on 7/5/2018.
|
|
*/
|
|
public class Dataset implements ElasticEntity<Dataset> {
|
|
|
|
private String id;
|
|
private List<Tag> tags = new LinkedList<>();
|
|
|
|
public String getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(String id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public List<Tag> getTags() {
|
|
return tags;
|
|
}
|
|
|
|
public void setTags(List<Tag> tags) {
|
|
this.tags = tags;
|
|
}
|
|
|
|
@Override
|
|
public XContentBuilder toElasticEntity(XContentBuilder builder) throws IOException {
|
|
builder.startObject();
|
|
builder.field("id", this.id);
|
|
builder.startArray("tags");
|
|
this.tags.forEach(x -> {
|
|
try {
|
|
x.toElasticEntity(builder);
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
});
|
|
builder.endArray();
|
|
builder.endObject();
|
|
return builder;
|
|
}
|
|
|
|
@Override
|
|
public Dataset fromElasticEntity(Map<String, Object> fields) {
|
|
if (fields != null) {
|
|
this.id = (String) fields.get("id");
|
|
this.tags = ((List<Tag>) fields.get("tags"));
|
|
}
|
|
return this;
|
|
}
|
|
|
|
}
|