Search in sources :

Example 1 with WSWhereCondition

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

the class Util method convertLine.

public static WSWhereCondition convertLine(String[] values) {
    WSWhereCondition wc = new WSWhereCondition();
    wc.setLeftPath(values[0]);
    WSWhereOperator operator = null;
    if (values[1].equals("Contains")) {
        // $NON-NLS-1$
        operator = WSWhereOperator.CONTAINS;
    } else if (values[1].equals("contains the sentence")) {
        // $NON-NLS-1$
        operator = WSWhereOperator.CONTAINS_SENTENCE;
    } else if (values[1].equals("Join With")) {
        // $NON-NLS-1$
        operator = WSWhereOperator.JOIN;
    } else if (values[1].equals("=")) {
        // $NON-NLS-1$
        operator = WSWhereOperator.EQUALS;
    } else if (values[1].equals(">")) {
        // $NON-NLS-1$
        operator = WSWhereOperator.GREATER_THAN;
    } else if (values[1].equals(">=")) {
        // $NON-NLS-1$
        operator = WSWhereOperator.GREATER_THAN_OR_EQUAL;
    } else if (values[1].equals("<")) {
        // $NON-NLS-1$
        operator = WSWhereOperator.LOWER_THAN;
    } else if (values[1].equals("<=")) {
        // $NON-NLS-1$
        operator = WSWhereOperator.LOWER_THAN_OR_EQUAL;
    } else if (values[1].equals("!=")) {
        // $NON-NLS-1$
        operator = WSWhereOperator.NOT_EQUALS;
    } else if (values[1].equals("Starts With")) {
        // $NON-NLS-1$
        operator = WSWhereOperator.STARTSWITH;
    } else if (values[1].equals("Is Empty Or Null")) {
        // $NON-NLS-1$
        operator = WSWhereOperator.EMPTY_NULL;
    } else if (values[1].equals("whole content contains")) {
        // $NON-NLS-1$
        operator = WSWhereOperator.FULLTEXTSEARCH;
    }
    wc.setOperator(operator);
    wc.setRightValueOrPath(values[2]);
    WSStringPredicate predicate = null;
    if (values[3].equals("")) {
        // $NON-NLS-1$
        predicate = WSStringPredicate.NONE;
    } else if (values[3].equals("Or")) {
        // $NON-NLS-1$
        predicate = WSStringPredicate.OR;
    }
    if (values[3].equals("And")) {
        // $NON-NLS-1$
        predicate = WSStringPredicate.AND;
    }
    if (values[3].equals("Not")) {
        // $NON-NLS-1$
        predicate = WSStringPredicate.NOT;
    }
    wc.setStringPredicate(predicate);
    return wc;
}
Also used : WSWhereOperator(com.amalto.workbench.webservices.WSWhereOperator) WSStringPredicate(com.amalto.workbench.webservices.WSStringPredicate) WSWhereCondition(com.amalto.workbench.webservices.WSWhereCondition)

Example 2 with WSWhereCondition

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

the class ViewMainPage method refreshData.

@Override
protected void refreshData() {
    try {
        if (this.comitting) {
            return;
        }
        this.refreshing = true;
        WSView wsObject = getWsViewObject();
        // $NON-NLS-1$
        desAntionComposite.setText(wsObject.getDescription() == null ? "" : wsObject.getDescription());
        btnRunProcess.setSelection(wsObject.getIsTransformerActive().isTrue());
        if (btnRunProcess.getSelection()) {
            cboProcessList.setEnabled(true);
            cboProcessList.setText(wsObject.getTransformerPK());
        } else {
            cboProcessList.setEnabled(false);
            // $NON-NLS-1$
            cboProcessList.setText("");
        }
        // /////////////////////
        combox_sortdirection.add(SORTING_DIRECTION[0]);
        combox_sortdirection.add(SORTING_DIRECTION[1]);
        String sortField = wsObject.getSortField();
        WSBoolean ascOrder = wsObject.getIsAsc();
        if (sortField == null || sortField.trim().isEmpty()) {
            sortField = SORT_FIELD[0];
        }
        lastSortField = sortField;
        String[] policys = { SORT_FIELD[0], SORT_FIELD[1], selectXPath };
        if (sortField.equals(SORT_FIELD[0]) || sortField.equals(SORT_FIELD[1])) {
            combox_sortdirection.setVisible(false);
        } else {
            policys = new String[] { SORT_FIELD[0], SORT_FIELD[1], sortField, selectXPath };
            combox_sortdirection.setVisible(true);
            if (ascOrder == null || ascOrder.isTrue()) {
                combox_sortdirection.setText(SORTING_DIRECTION[0]);
            } else {
                combox_sortdirection.setText(SORTING_DIRECTION[1]);
            }
        }
        combox_policy.setItems(policys);
        combox_policy.setText(sortField);
        if (adapter != null) {
            adapter.refreshData(wsObject);
        }
        // //////////////////
        java.util.List<Line> vlines = new ArrayList<Line>();
        java.util.List<String> vis = wsObject.getViewableBusinessElements();
        if (vis != null) {
            for (String vi : vis) {
                String[] strings = new String[] { vi };
                Line line = new Line(viewableElementColumns, strings);
                vlines.add(line);
            }
        }
        viewableViewer.getViewer().setInput(vlines);
        java.util.List<Line> slines = new ArrayList<Line>();
        java.util.List<String> ses = wsObject.getSearchableBusinessElements();
        if (ses != null) {
            for (String se : ses) {
                String[] strings = new String[] { se };
                Line line = new Line(searchableElementColumns, strings);
                slines.add(line);
            }
        }
        searchableViewer.getViewer().setInput(slines);
        java.util.List<Line> lines = new ArrayList<Line>();
        for (WSWhereCondition wc : wsObject.getWhereConditions()) {
            Line line = new Line(conditionsColumns, Util.convertWhereCondition(wc));
            lines.add(line);
        }
        conditionViewer.getViewer().setInput(lines);
        this.refreshing = false;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(this.getSite().getShell(), Messages.ViewMainPage_ErrorRefreshPage, Messages.bind(Messages.ViewMainPage_ErrorRefreshPageXX, e.getLocalizedMessage()));
    }
}
Also used : Line(com.amalto.workbench.models.Line) WSWhereCondition(com.amalto.workbench.webservices.WSWhereCondition) ArrayList(java.util.ArrayList) WSBoolean(com.amalto.workbench.webservices.WSBoolean) WSView(com.amalto.workbench.webservices.WSView) XtentisException(com.amalto.workbench.utils.XtentisException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 3 with WSWhereCondition

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

the class ViewMainPage method commit.

@Override
protected void commit() {
    try {
        if (this.refreshing) {
            return;
        }
        this.comitting = true;
        WSView wsObject = getWsViewObject();
        wsObject.setDescription(desAntionComposite.getText());
        wsObject.setIsTransformerActive(new WSBoolean(btnRunProcess.getSelection()));
        wsObject.setTransformerPK(cboProcessList.getText());
        String policy = combox_policy.getText();
        if (policy.equals(SORT_FIELD[0])) {
            policy = null;
        }
        wsObject.setSortField(policy);
        boolean visible = combox_sortdirection.isVisible();
        if (visible) {
            boolean isAscOrder = combox_sortdirection.getText().equals(SORTING_DIRECTION[0]);
            wsObject.setIsAsc(new WSBoolean(isAscOrder));
        } else {
            wsObject.setIsAsc(null);
        }
        if (adapter != null) {
            adapter.saveData(wsObject);
        }
        java.util.List<Line> vlines = (java.util.List<Line>) viewableViewer.getViewer().getInput();
        wsObject.getViewableBusinessElements().clear();
        for (Line item : vlines) {
            wsObject.getViewableBusinessElements().add(item.keyValues.get(0).value);
        }
        java.util.List<Line> slines = (java.util.List<Line>) searchableViewer.getViewer().getInput();
        wsObject.getSearchableBusinessElements().clear();
        for (Line item : slines) {
            wsObject.getSearchableBusinessElements().add(item.keyValues.get(0).value);
        }
        java.util.List<Line> lines = (java.util.List<Line>) conditionViewer.getViewer().getInput();
        java.util.List<WSWhereCondition> wclist = new ArrayList<WSWhereCondition>();
        wsObject.getWhereConditions().clear();
        for (Line item : lines) {
            String[] values = new String[] { item.keyValues.get(0).value, item.keyValues.get(1).value, item.keyValues.get(2).value, item.keyValues.get(3).value };
            WSWhereCondition wc = Util.convertLine(values);
            wsObject.getWhereConditions().add(wc);
        }
        this.comitting = false;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(this.getSite().getShell(), Messages.ViewMainPage_ErrorCommitPage, Messages.bind(Messages.ViewMainPage_ErrorCommitPageXX, e.getLocalizedMessage()));
    }
}
Also used : WSWhereCondition(com.amalto.workbench.webservices.WSWhereCondition) ArrayList(java.util.ArrayList) WSView(com.amalto.workbench.webservices.WSView) XtentisException(com.amalto.workbench.utils.XtentisException) InvocationTargetException(java.lang.reflect.InvocationTargetException) Line(com.amalto.workbench.models.Line) List(org.eclipse.swt.widgets.List) ArrayList(java.util.ArrayList) WSBoolean(com.amalto.workbench.webservices.WSBoolean)

Example 4 with WSWhereCondition

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

the class UtilTest method testConvertWhereCondition.

@Test
public void testConvertWhereCondition() {
    // $NON-NLS-1$ //$NON-NLS-2$
    WSWhereCondition wc = new WSWhereCondition("Entity/Id", WSWhereOperator.CONTAINS, "id1", false, WSStringPredicate.OR);
    String[] lines = Util.convertWhereCondition(wc);
    assertEquals(lines.length, 4);
    // $NON-NLS-1$
    assertEquals(lines[0], "Entity/Id");
    // $NON-NLS-1$
    assertEquals(lines[1], "Contains");
    // $NON-NLS-1$
    assertEquals(lines[2], "id1");
    // $NON-NLS-1$
    assertEquals(lines[3], "Or");
}
Also used : WSWhereCondition(com.amalto.workbench.webservices.WSWhereCondition) Test(org.junit.Test)

Example 5 with WSWhereCondition

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

the class UtilTest method testConvertLine.

@Test
public void testConvertLine() {
    // $NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    String[] values = { "Entity/Id", "Contains", "id1", "Or" };
    WSWhereCondition wc = Util.convertLine(values);
    // $NON-NLS-1$
    assertEquals(wc.getLeftPath(), "Entity/Id");
    // $NON-NLS-1$
    assertEquals(wc.getOperator().value(), "CONTAINS");
    // $NON-NLS-1$
    assertEquals(wc.getRightValueOrPath(), "id1");
    // $NON-NLS-1$
    assertEquals(wc.getStringPredicate().value(), "OR");
}
Also used : WSWhereCondition(com.amalto.workbench.webservices.WSWhereCondition) Test(org.junit.Test)

Aggregations

WSWhereCondition (com.amalto.workbench.webservices.WSWhereCondition)7 XtentisException (com.amalto.workbench.utils.XtentisException)4 WSView (com.amalto.workbench.webservices.WSView)4 ArrayList (java.util.ArrayList)4 Line (com.amalto.workbench.models.Line)2 WSBoolean (com.amalto.workbench.webservices.WSBoolean)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 MalformedURLException (java.net.MalformedURLException)2 List (org.eclipse.swt.widgets.List)2 Test (org.junit.Test)2 IXObjectModelListener (com.amalto.workbench.models.IXObjectModelListener)1 TreeObject (com.amalto.workbench.models.TreeObject)1 TMDMService (com.amalto.workbench.webservices.TMDMService)1 WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)1 WSQuickSearch (com.amalto.workbench.webservices.WSQuickSearch)1 WSStringPredicate (com.amalto.workbench.webservices.WSStringPredicate)1 WSViewSearch (com.amalto.workbench.webservices.WSViewSearch)1 WSWhereAnd (com.amalto.workbench.webservices.WSWhereAnd)1 WSWhereItem (com.amalto.workbench.webservices.WSWhereItem)1 WSWhereOperator (com.amalto.workbench.webservices.WSWhereOperator)1