Package org.apache.isis.applib.services.memento.MementoService

Examples of org.apache.isis.applib.services.memento.MementoService.Memento


        return mementoService.create()
                .set("path", fs.getParentPath())
                .asString();
    }
    void initOf(final String mementoStr, final FixtureScript fs) {
        Memento memento = mementoService.parse(mementoStr);
        fs.setParentPath(memento.get("path", String.class));
    }
View Full Code Here


                .set("key", fr.getKey())
                .set("object", bookmarkService.bookmarkFor(fr.getObject()))
                .asString();
    }
    void initOf(String mementoStr, FixtureResult fr) {
        Memento memento = mementoService.parse(mementoStr);
        fr.setFixtureScriptClassName(memento.get("fixtureScriptClassName", String.class));
        fr.setKey(memento.get("key", String.class));
        fr.setObject(bookmarkService.lookup(memento.get("object", Bookmark.class)));
    }
View Full Code Here

        Mon,Tue,Wed,Thu,Fri
    }
   
    @Test
    public void roundtrip() {
        final Memento memento = mementoService.create();
       
        memento.set("someString", "a string");
        memento.set("someStringWithDoubleSpaces", "a  string");
        memento.set("someByte", (byte)123);
        memento.set("someShort", (short)12345);
        memento.set("someInt", 123456789);
        memento.set("someLong", 1234567890123456789L);
        memento.set("someFloat", 123.45F);
        memento.set("someDouble", 1234567890.123456);
        memento.set("someBooleanTrue", Boolean.TRUE);
        memento.set("someBooleanFalse", Boolean.FALSE);
        memento.set("someBigInteger", new BigInteger("123456789012345678901234567890"));
        memento.set("someBigDecimal", new BigDecimal("123456789012345678901234567890.123456789"));
        memento.set("someLocalDate", new LocalDate(2013,9,3));
       
        memento.set("someBookmark", new Bookmark("CUS", "12345"));
        memento.set("someNullValue", null);
       
        memento.set("someEnum", DOW.Wed);
       
        final String str = memento.asString();
       
        final Memento memento2 = mementoService.parse(str);
       
        assertThat(memento2.get("someString", String.class), is("a string"));
        assertThat(memento2.get("someStringWithDoubleSpaces", String.class), is("a  string"));
        assertThat(memento2.get("someByte", Byte.class), is((byte)123));
        assertThat(memento2.get("someShort", Short.class), is((short)12345));
        assertThat(memento2.get("someInt", Integer.class), is(123456789));
        assertThat(memento2.get("someLong", Long.class), is(1234567890123456789L));
        assertThat(memento2.get("someFloat", Float.class), is(123.45F));
        assertThat(memento2.get("someDouble", Double.class), is(1234567890.123456));
        assertThat(memento2.get("someBooleanTrue", Boolean.class), is(Boolean.TRUE));
        assertThat(memento2.get("someBooleanFalse", Boolean.class), is(Boolean.FALSE));
        assertThat(memento2.get("someBigInteger", BigInteger.class), is(new BigInteger("123456789012345678901234567890")));
        assertThat(memento2.get("someBigDecimal", BigDecimal.class), is(new BigDecimal("123456789012345678901234567890.123456789")));
        assertThat(memento2.get("someLocalDate", LocalDate.class), is(new LocalDate(2013,9,3)));
        assertThat(memento2.get("someBookmark", Bookmark.class), is(new Bookmark("CUS", "12345")));
       
        // a nullValue can be grabbed as any type, will always succeed
        assertThat(memento2.get("someNullValue", Integer.class), is(nullValue()));
        assertThat(memento2.get("someNullValue", Bookmark.class), is(nullValue()));
        assertThat(memento2.get("someNullValue", LocalDate.class), is(nullValue()));
       
        assertThat(memento2.get("someEnum", DOW.class), is(DOW.Wed));
       
    }
View Full Code Here

        public void hintsToPageParameters(Map<String,String> hints, PageParameters pageParameters) {
            if(hints.isEmpty()) {
                return;
            }
            MementoServiceDefault vms = new MementoServiceDefault();
            Memento memento = vms.create();
            Set<String> hintKeys = hints.keySet();
            for (String key : hintKeys) {
                String safeKey = key.replace(':', '_');
                Serializable value = hints.get(key);
                memento.set(safeKey, value);
            }
            String serializedHints = memento.asString();
            PageParameterNames.ANCHOR.addStringTo(pageParameters, serializedHints);
        }
View Full Code Here

        public void pageParametersToHints(final PageParameters pageParameters, Map<String,String> hints) {
            String hintsStr = PageParameterNames.ANCHOR.getStringFrom(pageParameters);
            if(hintsStr != null) {
                try {
                    Memento memento = new MementoServiceDefault().parse(hintsStr);
                    Set<String> keys = memento.keySet();
                    for (String safeKey : keys) {
                        String value = memento.get(safeKey, String.class);
                        String key = safeKey.replace('_', ':');
                        hints.put(key, value);
                    }
                } catch(RuntimeException ex) {
                    // fail gracefully, ie ignore.
View Full Code Here

        return mementoService.create()
                .set("path", fs.getParentPath())
                .asString();
    }
    void initOf(final String mementoStr, final FixtureScript fs) {
        Memento memento = mementoService.parse(mementoStr);
        fs.setParentPath(memento.get("path", String.class));
    }
View Full Code Here

        public void hintsToPageParameters(Map<String,String> hints, PageParameters pageParameters) {
            if(hints.isEmpty()) {
                return;
            }
            MementoServiceDefault vms = new MementoServiceDefault();
            Memento memento = vms.create();
            Set<String> hintKeys = hints.keySet();
            for (String key : hintKeys) {
                String safeKey = key.replace(':', '_');
                Serializable value = hints.get(key);
                memento.set(safeKey, value);
            }
            String serializedHints = memento.asString();
            PageParameterNames.ANCHOR.addStringTo(pageParameters, serializedHints);
        }
View Full Code Here

        public void pageParametersToHints(final PageParameters pageParameters, Map<String,String> hints) {
            String hintsStr = PageParameterNames.ANCHOR.getStringFrom(pageParameters);
            if(hintsStr != null) {
                try {
                    Memento memento = new MementoServiceDefault().parse(hintsStr);
                    Set<String> keys = memento.keySet();
                    for (String safeKey : keys) {
                        String value = memento.get(safeKey, String.class);
                        String key = safeKey.replace('_', ':');
                        hints.put(key, value);
                    }
                } catch(RuntimeException ex) {
                    // fail gracefully, ie ignore.
View Full Code Here

TOP

Related Classes of org.apache.isis.applib.services.memento.MementoService.Memento

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.