def save_group_details(self,login,groupid, groupname, userids,desc): dupGrp=None group=Group() db=DBHelper() session=DBHelper().get_session() dupGrp=session.query(Group).filter(Group.group_name==groupname).first() if dupGrp is None: result = [] group.group_name=groupname group.created_by=(login) group.modified_by=(login) group.created_date=datetime.now() group.description=desc L=(userids).split(',') if userids !="": for i in L: user=session.query(User).filter(User.user_id==int(i)).first() group.users.append(user); db.add(group) return result else: result="False" return result
def save_group_details(self, login, groupid, groupname, userids, desc): dupGrp = None group = Group() db = DBHelper() session = DBHelper().get_session() dupGrp = session.query(Group).filter( Group.group_name == groupname).first() if dupGrp is None: result = [] group.group_name = groupname group.created_by = (login) group.modified_by = (login) group.created_date = datetime.now() group.description = desc L = (userids).split(',') if userids != "": for i in L: user = session.query(User).filter( User.user_id == int(i)).first() group.users.append(user) db.add(group) return result else: result = "False" return result
def updatesave_op_det(self, login, opid, opname, desc, entid, context_disp, dispname, icon): result = [] op = Operation() db = DBHelper() session = DBHelper().get_session() op = session.query(Operation).filter(Operation.id == opid).first() op.name = (opname) op.description = (desc) op.modified_date = datetime.now() op.modified_by = (login) op.display_name = (dispname) op.icon = (icon) if context_disp == "true": op.display = True else: op.display = False for i in op.entityType: op.entityType.remove(i) L = (entid).split(',') if entid != "": for i in L: ent = session.query(EntityType).filter( EntityType.id == int(i)).first() op.entityType.append(ent) db.update(op) return result
def save_oper_det(self, login, opname, descr, context_disp, entityid, dispname, icon): result = [] dupOp = None operation = Operation() db = DBHelper() session = DBHelper().get_session() dupOp = session.query(Operation).filter( Operation.name == opname).first() if dupOp is None: operation.name = (opname) operation.description = (descr) operation.display_name = (dispname) operation.icon = (icon) operation.created_by = (login) operation.modified_by = (login) operation.created_date = datetime.now() if context_disp == "true": operation.display = True else: operation.display = False L = (entityid).split(',') for i in L: ent = session.query(EntityType).filter( EntityType.id == int(i)).first() operation.entityType.append(ent) db.add(operation) return result else: result = "False" return result
def updatesave_op_det(self, login,opid, opname, desc, entid, context_disp,dispname,icon): result = [] op=Operation() db=DBHelper() session=DBHelper().get_session() op=session.query(Operation).filter(Operation.id==opid).first() op.name=(opname) op.description=(desc) op.modified_date=datetime.now() op.modified_by=(login) op.display_name=(dispname) op.icon=(icon) if context_disp=="true": op.display=True else: op.display=False for i in op.entityType: op.entityType.remove(i); L=(entid).split(',') if entid !="": for i in L: ent=session.query(EntityType).filter(EntityType.id==int(i)).first() op.entityType.append(ent); db.update(op) return result
def save_oper_det(self, login,opname, descr, context_disp, entityid,dispname,icon): result = [] dupOp=None operation=Operation() db=DBHelper() session=DBHelper().get_session() dupOp=session.query(Operation).filter(Operation.name==opname).first() if dupOp is None: operation.name=(opname) operation.description=(descr) operation.display_name=(dispname) operation.icon=(icon) operation.created_by=(login) operation.modified_by=(login) operation.created_date=datetime.now() if context_disp=="true": operation.display=True else: operation.display=False L=(entityid).split(',') for i in L: ent=session.query(EntityType).filter(EntityType.id==int(i)).first() operation.entityType.append(ent); db.add(operation) return result else: result="False" return result
def save_opsgroup_details(self, login, opsgroupname, opsgroupdesc, operation): dupOpsgrp = None db = DBHelper() session = DBHelper().get_session() dupOpsgrp = session.query(OperationGroup).filter( OperationGroup.name == opsgroupname).first() opsgroup = OperationGroup() if dupOpsgrp is None: result = [] opsgroup.name = (opsgroupname) opsgroup.description = (opsgroupdesc) opsgroup.created_by = (login) opsgroup.modified_by = (login) opsgroup.created_date = datetime.now() L = ((operation)).split(',') for i in L: oper = session.query(Operation).filter( Operation.id == int(i)).first() opsgroup.operations.append(oper) db.add(opsgroup) return result else: result = "False" return result
def updatesave_group_details(self,login,groupid, groupname, userids,desc): result = [] group=Group() session=DBHelper().get_session() if groupname in constants.DEFAULT_GROUPS: user=session.query(User).filter(User.user_name==constants.DEFAULT_USERS[0]).first() new_ids =[] if userids !="": new_ids=(userids).split(',') new_ids = [int(id) for id in new_ids] if user.user_id not in new_ids: raise Exception("Can not remove user "+user.user_name+" from "+groupname) group=session.query(Group).filter(Group.group_id==groupid).first() group.group_name=groupname group.description=desc group.modified_date=datetime.now() group.modified_by=(login) for user in group.users: group.users.remove(user) if userids !="": L=(userids).split(',') for i in L: user=session.query(User).filter(User.user_id==int(i)).first() group.users.append(user) DBHelper().update(group) return result
def edit_group_details(self,groupid): result=[] group=Group() session=DBHelper().get_session() group=session.query(Group).filter(Group.group_id==groupid).first() result.append(dict(groupid=group.group_id,groupname=group.group_name,createdby=group.created_by,modifiedby=group.modified_by,createddate=group.created_date,modifieddate=group.modified_date,desc=group.description)) return result
def edit_op_det(self,opid,enttype): result=[] op=Operation() session=DBHelper().get_session() op=session.query(Operation).filter(Operation.id==opid).first() entitytype=(enttype) result.append(dict(opid=op.id,opname=op.name,desc=op.description,contextdisplay=op.display,enttype=entitytype,createdby=op.created_by,modifiedby=op.modified_by,createddate=op.created_date,modifieddate=op.modified_date,dispname=op.display_name,icon=op.icon)) return result
def get_tousers_map(self,groupid): result= [] session=DBHelper().get_session() group=session.query(Group).filter(Group.group_id==groupid).first() users=group.users for u in users: uid=u.user_id uname=(u.user_name) result.append(dict(userid=uid,username=uname)) return result
def get_tooperations_map(self,opsgroupid): result= [] session=DBHelper().get_session() opsgroup=session.query(OperationGroup).filter(OperationGroup.id==opsgroupid).first() operatiions=opsgroup.operations for o in operatiions: oid=o.id oname=(o.name) result.append(dict(operationid=oid,operationname=oname)) return result
def updatesave_opsgroup_details(self, login,opsgroupid ,opsgroupname, opsgroupdesc,operation): result = [] opsgroup=OperationGroup(); db=DBHelper() session=DBHelper().get_session() opsgroup=session.query(OperationGroup).filter(OperationGroup.id==opsgroupid).first() opsgroup.name=opsgroupname opsgroup.description=opsgroupdesc opsgroup.modified_date=datetime.now() opsgroup.modified_by=(login) operation = operation[0:-1] L=(operation).split(',') for i in L: operation=session.query(Operation).filter(Operation.id==int(i)).first() opsgroup.operations.append(operation); db.update(opsgroup); return result
def edit_opsgroup_details(self,opsgroupid): result=[] session=DBHelper().get_session() opsgroup=session.query(OperationGroup).filter(OperationGroup.id==opsgroupid).first() opsgrpid=opsgroup.id opsgrpname=opsgroup.name opsgrpdesc=opsgroup.description result.append(dict(opsgroupid=opsgrpid,opsgroupname=opsgrpname,opsgroupdesc=opsgrpdesc,createdby=opsgroup.created_by,modifiedby=opsgroup.modified_by,createddate=opsgroup.created_date,modifieddate=opsgroup.modified_date)) return result
def edit_enttype_details(self,enttypeid): result=[] session=DBHelper().get_session() ent=session.query(EntityType).filter(EntityType.id==enttypeid).first() enttypeid=ent.id entname=ent.name entdisp=ent.display_name result.append(dict(enttypeid=enttypeid,entname=entname,entdisp=entdisp,createdby=ent.created_by,modifiedby=ent.modified_by,createddate=ent.created_date,modifieddate=ent.modified_date)) return result
def get_tousers_map(self, groupid): result = [] session = DBHelper().get_session() group = session.query(Group).filter(Group.group_id == groupid).first() users = group.users for u in users: uid = u.user_id uname = (u.user_name) result.append(dict(userid=uid, username=uname)) return result
def get_tooperations_map(self, opsgroupid): result = [] session = DBHelper().get_session() opsgroup = session.query(OperationGroup).filter( OperationGroup.id == opsgroupid).first() operatiions = opsgroup.operations for o in operatiions: oid = o.id oname = (o.name) result.append(dict(operationid=oid, operationname=oname)) return result
def updatesave_opsgroup_details(self, login, opsgroupid, opsgroupname, opsgroupdesc, operation): result = [] opsgroup = OperationGroup() db = DBHelper() session = DBHelper().get_session() opsgroup = session.query(OperationGroup).filter( OperationGroup.id == opsgroupid).first() opsgroup.name = opsgroupname opsgroup.description = opsgroupdesc opsgroup.modified_date = datetime.now() opsgroup.modified_by = (login) operation = operation[0:-1] L = (operation).split(',') for i in L: operation = session.query(Operation).filter( Operation.id == int(i)).first() opsgroup.operations.append(operation) db.update(opsgroup) return result
def updatesave_enttype_details(self, login, enttypeid ,enttypename, dispname): result = [] ent=EntityType(); db=DBHelper() session=DBHelper().get_session() ent=session.query(EntityType).filter(EntityType.id==enttypeid).first() ent.name=enttypename ent.display_name=dispname ent.modified_by=(login) ent.modified_date=datetime.now() db.update(ent); return result
def save_opsgroup_details(self,login, opsgroupname, opsgroupdesc, operation): dupOpsgrp=None db=DBHelper() session=DBHelper().get_session() dupOpsgrp=session.query(OperationGroup).filter(OperationGroup.name==opsgroupname).first() opsgroup=OperationGroup(); if dupOpsgrp is None: result=[] opsgroup.name=(opsgroupname) opsgroup.description=(opsgroupdesc) opsgroup.created_by=(login) opsgroup.modified_by=(login) opsgroup.created_date=datetime.now() L=((operation)).split(',') for i in L: oper=session.query(Operation).filter(Operation.id==int(i)).first() opsgroup.operations.append(oper); db.add(opsgroup); return result else: result="False" return result
def edit_group_details(self, groupid): result = [] group = Group() session = DBHelper().get_session() group = session.query(Group).filter(Group.group_id == groupid).first() result.append( dict(groupid=group.group_id, groupname=group.group_name, createdby=group.created_by, modifiedby=group.modified_by, createddate=group.created_date, modifieddate=group.modified_date, desc=group.description)) return result
def updatesave_group_details(self, login, groupid, groupname, userids, desc): result = [] group = Group() session = DBHelper().get_session() if groupname in constants.DEFAULT_GROUPS: user = session.query(User).filter( User.user_name == constants.DEFAULT_USERS[0]).first() new_ids = [] if userids != "": new_ids = (userids).split(',') new_ids = [int(id) for id in new_ids] if user.user_id not in new_ids: raise Exception("Can not remove user " + user.user_name + " from " + groupname) group = session.query(Group).filter(Group.group_id == groupid).first() group.group_name = groupname group.description = desc group.modified_date = datetime.now() group.modified_by = (login) for user in group.users: group.users.remove(user) if userids != "": L = (userids).split(',') for i in L: user = session.query(User).filter( User.user_id == int(i)).first() group.users.append(user) DBHelper().update(group) return result
def updatesave_enttype_details(self, login, enttypeid, enttypename, dispname): result = [] ent = EntityType() db = DBHelper() session = DBHelper().get_session() ent = session.query(EntityType).filter( EntityType.id == enttypeid).first() ent.name = enttypename ent.display_name = dispname ent.modified_by = (login) ent.modified_date = datetime.now() db.update(ent) return result
def edit_opsgroup_details(self, opsgroupid): result = [] session = DBHelper().get_session() opsgroup = session.query(OperationGroup).filter( OperationGroup.id == opsgroupid).first() opsgrpid = opsgroup.id opsgrpname = opsgroup.name opsgrpdesc = opsgroup.description result.append( dict(opsgroupid=opsgrpid, opsgroupname=opsgrpname, opsgroupdesc=opsgrpdesc, createdby=opsgroup.created_by, modifiedby=opsgroup.modified_by, createddate=opsgroup.created_date, modifieddate=opsgroup.modified_date)) return result
def edit_enttype_details(self, enttypeid): result = [] session = DBHelper().get_session() ent = session.query(EntityType).filter( EntityType.id == enttypeid).first() enttypeid = ent.id entname = ent.name entdisp = ent.display_name result.append( dict(enttypeid=enttypeid, entname=entname, entdisp=entdisp, createdby=ent.created_by, modifiedby=ent.modified_by, createddate=ent.created_date, modifieddate=ent.modified_date)) return result
def save_enttype_details(self,login,enttypename,dispname): dupEnt=None db=DBHelper() session=DBHelper().get_session() dupEnt=session.query(EntityType).filter(EntityType.name==enttypename).first() if dupEnt is None: result=[] ent=EntityType(); ent.name=(enttypename) ent.display_name=(dispname) ent.created_by=(login) ent.created_date=datetime.now() ent.modified_by=(login) db.add(ent); return result else: result="False" return result
def edit_op_det(self, opid, enttype): result = [] op = Operation() session = DBHelper().get_session() op = session.query(Operation).filter(Operation.id == opid).first() entitytype = (enttype) result.append( dict(opid=op.id, opname=op.name, desc=op.description, contextdisplay=op.display, enttype=entitytype, createdby=op.created_by, modifiedby=op.modified_by, createddate=op.created_date, modifieddate=op.modified_date, dispname=op.display_name, icon=op.icon)) return result
def save_enttype_details(self, login, enttypename, dispname): dupEnt = None db = DBHelper() session = DBHelper().get_session() dupEnt = session.query(EntityType).filter( EntityType.name == enttypename).first() if dupEnt is None: result = [] ent = EntityType() ent.name = (enttypename) ent.display_name = (dispname) ent.created_by = (login) ent.created_date = datetime.now() ent.modified_by = (login) db.add(ent) return result else: result = "False" return result
def get_groups_map(self, userid=None): result = [] session = DBHelper().get_session() groups = DBHelper().get_all(Group) user = session.query(User).filter(User.user_id == userid).first() for g in groups: gid = g.group_id gname = (g.group_name) result.append(dict(groupid=gid, groupname=gname)) if userid is None: return result else: for grp in user.groups: i = 0 for group in result: if grp.group_id == group['groupid']: del result[i] break i += 1 return result
def get_entitytype_map(self,opid=None): result= [] session=DBHelper().get_session() enty=DBHelper().get_all(EntityType) operation=session.query(Operation).filter(Operation.id==opid).first() for e in enty: eid=e.id ename=(e.display_name) result.append(dict(entid=eid,entname=ename)) if opid is None: return result else: for ent in operation.entityType: i = 0 for enttype in result: if ent.id == enttype['entid']: del result[i] break i += 1 return result
def get_users_map(self, groupid=None): result = [] users = DBHelper().get_all(User) session = DBHelper().get_session() group = session.query(Group).filter(Group.group_id == groupid).first() for u in users: uid = u.user_id uname = (u.user_name) result.append(dict(userid=uid, username=uname)) if groupid is None: return result else: for grp in group.users: i = 0 for user in result: if grp.user_id == user['userid']: del result[i] break i += 1 return result
def get_users_map(self,groupid=None): result= [] users=DBHelper().get_all(User) session=DBHelper().get_session() group=session.query(Group).filter(Group.group_id==groupid).first() for u in users: uid=u.user_id uname=(u.user_name) result.append(dict(userid=uid,username=uname)) if groupid is None: return result else: for grp in group.users: i = 0 for user in result: if grp.user_id == user['userid']: del result[i] break i += 1 return result
def get_entitytype_map(self, opid=None): result = [] session = DBHelper().get_session() enty = DBHelper().get_all(EntityType) operation = session.query(Operation).filter( Operation.id == opid).first() for e in enty: eid = e.id ename = (e.display_name) result.append(dict(entid=eid, entname=ename)) if opid is None: return result else: for ent in operation.entityType: i = 0 for enttype in result: if ent.id == enttype['entid']: del result[i] break i += 1 return result
def get_operations_map(self,opsgrpid=None): result= [] operation=DBHelper().get_all(Operation) session=DBHelper().get_session() opsgroup=session.query(OperationGroup).filter(OperationGroup.id==opsgrpid).first() for o in operation: opid=o.id opname=(o.name) result.append(dict(operationid=opid,operationname=opname)) if opsgrpid is None: return result else: for oprs in opsgroup.operations: i = 0 for operation in result: if oprs.id == operation['operationid']: del result[i] break i += 1 return result
def get_groups_map(self,userid=None): result= [] session=DBHelper().get_session() groups=DBHelper().get_all(Group) user=session.query(User).filter(User.user_id==userid).first() for g in groups: gid=g.group_id gname=(g.group_name) result.append(dict(groupid=gid,groupname=gname)) if userid is None: return result else: for grp in user.groups: i = 0 for group in result: if grp.group_id == group['groupid']: del result[i] break i += 1 return result
def get_operations_map(self, opsgrpid=None): result = [] operation = DBHelper().get_all(Operation) session = DBHelper().get_session() opsgroup = session.query(OperationGroup).filter( OperationGroup.id == opsgrpid).first() for o in operation: opid = o.id opname = (o.name) result.append(dict(operationid=opid, operationname=opname)) if opsgrpid is None: return result else: for oprs in opsgroup.operations: i = 0 for operation in result: if oprs.id == operation['operationid']: del result[i] break i += 1 return result