use of com.amalto.workbench.models.TreeParent in project tmdm-studio-se by Talend.
the class ImportItemsWizard method parses.
protected void parses(boolean importFromArchieve, String zipFilePath, IProgressMonitor monitor) {
// init var for progressMonitor
int total = 500, zipCount = 200, readCount = 100;
int step = 1, interval = 1;
//
monitor.beginTask(Messages.ImportItemsWizard_7, total);
if (importFromArchieve) {
checkUpExchangeImport(true);
try {
Util.unZipFile(zipFilePath, importFolder, zipCount, monitor);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
monitor.worked(zipCount);
monitor.setTaskName(Messages.ImportItemsWizard_8);
InputStreamReader reader = null;
try {
// $NON-NLS-1$//$NON-NLS-2$
reader = new InputStreamReader(new FileInputStream(importFolder + "/exportitems.xml"), "UTF-8");
final Exports exports = (Exports) Unmarshaller.unmarshal(Exports.class, reader);
String[] orgSchemas = exports.getSchemas();
int idx = 0;
if (orgSchemas != null) {
for (String orgSchema : orgSchemas) {
String orgSchemaCpy = new String(orgSchema);
for (Map.Entry<String, String> pair : ICoreConstants.rolesConvert.oldRoleToNewRoleMap.entrySet()) {
orgSchemaCpy = orgSchemaCpy.replaceAll(pair.getKey().toString(), pair.getValue().toString());
}
if (!orgSchemaCpy.equals(orgSchema)) {
orgSchemas[idx] = orgSchemaCpy;
}
idx++;
}
}
try {
LocalTreeObjectRepository.getInstance().makeUpDocWithImportCategory(orgSchemas, serverRoot);
} catch (Exception e) {
}
// import autoincrement
if (exports.getAutoIncrement() != null) {
try {
service.getAutoIncrement(new WSAutoIncrement(exports.getAutoIncrement()));
} catch (Exception e) {
}
}
// new server root
final TreeParent reserverRoot = new TreeParent(serverRoot.getDisplayName(), null, TreeObject._SERVER_, serverRoot.getWsKey(), serverRoot.getWsObject());
reserverRoot.setUser(serverRoot.getUser());
// serverRoot=reserverRoot;
TreeParent clusters = new TreeParent(EXtentisObjects.DataCluster.getDisplayName(), reserverRoot, TreeObject.DATA_CLUSTER, null, null);
TreeParent models = new TreeParent(EXtentisObjects.DataMODEL.getDisplayName(), reserverRoot, TreeObject.DATA_MODEL, null, null);
TreeParent menus = new TreeParent(EXtentisObjects.Menu.getDisplayName(), reserverRoot, TreeObject.MENU, null, null);
TreeParent roles = new TreeParent(EXtentisObjects.Role.getDisplayName(), reserverRoot, TreeObject.ROLE, null, null);
TreeParent eventManager = new TreeParent(EXtentisObjects.EventManagement.getDisplayName(), reserverRoot, TreeObject.EVENT_MANAGEMENT, null, null);
TreeParent routingrules = new TreeParent(EXtentisObjects.RoutingRule.getDisplayName(), reserverRoot, TreeObject.ROUTING_RULE, null, null);
TreeParent storeprocedures = new TreeParent(EXtentisObjects.StoredProcedure.getDisplayName(), reserverRoot, TreeObject.STORED_PROCEDURE, null, null);
TreeParent transformers = new TreeParent(EXtentisObjects.Transformer.getDisplayName(), reserverRoot, TreeObject.TRANSFORMER, null, null);
TreeParent pictures = new TreeParent(EXtentisObjects.PICTURESRESOURCE.getDisplayName(), reserverRoot, TreeObject.PICTURES_RESOURCE, null, null);
// add by ymli
TreeParent workflow = new TreeParent(EXtentisObjects.Workflow.getDisplayName(), reserverRoot, TreeObject.WORKFLOW, null, null);
TreeParent views = new TreeParent(EXtentisObjects.View.getDisplayName(), reserverRoot, TreeObject.VIEW, null, null);
reserverRoot.addChild(clusters);
reserverRoot.addChild(models);
reserverRoot.addChild(menus);
reserverRoot.addChild(roles);
reserverRoot.addChild(storeprocedures);
eventManager.addChild(transformers);
eventManager.addChild(routingrules);
reserverRoot.addChild(eventManager);
reserverRoot.addChild(pictures);
reserverRoot.addChild(workflow);
reserverRoot.addChild(views);
monitor.worked(readCount);
// caculate step and interval
float val = (total - zipCount - readCount) / exports.getItems().length;
if (val > 0) {
interval = 1;
step = Math.round(val);
} else {
step = 1;
interval = Math.round(exports.getItems().length / (total - zipCount - readCount) + 0.5f);
}
// System.out.println("count:" + exports.getItems().length + "\tinterval:" + interval + "\tstep:" + step);
monitor.setTaskName(Messages.ImportItemsWizard_9);
//
int tmp = 1;
for (TreeObject obj : exports.getItems()) {
obj.setServerRoot(reserverRoot);
switch(obj.getType()) {
case TreeObject.DATA_CLUSTER:
clusters.addChild(obj);
break;
case TreeObject.DATA_MODEL:
models.addChild(obj);
break;
case TreeObject.MENU:
menus.addChild(obj);
break;
case TreeObject.ROLE:
roles.addChild(obj);
break;
case TreeObject.ROUTING_RULE:
routingrules.addChild(obj);
break;
case TreeObject.STORED_PROCEDURE:
storeprocedures.addChild(obj);
break;
case TreeObject.TRANSFORMER:
transformers.addChild(obj);
break;
case TreeObject.PICTURES_RESOURCE:
pictures.addChild(obj);
break;
case TreeObject.WORKFLOW_PROCESS:
workflow.addChild(obj);
break;
case TreeObject.VIEW:
views.addChild(obj);
break;
default:
if (obj.getItems() != null && obj.getItems().length > 0) {
for (int i = 0; i < obj.getItems().length; i++) {
if (obj.getItems()[i].split(Messages.ImportItemsWizard_10)[1] != null) {
dataClusterContent.put(obj.getItems()[i].split(Messages.ImportItemsWizard_11)[1], obj.getItems());
}
}
}
}
// update monitor
if (interval == 1) {
monitor.worked(step);
} else {
if (tmp >= interval) {
monitor.worked(step);
tmp = 1;
} else {
tmp++;
}
}
}
Display.getDefault().syncExec(new Runnable() {
public void run() {
treeViewer.setRoot(reserverRoot);
treeViewer.getViewer().setInput(null);
treeViewer.setCheckItems(Arrays.asList(exports.getItems()));
GridData gd = (GridData) treeViewer.getViewer().getControl().getLayoutData();
gd.heightHint = 300;
treeViewer.getViewer().getControl().getParent().layout(true);
treeViewer.getViewer().getControl().getShell().layout(true);
try {
Object[] checkNodes = treeViewer.getCheckNodes();
if (checkNodes != null) {
LocalTreeObjectRepository.getInstance().setOriginalXobjectsToImport((TreeObject[]) checkNodes);
}
} catch (Exception e) {
}
}
});
} catch (Exception e) {
log.error(e.getMessage(), e);
} finally {
try {
if (reader != null) {
reader.close();
}
} catch (Exception e) {
}
monitor.done();
}
}
use of com.amalto.workbench.models.TreeParent in project tmdm-studio-se by Talend.
the class AbstractNodeCheckTreeViewer method expandParent.
protected void expandParent(TreeViewer viewer, TreeObject node) {
TreeParent parent = node.getParent();
if (parent != null) {
expandParent(viewer, parent);
viewer.setExpandedState(parent, true);
}
}
use of com.amalto.workbench.models.TreeParent 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.TreeParent 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.TreeParent 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