Search in sources :

Example 16 with DataProperty

use of org.pentaho.platform.api.repository2.unified.data.node.DataProperty in project pentaho-kettle by pentaho.

the class PartitionDelegate method dataNodeToElement.

public void dataNodeToElement(DataNode rootNode, RepositoryElementInterface element) throws KettleException {
    PartitionSchema partitionSchema = (PartitionSchema) element;
    partitionSchema.setDynamicallyDefined(rootNode.getProperty(PROP_DYNAMIC_DEFINITION).getBoolean());
    partitionSchema.setNumberOfPartitionsPerSlave(getString(rootNode, PROP_PARTITIONS_PER_SLAVE));
    // Also, load all the properties we can find...
    DataNode attrNode = rootNode.getNode(NODE_ATTRIBUTES);
    long partitionSchemaSize = attrNode.getProperty(PROP_NB_PARTITION_SCHEMA).getLong();
    for (int i = 0; i < partitionSchemaSize; i++) {
        DataProperty property = attrNode.getProperty(String.valueOf(i));
        partitionSchema.getPartitionIDs().add(Const.NVL(property.getString(), ""));
    }
}
Also used : PartitionSchema(org.pentaho.di.partition.PartitionSchema) DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) DataProperty(org.pentaho.platform.api.repository2.unified.data.node.DataProperty)

Example 17 with DataProperty

use of org.pentaho.platform.api.repository2.unified.data.node.DataProperty in project pentaho-kettle by pentaho.

the class PurRepositoryMetaStore method dataNodeToElement.

protected void dataNodeToElement(DataNode dataNode, IMetaStoreElement element) throws MetaStoreException {
    DataProperty nameProperty = dataNode.getProperty(PROP_NAME);
    if (nameProperty != null) {
        element.setName(nameProperty.getString());
    }
    DataNode childrenNode = dataNode.getNode(PROP_ELEMENT_CHILDREN);
    dataNodeToAttribute(childrenNode, element);
}
Also used : DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) DataProperty(org.pentaho.platform.api.repository2.unified.data.node.DataProperty)

Example 18 with DataProperty

use of org.pentaho.platform.api.repository2.unified.data.node.DataProperty in project pentaho-platform by pentaho.

the class NodeRepositoryFileDataTransformer method internalCreateOrUpdate.

protected void internalCreateOrUpdate(final Session session, final PentahoJcrConstants pentahoJcrConstants, final Node jcrParentNode, final DataNode dataNode) throws RepositoryException {
    // $NON-NLS-1$
    final String prefix = session.getNamespacePrefix(PentahoJcrConstants.PHO_NS) + ":";
    // get or create the node represented by dataNode
    Node jcrNode = null;
    String nodeName = dataNode.getName();
    // Not need to check the name if we encoded it
    // JcrRepositoryFileUtils.checkName( dataNode.getName() );
    nodeName = JcrStringHelper.fileNameEncode(nodeName);
    if (NodeHelper.hasNode(jcrParentNode, prefix, nodeName)) {
        jcrNode = NodeHelper.getNode(jcrParentNode, prefix, nodeName);
    } else {
        jcrNode = jcrParentNode.addNode(prefix + nodeName, pentahoJcrConstants.getPHO_NT_INTERNALFOLDER());
    }
    // set any properties represented by dataNode
    for (DataProperty dataProp : dataNode.getProperties()) {
        String propName = dataProp.getName();
        // Not need to check the name if we encoded it
        // JcrRepositoryFileUtils.checkName( propName );
        propName = prefix + JcrStringHelper.fileNameEncode(propName);
        switch(dataProp.getType()) {
            case STRING:
                {
                    jcrNode.setProperty(propName, dataProp.getString());
                    break;
                }
            case BOOLEAN:
                {
                    jcrNode.setProperty(propName, dataProp.getBoolean());
                    break;
                }
            case DOUBLE:
                {
                    jcrNode.setProperty(propName, dataProp.getDouble());
                    break;
                }
            case LONG:
                {
                    jcrNode.setProperty(propName, dataProp.getLong());
                    break;
                }
            case DATE:
                {
                    Calendar cal = Calendar.getInstance();
                    cal.setTime(dataProp.getDate());
                    jcrNode.setProperty(propName, cal);
                    break;
                }
            case REF:
                {
                    jcrNode.setProperty(propName, session.getNodeByIdentifier(dataProp.getRef().getId().toString()));
                    break;
                }
            default:
                {
                    throw new IllegalArgumentException();
                }
        }
    }
    // now process any child nodes of dataNode
    for (DataNode child : dataNode.getNodes()) {
        internalCreateOrUpdate(session, pentahoJcrConstants, jcrNode, child);
    }
}
Also used : DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) Node(javax.jcr.Node) Calendar(java.util.Calendar) DataProperty(org.pentaho.platform.api.repository2.unified.data.node.DataProperty)

Example 19 with DataProperty

use of org.pentaho.platform.api.repository2.unified.data.node.DataProperty in project pentaho-platform by pentaho.

the class UnifiedRepositoryTestUtils method pathPropertyPair.

/**
 * Factory for {@link PathPropertyPair} instances.
 */
public static PathPropertyPair pathPropertyPair(final String path, final boolean value) {
    checkPath(path);
    String[] pathSegments = path.split("/");
    return new PathPropertyPair(path, new DataProperty(pathSegments[pathSegments.length - 1], value, DataPropertyType.BOOLEAN));
}
Also used : DataProperty(org.pentaho.platform.api.repository2.unified.data.node.DataProperty)

Example 20 with DataProperty

use of org.pentaho.platform.api.repository2.unified.data.node.DataProperty in project pentaho-platform by pentaho.

the class UnifiedRepositoryTestUtils method pathPropertyPair.

/**
 * Factory for {@link PathPropertyPair} instances.
 */
public static PathPropertyPair pathPropertyPair(final String path, final String value) {
    checkPath(path);
    String[] pathSegments = path.split("/");
    return new PathPropertyPair(path, new DataProperty(pathSegments[pathSegments.length - 1], value, DataPropertyType.STRING));
}
Also used : DataProperty(org.pentaho.platform.api.repository2.unified.data.node.DataProperty)

Aggregations

DataProperty (org.pentaho.platform.api.repository2.unified.data.node.DataProperty)22 DataNode (org.pentaho.platform.api.repository2.unified.data.node.DataNode)13 NodeRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData)4 Date (java.util.Date)3 Test (org.junit.Test)3 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)3 ArrayList (java.util.ArrayList)2 Matchers.anyString (org.mockito.Matchers.anyString)2 ObjectId (org.pentaho.di.repository.ObjectId)2 StringObjectId (org.pentaho.di.repository.StringObjectId)2 ITenant (org.pentaho.platform.api.mt.ITenant)2 DataNodeRef (org.pentaho.platform.api.repository2.unified.data.node.DataNodeRef)2 Calendar (java.util.Calendar)1 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1 Map (java.util.Map)1 TimeZone (java.util.TimeZone)1 Node (javax.jcr.Node)1 DatabaseConnection (org.pentaho.database.model.DatabaseConnection)1 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)1