All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sippnex.fileblade.dtos.DirectoryDto Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package com.sippnex.fileblade.dtos;

import com.sippnex.fileblade.entities.Directory;
import com.sippnex.fileblade.entities.FilebladeItem;

import java.util.ArrayList;
import java.util.List;

public class DirectoryDto extends FilebladeItemDto {

    private List items;

    public List getItems() {
        return items;
    }

    public void setItems(List items) {
        this.items = items;
    }

    public static DirectoryDto parse(Directory directory, String serverBaseUrl) {
        DirectoryDto directoryDto = new DirectoryDto();
        directoryDto.setId(directory.getId());
        directoryDto.setName(directory.getName());
        directoryDto.setPath(directory.getPath());

        // Parse parent directory id
        if (directory.getParentDirectory() != null) {
            directoryDto.setParentDirectoryId(directory.getParentDirectory().getId());
        }

        // Parse items
        List items = new ArrayList<>();
        for (FilebladeItem item: directory.getItems()) {
            items.add(FilebladeItemDto.parse(item, serverBaseUrl));
        }
        directoryDto.setItems(items);

        directoryDto.setType(Type.Directory);
        return directoryDto;
    }

}






© 2015 - 2024 Weber Informatics LLC | Privacy Policy