|  | @@ -118,6 +118,7 @@ def org_name(block):
 | 
											
												
													
														|  |          "InputScale": get_field("InputScale", block),
 |  |          "InputScale": get_field("InputScale", block),
 | 
											
												
													
														|  |          "TimeArray": get_field("TimeArray", block),
 |  |          "TimeArray": get_field("TimeArray", block),
 | 
											
												
													
														|  |          "ColSrcType": get_field("ColSrcType", block),
 |  |          "ColSrcType": get_field("ColSrcType", block),
 | 
											
												
													
														|  | 
 |  | +        "Associations": [],
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -180,13 +181,7 @@ def levels(block):
 | 
											
												
													
														|  |          "Timerank": get_field("Timerank", block),
 |  |          "Timerank": get_field("Timerank", block),
 | 
											
												
													
														|  |          "UniqueCategories": get_field("UniqueCategories", block),
 |  |          "UniqueCategories": get_field("UniqueCategories", block),
 | 
											
												
													
														|  |          "UniqueMove": get_field("UniqueMove", block),
 |  |          "UniqueMove": get_field("UniqueMove", block),
 | 
											
												
													
														|  | -        "Associations": [
 |  | 
 | 
											
												
													
														|  | -            associations(b)
 |  | 
 | 
											
												
													
														|  | -            for b in re.findall(
 |  | 
 | 
											
												
													
														|  | -                r"Associations .*",
 |  | 
 | 
											
												
													
														|  | -                block.replace("Associations ", "\nAssociations "),
 |  | 
 | 
											
												
													
														|  | -            )
 |  | 
 | 
											
												
													
														|  | -        ],
 |  | 
 | 
											
												
													
														|  | 
 |  | +        "Associations": [],
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -264,6 +259,7 @@ def associations(block):
 | 
											
												
													
														|  |          "AssociationReferenced": get_field("AssociationReferenced", block),
 |  |          "AssociationReferenced": get_field("AssociationReferenced", block),
 | 
											
												
													
														|  |          "SortOrder": get_field("SortOrder", block),
 |  |          "SortOrder": get_field("SortOrder", block),
 | 
											
												
													
														|  |          "SortAs": get_field("SortAs", block),
 |  |          "SortAs": get_field("SortAs", block),
 | 
											
												
													
														|  | 
 |  | +        "Parent": "0",
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -302,13 +298,7 @@ def measure(block):
 | 
											
												
													
														|  |          "IsFolder": get_field("IsFolder", block),
 |  |          "IsFolder": get_field("IsFolder", block),
 | 
											
												
													
														|  |          "Format": get_field("Format", block),
 |  |          "Format": get_field("Format", block),
 | 
											
												
													
														|  |          "DrillThrough": get_field("DrillThrough", block),
 |  |          "DrillThrough": get_field("DrillThrough", block),
 | 
											
												
													
														|  | -        "Associations": [
 |  | 
 | 
											
												
													
														|  | -            associations(b)
 |  | 
 | 
											
												
													
														|  | -            for b in re.findall(
 |  | 
 | 
											
												
													
														|  | -                r"Associations .*",
 |  | 
 | 
											
												
													
														|  | -                block.replace("Associations ", "\nAssociations "),
 |  | 
 | 
											
												
													
														|  | -            )
 |  | 
 | 
											
												
													
														|  | -        ],
 |  | 
 | 
											
												
													
														|  | 
 |  | +        "Associations": [],
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -392,6 +382,54 @@ def cube(block):
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +def custom_view(block):
 | 
											
												
													
														|  | 
 |  | +    id, name = get_field("CustomView", block, 2)
 | 
											
												
													
														|  | 
 |  | +    return {
 | 
											
												
													
														|  | 
 |  | +        "Type": "CustomView",
 | 
											
												
													
														|  | 
 |  | +        "ID": id,
 | 
											
												
													
														|  | 
 |  | +        "Name": name,
 | 
											
												
													
														|  | 
 |  | +        "DimensionView": [
 | 
											
												
													
														|  | 
 |  | +            b for b in re.findall(r'DimensionView (\d+) "([^"]+)"', block)
 | 
											
												
													
														|  | 
 |  | +        ],
 | 
											
												
													
														|  | 
 |  | +        "MeasureInclude": [
 | 
											
												
													
														|  | 
 |  | +            b for b in re.findall(r"MeasureInclude (\d+) (\w+) ", block)
 | 
											
												
													
														|  | 
 |  | +        ],
 | 
											
												
													
														|  | 
 |  | +        "ChildList": {},
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +def custom_view_child_list(block):
 | 
											
												
													
														|  | 
 |  | +    id, name = get_field("CustomViewChildList", block, 2)
 | 
											
												
													
														|  | 
 |  | +    return {
 | 
											
												
													
														|  | 
 |  | +        "Type": "CustomViewChildList",
 | 
											
												
													
														|  | 
 |  | +        "ID": id,
 | 
											
												
													
														|  | 
 |  | +        "Name": name,
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +def security_namespace(block):
 | 
											
												
													
														|  | 
 |  | +    id, name = get_field("SecurityNameSpace", block, 2)
 | 
											
												
													
														|  | 
 |  | +    return {
 | 
											
												
													
														|  | 
 |  | +        "Type": "SecurityNameSpace",
 | 
											
												
													
														|  | 
 |  | +        "ID": id,
 | 
											
												
													
														|  | 
 |  | +        "Name": name,
 | 
											
												
													
														|  | 
 |  | +        "SecurityNameSpaceCAMID": get_field("SecurityNameSpaceCAMID", block),
 | 
											
												
													
														|  | 
 |  | +        "Objects": [],
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +def security_object(block):
 | 
											
												
													
														|  | 
 |  | +    id, name = get_field("SecurityObject", block, 2)
 | 
											
												
													
														|  | 
 |  | +    return {
 | 
											
												
													
														|  | 
 |  | +        "Type": "SecurityObject",
 | 
											
												
													
														|  | 
 |  | +        "ID": id,
 | 
											
												
													
														|  | 
 |  | +        "Name": name,
 | 
											
												
													
														|  | 
 |  | +        "SecurityObjectDisplayName": get_field("SecurityObjectDisplayName", block),
 | 
											
												
													
														|  | 
 |  | +        "SecurityObjectType": get_field("SecurityObjectType", block),
 | 
											
												
													
														|  | 
 |  | +        "CustomViewList": get_field("CustomViewList", block),
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  CONVERSION = {
 |  |  CONVERSION = {
 | 
											
												
													
														|  |      "Name": model_name,
 |  |      "Name": model_name,
 | 
											
												
													
														|  |      "CognosSource": cognos_source,
 |  |      "CognosSource": cognos_source,
 | 
											
										
											
												
													
														|  | @@ -402,6 +440,7 @@ CONVERSION = {
 | 
											
												
													
														|  |      "Root": root,
 |  |      "Root": root,
 | 
											
												
													
														|  |      "Drill": drill,
 |  |      "Drill": drill,
 | 
											
												
													
														|  |      "Levels": levels,
 |  |      "Levels": levels,
 | 
											
												
													
														|  | 
 |  | +    "Associations": associations,
 | 
											
												
													
														|  |      "Category": category,
 |  |      "Category": category,
 | 
											
												
													
														|  |      "SpecialCategory": special_category,
 |  |      "SpecialCategory": special_category,
 | 
											
												
													
														|  |      "MapDrills": map_drills,
 |  |      "MapDrills": map_drills,
 | 
											
										
											
												
													
														|  | @@ -409,6 +448,10 @@ CONVERSION = {
 | 
											
												
													
														|  |      "Measure": measure,
 |  |      "Measure": measure,
 | 
											
												
													
														|  |      "Signon": signon,
 |  |      "Signon": signon,
 | 
											
												
													
														|  |      "Cube": cube,
 |  |      "Cube": cube,
 | 
											
												
													
														|  | 
 |  | +    "CustomView": custom_view,
 | 
											
												
													
														|  | 
 |  | +    "CustomViewChildList": custom_view_child_list,
 | 
											
												
													
														|  | 
 |  | +    "SecurityNameSpace": security_namespace,
 | 
											
												
													
														|  | 
 |  | +    "SecurityObject": security_object,
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -423,11 +466,14 @@ def convert_block(block):
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  def main(filename):
 |  |  def main(filename):
 | 
											
												
													
														|  | -    with open(filename, "r") as frh:
 |  | 
 | 
											
												
													
														|  | 
 |  | +    with open(filename, "r", encoding="latin-1") as frh:
 | 
											
												
													
														|  |          mdl_str = frh.read()
 |  |          mdl_str = frh.read()
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      mdl_str = re.sub(r"\n+", "\n", mdl_str)
 |  |      mdl_str = re.sub(r"\n+", "\n", mdl_str)
 | 
											
												
													
														|  | -    mdl_str = re.sub(r"\nLevels 0 ", "Levels 0 ", mdl_str)
 |  | 
 | 
											
												
													
														|  | 
 |  | +    mdl_str = re.sub(r'\nLevels (\d+ [^"])', r"Levels \1", mdl_str)
 | 
											
												
													
														|  | 
 |  | +    mdl_str = re.sub(r" Associations ", " \nAssociations ", mdl_str)
 | 
											
												
													
														|  | 
 |  | +    mdl_str = re.sub(r'([^ ])""', r"\1'", mdl_str)
 | 
											
												
													
														|  | 
 |  | +    mdl_str = re.sub(r'""([^ ])', r"'\1", mdl_str)
 | 
											
												
													
														|  |      tags = "|".join(list(CONVERSION.keys()))
 |  |      tags = "|".join(list(CONVERSION.keys()))
 | 
											
												
													
														|  |      mdl_str = re.sub(r"\n(" + tags + r") ", r"\n\n\1 ", mdl_str)
 |  |      mdl_str = re.sub(r"\n(" + tags + r") ", r"\n\n\1 ", mdl_str)
 | 
											
												
													
														|  |      mdl_blocks = mdl_str.split("\n\n")
 |  |      mdl_blocks = mdl_str.split("\n\n")
 | 
											
										
											
												
													
														|  | @@ -440,45 +486,74 @@ def main(filename):
 | 
											
												
													
														|  |          "Dimensions": [],
 |  |          "Dimensions": [],
 | 
											
												
													
														|  |          "Measures": [],
 |  |          "Measures": [],
 | 
											
												
													
														|  |          "Signons": [],
 |  |          "Signons": [],
 | 
											
												
													
														|  | 
 |  | +        "CustomViews": [],
 | 
											
												
													
														|  | 
 |  | +        "Security": [],
 | 
											
												
													
														|  |          "Cubes": [],
 |  |          "Cubes": [],
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |      types = [c["Type"] for c in converted]
 |  |      types = [c["Type"] for c in converted]
 | 
											
												
													
														|  |      current = None
 |  |      current = None
 | 
											
												
													
														|  | 
 |  | +    level_ids = []
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      for c, t in zip(converted, types):
 |  |      for c, t in zip(converted, types):
 | 
											
												
													
														|  |          if t in [""]:
 |  |          if t in [""]:
 | 
											
												
													
														|  |              continue
 |  |              continue
 | 
											
												
													
														|  | 
 |  | +        if t in ["Category"] and result["Dimensions"][-1]["Name"] == "Zeit":
 | 
											
												
													
														|  | 
 |  | +            continue
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |          if t in ["ModelName"]:
 |  |          if t in ["ModelName"]:
 | 
											
												
													
														|  |              result["Model"] = c
 |  |              result["Model"] = c
 | 
											
												
													
														|  | -        if t in ["CognosSource", "CognosPackageDatasourceConnection"]:
 |  | 
 | 
											
												
													
														|  | 
 |  | +        elif t in ["CognosSource", "CognosPackageDatasourceConnection"]:
 | 
											
												
													
														|  |              result["Connections"].append(c)
 |  |              result["Connections"].append(c)
 | 
											
												
													
														|  | -        if t in ["DataSource"]:
 |  | 
 | 
											
												
													
														|  | -            current = c
 |  | 
 | 
											
												
													
														|  | 
 |  | +        elif t in ["DataSource"]:
 | 
											
												
													
														|  |              result["DataSources"].append(c)
 |  |              result["DataSources"].append(c)
 | 
											
												
													
														|  | -        if t in ["OrgName"]:
 |  | 
 | 
											
												
													
														|  | -            current["Columns"].append(c)
 |  | 
 | 
											
												
													
														|  | -        if t in ["Dimension"]:
 |  | 
 | 
											
												
													
														|  | -            current = c
 |  | 
 | 
											
												
													
														|  | 
 |  | +        elif t in ["OrgName"]:
 | 
											
												
													
														|  | 
 |  | +            result["DataSources"][-1]["Columns"].append(c)
 | 
											
												
													
														|  | 
 |  | +        elif t in ["Dimension"]:
 | 
											
												
													
														|  | 
 |  | +            level_ids = []
 | 
											
												
													
														|  |              result["Dimensions"].append(c)
 |  |              result["Dimensions"].append(c)
 | 
											
												
													
														|  | -        if t in ["Root"]:
 |  | 
 | 
											
												
													
														|  | -            current["Root"] = c
 |  | 
 | 
											
												
													
														|  | -        if t in ["Drill"]:
 |  | 
 | 
											
												
													
														|  | -            current["Root"]["Drill"] = c
 |  | 
 | 
											
												
													
														|  | -        if t in ["Levels"]:
 |  | 
 | 
											
												
													
														|  | -            current["Levels"].append(c)
 |  | 
 | 
											
												
													
														|  | -        if t in ["Category"] and current["Name"] != "Zeit":
 |  | 
 | 
											
												
													
														|  | -            current["Categories"].append(c)
 |  | 
 | 
											
												
													
														|  | -        if t in ["SpecialCategory"]:
 |  | 
 | 
											
												
													
														|  | -            current["SpecialCategories"].append(c)
 |  | 
 | 
											
												
													
														|  | -        if t in ["Measure"]:
 |  | 
 | 
											
												
													
														|  | 
 |  | +        elif t in ["Root"]:
 | 
											
												
													
														|  | 
 |  | +            result["Dimensions"][-1]["Root"] = c
 | 
											
												
													
														|  | 
 |  | +        elif t in ["Drill"]:
 | 
											
												
													
														|  | 
 |  | +            result["Dimensions"][-1]["Root"]["Drill"] = c
 | 
											
												
													
														|  | 
 |  | +        elif t in ["Levels"]:
 | 
											
												
													
														|  | 
 |  | +            current = c
 | 
											
												
													
														|  | 
 |  | +            level_ids.append(c["ID"])
 | 
											
												
													
														|  | 
 |  | +            result["Dimensions"][-1]["Levels"].append(c)
 | 
											
												
													
														|  | 
 |  | +        elif t in ["Category"]:
 | 
											
												
													
														|  | 
 |  | +            if c["Levels"] in level_ids[0:2]:
 | 
											
												
													
														|  | 
 |  | +                result["Dimensions"][-1]["Categories"].append(c)
 | 
											
												
													
														|  | 
 |  | +        elif t in ["SpecialCategory"]:
 | 
											
												
													
														|  | 
 |  | +            result["Dimensions"][-1]["SpecialCategories"].append(c)
 | 
											
												
													
														|  | 
 |  | +        elif t in ["Measure"]:
 | 
											
												
													
														|  | 
 |  | +            current = c
 | 
											
												
													
														|  |              result["Measures"].append(c)
 |  |              result["Measures"].append(c)
 | 
											
												
													
														|  | -        if t in ["Signon"]:
 |  | 
 | 
											
												
													
														|  | 
 |  | +        elif t in ["Associations"]:
 | 
											
												
													
														|  | 
 |  | +            c["Parent"] = current["ID"]
 | 
											
												
													
														|  | 
 |  | +            current["Associations"].append(c)
 | 
											
												
													
														|  | 
 |  | +            for ds in result["DataSources"]:
 | 
											
												
													
														|  | 
 |  | +                for col in ds["Columns"]:
 | 
											
												
													
														|  | 
 |  | +                    if col["Column"] == c["AssociationReferenced"]:
 | 
											
												
													
														|  | 
 |  | +                        col["Associations"].append(c)
 | 
											
												
													
														|  | 
 |  | +        elif t in ["Signon"]:
 | 
											
												
													
														|  |              result["Signons"].append(c)
 |  |              result["Signons"].append(c)
 | 
											
												
													
														|  | -        if t in ["Cube"]:
 |  | 
 | 
											
												
													
														|  | 
 |  | +        elif t in ["Cube"]:
 | 
											
												
													
														|  |              result["Cubes"].append(c)
 |  |              result["Cubes"].append(c)
 | 
											
												
													
														|  | 
 |  | +        elif t in ["CustomView"]:
 | 
											
												
													
														|  | 
 |  | +            result["CustomViews"].append(c)
 | 
											
												
													
														|  | 
 |  | +        elif t in ["CustomViewChildList"]:
 | 
											
												
													
														|  | 
 |  | +            for cv in result["CustomViews"]:
 | 
											
												
													
														|  | 
 |  | +                if cv["ID"] == c["ID"]:
 | 
											
												
													
														|  | 
 |  | +                    cv["ChildList"] = c
 | 
											
												
													
														|  | 
 |  | +        elif t in ["SecurityNameSpace"]:
 | 
											
												
													
														|  | 
 |  | +            result["Security"].append(c)
 | 
											
												
													
														|  | 
 |  | +        elif t in ["SecurityObject"]:
 | 
											
												
													
														|  | 
 |  | +            result["Security"][-1]["Objects"].append(c)
 | 
											
												
													
														|  | 
 |  | +        # else:
 | 
											
												
													
														|  | 
 |  | +        #     print(t, c)
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      json.dump(result, open(filename[:-4] + ".json", "w"), indent=2)
 |  |      json.dump(result, open(filename[:-4] + ".json", "w"), indent=2)
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  if __name__ == "__main__":
 |  |  if __name__ == "__main__":
 | 
											
												
													
														|  | -    main("data/S_Offene_Auftraege.mdl")
 |  | 
 | 
											
												
													
														|  | 
 |  | +    # main("data/S_Offene_Auftraege.mdl")
 | 
											
												
													
														|  | 
 |  | +    main("data/F_Belege_SKR_SKR_Boettche.mdl")
 |