Search in sources :

Example 31 with ServoyException

use of com.servoy.j2db.util.ServoyException in project servoy-client by Servoy.

the class JSSolutionModel method removeRelation.

/**
 * Removes the relation specified by name. You cannot remove the relation if it is touched within the application.
 * So even if you remove all the ui elements using it, like tabs, it still can't be removed, because of underlying created and cached data.
 *
 * @sample
 * var success = solutionModel.removeRelation('myRelation');
 * if (success) { application.output("Relation has been removed");}
 * else {application.output("Relation could not be removed");}
 *
 * @param name the name of the relation to be removed
 *
 * @return true if the removal was successful, false otherwise
 */
@JSFunction
public boolean removeRelation(String name) {
    FlattenedSolution fs = application.getFlattenedSolution();
    Relation rel = fs.getRelation(name);
    if (rel != null) {
        try {
            if (((FoundSetManager) application.getFoundSetManager()).getSQLGenerator().getCachedTableSQLSheet(rel.getForeignDataSource()).getRelatedSQLDescription(name) != null) {
                return false;
            }
            fs.deletePersistCopy(rel, false);
        } catch (ServoyException e) {
            Debug.error(e);
            return false;
        }
        return true;
    }
    return false;
}
Also used : ISMRelation(com.servoy.j2db.solutionmodel.ISMRelation) Relation(com.servoy.j2db.persistence.Relation) FlattenedSolution(com.servoy.j2db.FlattenedSolution) ServoyException(com.servoy.j2db.util.ServoyException) JSFunction(org.mozilla.javascript.annotations.JSFunction)

Example 32 with ServoyException

use of com.servoy.j2db.util.ServoyException in project servoy-client by Servoy.

the class JSCalculation method setCode.

@JSSetter
public void setCode(String code) {
    checkModification();
    String name = JSMethod.parseName(code);
    if (!name.equals(scriptCalculation.getName())) {
        try {
            scriptCalculation.updateName(new ScriptNameValidator(application.getFlattenedSolution()), name);
        } catch (RepositoryException e) {
            // $NON-NLS-1$ //$NON-NLS-2$
            throw new RuntimeException("Error updating the name from " + scriptCalculation.getName() + " to " + name, e);
        }
    }
    scriptCalculation.setDeclaration(code);
    try {
        TableScope tableScope = (TableScope) application.getScriptEngine().getTableScope(scriptCalculation.getTable());
        if (tableScope != null) {
            tableScope.put(scriptCalculation, scriptCalculation);
            String dataSource = scriptCalculation.getTable().getDataSource();
            FoundSetManager fsm = (FoundSetManager) application.getFoundSetManager();
            fsm.flushSQLSheet(dataSource);
            fsm.getRowManager(dataSource).clearCalcs(null, Arrays.asList(scriptCalculation.getName()));
        }
    } catch (ServoyException e) {
        Debug.error(e);
    }
}
Also used : FoundSetManager(com.servoy.j2db.dataprocessing.FoundSetManager) TableScope(com.servoy.j2db.scripting.TableScope) RepositoryException(com.servoy.j2db.persistence.RepositoryException) ScriptNameValidator(com.servoy.j2db.persistence.ScriptNameValidator) ServoyException(com.servoy.j2db.util.ServoyException) JSSetter(org.mozilla.javascript.annotations.JSSetter)

Example 33 with ServoyException

use of com.servoy.j2db.util.ServoyException in project servoy-client by Servoy.

the class CellAdapter method getTableCellRendererComponent.

/*
	 * @see TableCellRenderer#getTableCellRendererComponent(JTable, Object, boolean, boolean, int, int)
	 */
public Component getTableCellRendererComponent(JTable jtable, Object value, boolean isSelected, boolean hasFocus, final int row, final int column) {
    if (renderer == null || !isVisible(renderer) || !(jtable.getModel() instanceof IFoundSetInternal)) {
        return empty;
    }
    final ISwingFoundSet foundset = (ISwingFoundSet) jtable.getModel();
    if (foundset != tableViewFoundset) {
        // foundset changed
        this.tableViewFoundset = foundset;
        rowAndDataprovider.clear();
    }
    final IRecordInternal state;
    try {
        state = foundset.getRecord(row);
    } catch (RuntimeException re) {
        // $NON-NLS-1$
        Debug.error("Error getting row ", re);
        return empty;
    }
    RenderEventExecutor renderEventExecutor = null;
    IScriptRenderMethods renderable = null;
    if (renderer instanceof IScriptableProvider) {
        IScriptable scriptable = ((IScriptableProvider) renderer).getScriptObject();
        if (scriptable instanceof ISupportOnRenderCallback) {
            renderEventExecutor = ((ISupportOnRenderCallback) scriptable).getRenderEventExecutor();
            renderable = ((ISupportOnRenderCallback) scriptable).getRenderable();
        }
    }
    Color bgColor = getBgColor(jtable, isSelected, row, false);
    if (bgColor != null && renderer instanceof JComponent)
        ((JComponent) renderer).setOpaque(true);
    Color fgColor = getFgColor(jtable, isSelected, row);
    Font font = getFont(jtable, isSelected, row);
    // so that getLocation and getWidth in scripting on tableviews do work.
    if (editor != null && editor.getParent() == null) {
        Rectangle cellRect = jtable.getCellRect(row, column, false);
        editor.setLocation(cellRect.x, cellRect.y);
        editor.setSize(cellRect.width, cellRect.height);
    }
    boolean isRenderWithOnRender = renderEventExecutor != null && renderEventExecutor.hasRenderCallback() && renderable instanceof RenderableWrapper;
    Color renderBgColor = null;
    if (isSelected) {
        if (!isRenderWithOnRender || renderEventExecutor.isDifferentRenderState(state, row, isSelected)) {
            Color tableSelectionColor = jtable.getSelectionForeground();
            if (bgColor != null) {
                tableSelectionColor = adjustColorDifference(bgColor, tableSelectionColor);
            }
            ((RenderableWrapper) renderable).clearProperty(RenderableWrapper.PROPERTY_FGCOLOR);
            renderer.setForeground(fgColor != null ? fgColor : tableSelectionColor);
            ((RenderableWrapper) renderable).clearProperty(RenderableWrapper.PROPERTY_BGCOLOR);
            renderBgColor = (bgColor != null ? bgColor : jtable.getSelectionBackground());
            renderer.setBackground(renderBgColor);
            if (font != null) {
                ((RenderableWrapper) renderable).clearProperty(RenderableWrapper.PROPERTY_FONT);
                renderer.setFont(font);
            }
        } else if (isRenderWithOnRender && foundset.getSize() == 1) {
            // if the foundset contains a single record, we need to force trigger onRender
            // because renderEventExecutor refers already to the changed render state
            renderEventExecutor.setRenderStateChanged();
        }
    } else {
        if (isRenderWithOnRender) {
            if (renderEventExecutor.isDifferentRenderState(state, row, isSelected)) {
                Color newBGColor = bgColor != null ? bgColor : componentBgColor;
                if (newBGColor != null) {
                    ((RenderableWrapper) renderable).clearProperty(RenderableWrapper.PROPERTY_BGCOLOR);
                    renderBgColor = newBGColor;
                    renderer.setBackground(renderBgColor);
                }
                Color newFGColor = fgColor != null ? fgColor : componentFgColor;
                if (newFGColor != null) {
                    ((RenderableWrapper) renderable).clearProperty(RenderableWrapper.PROPERTY_FGCOLOR);
                    renderer.setForeground(newFGColor);
                } else if (newBGColor != null) {
                    renderer.setForeground(adjustColorDifference(newBGColor, jtable.getForeground()));
                }
                Font newFont = font != null ? font : componentFont;
                if (newFont != null) {
                    ((RenderableWrapper) renderable).clearProperty(RenderableWrapper.PROPERTY_FONT);
                    renderer.setFont(newFont);
                }
            }
        } else {
            // now get the editors background. if we don't do that then scripting doesn't show up
            Color background = editor.getBackground();
            if (background != null && !background.equals(lastEditorBgColor)) {
                unselectedBackground = background;
                lastEditorBgColor = background;
            }
            Font editorFont = editor.getFont();
            if (editorFont != null && !editorFont.equals(lastEditorFont)) {
                unselectedFont = editorFont;
            }
            if (editor instanceof IDisplayData && ((IDisplayData) editor).isValueValid() || !(editor instanceof IDisplayData)) {
                Color foreground = editor.getForeground();
                if (foreground != null && !foreground.equals(lastEditorFgColor)) {
                    unselectedForeground = foreground;
                }
                Color currentForeground = (fgColor != null ? fgColor : (unselectedForeground != null) ? unselectedForeground : jtable.getForeground());
                renderer.setForeground(currentForeground);
            }
            Color currentColor = (bgColor != null ? bgColor : (unselectedBackground != null) ? unselectedBackground : jtable.getBackground());
            renderer.setBackground(currentColor);
            Font currentFont = (font != null ? font : (unselectedFont != null) ? unselectedFont : jtable.getFont());
            renderer.setFont(currentFont);
        }
    }
    if (renderer instanceof JComponent) {
        applyRowBorder((JComponent) renderer, jtable, isSelected, row, hasFocus);
    }
    // $NON-NLS-1$
    boolean printing = Utils.getAsBoolean(application.getRuntimeProperties().get("isPrinting"));
    if (renderEventExecutor != null && renderEventExecutor.hasRenderCallback()) {
        renderEventExecutor.setRenderState(state, row, isSelected, true);
    }
    if (renderer instanceof IDisplayRelatedData) {
        IDisplayRelatedData drd = (IDisplayRelatedData) renderer;
        String relationName = drd.getSelectedRelationName();
        if (state != null) {
            if (relationName != null) {
                if (!printing && !state.isRelatedFoundSetLoaded(relationName, null)) {
                    IApplication app = dal.getApplication();
                    ((IDisplayData) renderer).setValueObject(null);
                    // $NON-NLS-1$ //$NON-NLS-2$
                    String key = row + "_" + relationName + "_" + null;
                    if (!rowAndDataprovider.contains(key)) {
                        rowAndDataprovider.add(key);
                        Runnable r = new ASynchonizedCellLoad(app, jtable, foundset, row, jtable.convertColumnIndexToModel(column), relationName, drd.getDefaultSort(), null);
                        app.getScheduledExecutor().execute(r);
                    }
                    return renderer.isVisible() ? renderer : empty;
                }
            }
            drd.setRecord(state, true);
        }
    }
    if (renderer instanceof IDisplayData) {
        if (state != null) {
            Object data = null;
            if (dataProviderID != null) {
                int index = -1;
                if (!printing && (index = dataProviderID.indexOf('.')) > 0) {
                    if (!ScopesUtils.isVariableScope(dataProviderID)) {
                        String partName = dataProviderID.substring(0, index);
                        final String restName = dataProviderID.substring(index + 1);
                        String relationName = partName;
                        if (relationName != null && !state.isRelatedFoundSetLoaded(relationName, restName)) {
                            IApplication app = dal.getApplication();
                            ((IDisplayData) renderer).setValueObject(null);
                            // $NON-NLS-1$ //$NON-NLS-2$
                            String key = row + "_" + relationName + "_" + restName;
                            if (!rowAndDataprovider.contains(key)) {
                                rowAndDataprovider.add(key);
                                List<SortColumn> defaultPKSortColumns = null;
                                try {
                                    defaultPKSortColumns = app.getFoundSetManager().getDefaultPKSortColumns(app.getFlattenedSolution().getRelation(relationName).getForeignDataSource());
                                } catch (ServoyException e) {
                                    Debug.error(e);
                                }
                                Runnable r = new ASynchonizedCellLoad(app, jtable, foundset, row, jtable.convertColumnIndexToModel(column), relationName, defaultPKSortColumns, restName);
                                app.getScheduledExecutor().execute(r);
                            }
                            return renderer.isVisible() ? renderer : empty;
                        }
                        IFoundSetInternal rfs = state.getRelatedFoundSet(relationName);
                        if (rfs != null) {
                            int selected = rfs.getSelectedIndex();
                            // should still go through record 0
                            if (selected == -1 && rfs.getSize() > 0) {
                                selected = 0;
                            }
                            final IRecordInternal relState = rfs.getRecord(selected);
                            if (testCalc(restName, relState, row, jtable.convertColumnIndexToModel(column), foundset))
                                return renderer;
                        }
                    }
                }
                if (!((IDisplayData) renderer).needEntireState() && !printing && testCalc(dataProviderID, state, row, jtable.convertColumnIndexToModel(column), foundset)) {
                    return renderer;
                }
                try {
                    data = dal.getValueObject(state, dataProviderID);
                } catch (IllegalArgumentException iae) {
                    Debug.error(iae);
                    // $NON-NLS-1$
                    data = "<conversion error>";
                }
            }
            ((IDisplayData) renderer).setTagResolver(new ITagResolver() {

                public String getStringValue(String nm) {
                    return TagResolver.formatObject(dal.getValueObject(state, nm), dal.getApplication());
                }
            });
            if (data instanceof DbIdentValue) {
                data = ((DbIdentValue) data).getPkValue();
            }
            convertAndSetValue(((IDisplayData) renderer), data);
        }
    }
    if (renderer instanceof IServoyAwareBean && state != null) {
        ((IServoyAwareBean) renderer).setSelectedRecord(new ServoyBeanState(state, dal.getFormScope()));
    }
    if (!(renderer instanceof IDisplayData) && !(renderer instanceof IDisplayRelatedData) && renderEventExecutor != null && renderEventExecutor.hasRenderCallback()) {
        renderEventExecutor.fireOnRender(false);
    }
    // if the bgcolor is not changed during onRender
    if (isRenderWithOnRender && renderBgColor != null && ((RenderableWrapper) renderable).getProperty(RenderableWrapper.PROPERTY_BGCOLOR) == null) {
        renderer.setBackground(renderBgColor);
    }
    return renderer.isVisible() ? renderer : empty;
}
Also used : IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal) Rectangle(java.awt.Rectangle) ISupportOnRenderCallback(com.servoy.j2db.ui.ISupportOnRenderCallback) SortColumn(com.servoy.j2db.dataprocessing.SortColumn) Font(java.awt.Font) ServoyException(com.servoy.j2db.util.ServoyException) IScriptRenderMethods(com.servoy.j2db.ui.IScriptRenderMethods) IDisplayRelatedData(com.servoy.j2db.dataprocessing.IDisplayRelatedData) IServoyAwareBean(com.servoy.j2db.dataui.IServoyAwareBean) DbIdentValue(com.servoy.j2db.dataprocessing.ValueFactory.DbIdentValue) RenderableWrapper(com.servoy.j2db.ui.RenderableWrapper) IScriptableProvider(com.servoy.j2db.scripting.IScriptableProvider) IRecordInternal(com.servoy.j2db.dataprocessing.IRecordInternal) ITagResolver(com.servoy.base.util.ITagResolver) Color(java.awt.Color) JComponent(javax.swing.JComponent) ISwingFoundSet(com.servoy.j2db.dataprocessing.ISwingFoundSet) IScriptable(com.servoy.j2db.scripting.IScriptable) Point(java.awt.Point) IApplication(com.servoy.j2db.IApplication) ServoyBeanState(com.servoy.j2db.component.ServoyBeanState) RenderEventExecutor(com.servoy.j2db.ui.RenderEventExecutor) IDisplayData(com.servoy.j2db.dataprocessing.IDisplayData) EventObject(java.util.EventObject)

Example 34 with ServoyException

use of com.servoy.j2db.util.ServoyException in project servoy-client by Servoy.

the class FoundsetTest method fillTestSolution.

@Override
protected void fillTestSolution() throws ServoyException {
    try {
        Form form = solution.createNewForm(validator, null, "test", "mem:test", false, new Dimension(600, 400));
        form.setNavigatorID(-1);
        form.createNewPart(IBaseSMPart.BODY, 5);
        WebComponent bean = form.createNewWebComponent("mycustombean", "my-component");
        bean.setProperty("myfoundset", new ServoyJSONObject("{foundsetSelector:'',dataproviders:{firstname:'test1',lastname:'test2'}}", false));
        bean.setProperty("myfoundsetWithAllow", new ServoyJSONObject("{foundsetSelector:'',dataproviders:{firstname:'test1',lastname:'test2'}}", false));
        WebComponent bean1 = form.createNewWebComponent("mydynamiccustombean", "my-dynamiccomponent");
        bean1.setProperty("myfoundset", new ServoyJSONObject("{foundsetSelector:'test_to_relatedtest', dataproviders:{dp1:'relatedtest1',dp2:'relatedtest2'}}", false));
        bean1.setProperty("myfoundsetWithAllow", new ServoyJSONObject("{foundsetSelector:'test_to_relatedtest', dataproviders:{dp1:'relatedtest1',dp2:'relatedtest2'}}", false));
        WebComponent bean2 = form.createNewWebComponent("mycustomseparatefoundsetbean", "my-component");
        bean2.setProperty("myfoundset", new ServoyJSONObject("{foundsetSelector: \"mem:testseparatefoundset\", loadAllRecords: true, dataproviders:{firstname:'test1',lastname:'test2'}}", false));
    } catch (JSONException e) {
        e.printStackTrace();
        throw new ServoyException();
    }
}
Also used : WebComponent(com.servoy.j2db.persistence.WebComponent) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject) Form(com.servoy.j2db.persistence.Form) JSONException(org.json.JSONException) Dimension(java.awt.Dimension) ServoyException(com.servoy.j2db.util.ServoyException)

Example 35 with ServoyException

use of com.servoy.j2db.util.ServoyException in project servoy-client by Servoy.

the class FoundsetTest method foundsetViewportBounds.

@Test
public void foundsetViewportBounds() throws JSONException {
    IWebFormController form = (IWebFormController) client.getFormManager().showFormInCurrentContainer("test");
    Assert.assertNotNull(form);
    WebFormComponent wc = form.getFormUI().getWebComponent("mycustombean");
    FoundsetTypeSabloValue rawPropertyValue = (FoundsetTypeSabloValue) wc.getRawPropertyValue("myfoundset");
    BrowserConverterContext allowBrowserConverterContext = new BrowserConverterContext(wc, PushToServerEnum.allow);
    FoundsetTypeViewport viewPort = rawPropertyValue.getViewPort();
    viewPort.setBounds(0, 2);
    StringWriter stringWriter = new StringWriter();
    JSONWriter jsonWriter = new JSONWriter(stringWriter);
    rawPropertyValue.toJSON(jsonWriter, new DataConversion(), allowBrowserConverterContext);
    Assert.assertTrue(new JSONObject("{\"serverSize\":18,\"foundsetId\":2,\"sortColumns\":\"\",\"selectedRowIndexes\":[0],\"multiSelect\":false,\"hasMoreRows\":false,\"viewPort\":{\"startIndex\":0,\"size\":2,\"rows\":[{\"_svyRowId\":\"1.1;_0\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"1.2;_1\",\"lastname\":\"value4\",\"firstname\":\"value3\"}]}}").similar(new JSONObject(stringWriter.toString())));
    try {
        rawPropertyValue.getFoundset().setSort("test1 asc");
    } catch (ServoyException e) {
        e.printStackTrace();
    }
    stringWriter = new StringWriter();
    jsonWriter = new JSONWriter(stringWriter);
    rawPropertyValue.toJSON(jsonWriter, new DataConversion(), allowBrowserConverterContext);
    Assert.assertTrue(new JSONObject("{\"serverSize\":18,\"foundsetId\":2,\"sortColumns\":\"firstname asc\",\"selectedRowIndexes\":[0],\"multiSelect\":false,\"hasMoreRows\":false,\"viewPort\":{\"startIndex\":0,\"size\":2,\"rows\":[{\"_svyRowId\":\"1.1;_0\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"1.2;_1\",\"lastname\":\"value4\",\"firstname\":\"value3\"}]}}").similar(new JSONObject(stringWriter.toString())));
    try {
        rawPropertyValue.getFoundset().setSort("test2 desc,pk asc,test1 asc");
    } catch (ServoyException e) {
        e.printStackTrace();
    }
    stringWriter = new StringWriter();
    jsonWriter = new JSONWriter(stringWriter);
    rawPropertyValue.toJSON(jsonWriter, new DataConversion(), allowBrowserConverterContext);
    Assert.assertTrue(new JSONObject("{\"serverSize\":18,\"foundsetId\":2,\"sortColumns\":\"lastname desc\",\"selectedRowIndexes\":[0],\"multiSelect\":false,\"hasMoreRows\":false,\"viewPort\":{\"startIndex\":0,\"size\":2,\"rows\":[{\"_svyRowId\":\"1.1;_0\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"1.2;_1\",\"lastname\":\"value4\",\"firstname\":\"value3\"}]}}").similar(new JSONObject(stringWriter.toString())));
    try {
        rawPropertyValue.getFoundset().setSort("test2 desc,test1 asc");
    } catch (ServoyException e) {
        e.printStackTrace();
    }
    stringWriter = new StringWriter();
    jsonWriter = new JSONWriter(stringWriter);
    rawPropertyValue.toJSON(jsonWriter, new DataConversion(), allowBrowserConverterContext);
    Assert.assertTrue(new JSONObject("{\"serverSize\":18,\"foundsetId\":2,\"sortColumns\":\"lastname desc,firstname asc\",\"selectedRowIndexes\":[0],\"multiSelect\":false,\"hasMoreRows\":false,\"viewPort\":{\"startIndex\":0,\"size\":2,\"rows\":[{\"_svyRowId\":\"1.1;_0\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"1.2;_1\",\"lastname\":\"value4\",\"firstname\":\"value3\"}]}}").similar(new JSONObject(stringWriter.toString())));
    try {
        rawPropertyValue.getFoundset().setSort("pk asc,test1 asc");
    } catch (ServoyException e) {
        e.printStackTrace();
    }
    stringWriter = new StringWriter();
    jsonWriter = new JSONWriter(stringWriter);
    rawPropertyValue.toJSON(jsonWriter, new DataConversion(), allowBrowserConverterContext);
    Assert.assertTrue(new JSONObject("{\"serverSize\":18,\"foundsetId\":2,\"sortColumns\":\"\",\"selectedRowIndexes\":[0],\"multiSelect\":false,\"hasMoreRows\":false,\"viewPort\":{\"startIndex\":0,\"size\":2,\"rows\":[{\"_svyRowId\":\"1.1;_0\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"1.2;_1\",\"lastname\":\"value4\",\"firstname\":\"value3\"}]}}").similar(new JSONObject(stringWriter.toString())));
    // changes to json
    // add changes test
    viewPort.setBounds(1, 1);
    StringWriter stringWriter2 = new StringWriter();
    JSONWriter jsonWriter2 = new JSONWriter(stringWriter2);
    rawPropertyValue.toJSON(jsonWriter2, new DataConversion(), allowBrowserConverterContext);
    Assert.assertTrue(new JSONObject("{\"serverSize\":18,\"foundsetId\":2,\"sortColumns\":\"\",\"selectedRowIndexes\":[0],\"multiSelect\":false,\"hasMoreRows\":false,\"viewPort\":{\"startIndex\":1,\"size\":1,\"rows\":[{\"_svyRowId\":\"1.2;_1\",\"lastname\":\"value4\",\"firstname\":\"value3\"}]}}").similar(new JSONObject(stringWriter2.toString())));
    viewPort.loadExtraRecords(-1);
    StringWriter stringWriter3 = new StringWriter();
    JSONWriter jsonWriter3 = new JSONWriter(stringWriter3);
    rawPropertyValue.changesToJSON(jsonWriter3, new DataConversion(), allowBrowserConverterContext);
    Assert.assertTrue(new JSONObject("{\"upd_viewPort\":{\"startIndex\":0,\"size\":2,\"upd_rows\":[{\"rows\":[{\"_svyRowId\":\"1.1;_0\",\"lastname\":\"value2\",\"firstname\":\"value1\"}],\"startIndex\":0,\"endIndex\":0,\"type\":1}]}}").similar(new JSONObject(stringWriter3.toString())));
    viewPort.loadExtraRecords(-1);
    stringWriter3 = new StringWriter();
    jsonWriter3 = new JSONWriter(stringWriter3);
    rawPropertyValue.changesToJSON(jsonWriter3, new DataConversion(), allowBrowserConverterContext);
    Assert.assertEquals(new JSONObject("{\"n\":true}").toString(), new JSONObject(stringWriter3.toString()).toString());
    viewPort.loadExtraRecords(16);
    stringWriter3 = new StringWriter();
    jsonWriter3 = new JSONWriter(stringWriter3);
    rawPropertyValue.changesToJSON(jsonWriter3, new DataConversion(), allowBrowserConverterContext);
    Assert.assertTrue(new JSONObject("{\"upd_viewPort\":{\"startIndex\":0,\"size\":18,\"upd_rows\":[{\"rows\":[{\"_svyRowId\":\"1.3;_2\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"1.4;_3\",\"lastname\":\"value4\",\"firstname\":\"value3\"},{\"_svyRowId\":\"1.5;_4\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"1.6;_5\",\"lastname\":\"value4\",\"firstname\":\"value3\"},{\"_svyRowId\":\"1.7;_6\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"1.8;_7\",\"lastname\":\"value4\",\"firstname\":\"value3\"},{\"_svyRowId\":\"1.9;_8\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"2.10;_9\",\"lastname\":\"value4\",\"firstname\":\"value3\"},{\"_svyRowId\":\"2.11;_10\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"2.12;_11\",\"lastname\":\"value4\",\"firstname\":\"value3\"},{\"_svyRowId\":\"2.13;_12\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"2.14;_13\",\"lastname\":\"value4\",\"firstname\":\"value3\"},{\"_svyRowId\":\"2.15;_14\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"2.16;_15\",\"lastname\":\"value4\",\"firstname\":\"value3\"},{\"_svyRowId\":\"2.17;_16\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"2.18;_17\",\"lastname\":\"value4\",\"firstname\":\"value3\"}],\"startIndex\":2,\"endIndex\":17,\"type\":1}]}}").similar(new JSONObject(stringWriter3.toString())));
    viewPort.loadExtraRecords(1);
    stringWriter3 = new StringWriter();
    jsonWriter3 = new JSONWriter(stringWriter3);
    rawPropertyValue.changesToJSON(jsonWriter3, new DataConversion(), allowBrowserConverterContext);
    Assert.assertEquals("{\"n\":true}", stringWriter3.toString());
}
Also used : JSONWriter(org.json.JSONWriter) DataConversion(org.sablo.websocket.utils.DataConversion) StringWriter(java.io.StringWriter) JSONObject(org.json.JSONObject) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject) WebFormComponent(com.servoy.j2db.server.ngclient.WebFormComponent) BrowserConverterContext(org.sablo.specification.property.BrowserConverterContext) IWebFormController(com.servoy.j2db.server.ngclient.IWebFormController) ServoyException(com.servoy.j2db.util.ServoyException) Test(org.junit.Test)

Aggregations

ServoyException (com.servoy.j2db.util.ServoyException)58 RepositoryException (com.servoy.j2db.persistence.RepositoryException)31 ApplicationException (com.servoy.j2db.ApplicationException)25 RemoteException (java.rmi.RemoteException)25 ArrayList (java.util.ArrayList)16 ITable (com.servoy.j2db.persistence.ITable)14 QuerySelect (com.servoy.j2db.query.QuerySelect)13 BaseQueryTable (com.servoy.base.query.BaseQueryTable)11 QueryTable (com.servoy.j2db.query.QueryTable)10 ServoyJSONObject (com.servoy.j2db.util.ServoyJSONObject)10 IOException (java.io.IOException)9 SQLException (java.sql.SQLException)9 JavaScriptException (org.mozilla.javascript.JavaScriptException)9 Column (com.servoy.j2db.persistence.Column)8 Table (com.servoy.j2db.persistence.Table)8 IBaseColumn (com.servoy.base.persistence.IBaseColumn)7 QueryColumn (com.servoy.j2db.query.QueryColumn)7 HashMap (java.util.HashMap)7 MarshallException (org.jabsorb.serializer.MarshallException)7 NativeObject (org.mozilla.javascript.NativeObject)7