def validateRemoveRelations(relations, removeindices): redundantindices=[] newrelations = DBnormalizer.removeRedundantSchemas(relations) newrelationsuser = [] for i, relation in enumerate(relations): if str(i) not in removeindices: newrelationsuser.append(relation) if sorted(newrelations[:]) == sorted(newrelationsuser[:]): return newrelations else: return []
def validateRemoveRelations(relations, removeindices): redundantindices=[] newrelations = DBnormalizer.removeRedundantSchemas(relations) newrelationsuser = [] for i, relation in enumerate(relations): if str(i) not in removeindices: newrelationsuser.append(relation) if sorted(newrelations[:]) == sorted(newrelationsuser[:]): return newrelations else: return []
numberOfTries, numberOfSteps, relationString, fdsString, currentfds, relations, keyrelationstring) inputpanel = views.inputToString(relation, currentfds, mvds, additionalFds, additionalMvds, "default", candidatekeys) if (step == '8'): currentfds, currentmvds = DBnormalizer.parseInputFDsMVDs( str(form['currentfds'].value)) #validate relation primary keys primarykeys = [] relations = [] currentrelationsStrings = str( form['currentrelations'].value).split(",") for r in currentrelationsStrings: relations.append(views.stringToRelation(r)) relations = DBnormalizer.removeRedundantSchemas(relations[:]) for i in range(len(relations)): try: primarykey = set(str( form['pk' + str(i)].value)) | set(EMPTY_SET) except KeyError: primarykey = set(EMPTY_SET) primarykeys.append(primarykey) if inputValidation.validatePrimaryKeys(relations, currentfds, primarykeys): alert = views.getSuccessMessageBox("Richtig!") keysAndFDs = DBnormalizer.getKeysAndFDsMVDsOfRelations( relations, currentfds) numberOfTries = numberOfTries - 1 quizform = quizForms.formResultSyntheseAlgorithm( numberOfTries, numberOfSteps, relationString, fdsString,
alert = views.getSuccessMessageBox("Richtig!") numberOfSteps = numberOfSteps + 1 quizform = quizForms.choosePrimaryKeys(numberOfTries, numberOfSteps, relationString, fdsString, currentfds, newrelations) else: alert = views.getErrorMessageBox("Leider falsch!") quizform = quizForms.removeRedundantRelations(numberOfTries, numberOfSteps, relationString, fdsString, currentfds, relations, keyrelationstring) inputpanel = views.inputToString(relation, currentfds, mvds, additionalFds, "default", candidatekeys) if (step=='8'): currentfds, currentmvds = DBnormalizer.parseInputFDsMVDs(str(form['currentfds'].value)) #validate relation primary keys primarykeys = [] relations = [] currentrelationsStrings = str(form['currentrelations'].value).split(",") for r in currentrelationsStrings: relations.append(views.stringToRelation(r)) relations = DBnormalizer.removeRedundantSchemas(relations[:]) for i in range(len(relations)): try: primarykey = set(str(form['pk'+str(i)].value))|set(EMPTY_SET) except KeyError: primarykey = set(EMPTY_SET) primarykeys.append(primarykey) if inputValidation.validatePrimaryKeys(relations, currentfds, primarykeys): alert = views.getSuccessMessageBox("Richtig!") keysAndFDs = DBnormalizer.getKeysAndFDsMVDsOfRelations(relations, currentfds) numberOfTries = numberOfTries - 1 quizform = quizForms.formResultSyntheseAlgorithm(numberOfTries, numberOfSteps, relationString, fdsString, currentfds, relations, keysAndFDs, primarykeys) else: alert = views.getErrorMessageBox("Leider falsch!") quizform = quizForms.choosePrimaryKeys(numberOfTries, numberOfSteps, relationString, fdsString, currentfds, relations) inputpanel = views.inputToString(relation, currentfds, mvds, additionalFds, "default", candidatekeys)