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);
}
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());
}
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);
}
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);
}
}
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">
* <purObjectRevisions>
* <revision>
* <versionId>1.0</versionId>
* <creationDate>2014-07-22T14:42:46.029-04:00</creationDate>
* <login>admin</login>
* <comment>JMeter test</comment>
* </revision>
* </purObjectRevisions>
* </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();
}
}
Aggregations