コード例 #1
0
def createSimpleCategoricalFilter():
    global FandS
    panelIDOfInputSeq = request.args["panelID"]
    ForSIDOfInputSeq = request.args["ForSID"]
    selectedAttrName = request.args["attributeName"]
    selectedAttrValue = request.args["attributeValue"]

    # init FandS
    newForSID = helper.getNewForSID(panelIDOfInputSeq)

    FandS[panelIDOfInputSeq][newForSID] = {
        "name": selectedAttrName + "=" + selectedAttrValue,
        "input": ForSIDOfInputSeq + "-after", # input must be after
        "output": None,
        "averageTime": { "after": None },
        "averageNumberOfEvents": { "after": None },
        "applyToSequences": False,
        "applyToRecordAttributes": True,
        "trueStart": { "after": {} },
        "trueEnd": { "after": {} }
    }

    # update output
    helper.updateCategoricalFilterOutput(panelIDOfInputSeq, newForSID)

    # change input of the ForS with the same input as the created ForS
    ForSIDWithInputChanged = None

    for currentForSID in FandS[panelIDOfInputSeq]:
        if currentForSID != newForSID and currentForSID != ForSIDOfInputSeq:  # a ForS can have its output as input
            inputStringOfUpdatedForS = ForSIDOfInputSeq + "-after"
            inputStringOfCurrentForS = FandS[panelIDOfInputSeq][currentForSID]["input"]

            if inputStringOfUpdatedForS == inputStringOfCurrentForS:
                ForSIDWithInputChanged = currentForSID
                FandS[panelIDOfInputSeq][currentForSID]["input"] = newForSID + "-after"
                break

    # update all subsequent ForS (all inputs are correct after the above step)
    currentForSID = ForSIDWithInputChanged

    while currentForSID != None:
        isPatternSplittingPoint = "orderedAVPairsForEachMatcher" in FandS[panelIDOfInputSeq][currentForSID]

        if isPatternSplittingPoint:
            helper.updatePatternSPOutput(panelIDOfInputSeq, currentForSID)
        if not isPatternSplittingPoint:
            helper.updateSimpleSPOutput(panelIDOfInputSeq, currentForSID)

        currentForSID = helper.getNextForSID(panelIDOfInputSeq, currentForSID)

    response = {
        "updatedPanelID": panelIDOfInputSeq,
        "minifiedFandS": helper.createMinifiedFandS()
    }

    return jsonify(response)
コード例 #2
0
def removeSorF():
    global FandS
    panelID = request.args["panelID"]
    ForSIDToBeDeleted = request.args["ForSID"]

    inputStringOfDeletedForS = FandS[panelID][ForSIDToBeDeleted]["input"]
    ForSIDAfterDeletedForS = helper.getNextForSID(panelID, ForSIDToBeDeleted)

    if ForSIDAfterDeletedForS != None:
        # change input of next ForS
        FandS[panelID][ForSIDAfterDeletedForS][
            "input"] = inputStringOfDeletedForS

        # update all subsequent ForS
        currentForSID = ForSIDAfterDeletedForS

        while currentForSID != None:
            isSplittingPoint = FandS[panelID][currentForSID][
                "applyToSequences"]
            isPatternSplittingPoint = "orderedAVPairsForEachMatcher" in FandS[
                panelID][currentForSID]
            isNumerical = "<=" in FandS[panelID][currentForSID]["name"]

            if isSplittingPoint and isPatternSplittingPoint:
                helper.updatePatternSPOutput(panelID, currentForSID)
            if isSplittingPoint and not isPatternSplittingPoint:
                helper.updateSimpleSPOutput(panelID, currentForSID)
            if not isSplittingPoint and not isNumerical:
                helper.updateCategoricalFilterOutput(panelID, currentForSID)
            if not isSplittingPoint and isNumerical:
                helper.updateNumericalFilterOutput(panelID, currentForSID)

            currentForSID = helper.getNextForSID(panelID, currentForSID)

    del FandS[panelID][ForSIDToBeDeleted]

    response = {
        "updatedPanelID": panelID,
        "removedForSID": ForSIDToBeDeleted,
        "minifiedFandS": helper.createMinifiedFandS()
    }

    return jsonify(response)
コード例 #3
0
def createMultipleSimpleSplittingPoints(
):  # cascading add is not required because multiple splitting points are added to new panel
    global FandS
    data = request.get_json()
    panelIDOfInputSeq = data["panelID"]
    ForSIDOfInputSeq = data["ForSID"]
    AVPairs = data["AVPairs"]
    currentInputForSID = ForSIDOfInputSeq

    for AVPair in AVPairs:
        # handle for av pair
        if AVPair["type"] == "AVPair":
            attributeName = AVPair["attributeName"]
            attributeValue = AVPair["attributeValue"]

            # init FandS
            newForSID = helper.getNewForSID(panelIDOfInputSeq)

            FandS[panelIDOfInputSeq][newForSID] = {
                "name": attributeName + "=" + attributeValue,
                "input": currentInputForSID + "-after",  # input must be after
                "output": None,
                "averageTime": {
                    "before": None,
                    "after": None
                },  # in second
                "averageNumberOfEvents": {
                    "before": None,
                    "after": None
                },
                "applyToSequences": True,
                "applyToRecordAttributes": False,
                "trueStart": {
                    "before": {},
                    "after": {},
                    "not": {}
                },
                "trueEnd": {
                    "before": {},
                    "after": {},
                    "not": {}
                }
            }

            # update output, averageTime, averageNumberOfEvents, trueStart and trueEnd
            helper.updateSimpleSPOutput(panelIDOfInputSeq, newForSID)

        # handle for event with multiple av pair
        if AVPair["type"] == "Pattern":
            name = AVPair["name"]
            eventMatchers = AVPair["eventMatchers"]
            orderedAVPairsForEachMatcher = AVPair[
                "orderedAVPairsForEachMatcher"]
            logicTableForEachMatcher = AVPair["logicTableForEachMatcher"]

            # init FandS
            newForSID = helper.getNewForSID(panelIDOfInputSeq)

            FandS[panelIDOfInputSeq][newForSID] = {
                "name": name,
                "input": ForSIDOfInputSeq + "-after",  # input must be after
                "output": None,
                "averageTime": {
                    "before": None,
                    "after": None
                },  # in second
                "averageNumberOfEvents": {
                    "before": None,
                    "after": None
                },
                "applyToSequences": True,
                "applyToRecordAttributes": False,
                "trueStart": {
                    "before": {},
                    "after": {},
                    "not": {}
                },
                "trueEnd": {
                    "before": {},
                    "after": {},
                    "not": {}
                },
                "eventMatchers": eventMatchers,
                "orderedAVPairsForEachMatcher": orderedAVPairsForEachMatcher,
                "logicTableForEachMatcher": logicTableForEachMatcher
            }

            # update output, averageTime, averageNumberOfEvents, trueStart and trueEnd
            helper.updatePatternSPOutput(panelIDOfInputSeq, newForSID)

        # update for next iteration
        currentInputForSID = newForSID

    response = {
        "updatedPanelID": panelIDOfInputSeq,
        "minifiedFandS": helper.createMinifiedFandS()
    }

    return jsonify(response)
コード例 #4
0
def createPatternSplittingPoint():
    global FandS
    data = request.get_json()
    panelIDOfInputSeq = data["panelID"]
    ForSIDOfInputSeq = data["ForSID"]
    name = data["name"]
    eventMatchers = data["eventMatchers"]
    orderedAVPairsForEachMatcher = data["orderedAVPairsForEachMatcher"]
    logicTableForEachMatcher = data["logicTableForEachMatcher"]

    # init FandS
    newForSID = helper.getNewForSID(panelIDOfInputSeq)

    FandS[panelIDOfInputSeq][newForSID] = {
        "name": name,
        "input": ForSIDOfInputSeq + "-after",  # input must be after
        "output": None,
        "averageTime": {
            "before": None,
            "after": None
        },  # in second
        "averageNumberOfEvents": {
            "before": None,
            "after": None
        },
        "applyToSequences": True,
        "applyToRecordAttributes": False,
        "trueStart": {
            "before": {},
            "after": {},
            "not": {}
        },
        "trueEnd": {
            "before": {},
            "after": {},
            "not": {}
        },
        "eventMatchers": eventMatchers,
        "orderedAVPairsForEachMatcher": orderedAVPairsForEachMatcher,
        "logicTableForEachMatcher": logicTableForEachMatcher
    }

    # update output, averageTime, averageNumberOfEvents, trueStart and trueEnd
    helper.updatePatternSPOutput(panelIDOfInputSeq, newForSID)

    # change input of the ForS with the same input as the created ForS
    ForSIDWithInputChanged = None

    for currentForSID in FandS[panelIDOfInputSeq]:
        if currentForSID != newForSID and currentForSID != ForSIDOfInputSeq:  # a ForS can have its output as input
            inputStringOfUpdatedForS = ForSIDOfInputSeq + "-after"
            inputStringOfCurrentForS = FandS[panelIDOfInputSeq][currentForSID][
                "input"]

            if inputStringOfUpdatedForS == inputStringOfCurrentForS:
                ForSIDWithInputChanged = currentForSID
                FandS[panelIDOfInputSeq][currentForSID][
                    "input"] = newForSID + "-after"
                break

    # update all subsequent ForS
    currentForSID = ForSIDWithInputChanged

    while currentForSID != None:
        isPatternSplittingPoint = "orderedAVPairsForEachMatcher" in FandS[
            panelIDOfInputSeq][currentForSID]

        if isPatternSplittingPoint:
            helper.updatePatternSPOutput(panelIDOfInputSeq, currentForSID)
        if not isPatternSplittingPoint:
            helper.updateSimpleSPOutput(panelIDOfInputSeq, currentForSID)

        currentForSID = helper.getNextForSID(panelIDOfInputSeq, currentForSID)

    response = {
        "updatedPanelID": panelIDOfInputSeq,
        "minifiedFandS": helper.createMinifiedFandS()
    }

    return jsonify(response)