mapping_p_o["skos:note"] = ['"Imported from external mapping resource: Iris 1.1"']
mapping_p_o["mr:reason"] = ['"new mapping"']


with fu.FusekiServer(3131) as fu_p:
    fu_p.load()
    print "load complete"
    for newlink in linkages:
        map_dict = copy.deepcopy(mapping_p_o)
        map_dict["mr:invertible"] = newlink["mr:invertible"]
        st = ["mr:source", "mr:target"]
        for pref in st:
            members = newlink[pref]["mr:hasProperty"]
            memberids = []
            for v_dict in members:
                prop_res = moq.get_property(fu_p, v_dict)
                if prop_res:
                    prop_id = "%s" % prop_res["property"]
                else:
                    raise ValueError("%i results returned from get_value %s" % (len(val_res), str(val_res)))
                memberids.append(prop_id)
            fc_dict = {"mr:hasFormat": newlink[pref]["mr:hasFormat"], "mr:hasProperty": memberids}
            fc_res = moq.get_component(fu_p, fc_dict)
            if fc_res:
                fcID = "%s" % fc_res["component"]
            else:
                raise ValueError("%i results returned from get_component %s" % (len(fc_res), str(fc_res)))
            map_dict[pref] = fcID
        map_res = moq.create_mapping(fu_p, map_dict)
    print "saving cached changes"
    fu_p.save()