Package org.mapfish.print.wrapper

Examples of org.mapfish.print.wrapper.PObject


        }

        final DataSourceAttributeValue value = new DataSourceAttributeValue();
        value.attributesValues = new Map[pValue.size()];
        for (int i = 0; i < pValue.size(); i++) {
            PObject rowData = pValue.getObject(i);
            final Values valuesForParsing = new Values();
            valuesForParsing.populateFromAttributes(template, parser, this.attributes, rowData);
            value.attributesValues[i] = valuesForParsing.asMap();
        }
View Full Code Here


    @Override
    public final PObject optObject(final String key) {
        List<PObject> results = new ArrayList<PObject>();
        for (PObject obj : this.objs) {
            PObject result = obj.optObject(key);
            if (result != null) {
                results.add(result);
            }
        }
        if (results.size() == 0) {
View Full Code Here

        } else if (type.isEnum()) {
            value = parseEnum(type, layer.getPath(fieldName), layer.getString(name));
        } else {
            try {
                value = type.newInstance();
                PObject object = layer.getObject(name);
                parse(errorOnExtraProperties, object, value, extraPropertyToIgnore);
            } catch (InstantiationException e) {
                throw new UnsupportedTypeException(type, e);
            } catch (IllegalAccessException e) {
                throw ExceptionUtils.getRuntimeException(e);
View Full Code Here

        } else if (type.isEnum()) {
            value = parseEnum(type, array.getPath("" + i), array.getString(i));
        } else {
            try {
                value = type.newInstance();
                PObject object = array.getObject(i);
                parse(errorOnExtraProperties, object, value, extraPropertyToIgnore);
            } catch (InstantiationException e) {
                throw new UnsupportedTypeException(type, e);
            } catch (IllegalAccessException e) {
                throw ExceptionUtils.getRuntimeException(e);
View Full Code Here

    }

    private static PObject getOldMapPage(final PJsonObject oldRequest) {
        final PArray pages = oldRequest.getArray("pages");

        PObject mapPage = null;
        for (int i = 0; i < pages.size(); i++) {
            final PObject page = pages.getObject(i);

            if (isMapPage(page)) {
                if (mapPage == null) {
                    mapPage = page;
                } else {
View Full Code Here

    }

    private static PObject getOldTablePage(final PJsonObject oldRequest) {
        final PArray pages = oldRequest.getArray("pages");

        PObject tablePage = null;
        for (int i = 0; i < pages.size(); i++) {
            final PObject page = pages.getObject(i);

            if (isTablePage(page)) {
                if (tablePage == null) {
                    tablePage = page;
                } else {
View Full Code Here

            //    ],
            //    "columns":[
            //       "col0"
            //    ]
            // }
            PObject table = page.getObject("table");
            if (table.getArray("columns").size() == 1 && table.getArray("data").size() == 1) {
                String columnName = table.getArray("columns").getString(0);
                String value = table.getArray("data").getObject(0).getString(columnName);
                return !Strings.isNullOrEmpty(value);
            }
            return true;
        }
        return false;
View Full Code Here

        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
                    continue;
                }

                // copy the values for each column
                final JSONArray row = new JSONArray();
                for (String key : columnKeys) {
                    row.put(oldRow.getString(key));
                }
                tableData.add(row);
            }
        }
        return tableData;
View Full Code Here

            final Attribute attribute = attributes.get(attributeName);
            final Object value;
            if (attribute instanceof PrimitiveAttribute) {
                PrimitiveAttribute<?> pAtt = (PrimitiveAttribute<?>) attribute;
                Object defaultVal = pAtt.getDefault();
                PObject jsonToUse = requestJsonAttributes;
                if (defaultVal != null) {
                    final JSONObject obj = new JSONObject();
                    obj.put(attributeName, defaultVal);
                    PObject[] pValues = new PObject[]{requestJsonAttributes, new PJsonObject(obj, "default_" + attributeName)};
                    jsonToUse = new PMultiObject(pValues);
                }
                value = parser.parsePrimitive(attributeName, pAtt.getValueClass(), jsonToUse);
            } else if (attribute instanceof DataSourceAttribute) {
                DataSourceAttribute dsAttribute = (DataSourceAttribute) attribute;
                value = dsAttribute.parseAttribute(parser, template, requestJsonAttributes.optArray(attributeName));
            } else if (attribute instanceof ReflectiveAttribute) {
                boolean errorOnExtraParameters = template.getConfiguration().isThrowErrorOnExtraParameters();
                ReflectiveAttribute<?> rAtt = (ReflectiveAttribute<?>) attribute;
                value = rAtt.createValue(template);
                PObject pValue = requestJsonAttributes.optObject(attributeName);

                if (pValue != null) {
                    PObject[] pValues = new PObject[]{pValue, rAtt.getDefaultValue()};
                    pValue = new PMultiObject(pValues);
                } else {
View Full Code Here

        assertTrue(info.has("layouts"));
        assertTrue(info.has("printURL"));
        assertTrue(info.has("createURL"));

        assertEquals(10, info.getArray("scales").size());
        final PObject firstScale = info.getArray("scales").getObject(0);
        assertEquals("1:5000", firstScale.getString("name"));
        assertEquals("5000", firstScale.getString("value"));

        assertEquals(5, info.getArray("dpis").size());
       
        assertTrue(info.getArray("outputFormats").size() > 0);
        assertTrue(info.getArray("outputFormats").getObject(0).has("name"));

        assertTrue(info.getArray("layouts").size() > 0);
        PObject layout = info.getArray("layouts").getObject(0);
        assertEquals("A4 Portrait", layout.getString("name"));
        assertTrue(layout.getBool("rotation"));
        assertEquals(802, layout.getObject("map").getInt("width"));
        assertEquals(210, layout.getObject("map").getInt("height"));
       
        assertEquals("/print-old/dep/print.pdf", info.getString("printURL"));
        assertEquals("/print-old/dep/create.json", info.getString("createURL"));
    }
View Full Code Here

TOP

Related Classes of org.mapfish.print.wrapper.PObject

Copyright © 2018 www.massapicom. 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.