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;
}
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());
}
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();
}
}
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;
}
Aggregations