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