public static StationElementProxy convertToProxy(
     CategoryElementsListAdapter.ViewModel viewModel) {
   StationElementProxy proxy = new StationElementProxy();
   StationElement se = new StationElement();
   Element element = new Element();
   DescriptorServices.setByFieldDescriptor(viewModel, element);
   DescriptorServices.setByFieldDescriptor(viewModel, se);
   List<StationElementMeta> metaElements = MetaDataService.fromAnnotations(viewModel, true);
   if (metaElements != null && metaElements.size() > 0) se.setMetaData(metaElements);
   se.setElement(element);
   proxy.setModel(se);
   if (viewModel.location != null) {
     Location l = new Location();
     if (proxy.getModel().getRowGuid() == null) proxy.getModel().setRowGuid();
     l.setName(proxy.getModel().getRowGuid());
     LocationProxy lp = LocationService.createPointFromLocation(viewModel.location, l);
     proxy.setLocation(lp);
   }
   return proxy;
 }
 /**
  * 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;
 }