View Javadoc
1   package com.srv4pos.server.api.sync.sample;
2   
3   import com.srv4pos.server.api.infrastructure.picture.SaleSlotPictureInfo;
4   import com.srv4pos.server.api.sync.EntityPictureSyncAdapter;
5   
6   /**
7    * Created by misha on 30.06.16.
8    */
9   public class SaleSlotPictureSyncAdapter implements EntityPictureSyncAdapter<SaleSlotPictureInfo> {
10      private final MemoryLocalStorage storage;
11  
12      public SaleSlotPictureSyncAdapter(MemoryLocalStorage storage) {
13          this.storage = storage;
14      }
15  
16      public void createOrUpdateEntityPictureFromBytes(SaleSlotPictureInfo info, byte[] pictureBytes) {
17  
18          final String entityIdentifier = info.getEntityIdentifier();
19          final SyncSaleSlot saleSlot = storage.getSaleSlotByIdentifier(entityIdentifier);
20  
21          if (saleSlot != null && !saleSlot.getInfo().isDeleted()) {
22              saleSlot.setPictureBytes(pictureBytes);
23          }
24  
25      }
26  }