use of org.pentaho.di.repository.StringObjectId in project pentaho-metaverse by pentaho.
the class DIRepositoryLocator method getContents.
@Override
protected Object getContents(RepositoryFile file) throws Exception {
Object object = null;
ObjectId objectId;
Repository repo = getRepository();
if (repo instanceof KettleFileRepository) {
objectId = new StringObjectId(file.getPath());
} else {
objectId = new StringObjectId(file.getId().toString());
}
String extension = FilenameUtils.getExtension(file.getName());
if ("ktr".equals(extension)) {
object = repo.loadTransformation(objectId, null);
} else if ("kjb".equals(extension)) {
object = repo.loadJob(objectId, null);
}
return object;
}
use of org.pentaho.di.repository.StringObjectId in project pentaho-metaverse by pentaho.
the class TransMetaJsonDeserializerTest method testWriteJsonAttributes.
@Test
public void testWriteJsonAttributes() throws Exception {
JsonNode attributes = mock(JsonNode.class);
ObjectId stepId = new StringObjectId("id");
Map<String, Object> attrMap = new HashMap<String, Object>() {
{
put("name", "Test");
put("int", 2);
put("long", 3L);
put("double", 3.0D);
put("bool", true);
put("null", null);
}
};
when(attributes.toString()).thenReturn("mockedAttributes");
when(mapper.readValue("mockedAttributes", attrs0.getClass())).then(invocationOnMock -> attrMap);
deserializer.writeJsonAttributes(attributes, mapper, stepId);
verify(repo).saveStepAttribute(null, stepId, "name", "Test");
verify(repo).saveStepAttribute(null, stepId, "int", 2);
verify(repo).saveStepAttribute(null, stepId, "long", 3L);
verify(repo).saveStepAttribute(null, stepId, "double", 3.0D);
verify(repo).saveStepAttribute(null, stepId, "bool", true);
verify(repo).saveStepAttribute(null, stepId, "null", null);
}
use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.
the class TransExecutorMeta method loadXML.
public void loadXML(Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore) throws KettleXMLException {
try {
String method = XMLHandler.getTagValue(stepnode, "specification_method");
specificationMethod = ObjectLocationSpecificationMethod.getSpecificationMethodByCode(method);
String transId = XMLHandler.getTagValue(stepnode, "trans_object_id");
transObjectId = Utils.isEmpty(transId) ? null : new StringObjectId(transId);
transName = XMLHandler.getTagValue(stepnode, "trans_name");
fileName = XMLHandler.getTagValue(stepnode, "filename");
directoryPath = XMLHandler.getTagValue(stepnode, "directory_path");
groupSize = XMLHandler.getTagValue(stepnode, "group_size");
groupField = XMLHandler.getTagValue(stepnode, "group_field");
groupTime = XMLHandler.getTagValue(stepnode, "group_time");
// Load the mapping parameters too..
//
Node mappingParametersNode = XMLHandler.getSubNode(stepnode, TransExecutorParameters.XML_TAG);
parameters = new TransExecutorParameters(mappingParametersNode);
// The output side...
//
executionResultTargetStep = XMLHandler.getTagValue(stepnode, F_EXECUTION_RESULT_TARGET_STEP);
executionTimeField = XMLHandler.getTagValue(stepnode, "execution_time_field");
executionResultField = XMLHandler.getTagValue(stepnode, "execution_result_field");
executionNrErrorsField = XMLHandler.getTagValue(stepnode, "execution_errors_field");
executionLinesReadField = XMLHandler.getTagValue(stepnode, "execution_lines_read_field");
executionLinesWrittenField = XMLHandler.getTagValue(stepnode, "execution_lines_written_field");
executionLinesInputField = XMLHandler.getTagValue(stepnode, "execution_lines_input_field");
executionLinesOutputField = XMLHandler.getTagValue(stepnode, "execution_lines_output_field");
executionLinesRejectedField = XMLHandler.getTagValue(stepnode, "execution_lines_rejected_field");
executionLinesUpdatedField = XMLHandler.getTagValue(stepnode, "execution_lines_updated_field");
executionLinesDeletedField = XMLHandler.getTagValue(stepnode, "execution_lines_deleted_field");
executionFilesRetrievedField = XMLHandler.getTagValue(stepnode, "execution_files_retrieved_field");
executionExitStatusField = XMLHandler.getTagValue(stepnode, "execution_exit_status_field");
executionLogTextField = XMLHandler.getTagValue(stepnode, "execution_log_text_field");
executionLogChannelIdField = XMLHandler.getTagValue(stepnode, "execution_log_channelid_field");
outputRowsSourceStep = XMLHandler.getTagValue(stepnode, "result_rows_target_step");
int nrFields = XMLHandler.countNodes(stepnode, "result_rows_field");
allocate(nrFields);
for (int i = 0; i < nrFields; i++) {
Node fieldNode = XMLHandler.getSubNodeByNr(stepnode, "result_rows_field", i);
outputRowsField[i] = XMLHandler.getTagValue(fieldNode, "name");
outputRowsType[i] = ValueMetaFactory.getIdForValueMeta(XMLHandler.getTagValue(fieldNode, "type"));
outputRowsLength[i] = Const.toInt(XMLHandler.getTagValue(fieldNode, "length"), -1);
outputRowsPrecision[i] = Const.toInt(XMLHandler.getTagValue(fieldNode, "precision"), -1);
}
resultFilesTargetStep = XMLHandler.getTagValue(stepnode, F_RESULT_FILE_TARGET_STEP);
resultFilesFileNameField = XMLHandler.getTagValue(stepnode, "result_files_file_name_field");
executorsOutputStep = XMLHandler.getTagValue(stepnode, F_EXECUTOR_OUTPUT_STEP);
} catch (Exception e) {
throw new KettleXMLException(BaseMessages.getString(PKG, "TransExecutorMeta.Exception.ErrorLoadingTransExecutorDetailsFromXML"), e);
}
}
use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.
the class SimpleMappingMeta method readRep.
public void readRep(Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases) throws KettleException {
String method = rep.getStepAttributeString(id_step, "specification_method");
specificationMethod = ObjectLocationSpecificationMethod.getSpecificationMethodByCode(method);
String transId = rep.getStepAttributeString(id_step, "trans_object_id");
transObjectId = Utils.isEmpty(transId) ? null : new StringObjectId(transId);
transName = rep.getStepAttributeString(id_step, "trans_name");
fileName = rep.getStepAttributeString(id_step, "filename");
directoryPath = rep.getStepAttributeString(id_step, "directory_path");
// Backward compatibility check for object specification
//
checkObjectLocationSpecificationMethod();
inputMapping = new MappingIODefinition(rep, id_step, "input_", 0);
outputMapping = new MappingIODefinition(rep, id_step, "output_", 0);
mappingParameters = new MappingParameters(rep, id_step);
}
use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.
the class SimpleMappingMeta method loadXML.
public void loadXML(Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore) throws KettleXMLException {
try {
String method = XMLHandler.getTagValue(stepnode, "specification_method");
specificationMethod = ObjectLocationSpecificationMethod.getSpecificationMethodByCode(method);
String transId = XMLHandler.getTagValue(stepnode, "trans_object_id");
transObjectId = Utils.isEmpty(transId) ? null : new StringObjectId(transId);
transName = XMLHandler.getTagValue(stepnode, "trans_name");
fileName = XMLHandler.getTagValue(stepnode, "filename");
directoryPath = XMLHandler.getTagValue(stepnode, "directory_path");
// Backward compatibility check for object specification
//
checkObjectLocationSpecificationMethod();
Node mappingsNode = XMLHandler.getSubNode(stepnode, "mappings");
if (mappingsNode == null) {
throw new KettleXMLException("Unable to find <mappings> element in the step XML");
}
// Read all the input mapping definitions...
//
Node inputNode = XMLHandler.getSubNode(mappingsNode, "input");
Node mappingNode = XMLHandler.getSubNode(inputNode, MappingIODefinition.XML_TAG);
if (mappingNode != null) {
inputMapping = new MappingIODefinition(mappingNode);
} else {
// empty
inputMapping = new MappingIODefinition();
}
Node outputNode = XMLHandler.getSubNode(mappingsNode, "output");
mappingNode = XMLHandler.getSubNode(outputNode, MappingIODefinition.XML_TAG);
if (mappingNode != null) {
outputMapping = new MappingIODefinition(mappingNode);
} else {
// empty
outputMapping = new MappingIODefinition();
}
// Load the mapping parameters too..
//
Node mappingParametersNode = XMLHandler.getSubNode(mappingsNode, MappingParameters.XML_TAG);
mappingParameters = new MappingParameters(mappingParametersNode);
} catch (Exception e) {
throw new KettleXMLException(BaseMessages.getString(PKG, "SimpleMappingMeta.Exception.ErrorLoadingTransformationStepFromXML"), e);
}
}
Aggregations