def __cleanup(self, cfg): Accessor.factory(self._dest_db).delete( { AccessParams.KEY_COLLECTION: cfg[Transformation._CFG_KEY_CLEANUP_TARGET], AccessParams.KEY_TYPE: AccessParams.TYPE_MULTI, AccessParams.KEY_MATCH_PARAMS: {} }, triggers_on=False)
def __save(self, cfg): Accessor.factory(self._dest_db).upsert( { AccessParams.KEY_COLLECTION: cfg[Transformation._CFG_KEY_SAVE_DEST], AccessParams.KEY_TYPE: AccessParams.TYPE_SINGLE if isinstance(self.__res, dict) else AccessParams.TYPE_MULTI, AccessParams.KEY_OBJECT: self.__res }, triggers_on=False)
def get(self): return Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get({ AccessParams.KEY_COLLECTION: DbConstants.PROJECT_EMPLOYEES, AccessParams.KEY_TYPE: AccessParams.TYPE_MULTI })
def post(self): allocation_details = request.get_json() allocation_details[ParamConstants.PARAM_WHRS] = Converter.convert( allocation_details[ParamConstants.PARAM_WHRS], Types.TYPE_FLOAT) allocation_details[ParamConstants.PARAM_DATE] = Converter.convert( allocation_details[ParamConstants.PARAM_DATE], Types.TYPE_DATE) return Accessor.factory(DbConstants.CFG_DB_SCRUM_API).upsert({ AccessParams.KEY_COLLECTION: DbConstants.SCRUM_ALLOCATIONS, AccessParams.KEY_TYPE: AccessParams.TYPE_SINGLE, AccessParams.KEY_OBJECT: allocation_details, AccessParams.KEY_MATCH_PARAMS: { ParamConstants.PARAM_ITEM_KEY: allocation_details[ParamConstants.PARAM_ITEM_KEY], ParamConstants.PARAM_DATE: allocation_details[ParamConstants.PARAM_DATE], ParamConstants.PARAM_GROUP: allocation_details[ParamConstants.PARAM_GROUP], ParamConstants.PARAM_EMPLOYEE: allocation_details[ParamConstants.PARAM_EMPLOYEE] } }), 201
def get_linked_allocations(input, **params): LINK_TARGET = 'target' PARAM_FUNC = 'func' linked_issues = get_linked_issues(input[ParamConstants.PARAM_ITEM_KEY], params.get(ParamConstants.PARAM_TYPE)) filter = [] if len(linked_issues) > 0: for issue in linked_issues: filter.append({ParamConstants.PARAM_ITEM_KEY: issue[LINK_TARGET]}) linked_allocations = Accessor.factory( DbConstants.CFG_DB_SCRUM_API).get({ AccessParams.KEY_MATCH_PARAMS: { AccessParams.OPERATOR_OR: filter }, AccessParams.KEY_COLLECTION: DbConstants.SCRUM_ALLOCATIONS, AccessParams.KEY_TYPE: AccessParams.TYPE_MULTI }) agg_func = params.get(PARAM_FUNC) return Aggregator.agg_single_func(linked_allocations, ParamConstants.PARAM_DATE, agg_func, [ParamConstants.PARAM_ITEM_KEY]) else: return None
def _load(self, cfg): return Accessor.factory(self._src_db).get({ AccessParams.KEY_COLLECTION: cfg[Transformation._CFG_KEY_LOAD_SRC], AccessParams.KEY_TYPE: AccessParams.TYPE_MULTI })
def get(self): return jsonify( Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get({ AccessParams.KEY_COLLECTION: DbConstants.SCRUM_SPRINT, AccessParams.KEY_TYPE: AccessParams.TYPE_SINGLE }))
def get(self): return jsonify( Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get({ AccessParams.KEY_COLLECTION: DbConstants.ACTUAL_DISCREPENCIES, AccessParams.KEY_TYPE: AccessParams.TYPE_MULTI }))
def get(self): return jsonify( Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get({ AccessParams.KEY_COLLECTION: DbConstants.GANTT_LINKS, AccessParams.KEY_TYPE: AccessParams.TYPE_MULTI }))
def get(self): found = Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get({ AccessParams.KEY_COLLECTION: DbConstants.SCRUM_SPRINT_TIMELINE, AccessParams.KEY_TYPE: AccessParams.TYPE_SINGLE }) return ([] if (not found or not ParamConstants.PARAM_TIMELINE in found) else jsonify(found[ParamConstants.PARAM_TIMELINE]))
def delete(self, group): return Accessor.factory(DbConstants.CFG_DB_SCRUM_API).delete({ AccessParams.KEY_COLLECTION: DbConstants.PROJECT_TEAM, AccessParams.KEY_TYPE: AccessParams.TYPE_SINGLE, AccessParams.KEY_MATCH_PARAMS: { ParamConstants.PARAM_GROUP: group } }), 204
def _load(self, cfg): src_data = {} for collection in cfg[ MultiColDoc2XTransformation._CFG_KEY_LOAD_SRC_COLS]: src_data[collection] = Accessor.factory(self._src_db).get({ AccessParams.KEY_COLLECTION: collection, AccessParams.KEY_TYPE: AccessParams.TYPE_MULTI }) for collection in cfg[ MultiColDoc2XTransformation._CFG_KEY_LOAD_SRC_DOCS]: src_data[collection] = Accessor.factory(self._src_db).get({ AccessParams.KEY_COLLECTION: collection, AccessParams.KEY_TYPE: AccessParams.TYPE_SINGLE }) return src_data
def get(self): found = Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get({ AccessParams.KEY_COLLECTION: DbConstants.PROJECT_COMPONENTS, AccessParams.KEY_TYPE: AccessParams.TYPE_SINGLE }) return ([] if (not found or not ParamConstants.PARAM_COMPONENT in found) else found[ParamConstants.PARAM_COMPONENT])
def _load(self, cfg): sources = cfg[Transformation._CFG_KEY_LOAD_SRC] src_data = {} for collection in sources: src_data[collection] = Accessor.factory(self._src_db).get({ AccessParams.KEY_COLLECTION: collection, AccessParams.KEY_TYPE: AccessParams.TYPE_SINGLE }) return src_data
def get_linked_issues(key, link_type): filter = {'source': key, 'type': link_type} return Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get({ AccessParams.KEY_MATCH_PARAMS: filter, AccessParams.KEY_COLLECTION: DbConstants.SCRUM_BACKLOG_LINKS, AccessParams.KEY_TYPE: AccessParams.TYPE_MULTI })
def __extract(input, cfg): filter = {} filter_params = cfg[AccessParams.KEY_MATCH_PARAMS] for param in filter_params: filter.update({param: input[param]}) return Accessor.factory(cfg[AccessParams.KEY_DB]).get({ AccessParams.KEY_MATCH_PARAMS: filter, AccessParams.KEY_COLLECTION: cfg[AccessParams.KEY_COLLECTION], AccessParams.KEY_TYPE: cfg[AccessParams.KEY_TYPE] })
def delete(self, key, date, group, employee): return Accessor.factory(DbConstants.CFG_DB_SCRUM_API).delete({ AccessParams.KEY_COLLECTION: DbConstants.SCRUM_ALLOCATIONS, AccessParams.KEY_TYPE: AccessParams.TYPE_SINGLE, AccessParams.KEY_MATCH_PARAMS: { ParamConstants.PARAM_ITEM_KEY: key, ParamConstants.PARAM_DATE: Converter.convert(date, Types.TYPE_DATE), ParamConstants.PARAM_GROUP: group, ParamConstants.PARAM_EMPLOYEE: employee } }), 204
def get(self): return jsonify( Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get({ AccessParams.KEY_COLLECTION: DbConstants.SCRUM_SPRINT_BACKLOG, AccessParams.KEY_TYPE: AccessParams.TYPE_MULTI, AccessParams.KEY_MATCH_PARAMS: { AccessParams.OPERATOR_OR: [{ ParamConstants.PARAM_TYPE: MatchConstants.TYPE_STORY }, { ParamConstants.PARAM_TYPE: MatchConstants.TYPE_BUG }] } }))
def post(self, group=None): obj_group = request.get_json() employees = obj_group[ParamConstants.PARAM_EMPLOYEES] if ParamConstants.PARAM_EMPLOYEES in obj_group else [] for employee in employees: employee[ParamConstants.PARAM_CAPACITY] = Converter.convert( employee[ParamConstants.PARAM_CAPACITY], Types.TYPE_INT) match_params = { ParamConstants.PARAM_GROUP: group if group else obj_group[ParamConstants.PARAM_GROUP] } return Accessor.factory(DbConstants.CFG_DB_SCRUM_API).upsert({ AccessParams.KEY_COLLECTION: DbConstants.PROJECT_TEAM, AccessParams.KEY_TYPE: AccessParams.TYPE_SINGLE, AccessParams.KEY_OBJECT: obj_group, AccessParams.KEY_MATCH_PARAMS: match_params }), 201
def setUp(self): logger = logging.getLogger(__name__) self.__test_env_cfg = na3x.cfg.get_env_params() self.__test_env_cfg[CFG_KEY_SCRUM_SPRINT] = Accessor.factory( CFG_TEST_DATA_DB).get({ AccessParams.KEY_COLLECTION: CFG_TEST_DATA_COL_SPRINT, AccessParams.KEY_TYPE: AccessParams.TYPE_SINGLE })[CFG_TEST_DATA_SPRINT_ID] try: logger.info('Init JIRA test data importer: {}'.format( ImportTestCase.__CFG_IMPORT)) with open(ImportTestCase.__CFG_IMPORT) as cfg_file: cfg = json.loads( CfgUtils.substitute_params(cfg_file.read(), self.__test_env_cfg)) Importer(cfg, self.__test_env_cfg[CFG_KEY_JIRA_LOGIN], self.__test_env_cfg[CFG_KEY_JIRA_PSWD]).perform() except Exception as e: logging.error(e, exc_info=True) self.__collections = MongoDb(self.__test_env_cfg[ ImportTestCase.__CFG_IMPORT_DB]).connection.collection_names()