Exemple #1
0
 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)
Exemple #2
0
 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)
Exemple #3
0
 def get(self):
     return Accessor.factory(DbConstants.CFG_DB_SCRUM_API).get({
         AccessParams.KEY_COLLECTION:
         DbConstants.PROJECT_EMPLOYEES,
         AccessParams.KEY_TYPE:
         AccessParams.TYPE_MULTI
     })
Exemple #4
0
    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
Exemple #5
0
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
Exemple #6
0
 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
     })
Exemple #7
0
 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
         }))
Exemple #8
0
 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
         }))
Exemple #9
0
 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
         }))
Exemple #10
0
 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]))
Exemple #11
0
 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
Exemple #12
0
 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
Exemple #13
0
 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])
Exemple #14
0
 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
Exemple #15
0
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
    })
Exemple #16
0
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]
    })
Exemple #17
0
 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
Exemple #18
0
 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
                 }]
             }
         }))
Exemple #19
0
 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
Exemple #20
0
 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()