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;
}
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);
}
}
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;
}
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;
}
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;
}
Aggregations