use of com.amalto.workbench.models.TreeObject in project tmdm-studio-se by Talend.
the class Bean2EObjUtilTest method testWrapEObjWithTreeObject2Args.
/**
* test wrapEObjWithTreeObject with two input parameters
*/
@Test
public void testWrapEObjWithTreeObject2Args() {
EObject eobj = null;
Object wsObj = null;
Bean2EObjUtil util = Bean2EObjUtil.getInstance();
TreeObject treeObject = util.wrapEObjWithTreeObject(eobj, wsObj);
assertNull(treeObject);
MDMServerObject mdmServerObject = PowerMockito.mock(MDMServerObject.class);
when(mdmServerObject.getName()).thenReturn("name");
when(mdmServerObject.getType()).thenReturn(2);
eobj = mdmServerObject;
treeObject = util.wrapEObjWithTreeObject(eobj, wsObj);
assertNotNull(treeObject);
Mockito.verify(mdmServerObject, Mockito.atLeastOnce()).getName();
Mockito.verify(mdmServerObject, Mockito.atLeastOnce()).getType();
assertEquals("name", treeObject.getName());
assertEquals(2, treeObject.getType());
}
use of com.amalto.workbench.models.TreeObject in project tmdm-studio-se by Talend.
the class ResourcesUtilTest method testGetResourcesMapFromURI.
@Test
public void testGetResourcesMapFromURI() {
// $NON-NLS-1$
String method_private_getXMLString = "getXMLString";
// $NON-NLS-1$
String method_private_parsXMLString = "parsXMLString";
// $NON-NLS-1$
String responseBody = "responseBody";
// $NON-NLS-1$
String uri = "uri";
TreeObject treeObj = new TreeObject();
try {
PowerMockito.mockStatic(ResourcesUtil.class);
PowerMockito.when(ResourcesUtil.class, method_private_getXMLString, anyString(), any(TreeObject.class)).thenReturn(responseBody);
Document doc = null;
PowerMockito.when(ResourcesUtil.class, method_private_parsXMLString, anyString()).thenReturn(doc);
PowerMockito.when(ResourcesUtil.getResourcesMapFromURI(anyString(), any(TreeObject.class))).thenCallRealMethod();
HashMap<String, String> resourcesMapFromURI = ResourcesUtil.getResourcesMapFromURI(uri, treeObj);
assertTrue(resourcesMapFromURI.isEmpty());
doc = DocumentHelper.createDocument();
// $NON-NLS-1$
Element rootElement = DocumentHelper.createElement("root");
doc.setRootElement(rootElement);
PowerMockito.when(ResourcesUtil.class, method_private_parsXMLString, anyString()).thenReturn(doc);
boolean[][] ownNameURIElement = { { true, true }, { true, false }, { false, true }, { false, false } };
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
String[][] localNameUris = { { "name0", "uri0" }, { "name1", "uri1" }, { "name2", "uri2" }, { "name3", "uri3" } };
// $NON-NLS-1$
String entry = "entry";
for (int i = 0; i < ownNameURIElement.length; i++) {
createChildElement(rootElement, entry + i, localNameUris[i], ownNameURIElement[i][0], ownNameURIElement[i][1]);
}
resourcesMapFromURI = ResourcesUtil.getResourcesMapFromURI(uri, treeObj);
assertNotNull(resourcesMapFromURI);
assertEquals(4, resourcesMapFromURI.size());
Map<String, String> resourcesMap_expected = new HashMap<String, String>();
// $NON-NLS-1$ //$NON-NLS-2$
resourcesMap_expected.put("name0", "uri0");
// $NON-NLS-1$ //$NON-NLS-2$
resourcesMap_expected.put("entry1name1", "uri/entry1name1");
// $NON-NLS-1$ //$NON-NLS-2$
resourcesMap_expected.put("entry2uri2", "uri/entry2uri2");
// $NON-NLS-1$ //$NON-NLS-2$
resourcesMap_expected.put("entry3", "uri/entry3");
assertEquals(resourcesMap_expected, resourcesMapFromURI);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
use of com.amalto.workbench.models.TreeObject in project tmdm-studio-se by Talend.
the class JobAvailableModel method addTreeObjects.
@Override
public void addTreeObjects(TMDMService service, IProgressMonitor monitor, TreeParent serverRoot) {
monitor.subTask(Messages.JobAvailableModel_LoadingJobs);
// MDM Job
TreeParent jobs = serverRoot.findServerFolder(TreeObject.JOB_REGISTRY);
if (jobs == null) {
jobs = new TreeParent(EXtentisObjects.JobRegistry.getDisplayName(), serverRoot, TreeObject.JOB_REGISTRY, null, null);
}
TreeParent deployedJob = new TreeParent(Messages.JobAvailableModel_DeployedJobs, serverRoot, TreeObject.BUILT_IN_CATEGORY_FOLDER, null, null);
try {
List<WSMDMJob> jobPKs = service.getMDMJob(new WSMDMNULL()).getWsMDMJob();
if (jobPKs != null) {
for (WSMDMJob jobPK : jobPKs) {
// $NON-NLS-1$
String name = jobPK.getJobName() + "_" + jobPK.getJobVersion() + jobPK.getSuffix();
TreeObject obj = new TreeObject(name, serverRoot, TreeObject.JOB, name, null);
deployedJob.addChild(obj);
}
}
} catch (Exception e) {
}
jobs.addChild(deployedJob);
serverRoot.addChild(jobs);
monitor.worked(1);
}
use of com.amalto.workbench.models.TreeObject in project tmdm-studio-se by Talend.
the class DataClusterBrowserMainPage method getRealTreeParent.
// The ending| bug:21784
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;
}
use of com.amalto.workbench.models.TreeObject in project tmdm-studio-se by Talend.
the class DataClusterComposite method doSelectDataModelForEntityRecords.
/**
* @param clusterName
* @throws XtentisException
* @throws Exception
*/
private boolean doSelectDataModelForEntityRecords(String clusterName) throws XtentisException, Exception {
// if (false) {
// Modified by hbhong,to fix bug 21784|
TreeParent treeParent = (TreeParent) getAdapter(TreeParent.class);
DataModelSelectDialog dialog = new DataModelSelectDialog(getSite(), treeParent, clusterName);
// The ending| bug:21784
dialog.setBlockOnOpen(true);
dialog.open();
if (dialog.getReturnCode() == Window.OK) {
List<String> allConcept = new ArrayList<String>();
String[] xpaths = dialog.getXpath();
for (String xpath : xpaths) {
WSDataModel dm = Util.getMDMService(this.getXObject()).getDataModel(new WSGetDataModel(new WSDataModelPK(xpath)));
if (dm == null) {
return false;
}
List<String> concepts = Util.getConcepts(Util.getXSDSchema(dm.getXsdSchema()));
allConcept.addAll(concepts);
}
String[] concepts = allConcept.toArray(new String[0]);
TreeObject object = null;
TreeObject[] children = treeParent.getChildren();
for (TreeObject element : children) {
object = element;
if (object.getType() == TreeObject.DATA_MODEL) {
break;
}
}
// $NON-NLS-1$
String revision = "";
if (object != null) {
// revisions).
if (object.getDisplayName().contains(Messages.DataClusterBrowserMainPage_16) && object.getDisplayName().contains(Messages.DataClusterBrowserMainPage_17)) {
revision = // $NON-NLS-1$
object.getDisplayName().substring(// $NON-NLS-1$
object.getDisplayName().indexOf("[") + 1, // $NON-NLS-1$
object.getDisplayName().indexOf("]"));
}
}
for (int i = 0; i < concepts.length; i++) {
String concept = concepts[i];
if (revision == null || revision.equals("")) {
// $NON-NLS-1$
// $NON-NLS-1$
revision = "HEAD";
}
// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
concepts[i] = concept + " " + "[" + revision + "]";
}
conceptCombo.removeAll();
// $NON-NLS-1$
conceptCombo.add("*");
for (String concept : concepts) {
conceptCombo.add(concept);
}
} else {
// $NON-NLS-1$
conceptCombo.add("*");
}
return true;
}
Aggregations