Search in sources :

Example 1 with NodeRepositoryFileDataDto

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

the class NodeRepositoryFileDataAdapter method unmarshal.

@Override
public NodeRepositoryFileData unmarshal(final NodeRepositoryFileDataDto v) {
    DataNode node = toDataNode(v.getNode());
    NodeRepositoryFileData data = new NodeRepositoryFileData(node);
    return data;
}
Also used : DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) NodeRepositoryFileData(org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData)

Example 2 with NodeRepositoryFileDataDto

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

the class NodeRepositoryFileDataAdapterTest method testMarshalUnmarshalDate.

private void testMarshalUnmarshalDate(Locale locale, TimeZone timeZone) throws Exception {
    final Locale defaultLocale = Locale.getDefault();
    final TimeZone defaultTimeZone = TimeZone.getDefault();
    // $NON-NLS-1$
    final String DATE_PROPERTY = "date";
    NodeRepositoryFileDataAdapter adapter = new NodeRepositoryFileDataAdapter();
    Date date = new Date();
    // $NON-NLS-1$
    DataNode node = new DataNode("");
    node.setProperty(DATE_PROPERTY, date);
    NodeRepositoryFileData data = new NodeRepositoryFileData(node);
    NodeRepositoryFileData result;
    // Convert using the provided locale
    try {
        Locale.setDefault(locale);
        TimeZone.setDefault(timeZone);
        NodeRepositoryFileDataDto dto = adapter.marshal(data);
        result = adapter.unmarshal(dto);
    } finally {
        Locale.setDefault(defaultLocale);
        TimeZone.setDefault(defaultTimeZone);
    }
    DataProperty property = result.getNode().getProperty(DATE_PROPERTY);
    assertNotNull(property);
    assertEquals(date, property.getDate());
}
Also used : Locale(java.util.Locale) TimeZone(java.util.TimeZone) NodeRepositoryFileDataDto(org.pentaho.platform.api.repository2.unified.webservices.NodeRepositoryFileDataDto) DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) NodeRepositoryFileData(org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData) DataProperty(org.pentaho.platform.api.repository2.unified.data.node.DataProperty) Date(java.util.Date)

Example 3 with NodeRepositoryFileDataDto

use of org.pentaho.platform.api.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.api.repository2.unified.webservices.RepositoryFileDto) NodeRepositoryFileDataDto(org.pentaho.platform.api.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)

Example 4 with NodeRepositoryFileDataDto

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

the class NodeRepositoryFileDataAdapter method marshal.

@Override
public NodeRepositoryFileDataDto marshal(final NodeRepositoryFileData v) {
    NodeRepositoryFileDataDto d = new NodeRepositoryFileDataDto();
    DataNodeDto node = new DataNodeDto();
    d.setNode(node);
    toDataNodeDto(node, v.getNode());
    return d;
}
Also used : NodeRepositoryFileDataDto(org.pentaho.platform.api.repository2.unified.webservices.NodeRepositoryFileDataDto) DataNodeDto(org.pentaho.platform.api.repository2.unified.webservices.DataNodeDto)

Aggregations

NodeRepositoryFileDataDto (org.pentaho.platform.api.repository2.unified.webservices.NodeRepositoryFileDataDto)3 DataNode (org.pentaho.platform.api.repository2.unified.data.node.DataNode)2 NodeRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 Locale (java.util.Locale)1 TimeZone (java.util.TimeZone)1 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)1 DataProperty (org.pentaho.platform.api.repository2.unified.data.node.DataProperty)1 SimpleRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData)1 DataNodeDto (org.pentaho.platform.api.repository2.unified.webservices.DataNodeDto)1 RepositoryFileDto (org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto)1