/** * Builds a ViewModel from the provided proxy note: uses the first location in the proxy's * locations as the location * * @param proxy * @return the generated ViewModel or null if the proxy, or the proxy's model's element is null */ public static CategoryElementsListAdapter.ViewModel convertToViewModel( StationElementProxy proxy) { if (proxy == null || proxy.getModel() == null) return null; CategoryElementsListAdapter.ViewModel vm = convertToViewModel(proxy.getModel().getElement()); if (vm == null) return null; DescriptorServices.getByFieldDescriptor(vm, proxy.getModel()); if (proxy.getModel().hasMetaData()) MetaDataService.updateAnnotations(vm, proxy.getModel().getMetaData()); if (proxy.getLocation() != null && proxy.getLocation().getLocations().size() > 0) vm.location = proxy.getLocation().getLocations().get(0); if (proxy.getPhotos() != null && proxy.getPhotos().size() > 0) vm.photos = PhotoService.convertProxiesToFilePathArray(proxy.getPhotos()); return vm; }
/** * @param element * @return */ public static CategoryElementsListAdapter.ViewModel convertToViewModel(Element element) { if (element == null) return null; CategoryElementsListAdapter.ViewModel vm = new CategoryElementsListAdapter.ViewModel(); DescriptorServices.getByFieldDescriptor(vm, element); return vm; }