private static void updateLocationProxy( StationElementProxy destination, StationElementProxy source) { if (destination.getLocation() == null && source.getLocation() == null) return; else if (destination.getLocation() == null) { destination.setLocation(source.getLocation()); if (destination.getModel().getRowGuid() == null) destination.getModel().setRowGuid(); destination.getLocation().getModel().setName(destination.getModel().getRowGuid()); } else if (source.getLocation() == null) { destination.setLocation(null); } else { destination.getLocation().setCoordinates(source.getLocation().getCoordinates()); } }
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; }