use of com.amalto.workbench.models.TreeObject in project tmdm-studio-se by Talend.
the class DataClusterDialog method getAllDataContainers.
private boolean getAllDataContainers(List<TreeObject> dataContainers) {
MDMServerDef serverDef = getSelectedMdmServerDef();
String username = serverDef.getUser();
String password = serverDef.getPasswd();
String serverName = serverDef.getName();
String endpointaddress = serverDef.getUrl();
boolean canConnect = checkConnection(endpointaddress, username, password);
if (!canConnect) {
MessageDialog.openError(site.getShell(), Messages.DataClusterDialog_7, Messages.DataClusterDialog_8);
return false;
}
List<WSDataClusterPK> xdcPKs = null;
try {
TMDMService service = Util.getMDMService(new URL(endpointaddress), username, password);
TreeParent serverRoot = new TreeParent(serverName, null, TreeObject._SERVER_, endpointaddress, username + ":" + // $NON-NLS-1$//$NON-NLS-2$
(password == null ? "" : password));
// $NON-NLS-1$
xdcPKs = service.getDataClusterPKs(new WSRegexDataClusterPKs("*")).getWsDataClusterPKs();
for (WSDataClusterPK pk : xdcPKs) {
String name = pk.getPk();
if (!("CACHE".equals(name))) {
// $NON-NLS-1$
WSDataCluster wsObject = null;
boolean retriveWSObject = false;
try {
if (retriveWSObject) {
wsObject = service.getDataCluster(new WSGetDataCluster(pk));
}
TreeObject obj = new TreeObject(name, serverRoot, TreeObject.DATA_CLUSTER, pk, wsObject);
dataContainers.add(obj);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
return false;
}
return true;
}
use of com.amalto.workbench.models.TreeObject in project tmdm-studio-se by Talend.
the class DataModelSelectDialog method selectDataModel.
private void selectDataModel() {
Object input = domViewer.getInput();
TreeObject[] elements = (TreeObject[]) contentProvider.getElements(input);
selectDefaultDataModel(elements);
domViewer.addTreeListener(new ITreeViewerListener() {
public void treeExpanded(TreeExpansionEvent event) {
TreeParent parent = (TreeParent) event.getElement();
TreeObject[] children = parent.getChildren();
selectDefaultDataModel(children);
}
public void treeCollapsed(TreeExpansionEvent event) {
//
}
});
}
use of com.amalto.workbench.models.TreeObject in project tmdm-studio-se by Talend.
the class DataModelSelectDialog method changeToResource.
private void changeToResource() {
TreeParent parent = null;
// Modified by hbhong,to fix bug 21784
TreeObject[] children = treeParent.getChildren();
for (TreeObject element : children) {
parent = (TreeParent) element;
if (parent.getType() == TreeObject.DATA_MODEL) {
break;
}
}
// The ending| bug:21784
contentProvider = new ServerTreeContentProvider(site, parent);
setTreeContentProvider(contentProvider);
domViewer.setLabelProvider(new ServerTreeLabelProvider());
domViewer.setSorter(new ViewerSorter() {
@Override
public int category(Object element) {
if (element instanceof TreeParent) {
TreeParent category = (TreeParent) element;
if (category.getType() == TreeObject.CATEGORY_FOLDER) {
return -1;
}
}
return 0;
}
});
domViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent e) {
StructuredSelection sel = (StructuredSelection) e.getSelection();
List<String> xpathList = new ArrayList<String>();
Object[] selections = sel.toArray();
for (Object obj : selections) {
TreeObject treeObj = (TreeObject) obj;
if (treeObj != null && treeObj.getType() == TreeObject.DATA_MODEL) {
xpathList.add(treeObj.getDisplayName());
}
}
xpaths = xpathList.toArray(new String[0]);
if (getButton(IDialogConstants.OK_ID) != null) {
getButton(IDialogConstants.OK_ID).setEnabled(xpathList.size() > 0);
}
}
});
domViewer.setInput(site);
}
use of com.amalto.workbench.models.TreeObject in project tmdm-studio-se by Talend.
the class AddBrowseItemsWizard method createNewTreeObject.
private TreeObject createNewTreeObject(XSDElementDeclaration decl, String browseItem) {
WSView view = new WSView();
view.setIsTransformerActive(new WSBoolean(false));
// $NON-NLS-1$
view.setTransformerPK("");
view.setName(browseItem);
EList<XSDIdentityConstraintDefinition> idtylist = decl.getIdentityConstraintDefinitions();
List<String> keys = new ArrayList<String>();
for (XSDIdentityConstraintDefinition idty : idtylist) {
EList<XSDXPathDefinition> xpathList = idty.getFields();
for (XSDXPathDefinition path : xpathList) {
String key = decl.getName();
// remove
// $NON-NLS-1$//$NON-NLS-2$
key = key.replaceFirst("#.*", "");
// $NON-NLS-1$
key += "/" + path.getValue();
keys.add(key);
}
}
view.getSearchableBusinessElements().addAll(keys);
view.getViewableBusinessElements().addAll(keys);
StringBuffer desc = new StringBuffer();
LinkedHashMap<String, String> labels = new LinkedHashMap<String, String>();
if (decl.getAnnotation() != null) {
labels = new XSDAnnotationsStructure(decl.getAnnotation()).getLabels();
}
if (labels.size() == 0) {
// $NON-NLS-1$
labels.put("EN", decl.getName());
}
for (String lan : labels.keySet()) {
// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
desc.append("[" + lan.toUpperCase() + ":" + labels.get(lan) + "]");
}
view.setDescription(desc.toString());
WSPutView wrap = new WSPutView();
wrap.setWsView(view);
WSViewPK viewPk = new WSViewPK();
viewPk.setPk(browseItem);
WSDeleteView delView = new WSDeleteView();
delView.setWsViewPK(viewPk);
WSGetView getView = new WSGetView();
getView.setWsViewPK(viewPk);
service.putView(wrap);
// add node in the root
TreeParent root = page.getXObject().getServerRoot();
TreeObject obj = new // no storage to save
TreeObject(// no storage to save
browseItem, // no storage to save
root, // no storage to save
TreeObject.VIEW, // no storage to save
viewPk, // no storage to save
null);
return obj;
}
use of com.amalto.workbench.models.TreeObject in project tmdm-studio-se by Talend.
the class AddBrowseItemsWizard method newBrowseItemView.
protected void newBrowseItemView(String browseItem) {
for (XSDElementDeclaration decl : declList) {
String fullName = BROWSE_ITEMS + decl.getName();
if (fullName.equals(browseItem)) {
TreeParent serverRoot = page.getXObject().getServerRoot();
TreeParent serverFolder = serverRoot.findServerFolder(TreeObject.VIEW);
TreeObject obj = serverFolder.findObject(TreeObject.VIEW, browseItem);
if (obj != null) {
IEditorInput xobjectEditorinput = new XObjectEditorInput(obj, obj.getDisplayName());
final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart currentEditor = activePage.findEditor(xobjectEditorinput);
if (currentEditor != null) {
// editor is opened
if (MessageDialog.openConfirm(this.getShell(), Messages.Warning, Messages.AddBrowseItemsWizard_DuplicatedView)) {
refreshEditorContent(obj);
} else {
break;
}
}
}
obj = createNewTreeObject(decl, browseItem);
TreeParent folder = obj.findServerFolder(obj.getType());
folder.addChild(obj);
}
}
}
Aggregations