Beispiel #1
0
def insert_monitor_topic():
    monitor_topic = get_topic_by_name("raw_pipeline_monitor")
    if monitor_topic is None:
        topic = Topic()
        topic.topicId = get_surrogate_key()
        topic.name = "raw_pipeline_monitor"
        topic.type = "raw"
        topic.kind = "system"
        save_topic(topic)
Beispiel #2
0
def build_topic(model_schema_set: ModelSchemaSet, current_user):
    topic = Topic()
    topic.tenantId = current_user.tenantId
    topic.topicId = get_surrogate_key()
    topic.name = model_schema_set.code
    topic.type = "raw"
    topic.factors = []
    parent = ""
    build_factors(topic.factors, parent, model_schema_set.schemas[topic.name],
                  model_schema_set)
    create_topic_schema(topic)
def create_raw_topic(code, data, current_user):
    topic = Topic()
    topic.topicId = get_surrogate_key()
    topic.tenantId = current_user.tenantId
    topic.name = code
    topic.type = "raw"
    topic.factors = []
    queue = deque([])
    if type(data) == list:
        for record in data:
            model: dict = {"root": record}
            queue.append(model)
    create_factors(queue, topic)
    create_topic_schema(topic)
def create_raw_topic_v3(code, data, current_user):
    topic = Topic()
    topic.topicId = get_surrogate_key()
    topic.tenantId = current_user.tenantId
    topic.name = code
    topic.type = "raw"
    topic.factors = []
    queue = deque([])
    rs = Relationship()
    if type(data) == list:
        for record in data:
            model: dict = {"root": record}
            queue.append(model)
        create_factors(queue, topic, rs)
        mp = rs.get_mapping()
        parent = []
        child = mp.get("root", [])
        generate_surrogate_key("root", parent, child, mp, topic)
        create_topic_schema(topic)
    else:
        raise ValueError("the data must be array")