Search in sources :

Example 61 with StringObjectId

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;
}
Also used : Repository(org.pentaho.di.repository.Repository) KettleFileRepository(org.pentaho.di.repository.filerep.KettleFileRepository) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) ObjectId(org.pentaho.di.repository.ObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) KettleFileRepository(org.pentaho.di.repository.filerep.KettleFileRepository)

Example 62 with StringObjectId

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);
}
Also used : StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId) HashMap(java.util.HashMap) JsonNode(com.fasterxml.jackson.databind.JsonNode) Matchers.anyString(org.mockito.Matchers.anyString) StringObjectId(org.pentaho.di.repository.StringObjectId) Test(org.junit.Test)

Example 63 with StringObjectId

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);
    }
}
Also used : Node(org.w3c.dom.Node) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) StringObjectId(org.pentaho.di.repository.StringObjectId) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettlePluginException(org.pentaho.di.core.exception.KettlePluginException) KettleStepException(org.pentaho.di.core.exception.KettleStepException)

Example 64 with StringObjectId

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);
}
Also used : MappingIODefinition(org.pentaho.di.trans.steps.mapping.MappingIODefinition) MappingParameters(org.pentaho.di.trans.steps.mapping.MappingParameters) StringObjectId(org.pentaho.di.repository.StringObjectId)

Example 65 with StringObjectId

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);
    }
}
Also used : MappingIODefinition(org.pentaho.di.trans.steps.mapping.MappingIODefinition) Node(org.w3c.dom.Node) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) MappingParameters(org.pentaho.di.trans.steps.mapping.MappingParameters) StringObjectId(org.pentaho.di.repository.StringObjectId) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleStepException(org.pentaho.di.core.exception.KettleStepException)

Aggregations

StringObjectId (org.pentaho.di.repository.StringObjectId)123 KettleException (org.pentaho.di.core.exception.KettleException)49 ObjectId (org.pentaho.di.repository.ObjectId)38 Test (org.junit.Test)34 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)25 KettleFileException (org.pentaho.di.core.exception.KettleFileException)21 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)18 MetaStoreNamespaceExistsException (org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException)18 ArrayList (java.util.ArrayList)16 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)15 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)14 RepositoryObject (org.pentaho.di.repository.RepositoryObject)14 TransMeta (org.pentaho.di.trans.TransMeta)14 IdNotFoundException (org.pentaho.di.core.exception.IdNotFoundException)13 KettleSecurityException (org.pentaho.di.core.exception.KettleSecurityException)13 UnifiedRepositoryCreateFileException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryCreateFileException)13 UnifiedRepositoryUpdateFileException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryUpdateFileException)13 Repository (org.pentaho.di.repository.Repository)11 IOException (java.io.IOException)10 FileObject (org.apache.commons.vfs2.FileObject)10