Examples of DateFormatTransform


Examples of org.geoserver.importer.transform.DateFormatTransform

        json.object();
        json.key("type").value(transform.getClass().getSimpleName());
        json.key("href").value(page.rootURI(pathTo(task)+"/transform/" + index));
        if (expand > 0) {
            if (transform instanceof DateFormatTransform) {
                DateFormatTransform df = (DateFormatTransform) transform;
                json.key("field").value(df.getField());
                if (df.getDatePattern() != null) {
                    json.key("format").value(df.getDatePattern().dateFormat().toPattern());
                }
   
            } else if (transform instanceof IntegerFieldToDateTransform) {
                IntegerFieldToDateTransform df = (IntegerFieldToDateTransform) transform;
                json.key("field").value(df.getField());
            } else if (transform instanceof CreateIndexTransform) {
                CreateIndexTransform df = (CreateIndexTransform) transform;
                json.key("field").value(df.getField());
            } else if (transform instanceof AttributeRemapTransform) {
                AttributeRemapTransform art = (AttributeRemapTransform) transform;
                json.key("field").value(art.getField());
                json.key("target").value(art.getType().getName());
            } else if (transform.getClass() == AttributesToPointGeometryTransform.class) {
View Full Code Here

Examples of org.geoserver.importer.transform.DateFormatTransform

                            if (Date.class.equals(type)) {
                                String dateFormat = dateFormatTextField.getModelObject();
                                if (dateFormat == null || "".equals(dateFormat.trim())) {
                                    dateFormat = null;
                                }
                                item.setModelObject(new DateFormatTransform(field, dateFormat));
                            }
                            else if (Number.class.isAssignableFrom(type)) {
                                item.setModelObject(new NumberFormatTransform(field, type));
                            }
                           
View Full Code Here

Examples of org.geoserver.importer.transform.DateFormatTransform

        assertEquals(1, context.getTasks().size());
       
        context.setTargetStore(store);

        ImportTask task = context.getTasks().get(0);
        task.getTransform().add(new DateFormatTransform("timestamp", "yyyy-MM-dd HH:mm:ss.S"));
       
        importer.run(context);

        assertEquals(ImportContext.State.COMPLETE, context.getState());
View Full Code Here

Examples of org.geoserver.importer.transform.DateFormatTransform

    ImportTransform transform(JSONObject json) throws IOException {
        ImportTransform transform;
        String type = json.getString("type");
        if ("DateFormatTransform".equalsIgnoreCase(type)) {
            transform = new DateFormatTransform(json.getString("field"), json.optString("format", null));
        } else if ("IntegerFieldToDateTransform".equalsIgnoreCase(type)) {
            transform = new IntegerFieldToDateTransform(json.getString("field"));
        } else if ("CreateIndexTransform".equalsIgnoreCase(type)) {
            transform = new CreateIndexTransform(json.getString("field"));
        } else if ("AttributeRemapTransform".equalsIgnoreCase(type)) {
View Full Code Here

Examples of org.geoserver.importer.transform.DateFormatTransform

        assertNotNull(task);

        TransformChain chain = task.getTransform();
        assertNotNull(chain);
        assertEquals(1, chain.getTransforms().size());
        DateFormatTransform dft = (DateFormatTransform) chain.getTransforms().get(0);
        assertEquals("foobar",dft.getField());
        assertEquals("yyyy-MM-dd",dft.getDatePattern().dateFormat().toPattern());

    }
View Full Code Here

Examples of org.geoserver.importer.transform.DateFormatTransform

    }
   
    public void testExtents() throws Exception {
        // this is mostly a verification of the extents of the builtin date parsing
        String NOT_USED = null;
        DateFormatTransform transform = new DateFormatTransform("not used", NOT_USED);
       
        GregorianCalendar cal = new GregorianCalendar();
        cal.clear();
        cal.setTimeZone(TimeZone.getTimeZone("GMT"));
       
        int minYear = -292269052; // this is the text value
        Date parsed = transform.parseDate("" + minYear);
        cal.setTime(parsed);

        // the real value is the minYear - 1 since 0BC == 1AD
        assertEquals(minYear - 1, - cal.get(Calendar.YEAR));
        assertEquals(GregorianCalendar.BC,cal.get(Calendar.ERA));
       
        cal.setTimeInMillis(Long.MAX_VALUE);
        int maxYear = cal.get(Calendar.YEAR);
        parsed = transform.parseDate("" + maxYear);
        cal.setTime(parsed);
        assertEquals(maxYear, cal.get(Calendar.YEAR));
        assertEquals(GregorianCalendar.AD, cal.get(Calendar.ERA));
    }
View Full Code Here

Examples of org.geoserver.importer.transform.DateFormatTransform

        assertEquals(GregorianCalendar.AD, cal.get(Calendar.ERA));
    }

    public void testTransformSuccess() throws ParseException {
        String NOT_USED = null;
        DateFormatTransform transform = new DateFormatTransform("not used", NOT_USED);

        Date now = new Date();
       
        // make a big shuffled list of patterns to ensure caching of last pattern
        // doesn't cause any problems
        List<String> patterns = new ArrayList<String>();
        patterns.addAll(Collections2.transform(Dates.patterns(false),
            new Function<DatePattern, String>() {
           
            @Override
            public String apply(DatePattern input) {
                return input.dateFormat().toPattern();
            }
        }));
       
        Collections.shuffle(patterns);
       
        for (String f : patterns) {
            SimpleDateFormat fmt = new SimpleDateFormat(f);
            fmt.setTimeZone(Dates.UTC_TZ);
            Date expected = fmt.parse(fmt.format(now));
            Date parsed = transform.parseDate(fmt.format(now));
            assertEquals(expected, parsed);
        }
    }
View Full Code Here

Examples of org.geoserver.importer.transform.DateFormatTransform

        }
    }

    public void testTransformSuccessCustomFormat() throws ParseException {
        String customFormat = "yyyy-MM-dd'X'00";
        DateFormatTransform transform = new DateFormatTransform("not used", customFormat);

        Date now = new Date();
        SimpleDateFormat fmt = new SimpleDateFormat(customFormat);
        fmt.setTimeZone(Dates.UTC_TZ);
        Date expected = fmt.parse(fmt.format(now));
        Date parsed = transform.parseDate(fmt.format(now));
        assertEquals(expected, parsed);
    }
View Full Code Here

Examples of org.geoserver.importer.transform.DateFormatTransform

        Date parsed = transform.parseDate(fmt.format(now));
        assertEquals(expected, parsed);
    }
   
    public void testJSON() throws Exception {
        doJSONTest(new DateFormatTransform("foo", null));
        doJSONTest(new DateFormatTransform("foo", "yyyy-MM-dd"));
    }
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.