use of com.amalto.workbench.models.TreeObject in project tmdm-studio-se by Talend.
the class StoredProcedureMainPage method createCharacteristicsContent.
@Override
protected void createCharacteristicsContent(FormToolkit toolkit, Composite charComposite) {
try {
WSStoredProcedure wsStoredProcedure = (WSStoredProcedure) (getXObject().getWsObject());
// description
Label descriptionLabel = toolkit.createLabel(charComposite, Messages.StoredProcedureMainPage_4, SWT.NULL);
descriptionLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 1, 1));
// $NON-NLS-1$
descriptionText = toolkit.createText(charComposite, "", SWT.BORDER);
descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
// $NON-NLS-1$
descriptionText.setText(wsStoredProcedure.getDescription() == null ? "" : wsStoredProcedure.getDescription());
descriptionText.addModifyListener(this);
// Procedure
Group storedProcedureGroup = new Group(charComposite, SWT.SHADOW_NONE);
storedProcedureGroup.setText(Messages.StoredProcedureMainPage_5);
storedProcedureGroup.setLayout(new GridLayout(1, true));
storedProcedureGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
((GridData) storedProcedureGroup.getLayoutData()).minimumHeight = 100;
procedureViewer = new SourceViewer(storedProcedureGroup, new VerticalRuler(10), SWT.V_SCROLL);
procedureViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
procedureViewer.addTextListener(this);
WidgetUtils.initRedoUndo(procedureViewer);
refreshCacheBtn = toolkit.createButton(charComposite, Messages.StoredProcedureMainPage_6, SWT.CHECK);
refreshCacheBtn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
refreshCacheBtn.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
markDirty();
}
public void widgetDefaultSelected(SelectionEvent e) {
markDirty();
}
});
/**
**********************************************************
* Execute Stored Procedure
***********************************************************
*/
createCompDropTarget();
Composite resultsGroup = this.getNewSectionComposite(Messages.StoredProcedureMainPage_7);
resultsGroup.setLayout(new GridLayout(4, false));
// data cluster
Hyperlink dataClusterLink = toolkit.createHyperlink(resultsGroup, Messages.StoredProcedureMainPage_8, SWT.NULL);
dataClusterLink.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
dataClusterLink.addHyperlinkListener(new IHyperlinkListener() {
public void linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent e) {
}
public void linkExited(org.eclipse.ui.forms.events.HyperlinkEvent e) {
}
public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent e) {
if (!isLocalInput()) {
TreeParent serverRoot = StoredProcedureMainPage.this.getXObject().getServerRoot();
TreeObject iaObject = new TreeObject(StoredProcedureMainPage.this.dataClusterCombo.getText(), serverRoot, TreeObject.DATA_CLUSTER, new WSDataClusterPK(StoredProcedureMainPage.this.dataClusterCombo.getText()), null);
(new EditXObjectAction(iaObject, StoredProcedureMainPage.this.getSite().getPage())).run();
}
}
});
dataClusterCombo = new Combo(resultsGroup, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.SINGLE);
dataClusterCombo.setLayoutData(new GridData(SWT.BEGINNING, SWT.NONE, false, false, 1, 1));
Button executeButton = new Button(resultsGroup, SWT.PUSH);
executeButton.setText(Messages.StoredProcedureMainPage_9);
executeButton.addMouseListener(new MouseListener() {
public void mouseUp(MouseEvent e) {
executeProcedure();
}
public void mouseDoubleClick(MouseEvent e) {
}
public void mouseDown(MouseEvent e) {
}
});
resultsLabel = toolkit.createLabel(resultsGroup, // $NON-NLS-1$
" ", SWT.NULL);
resultsLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false, 1, 1));
resultsViewer = new TableViewer(resultsGroup);
resultsViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
((GridData) resultsViewer.getControl().getLayoutData()).heightHint = 300;
resultsViewer.setContentProvider(new ArrayContentProvider());
resultsViewer.setLabelProvider(new XMLTableLabelProvider());
resultsViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
resultsViewer.setSelection(event.getSelection());
new ResultsViewAction(StoredProcedureMainPage.this.getSite().getShell(), resultsViewer).run();
}
});
hookContextMenu();
refreshData();
dataClusterCombo.select(0);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
use of com.amalto.workbench.models.TreeObject in project tmdm-studio-se by Talend.
the class XObjectBrowser method addPages.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.forms.editor.FormEditor#addPages()
*/
@Override
protected void addPages() {
try {
updateTitle();
TreeObject xobject = (TreeObject) ((XObjectBrowserInput) this.getEditorInput()).getModel();
if (!xobject.isXObject()) {
return;
}
// register model listener in order to close the browser when object is removed
xobject.addListener(this);
// available models
java.util.List<IAvailableModel> availablemodels = AvailableModelUtil.getAvailableModels(isLocalInput());
;
for (IAvailableModel model : availablemodels) {
model.addPage(xobject, this);
}
addPageForXObject(xobject);
} catch (PartInitException e) {
MessageDialog.openError(this.getSite().getShell(), Messages._Error, Messages.bind(Messages.XObjectBrowser_ErrorMsg, e.getLocalizedMessage()));
}
}
use of com.amalto.workbench.models.TreeObject in project tmdm-studio-se by Talend.
the class XObjectBrowser method dispose.
@Override
public void dispose() {
// save space
TreeObject xobject = (TreeObject) ((XObjectBrowserInput) this.getEditorInput()).getModel();
if (xobject != null) {
xobject.setWsObject(null);
// xobject.removeListener(this);
}
formPages.clear();
super.dispose();
}
use of com.amalto.workbench.models.TreeObject in project tmdm-studio-se by Talend.
the class ExportItemsWizard method exportCluster.
protected TreeObject exportCluster(List<TreeObject> exports, WSDataClusterPK pk, TMDMService service) {
String encodedID = null;
try {
List<String> items1 = new ArrayList<String>();
List<WSItemPKsByCriteriaResponseResults> results = service.getItemPKsByCriteria(new WSGetItemPKsByCriteria(null, encodedID, (long) -1, encodedID, encodedID, Integer.MAX_VALUE, 0, (long) -1, pk)).getResults();
if (results == null) {
return null;
}
for (WSItemPKsByCriteriaResponseResults item : results) {
if (item.getWsItemPK().getIds() == null) {
continue;
}
WSItem wsitem = service.getItem(new WSGetItem(item.getWsItemPK()));
// Marshal
StringWriter sw1 = new StringWriter();
Marshaller.marshal(wsitem, sw1);
// $NON-NLS-1$
String uniqueId = pk.getPk() + "." + wsitem.getConceptName();
for (String id : wsitem.getIds()) {
// $NON-NLS-1$
uniqueId = uniqueId + "." + id;
}
// $NON-NLS-1$
encodedID = URLEncoder.encode(uniqueId, "UTF-8");
// $NON-NLS-1$//$NON-NLS-2$
writeString(sw1.toString(), TreeObject.DATACONTAINER_COTENTS + "/" + pk.getPk() + "/" + encodedID);
// $NON-NLS-1$//$NON-NLS-2$
items1.add(TreeObject.DATACONTAINER_COTENTS + "/" + pk.getPk() + "/" + encodedID);
}
TreeObject obj1 = new TreeObject(pk.getPk(), null, TreeObject.DATA_CLUSTER_CONTENTS, null, null);
obj1.setItems(items1.toArray(new String[items1.size()]));
exports.add(obj1);
return obj1;
} catch (Exception e) {
}
return null;
}
use of com.amalto.workbench.models.TreeObject in project tmdm-studio-se by Talend.
the class ExportItemsWizard method doexport.
public void doexport(Object[] selectedObjs, IProgressMonitor monitor) {
TreeObject[] objs = null;
if (selectedObjs.length > 0 && selectedObjs[0] instanceof TreeObject) {
objs = Arrays.asList(selectedObjs).toArray(new TreeObject[0]);
}
if (objs == null || objs.length == 0) {
return;
}
monitor.beginTask(Messages.ExportItemsWizard_Export, IProgressMonitor.UNKNOWN);
Exports eps = new Exports();
List<TreeObject> exports = new ArrayList<TreeObject>();
TMDMService service;
try {
service = Util.getMDMService(objs[0]);
try {
LocalTreeObjectRepository.getInstance().parseElementForOutput(objs);
} catch (Exception e) {
}
for (TreeObject obj : objs) {
StringWriter sw;
ArrayList<String> items;
String encodedID = null;
switch(obj.getType()) {
case TreeObject.DATA_CLUSTER:
monitor.subTask(Messages.ExportItemsWizard_2);
items = new ArrayList<String>();
// dataclusters
WSDataClusterPK pk = (WSDataClusterPK) obj.getWsKey();
try {
WSDataCluster cluster = service.getDataCluster(new WSGetDataCluster(pk));
// Marshal
sw = new StringWriter();
Marshaller.marshal(cluster, sw);
// $NON-NLS-1$
encodedID = URLEncoder.encode(cluster.getName(), "UTF-8");
// $NON-NLS-1$
writeString(sw.toString(), TreeObject.DATACONTAINER + "/" + encodedID);
// $NON-NLS-1$
items.add(TreeObject.DATACONTAINER + "/" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
} catch (Exception e) {
}
monitor.worked(1);
// datacluster contents
monitor.subTask(Messages.bind(Messages.ExportItemsWizard_3, pk.getPk()));
exportCluster(exports, pk, service);
monitor.worked(1);
break;
case TreeObject.DATA_MODEL:
monitor.subTask(Messages.ExportItemsWizard_5);
items = new ArrayList<String>();
// datamodels
try {
WSDataModel model = service.getDataModel(new WSGetDataModel((WSDataModelPK) obj.getWsKey()));
sw = new StringWriter();
Marshaller.marshal(model, sw);
// $NON-NLS-1$
encodedID = URLEncoder.encode(model.getName(), "UTF-8");
// $NON-NLS-1$
writeString(sw.toString(), TreeObject.DATAMODEL_ + "/" + encodedID);
// $NON-NLS-1$
items.add(TreeObject.DATAMODEL_ + "/" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
} catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.MENU:
monitor.subTask(Messages.ExportItemsWizard_6);
// ExportItem exportItem=new ExportItem();
items = new ArrayList<String>();
// menu
try {
WSMenu menu = service.getMenu(new WSGetMenu((WSMenuPK) obj.getWsKey()));
// Marshal
sw = new StringWriter();
Marshaller.marshal(menu, sw);
// $NON-NLS-1$
encodedID = URLEncoder.encode(menu.getName(), "UTF-8");
// $NON-NLS-1$
writeString(sw.toString(), TreeObject.MENU_ + "/" + encodedID);
// $NON-NLS-1$
items.add(TreeObject.MENU_ + "/" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
} catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.PICTURES_RESOURCE:
monitor.subTask(Messages.ExportItemsWizard_7);
// ExportItem exportItem=new ExportItem();
items = new ArrayList<String>();
// picture
try {
String endpointIpAddress = obj.getEndpointIpAddress();
// $NON-NLS-1$
int index = endpointIpAddress.indexOf("/services/soap");
if (index != -1) {
endpointIpAddress = endpointIpAddress.substring(0, index);
}
String picUrl = endpointIpAddress + ResourcesUtil.getResourcesMapFromURI(endpointIpAddress + TreeObject.PICTURES_URI, objs[0]).get(obj.getDisplayName());
// Marshal
sw = new StringWriter();
byte[] content = HttpClientUtil.getByteArrayContentByHttpget(picUrl);
Marshaller.marshal(content, sw);
// $NON-NLS-1$
encodedID = URLEncoder.encode(obj.getDisplayName(), "UTF-8");
// $NON-NLS-1$
writeInputStream(new ByteArrayInputStream(content), TreeObject.PICTURES_ + "/" + encodedID);
// $NON-NLS-1$
items.add(TreeObject.PICTURES_ + "/" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
monitor.worked(1);
break;
case TreeObject.ROUTING_RULE:
monitor.subTask(Messages.ExportItemsWizard_10);
// ExportItem exportItem=new ExportItem();
items = new ArrayList<String>();
// routing rule
try {
WSRoutingRule RoutingRule = service.getRoutingRule(new WSGetRoutingRule((WSRoutingRulePK) obj.getWsKey()));
// Marshal
sw = new StringWriter();
Marshaller.marshal(RoutingRule, sw);
// $NON-NLS-1$
encodedID = URLEncoder.encode(RoutingRule.getName(), "UTF-8");
// $NON-NLS-1$
writeString(sw.toString(), TreeObject.ROUTINGRULE_ + "/" + encodedID);
// $NON-NLS-1$
items.add(TreeObject.ROUTINGRULE_ + "/" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
} catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.STORED_PROCEDURE:
monitor.subTask(Messages.ExportItemsWizard_11);
items = new ArrayList<String>();
// stored procedure
try {
WSStoredProcedure StoredProcedure = service.getStoredProcedure(new WSGetStoredProcedure((WSStoredProcedurePK) obj.getWsKey()));
// Marshal
sw = new StringWriter();
Marshaller.marshal(StoredProcedure, sw);
// $NON-NLS-1$
encodedID = URLEncoder.encode(StoredProcedure.getName(), "UTF-8");
// $NON-NLS-1$
writeString(sw.toString(), TreeObject.STOREDPROCEDURE_ + "/" + encodedID);
// $NON-NLS-1$
items.add(TreeObject.STOREDPROCEDURE_ + "/" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
} catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.TRANSFORMER:
monitor.subTask(Messages.ExportItemsWizard_13);
items = new ArrayList<String>();
// TODO:check the pk
try {
WSTransformerV2 transformer = service.getTransformerV2(new WSGetTransformerV2(new WSTransformerV2PK(((WSTransformerV2PK) obj.getWsKey()).getPk())));
// Marshal
sw = new StringWriter();
Marshaller.marshal(transformer, sw);
// $NON-NLS-1$
encodedID = URLEncoder.encode(transformer.getName(), "UTF-8");
// $NON-NLS-1$
writeString(sw.toString(), TreeObject.TRANSFORMER_ + "/" + encodedID);
// $NON-NLS-1$
items.add(TreeObject.TRANSFORMER_ + "/" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
} catch (Exception e) {
}
monitor.worked(1);
break;
case TreeObject.VIEW:
monitor.subTask(Messages.ExportItemsWizard_15);
items = new ArrayList<String>();
// view
try {
WSView View = service.getView(new WSGetView((WSViewPK) obj.getWsKey()));
// Marshal
sw = new StringWriter();
Marshaller.marshal(View, sw);
// $NON-NLS-1$
encodedID = URLEncoder.encode(View.getName(), "UTF-8");
// $NON-NLS-1$
writeString(sw.toString(), TreeObject.VIEW_ + "/" + encodedID);
// $NON-NLS-1$
items.add(TreeObject.VIEW_ + "/" + encodedID);
obj.setItems(items.toArray(new String[items.size()]));
exports.add(obj);
} catch (Exception e) {
}
monitor.worked(1);
break;
default:
IExportItemsWizardAdapter exAdapter = ExAdapterManager.getAdapter(this, IExportItemsWizardAdapter.class);
if (exAdapter != null) {
exAdapter.doexport(service, obj.getType(), exports, obj, monitor);
}
break;
}
}
// store the content xml
eps.setItems(exports.toArray(new TreeObject[exports.size()]));
eps.setSchemas(LocalTreeObjectRepository.getInstance().outPutSchemas());
// export autoincrement
try {
WSAutoIncrement auto = service.getAutoIncrement(null);
if (auto != null && auto.getAutoincrement() != null) {
eps.setAutoIncrement(auto.getAutoincrement());
}
} catch (Exception e) {
}
StringWriter sw = new StringWriter();
try {
Marshaller.marshal(eps, sw);
// $NON-NLS-1$
writeString(sw.toString(), "exportitems.xml");
} catch (Exception e) {
}
monitor.done();
} catch (Exception e) {
}
}
Aggregations