use of org.apache.hop.ui.hopgui.perspective.metadata.MetadataPerspective in project hop by apache.
the class DataProbeGuiPlugin method addDataProbeForTransform.
@GuiContextAction(id = "pipeline-graph-transform-9000-add-probe", parentId = HopGuiPipelineTransformContext.CONTEXT_ID, type = GuiActionType.Info, name = "Add data probe", tooltip = "Streams the rows to a pipeline defined in a selected pipeline probe", image = "probe.svg", category = "Preview", categoryOrder = "3")
public void addDataProbeForTransform(HopGuiPipelineTransformContext context) {
PipelineMeta pipelineMeta = context.getPipelineMeta();
TransformMeta transformMeta = context.getTransformMeta();
HopGui hopGui = HopGui.getInstance();
try {
// Present the user with a list of pipeline probes...
//
IHopMetadataProvider metadataProvider = hopGui.getMetadataProvider();
IHopMetadataSerializer<PipelineProbe> serializer = metadataProvider.getSerializer(PipelineProbe.class);
MetadataManager<PipelineProbe> manager = new MetadataManager<>(hopGui.getVariables(), metadataProvider, PipelineProbe.class);
PipelineProbe pipelineProbe = null;
List<String> pipelineProbeNames = serializer.listObjectNames();
if (pipelineProbeNames.isEmpty()) {
MessageBox box = new MessageBox(hopGui.getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION);
box.setText("No probes available");
box.setMessage("There are no pipeline probe objects defined yet. Do you want to create one?");
int answer = box.open();
if ((answer & SWT.YES) != 0) {
// Create a new pipeline probe...
//
pipelineProbe = new PipelineProbe();
addLocation(hopGui.getVariables(), pipelineProbe, pipelineMeta, transformMeta);
manager.newMetadata(pipelineProbe);
return;
} else {
return;
}
} else {
EnterSelectionDialog dialog = new EnterSelectionDialog(hopGui.getShell(), pipelineProbeNames.toArray(new String[0]), "Select pipeline probe", "Select the pipeline probe to add this pipeline transform to");
String pipelineProbeName = dialog.open();
if (pipelineProbeName != null) {
pipelineProbe = serializer.load(pipelineProbeName);
}
}
if (pipelineProbe != null) {
// See if it's open in the metadata perspective...
//
MetadataPerspective perspective = (MetadataPerspective) hopGui.getPerspectiveManager().findPerspective(MetadataPerspective.class);
String key = PipelineProbe.class.getAnnotation(HopMetadata.class).key();
PipelineProbeEditor editor = (PipelineProbeEditor) perspective.findEditor(key, pipelineProbe.getName());
if (editor != null) {
// We're going to change the current metadata and flag it as changed...
//
pipelineProbe = new PipelineProbe();
editor.getWidgetsContent(pipelineProbe);
// Add the location
//
addLocation(hopGui.getVariables(), pipelineProbe, pipelineMeta, transformMeta);
// Replace and refresh the dialog
//
editor.setMetadata(pipelineProbe);
editor.setWidgetsContent();
// Set changed...
//
editor.setChanged();
// Switch to the editor...
//
perspective.activate();
perspective.setActiveEditor(editor);
return;
} else {
// Not opened in the perspective, simply add the data probe location...
//
addLocation(hopGui.getVariables(), pipelineProbe, pipelineMeta, transformMeta);
// ... and save the pipeline probe
//
serializer.save(pipelineProbe);
}
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), "Error", "Error adding pipeline probe to transform '" + transformMeta.getName() + "'", e);
}
}
use of org.apache.hop.ui.hopgui.perspective.metadata.MetadataPerspective in project hop by apache.
the class MetadataManager method editWithEditor.
public void editWithEditor(String name) {
if (name == null) {
return;
}
HopGui hopGui = HopGui.getInstance();
try {
HopMetadata annotation = HopMetadataUtil.getHopMetadataAnnotation(managedClass);
MetadataPerspective perspective = MetadataPerspective.getInstance();
MetadataEditor<?> editor = perspective.findEditor(annotation.key(), name);
if (editor == null) {
// Load the metadata element from the metadata
//
IHopMetadataSerializer<T> serializer = metadataProvider.getSerializer(managedClass);
T element = serializer.load(name);
if (element == null) {
//
throw new HopException("Unable to find element '" + name + "' in the metadata");
}
initializeElementVariables(element);
perspective.addEditor(createEditor(element));
} else {
perspective.setActiveEditor(editor);
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), "Error", "Error editing metadata", e);
}
}
use of org.apache.hop.ui.hopgui.perspective.metadata.MetadataPerspective in project hop by apache.
the class WebServiceGuiPlugin method addWebServiceForTransform.
@GuiContextAction(id = "pipeline-graph-transform-9000-add-web-serviec", parentId = HopGuiPipelineTransformContext.CONTEXT_ID, type = GuiActionType.Info, name = "Add web service", tooltip = "Use the output of this transform as a web service with Hop Server", image = "ui/images/webservice.svg", category = "Data routing", categoryOrder = "2")
public void addWebServiceForTransform(HopGuiPipelineTransformContext context) {
PipelineMeta pipelineMeta = context.getPipelineMeta();
TransformMeta transformMeta = context.getTransformMeta();
IVariables variables = context.getPipelineGraph().getVariables();
HopGui hopGui = HopGui.getInstance();
try {
// Ask which field should be used...
//
IRowMeta fields = pipelineMeta.getTransformFields(variables, transformMeta);
EnterSelectionDialog fieldSelectionDialog = new EnterSelectionDialog(hopGui.getShell(), fields.getFieldNames(), "Select the output field", "Please select the field to output when the service is called");
String fieldName = fieldSelectionDialog.open();
if (fieldName == null) {
return;
}
// Present the user with a list of pipeline probes...
//
IHopMetadataProvider metadataProvider = hopGui.getMetadataProvider();
IHopMetadataSerializer<WebService> serializer = metadataProvider.getSerializer(WebService.class);
MetadataManager<WebService> manager = new MetadataManager<>(hopGui.getVariables(), metadataProvider, WebService.class);
WebService webService = null;
List<String> serviceNames = serializer.listObjectNames();
if (serviceNames.isEmpty()) {
MessageBox box = new MessageBox(hopGui.getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION);
box.setText("No web services available");
box.setMessage("There are no web service objects defined yet. Do you want to create one?");
int answer = box.open();
if ((answer & SWT.YES) != 0) {
// Create a new web service...
//
webService = new WebService(pipelineMeta.getName(), true, pipelineMeta.getFilename(), transformMeta.getName(), fieldName, "text/plain", false);
manager.newMetadata(webService);
return;
} else {
return;
}
} else {
EnterSelectionDialog dialog = new EnterSelectionDialog(hopGui.getShell(), serviceNames.toArray(new String[0]), "Select a web service", "Select the web service to update");
String pipelineProbeName = dialog.open();
if (pipelineProbeName != null) {
webService = serializer.load(pipelineProbeName);
}
}
if (webService != null) {
// See if it's open in the metadata perspective...
//
MetadataPerspective perspective = (MetadataPerspective) hopGui.getPerspectiveManager().findPerspective(MetadataPerspective.class);
String key = WebService.class.getAnnotation(HopMetadata.class).key();
WebServiceEditor editor = (WebServiceEditor) perspective.findEditor(key, webService.getName());
if (editor != null) {
// We're going to change the current metadata and flag it as changed...
//
webService = new WebService();
editor.getWidgetsContent(webService);
// Update the web service details
//
webService.setFilename(pipelineMeta.getFilename());
webService.setTransformName(transformMeta.getName());
webService.setFieldName(fieldName);
// Replace and refresh the dialog
//
editor.setMetadata(webService);
editor.setWidgetsContent();
// Set changed...
//
editor.setChanged();
// Switch to the editor...
//
perspective.activate();
perspective.setActiveEditor(editor);
return;
} else {
// Not opened in the perspective, simply set the web service details
//
webService.setFilename(pipelineMeta.getFilename());
webService.setTransformName(transformMeta.getName());
webService.setFieldName(fieldName);
// ... and save the pipeline probe
//
serializer.save(webService);
}
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), "Error", "Error adding web service for transform '" + transformMeta.getName() + "'", e);
}
}
use of org.apache.hop.ui.hopgui.perspective.metadata.MetadataPerspective in project hop by apache.
the class HopGuiAuditDelegate method openMetadataObject.
private void openMetadataObject(String className, String name) throws HopException {
try {
IHopMetadataProvider metadataProvider = hopGui.getMetadataProvider();
MetadataPerspective perspective = MetadataPerspective.getInstance();
// Find the class...
List<Class<IHopMetadata>> metadataClasses = metadataProvider.getMetadataClasses();
for (Class<IHopMetadata> metadataClass : metadataClasses) {
if (metadataClass.getName().equals(className)) {
// Get the serializer and open it up
//
IHopMetadataSerializer<IHopMetadata> serializer = metadataProvider.getSerializer(metadataClass);
//
if (serializer.exists(name)) {
IHopMetadata metadata = serializer.load(name);
MetadataManager<IHopMetadata> metadataManager = new MetadataManager<>(HopGui.getInstance().getVariables(), metadataProvider, metadataClass);
MetadataEditor<IHopMetadata> editor = metadataManager.createEditor(metadata);
// We assume that all tab items are closed so we can just open up a new editor for the
// metadata
//
perspective.addEditor(editor);
}
}
}
} catch (Exception e) {
throw new HopException("Error opening metadata object '" + name + "' of class " + className, e);
}
}
use of org.apache.hop.ui.hopgui.perspective.metadata.MetadataPerspective in project hop by apache.
the class MetadataFileTypeHandler method findTabItemHandler.
private TabItemHandler findTabItemHandler() {
if (metadata == null) {
return null;
}
MetadataPerspective perspective = MetadataPerspective.getInstance();
for (TabItemHandler tabItemHandler : perspective.getItems()) {
CTabItem tabItem = tabItemHandler.getTabItem();
MetadataEditor editor = (MetadataEditor) tabItem.getData();
IHopMetadata other = editor.getMetadata();
if (other.equals(metadata)) {
return tabItemHandler;
}
}
return null;
}
Aggregations