Beispiel #1
0
def printResults(string, answers={}):
                history = DBtransactions.parseInput(string)
                if not isinstance(history, basestring):
                        historyString = views.historyToString(history)
			historyTable = views.historyToTable(history)
                        result = DBtransactions.computeEverything(history)
			conflictOperations = views.conflictOperationsToString(result['conflictOperations'])
			readingTAs = views.readingTAsToString(result['readingTAs'])
			committedTransactions = views.transactionListToString(result['committedTAs'])
			abortedTransactions = views.transactionListToString(result['abortedTAs'])
                        graph = result['graph']
                        isSR = result['SR']
                        operationsNotRC = result['operationsNotRC']
			isRC = result['RC']
                        operationsNotACA = result['operationsNotACA']
			isACA = result['ACA']
                        operationsNotST = result['operationsNotST']
			isST = result['ST']
			
			resultString =  historyTable+views.wrapInPanel("Konfliktoperationen", conflictOperations,3)+views.wrapInPanel("Lesende Transaktionen", readingTAs, 3)+views.wrapInPanel("Committete Transaktionen", committedTransactions, 3)+views.wrapInPanel("Abortete Transaktionen", abortedTransactions, 3)+views.htmlGraph()+"<div>"+views.wrapInPanel("Eigenschaften von H := "+historyString, views.booleanPropertyToString("serialisierbar", isSR)+views.propertyToString("rücksetzbar", history, operationsNotRC)+views.propertyToString("vermeidet kaskadierendes Rücksetzen", history, operationsNotACA)+views.propertyToString("strikt", history, operationsNotST), 12)+"</div>"+printjquery(graph, history)
                	if answers:
				if answers['SR'] == isSR and  answers['RC'] == isRC and  answers['ACA'] == isACA and  answers['ST'] == isST:
					returnString = printCheckboxes(answers) + views.getMessageBox("Richtig!","thumbs-up") + resultString
				else:
					returnString = printCheckboxes(answers) + views.getMessageBox("Leider falsch!","thumbs-down")
			else:
				returnString = printCheckboxes(result) + resultString
		else:
			returnString = printCheckboxes(answers) + history
		return returnString
def parseInput(string):
    string = string.replace(" ", "")
    elements = string.split(",")
    history = []
    for i, e in enumerate(elements):
        if len(e) == 2:
            #c or a
            if re.match("^[ac]\d$", e):
                history.append(HistoryItem(e[1], e[0], "", i))
            else:
                return views.getMessageBox(
                    "Verstehe deine Eingabe " + e + " nicht!",
                    "exclamation-sign")
        elif len(e) == 5:
            #w or r
            if re.match("^[wr]\d[\[\(][a-zA-Z][\]\)]$", e):
                history.append(HistoryItem(e[1], e[0], e[3], i))
            else:
                return views.getMessageBox(
                    "Verstehe deine Eingabe " + e + " nicht!",
                    "exclamation-sign")
        elif re.match("[ac]\d+$", e) or re.match("[wr]\d+[\[\(][a-zA-Z][\]\)]",
                                                 e):
            return views.getMessageBox(
                "Bitte nur TA-IDs zwischen 0 und 9 verwenden!",
                "exclamation-sign")
        else:
            return views.getMessageBox("Kein gültiges Format: " + e + "",
                                       "exclamation-sign")
    validation = validateInput(history)
    if validation[0]:
        return history
    else:
        return validation[1]
def parseInput(string):
	string = string.replace(" ", "")
	elements = string.split(",")
	history = []
	for i, e in enumerate(elements):
		if len(e) == 2:
			#c or a
			if re.match("^[ac]\d$",e):
				history.append(HistoryItem(e[1],e[0], "", i))
			else:
				return views.getMessageBox("Verstehe deine Eingabe "+e+" nicht!", "exclamation-sign")
		elif len(e) == 5:
			#w or r
			if re.match("^[wr]\d[\[\(][a-zA-Z][\]\)]$",e):
				history.append(HistoryItem(e[1],e[0],e[3], i))
			else:
				return views.getMessageBox("Verstehe deine Eingabe "+e+" nicht!", "exclamation-sign")
		elif re.match("[ac]\d+$",e) or re.match("[wr]\d+[\[\(][a-zA-Z][\]\)]",e):
			return views.getMessageBox("Bitte nur TA-IDs zwischen 0 und 9 verwenden!", "exclamation-sign")
		else:
			return views.getMessageBox("Kein gültiges Format: "+e+"", "exclamation-sign")
	validation = validateInput(history)
	if validation[0]:
		return history
	else:
		return validation[1]
Beispiel #4
0
def printResults(string, answers={}):
                history = DBtransactions.parseInput(string)
                if not isinstance(history, basestring):
                        historyString = views.historyToString(history)
			historyTable = views.historyToTable(history)
                        result = DBtransactions.computeEverything(history)
			conflictOperations = views.conflictOperationsToString(result['conflictOperations'])
			readingTAs = views.readingTAsToString(result['readingTAs'])
			committedTransactions = views.transactionListToString(result['committedTAs'])
			abortedTransactions = views.transactionListToString(result['abortedTAs'])
                        graph = result['graph']
                        isSR = result['SR']
                        operationsNotRC = result['operationsNotRC']
			isRC = result['RC']
                        operationsNotACA = result['operationsNotACA']
			isACA = result['ACA']
                        operationsNotST = result['operationsNotST']
			isST = result['ST']
			
			resultString =  historyTable+views.wrapInPanel("Konfliktoperationen", conflictOperations,3)+views.wrapInPanel("Lesende Transaktionen", readingTAs, 3)+views.wrapInPanel("Committete Transaktionen", committedTransactions, 3)+views.wrapInPanel("Abortete Transaktionen", abortedTransactions, 3)+views.htmlGraph()+"<div>"+views.wrapInPanel("Eigenschaften von H := "+historyString, views.booleanPropertyToString("serialisierbar", isSR)+views.propertyToString("rücksetzbar", history, operationsNotRC)+views.propertyToString("vermeidet kaskadierendes Rücksetzen", history, operationsNotACA)+views.propertyToString("strikt", history, operationsNotST), 12)+"</div>"+printjquery(graph, history)
                	if answers:
				if answers['SR'] == isSR and  answers['RC'] == isRC and  answers['ACA'] == isACA and  answers['ST'] == isST:
					returnString = printCheckboxes(answers) + views.getMessageBox("Richtig!","thumbs-up") + resultString
				else:
					returnString = printCheckboxes(answers) + views.getMessageBox("Leider falsch!","thumbs-down")
			else:
				returnString = printCheckboxes(result) + resultString
		else:
			returnString = printCheckboxes(answers) + history
		return returnString
def validateInput(history):
	for i,e in enumerate(history):
		if (e.operation == COMMIT or e.operation == ABORT) and i<len(history)-1:
			for e2 in history[i+1:]:
				if e.transaction == e2.transaction:
					#the transaction does something after abort/commit, which is invalid
					return (False, views.getMessageBox("Operationen nach Commit/Abort!", "exclamation-sign"))
	if committedTransactions(history) | abortedTransactions(history) < involvedTransactions(history):
		#there are transactions which do not commit/abort
		return (False, views.getMessageBox("Es gibt TAs, die weder committen noch aborten!", "exclamation-sign"))
	else:
		return (True, "Alles ok") 
def validateInput(history):
    for i, e in enumerate(history):
        if (e.operation == COMMIT
                or e.operation == ABORT) and i < len(history) - 1:
            for e2 in history[i + 1:]:
                if e.transaction == e2.transaction:
                    #the transaction does something after abort/commit, which is invalid
                    return (False,
                            views.getMessageBox(
                                "Operationen nach Commit/Abort!",
                                "exclamation-sign"))
    if committedTransactions(history) | abortedTransactions(
            history) < involvedTransactions(history):
        #there are transactions which do not commit/abort
        return (False,
                views.getMessageBox(
                    "Es gibt TAs, die weder committen noch aborten!",
                    "exclamation-sign"))
    else:
        return (True, "Alles ok")