use of org.pentaho.platform.api.repository2.unified.data.node.DataNode in project pentaho-kettle by pentaho.
the class PurRepositoryMetaStore method getElementTypeDataNode.
private DataNode getElementTypeDataNode(IMetaStoreElementType elementType) {
DataNode dataNode = new DataNode(ELEMENT_TYPE_DETAILS_FILENAME);
dataNode.setProperty(PROP_ELEMENT_TYPE_DESCRIPTION, elementType.getDescription());
dataNode.setProperty(PROP_ELEMENT_TYPE_NAME, elementType.getName());
dataNode.setProperty(PROP_NAME, elementType.getName());
return dataNode;
}
use of org.pentaho.platform.api.repository2.unified.data.node.DataNode in project pentaho-kettle by pentaho.
the class PurRepositoryMetaStore method dataNodeToAttribute.
protected void dataNodeToAttribute(DataNode dataNode, IMetaStoreAttribute attribute) throws MetaStoreException {
for (DataProperty dataProperty : dataNode.getProperties()) {
Object value;
switch(dataProperty.getType()) {
case DATE:
value = (dataProperty.getDate());
break;
case DOUBLE:
value = (dataProperty.getDouble());
break;
case LONG:
value = (dataProperty.getLong());
break;
case STRING:
value = (dataProperty.getString());
break;
default:
continue;
}
// Backwards Compatibility
if (dataProperty.getName().equals(dataNode.getName())) {
attribute.setValue(value);
}
attribute.addChild(newAttribute(dataProperty.getName(), value));
}
for (DataNode subNode : dataNode.getNodes()) {
IMetaStoreAttribute subAttr = newAttribute(subNode.getName(), null);
dataNodeToAttribute(subNode, subAttr);
attribute.addChild(subAttr);
}
}
use of org.pentaho.platform.api.repository2.unified.data.node.DataNode in project pentaho-kettle by pentaho.
the class PurRepositoryMetaStore method createElement.
// The elements
public void createElement(String namespace, IMetaStoreElementType elementType, IMetaStoreElement element) throws MetaStoreException {
RepositoryFile elementTypeFolder = validateElementTypeRepositoryFolder(namespace, elementType);
RepositoryFile elementFile = new RepositoryFile.Builder(PurRepository.checkAndSanitize(element.getName())).title(element.getName()).versioned(false).build();
DataNode elementDataNode = new DataNode(PurRepository.checkAndSanitize(element.getName()));
elementToDataNode(element, elementDataNode);
RepositoryFile createdFile = pur.createFile(elementTypeFolder.getId(), elementFile, new NodeRepositoryFileData(elementDataNode), null);
element.setId(createdFile.getId().toString());
// Verify existence.
if (pur.getFileById(createdFile.getId()) == null) {
throw new RuntimeException("Unable to verify creation of element '" + element.getName() + "' in folder: " + elementTypeFolder.getPath());
}
}
use of org.pentaho.platform.api.repository2.unified.data.node.DataNode in project pentaho-platform by pentaho.
the class NodeHelperTest method testCreateDataNode.
@Test
public void testCreateDataNode() {
mLog.info("testCreateDataNode..");
try {
DataNode lDataNode = NodeHelper.createDataNode("TEST_NODE");
assertTrue("TEST_NODE".equals(lDataNode.getName()));
} catch (Exception e) {
fail();
}
}
use of org.pentaho.platform.api.repository2.unified.data.node.DataNode in project pentaho-platform by pentaho.
the class DatabaseHelperTest method testDatabaseConnectionToDataNodeAddsExtraOptions.
@Test
public void testDatabaseConnectionToDataNodeAddsExtraOptions() {
DataNode dataNode = databaseHelper.databaseConnectionToDataNode(createDatabaseConnection());
DataNode extraOptionsNode = dataNode.getNode(NODE_EXTRA_OPTIONS_ORDER);
assertNotNull(extraOptionsNode);
assertNotNull(extraOptionsNode.getProperties().iterator());
assertTrue(extraOptionsNode.getProperties().iterator().hasNext());
}
Aggregations