public static void addPhotoProxy( VegetationSurveyProxy proxy, PhotoProxy photoProxy, CategoryElementsListAdapter.ViewModel viewModel) { for (StationElementProxy seProxy : proxy.getStationElements()) { if (seProxy.getModel().getElement().getId() == viewModel.getElementId()) { if (seProxy.getPhotos() == null) seProxy.setPhotos(new ArrayList<PhotoProxy>()); seProxy.getPhotos().add(photoProxy); } } }
public static void updateFromViewModels( ArrayList<CategoryElementsListAdapter.ViewModel> viewModels, List<StationElementProxy> proxies) { StationElementProxy.StationElementProxyByRowGuidComparator comparator = new StationElementProxy.StationElementProxyByRowGuidComparator(); List<StationElementProxy> fromVM = CategorySurveyService.convertToProxies(viewModels); List<StationElementProxy> forDelete = CollectionOperations.except(proxies, fromVM, comparator); if (forDelete != null && forDelete.size() > 0) CollectionOperations.removeAll(proxies, forDelete, comparator); // PhotoService photoService = new PhotoService(SageApplication.getInstance().getDaoSession()); for (StationElementProxy proxy : proxies) { // TODO: investigate moving to ElementService StationElementProxy temp = CollectionOperations.find(fromVM, proxy, comparator); proxy.getModel().setCount(temp.getModel().getCount()); MetaDataService.MetaSupportExtensionMethods.replace(proxy.getModel(), temp.getModel()); updateLocationProxy(proxy, temp); // TODO: deal with photos temp.setPhotos(proxy.getPhotos()); // List<Photo> photos = photoService.find(proxy.getModel()); // if(photos != null && photos.size() > 0) proxy.setPhotos(PhotoService.convertToProxy(photos, // proxy.getModel())); } }