Examples of PJsonArray


Examples of org.mapfish.print.wrapper.json.PJsonArray

            } else {
                jsonArray.put(o);
            }

        }
        return new PJsonArray(null, jsonArray, getContextName());
    }
View Full Code Here

Examples of org.mapfish.print.wrapper.json.PJsonArray

     */
    private static void setLegendAttribute(final JSONObject attributes,
                                           final PJsonObject oldRequest,
                                           final Template template) throws JSONException {
        final List<LegendProcessor> legendProcessors = getLegendProcessor(template);
        PJsonArray oldLegendJson = getLegendJson(oldRequest);

        if (legendProcessors.isEmpty()) {
            if (oldLegendJson == null) {
                // no table, no work
                return;
            } else {
                LOGGER.warn("The request json data has attribute information for creating the map but config does not have a" +
                            "map attribute.  Check that the request and the config.yaml are correct.");
                return;
            }
        } else if (oldLegendJson == null) {
            LOGGER.warn("Configuration expects a table, but no table data is defined in the request");
            oldLegendJson = new PJsonArray(oldRequest, new JSONArray(), "generated");
        }

        if (legendProcessors.size() != oldLegendJson.size()) {
            LOGGER.warn("Not all legends processors have request data.  There are " + legendProcessors.size() +
                        " and there are " + oldLegendJson.size() + " legend request objects.");
        }

        for (int i = 0; i < legendProcessors.size(); i++) {
            String legendAttName = "legend";
            LegendProcessor legendProcessor = legendProcessors.get(i);

            if (legendProcessor.getInputMapperBiMap().containsValue("legend")) {
                legendAttName = legendProcessor.getInputMapperBiMap().inverse().get("legend");
            }

            final JSONObject value;
            if (oldLegendJson.size() > i) {
                value = oldLegendJson.getJSONObject(i).getInternalObj();
            } else {
                value = new JSONObject();
            }

            attributes.put(legendAttName, value);
View Full Code Here

Examples of org.mapfish.print.wrapper.json.PJsonArray

    private static List<String> getTableColumnKeys(final PJsonObject oldTablePage) {
        final PJsonObject table = oldTablePage.optJSONObject("table");
        final List<String> columnKeys = new LinkedList<String>();
        if (table != null) {
            final PArray columns = table.optArray("columns", new PJsonArray(table, new JSONArray(), "columns"));

            for (int i = 0; i < columns.size(); i++) {
                columnKeys.add(columns.getString(i));
            }
        }
View Full Code Here

Examples of org.mapfish.print.wrapper.json.PJsonArray

            final PJsonObject oldTablePage) {
        final PJsonObject table = oldTablePage.optJSONObject("table");

        final List<JSONArray> tableData = new LinkedList<JSONArray>();
        if (table != null) {
            final PArray oldTableRows = table.optArray("data", new PJsonArray(table, new JSONArray(), "data"));

            for (int i = 0; i < oldTableRows.size(); i++) {
                final PObject oldRow = oldTableRows.getObject(i);
                if (!oldRow.keys().hasNext()) {
                    // row is empty, skip
View Full Code Here

Examples of org.mapfish.print.wrapper.json.PJsonArray

            } catch (CQLException e) {
                throw new RuntimeException("Error compiling rule filter: " + jsonKey, e);
            }
        }

        PJsonArray symbolizerJsonArray = ruleJson.getJSONArray(JSON_SYMB);
        Symbolizer[] symbolizers = new Symbolizer[symbolizerJsonArray.size()];

        for (int i = 0; i < symbolizerJsonArray.size(); i++) {
            final PJsonObject symbolizerJson = symbolizerJsonArray.getJSONObject(i);
            updateSymbolizerProperties(ruleJson, symbolizerJson);

            SymbolizerType type = SymbolizerType.valueOf(symbolizerJson.getString(JSON_TYPE).toUpperCase());
            symbolizers[i] = type.parseJson(this.parserHelper, symbolizerJson);
            if (symbolizers[i] == null) {
View Full Code Here

Examples of org.mapfish.print.wrapper.json.PJsonArray

     * Constructor.
     *
     * @param table the table data.
     */
    public TableDataSource(final PJsonObject table) {
        PJsonArray jsonColumns = table.getJSONArray("columns");
        this.columnNames = new String[jsonColumns.size()];
        for (int i = 0; i < jsonColumns.size(); i++) {
            this.columnNames[i] = jsonColumns.getString(i);
        }

        PJsonArray jsonData = table.getJSONArray("data");
        this.data = new String[jsonData.size()][];
        for (int i = 0; i < jsonData.size(); i++) {
            PJsonArray jsonRow = jsonData.getJSONArray(i);
            this.data[i] = new String[jsonRow.size()];
            for (int j = 0; j < jsonRow.size(); j++) {
                this.data[i][j] = jsonRow.getString(j);
            }
        }

    }
View Full Code Here

Examples of org.mapfish.print.wrapper.json.PJsonArray

        final PJsonObject test = new PYamlObject(map, "test").toJSON();

        assertEquals(3, test.size());
        assertEquals(1, test.getInt("att1"));

        PJsonArray array1 = test.getJSONArray("att2");
        assertEquals(2, array1.size());
        assertEquals(1, array1.get(0));
        assertEquals(2, array1.get(1));

        PJsonObject embeddedJson = test.getJSONObject("att3");
        assertEquals(3, embeddedJson.size());
        assertEquals(true, embeddedJson.has("embeddedAtt1"));

        PJsonObject embeddedEmbeddedJson = embeddedJson.getJSONObject("embeddedAtt2");
        assertEquals(1, embeddedEmbeddedJson.size());
        assertEquals(1, embeddedEmbeddedJson.getInt("ee1"));

        PJsonArray array2 = embeddedJson.getJSONArray("embeddedAtt3");
        assertEquals(3, array2.size());
        assertEquals("one", array2.getString(0));
        assertEquals("two", array2.getString(1));
        assertEquals("three", array2.getString(2));
    }
View Full Code Here

Examples of org.mapfish.print.wrapper.json.PJsonArray

        Map<String, Object> embedded = Maps.newHashMap();
        embedded.put("a", 1);
        List<Object> array = Lists.newArrayList(1, embedded,
                Lists.newArrayList(1,2,3),
                new String[]{"a", "b", "c"});
        final PJsonArray test = new PYamlArray(null, array, "test").toJSON();
        assertEquals(4, test.size());

        assertEquals(1, test.get(0));

        final JSONObject embeddedJson = (JSONObject) test.get(1);
        assertEquals(1, embeddedJson.length());
        assertEquals(1, embeddedJson.getInt("a"));

        final JSONArray array1 = (JSONArray) test.get(2);
        assertEquals(3, array1.length());
        assertEquals(1, array1.getInt(0));
        assertEquals(2, array1.getInt(1));
        assertEquals(3, array1.getInt(2));

        final JSONArray array2 = (JSONArray) test.get(3);
        assertEquals(3, array2.length());
        assertEquals("a", array2.getString(0));
        assertEquals("b", array2.getString(1));
        assertEquals("c", array2.getString(2));

        assertTrue(test.getArray(3) instanceof PJsonArray);
        assertTrue(test.getJSONArray(3) != null);
    }
View Full Code Here

Examples of org.mapfish.print.wrapper.json.PJsonArray

        mapAttribute.setMaxDpi(600.0);
        MapAttributeValues mapParams = mapAttribute.createValue(null);
        mapParams.dpi = 72;
        mapParams.center = new double[]{-8235878.4938425, 4979784.7605681};
        mapParams.scale = 26000.0;
        mapParams.layers = new PJsonArray(null, new JSONArray(), "");
        mapParams.postConstruct();

        ScalebarAttribute scalebarAttibute = new ScalebarAttribute();
        scalebarAttibute.setWidth(300);
        scalebarAttibute.setHeight(40);
View Full Code Here

Examples of org.mapfish.print.wrapper.json.PJsonArray

        MapAttributeValues mapParams = mapAttribute.createValue(null);
        // use a dpi of 144, this will create a scale bar graphic of 600x80 px
        mapParams.dpi = 144;
        mapParams.center = new double[]{-8235878.4938425, 4979784.7605681};
        mapParams.scale = 26000.0;
        mapParams.layers = new PJsonArray(null, new JSONArray(), "");
        mapParams.postConstruct();

        ScalebarAttribute scalebarAttibute = new ScalebarAttribute();
        scalebarAttibute.setWidth(300);
        scalebarAttibute.setHeight(40);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.