use of com.amalto.workbench.webservices.WSDataClusterPK in project tmdm-studio-se by Talend.
the class ResourceCompareInput method commitToDB.
private void commitToDB() {
try {
String toCommitContent = CompareManager.getInstance().getLeftContent();
// $NON-NLS-1$
toCommitContent = XmlUtil.formatCompact(toCommitContent, "UTF-8");
if (this.compareHeadInfo.isItem()) {
Util.getMDMService(compareHeadInfo.getXobject()).putItem(new WSPutItem(false, (WSDataClusterPK) compareHeadInfo.getXobject().getWsKey(), // $NON-NLS-1$
"".equals(compareHeadInfo.getDataModelName()) ? null : new WSDataModelPK(compareHeadInfo.getDataModelName()), toCommitContent));
} else {
// TODO add support for Object(s)
}
} catch (Exception e) {
log.error(e.getMessage(), e);
if (!Util.handleConnectionException((Shell) null, e, null)) {
MessageDialog.openError(null, Messages._Error, Messages.bind(Messages.ResourceCompareInput_ErrorMsg, e.getLocalizedMessage()));
}
}
}
use of com.amalto.workbench.webservices.WSDataClusterPK in project tmdm-studio-se by Talend.
the class DataClusterComposite method getResults.
protected LineItem[] getResults(boolean showResultInfo) {
Cursor waitCursor = null;
try {
waitCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_WAIT);
getSite().getShell().setCursor(waitCursor);
TMDMService service = Util.getMDMService(getXObject());
long from = -1;
long to = -1;
// $NON-NLS-1$
Pattern pattern = Pattern.compile("^\\d{4}\\d{2}\\d{2} \\d{2}:\\d{2}:\\d{2}$");
if (!"".equals(fromText.getText())) {
// $NON-NLS-1$
String dateTimeText = fromText.getText().trim();
Matcher matcher = pattern.matcher(dateTimeText);
if (!matcher.matches()) {
MessageDialog.openWarning(this.getSite().getShell(), Messages.Warning, Messages.DataClusterBrowserMainPage_21);
return new LineItem[0];
}
try {
Date d = sdf.parse(fromText.getText());
from = d.getTime();
} catch (ParseException pe) {
}
}
if (!"".equals(toText.getText())) {
// $NON-NLS-1$
String dateTimeText = toText.getText().trim();
Matcher matcher = pattern.matcher(dateTimeText);
if (!matcher.matches()) {
MessageDialog.openWarning(this.getSite().getShell(), Messages.Warning, Messages.DataClusterBrowserMainPage_23);
return new LineItem[0];
}
try {
Date d = sdf.parse(toText.getText());
to = d.getTime();
} catch (ParseException pe) {
}
}
String concept = conceptCombo.getText();
if ("*".equals(concept) | "".equals(concept)) {
// $NON-NLS-1$ //$NON-NLS-2$
concept = null;
}
if (concept != null) {
// $NON-NLS-1$//$NON-NLS-2$
concept = concept.replaceAll("\\[.*\\]", "").trim();
}
String keys = keyText.getText();
if ("*".equals(keys) | "".equals(keys)) {
// $NON-NLS-1$ //$NON-NLS-2$
keys = null;
}
boolean useFTSearch = isMaster ? checkFTSearchButton.getSelection() : false;
String search = searchText.getText();
if ("*".equals(search) | "".equals(search)) {
// $NON-NLS-1$ //$NON-NLS-2$
search = null;
}
int start = pageToolBar.getStart();
int limit = pageToolBar.getLimit();
// see 0015909
// $NON-NLS-1$
String clusterName = URLEncoder.encode(getXObject().toString(), "utf-8");
WSDataClusterPK clusterPk = new WSDataClusterPK(clusterName + getPkAddition());
// @temp yguo, get item with taskid or get taskid by specify wsitempk.
List<WSItemPKsByCriteriaResponseResults> results = service.getItemPKsByFullCriteria(new WSGetItemPKsByFullCriteria(useFTSearch, new WSGetItemPKsByCriteria(concept, search, from, null, keys, limit, start, to, clusterPk))).getResults();
if (showResultInfo && (results.size() == 1)) {
MessageDialog.openInformation(this.getSite().getShell(), Messages.DataClusterBrowserMainPage_24, Messages.DataClusterBrowserMainPage_25);
return new LineItem[0];
}
if (results.size() == 1) {
return new LineItem[0];
}
int totalSize = 0;
List<LineItem> ress = new ArrayList<LineItem>();
for (int i = 0; i < results.size(); i++) {
WSItemPKsByCriteriaResponseResults result = results.get(i);
if (i == 0) {
totalSize = Integer.parseInt(Util.parse(result.getWsItemPK().getConceptName()).getDocumentElement().getTextContent());
continue;
}
ress.add(new LineItem(result.getDate(), result.getWsItemPK().getConceptName(), result.getWsItemPK().getIds().toArray(new String[0]), result.getTaskId()));
}
pageToolBar.setTotalsize(totalSize);
pageToolBar.refreshUI();
return ress.toArray(new LineItem[ress.size()]);
} catch (Exception e) {
log.error(e.getMessage(), e);
if ((e.getLocalizedMessage() != null) && e.getLocalizedMessage().contains("10000")) {
// $NON-NLS-1$
MessageDialog.openError(this.getSite().getShell(), Messages.DataClusterBrowserMainPage_26, Messages.DataClusterBrowserMainPage_27);
} else if (!Util.handleConnectionException(this.getSite().getShell(), e, Messages.DataClusterBrowserMainPage_28)) {
MessageDialog.openError(this.getSite().getShell(), Messages.DataClusterBrowserMainPage_28, e.getLocalizedMessage());
}
return null;
} finally {
try {
this.getSite().getShell().setCursor(null);
waitCursor.dispose();
} catch (Exception e) {
}
}
}
use of com.amalto.workbench.webservices.WSDataClusterPK in project tmdm-studio-se by Talend.
the class DataClusterDialog method getAllDataContainers.
private boolean getAllDataContainers(List<TreeObject> dataContainers) {
MDMServerDef serverDef = getSelectedMdmServerDef();
String username = serverDef.getUser();
String password = serverDef.getPasswd();
String serverName = serverDef.getName();
String endpointaddress = serverDef.getUrl();
boolean canConnect = checkConnection(endpointaddress, username, password);
if (!canConnect) {
MessageDialog.openError(site.getShell(), Messages.DataClusterDialog_7, Messages.DataClusterDialog_8);
return false;
}
List<WSDataClusterPK> xdcPKs = null;
try {
TMDMService service = Util.getMDMService(new URL(endpointaddress), username, password);
TreeParent serverRoot = new TreeParent(serverName, null, TreeObject._SERVER_, endpointaddress, username + ":" + // $NON-NLS-1$//$NON-NLS-2$
(password == null ? "" : password));
// $NON-NLS-1$
xdcPKs = service.getDataClusterPKs(new WSRegexDataClusterPKs("*")).getWsDataClusterPKs();
for (WSDataClusterPK pk : xdcPKs) {
String name = pk.getPk();
if (!("CACHE".equals(name))) {
// $NON-NLS-1$
WSDataCluster wsObject = null;
boolean retriveWSObject = false;
try {
if (retriveWSObject) {
wsObject = service.getDataCluster(new WSGetDataCluster(pk));
}
TreeObject obj = new TreeObject(name, serverRoot, TreeObject.DATA_CLUSTER, pk, wsObject);
dataContainers.add(obj);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
return false;
}
return true;
}
use of com.amalto.workbench.webservices.WSDataClusterPK in project tmdm-studio-se by Talend.
the class ProjectDecisionDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
// Should not really be here but well,....
parent.getShell().setText(this.title);
Composite composite = (Composite) super.createDialogArea(parent);
GridLayout layout = (GridLayout) composite.getLayout();
layout.numColumns = 2;
try {
// process the decision
// $NON-NLS-1$
String dataClusterName = "";
// $NON-NLS-1$
String dataModelName = "";
boolean doOverwrite = true;
Matcher m = dp.matcher(decision);
if (m.matches()) {
dataClusterName = m.group(1);
dataModelName = m.group(2);
if (m.groupCount() >= 4) {
// $NON-NLS-1$
doOverwrite = (!"false".equals(m.group(3)));
}
}
TMDMService port = Util.getMDMService(new URL(transformerObject.getEndpointAddress()), transformerObject.getUsername(), transformerObject.getPassword());
// Grab the available Clusters
// $NON-NLS-1$
List<WSDataClusterPK> dcpks = port.getDataClusterPKs(new WSRegexDataClusterPKs(".*")).getWsDataClusterPKs();
Label dataClustersLabel = new Label(composite, SWT.NULL);
dataClustersLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
dataClustersLabel.setText(Messages.ProjectDecisionDialog_DataContainers);
dataClustersCombo = new Combo(composite, SWT.DROP_DOWN);
dataClustersCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
int dataClusterSelect = -1;
if (dcpks != null) {
int i = 0;
for (WSDataClusterPK pk : dcpks) {
dataClustersCombo.add(pk.getPk());
if (pk.getPk().equals(dataClusterName)) {
dataClusterSelect = i;
}
i++;
}
}
dataClustersCombo.select(dataClusterSelect);
// Grab the available Models
// $NON-NLS-1$
List<WSDataModelPK> dmpks = port.getDataModelPKs(new WSRegexDataModelPKs(".*")).getWsDataModelPKs();
Label dataModelsLabel = new Label(composite, SWT.NULL);
dataModelsLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
dataModelsLabel.setText(Messages.ProjectDecisionDialog_DataModels);
dataModelsCombo = new Combo(composite, SWT.DROP_DOWN);
dataModelsCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
int dataModelSelect = -1;
if (dmpks != null) {
int i = 0;
for (WSDataModelPK pk : dmpks) {
dataModelsCombo.add(pk.getPk());
if (pk.getPk().equals(dataModelName)) {
dataModelSelect = i;
}
i++;
}
}
dataModelsCombo.select(dataModelSelect);
// Overwrite
Label overwriteLabel = new Label(composite, SWT.NULL);
overwriteLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
overwriteLabel.setText(Messages.ProjectDecisionDialog_Overwrite);
overwriteButton = new Button(composite, SWT.CHECK);
overwriteButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
overwriteButton.setSelection(doOverwrite);
} catch (Exception e) {
if (!Util.handleConnectionException(this.getShell(), e, null)) {
MessageDialog.openError(ProjectDecisionDialog.this.getShell(), Messages.ProjectDecisionDialog_ErrorTitle, Messages.bind(Messages.ProjectDecisionDialog_ErrorMsg, e.getMessage()));
}
}
return composite;
}
use of com.amalto.workbench.webservices.WSDataClusterPK in project tmdm-studio-se by Talend.
the class StoredProcedureMainPage method createCharacteristicsContent.
@Override
protected void createCharacteristicsContent(FormToolkit toolkit, Composite charComposite) {
try {
WSStoredProcedure wsStoredProcedure = (WSStoredProcedure) (getXObject().getWsObject());
// description
Label descriptionLabel = toolkit.createLabel(charComposite, Messages.StoredProcedureMainPage_4, SWT.NULL);
descriptionLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 1, 1));
// $NON-NLS-1$
descriptionText = toolkit.createText(charComposite, "", SWT.BORDER);
descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
// $NON-NLS-1$
descriptionText.setText(wsStoredProcedure.getDescription() == null ? "" : wsStoredProcedure.getDescription());
descriptionText.addModifyListener(this);
// Procedure
Group storedProcedureGroup = new Group(charComposite, SWT.SHADOW_NONE);
storedProcedureGroup.setText(Messages.StoredProcedureMainPage_5);
storedProcedureGroup.setLayout(new GridLayout(1, true));
storedProcedureGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
((GridData) storedProcedureGroup.getLayoutData()).minimumHeight = 100;
procedureViewer = new SourceViewer(storedProcedureGroup, new VerticalRuler(10), SWT.V_SCROLL);
procedureViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
procedureViewer.addTextListener(this);
WidgetUtils.initRedoUndo(procedureViewer);
refreshCacheBtn = toolkit.createButton(charComposite, Messages.StoredProcedureMainPage_6, SWT.CHECK);
refreshCacheBtn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
refreshCacheBtn.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
markDirty();
}
public void widgetDefaultSelected(SelectionEvent e) {
markDirty();
}
});
/**
**********************************************************
* Execute Stored Procedure
***********************************************************
*/
createCompDropTarget();
Composite resultsGroup = this.getNewSectionComposite(Messages.StoredProcedureMainPage_7);
resultsGroup.setLayout(new GridLayout(4, false));
// data cluster
Hyperlink dataClusterLink = toolkit.createHyperlink(resultsGroup, Messages.StoredProcedureMainPage_8, SWT.NULL);
dataClusterLink.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
dataClusterLink.addHyperlinkListener(new IHyperlinkListener() {
public void linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent e) {
}
public void linkExited(org.eclipse.ui.forms.events.HyperlinkEvent e) {
}
public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent e) {
if (!isLocalInput()) {
TreeParent serverRoot = StoredProcedureMainPage.this.getXObject().getServerRoot();
TreeObject iaObject = new TreeObject(StoredProcedureMainPage.this.dataClusterCombo.getText(), serverRoot, TreeObject.DATA_CLUSTER, new WSDataClusterPK(StoredProcedureMainPage.this.dataClusterCombo.getText()), null);
(new EditXObjectAction(iaObject, StoredProcedureMainPage.this.getSite().getPage())).run();
}
}
});
dataClusterCombo = new Combo(resultsGroup, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.SINGLE);
dataClusterCombo.setLayoutData(new GridData(SWT.BEGINNING, SWT.NONE, false, false, 1, 1));
Button executeButton = new Button(resultsGroup, SWT.PUSH);
executeButton.setText(Messages.StoredProcedureMainPage_9);
executeButton.addMouseListener(new MouseListener() {
public void mouseUp(MouseEvent e) {
executeProcedure();
}
public void mouseDoubleClick(MouseEvent e) {
}
public void mouseDown(MouseEvent e) {
}
});
resultsLabel = toolkit.createLabel(resultsGroup, // $NON-NLS-1$
" ", SWT.NULL);
resultsLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false, 1, 1));
resultsViewer = new TableViewer(resultsGroup);
resultsViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
((GridData) resultsViewer.getControl().getLayoutData()).heightHint = 300;
resultsViewer.setContentProvider(new ArrayContentProvider());
resultsViewer.setLabelProvider(new XMLTableLabelProvider());
resultsViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
resultsViewer.setSelection(event.getSelection());
new ResultsViewAction(StoredProcedureMainPage.this.getSite().getShell(), resultsViewer).run();
}
});
hookContextMenu();
refreshData();
dataClusterCombo.select(0);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
Aggregations