use of com.amalto.workbench.webservices.TMDMService in project tmdm-studio-se by Talend.
the class ExportDataClusterAction method doRun.
@Override
protected void doRun() {
List<Object> selectedObject = getSelectedObject();
if (!selectedObject.isEmpty()) {
IRepositoryViewObject viewObj = (IRepositoryViewObject) selectedObject.get(0);
SelectServerDefDialog dialog = new SelectServerDefDialog(getShell());
if (dialog.open() == IDialogConstants.OK_ID) {
MDMServerDef serverDef = dialog.getSelectedServerDef();
MDMServerObjectItem item = (MDMServerObjectItem) viewObj.getProperty().getItem();
String dName = item.getMDMServerObject().getName();
try {
FileDialog fd = new FileDialog(getShell(), SWT.SAVE);
// $NON-NLS-1$
fd.setFilterExtensions(new String[] { "*.zip" });
String fPath = fd.open();
if (fPath != null) {
TMDMService service = RepositoryWebServiceAdapter.getMDMService(serverDef);
service.ping(new WSPing(Messages.ExportDataClusterAction_exportContent));
DataClusterService dataClusterService = DataClusterService.getIntance();
if (dataClusterService.isExistDataCluster(service, dName)) {
File tempFolder = IOUtil.getTempFolder();
String tempFolderPath = tempFolder.getAbsolutePath();
dataClusterService.storeIndexFile(tempFolderPath, dName);
//
IDataContentProcess process = dataClusterService.getNewExportContentProcess(service, tempFolderPath, dName, fPath);
try {
process.run();
} catch (InterruptedException e) {
// do nothing
return;
}
MultiStatus status = process.getResult();
if (status != null && status.getChildren().length > 0) {
MessageDialog.openError(getShell(), Messages._Error, Messages.bind(Messages.ExportDataClusterAction_failedExportContent, dName));
} else {
MessageDialog.openInformation(getShell(), Messages.ExportDataClusterAction_exportContent, Messages.bind(Messages.ExportDataClusterAction_successExport, dName));
}
} else {
MessageDialog.openInformation(getShell(), Messages.Common_Warning, Messages.bind(Messages.ExportDataClusterAction_noContainerFound, dName));
}
}
} catch (XtentisException e) {
log.error(e.getMessage(), e);
} catch (WebServiceException e) {
MessageDialog.openError(getShell(), Messages.ExportDataClusterAction_exportContent, Messages.AbstractDataClusterAction_ConnectFailed);
}
}
}
}
use of com.amalto.workbench.webservices.TMDMService in project tmdm-studio-se by Talend.
the class ImportDataClusterAction method doRun.
@Override
protected void doRun() {
FileDialog fd = new FileDialog(getShell(), SWT.OPEN);
// $NON-NLS-1$
fd.setFilterExtensions(new String[] { "*.zip" });
String fPath = fd.open();
if (fPath != null) {
DataClusterService dataClusterService = DataClusterService.getIntance();
File tempFolder = IOUtil.getTempFolder();
String tempFolderPath = tempFolder.getAbsolutePath();
dataClusterService.unZipFile(fPath, tempFolderPath);
String dName = dataClusterService.loadIndexFile(tempFolderPath);
if (dName == null) {
MessageDialog.openError(getShell(), Messages.Common_Error, Messages.ImportDataClusterAction_errorFormat);
return;
}
tempFolderPath += File.separator + dName;
//
SelectServerDefDialog dialog = new SelectServerDefDialog(getShell());
if (dialog.open() == IDialogConstants.OK_ID) {
MDMServerDef serverDef = dialog.getSelectedServerDef();
try {
TMDMService service = RepositoryWebServiceAdapter.getMDMService(serverDef);
service.ping(new WSPing(Messages.ImportDataClusterAction_importTitle));
if (!dataClusterService.isExistDataCluster(service, dName)) {
if (MessageDialog.openQuestion(getShell(), Messages.ImportDataClusterAction_createDataClusterTitle, Messages.bind(Messages.ImportDataClusterAction_createConfirm, dName))) {
dataClusterService.createDataCluster(service, dName);
} else {
return;
}
}
IDataContentProcess process = dataClusterService.getNewImportContentProcess(serverDef, dName, tempFolderPath);
try {
process.run();
} catch (InterruptedException e) {
// do nothing
return;
}
MultiStatus multiStatus = process.getResult();
if (multiStatus != null && multiStatus.getChildren().length > 0) {
MultiStatusDialog statusDialog = new MultiStatusDialog(getShell(), multiStatus.getMessage(), multiStatus);
statusDialog.open();
} else {
// show success info
MessageDialog.openInformation(getShell(), Messages.ImportDataClusterAction_importTitle, Messages.bind(Messages.ImportDataClusterAction_successImport, dName));
}
} catch (XtentisException e) {
log.error(e.getMessage(), e);
} catch (WebServiceException e) {
MessageDialog.openError(getShell(), Messages.ImportDataClusterAction_importTitle, Messages.AbstractDataClusterAction_ConnectFailed);
} finally {
IOUtil.cleanFolder(tempFolder);
}
}
}
}
use of com.amalto.workbench.webservices.TMDMService in project tmdm-studio-se by Talend.
the class SelectImportedModulesDialog method resolveSchemaList.
protected boolean resolveSchemaList(List<String> schemaList) throws XtentisException {
TMDMService port = getPort();
if (port == null) {
MessageDialog.openError(getShell(), Messages._Error, Messages.ServerNotNull);
return false;
}
// $NON-NLS-1$
List<WSDataModelPK> xdmPKs = port.getDataModelPKs(new WSRegexDataModelPKs("")).getWsDataModelPKs();
if (xdmPKs != null) {
for (WSDataModelPK xdmPK : xdmPKs) {
String name = xdmPK.getPk();
if (!name.startsWith("XMLSCHEMA")) {
// $NON-NLS-1$
schemaList.add(name);
}
}
}
return true;
}
use of com.amalto.workbench.webservices.TMDMService in project tmdm-studio-se by Talend.
the class XpathSelectDialog method changeDomTree.
protected void changeDomTree(final TreeParent pObject, String filter) {
String modelDisplay = dataModelCombo.getText();
if (modelDisplay.length() == 0) {
return;
}
this.dataModelName = modelDisplay;
// this.selectedDataModelName = modelDisplay;
// xobject = pObject.findObject(TreeObject.DATA_MODEL, modelDisplay);
TMDMService service = null;
try {
service = Util.getMDMService(pObject);
} catch (XtentisException e3) {
log.error(e3.getMessage(), e3);
} catch (Exception e3) {
log.error(e3.getMessage(), e3);
}
WSDataModel wsDataModel = null;
String schema = null;
XSDSchema xsd = null;
if (service == null) {
xsd = MDMRepositoryViewExtensionService.getDataModelXsd(pObject, filter, dataModelName);
provideViwerContent(xsd, filter);
} else {
try {
wsDataModel = service.getDataModel(new WSGetDataModel(new WSDataModelPK(dataModelName)));
// XSDSchema xsdSchema = Util.getXSDSchema(wsDataModel.getXsdSchema());
// Util.nodeToString(xsdSchema.getDocument());
schema = wsDataModel.getXsdSchema();
xsd = Util.createXsdSchema(schema, pObject);
provideViwerContent(xsd, filter);
} catch (Exception e1) {
log.error(e1.getMessage(), e1);
}
}
}
use of com.amalto.workbench.webservices.TMDMService in project tmdm-studio-se by Talend.
the class Util method getMDMService.
/**
*******************************************************************
* WEB SERVICES
********************************************************************
*/
public static TMDMService getMDMService(TreeObject xobject) throws XtentisException {
try {
if (xobject == null) {
return null;
}
String endpointAddress = xobject.getEndpointAddress();
String username = xobject.getUsername();
String password = xobject.getPassword();
TMDMService mdmService = getMDMService(new URL(endpointAddress), username, password);
return mdmService;
} catch (MalformedURLException e) {
throw new XtentisException(Messages.Util_0 + xobject.getEndpointAddress());
}
}
Aggregations