Search in sources :

Example 46 with ClassInfo

use of siena.ClassInfo in project siena by mandubian.

the class PersistenceManagerLifeCycleWrapper method insert.

@Override
public void insert(Object obj) {
    ClassInfo ci = ClassInfo.getClassInfo(obj.getClass());
    LifeCycleUtils.executeMethods(LifeCyclePhase.PRE_INSERT, ci, obj);
    pm.insert(obj);
    LifeCycleUtils.executeMethods(LifeCyclePhase.POST_INSERT, ci, obj);
}
Also used : ClassInfo(siena.ClassInfo)

Example 47 with ClassInfo

use of siena.ClassInfo in project siena by mandubian.

the class SdbMappingUtils method mapSelectResultToListKeysOnly.

public static <T> void mapSelectResultToListKeysOnly(SelectResult res, List<T> resList, Class<T> clazz, int offset) {
    List<Item> items = res.getItems();
    ClassInfo info = ClassInfo.getClassInfo(clazz);
    for (int i = offset; i < items.size(); i++) {
        Item item = items.get(i);
        T obj = Util.createObjectInstance(clazz);
        fillModelKeysOnly(item, clazz, info, obj);
        resList.add(obj);
    }
}
Also used : DeletableItem(com.amazonaws.services.simpledb.model.DeletableItem) ReplaceableItem(com.amazonaws.services.simpledb.model.ReplaceableItem) Item(com.amazonaws.services.simpledb.model.Item) ClassInfo(siena.ClassInfo)

Example 48 with ClassInfo

use of siena.ClassInfo in project siena by mandubian.

the class SdbMappingUtils method mapSelectResultToListKeysOnly.

public static <T> void mapSelectResultToListKeysOnly(SelectResult res, List<T> resList, Class<T> clazz) {
    List<Item> items = res.getItems();
    ClassInfo info = ClassInfo.getClassInfo(clazz);
    for (Item item : items) {
        T obj = Util.createObjectInstance(clazz);
        fillModelKeysOnly(item, clazz, info, obj);
        resList.add(obj);
    }
}
Also used : DeletableItem(com.amazonaws.services.simpledb.model.DeletableItem) ReplaceableItem(com.amazonaws.services.simpledb.model.ReplaceableItem) Item(com.amazonaws.services.simpledb.model.Item) ClassInfo(siena.ClassInfo)

Example 49 with ClassInfo

use of siena.ClassInfo in project siena by mandubian.

the class SdbMappingUtils method mapSelectResultToList.

public static <T> void mapSelectResultToList(SelectResult res, List<T> resList, Class<T> clazz) {
    List<Item> items = res.getItems();
    ClassInfo info = ClassInfo.getClassInfo(clazz);
    for (Item item : items) {
        T obj = Util.createObjectInstance(clazz);
        fillModel(item, clazz, info, obj);
        resList.add(obj);
    }
}
Also used : DeletableItem(com.amazonaws.services.simpledb.model.DeletableItem) ReplaceableItem(com.amazonaws.services.simpledb.model.ReplaceableItem) Item(com.amazonaws.services.simpledb.model.Item) ClassInfo(siena.ClassInfo)

Example 50 with ClassInfo

use of siena.ClassInfo in project siena by mandubian.

the class SdbMappingUtils method mapSelectResult.

public static <T> int mapSelectResult(SelectResult res, Iterable<T> objects) {
    List<Item> items = res.getItems();
    Class<?> clazz = null;
    ClassInfo info = null;
    int nb = 0;
    for (T obj : objects) {
        if (clazz == null) {
            clazz = obj.getClass();
            info = ClassInfo.getClassInfo(clazz);
        }
        String itemName = getItemName(clazz, obj);
        Item theItem = null;
        for (Item item : items) {
            if (item.getName().equals(itemName)) {
                theItem = item;
                items.remove(item);
                break;
            }
        }
        if (theItem != null) {
            fillModel(theItem, clazz, info, obj);
            nb++;
        }
    }
    return nb;
}
Also used : DeletableItem(com.amazonaws.services.simpledb.model.DeletableItem) ReplaceableItem(com.amazonaws.services.simpledb.model.ReplaceableItem) Item(com.amazonaws.services.simpledb.model.Item) ClassInfo(siena.ClassInfo)

Aggregations

ClassInfo (siena.ClassInfo)68 Field (java.lang.reflect.Field)33 ArrayList (java.util.ArrayList)24 Key (com.google.appengine.api.datastore.Key)23 SienaException (siena.SienaException)21 Entity (com.google.appengine.api.datastore.Entity)17 QueryResultList (com.google.appengine.api.datastore.QueryResultList)10 List (java.util.List)10 DeletableItem (com.amazonaws.services.simpledb.model.DeletableItem)6 Item (com.amazonaws.services.simpledb.model.Item)6 ReplaceableItem (com.amazonaws.services.simpledb.model.ReplaceableItem)6 SQLException (java.sql.SQLException)6 ResultSet (java.sql.ResultSet)5 HashMap (java.util.HashMap)5 SienaRestrictedApiException (siena.SienaRestrictedApiException)5 Relation (siena.core.Relation)5 IOException (java.io.IOException)4 QueryFilterSearch (siena.QueryFilterSearch)4 Many4PM (siena.core.Many4PM)4 SienaFutureContainer (siena.core.async.SienaFutureContainer)4