Search in sources :

Example 11 with DataNodeRef

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

the class RepositoryProxy method insertJobEntryDatabase.

public void insertJobEntryDatabase(ObjectId idJob, ObjectId idJobentry, ObjectId idDatabase) throws KettleException {
    DataNodeRef ref = new DataNodeRef(idDatabase.getId());
    node.setProperty(idDatabase.getId(), ref);
}
Also used : DataNodeRef(org.pentaho.platform.api.repository2.unified.data.node.DataNodeRef)

Example 12 with DataNodeRef

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

the class RepositoryProxy method saveDatabaseMetaStepAttribute.

public void saveDatabaseMetaStepAttribute(ObjectId idTransformation, ObjectId idStep, String code, DatabaseMeta database) throws KettleException {
    if (database != null && database.getObjectId() != null) {
        DataNodeRef ref = new DataNodeRef(database.getObjectId().getId());
        node.setProperty(code, ref);
    }
}
Also used : DataNodeRef(org.pentaho.platform.api.repository2.unified.data.node.DataNodeRef)

Example 13 with DataNodeRef

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

the class RepositoryProxy method insertStepDatabase.

public void insertStepDatabase(ObjectId idTransformation, ObjectId idStep, ObjectId idDatabase) throws KettleException {
    DataNodeRef ref = new DataNodeRef(idDatabase.getId());
    node.setProperty(idDatabase.getId(), ref);
}
Also used : DataNodeRef(org.pentaho.platform.api.repository2.unified.data.node.DataNodeRef)

Example 14 with DataNodeRef

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

the class NodeRepositoryFileDataTransformer method internalRead.

protected DataNode internalRead(final Session session, final PentahoJcrConstants pentahoJcrConstants, final Node jcrNode, final DataNode parentDataNode) throws RepositoryException {
    // $NON-NLS-1$
    final String prefix = session.getNamespacePrefix(PentahoJcrConstants.PHO_NS) + ":";
    // $NON-NLS-1$
    final String pattern = prefix + "*";
    String nodeName = JcrStringHelper.fileNameDecode(jcrNode.getName().substring(prefix.length()));
    DataNode dataNode = parentDataNode != null ? parentDataNode.addNode(nodeName) : new DataNode(nodeName);
    dataNode.setId(jcrNode.getIdentifier());
    PropertyIterator props = jcrNode.getProperties(pattern);
    while (props.hasNext()) {
        Property prop = props.nextProperty();
        String propName = JcrStringHelper.fileNameDecode(prop.getName().substring(prefix.length()));
        switch(prop.getType()) {
            case PropertyType.STRING:
                {
                    dataNode.setProperty(propName, prop.getString());
                    break;
                }
            case PropertyType.BOOLEAN:
                {
                    dataNode.setProperty(propName, prop.getBoolean());
                    break;
                }
            case PropertyType.DOUBLE:
                {
                    dataNode.setProperty(propName, prop.getDouble());
                    break;
                }
            case PropertyType.LONG:
                {
                    dataNode.setProperty(propName, prop.getLong());
                    break;
                }
            case PropertyType.DATE:
                {
                    dataNode.setProperty(propName, prop.getDate().getTime());
                    break;
                }
            case PropertyType.REFERENCE:
                {
                    try {
                        dataNode.setProperty(propName, new DataNodeRef(prop.getNode().getIdentifier()));
                    } catch (ItemNotFoundException e) {
                        // reference is missing, replace with missing data ref
                        // this situation can occur if the user does not have permission to access the reference.
                        dataNode.setProperty(propName, new DataNodeRef(DataNodeRef.REF_MISSING));
                    }
                    break;
                }
            default:
                {
                    throw new IllegalArgumentException();
                }
        }
    }
    // iterate over children
    NodeIterator nodes = jcrNode.getNodes(pattern);
    while (nodes.hasNext()) {
        Node child = nodes.nextNode();
        internalRead(session, pentahoJcrConstants, child, dataNode);
    }
    return dataNode;
}
Also used : DataNodeRef(org.pentaho.platform.api.repository2.unified.data.node.DataNodeRef) NodeIterator(javax.jcr.NodeIterator) DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) Node(javax.jcr.Node) PropertyIterator(javax.jcr.PropertyIterator) DataProperty(org.pentaho.platform.api.repository2.unified.data.node.DataProperty) Property(javax.jcr.Property) ItemNotFoundException(javax.jcr.ItemNotFoundException)

Example 15 with DataNodeRef

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

the class NodeRepositoryFileDataAdapter method toDataNode.

protected DataNode toDataNode(final DataNodeDto nodeDto) {
    DataNode node = new DataNode(nodeDto.name);
    node.setId(nodeDto.id);
    for (DataPropertyDto dtoProp : nodeDto.childProperties) {
        if (dtoProp.type == DataPropertyType.BOOLEAN.ordinal()) {
            node.setProperty(dtoProp.name, Boolean.parseBoolean(dtoProp.value));
        } else if (dtoProp.type == DataPropertyType.DATE.ordinal()) {
            node.setProperty(dtoProp.name, new Date(Long.parseLong(dtoProp.value)));
        } else if (dtoProp.type == DataPropertyType.DOUBLE.ordinal()) {
            node.setProperty(dtoProp.name, Double.parseDouble(dtoProp.value));
        } else if (dtoProp.type == DataPropertyType.LONG.ordinal()) {
            node.setProperty(dtoProp.name, Long.parseLong(dtoProp.value));
        } else if (dtoProp.type == DataPropertyType.STRING.ordinal()) {
            node.setProperty(dtoProp.name, dtoProp.value);
        } else if (dtoProp.type == DataPropertyType.REF.ordinal()) {
            node.setProperty(dtoProp.name, new DataNodeRef(dtoProp.value));
        } else {
            throw new IllegalArgumentException();
        }
    }
    for (DataNodeDto childNodeDto : nodeDto.childNodes) {
        node.addNode(toDataNode(childNodeDto));
    }
    return node;
}
Also used : DataNodeRef(org.pentaho.platform.api.repository2.unified.data.node.DataNodeRef) DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) Date(java.util.Date)

Aggregations

DataNodeRef (org.pentaho.platform.api.repository2.unified.data.node.DataNodeRef)15 DataNode (org.pentaho.platform.api.repository2.unified.data.node.DataNode)9 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)4 NodeRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData)4 Test (org.junit.Test)3 Matchers.anyString (org.mockito.Matchers.anyString)3 ITenant (org.pentaho.platform.api.mt.ITenant)3 DataProperty (org.pentaho.platform.api.repository2.unified.data.node.DataProperty)3 Date (java.util.Date)2 ClusterSchema (org.pentaho.di.cluster.ClusterSchema)2 LogTableInterface (org.pentaho.di.core.logging.LogTableInterface)2 RepositoryAttributeInterface (org.pentaho.di.repository.RepositoryAttributeInterface)2 ItemNotFoundException (javax.jcr.ItemNotFoundException)1 Node (javax.jcr.Node)1 NodeIterator (javax.jcr.NodeIterator)1 Property (javax.jcr.Property)1 PropertyIterator (javax.jcr.PropertyIterator)1 SlaveServer (org.pentaho.di.cluster.SlaveServer)1 NotePadMeta (org.pentaho.di.core.NotePadMeta)1 Repository (org.pentaho.di.repository.Repository)1