View Javadoc
1   package de.dlr.shepard.data.file.io;
2   
3   import com.fasterxml.jackson.annotation.JsonInclude;
4   import de.dlr.shepard.common.neo4j.io.BasicContainerIO;
5   import de.dlr.shepard.context.collection.entities.Collection;
6   import de.dlr.shepard.data.file.entities.FileContainer;
7   import java.util.ArrayList;
8   import java.util.List;
9   import java.util.stream.Collectors;
10  import lombok.Data;
11  import lombok.EqualsAndHashCode;
12  import lombok.NoArgsConstructor;
13  import org.eclipse.microprofile.openapi.annotations.media.Schema;
14  
15  @Data
16  @EqualsAndHashCode(callSuper = true)
17  @NoArgsConstructor
18  @Schema(name = "FileContainer")
19  public class FileContainerIO extends BasicContainerIO {
20  
21    @Schema(readOnly = true, required = true)
22    private String oid;
23  
24    /**
25     * List of collection Ids this container is assigned to as their default container.
26     * This field is not returned in the response, if it is set to null.
27     */
28    @Schema(readOnly = true, nullable = true)
29    @JsonInclude(JsonInclude.Include.NON_NULL)
30    private List<Long> defaultCollectionIdList = new ArrayList<>();
31  
32    public FileContainerIO(FileContainer container) {
33      super(container);
34      this.oid = container.getMongoId();
35  
36      if (container.getCollectionList() != null) {
37        this.defaultCollectionIdList = container
38          .getCollectionList()
39          .stream()
40          .map(Collection::getId)
41          .collect(Collectors.toList());
42      } else {
43        this.defaultCollectionIdList = null;
44      }
45    }
46  }