def createTab (tab_name, user, workspace): # Creating Entry in AbstractVariable table for polimorphic access from Connectable hierarchy abstractVariable = AbstractVariable (name=tab_name, type='WORKSPACE') abstractVariable.save() # Creating implicit workspace variable wsVariable = WorkSpaceVariable (workspace=workspace, aspect='TAB', abstract_variable=abstractVariable) wsVariable.save() #Creating implicit OUT Connectable element connectableName = 'tab_' + tab_name; connectable = Out(name=connectableName, abstract_variable=abstractVariable) connectable.save() visible = False tabs = Tab.objects.filter(workspace=workspace, visible=True) if tabs.count()==0: visible = True # Creating tab tab = Tab (name=tab_name, visible=visible, workspace=workspace, abstract_variable=abstractVariable) tab.save() # Returning created Ids ids = {} ids['id'] = tab.id ids['name'] = tab.name data = serializers.serialize('python', [wsVariable], ensure_ascii=False) ids['workspaceVariables'] = [get_workspace_variable_data(d) for d in data] return ids
def createTab(tab_name, user, workspace): # Creating Entry in AbstractVariable table for polimorphic access from Connectable hierarchy abstractVariable = AbstractVariable(name=tab_name, type='WORKSPACE') abstractVariable.save() # Creating implicit workspace variable wsVariable = WorkSpaceVariable(workspace=workspace, aspect='TAB', abstract_variable=abstractVariable) wsVariable.save() #Creating implicit OUT Connectable element connectableName = 'tab_' + tab_name connectable = Out(name=connectableName, abstract_variable=abstractVariable) connectable.save() # Creating tab tab = Tab(name=tab_name, visible=False, workspace=workspace, abstract_variable=abstractVariable) tab.save() setVisibleTab(user, workspace.pk, tab) # Returning created Ids ids = {} ids['id'] = tab.id ids['name'] = tab.name data = serializers.serialize('python', [wsVariable], ensure_ascii=False) ids['workspaceVariables'] = [get_workspace_variable_data(d) for d in data] return ids
def createTab(tab_name, user, workspace): # Creating Entry in AbstractVariable table for polimorphic access from Connectable hierarchy abstractVariable = AbstractVariable(name=tab_name, type='WORKSPACE') abstractVariable.save() # Creating Value for Abstract Variable variableValue = VariableValue(user=user, value="", abstract_variable=abstractVariable) variableValue.save() # Creating implicit workspace variable wsVariable = WorkSpaceVariable(workspace=workspace, aspect='TAB', abstract_variable=abstractVariable) wsVariable.save() #Creating implicit OUT Connectable element connectableName = 'tab_' + tab_name connectable = Out(name=connectableName, abstract_variable=abstractVariable) connectable.save() visible = False tabs = Tab.objects.filter(workspace=workspace, visible=True) if tabs.count() == 0: visible = True #it's always the last tab position = Tab.objects.filter(workspace=workspace).count() # Creating tab tab = Tab(name=tab_name, visible=visible, position=position, workspace=workspace, abstract_variable=abstractVariable) tab.save() # Returning created Ids ids = {} ids['id'] = tab.id ids['name'] = tab.name ids['workspaceVariables'] = [ get_workspace_variable_data(wsVariable, user, workspace) ] return ids
def createTab(tab_name, user, workspace): # Creating Entry in AbstractVariable table for polimorphic access from Connectable hierarchy abstractVariable = AbstractVariable(name=tab_name, type='WORKSPACE') abstractVariable.save() # Creating Value for Abstract Variable variableValue = VariableValue(user=user, value="", abstract_variable=abstractVariable) variableValue.save() # Creating implicit workspace variable wsVariable = WorkSpaceVariable(workspace=workspace, aspect='TAB', abstract_variable=abstractVariable) wsVariable.save() #Creating implicit OUT Connectable element connectableName = 'tab_' + tab_name connectable = Out(name=connectableName, abstract_variable=abstractVariable) connectable.save() visible = False tabs = Tab.objects.filter(workspace=workspace, visible=True) if tabs.count() == 0: visible = True # Creating tab tab = Tab(name=tab_name, visible=visible, locked=False, workspace=workspace, abstract_variable=abstractVariable) tab.save() # Returning created Ids ids = {} ids['id'] = tab.id ids['name'] = tab.name data = serializers.serialize('python', [wsVariable], ensure_ascii=False) ids['workspaceVariables'] = [ get_workspace_variable_data(d, user) for d in data ] return ids
def createTab(tab_name, user, workspace, allow_renaming=False): visible = False tabs = Tab.objects.filter(workspace=workspace, visible=True) if tabs.count() == 0: visible = True # It's always the last tab position = Tab.objects.filter(workspace=workspace).count() # Creating tab tab = Tab(name=tab_name, visible=visible, position=position, workspace=workspace) try: tab.save() except IntegrityError: if allow_renaming: save_alternative(Tab, 'name', tab) else: raise return tab
def createTab(tab_name, user, workspace): # Creating Entry in AbstractVariable table for polimorphic access from Connectable hierarchy abstractVariable = AbstractVariable(name=tab_name, type='WORKSPACE') abstractVariable.save() # Creating Value for Abstract Variable variableValue = VariableValue(user=user, value="", abstract_variable=abstractVariable) variableValue.save() # Creating implicit workspace variable wsVariable = WorkSpaceVariable(workspace=workspace, aspect='TAB', abstract_variable=abstractVariable) wsVariable.save() #Creating implicit OUT Connectable element connectableName = 'tab_' + tab_name connectable = Out(name=connectableName, abstract_variable=abstractVariable) connectable.save() visible = False tabs = Tab.objects.filter(workspace=workspace, visible=True) if tabs.count() == 0: visible = True #it's always the last tab position = Tab.objects.filter(workspace=workspace).count() # Creating tab tab = Tab(name=tab_name, visible=visible, position=position, workspace=workspace, abstract_variable=abstractVariable) tab.save() # Returning created Ids ids = {} ids['id'] = tab.id ids['name'] = tab.name ids['workspaceVariables'] = [get_workspace_variable_data(wsVariable, user, workspace)] return ids