Search in sources :

Example 1 with WSPutItem

use of com.amalto.workbench.webservices.WSPutItem 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()));
        }
    }
}
Also used : WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) WSPutItem(com.amalto.workbench.webservices.WSPutItem) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) WSDataModelPK(com.amalto.workbench.webservices.WSDataModelPK)

Example 2 with WSPutItem

use of com.amalto.workbench.webservices.WSPutItem in project tmdm-studio-se by Talend.

the class NewItemHandler method createItemRecord.

public boolean createItemRecord(final TMDMService service, final Shell ashell, final WSDataClusterPK wsDataClusterPK, boolean isMaster) {
    if (service == null || wsDataClusterPK == null) {
        throw new IllegalArgumentException();
    }
    final Shell shell = ashell != null ? ashell : Display.getCurrent().getActiveShell();
    try {
        // $NON-NLS-1$
        String xml = "<NewItem><NewElement></NewElement></NewItem>";
        // $NON-NLS-1$
        WSDataModelPKArray dataModelPKs = service.getDataModelPKs(new WSRegexDataModelPKs("*"));
        List<WSDataModelPK> dmPKs = dataModelPKs.getWsDataModelPKs();
        List<String> dataModels = new ArrayList<String>();
        if (dmPKs != null) {
            for (WSDataModelPK pk : dmPKs) {
                if (!"XMLSCHEMA---".equals(pk.getPk())) {
                    // $NON-NLS-1$
                    dataModels.add(pk.getPk());
                }
            }
        }
        final DataContainerDOMViewDialog d = new DataContainerDOMViewDialog(shell, service, Util.parse(xml), dataModels, DOMViewDialog.SOURCE_VIEWER, null, isMaster);
        d.addListener(new Listener() {

            public void handleEvent(Event event) {
                if (event.button == DOMViewDialog.BUTTON_SAVE) {
                    // attempt to save
                    try {
                        WSPutItem putItem = new WSPutItem(false, wsDataClusterPK, // $NON-NLS-1$
                        "".equals(d.getDataModelName()) ? // $NON-NLS-1$
                        null : new WSDataModelPK(d.getDataModelName()), d.getXML());
                        // $NON-NLS-1$
                        WSPutItemWithReport item = new WSPutItemWithReport(d.isBeforeVerification(), "genericUI", putItem);
                        if (d.isTriggerProcess()) {
                            service.putItemWithReport(item);
                        } else {
                            service.putItem(putItem);
                        }
                        created = true;
                    } catch (Exception e) {
                        log.error(e.getMessage(), e);
                        MessageDialog.openError(shell, Messages.DataClusterBrowserMainPage_100, Messages.bind(Messages.DataClusterBrowserMainPage_101, Util.formatErrorMessage(e.getLocalizedMessage())));
                        return;
                    }
                }
                d.close();
            }
        });
        d.setBlockOnOpen(true);
        d.open();
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        if (!Util.handleConnectionException(shell, e, null)) {
            MessageDialog.openError(shell, Messages._Error, Messages.bind(Messages.DataClusterBrowserMainPage_103, e.getLocalizedMessage()));
        }
    }
    return created;
}
Also used : Listener(org.eclipse.swt.widgets.Listener) WSPutItem(com.amalto.workbench.webservices.WSPutItem) ArrayList(java.util.ArrayList) Shell(org.eclipse.swt.widgets.Shell) DataContainerDOMViewDialog(com.amalto.workbench.dialogs.datacontainer.DataContainerDOMViewDialog) WSDataModelPKArray(com.amalto.workbench.webservices.WSDataModelPKArray) WSRegexDataModelPKs(com.amalto.workbench.webservices.WSRegexDataModelPKs) Event(org.eclipse.swt.widgets.Event) WSPutItemWithReport(com.amalto.workbench.webservices.WSPutItemWithReport) WSDataModelPK(com.amalto.workbench.webservices.WSDataModelPK)

Aggregations

WSDataModelPK (com.amalto.workbench.webservices.WSDataModelPK)2 WSPutItem (com.amalto.workbench.webservices.WSPutItem)2 DataContainerDOMViewDialog (com.amalto.workbench.dialogs.datacontainer.DataContainerDOMViewDialog)1 WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)1 WSDataModelPKArray (com.amalto.workbench.webservices.WSDataModelPKArray)1 WSPutItemWithReport (com.amalto.workbench.webservices.WSPutItemWithReport)1 WSRegexDataModelPKs (com.amalto.workbench.webservices.WSRegexDataModelPKs)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 CoreException (org.eclipse.core.runtime.CoreException)1 Event (org.eclipse.swt.widgets.Event)1 Listener (org.eclipse.swt.widgets.Listener)1 Shell (org.eclipse.swt.widgets.Shell)1