Search in sources :

Example 36 with TreeObject

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;
}
Also used : TreeParent(com.amalto.workbench.models.TreeParent) URL(java.net.URL) XtentisException(com.amalto.workbench.utils.XtentisException) MalformedURLException(java.net.MalformedURLException) WebServiceException(javax.xml.ws.WebServiceException) WSDataCluster(com.amalto.workbench.webservices.WSDataCluster) WSGetDataCluster(com.amalto.workbench.webservices.WSGetDataCluster) WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) TMDMService(com.amalto.workbench.webservices.TMDMService) TreeObject(com.amalto.workbench.models.TreeObject) MDMServerDef(com.amalto.workbench.utils.MDMServerDef) WSRegexDataClusterPKs(com.amalto.workbench.webservices.WSRegexDataClusterPKs)

Example 37 with TreeObject

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) {
        // 
        }
    });
}
Also used : TreeParent(com.amalto.workbench.models.TreeParent) ITreeViewerListener(org.eclipse.jface.viewers.ITreeViewerListener) TreeObject(com.amalto.workbench.models.TreeObject) TreeObject(com.amalto.workbench.models.TreeObject) TreeExpansionEvent(org.eclipse.jface.viewers.TreeExpansionEvent)

Example 38 with TreeObject

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);
}
Also used : TreeParent(com.amalto.workbench.models.TreeParent) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ViewerSorter(org.eclipse.jface.viewers.ViewerSorter) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ServerTreeContentProvider(com.amalto.workbench.providers.ServerTreeContentProvider) TreeObject(com.amalto.workbench.models.TreeObject) TreeObject(com.amalto.workbench.models.TreeObject) ArrayList(java.util.ArrayList) List(java.util.List) ServerTreeLabelProvider(com.amalto.workbench.providers.ServerTreeLabelProvider)

Example 39 with TreeObject

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;
}
Also used : XSDAnnotationsStructure(com.amalto.workbench.utils.XSDAnnotationsStructure) TreeParent(com.amalto.workbench.models.TreeParent) ArrayList(java.util.ArrayList) WSDeleteView(com.amalto.workbench.webservices.WSDeleteView) WSView(com.amalto.workbench.webservices.WSView) LinkedHashMap(java.util.LinkedHashMap) WSPutView(com.amalto.workbench.webservices.WSPutView) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) TreeObject(com.amalto.workbench.models.TreeObject) WSBoolean(com.amalto.workbench.webservices.WSBoolean) XSDXPathDefinition(org.eclipse.xsd.XSDXPathDefinition) WSGetView(com.amalto.workbench.webservices.WSGetView) WSViewPK(com.amalto.workbench.webservices.WSViewPK)

Example 40 with TreeObject

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);
        }
    }
}
Also used : TreeParent(com.amalto.workbench.models.TreeParent) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) TreeObject(com.amalto.workbench.models.TreeObject) XObjectEditorInput(com.amalto.workbench.providers.XObjectEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) IEditorInput(org.eclipse.ui.IEditorInput)

Aggregations

TreeObject (com.amalto.workbench.models.TreeObject)66 TreeParent (com.amalto.workbench.models.TreeParent)21 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)14 ArrayList (java.util.ArrayList)12 MDMServerObject (org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)12 TMDMService (com.amalto.workbench.webservices.TMDMService)6 WSDataModel (com.amalto.workbench.webservices.WSDataModel)5 WSDataModelPK (com.amalto.workbench.webservices.WSDataModelPK)5 WSGetDataModel (com.amalto.workbench.webservices.WSGetDataModel)5 Document (org.dom4j.Document)5 Element (org.dom4j.Element)5 EObject (org.eclipse.emf.ecore.EObject)5 MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)5 WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 IAvailableModel (com.amalto.workbench.availablemodel.IAvailableModel)3 UserInfo (com.amalto.workbench.utils.UserInfo)3 WSDataCluster (com.amalto.workbench.webservices.WSDataCluster)3 WSDigest (com.amalto.workbench.webservices.WSDigest)3 WSDigestKey (com.amalto.workbench.webservices.WSDigestKey)3