use of org.locationtech.geogig.osm.internal.OSMImportOp in project GeoGig by boundlessgeo.
the class OsmImportWebOp method getRepresentation.
@Override
public Representation getRepresentation(final Variant variant) {
final Request request = getRequest();
final Context context = super.getContext(request);
Form options = getRequest().getResourceRef().getQueryAsForm();
final String urlOrFilepath = options.getFirstValue("uri");
final boolean add = Boolean.valueOf(options.getFirstValue("add"));
final String mappingFile = options.getFirstValue("mapping");
Mapping mapping = null;
if (mappingFile != null) {
mapping = Mapping.fromFile(mappingFile);
}
final boolean noRaw = Boolean.valueOf(options.getFirstValue("noRaw"));
final String message = options.getFirstValue("message");
if (urlOrFilepath == null) {
String msg = "Missing parameter: uri\n" + "Usage: GET <repo context>/osm/import?uri=<osm file URI>[&<arg>=<value>]+\n" + "Arguments:\n" + " * uri: Mandatory. URL or path to OSM data file in the server filesystem\n" + " * add: Optional. true|false. Default: false. If true, do not remove previous data before importing.\n" + " * mapping: Optional. Location of mapping file in the server filesystem\n" + " * noRaw: Optional. true|false. Default: false. If true, do not import raw data when using a mapping\n" + " * message: Optional. Message for the commit to create.";
throw new CommandSpecException(msg);
}
OSMImportOp command = context.command(OSMImportOp.class);
command.setAdd(add);
command.setDataSource(urlOrFilepath);
command.setMapping(mapping);
command.setMessage(message);
command.setNoRaw(noRaw);
AsyncCommand<Optional<OSMReport>> asyncCommand;
URL repo = context.repository().getLocation();
String description = String.format("osm import %s, repository: %s", urlOrFilepath, repo);
asyncCommand = AsyncContext.get().run(command, description);
final String rootPath = request.getRootRef().toString();
MediaType mediaType = variant.getMediaType();
Representation rep = new OSMReportRepresentation(mediaType, asyncCommand, rootPath);
return rep;
}
Aggregations