Search in sources :

Example 11 with IMetaStoreAttribute

use of org.pentaho.metastore.api.IMetaStoreAttribute in project pentaho-kettle by pentaho.

the class MetaStoreExplorerDialog method addAttributesToTree.

private void addAttributesToTree(TreeItem parentItem, IMetaStoreAttribute parentAttribute) {
    for (IMetaStoreAttribute childAttribute : parentAttribute.getChildren()) {
        TreeItem treeItem = new TreeItem(parentItem, SWT.NONE);
        treeItem.setText(0, Const.NVL(childAttribute.getId(), ""));
        treeItem.setText(1, childAttribute.getValue() == null ? "" : childAttribute.getValue().toString());
        // Add more child attributes below
        // 
        addAttributesToTree(treeItem, childAttribute);
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) IMetaStoreAttribute(org.pentaho.metastore.api.IMetaStoreAttribute)

Example 12 with IMetaStoreAttribute

use of org.pentaho.metastore.api.IMetaStoreAttribute in project pentaho-kettle by pentaho.

the class PurRepositoryMetaStore method attributeToDataNode.

protected void attributeToDataNode(IMetaStoreAttribute attribute, DataNode dataNode) {
    String id = attribute.getId();
    Object value = attribute.getValue();
    if (id == null) {
        throw new NullPointerException();
    } else if (value != null) {
        if (value instanceof Double) {
            dataNode.setProperty(id, (Double) value);
        } else if (value instanceof Date) {
            dataNode.setProperty(id, (Date) value);
        } else if (value instanceof Long) {
            dataNode.setProperty(id, (Long) value);
        } else {
            dataNode.setProperty(id, value.toString());
        }
    }
    for (IMetaStoreAttribute child : attribute.getChildren()) {
        DataNode subNode = new DataNode(child.getId());
        attributeToDataNode(child, subNode);
        dataNode.addNode(subNode);
    }
}
Also used : DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) IMetaStoreAttribute(org.pentaho.metastore.api.IMetaStoreAttribute) Date(java.util.Date)

Example 13 with IMetaStoreAttribute

use of org.pentaho.metastore.api.IMetaStoreAttribute in project pentaho-kettle by pentaho.

the class KettleMetaStoreTestBase method generateCustomerDimensionElement.

private IMetaStoreElement generateCustomerDimensionElement(IMetaStore metaStore, IMetaStoreElementType elementType) throws MetaStoreException {
    IMetaStoreElement element = metaStore.newElement();
    element.setElementType(elementType);
    element.setName(CUSTOMER_DIMENSION_NAME);
    element.addChild(metaStore.newAttribute("description", "This is the shared customer dimension"));
    element.addChild(metaStore.newAttribute("physical_table", "DIM_CUSTOMER"));
    IMetaStoreAttribute fieldsElement = metaStore.newAttribute("fields", null);
    element.addChild(fieldsElement);
    // A technical key
    // 
    IMetaStoreAttribute fieldElement = metaStore.newAttribute("field_0", null);
    fieldsElement.addChild(fieldElement);
    fieldElement.addChild(metaStore.newAttribute("field_name", "Customer TK"));
    fieldElement.addChild(metaStore.newAttribute("field_description", "Customer Technical key"));
    fieldElement.addChild(metaStore.newAttribute("field_phyiscal_name", "customer_tk"));
    fieldElement.addChild(metaStore.newAttribute("field_kettle_type", "Integer"));
    // A version field
    // 
    fieldElement = metaStore.newAttribute("field_1", null);
    fieldsElement.addChild(fieldElement);
    fieldElement.addChild(metaStore.newAttribute("field_name", "version field"));
    fieldElement.addChild(metaStore.newAttribute("field_description", "dimension version field (1..N)"));
    fieldElement.addChild(metaStore.newAttribute("field_phyiscal_name", "version"));
    fieldElement.addChild(metaStore.newAttribute("field_kettle_type", "Integer"));
    // Natural key
    // 
    fieldElement = metaStore.newAttribute("field_2", null);
    fieldsElement.addChild(fieldElement);
    fieldElement.addChild(metaStore.newAttribute("field_name", "Customer ID"));
    fieldElement.addChild(metaStore.newAttribute("field_description", "Customer ID as a natural key of this dimension"));
    fieldElement.addChild(metaStore.newAttribute("field_phyiscal_name", "customer_id"));
    fieldElement.addChild(metaStore.newAttribute("field_kettle_type", "Integer"));
    // Start date
    // 
    fieldElement = metaStore.newAttribute("field_3", null);
    fieldsElement.addChild(fieldElement);
    fieldElement.addChild(metaStore.newAttribute("field_name", "Start date"));
    fieldElement.addChild(metaStore.newAttribute("field_description", "Start of validity of this dimension entry"));
    fieldElement.addChild(metaStore.newAttribute("field_phyiscal_name", "start_date"));
    fieldElement.addChild(metaStore.newAttribute("field_kettle_type", "Date"));
    // End date
    // 
    fieldElement = metaStore.newAttribute("field_4", null);
    fieldsElement.addChild(fieldElement);
    fieldElement.addChild(metaStore.newAttribute("field_name", "End date"));
    fieldElement.addChild(metaStore.newAttribute("field_description", "End of validity of this dimension entry"));
    fieldElement.addChild(metaStore.newAttribute("field_phyiscal_name", "end_date"));
    fieldElement.addChild(metaStore.newAttribute("field_kettle_type", "Date"));
    // 
    for (int i = 5; i <= 10; i++) {
        fieldElement = metaStore.newAttribute("field_" + i, null);
        fieldsElement.addChild(fieldElement);
        fieldElement.addChild(metaStore.newAttribute("field_name", "Field name " + i));
        fieldElement.addChild(metaStore.newAttribute("field_description", "Field description " + i));
        fieldElement.addChild(metaStore.newAttribute("field_phyiscal_name", "physical_name_" + i));
        fieldElement.addChild(metaStore.newAttribute("field_kettle_type", "String"));
    }
    // Some security
    // 
    element.setOwner(metaStore.newElementOwner("joe", MetaStoreElementOwnerType.USER));
    // The "users" role has read/write permissions
    // 
    IMetaStoreElementOwner usersRole = metaStore.newElementOwner("users", MetaStoreElementOwnerType.ROLE);
    MetaStoreOwnerPermissions usersRoleOwnerPermissions = new MetaStoreOwnerPermissions(usersRole, MetaStoreObjectPermission.READ, MetaStoreObjectPermission.UPDATE);
    element.getOwnerPermissionsList().add(usersRoleOwnerPermissions);
    return element;
}
Also used : IMetaStoreElementOwner(org.pentaho.metastore.api.security.IMetaStoreElementOwner) MetaStoreOwnerPermissions(org.pentaho.metastore.api.security.MetaStoreOwnerPermissions) IMetaStoreAttribute(org.pentaho.metastore.api.IMetaStoreAttribute) IMetaStoreElement(org.pentaho.metastore.api.IMetaStoreElement)

Aggregations

IMetaStoreAttribute (org.pentaho.metastore.api.IMetaStoreAttribute)13 IMetaStoreElement (org.pentaho.metastore.api.IMetaStoreElement)6 Properties (java.util.Properties)2 KettlePluginException (org.pentaho.di.core.exception.KettlePluginException)2 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)2 IMetaStoreElementOwner (org.pentaho.metastore.api.security.IMetaStoreElementOwner)2 MetaStoreOwnerPermissions (org.pentaho.metastore.api.security.MetaStoreOwnerPermissions)2 DataNode (org.pentaho.platform.api.repository2.unified.data.node.DataNode)2 Date (java.util.Date)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)1 DatabaseInterface (org.pentaho.di.core.database.DatabaseInterface)1 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)1 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)1 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)1 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)1 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)1 LongObjectId (org.pentaho.di.repository.LongObjectId)1