Examples of PObject


Examples of org.mapfish.print.wrapper.PObject

            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

Examples of org.mapfish.print.wrapper.PObject

        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

Examples of org.mapfish.print.wrapper.PObject

        final String result = infoResponse.getContentAsString();
        final PJsonObject info = parseJSONObjectFromString(result);
       
        assertTrue(info.has("dpis"));
        assertEquals(4, info.getArray("dpis").size());
        final PObject firstDpi = info.getArray("dpis").getObject(0);
        assertEquals("90", firstDpi.getString("name"));
        assertEquals("90", firstDpi.getString("value"));
        final PObject lastDpi = info.getArray("dpis").getObject(3);
        assertEquals("400", lastDpi.getString("name"));
        assertEquals("400", lastDpi.getString("value"));
    }
View Full Code Here

Examples of org.mapfish.print.wrapper.PObject

        final PJsonObject getInfoJson = parseJSONObjectFromString(contentAsString);

        assertTrue(getInfoJson.has("layouts"));
        final PJsonArray layouts = getInfoJson.getJSONArray("layouts");
        assertEquals(2, layouts.size());
        final PObject mainLayout = layouts.getObject(0);
        assertEquals("A4 Landscape", mainLayout.getString("name"));
        assertTrue(mainLayout.has("attributes"));
        assertEquals(2, mainLayout.getArray("attributes").size());
        assertEquals("imageMap", mainLayout.getArray("attributes").getObject(1).getString("name"));
        assertTrue(getInfoJson.has("formats"));
        final PJsonArray formats = getInfoJson.getJSONArray("formats");
        assertCapabilitiesFormats(formats);

    }
View Full Code Here

Examples of org.mapfish.print.wrapper.PObject

        final PJsonObject getInfoJson = parseJSONObjectFromString(contentAsString);

        assertTrue(getInfoJson.has("layouts"));
        final PJsonArray layouts = getInfoJson.getJSONArray("layouts");
        assertEquals(2, layouts.size());
        final PObject mainLayout = layouts.getObject(0);
        assertEquals("A4 Landscape", mainLayout.getString("name"));
        assertTrue(mainLayout.has("attributes"));
        assertEquals(2, mainLayout.getArray("attributes").size());
        assertEquals("imageMap", mainLayout.getArray("attributes").getObject(1).getString("name"));
        assertTrue(getInfoJson.has("formats"));
        final PJsonArray formats = getInfoJson.getJSONArray("formats");
        assertCapabilitiesFormats(formats);
    }
View Full Code Here

Examples of org.mapfish.print.wrapper.PObject

        final String contentAsString = defaultGetInfoResponse.getContentAsString();
        assertFalse(contentAsString.contains("\n"));
        final PJsonObject defaultGetInfoJson = parseJSONObjectFromString(contentAsString);
        final PJsonArray defaultLayouts = defaultGetInfoJson.getJSONArray("layouts");
        final PObject a4LandscapeLayout = defaultLayouts.getObject(0);
        assertEquals("A4 Landscape", a4LandscapeLayout.getString("name"));

        final MockHttpServletResponse app2GetInfoResponse = new MockHttpServletResponse();
        this.servlet.getCapabilities("app2", false, "", app2GetInfoResponse);
        assertEquals(HttpStatus.OK.value(), app2GetInfoResponse.getStatus());

        final PJsonObject app2GetInfoJson = parseJSONObjectFromString(app2GetInfoResponse.getContentAsString());
        final PJsonArray app2Layouts = app2GetInfoJson.getJSONArray("layouts");
        final PObject mainLayout = app2Layouts.getObject(0);
        assertEquals("main", mainLayout.getString("name"));

        final MockHttpServletResponse noSuchGetInfoResponse = new MockHttpServletResponse();
        this.servlet.getCapabilities("NoSuch", false, "", noSuchGetInfoResponse);
        assertEquals(HttpStatus.NOT_FOUND.value(), noSuchGetInfoResponse.getStatus());
    }
View Full Code Here

Examples of org.mapfish.print.wrapper.PObject

        private List<MapLayer> parseLayers() {
            List<MapLayer> layerList = Lists.newArrayList();

            for (int i = 0; i < this.getRawLayers().size(); i++) {
                try {
                    PObject layer = this.getRawLayers().getObject(i);
                    parseSingleLayer(layerList, layer);
                } catch (Throwable throwable) {
                    throw ExceptionUtils.getRuntimeException(throwable);
                }
            }
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.