Package org.slim3.datastore.model

Examples of org.slim3.datastore.model.Hoge


    /**
     * @throws Exception
     */
    @Test
    public void accept() throws Exception {
        Hoge hoge = new Hoge();
        hoge.setMyString("aaa");
        InMemoryNotEqualCriterion c =
            new InMemoryNotEqualCriterion(meta.myString, "bbb");
        assertThat(c.accept(hoge), is(true));
        hoge.setMyString("bbb");
        assertThat(c.accept(hoge), is(false));
    }
View Full Code Here


     */
    @Test
    public void acceptForEnum() throws Exception {
        InMemoryNotEqualCriterion c =
            new InMemoryNotEqualCriterion(meta.myEnum, SortDirection.ASCENDING);
        Hoge hoge = new Hoge();
        hoge.setMyEnum(SortDirection.DESCENDING);
        assertThat(c.accept(hoge), is(true));
        hoge.setMyEnum(SortDirection.ASCENDING);
        assertThat(c.accept(hoge), is(false));
    }
View Full Code Here

    /**
     * @throws Exception
     */
    @Test
    public void acceptForNull() throws Exception {
        Hoge hoge = new Hoge();
        InMemoryNotEqualCriterion c =
            new InMemoryNotEqualCriterion(meta.myString, null);
        assertThat(c.accept(hoge), is(false));
    }
View Full Code Here

    /**
     * @throws Exception
     */
    @Test
    public void acceptForCollection() throws Exception {
        Hoge hoge = new Hoge();
        hoge.setMyIntegerList(Arrays.asList(1));
        InMemoryNotEqualCriterion c =
            new InMemoryNotEqualCriterion(meta.myIntegerList, 1);
        assertThat(c.accept(hoge), is(false));
        hoge.setMyIntegerList(Arrays.asList(2));
        assertThat(c.accept(hoge), is(true));
    }
View Full Code Here

                meta,
                "myString",
                "myString",
                String.class) {
            };
        Hoge hoge = new Hoge();
        hoge.setKey(Datastore.createKey(Hoge.class, 1));
        hoge.setMyString("aaa");
        assertThat((String) attrMeta.getValue(hoge), is("aaa"));
    }
View Full Code Here

        super("Hoge", Hoge.class);
    }

    @Override
    public Hoge entityToModel(Entity entity) {
        Hoge model = new Hoge();
        model.setKey(entity.getKey());
        model.setMyPrimitiveShort(longToPrimitiveShort((Long) entity
            .getProperty("myPrimitiveShort")));
        model.setMyShort(longToShort((Long) entity.getProperty("myShort")));
        model.setMyPrimitiveInt(longToPrimitiveInt((Long) entity
            .getProperty("myPrimitiveInt")));
        model
            .setMyInteger(longToInteger((Long) entity.getProperty("myInteger")));
        model.setMyPrimitiveLong(longToPrimitiveLong((Long) entity
            .getProperty("myPrimitiveLong")));
        model.setMyLong((Long) entity.getProperty("myLong"));
        model.setMyPrimitiveFloat(doubleToPrimitiveFloat((Double) entity
            .getProperty("myPrimitiveFloat")));
        model.setMyFloat(doubleToFloat((Double) entity.getProperty("myFloat")));
        model.setMyPrimitiveDouble(doubleToPrimitiveDouble((Double) entity
            .getProperty("myPrimitiveDouble")));
        model.setMyDouble((Double) entity.getProperty("myDouble"));
        model.setMyString((String) entity.getProperty("myString"));
        model.setMyPrimitiveBoolean(booleanToPrimitiveBoolean((Boolean) entity
            .getProperty("myPrimitiveBoolean")));
        model.setMyBoolean((Boolean) entity.getProperty("myBoolean"));
        model.setMyDate((Date) entity.getProperty("myDate"));
        model.setMyEnum(stringToEnum(SortDirection.class, (String) entity
            .getProperty("myEnum")));

        model.setMyStringText(textToString((Text) entity
            .getProperty("myStringText")));
        model.setMyText((Text) entity.getProperty("myText"));
        model.setMyBytes(shortBlobToBytes((ShortBlob) entity
            .getProperty("myBytes")));
        model.setMyBytesBlob(blobToBytes((Blob) entity
            .getProperty("myBytesBlob")));
        model
            .setMySerializable((MySerializable) shortBlobToSerializable((ShortBlob) entity
                .getProperty("mySerializable")));
        model
            .setMySerializableBlob((MySerializable) blobToSerializable((Blob) entity
                .getProperty("mySerializableBlob")));
        model.setMyBlob((Blob) entity.getProperty("myBlob"));
        model.setMyShortBlob((ShortBlob) entity.getProperty("myShortBlob"));

        model.setMyShortList(longListToShortList(entity
            .getProperty("myShortList")));
        model.setMyShortSet(new HashSet<Short>(longListToShortList(entity
            .getProperty("myShortSet"))));
        model.setMyShortSortedSet(new TreeSet<Short>(longListToShortList(entity
            .getProperty("myShortSortedSet"))));

        model.setMyIntegerList(longListToIntegerList(entity
            .getProperty("myIntegerList")));
        model.setMyIntegerSet(new HashSet<Integer>(longListToIntegerList(entity
            .getProperty("myIntegerSet"))));
        model.setMyIntegerSortedSet(new TreeSet<Integer>(
            longListToIntegerList(entity.getProperty("myIntegerSortedSet"))));

        model
            .setMyLongList(toList(Long.class, entity.getProperty("myLongList")));
        model.setMyLongSet(new HashSet<Long>(toList(Long.class, entity
            .getProperty("myLongSet"))));
        model.setMyLongSortedSet(new TreeSet<Long>(toList(Long.class, entity
            .getProperty("myLongSortedSet"))));

        model.setMyFloatList(doubleListToFloatList(entity
            .getProperty("myFloatList")));
        model.setMyFloatSet(new HashSet<Float>(doubleListToFloatList(entity
            .getProperty("myFloatSet"))));
        model.setMyFloatSortedSet(new TreeSet<Float>(
            doubleListToFloatList(entity.getProperty("myFloatSortedSet"))));
        model.setMyEnumList(stringListToEnumList(SortDirection.class, entity
            .getProperty("myEnumList")));
        model.setMyStringList(toList(String.class, entity
            .getProperty("myStringList")));
        model.setVersion((Long) entity.getProperty("version"));
        model.setMyCipherLobString(decrypt(textToString((Text) entity
            .getProperty("myCipherLobString"))));
        model.setMyCipherString(decrypt((java.lang.String) entity
            .getProperty("myCipherString")));
        model
            .setMyCipherText(decrypt((Text) entity.getProperty("myCipherText")));
        return model;
    }
View Full Code Here

        return model;
    }

    @Override
    public Entity modelToEntity(Object model) {
        Hoge m = (Hoge) model;
        Entity e = null;
        if (m.getKey() != null) {
            e = new Entity(m.getKey());
        } else {
            e = new Entity("Hoge");
        }
        e.setProperty("myPrimitiveShort", m.getMyPrimitiveShort());
        e.setProperty("myShort", m.getMyShort());
        e.setProperty("myPrimitiveInt", m.getMyPrimitiveInt());
        e.setProperty("myInteger", m.getMyInteger());
        e.setProperty("myPrimitiveLong", m.getMyPrimitiveLong());
        e.setProperty("myLong", m.getMyLong());
        e.setProperty("myPrimitiveFloat", m.getMyPrimitiveFloat());
        e.setProperty("myFloat", m.getMyFloat());
        e.setProperty("myPrimitiveDouble", m.getMyPrimitiveDouble());
        e.setProperty("myDouble", m.getMyDouble());
        e.setProperty("myString", m.getMyString());
        e.setProperty("myPrimitiveBoolean", m.isMyPrimitiveBoolean());
        e.setProperty("myBoolean", m.getMyBoolean());
        e.setProperty("myDate", m.getMyDate());
        e.setProperty("myEnum", enumToString(m.getMyEnum()));

        e.setUnindexedProperty(
            "myStringText",
            stringToText(m.getMyStringText()));
        e.setUnindexedProperty("myText", m.getMyText());
        e.setUnindexedProperty("myBytes", bytesToShortBlob(m.getMyBytes()));
        e.setUnindexedProperty("myBytesBlob", bytesToBlob(m.getMyBytesBlob()));
        e.setUnindexedProperty("mySerializable", serializableToShortBlob(m
            .getMySerializable()));
        e.setUnindexedProperty("mySerializableBlob", serializableToBlob(m
            .getMySerializableBlob()));
        e.setProperty("myBlob", m.getMyBlob());
        e.setProperty("myShortList", m.getMyShortList());
        e.setProperty("myShortSet", m.getMyShortSet());
        e.setProperty("myShortSortedSet", m.getMyShortSortedSet());

        e.setProperty("myIntegerList", m.getMyIntegerList());
        e.setProperty("myIntegerSet", m.getMyIntegerSet());
        e.setProperty("myIntegerSortedSet", m.getMyIntegerSortedSet());

        e.setProperty("myLongList", m.getMyLongList());
        e.setProperty("myLongSet", m.getMyLongSet());
        e.setProperty("myLongSortedSet", m.getMyLongSortedSet());

        e.setProperty("myFloatList", m.getMyFloatList());
        e.setProperty("myFloatSet", m.getMyFloatSet());
        e.setProperty("myFloatSortedSet", m.getMyFloatSortedSet());

        e.setProperty("myEnumList", enumListToStringList(m.getMyEnumList()));
        e.setProperty("myStringList", m.getMyStringList());

        e.setProperty("version", m.getVersion());
        e.setUnindexedProperty("myCipherLobString", stringToText(encrypt(m
            .getMyCipherLobString())));
        e.setProperty("myCipherString", encrypt(m.getMyCipherString()));
        e.setUnindexedProperty("myCipherText", encrypt(m.getMyCipherText()));
        return e;
    }
View Full Code Here

        DatastoreUtil.put(ds, null, new Entity("Hoge"));
        EntityQuery query = new EntityQuery(ds, "Hoge");
        Iterator<Entity> iterator = query.asIterator();
        ModelIterator<Hoge> modelIterator =
            new ModelIterator<Hoge>(iterator, meta);
        Hoge hoge = modelIterator.next();
        assertThat(hoge, is(notNullValue()));
    }
View Full Code Here

     * @throws Exception
     */
    @Test
    public void compare() throws Exception {
        InMemoryDescCriterion c = new InMemoryDescCriterion(meta.myString);
        assertThat(c.compare(new Hoge(), new Hoge()), is(0));
        Hoge hoge = new Hoge();
        hoge.setMyString("aaa");
        assertThat(c.compare(new Hoge(), hoge), is(1));
        assertThat(c.compare(hoge, new Hoge()), is(-1));
        Hoge hoge2 = new Hoge();
        hoge2.setMyString("bbb");
        assertThat(c.compare(hoge, hoge2), is(1));
        assertThat(c.compare(hoge2, hoge), is(-1));
    }
View Full Code Here

     * @throws Exception
     */
    @Test
    public void compareForEnum() throws Exception {
        InMemoryDescCriterion c = new InMemoryDescCriterion(meta.myEnum);
        assertThat(c.compare(new Hoge(), new Hoge()), is(0));
        Hoge hoge = new Hoge();
        hoge.setMyEnum(SortDirection.ASCENDING);
        assertThat(c.compare(new Hoge(), hoge), is(1));
        assertThat(c.compare(hoge, new Hoge()), is(-1));
        Hoge hoge2 = new Hoge();
        hoge2.setMyEnum(SortDirection.DESCENDING);
        assertThat(c.compare(hoge, hoge2) > 0, is(true));
        assertThat(c.compare(hoge2, hoge) < 0, is(true));
    }
View Full Code Here

TOP

Related Classes of org.slim3.datastore.model.Hoge

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.