use of org.pentaho.metaverse.api.model.WebServiceResourceInfo in project pentaho-metaverse by pentaho.
the class HTTPPostExternalResourceConsumer method getResourcesFromRow.
@Override
public Collection<IExternalResourceInfo> getResourcesFromRow(HTTPPOST httpClientInput, RowMetaInterface rowMeta, Object[] row) {
Collection<IExternalResourceInfo> resources = new LinkedList<IExternalResourceInfo>();
// For some reason the step doesn't return the StepMetaInterface directly, so go around it
HTTPPOSTMeta meta = (HTTPPOSTMeta) httpClientInput.getStepMetaInterface();
if (meta == null) {
meta = (HTTPPOSTMeta) httpClientInput.getStepMeta().getStepMetaInterface();
}
if (meta != null) {
try {
String url;
if (meta.isUrlInField()) {
url = rowMeta.getString(row, meta.getUrlField(), null);
} else {
url = meta.getUrl();
}
if (!Const.isEmpty(url)) {
WebServiceResourceInfo resourceInfo = (WebServiceResourceInfo) ExternalResourceInfoFactory.createURLResource(url, true);
if (ArrayUtils.isNotEmpty(meta.getArgumentField())) {
for (int i = 0; i < meta.getArgumentField().length; i++) {
String field = meta.getArgumentField()[i];
String label = meta.getArgumentParameter()[i];
resourceInfo.addHeader(label, rowMeta.getString(row, field, null));
}
}
if (ArrayUtils.isNotEmpty(meta.getQueryField())) {
for (int i = 0; i < meta.getQueryField().length; i++) {
String field = meta.getQueryField()[i];
String label = meta.getQueryParameter()[i];
resourceInfo.addParameter(label, rowMeta.getString(row, field, null));
}
}
resources.add(resourceInfo);
}
} catch (KettleException kve) {
// TODO throw exception or ignore?
}
}
return resources;
}
use of org.pentaho.metaverse.api.model.WebServiceResourceInfo in project pentaho-metaverse by pentaho.
the class RestClientExternalResourceConsumer method getResourcesFromMeta.
@Override
public Collection<IExternalResourceInfo> getResourcesFromMeta(RestMeta meta, IAnalysisContext context) {
List<IExternalResourceInfo> resources = new ArrayList<>();
if (!meta.isUrlInField()) {
String url = meta.getUrl();
WebServiceResourceInfo resourceInfo = createResourceInfo(url, meta);
resources.add(resourceInfo);
}
return resources;
}
use of org.pentaho.metaverse.api.model.WebServiceResourceInfo in project pentaho-metaverse by pentaho.
the class RestClientExternalResourceConsumer method getResourcesFromRow.
@Override
public Collection<IExternalResourceInfo> getResourcesFromRow(Rest step, RowMetaInterface rowMeta, Object[] row) {
Set<IExternalResourceInfo> resources = new HashSet<>();
RestMeta meta = (RestMeta) step.getStepMetaInterface();
if (meta == null) {
meta = (RestMeta) step.getStepMeta().getStepMetaInterface();
}
if (meta != null) {
String url;
String method;
String body;
try {
if (meta.isUrlInField()) {
url = rowMeta.getString(row, meta.getUrlField(), null);
} else {
url = meta.getUrl();
}
if (StringUtils.isNotEmpty(url)) {
WebServiceResourceInfo resourceInfo = createResourceInfo(url, meta);
if (ArrayUtils.isNotEmpty(meta.getHeaderField())) {
for (int i = 0; i < meta.getHeaderField().length; i++) {
String field = meta.getHeaderField()[i];
String label = meta.getHeaderName()[i];
resourceInfo.addHeader(label, rowMeta.getString(row, field, null));
}
}
if (ArrayUtils.isNotEmpty(meta.getParameterField())) {
for (int i = 0; i < meta.getParameterField().length; i++) {
String field = meta.getParameterField()[i];
String label = meta.getParameterName()[i];
resourceInfo.addParameter(label, rowMeta.getString(row, field, null));
}
}
if (meta.isDynamicMethod()) {
method = rowMeta.getString(row, meta.getMethodFieldName(), null);
resourceInfo.setMethod(method);
}
if (StringUtils.isNotEmpty(meta.getBodyField())) {
body = rowMeta.getString(row, meta.getBodyField(), null);
resourceInfo.setBody(body);
}
resources.add(resourceInfo);
}
} catch (KettleValueException e) {
// could not find a url on this row
log.debug(e.getMessage(), e);
}
}
return resources;
}
use of org.pentaho.metaverse.api.model.WebServiceResourceInfo in project pentaho-metaverse by pentaho.
the class RestClientExternalResourceConsumer method createResourceInfo.
private WebServiceResourceInfo createResourceInfo(String url, RestMeta meta) {
WebServiceResourceInfo resourceInfo = (WebServiceResourceInfo) ExternalResourceInfoFactory.createURLResource(url, true);
if (!meta.isDynamicMethod()) {
resourceInfo.setMethod(meta.getMethod());
}
if (StringUtils.isNotEmpty(meta.getBodyField())) {
resourceInfo.setBody(meta.getBodyField());
}
resourceInfo.setApplicationType(meta.getApplicationType());
return resourceInfo;
}
use of org.pentaho.metaverse.api.model.WebServiceResourceInfo in project pentaho-metaverse by pentaho.
the class HTTPClientExternalResourceConsumer method getResourcesFromRow.
@Override
public Collection<IExternalResourceInfo> getResourcesFromRow(HTTP httpClientInput, RowMetaInterface rowMeta, Object[] row) {
Collection<IExternalResourceInfo> resources = new LinkedList<IExternalResourceInfo>();
// For some reason the step doesn't return the StepMetaInterface directly, so go around it
HTTPMeta meta = (HTTPMeta) httpClientInput.getStepMetaInterface();
if (meta == null) {
meta = (HTTPMeta) httpClientInput.getStepMeta().getStepMetaInterface();
}
if (meta != null) {
try {
String url;
if (meta.isUrlInField()) {
url = rowMeta.getString(row, meta.getUrlField(), null);
} else {
url = meta.getUrl();
}
if (!Const.isEmpty(url)) {
WebServiceResourceInfo resourceInfo = (WebServiceResourceInfo) ExternalResourceInfoFactory.createURLResource(url, true);
if (ArrayUtils.isNotEmpty(meta.getHeaderField())) {
for (int i = 0; i < meta.getHeaderField().length; i++) {
String field = meta.getHeaderField()[i];
String label = meta.getHeaderParameter()[i];
resourceInfo.addHeader(label, rowMeta.getString(row, field, null));
}
}
if (ArrayUtils.isNotEmpty(meta.getArgumentField())) {
for (int i = 0; i < meta.getArgumentField().length; i++) {
String field = meta.getArgumentField()[i];
String label = meta.getArgumentParameter()[i];
resourceInfo.addParameter(label, rowMeta.getString(row, field, null));
}
}
resources.add(resourceInfo);
}
} catch (KettleException kve) {
// TODO throw exception or ignore?
}
}
return resources;
}
Aggregations