def update_model(datasetname): #we just got everything now let's save it sourcemeta = request.get_json().get("meta", None) sourcemodeler = request.get_json().get("modeler", None) #validate that we have everything here r = {"mapping":sourcemodeler} #let's handle the compounds for item in r['mapping'].values(): if item['type'] in ("compound", "geometry"): for attitem in item['attributes'].values(): if attitem['column'] == 'countryid': pass attitem['column'] = item['column'] #if not hasattr(r['mapping'], 'theid'): r['mapping']['theid'] = { "default_value": "", "description": "Unique ID", "datatype": "string", "key": True, "label": "UniqueID", "column": "uniqueid", "type": "attribute", "form": { "label": "Unique Identifier" } } r['mapping']['geom_time_id'] = { "default_value": "", "description": "Geometry Time ID", "datatype": "integer", "label": "Geometry Time ID", "column": "geom_time_id", "type": "geom_time_id", "form": { "label": "Geometry-Time ID" } } dataset = get_dataset(datasetname) dataset.mapping = r dataset.ORoperations = {'data': dataset.source.getORInstructions()} dataset.source.addData(r) db.session.commit() load_source(dataset.source.id) cache.clear() #add async request to load data return jsonify({"success":True})
def update_model(datasetname): #we just got everything now let's save it sourcemeta = request.get_json().get("meta", None) sourcemodeler = request.get_json().get("modeler", None) #validate that we have everything here r = {"mapping": sourcemodeler} #let's handle the compounds for item in r['mapping'].values(): if item['type'] in ("compound", "geometry"): for attitem in item['attributes'].values(): if attitem['column'] == 'countryid': pass attitem['column'] = item['column'] #if not hasattr(r['mapping'], 'theid'): r['mapping']['theid'] = { "default_value": "", "description": "Unique ID", "datatype": "string", "key": True, "label": "UniqueID", "column": "uniqueid", "type": "attribute", "form": { "label": "Unique Identifier" } } r['mapping']['geom_time_id'] = { "default_value": "", "description": "Geometry Time ID", "datatype": "integer", "label": "Geometry Time ID", "column": "geom_time_id", "type": "geom_time_id", "form": { "label": "Geometry-Time ID" } } dataset = get_dataset(datasetname) dataset.mapping = r dataset.ORoperations = {'data': dataset.source.getORInstructions()} dataset.source.addData(r) db.session.commit() load_source(dataset.source.id) cache.clear() #add async request to load data return jsonify({"success": True})
def reload_all(**args): """Reload all sources with mapping. This will take a while""" datasets = Dataset.all().all() ids = [] for dataset in datasets: ids.append(dataset.id) total = 0 ran = 0 for id in ids: dataset = Dataset.by_id(id) total += 1 #has mapping and source if dataset.mapping and dataset.source: print "working on ", dataset load_source(dataset.source.id) ran += 1 print "Ran", ran, "out of", total
def reload_all(**args): """Reload all sources with mapping. This will take a while""" datasets = Dataset.all().all() ids = [] for dataset in datasets: ids.append(dataset.id) total = 0 ran = 0 for id in ids: dataset = Dataset.by_id(id) total +=1 #has mapping and source if dataset.mapping and dataset.source: print "working on ", dataset load_source(dataset.source.id) ran +=1 print "Ran", ran, "out of", total