Search in sources :

Example 16 with DataNode

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;
}
Also used : DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode)

Example 17 with 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);
    }
}
Also used : DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) IMetaStoreAttribute(org.pentaho.metastore.api.IMetaStoreAttribute) DataProperty(org.pentaho.platform.api.repository2.unified.data.node.DataProperty)

Example 18 with DataNode

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());
    }
}
Also used : DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) NodeRepositoryFileData(org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile)

Example 19 with DataNode

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();
    }
}
Also used : DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) Test(org.junit.Test)

Example 20 with DataNode

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());
}
Also used : DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) Test(org.junit.Test)

Aggregations

DataNode (org.pentaho.platform.api.repository2.unified.data.node.DataNode)63 NodeRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData)22 Test (org.junit.Test)17 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)17 DataProperty (org.pentaho.platform.api.repository2.unified.data.node.DataProperty)15 DataNodeRef (org.pentaho.platform.api.repository2.unified.data.node.DataNodeRef)11 Matchers.anyString (org.mockito.Matchers.anyString)7 Date (java.util.Date)6 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)6 ArrayList (java.util.ArrayList)5 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)5 ITenant (org.pentaho.platform.api.mt.ITenant)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 NotePadMeta (org.pentaho.di.core.NotePadMeta)4 KettleException (org.pentaho.di.core.exception.KettleException)4 JobMeta (org.pentaho.di.job.JobMeta)4 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)4 StringObjectId (org.pentaho.di.repository.StringObjectId)4 Properties (java.util.Properties)3