Search in sources :

Example 26 with TreeObject

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

the class ServerTreeLabelProvider method filterName.

private String filterName(String label, TreeObject treeObject) {
    String transformedName = label;
    if (label == null || label.isEmpty()) {
        return transformedName;
    }
    Object wsObject = treeObject.getWsObject();
    ITransformService transformService = (ITransformService) GlobalServiceRegister.getDefault().getService(ITransformService.class);
    if (wsObject instanceof WSTransformerV2) {
        transformedName = transformService.transformToSilyProcessName(label, true);
    } else if (wsObject instanceof WSView) {
        transformedName = transformService.transformToSilyViewName(label, true);
    }
    return transformedName;
}
Also used : ITransformService(com.amalto.workbench.service.bridge.ITransformService) WSTransformerV2(com.amalto.workbench.webservices.WSTransformerV2) TreeObject(com.amalto.workbench.models.TreeObject) WSView(com.amalto.workbench.webservices.WSView)

Example 27 with TreeObject

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

the class CheckboxRepositoryTreeViewer method getTreeObject.

private TreeObject getTreeObject(Item node) {
    Object data = node.getData();
    TreeObject repositoryNode = null;
    if (data instanceof TreeObject) {
        repositoryNode = (TreeObject) data;
    }
    return repositoryNode;
}
Also used : TreeObject(com.amalto.workbench.models.TreeObject) TreeObject(com.amalto.workbench.models.TreeObject)

Example 28 with TreeObject

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

the class CheckboxRepositoryTreeViewer method getExpanded.

@Override
protected boolean getExpanded(Item item) {
    TreeObject repositoryNode = getTreeObject(item);
    if (repositoryNode != null && repositoryNode.getDisplayName() != null) {
        Boolean result = expanded.get(repositoryNode.getDisplayName());
        if (result != null) {
            if (item instanceof TreeItem) {
                TreeItem treeItem = (TreeItem) item;
                treeItem.setExpanded(result);
            }
        }
    }
    return super.getExpanded(item);
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) TreeObject(com.amalto.workbench.models.TreeObject)

Example 29 with TreeObject

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

the class ExtensibleTextContentEditorPage method createCompDropTarget.

protected void createCompDropTarget() {
    DropTarget dropTarget = new DropTarget(textViewer.getTextWidget(), DND.DROP_MOVE | DND.DROP_LINK);
    dropTarget.setTransfer(new TreeObjectTransfer[] { TreeObjectTransfer.getInstance() });
    dropTarget.addDropListener(new DropTargetAdapter() {

        @Override
        public void dragEnter(DropTargetEvent event) {
        }

        @Override
        public void dragLeave(DropTargetEvent event) {
        }

        @Override
        public void dragOver(DropTargetEvent event) {
            event.feedback |= DND.FEEDBACK_EXPAND | DND.FEEDBACK_SCROLL;
        }

        @Override
        public void drop(DropTargetEvent event) {
            if (event.data instanceof TreeObject[]) {
                if (((TreeObject[]) event.data)[0].getType() == TreeObject.TRANSFORMER) {
                    textViewer.getTextWidget().setText(// $NON-NLS-1$//$NON-NLS-2$
                    textViewer.getTextWidget().getText().replace("?", "") + ((TreeObject[]) event.data)[0].getDisplayName());
                } else {
                    textViewer.getTextWidget().setText(textViewer.getTextWidget().getText() + ((TreeObject[]) event.data)[0].getDisplayName());
                }
            }
        }
    });
}
Also used : DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) TreeObject(com.amalto.workbench.models.TreeObject) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DropTarget(org.eclipse.swt.dnd.DropTarget)

Example 30 with TreeObject

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

the class ConsistencyServiceTest method testQueryServerDigestValue.

@Test
public void testQueryServerDigestValue() {
    MDMServerDef serverDef = MdmmetadataFactory.eINSTANCE.createMDMServerDef();
    serverDef.setAlgorithm(PasswordUtil.ALGORITHM_COMMON_V2);
    // $NON-NLS-1$
    String url = "http://localhost:8180/talendmdm/service/soap?wsdl";
    serverDef.parse(url);
    serverDef.setUrl(url);
    // $NON-NLS-1$
    serverDef.setName("MyServer");
    // $NON-NLS-1$
    serverDef.setUser("admin");
    // $NON-NLS-1$
    serverDef.setPasswd("talend");
    // $NON-NLS-1$
    String label = "Product";
    ERepositoryObjectType type = IServerObjectRepositoryType.TYPE_DATAMODEL;
    try {
        WSDigest mockDigest = PowerMockito.mock(WSDigest.class);
        TMDMService mockService = PowerMockito.mock(TMDMService.class);
        PowerMockito.when(mockService.getDigest(Mockito.any(WSDigestKey.class))).thenReturn(mockDigest);
        PowerMockito.mockStatic(RepositoryWebServiceAdapter.class);
        PowerMockito.when(RepositoryWebServiceAdapter.getMDMService(serverDef)).thenReturn(mockService);
        // IRepositoryViewObject
        IRepositoryViewObject mockViewObj = PowerMockito.mock(IRepositoryViewObject.class);
        PowerMockito.when(mockViewObj.getLabel()).thenReturn(label);
        PowerMockito.when(mockViewObj.getRepositoryObjectType()).thenReturn(type);
        // /////////
        Map<IRepositoryViewObject, WSDigest> queryServerDigestValue = ConsistencyService.getInstance().queryServerDigestValue(serverDef, Collections.singleton(mockViewObj));
        assertNotNull(queryServerDigestValue);
        assertTrue(queryServerDigestValue.size() == 1);
        assertEquals(mockViewObj, queryServerDigestValue.keySet().iterator().next());
        assertEquals(mockDigest, queryServerDigestValue.values().iterator().next());
        // TreeObject
        TreeObject mockTreeObj = PowerMockito.mock(TreeObject.class);
        PowerMockito.when(mockTreeObj.getDisplayName()).thenReturn(label);
        PowerMockito.when(mockTreeObj.getType()).thenReturn(1);
        PowerMockito.mockStatic(RepositoryQueryService.class);
        PowerMockito.when(RepositoryQueryService.getRepositoryObjectType(anyInt())).thenReturn(type);
        ConsistencyService mockCService = PowerMockito.mock(ConsistencyService.class);
        // $NON-NLS-1$
        PowerMockito.when(mockCService, "getObjectName", any(TreeObject.class)).thenReturn(label);
        // $NON-NLS-1$
        PowerMockito.when(mockCService, "isSupportConsistency", any(TMDMService.class)).thenReturn(true);
        PowerMockito.when(mockCService.queryServerDigestValue(any(MDMServerDef.class), anySetOf(TreeObject.class))).thenCallRealMethod();
        Map<TreeObject, WSDigest> serverDigestValue = mockCService.queryServerDigestValue(serverDef, Collections.singleton(mockTreeObj));
        assertNotNull(serverDigestValue);
        assertTrue(serverDigestValue.size() >= 0);
        if (serverDigestValue.size() > 0) {
            assertEquals(mockTreeObj, serverDigestValue.keySet().iterator().next());
            assertEquals(mockDigest, serverDigestValue.values().iterator().next());
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : TMDMService(com.amalto.workbench.webservices.TMDMService) WSDigestKey(com.amalto.workbench.webservices.WSDigestKey) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TreeObject(com.amalto.workbench.models.TreeObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) WSDigest(com.amalto.workbench.webservices.WSDigest) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

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