Search in sources :

Example 6 with TreeParent

use of com.amalto.workbench.models.TreeParent in project tmdm-studio-se by Talend.

the class LocalTreeObjectRepository method getParentElement.

public Element getParentElement(TreeObject treeObj) {
    if (!(treeObj instanceof TreeParent)) {
        return null;
    }
    if (treeObj.getServerRoot() == null) {
        return null;
    }
    Element elemFolder = null;
    String xpath = getXPathForTreeObject(treeObj);
    if (credentials.get(UnifyUrl(treeObj.getServerRoot().getWsKey().toString())) == null) {
        return null;
    }
    Document doc = credentials.get(UnifyUrl(treeObj.getServerRoot().getWsKey().toString())).doc;
    if (doc.selectNodes(xpath).isEmpty()) {
        // $NON-NLS-1$//$NON-NLS-2$
        xpath = xpath.replaceAll("\\[.*\\]", "");
        if (doc.selectNodes(xpath).isEmpty()) {
            xpath = getXPathForTreeObject(treeObj.getParent() != null ? treeObj.getParent() : treeObj.getServerRoot());
        }
        if (xpath != null) {
            Element elemTop = null;
            if (doc.selectNodes(xpath).isEmpty()) {
                elemTop = getTopElementWithUser(treeObj.getServerRoot().getUser().getUsername(), UnifyUrl(treeObj.getServerRoot().getWsKey().toString()));
            } else {
                // level as data container and data model
                if (treeObj.getType() == TreeObject.TRANSFORMER && treeObj.getParent() == null) {
                    // $NON-NLS-1$
                    xpath += "/EventManagement[text() = '33']";
                }
                elemTop = (Element) doc.selectNodes(xpath).get(0);
            }
            // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
            String selPath = "./" + filterOutBlank(treeObj.getDisplayName()) + "[text() = '" + treeObj.getType() + "']";
            if (elemTop.selectNodes(selPath).isEmpty()) {
                elemFolder = elemTop.addElement(filterOutBlank(treeObj.getDisplayName()));
                // $NON-NLS-1$
                elemFolder.setText(treeObj.getType() + "");
            } else {
                elemFolder = (Element) elemTop.selectNodes(selPath).get(0);
            }
        }
    } else {
        elemFolder = (Element) doc.selectNodes(xpath).get(0);
    }
    return elemFolder;
}
Also used : TreeParent(com.amalto.workbench.models.TreeParent) Element(org.dom4j.Element) Document(org.dom4j.Document)

Example 7 with TreeParent

use of com.amalto.workbench.models.TreeParent in project tmdm-studio-se by Talend.

the class LocalTreeObjectRepository method isInSystemCatalog.

public boolean isInSystemCatalog(TreeObject xobject) {
    if (xobject instanceof TreeParent) {
        if (xobject.getType() == TreeObject.CATEGORY_FOLDER && xobject.getDisplayName().equals("System")) {
            // $NON-NLS-1$
            Document doc = credentials.get(UnifyUrl(xobject.getServerRoot().getWsKey().toString())).doc;
            String path = this.getXPathForTreeObject(xobject);
            List<Element> elems = doc.selectNodes(path);
            if (!elems.isEmpty()) {
                Element elem = elems.get(0);
                if (isAEXtentisObjects(elem, xobject) == XTENTIS_LEVEL) {
                    return true;
                }
            }
        }
        return false;
    } else {
        TreeParent parent = xobject.getParent();
        return isInSystemCatalog(parent);
    }
}
Also used : TreeParent(com.amalto.workbench.models.TreeParent) Element(org.dom4j.Element) Document(org.dom4j.Document)

Example 8 with TreeParent

use of com.amalto.workbench.models.TreeParent in project tmdm-studio-se by Talend.

the class OpenObjectAction method getServerRoot.

public TreeParent getServerRoot(MDMServerDef serverDef) {
    if (isNull(serverDef)) {
        return null;
    }
    String serverName = serverDef.getName();
    String username = serverDef.getUser();
    String password = serverDef.getPasswd();
    String endpointaddress = // $NON-NLS-1$
    serverDef.getProtocol() + serverDef.getHost() + ":" + serverDef.getPort() + serverDef.getPath();
    TreeParent serverRoot = new TreeParent(serverName, null, TreeObject._SERVER_, endpointaddress, username + ":" + // $NON-NLS-1$//$NON-NLS-2$
    (password == null ? "" : password));
    UserInfo user = new UserInfo();
    user.setUsername(username);
    user.setPassword(password);
    user.setServerUrl(endpointaddress);
    serverRoot.setUser(user);
    return serverRoot;
}
Also used : TreeParent(com.amalto.workbench.models.TreeParent) UserInfo(com.amalto.workbench.utils.UserInfo)

Example 9 with TreeParent

use of com.amalto.workbench.models.TreeParent in project tmdm-studio-se by Talend.

the class OpenObjectAction method doSelectServer.

public boolean doSelectServer(Item item, IRepositoryViewEditorInput editorInput) {
    MDMServerObject serverObject = ((MDMServerObjectItem) item).getMDMServerObject();
    if (serverObject.getType() == TreeObject.DATA_CLUSTER) {
        // Data Cluster
        MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(item);
        MDMServerDef serverDef = openServerDialog(lastServerDef);
        if (serverDef != null) {
            XObjectBrowserInput input = (XObjectBrowserInput) editorInput;
            TreeObject xobject = (TreeObject) input.getModel();
            if (xobject != null && xobject.getWsKey() != null) {
                TreeParent serverRoot = getServerRoot(serverDef);
                xobject.setWsKey(new WSDataClusterPK(xobject.getWsKey().toString()));
                xobject.setServerRoot(serverRoot);
                return true;
            }
        }
        return false;
    }
    return true;
}
Also used : WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) TreeParent(com.amalto.workbench.models.TreeParent) XObjectBrowserInput(com.amalto.workbench.providers.XObjectBrowserInput) TreeObject(com.amalto.workbench.models.TreeObject) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 10 with TreeParent

use of com.amalto.workbench.models.TreeParent in project tmdm-studio-se by Talend.

the class DataClusterComposite method getRealTreeParent.

private TreeParent getRealTreeParent() {
    TreeParent treeParent = null;
    TreeObject xObject = getXObject();
    if (xObject != null) {
        TreeParent serverRoot = xObject.getServerRoot();
        UserInfo user = serverRoot.getUser();
        String serverName = serverRoot.getName();
        String password = user.getPassword();
        String url = user.getServerUrl();
        String username = user.getUsername();
        final XtentisServerObjectsRetriever retriever = new XtentisServerObjectsRetriever(serverName, url, username, password);
        retriever.setRetriveWSObject(true);
        try {
            retriever.run(new NullProgressMonitor());
            // get the real server root as the treeParent
            treeParent = retriever.getServerRoot();
        } catch (InvocationTargetException e) {
            log.error(e.getMessage(), e);
        } catch (InterruptedException e) {
            log.error(e.getMessage(), e);
        }
    }
    return treeParent;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) XtentisServerObjectsRetriever(com.amalto.workbench.providers.XtentisServerObjectsRetriever) TreeParent(com.amalto.workbench.models.TreeParent) TreeObject(com.amalto.workbench.models.TreeObject) UserInfo(com.amalto.workbench.utils.UserInfo) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

TreeParent (com.amalto.workbench.models.TreeParent)38 TreeObject (com.amalto.workbench.models.TreeObject)21 Document (org.dom4j.Document)7 Element (org.dom4j.Element)7 GridData (org.eclipse.swt.layout.GridData)7 UserInfo (com.amalto.workbench.utils.UserInfo)6 ArrayList (java.util.ArrayList)6 GridLayout (org.eclipse.swt.layout.GridLayout)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 Composite (org.eclipse.swt.widgets.Composite)5 WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)4 HashMap (java.util.HashMap)4 SelectionListener (org.eclipse.swt.events.SelectionListener)4 Combo (org.eclipse.swt.widgets.Combo)4 Label (org.eclipse.swt.widgets.Label)4 XtentisException (com.amalto.workbench.utils.XtentisException)3 WSDataModel (com.amalto.workbench.webservices.WSDataModel)3 WSDataModelPK (com.amalto.workbench.webservices.WSDataModelPK)3 WSGetDataModel (com.amalto.workbench.webservices.WSGetDataModel)3 ModifyEvent (org.eclipse.swt.events.ModifyEvent)3