예제 #1
0
def map_measures(votable_path):
    vodml_instance = VodmlInstance(votable_path)
    vodml_instance.populate_templates()
    vodml_instance.connect_join_iterators()

    instance = vodml_instance.get_root_element("mango:MangoObject")
    if instance is None:
        raise Exception("No root element found")

    while True:
        inst = instance._get_next_row_instance()
        if inst != None:
            break
        else:
            break

    #BUG 2 parameters arrays are nested
    #TODO 2 be fixed
    parameters = inst["mango:MangoObject.parameters"]
    parameters = parameters[0]["mango:MangoObject.parameters"]
    parameter_map = {}
    for parameter in parameters:
        ucd = parameter["mango:Parameter.ucd"]["@value"]
        classe = parameter["mango:Parameter.measure"]["@dmtype"]
        semantic = parameter["mango:Parameter.semantic"]["@value"]
        description = parameter["mango:Parameter.description"]["@value"]
        parameter_map[classe] = {
            "class": classe,
            "ucd": ucd,
            "semantic": semantic,
            "description": description
        }
    return parameter_map
예제 #2
0
    def setUp(self):
        self.data_path = os.path.dirname(os.path.realpath(__file__))
        self.votable_path = os.path.join(self.data_path, "./data/test_rich_vodml_instance.xml")
        self.json_ref_path = os.path.join(self.data_path, "./data/test_rich_vodml_instance.json")

        logger.info("processing %s", self.votable_path)
        self.populated = False
        self.vodml_instance = VodmlInstance(self.votable_path)
예제 #3
0
file_path = os.path.dirname(os.path.realpath(__file__)) + "/../../"
if file_path not in sys.path:
    sys.path.append(file_path)

from client.demo import data_dir

from utils.dict_utils import DictUtils

from client.inst_builder.vodml_instance import VodmlInstance

if __name__ == '__main__':
    base_path = os.path.dirname(os.path.realpath(__file__))
    votable_path = os.path.join(data_dir, "annotated_data",
                                "vizier_votable_avecActivity_Vo-dml-lite.xml")
    vodml_instance = VodmlInstance(votable_path)
    vodml_instance.populate_templates()
    vodml_instance.connect_join_iterators()

    instance = vodml_instance.get_root_element("voprov:Entity")

    print(DictUtils.get_pretty_json(instance.json))
    print("=== Mapping of the columns")
    print(instance.get_flatten_data_head())
    #print(instance.get_data_subset_keys())
    print("=== First row: flatten mode")
    while True:
        inst = instance._get_next_flatten_row()
        if inst != None:
            print(DictUtils.get_pretty_json(inst))
            break