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);
}
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);
}
}
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);
}
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;
}
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;
}
Aggregations