Search in sources :

Example 1 with PersistSaveManyAction

use of com.tvd12.calabash.persist.action.PersistSaveManyAction in project calabash by youngmonkeys.

the class PersistSaveActionBulk method execute.

@Override
public void execute() {
    Map<Object, Object> keyValues = new HashMap<>();
    for (PersistAction action : actions) {
        if (action.getType() == PersistActionType.SAVE_ONE) {
            PersistSaveOneAction one = (PersistSaveOneAction) action;
            keyValues.put(one.getKey(), one.getValue());
        } else {
            PersistSaveManyAction many = (PersistSaveManyAction) action;
            keyValues.putAll(many.getKeyValues());
        }
    }
    ((EntityMapPersist) mapPersist).persist(keyValues);
}
Also used : PersistSaveManyAction(com.tvd12.calabash.persist.action.PersistSaveManyAction) HashMap(java.util.HashMap) PersistSaveOneAction(com.tvd12.calabash.persist.action.PersistSaveOneAction) EntityMapPersist(com.tvd12.calabash.persist.EntityMapPersist) PersistAction(com.tvd12.calabash.persist.action.PersistAction)

Example 2 with PersistSaveManyAction

use of com.tvd12.calabash.persist.action.PersistSaveManyAction in project calabash by youngmonkeys.

the class PersistSaveActionBulk method execute.

@Override
public void execute() {
    Map keyValues = new HashMap<>();
    for (PersistAction action : actions) {
        if (action.getType() == PersistActionType.SAVE_ONE) {
            PersistSaveOneAction one = (PersistSaveOneAction) action;
            keyValues.put(one.getKey(), one.getValue());
        } else {
            PersistSaveManyAction many = (PersistSaveManyAction) action;
            keyValues.putAll(many.getKeyValues());
        }
    }
    ((BytesMapPersist) mapPersist).persist(keyValues);
}
Also used : PersistSaveManyAction(com.tvd12.calabash.persist.action.PersistSaveManyAction) HashMap(java.util.HashMap) PersistSaveOneAction(com.tvd12.calabash.persist.action.PersistSaveOneAction) PersistAction(com.tvd12.calabash.persist.action.PersistAction) BytesMapPersist(com.tvd12.calabash.persist.BytesMapPersist) Map(java.util.Map) HashMap(java.util.HashMap)

Example 3 with PersistSaveManyAction

use of com.tvd12.calabash.persist.action.PersistSaveManyAction in project calabash by youngmonkeys.

the class SimpleBytesMapPersistExecutor method persist.

@Override
public void persist(MapSetting mapSetting, Map<ByteArray, byte[]> m) {
    BytesMapPersist mapPersist = getMapPersist(mapSetting);
    if (mapPersist != null) {
        PersistSaveManyAction action = new PersistSaveManyAction(m);
        addPersistActionToQueue(mapSetting, action);
    }
}
Also used : BytesMapPersist(com.tvd12.calabash.persist.BytesMapPersist)

Example 4 with PersistSaveManyAction

use of com.tvd12.calabash.persist.action.PersistSaveManyAction in project calabash by youngmonkeys.

the class SimpleEntityMapPersistExecutor method persist.

@Override
public void persist(EntityMapSetting mapSetting, Map m) {
    EntityMapPersist mapPersist = getMapPersist(mapSetting);
    if (mapPersist != null) {
        PersistSaveManyAction action = new PersistSaveManyAction(m);
        addPersistActionToQueue(mapSetting, action);
    }
}
Also used : EntityMapPersist(com.tvd12.calabash.persist.EntityMapPersist)

Aggregations

BytesMapPersist (com.tvd12.calabash.persist.BytesMapPersist)2 EntityMapPersist (com.tvd12.calabash.persist.EntityMapPersist)2 PersistAction (com.tvd12.calabash.persist.action.PersistAction)2 PersistSaveManyAction (com.tvd12.calabash.persist.action.PersistSaveManyAction)2 PersistSaveOneAction (com.tvd12.calabash.persist.action.PersistSaveOneAction)2 HashMap (java.util.HashMap)2 Map (java.util.Map)1