Search in sources :

Example 96 with StringObjectId

use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.

the class MQTTConsumerMetaTest method testSavesToRepository.

@Test
public void testSavesToRepository() throws Exception {
    StringObjectId stepId = new StringObjectId("step1");
    StringObjectId transId = new StringObjectId("trans1");
    ArrayList<String> topicList = new ArrayList<>();
    topicList.add("temperature");
    MQTTConsumerMeta localMeta = getTestMeta2(topicList);
    localMeta.saveRep(rep, metastore, transId, stepId);
    verify(rep).saveStepAttribute(transId, stepId, "step-xml", localMeta.getXML());
    verifyNoMoreInteractions(rep);
}
Also used : ArrayList(java.util.ArrayList) StringObjectId(org.pentaho.di.repository.StringObjectId) Test(org.junit.Test)

Example 97 with StringObjectId

use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.

the class MQTTProducerMetaTest method testReadFromRepository.

@Test
public void testReadFromRepository() throws Exception {
    MQTTProducerMeta testMeta = testMeta();
    testMeta.setAutomaticReconnect("true");
    testMeta.setServerUris("mqttHost2:1883");
    testMeta.setMqttServer("mqttserver:1883");
    StringObjectId stepId = new StringObjectId("stepId");
    String xml = testMeta.getXML();
    when(rep.getStepAttributeString(stepId, "step-xml")).thenReturn(xml);
    MQTTProducerMeta meta = new MQTTProducerMeta();
    meta.readRep(rep, metaStore, stepId, emptyList());
    meta.readRep(rep, metaStore, stepId, Collections.emptyList());
    assertEquals("mqttserver:1883", meta.getMqttServer());
    assertEquals("client1", meta.getClientId());
    assertEquals("test-topic", meta.getTopic());
    assertEquals("1", meta.getQOS());
    assertEquals("tempvalue", meta.getMessageField());
    assertEquals("testuser", meta.getUsername());
    assertEquals("test", meta.getPassword());
    assertEquals("1000", meta.getKeepAliveInterval());
    assertEquals("2000", meta.getMaxInflight());
    assertEquals("3000", meta.getConnectionTimeout());
    assertEquals("true", meta.getCleanSession());
    assertEquals("/Users/noname/temp", meta.getStorageLevel());
    assertEquals("mqttHost2:1883", meta.getServerUris());
    assertEquals("3", meta.getMqttVersion());
    assertEquals("true", meta.getAutomaticReconnect());
}
Also used : StringObjectId(org.pentaho.di.repository.StringObjectId) Test(org.junit.Test)

Example 98 with StringObjectId

use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.

the class PurRepository_GetObjectInformation_IT method getObjectInformation_InvalidRepositoryId_NullIsHandled.

@Test
public void getObjectInformation_InvalidRepositoryId_NullIsHandled() throws Exception {
    IUnifiedRepository unifiedRepository = mock(IUnifiedRepository.class);
    when(unifiedRepository.getFileById(any(Serializable.class))).thenReturn(null);
    purRepository.setTest(unifiedRepository);
    RepositoryObject information = purRepository.getObjectInformation(new StringObjectId("invalid id"), RepositoryObjectType.JOB);
    assertNull("Should return null if file was not found", information);
}
Also used : Serializable(java.io.Serializable) RepositoryObject(org.pentaho.di.repository.RepositoryObject) StringObjectId(org.pentaho.di.repository.StringObjectId) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Test(org.junit.Test)

Example 99 with StringObjectId

use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.

the class MetaInjectMeta method readRep.

@Override
public void readRep(Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases) throws KettleException {
    try {
        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);
        sourceStepName = rep.getStepAttributeString(id_step, SOURCE_STEP);
        streamSourceStepname = rep.getStepAttributeString(id_step, STREAM_SOURCE_STEP);
        streamTargetStepname = rep.getStepAttributeString(id_step, STREAM_TARGET_STEP);
        sourceOutputFields = new ArrayList<MetaInjectOutputField>();
        int nrSourceOutputFields = rep.countNrStepAttributes(id_step, SOURCE_OUTPUT_FIELD_NAME);
        for (int i = 0; i < nrSourceOutputFields; i++) {
            String name = rep.getStepAttributeString(id_step, i, SOURCE_OUTPUT_FIELD_NAME);
            String typeName = rep.getStepAttributeString(id_step, i, SOURCE_OUTPUT_FIELD_TYPE);
            int length = (int) rep.getStepAttributeInteger(id_step, i, SOURCE_OUTPUT_FIELD_LENGTH);
            int precision = (int) rep.getStepAttributeInteger(id_step, i, SOURCE_OUTPUT_FIELD_PRECISION);
            int type = ValueMetaFactory.getIdForValueMeta(typeName);
            sourceOutputFields.add(new MetaInjectOutputField(name, type, length, precision));
        }
        targetFile = rep.getStepAttributeString(id_step, TARGET_FILE);
        noExecution = rep.getStepAttributeBoolean(id_step, NO_EXECUTION);
        int nrMappings = rep.countNrStepAttributes(id_step, MAPPING_TARGET_STEP_NAME);
        for (int i = 0; i < nrMappings; i++) {
            String targetStepname = rep.getStepAttributeString(id_step, i, MAPPING_TARGET_STEP_NAME);
            String targetAttributeKey = rep.getStepAttributeString(id_step, i, MAPPING_TARGET_ATTRIBUTE_KEY);
            boolean targetDetail = rep.getStepAttributeBoolean(id_step, i, MAPPING_TARGET_DETAIL);
            String sourceStepname = rep.getStepAttributeString(id_step, i, MAPPING_SOURCE_STEP);
            String sourceField = rep.getStepAttributeString(id_step, i, MAPPING_SOURCE_FIELD);
            TargetStepAttribute target = new TargetStepAttribute(targetStepname, targetAttributeKey, targetDetail);
            SourceStepField source = new SourceStepField(sourceStepname, sourceField);
            targetSourceMapping.put(target, source);
        }
        MetaInjectMigration.migrateFrom70(targetSourceMapping);
    } catch (Exception e) {
        throw new KettleException("Unexpected error reading step information from the repository", e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) 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 100 with StringObjectId

use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.

the class RevisionResource method doGetVersions.

/**
 * Retrieves the version history of a selected repository file
 *
 * <p>
 * <b>Example Request:</b><br>
 * GET /pur-repository-plugin/api/revision/path:to:file/revisions
 * </p>
 *
 * @param pathId
 *          (colon separated path for the repository file)
 *
 *          <pre function="syntax.xml">
 *    :path:to:file:id
 * </pre>
 * @return file revisions objects <code> purObjectRevisions </code>
 *
 *         <pre function="syntax.xml">
 * &lt;purObjectRevisions&gt;
 * &lt;revision&gt;
 * &lt;versionId&gt;1.0&lt;/versionId&gt;
 * &lt;creationDate&gt;2014-07-22T14:42:46.029-04:00&lt;/creationDate&gt;
 * &lt;login&gt;admin&lt;/login&gt;
 * &lt;comment&gt;JMeter test&lt;/comment&gt;
 * &lt;/revision&gt;
 * &lt;/purObjectRevisions&gt;
 * </pre>
 */
@GET
@Path("{pathId : .+}/revisions")
@StatusCodes({ @ResponseCode(code = 200, condition = "Successfully returns list of revisions"), @ResponseCode(code = 500, condition = "Something failed when attempting to retrieve revisions"), @ResponseCode(code = 404, condition = "Invalid path") })
@Produces({ APPLICATION_XML, APPLICATION_JSON })
public Response doGetVersions(@PathParam("pathId") String pathId) {
    Serializable fileId = null;
    List<ObjectRevision> originalRevisions = null;
    RepositoryFile repositoryFile = repository.getFile(FileUtils.idToPath(pathId));
    if (repositoryFile != null) {
        fileId = repositoryFile.getId();
    }
    if (fileId != null) {
        try {
            originalRevisions = revisionService.getRevisions(new StringObjectId(fileId.toString()));
        } catch (KettleException e) {
            return Response.serverError().build();
        }
        List<PurObjectRevision> revisions = new ArrayList();
        for (ObjectRevision revision : originalRevisions) {
            revisions.add((PurObjectRevision) revision);
        }
        GenericEntity<List<PurObjectRevision>> genericRevisionsEntity = new GenericEntity<List<PurObjectRevision>>(revisions) {
        };
        return Response.ok(genericRevisionsEntity).build();
    } else {
        return Response.serverError().build();
    }
}
Also used : ObjectRevision(org.pentaho.di.repository.ObjectRevision) PurObjectRevision(org.pentaho.di.repository.pur.PurObjectRevision) KettleException(org.pentaho.di.core.exception.KettleException) Serializable(java.io.Serializable) GenericEntity(javax.ws.rs.core.GenericEntity) PurObjectRevision(org.pentaho.di.repository.pur.PurObjectRevision) ArrayList(java.util.ArrayList) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) ArrayList(java.util.ArrayList) List(java.util.List) StringObjectId(org.pentaho.di.repository.StringObjectId) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) StatusCodes(org.codehaus.enunciate.jaxrs.StatusCodes)

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