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