Search in sources :

Example 26 with TreeParent

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

the class ViewMainPage method createCharacteristicsContent.

@Override
protected void createCharacteristicsContent(FormToolkit toolkit, Composite charComposite) {
    try {
        Composite descriptionComposite = toolkit.createComposite(charComposite, SWT.NONE);
        descriptionComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        descriptionComposite.setLayout(new GridLayout());
        desAntionComposite = new DescAnnotationComposite(Messages.ViewMainPage_Description, // $NON-NLS-1$
        " ...", // $NON-NLS-1$
        toolkit, // $NON-NLS-1$
        descriptionComposite, // $NON-NLS-1$
        this, false);
        Composite comp = toolkit.createComposite(descriptionComposite);
        GridLayout layout = new GridLayout(2, false);
        layout.marginWidth = 0;
        layout.marginLeft = 0;
        layout.marginTop = 0;
        layout.marginHeight = 0;
        layout.marginBottom = 0;
        comp.setLayout(layout);
        comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        btnRunProcess = toolkit.createButton(comp, Messages.ViewMainPage_RunResultThroughProcess, SWT.CHECK);
        btnRunProcess.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
        cboProcessList = new Combo(comp, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.SINGLE);
        cboProcessList.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, true, 1, 1));
        initProcessCombo();
        createSortPart(toolkit, comp);
        if (adapter != null) {
            adapter.createComposite(this, toolkit, comp);
        }
        // add listener
        btnRunProcess.addSelectionListener(new SelectionListener() {

            public void widgetSelected(SelectionEvent e) {
                cboProcessList.setEnabled(btnRunProcess.getSelection());
                markDirtyWithoutCommit();
            }

            public void widgetDefaultSelected(SelectionEvent e) {
                cboProcessList.setEnabled(btnRunProcess.getSelection());
                markDirtyWithoutCommit();
            }
        });
        cboProcessList.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent e) {
                markDirtyWithoutCommit();
            }
        });
        // make the Page window a DropTarget - we need to dispose it
        windowTarget = new DropTarget(this.getPartControl(), DND.DROP_MOVE);
        windowTarget.setTransfer(new Transfer[] { TextTransfer.getInstance() });
        windowTarget.addDropListener(new DCDropTargetListener());
        /**
         **
         * /viewable Business Elements
         ***
         */
        TreeParent treeParent = (TreeParent) getAdapter(TreeParent.class);
        Composite viewablehGroup = this.getNewSectionComposite(Messages.ViewMainPage_ViewableBusinessElements);
        viewablehGroup.setLayout(new GridLayout(2, false));
        viewableElementColumns[0].setColumnWidth(220);
        viewableViewer = getNewTisTableViewer(viewablehGroup, toolkit, Arrays.asList(viewableElementColumns));
        viewableViewer.setTreeParent(treeParent);
        viewableViewer.setXpath(true);
        if (viewName.startsWith(Messages.ViewMainPage_BrowseItems)) {
            // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
            concept = viewName.replaceAll("Browse_items_", "").replaceAll("#.*", "");
        }
        viewableViewer.setConceptName(concept);
        viewableViewer.setMainPage(this);
        viewableViewer.setAddMulti(true);
        viewableViewer.create();
        viewableViewer.setHeight(110);
        // wrap.Wrap(this, viewableViewer);
        Composite searchGroup = this.getNewSectionComposite(Messages.ViewMainPage_SearchableBusinessElements);
        searchGroup.setLayout(new GridLayout(2, false));
        searchableElementColumns[0].setColumnWidth(220);
        searchableViewer = getNewTisTableViewer(searchGroup, toolkit, Arrays.asList(searchableElementColumns));
        searchableViewer.setTreeParent(treeParent);
        searchableViewer.setXpath(true);
        searchableViewer.setConceptName(concept);
        searchableViewer.setMainPage(this);
        searchableViewer.setAddMulti(true);
        searchableViewer.create();
        searchableViewer.setHeight(110);
        // wrap.Wrap(this, searchableViewer);
        // Where Conditions
        // if(viewName.startsWith("Browse_items_"))
        // setCompositeView(false);
        // else
        setCompositeView(true);
        initCoditionsColumns();
        Composite wcGroup = this.getNewSectionComposite(Messages.ViewMainPage_WhereConditions);
        wcGroup.setLayout(new GridLayout(2, false));
        conditionsColumns[0].setColumnWidth(250);
        conditionsColumns[1].setColumnWidth(150);
        conditionsColumns[2].setColumnWidth(250);
        conditionsColumns[3].setColumnWidth(120);
        conditionViewer = getNewTisTableViewer(wcGroup, toolkit, Arrays.asList(conditionsColumns));
        conditionViewer.setTreeParent(treeParent);
        conditionViewer.setXpath(true);
        conditionViewer.setConceptName(concept);
        conditionViewer.setMainPage(this);
        conditionViewer.setAddMulti(true);
        conditionViewer.create();
        conditionViewer.setHeight(110);
        // wrap.Wrap(this, conditionViewer);
        addToolBarItem();
        refreshData();
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : Composite(org.eclipse.swt.widgets.Composite) DescAnnotationComposite(com.amalto.workbench.widgets.DescAnnotationComposite) ModifyListener(org.eclipse.swt.events.ModifyListener) TreeParent(com.amalto.workbench.models.TreeParent) Combo(org.eclipse.swt.widgets.Combo) XtentisException(com.amalto.workbench.utils.XtentisException) InvocationTargetException(java.lang.reflect.InvocationTargetException) DescAnnotationComposite(com.amalto.workbench.widgets.DescAnnotationComposite) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DropTarget(org.eclipse.swt.dnd.DropTarget) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 27 with TreeParent

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

the class XtentisServerObjectsRetriever method run.

public synchronized void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    try {
        if (password == null || password.length() == 0) {
            throw new Exception(Messages.XtentisServerObjectsRetriever_0);
        }
        monitor.beginTask(Messages.bind(Messages.XtentisServerObjectsRetriever_1, IConstants.TALEND), Messages.XtentisServerObjectsRetriever_3.equals(username) ? 12 : 9);
        // server
        serverRoot = new TreeParent(serverName, null, TreeObject._SERVER_, endpointaddress, username + ":" + // $NON-NLS-1$//$NON-NLS-2$
        (password == null ? "" : password));
        // init load category
        monitor.subTask(Messages.XtentisServerObjectsRetriever_4);
        LocalTreeObjectRepository.getInstance().startUp(endpointaddress, username, password);
        LocalTreeObjectRepository.getInstance().switchOnListening();
        LocalTreeObjectRepository.getInstance().setLazySaveStrategy(true, serverRoot);
        monitor.worked(1);
        // Access to server and get port
        TMDMService service = Util.getMDMService(new URL(endpointaddress), username, password);
        // viewer user can't use studio
        service.ping(new WSPing(Messages.XtentisServerObjectsRetriever_5));
        monitor.worked(1);
        // fetch version info
        try {
            WSVersion version = service.getComponentVersion(new WSGetComponentVersion(WSComponent.DATA_MANAGER, null));
            String versionStr = // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            version.getMajor() + "." + version.getMinor() + "." + version.getRevision() + "_" + version.getBuild();
            // $NON-NLS-1$
            log.info("Server version = " + versionStr);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        if (monitor.isCanceled()) {
            throw new InterruptedException(Messages.XtentisServerObjectsRetriever_6);
        }
        monitor.subTask(Messages.XtentisServerObjectsRetriever_7);
        UserInfo user = new UserInfo();
        user.setUsername(username);
        user.setPassword(password);
        user.setServerUrl(endpointaddress);
        serverRoot.setUser(user);
        // String uriPre=serverRoot.getEndpointIpAddress();
        // Data Models
        TreeParent models = new TreeParent(EXtentisObjects.DataMODEL.getDisplayName(), serverRoot, TreeObject.DATA_MODEL, null, null);
        List<WSDataModelPK> xdmPKs = null;
        try {
            // $NON-NLS-1$
            xdmPKs = service.getDataModelPKs(new WSRegexDataModelPKs("")).getWsDataModelPKs();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        if (xdmPKs != null) {
            monitor.subTask(Messages.XtentisServerObjectsRetriever_8);
            for (WSDataModelPK pk : xdmPKs) {
                String name = pk.getPk();
                if (!name.startsWith("XMLSCHEMA")) {
                    // $NON-NLS-1$
                    WSDataModel wsobj = null;
                    if (retriveWSObject) {
                        wsobj = service.getDataModel(new WSGetDataModel(pk));
                    }
                    TreeObject obj = new TreeObject(name, serverRoot, TreeObject.DATA_MODEL, pk, wsobj);
                    models.addChild(obj);
                }
            }
        }
        monitor.worked(1);
        if (monitor.isCanceled()) {
            throw new InterruptedException(Messages.XtentisServerObjectsRetriever_9);
        }
        // DataClusters
        TreeParent dataClusters = new TreeParent(EXtentisObjects.DataCluster.getDisplayName(), serverRoot, TreeObject.DATA_CLUSTER, null, null);
        List<WSDataClusterPK> xdcPKs = null;
        try {
            // $NON-NLS-1$
            xdcPKs = service.getDataClusterPKs(new WSRegexDataClusterPKs("*")).getWsDataClusterPKs();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        if (xdcPKs != null) {
            monitor.subTask(Messages.XtentisServerObjectsRetriever_10);
            for (WSDataClusterPK pk : xdcPKs) {
                String name = pk.getPk();
                if (!("CACHE".equals(name))) {
                    // FIXME: Hardcoded CACHE//$NON-NLS-1$
                    WSDataCluster wsObject = null;
                    try {
                        if (retriveWSObject) {
                            wsObject = service.getDataCluster(new WSGetDataCluster(pk));
                        }
                        TreeObject obj = new TreeObject(name, serverRoot, TreeObject.DATA_CLUSTER, pk, wsObject);
                        dataClusters.addChild(obj);
                    } catch (Exception e) {
                        log.error(e.getMessage(), e);
                    }
                }
            }
        }
        monitor.worked(1);
        if (monitor.isCanceled()) {
            throw new InterruptedException(Messages.XtentisServerObjectsRetriever_11);
        }
        // event management
        TreeParent eventManagement = new TreeParent(EXtentisObjects.EventManagement.getDisplayName(), serverRoot, TreeObject.EVENT_MANAGEMENT, null, null);
        // subscript engine
        TreeObject engine = new TreeObject(EXtentisObjects.SubscriptionEngine.getDisplayName(), serverRoot, TreeObject.SUBSCRIPTION_ENGINE, null, null);
        eventManagement.addChild(engine);
        // transformer
        List<WSTransformerV2PK> transformerPKs = null;
        try {
            // $NON-NLS-1$
            transformerPKs = service.getTransformerV2PKs(new WSGetTransformerV2PKs("")).getWsTransformerV2PK();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        TreeParent transformers = null;
        transformers = new TreeParent(EXtentisObjects.Transformer.getDisplayName(), serverRoot, TreeObject.TRANSFORMER, null, null);
        eventManagement.addChild(transformers);
        if (transformerPKs != null) {
            monitor.subTask(Messages.XtentisServerObjectsRetriever_12);
            for (WSTransformerV2PK pk : transformerPKs) {
                String id = pk.getPk();
                WSTransformerV2 wsobject = null;
                if (retriveWSObject) {
                    wsobject = service.getTransformerV2(new WSGetTransformerV2(pk));
                }
                TreeObject obj = new TreeObject(id, serverRoot, TreeObject.TRANSFORMER, new WSTransformerV2PK(id), wsobject);
                transformers.addChild(obj);
            }
        }
        monitor.worked(1);
        // routing rule
        List<WSRoutingRulePK> routingRulePKs = null;
        try {
            // $NON-NLS-1$
            routingRulePKs = service.getRoutingRulePKs(new WSGetRoutingRulePKs("")).getWsRoutingRulePKs();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        TreeParent rules = null;
        rules = new TreeParent(EXtentisObjects.RoutingRule.getDisplayName(), serverRoot, TreeObject.ROUTING_RULE, null, null);
        eventManagement.addChild(rules);
        if (routingRulePKs != null) {
            monitor.subTask(Messages.XtentisServerObjectsRetriever_13);
            for (WSRoutingRulePK pk : routingRulePKs) {
                String id = pk.getPk();
                WSRoutingRule wsobject = null;
                if (retriveWSObject) {
                    wsobject = service.getRoutingRule(new WSGetRoutingRule(pk));
                }
                TreeObject obj = new TreeObject(id, serverRoot, TreeObject.ROUTING_RULE, new WSRoutingRulePK(id), wsobject);
                rules.addChild(obj);
            }
        }
        monitor.worked(1);
        // add event management to serverRoot
        serverRoot.addChild(eventManagement);
        // Views
        TreeParent views = new TreeParent(EXtentisObjects.View.getDisplayName(), serverRoot, TreeObject.VIEW, null, null);
        List<WSViewPK> viewPKs = null;
        try {
            // $NON-NLS-1$
            viewPKs = service.getViewPKs((new WSGetViewPKs(""))).getWsViewPK();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        if (viewPKs != null) {
            monitor.subTask(Messages.XtentisServerObjectsRetriever_14);
            for (WSViewPK pk : viewPKs) {
                String name = pk.getPk();
                WSView wsobject = null;
                if (retriveWSObject) {
                    wsobject = service.getView(new WSGetView(pk));
                }
                TreeObject obj = new TreeObject(name, serverRoot, TreeObject.VIEW, new WSViewPK(name), wsobject);
                views.addChild(obj);
            }
        }
        monitor.worked(1);
        if (monitor.isCanceled()) {
            throw new InterruptedException(Messages.XtentisServerObjectsRetriever_15);
        }
        // Stored Procedures
        TreeParent storedProcedures = new TreeParent(EXtentisObjects.StoredProcedure.getDisplayName(), serverRoot, TreeObject.STORED_PROCEDURE, null, null);
        List<WSStoredProcedurePK> spk = null;
        try {
            // $NON-NLS-1$
            spk = service.getStoredProcedurePKs(new WSRegexStoredProcedure("")).getWsStoredProcedurePK();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        if (spk != null) {
            monitor.subTask(Messages.XtentisServerObjectsRetriever_16);
            for (WSStoredProcedurePK pk : spk) {
                String name = pk.getPk();
                WSStoredProcedure wsobject = null;
                if (retriveWSObject) {
                    wsobject = service.getStoredProcedure(new WSGetStoredProcedure(pk));
                }
                TreeObject obj = new TreeObject(name, serverRoot, TreeObject.STORED_PROCEDURE, new WSStoredProcedurePK(name), wsobject);
                storedProcedures.addChild(obj);
            }
        }
        monitor.worked(1);
        if (monitor.isCanceled()) {
            throw new InterruptedException(Messages.XtentisServerObjectsRetriever_17);
        }
        // Service Configuration
        TreeObject serviceConfiguration = new TreeObject(EXtentisObjects.ServiceConfiguration.getDisplayName(), serverRoot, TreeObject.SERVICE_CONFIGURATION, null, null);
        // serviceConfiguration.setXObject(false);
        monitor.worked(1);
        if (monitor.isCanceled()) {
            throw new InterruptedException(Messages.XtentisServerObjectsRetriever_18);
        }
        // Menus
        List<WSMenuPK> menuPKs = null;
        boolean hasMenus = true;
        try {
            // $NON-NLS-1$
            menuPKs = service.getMenuPKs(new WSGetMenuPKs("*")).getWsMenuPK();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            // This server IS old
            hasMenus = false;
        }
        TreeParent menus = null;
        if (hasMenus) {
            menus = new TreeParent(EXtentisObjects.Menu.getDisplayName(), serverRoot, TreeObject.MENU, null, null);
            if (menuPKs != null) {
                monitor.subTask(Messages.XtentisServerObjectsRetriever_19);
                for (WSMenuPK pk : menuPKs) {
                    String id = pk.getPk();
                    WSMenu wsobject = null;
                    try {
                        if (retriveWSObject) {
                            wsobject = service.getMenu(new WSGetMenu(pk));
                        }
                        TreeObject obj = new TreeObject(id, serverRoot, TreeObject.MENU, new WSMenuPK(id), wsobject);
                        menus.addChild(obj);
                    } catch (Exception e) {
                        log.error(e.getMessage(), e);
                    }
                }
            }
            monitor.worked(1);
            if (monitor.isCanceled()) {
                throw new InterruptedException(Messages.XtentisServerObjectsRetriever_20);
            }
        }
        // move Job from EE to CE.
        monitor.worked(1);
        serverRoot.addChild(models);
        serverRoot.addChild(dataClusters);
        serverRoot.addChild(views);
        serverRoot.addChild(storedProcedures);
        serverRoot.addChild(serviceConfiguration);
        if (hasMenus) {
            serverRoot.addChild(menus);
        }
        // available models
        List<IAvailableModel> availablemodels = AvailableModelUtil.getAvailableModels();
        for (IAvailableModel model : availablemodels) {
            model.addTreeObjects(service, monitor, serverRoot);
        }
        monitor.done();
    } catch (Exception e) {
        if (monitor.isCanceled()) {
            throw new InterruptedException(Messages.XtentisServerObjectsRetriever_21);
        }
        log.error(e.getMessage(), e);
        throw new InvocationTargetException(e);
    }
}
Also used : WSStoredProcedurePK(com.amalto.workbench.webservices.WSStoredProcedurePK) WSView(com.amalto.workbench.webservices.WSView) WSGetDataModel(com.amalto.workbench.webservices.WSGetDataModel) WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) TMDMService(com.amalto.workbench.webservices.TMDMService) WSGetMenuPKs(com.amalto.workbench.webservices.WSGetMenuPKs) WSRoutingRule(com.amalto.workbench.webservices.WSRoutingRule) WSRegexDataModelPKs(com.amalto.workbench.webservices.WSRegexDataModelPKs) WSGetView(com.amalto.workbench.webservices.WSGetView) WSGetComponentVersion(com.amalto.workbench.webservices.WSGetComponentVersion) WSGetMenu(com.amalto.workbench.webservices.WSGetMenu) WSRoutingRulePK(com.amalto.workbench.webservices.WSRoutingRulePK) WSGetRoutingRulePKs(com.amalto.workbench.webservices.WSGetRoutingRulePKs) WSVersion(com.amalto.workbench.webservices.WSVersion) InvocationTargetException(java.lang.reflect.InvocationTargetException) WSGetDataCluster(com.amalto.workbench.webservices.WSGetDataCluster) WSTransformerV2(com.amalto.workbench.webservices.WSTransformerV2) WSTransformerV2PK(com.amalto.workbench.webservices.WSTransformerV2PK) TreeObject(com.amalto.workbench.models.TreeObject) WSRegexDataClusterPKs(com.amalto.workbench.webservices.WSRegexDataClusterPKs) WSDataModelPK(com.amalto.workbench.webservices.WSDataModelPK) WSViewPK(com.amalto.workbench.webservices.WSViewPK) WSGetStoredProcedure(com.amalto.workbench.webservices.WSGetStoredProcedure) WSPing(com.amalto.workbench.webservices.WSPing) WSMenuPK(com.amalto.workbench.webservices.WSMenuPK) TreeParent(com.amalto.workbench.models.TreeParent) WSGetTransformerV2(com.amalto.workbench.webservices.WSGetTransformerV2) UserInfo(com.amalto.workbench.utils.UserInfo) URL(java.net.URL) WSGetTransformerV2PKs(com.amalto.workbench.webservices.WSGetTransformerV2PKs) WSDataCluster(com.amalto.workbench.webservices.WSDataCluster) WSStoredProcedure(com.amalto.workbench.webservices.WSStoredProcedure) IAvailableModel(com.amalto.workbench.availablemodel.IAvailableModel) InvocationTargetException(java.lang.reflect.InvocationTargetException) WSGetRoutingRule(com.amalto.workbench.webservices.WSGetRoutingRule) WSGetViewPKs(com.amalto.workbench.webservices.WSGetViewPKs) WSMenu(com.amalto.workbench.webservices.WSMenu) WSDataModel(com.amalto.workbench.webservices.WSDataModel) WSRegexStoredProcedure(com.amalto.workbench.webservices.WSRegexStoredProcedure)

Example 28 with TreeParent

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

the class LocalTreeObjectRepository method addChild.

private void addChild(TreeObject parent, TreeObject child) {
    if (parent.getParent() == null && parent.getDisplayName().equals("INVISIBLE ROOT")) {
        return;
    }
    if (parent.getServerRoot() == null) {
        return;
    }
    String xpath = getXPathForTreeObject(child);
    Document doc = credentials.get(UnifyUrl(parent.getServerRoot().getWsKey().toString())).doc;
    List<Element> models = doc.selectNodes(xpath);
    if (!models.isEmpty() && child instanceof TreeParent) {
        Element model = models.get(0);
        if (isAEXtentisObjects(model, child) == MODEL_LEVEL) {
            checkUpAllCategoryForModel((TreeParent) child);
        }
    }
    String catalog = synchronizeWithElem(child, (TreeParent) parent, true);
    Element elemFolder = getParentElement(parent);
    if (elemFolder != null) {
        // $NON-NLS-1$
        String xpathTail = "";
        // $NON-NLS-1$
        String xpathTailOther = "']";
        // $NON-NLS-1$//$NON-NLS-2$
        xpath = "child::*[name()='" + filterOutBlank(child.getDisplayName()) + "' and text()='" + child.getType();
        if (child.getType() == TreeObject.CATEGORY_FOLDER) {
            // $NON-NLS-1$
            xpathTail = "' and @Url='" + getURLFromTreeObject(child);
        }
        List<Element> list = elemFolder.selectNodes(xpath + xpathTail + xpathTailOther);
        if (list.isEmpty() && (catalog.equals("") || catalog == null)) {
            // $NON-NLS-1$
            Element childElem = elemFolder.addElement(filterOutBlank(child.getDisplayName()));
            // $NON-NLS-1$
            childElem.setText(child.getType() + "");
            if (child.getType() == TreeObject.CATEGORY_FOLDER) {
                childElem.addAttribute(URL, getURLFromTreeObject(child));
                childElem.addAttribute(REALNAME, child.getDisplayName());
            }
        }
    }
    saveDocument(parent);
}
Also used : TreeParent(com.amalto.workbench.models.TreeParent) Element(org.dom4j.Element) Document(org.dom4j.Document)

Example 29 with TreeParent

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

the class LocalTreeObjectRepository method synchronizeWithDoc.

public void synchronizeWithDoc(TreeParent root) {
    internalCheck = false;
    TreeObject[] targetChildren = root.getChildren();
    for (TreeObject treeObj : targetChildren) {
        if (treeObj instanceof TreeParent && treeObj.getServerRoot() == treeObj) {
            synchronizeWithDoc((TreeParent) treeObj);
        }
        synchronizeWithElem(treeObj, root, true);
    }
}
Also used : TreeParent(com.amalto.workbench.models.TreeParent) TreeObject(com.amalto.workbench.models.TreeObject)

Example 30 with TreeParent

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

the class LocalTreeObjectRepository method checkUpAllCategoryForModel.

private void checkUpAllCategoryForModel(TreeParent model) {
    if (model.getServerRoot() == null) {
        return;
    }
    String username = model.getServerRoot().getUser().getUsername();
    String xpath = // $NON-NLS-1$//$NON-NLS-2$
    "//" + transformForXPath(username) + "/" + filterOutBlank(model.getDisplayName()) + "//child::*[text() = '" + TreeObject.CATEGORY_FOLDER + "' and @Url='" + getURLFromTreeObject(model) + // $NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
    "']";
    Document doc = credentials.get(UnifyUrl(model.getServerRoot().getWsKey().toString())).doc;
    String xpathForModel = getXPathForTreeObject(model);
    List<Element> elems = doc.selectNodes(xpathForModel);
    Element modelElem = elems.get(0);
    elems = doc.selectNodes(xpath);
    for (Element elem : elems) {
        Element spec = elem;
        ArrayList<Element> hierarchicalList = new ArrayList<Element>();
        while (spec != modelElem) {
            hierarchicalList.add(spec);
            spec = spec.getParent();
        }
        Collections.reverse(hierarchicalList);
        TreeParent modelCpy = model;
        while (!hierarchicalList.isEmpty()) {
            spec = hierarchicalList.remove(0);
            String elemName = spec.getName();
            if (spec.attributeValue(REALNAME) != null) {
                elemName = spec.attributeValue(REALNAME);
            }
            TreeObject to = findObject(modelCpy, Integer.parseInt(spec.getText().trim()), elemName);
            if (to == null) {
                TreeParent catalog = new TreeParent(elemName, modelCpy.getServerRoot(), TreeObject.CATEGORY_FOLDER, null, null);
                boolean cpyInternalCheck = internalCheck;
                internalCheck = true;
                modelCpy.addChild(catalog);
                internalCheck = cpyInternalCheck;
                modelCpy = catalog;
            } else {
                modelCpy = (TreeParent) to;
            }
        }
    }
}
Also used : TreeParent(com.amalto.workbench.models.TreeParent) Element(org.dom4j.Element) ArrayList(java.util.ArrayList) TreeObject(com.amalto.workbench.models.TreeObject) Document(org.dom4j.Document)

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