Example #1
0
  @Override
  public void insertOrUpdateAssociation(
      AssociationKey key, Association association, AssociationContext associationContext) {
    Map<SerializableRowKey, Map<String, Object>> associationRows =
        ((SerializableMapAssociationSnapshot) association.getSnapshot()).getUnderlyingMap();

    for (AssociationOperation action : association.getOperations()) {
      switch (action.getType()) {
        case CLEAR:
          associationRows.clear();
        case PUT:
          associationRows.put(
              new SerializableRowKey(action.getKey()),
              MapHelpers.associationRowToMap(action.getValue()));
          break;
        case REMOVE:
          associationRows.remove(new SerializableRowKey(action.getKey()));
          break;
      }
    }

    final Cache<AK> associationCache = getCacheManager().getAssociationCache(key.getMetadata());
    associationCache.put(
        new Element(getKeyProvider().getAssociationCacheKey(key), associationRows));
  }
 @Override
 public void insertOrUpdateTuple(
     EntityKey key, TuplePointer tuplePointer, TupleContext tupleContext) {
   Tuple tuple = tuplePointer.getTuple();
   Map<String, Object> atomicMap = ((InfinispanTupleSnapshot) tuple.getSnapshot()).getAtomicMap();
   MapHelpers.applyTupleOpsOnMap(tuple, atomicMap);
 }
Example #3
0
  @Override
  public void insertOrUpdateTuple(EntityKey key, Tuple tuple, TupleContext tupleContext) {
    Cache<EK> entityCache = getCacheManager().getEntityCache(key.getMetadata());

    Map<String, Object> entityRecord = ((MapTupleSnapshot) tuple.getSnapshot()).getMap();

    if (entityRecord.isEmpty()) {
      MapHelpers.applyTupleOpsOnMap(tuple, entityRecord);
      Element previous =
          entityCache.putIfAbsent(
              new Element(getKeyProvider().getEntityCacheKey(key), entityRecord));
      if (previous != null) {
        throw new TupleAlreadyExistsException(key.getMetadata(), tuple);
      }
    } else {
      MapHelpers.applyTupleOpsOnMap(tuple, entityRecord);
      entityCache.put(new Element(getKeyProvider().getEntityCacheKey(key), entityRecord));
    }
  }
 @Override
 public void insertOrUpdateAssociation(
     AssociationKey key, Association association, AssociationContext associationContext) {
   MapHelpers.updateAssociation(association);
 }