Search in sources :

Example 1 with NodeRepositoryFileDataDto

use of org.pentaho.platform.repository2.unified.webservices.NodeRepositoryFileDataDto in project pentaho-platform by pentaho.

the class UnifiedRepositoryToWebServiceAdapter method getDataForReadInBatch.

@Override
@SuppressWarnings("unchecked")
public <T extends IRepositoryFileData> java.util.List<T> getDataForReadInBatch(final List<RepositoryFile> files, final Class<T> dataClass) {
    List<RepositoryFileDto> fileDtos = new ArrayList<RepositoryFileDto>(files.size());
    for (RepositoryFile file : files) {
        fileDtos.add(repositoryFileAdapter.marshal(file));
    }
    if (dataClass.equals(NodeRepositoryFileData.class)) {
        List<NodeRepositoryFileDataDto> nodeData = repoWebService.getDataAsNodeForReadInBatch(fileDtos);
        List<T> data = new ArrayList<T>(nodeData.size());
        for (NodeRepositoryFileDataDto node : nodeData) {
            data.add((T) nodeRepositoryFileDataAdapter.unmarshal(node));
        }
        return data;
    } else if (dataClass.equals(SimpleRepositoryFileData.class)) {
        List<SimpleRepositoryFileDataDto> nodeData = repoWebService.getDataAsBinaryForReadInBatch(fileDtos);
        List<T> data = new ArrayList<T>(nodeData.size());
        for (SimpleRepositoryFileDataDto node : nodeData) {
            data.add((T) SimpleRepositoryFileDataDto.convert(node));
        }
        return data;
    } else {
        throw new IllegalArgumentException();
    }
}
Also used : RepositoryFileDto(org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto) NodeRepositoryFileDataDto(org.pentaho.platform.repository2.unified.webservices.NodeRepositoryFileDataDto) ArrayList(java.util.ArrayList) SimpleRepositoryFileData(org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)1 SimpleRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData)1 NodeRepositoryFileDataDto (org.pentaho.platform.repository2.unified.webservices.NodeRepositoryFileDataDto)1 RepositoryFileDto (org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto)1