Search in sources :

Example 1 with WSRoutingOrderV2

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

the class RoutingEngineV2BrowserMainPage method getResults.

protected WSRoutingOrderV2[] getResults() {
    Cursor waitCursor = null;
    try {
        Display display = getEditor().getSite().getPage().getWorkbenchWindow().getWorkbench().getDisplay();
        waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
        this.getSite().getShell().setCursor(waitCursor);
        TMDMService service = getMDMService();
        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 (!BLANK.equals(fromText.getText())) {
            String dateTimeText = fromText.getText().trim();
            Matcher matcher = pattern.matcher(dateTimeText);
            if (!matcher.matches()) {
                MessageDialog.openWarning(this.getSite().getShell(), Messages.Warning, Messages.RoutingEngineV2BrowserMainPage_FormatIllegal);
                return new WSRoutingOrderV2[0];
            }
            try {
                Date d = sdf.parse(fromText.getText());
                from = d.getTime();
            } catch (ParseException pe) {
            }
        }
        if (!BLANK.equals(toText.getText())) {
            String dateTimeText = toText.getText().trim();
            Matcher matcher = pattern.matcher(dateTimeText);
            if (!matcher.matches()) {
                MessageDialog.openWarning(this.getSite().getShell(), Messages.Warning, Messages.RoutingEngineV2BrowserMainPage_FormatIllegal);
                return new WSRoutingOrderV2[0];
            }
            try {
                Date d = sdf.parse(toText.getText());
                to = d.getTime();
            } catch (ParseException pe) {
            }
        }
        long timeCreatedMin = -1;
        long timeCreatedMax = -1;
        long timeScheduledMin = -1;
        long timeScheduledMax = -1;
        long timeLastRunStartedMin = -1;
        long timeLastRunStartedMax = -1;
        long timeLastRunCompletedMin = -1;
        long timeLastRunCompletedMax = -1;
        WSRoutingOrderV2Status status = null;
        String statusText = statusCombo.getItem(statusCombo.getSelectionIndex());
        if ("COMPLETED".equals(statusText)) {
            // $NON-NLS-1$
            timeLastRunCompletedMin = from;
            timeLastRunCompletedMax = to;
            status = WSRoutingOrderV2Status.COMPLETED;
        } else if ("FAILED".equals(statusText)) {
            // $NON-NLS-1$
            timeLastRunCompletedMin = from;
            timeLastRunCompletedMax = to;
            status = WSRoutingOrderV2Status.FAILED;
        } else {
            throw new XtentisException(Messages.RoutingEngineV2BrowserMainPage_ExceptionInfo + statusText + Messages.RoutingEngineV2BrowserMainPage_ExceptionInfoA);
        }
        String serviceJNDI = serviceCombo.getItem(serviceCombo.getSelectionIndex());
        if (BLANK.equals(serviceJNDI)) {
            serviceJNDI = null;
        }
        int start = pageToolBar.getStart();
        int limit = pageToolBar.getLimit();
        List<WSRoutingOrderV2> wsRoutingOrder = service.getRoutingOrderV2ByCriteriaWithPaging(new WSGetRoutingOrderV2ByCriteriaWithPaging(new WSRoutingOrderV2SearchCriteriaWithPaging(// $NON-NLS-1$
        "*".equals(anyFieldText.getText()) || BLANK.equals(anyFieldText.getText()) ? null : anyFieldText.getText(), // $NON-NLS-1$
        "*".equals(documentTypeText.getText()) || BLANK.equals(documentTypeText.getText()) ? // $NON-NLS-1$
        null : documentTypeText.getText(), // $NON-NLS-1$
        "*".equals(idText.getText()) || BLANK.equals(idText.getText()) ? // $NON-NLS-1$
        null : idText.getText(), limit, null, null, serviceJNDI, null, start, status, timeCreatedMax, timeCreatedMin, timeLastRunCompletedMax, timeLastRunCompletedMin, timeLastRunStartedMax, timeLastRunStartedMin, timeScheduledMax, timeScheduledMin, true))).getWsRoutingOrder();
        if (wsRoutingOrder.size() == 1) {
            MessageDialog.openInformation(this.getSite().getShell(), Messages.RoutingEngineV2BrowserMainPage_Info, Messages.RoutingEngineV2BrowserMainPage_SorryNoResult);
            return new WSRoutingOrderV2[0];
        }
        int totalSize = Integer.parseInt(wsRoutingOrder.get(0).getName());
        pageToolBar.setTotalsize(totalSize);
        pageToolBar.refreshUI();
        WSRoutingOrderV2[] resultOrderV2s = new WSRoutingOrderV2[wsRoutingOrder.size() - 1];
        System.arraycopy(wsRoutingOrder.toArray(new WSRoutingOrderV2[0]), 1, resultOrderV2s, 0, resultOrderV2s.length);
        return resultOrderV2s;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        if ((e.getLocalizedMessage() != null) && e.getLocalizedMessage().contains("10000")) {
            MessageDialog.openError(this.getSite().getShell(), Messages.RoutingEngineV2BrowserMainPage_TooManyResults, Messages.RoutingEngineV2BrowserMainPage_ErrorMsg1);
        } else if (!Util.handleConnectionException(this.getSite().getShell(), e, null)) {
            MessageDialog.openError(this.getSite().getShell(), Messages.ErrorTitle1, e.getLocalizedMessage());
        }
        return null;
    } finally {
        try {
            this.getSite().getShell().setCursor(null);
            if (waitCursor != null) {
                waitCursor.dispose();
            }
        } catch (Exception e) {
        // do nothing
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) WSRoutingOrderV2(com.amalto.workbench.webservices.WSRoutingOrderV2) WSGetRoutingOrderV2ByCriteriaWithPaging(com.amalto.workbench.webservices.WSGetRoutingOrderV2ByCriteriaWithPaging) Cursor(org.eclipse.swt.graphics.Cursor) Date(java.util.Date) XtentisException(com.amalto.workbench.utils.XtentisException) ParseException(java.text.ParseException) WSRoutingOrderV2Status(com.amalto.workbench.webservices.WSRoutingOrderV2Status) TMDMService(com.amalto.workbench.webservices.TMDMService) ParseException(java.text.ParseException) Display(org.eclipse.swt.widgets.Display) XtentisException(com.amalto.workbench.utils.XtentisException) WSRoutingOrderV2SearchCriteriaWithPaging(com.amalto.workbench.webservices.WSRoutingOrderV2SearchCriteriaWithPaging)

Example 2 with WSRoutingOrderV2

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

the class DeleteItemsAction method run.

@Override
public void run() {
    try {
        super.run();
        // retrieve the list of items
        IStructuredSelection selection = ((IStructuredSelection) viewer.getSelection());
        List<WSRoutingOrderV2> lineItems = selection.toList();
        if (lineItems.size() == 0) {
            return;
        }
        if (!MessageDialog.openConfirm(this.shell, Messages.RoutingEngineV2BrowserMainPage_ConfirmDeletion, Messages.bind(Messages.RoutingEngineV2BrowserMainPage_ErrorMsg2, lineItems.size()))) {
            return;
        }
        // Instantiate the Monitor with actual deletes
        DeleteItemsWithProgress diwp = new DeleteItemsWithProgress((TMDMService) routingEngineV2BrowserMainPage.getAdapter(TMDMService.class), lineItems, this.shell);
        // run
        // fork
        new ProgressMonitorDialog(this.shell).run(// fork
        false, // cancelable
        true, diwp);
        // refresh the search
        routingEngineV2BrowserMainPage.doSearch();
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(shell, Messages._Error, Messages.bind(Messages.RoutingEngineV2BrowserMainPage_ErrorMsg3, e.getLocalizedMessage()));
    }
}
Also used : WSRoutingOrderV2(com.amalto.workbench.webservices.WSRoutingOrderV2) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 3 with WSRoutingOrderV2

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

the class EditItemAction method run.

@Override
public void run() {
    try {
        super.run();
        IStructuredSelection selection = ((IStructuredSelection) viewer.getSelection());
        if (selection.isEmpty()) {
            return;
        }
        WSRoutingOrderV2 routingOrder = (WSRoutingOrderV2) selection.getFirstElement();
        StringWriter sw = new StringWriter();
        Marshaller.marshal(routingOrder, sw);
        final DOMViewDialog d = new DOMViewDialog(shell, Util.parse(sw.toString()));
        d.addListener(new Listener() {

            public void handleEvent(Event event) {
                d.close();
            }
        });
        d.setBlockOnOpen(true);
        d.open();
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(shell, Messages._Error, Messages.bind(Messages.RoutingEngineV2BrowserMainPage_ErrorToViewRoutingOrder, e.getLocalizedMessage()));
    }
}
Also used : Listener(org.eclipse.swt.widgets.Listener) StringWriter(java.io.StringWriter) WSRoutingOrderV2(com.amalto.workbench.webservices.WSRoutingOrderV2) Event(org.eclipse.swt.widgets.Event) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DOMViewDialog(com.amalto.workbench.dialogs.DOMViewDialog)

Example 4 with WSRoutingOrderV2

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

the class ExecuteRoutingOrdersAction method run.

@Override
public void run() {
    try {
        super.run();
        // retrieve the list of items
        IStructuredSelection selection = ((IStructuredSelection) viewer.getSelection());
        List<WSRoutingOrderV2> lineItems = selection.toList();
        if (lineItems.size() == 0) {
            return;
        }
        if (!MessageDialog.openConfirm(this.shell, Messages.RoutingEngineV2BrowserMainPage_ConfirmTitle, Messages.RoutingEngineV2BrowserMainPage_ConfirmContent + (synchronously ? Messages.RoutingEngineV2BrowserMainPage_Text2 : Messages.RoutingEngineV2BrowserMainPage_Text3) + Messages.RoutingEngineV2BrowserMainPage_ConfirmContentA + lineItems.size() + Messages.RoutingEngineV2BrowserMainPage_B)) {
            return;
        }
        // Instantiate the Monitor with actual deletes
        ExecuteRoutingOrdersWithProgress diwp = new ExecuteRoutingOrdersWithProgress((TMDMService) routingEngineV2BrowserMainPage.getAdapter(TMDMService.class), lineItems, this.shell);
        // run
        // fork
        new ProgressMonitorDialog(this.shell).run(// fork
        false, // cancelable
        true, diwp);
        // refresh the search
        routingEngineV2BrowserMainPage.doSearch();
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(shell, Messages._Error, Messages.bind(Messages.RoutingEngineV2BrowserMainPage_ErrorMsg4, e.getLocalizedMessage()));
    }
}
Also used : WSRoutingOrderV2(com.amalto.workbench.webservices.WSRoutingOrderV2) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

WSRoutingOrderV2 (com.amalto.workbench.webservices.WSRoutingOrderV2)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)2 DOMViewDialog (com.amalto.workbench.dialogs.DOMViewDialog)1 XtentisException (com.amalto.workbench.utils.XtentisException)1 TMDMService (com.amalto.workbench.webservices.TMDMService)1 WSGetRoutingOrderV2ByCriteriaWithPaging (com.amalto.workbench.webservices.WSGetRoutingOrderV2ByCriteriaWithPaging)1 WSRoutingOrderV2SearchCriteriaWithPaging (com.amalto.workbench.webservices.WSRoutingOrderV2SearchCriteriaWithPaging)1 WSRoutingOrderV2Status (com.amalto.workbench.webservices.WSRoutingOrderV2Status)1 StringWriter (java.io.StringWriter)1 ParseException (java.text.ParseException)1 Date (java.util.Date)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 Cursor (org.eclipse.swt.graphics.Cursor)1 Display (org.eclipse.swt.widgets.Display)1 Event (org.eclipse.swt.widgets.Event)1 Listener (org.eclipse.swt.widgets.Listener)1