def finish_handle(self): filepath = os.path.join(settings.FILEPATH, "corehq", "pillows", "mappings", "app_mapping.py") app_pillow = AppPillow(create_index=False) # current index # check current index aliased_indices = app_pillow.check_alias() current_index = app_pillow.es_index # regenerate the mapping dict m = DEFAULT_MAPPING_WRAPPER m["properties"] = dynamic.set_properties(self.doc_class, custom_types=app_special_types) m["_meta"]["comment"] = "Autogenerated [%s] mapping from ptop_generate_mapping %s" % ( self.doc_class_str, datetime.utcnow().strftime("%m/%d/%Y"), ) app_pillow.default_mapping = m if hasattr(app_pillow, "_calc_meta"): delattr(app_pillow, "_calc_meta") output = [] output.append('APP_INDEX="%s_%s"' % (app_pillow.es_index_prefix, app_pillow.calc_meta())) output.append("APP_MAPPING=%s" % pprint.pformat(m)) newcalc_index = "%s_%s" % (app_pillow.es_index_prefix, app_pillow.calc_meta()) print "Writing new application index and mapping: %s" % output[0] with open(filepath, "w") as outfile: outfile.write("\n".join(output)) if newcalc_index not in aliased_indices and newcalc_index != current_index: sys.stderr.write("\n\tWarning, current index %s is not aliased at the moment\n" % current_index) sys.stderr.write("\tCurrent live aliased index: %s\n\n" % (",".join(aliased_indices))) sys.stderr.write("File written to %s\n" % filepath)
def finish_handle(self): filepath = os.path.join(settings.FILEPATH, 'submodules','core-hq-src','corehq','pillows','mappings','case_mapping.py') casepillow = CasePillow(create_index=False) #current index #check current index aliased_indices = casepillow.check_alias() # current_index = '%s_%s' % (casepillow.es_index_prefix, casepillow.calc_meta()) current_index = casepillow.es_index #regenerate the mapping dict m = DEFAULT_MAPPING_WRAPPER m['properties'] = dynamic.set_properties(self.doc_class, custom_types=case_special_types) m['_meta']['comment'] = "Autogenerated [%s] mapping from ptop_generate_mapping %s" % (self.doc_class_str, datetime.utcnow().strftime('%m/%d/%Y')) casepillow.default_mapping = m delattr(casepillow, '_calc_meta') output = [] output.append('CASE_INDEX="%s_%s"' % (casepillow.es_index_prefix, casepillow.calc_meta())) output.append('CASE_MAPPING=%s' % m) newcalc_index = "%s_%s" % (casepillow.es_index_prefix, casepillow.calc_meta()) print "Writing new case_index and mapping: %s" % output[0] with open(filepath, 'w') as outfile: outfile.write('\n'.join(output)) if newcalc_index not in aliased_indices and newcalc_index != current_index: sys.stderr.write("\n\tWarning, current index %s is not aliased at the moment\n" % current_index) sys.stderr.write("\tCurrent live aliased index: %s\n\n" % (','.join(aliased_indices))) sys.stderr.write("File written to %s\n" % filepath)
def finish_handle(self): filepath = os.path.join(settings.FILEPATH, 'corehq', 'pillows', 'mappings', 'user_mapping.py') userpillow = UserPillow(create_index=False) #current index #check current index aliased_indices = userpillow.check_alias() current_index = userpillow.es_index #regenerate the mapping dict m = DEFAULT_MAPPING_WRAPPER user_special_types = { "domain": type_exact_match_string("domain", dual=True), "username": type_exact_match_string("username", dual=True), "user_data": { "dynamic": True, "type": "object" }, } user_special_types["username"]["fields"]["exact"][ "include_in_all"] = False user_special_types["username"]["fields"]["username"][ "analyzer"] = "simple" m['properties'] = dynamic.set_properties( self.doc_class, custom_types=user_special_types) m['_meta'][ 'comment'] = "Autogenerated [%s] mapping from ptop_generate_mapping %s" % ( self.doc_class_str, datetime.utcnow().strftime('%m/%d/%Y')) m['_all'] = {"analyzer": "simple"} userpillow.default_mapping = m if hasattr(userpillow, '_calc_meta'): delattr(userpillow, '_calc_meta') output = [] output.append('USER_INDEX="%s_%s"' % (userpillow.es_index_prefix, userpillow.calc_meta())) output.append('USER_MAPPING=%s' % pprint.pformat(m)) newcalc_index = "%s_%s" % (userpillow.es_index_prefix, userpillow.calc_meta()) print "Writing new user index and mapping: %s" % output[0] with open(filepath, 'w') as outfile: outfile.write('\n'.join(output)) if newcalc_index not in aliased_indices and newcalc_index != current_index: sys.stderr.write( "\n\tWarning, current index %s is not aliased at the moment\n" % current_index) sys.stderr.write("\tCurrent live aliased index: %s\n\n" % (','.join(aliased_indices))) sys.stderr.write("File written to %s\n" % filepath)
def finish_handle(self): filepath = os.path.join(settings.FILEPATH, 'corehq','pillows','mappings','tc_sms_mapping.py') smspillow = TCSMSPillow(create_index=False) #current index #check current index aliased_indices = smspillow.check_alias() current_index = smspillow.es_index #regenerate the mapping dict m = DEFAULT_MAPPING_WRAPPER init_dict = { TC_STUB + "case_data": { "dynamic": False, "properties": { "case_id": {'type': 'string'}, "case_type": {'type': 'string'}, "response_state": {'type': 'string'}, }, }, TC_STUB + "session_data": { "dynamic": False, "properties": { "session_id": {'type': 'string'}, "case_type": {'type': 'string'}, "response_state": {'type': 'string'}, }, }, } m['properties'] = dynamic.set_properties(self.doc_class, init_dict=init_dict) m['_meta']['comment'] = "Autogenerated [%s] mapping from ptop_generate_mapping %s" % (self.doc_class_str, datetime.utcnow().strftime('%m/%d/%Y')) smspillow.default_mapping = m if hasattr(smspillow, '_calc_meta'): delattr(smspillow, '_calc_meta') output = [] output.append('TCSMS_INDEX="%s_%s"' % (smspillow.es_index_prefix, smspillow.calc_meta())) output.append('TCSMS_MAPPING=%s' % pprint.pformat(m)) newcalc_index = "%s_%s" % (smspillow.es_index_prefix, smspillow.calc_meta()) print "Writing new trialconnect sms index and mapping: %s" % output[0] with open(filepath, 'w') as outfile: outfile.write('\n'.join(output)) if newcalc_index not in aliased_indices and newcalc_index != current_index: sys.stderr.write("\n\tWarning, current index %s is not aliased at the moment\n" % current_index) sys.stderr.write("\tCurrent live aliased index: %s\n\n" % (','.join(aliased_indices))) sys.stderr.write("File written to %s\n" % filepath)
def finish_handle(self): filepath = os.path.join(settings.FILEPATH, 'corehq', 'pillows', 'mappings', 'app_mapping.py') app_pillow = AppPillow(create_index=False) #current index #check current index aliased_indices = app_pillow.check_alias() current_index = app_pillow.es_index #regenerate the mapping dict m = DEFAULT_MAPPING_WRAPPER init_dict = { "cp_is_active": { "type": "boolean" }, } m['properties'] = dynamic.set_properties( self.doc_class, custom_types=app_special_types, init_dict=init_dict) m['_meta'][ 'comment'] = "Autogenerated [%s] mapping from ptop_generate_mapping %s" % ( self.doc_class_str, datetime.utcnow().strftime('%m/%d/%Y')) app_pillow.default_mapping = m if hasattr(app_pillow, '_calc_meta'): delattr(app_pillow, '_calc_meta') output = [] output.append('APP_INDEX="%s_%s"' % (app_pillow.es_index_prefix, app_pillow.calc_meta())) output.append('APP_MAPPING=%s' % pprint.pformat(m)) newcalc_index = "%s_%s" % (app_pillow.es_index_prefix, app_pillow.calc_meta()) print "Writing new application index and mapping: %s" % output[0] with open(filepath, 'w') as outfile: outfile.write('\n'.join(output)) if newcalc_index not in aliased_indices and newcalc_index != current_index: sys.stderr.write( "\n\tWarning, current index %s is not aliased at the moment\n" % current_index) sys.stderr.write("\tCurrent live aliased index: %s\n\n" % (','.join(aliased_indices))) sys.stderr.write("File written to %s\n" % filepath)
def finish_handle(self): filepath = os.path.join(settings.FILEPATH, 'corehq','pillows','mappings','domain_mapping.py') domainpillow = DomainPillow(create_index=False) #current index #check current index aliased_indices = domainpillow.check_alias() # current_index = '%s_%s' % (casepillow.es_index_prefix, casepillow.calc_meta()) current_index = domainpillow.es_index #regenerate the mapping dict m = DEFAULT_MAPPING_WRAPPER init_dict = { "cp_n_web_users": {"type": "long"}, "cp_n_active_cc_users": {"type": "long"}, "cp_n_cc_users": {"type": "long"}, "cp_n_users_submitted_form": {"type": "long"}, "cp_n_60_day_cases": {"type": "long"}, "cp_n_active_cases": {"type": "long"}, "cp_n_inactive_cases": {"type": "long"}, "cp_n_cases": {"type": "long"}, "cp_n_forms": {"type": "long"}, "cp_first_form": type_full_date(), "cp_last_form": type_full_date(), "cp_is_active": {"type": "boolean"}, "cp_has_app": {"type": "boolean"}, } m['properties'] = dynamic.set_properties(self.doc_class, custom_types=domain_special_types, init_dict=init_dict) m['_meta']['comment'] = "Autogenerated [%s] mapping from ptop_generate_mapping %s" % (self.doc_class_str, datetime.utcnow().strftime('%m/%d/%Y')) domainpillow.default_mapping = m if hasattr(domainpillow, '_calc_meta'): delattr(domainpillow, '_calc_meta') output = [] output.append('DOMAIN_INDEX="%s_%s"' % (domainpillow.es_index_prefix, domainpillow.calc_meta())) output.append('DOMAIN_MAPPING=%s' % pprint.pformat(m)) newcalc_index = "%s_%s" % (domainpillow.es_index_prefix, domainpillow.calc_meta()) print "Writing new domain index and mapping: %s" % output[0] with open(filepath, 'w') as outfile: outfile.write('\n'.join(output)) if newcalc_index not in aliased_indices and newcalc_index != current_index: sys.stderr.write("\n\tWarning, current index %s is not aliased at the moment\n" % current_index) sys.stderr.write("\tCurrent live aliased index: %s\n\n" % (','.join(aliased_indices))) sys.stderr.write("File written to %s\n" % filepath)
def finish_handle(self): filepath = os.path.join(settings.FILEPATH, 'corehq','pillows','mappings','user_mapping.py') userpillow = UserPillow(create_index=False) #current index #check current index aliased_indices = userpillow.check_alias() current_index = userpillow.es_index #regenerate the mapping dict m = DEFAULT_MAPPING_WRAPPER user_special_types = { "domain": type_exact_match_string("domain", dual=True), "username": type_exact_match_string("username", dual=True), "user_data": {"dynamic": True, "type": "object"}, } user_special_types["username"]["fields"]["exact"]["include_in_all"] = False user_special_types["username"]["fields"]["username"]["analyzer"] = "simple" m['properties'] = dynamic.set_properties(self.doc_class, custom_types=user_special_types) m['_meta']['comment'] = "Autogenerated [%s] mapping from ptop_generate_mapping %s" % (self.doc_class_str, datetime.utcnow().strftime('%m/%d/%Y')) m['_all'] = {"analyzer": "simple"} userpillow.default_mapping = m if hasattr(userpillow, '_calc_meta'): delattr(userpillow, '_calc_meta') output = [] output.append('USER_INDEX="%s_%s"' % (userpillow.es_index_prefix, userpillow.calc_meta())) output.append('USER_MAPPING=%s' % pprint.pformat(m)) newcalc_index = "%s_%s" % (userpillow.es_index_prefix, userpillow.calc_meta()) print "Writing new user index and mapping: %s" % output[0] with open(filepath, 'w') as outfile: outfile.write('\n'.join(output)) if newcalc_index not in aliased_indices and newcalc_index != current_index: sys.stderr.write("\n\tWarning, current index %s is not aliased at the moment\n" % current_index) sys.stderr.write("\tCurrent live aliased index: %s\n\n" % (','.join(aliased_indices))) sys.stderr.write("File written to %s\n" % filepath)
def finish_handle(self): """ Yes, this looks eerily similar to ptop_make_case_mapping Only thing flipping is dynamic=False to True on the top level mapping dict However, this FullCaseIndex is likely going to be a stopgap measure until we get a concept dictionary setup, so a little ugliness in execution will get things done for now """ filepath = os.path.join(settings.FILEPATH, 'corehq','pillows','mappings','fullcase_mapping.py') casepillow = FullCasePillow(create_index=False) #current index #check current index aliased_indices = casepillow.check_alias() # current_index = '%s_%s' % (casepillow.es_index_prefix, casepillow.calc_meta()) current_index = casepillow.es_index #regenerate the mapping dict m = DEFAULT_MAPPING_WRAPPER m['dynamic'] = True m['properties'] = dynamic.set_properties(self.doc_class, custom_types=case_special_types) m['_meta']['comment'] = "Autogenerated [%s] mapping from ptop_generate_mapping %s" % (self.doc_class_str, datetime.utcnow().strftime('%m/%d/%Y')) casepillow.default_mapping = m delattr(casepillow, '_calc_meta_cache') output = [] output.append('FULL_CASE_INDEX="%s_%s"' % (casepillow.es_index_prefix, casepillow.calc_meta())) output.append('FULL_CASE_MAPPING=%s' % pprint.pprint(m)) newcalc_index = "%s_%s" % (casepillow.es_index_prefix, casepillow.calc_meta()) print "Writing new case_index and mapping: %s" % output[0] with open(filepath, 'w') as outfile: outfile.write('\n'.join(output)) if newcalc_index not in aliased_indices and newcalc_index != current_index: sys.stderr.write("\n\tWarning, current index %s is not aliased at the moment\n" % current_index) sys.stderr.write("\tCurrent live aliased index: %s\n\n" % (','.join(aliased_indices))) sys.stderr.write("File written to %s\n" % filepath)
def finish_handle(self): filepath = os.path.join(settings.FILEPATH, 'corehq','pillows','mappings','app_mapping.py') app_pillow = AppPillow(create_index=False) #current index #check current index aliased_indices = app_pillow.check_alias() current_index = app_pillow.es_index #regenerate the mapping dict m = DEFAULT_MAPPING_WRAPPER init_dict = { "cp_is_active": {"type": "boolean"}, } m['properties'] = dynamic.set_properties(self.doc_class, custom_types=app_special_types, init_dict=init_dict) m['_meta']['comment'] = "Autogenerated [%s] mapping from ptop_generate_mapping %s" % (self.doc_class_str, datetime.utcnow().strftime('%m/%d/%Y')) app_pillow.default_mapping = m if hasattr(app_pillow, '_calc_meta'): delattr(app_pillow, '_calc_meta') output = [] output.append('APP_INDEX="%s_%s"' % (app_pillow.es_index_prefix, app_pillow.calc_meta())) output.append('APP_MAPPING=%s' % pprint.pformat(m)) newcalc_index = "%s_%s" % (app_pillow.es_index_prefix, app_pillow.calc_meta()) print "Writing new application index and mapping: %s" % output[0] with open(filepath, 'w') as outfile: outfile.write('\n'.join(output)) if newcalc_index not in aliased_indices and newcalc_index != current_index: sys.stderr.write("\n\tWarning, current index %s is not aliased at the moment\n" % current_index) sys.stderr.write("\tCurrent live aliased index: %s\n\n" % (','.join(aliased_indices))) sys.stderr.write("File written to %s\n" % filepath)
def schedule_mapping_generator(): m = dynamic.DEFAULT_MAPPING_WRAPPER doc_class=CDotWeeklySchedule m['properties'] = dynamic.set_properties(doc_class) m['_meta']['created'] = "foo" return m
def finish_handle(self): filepath = os.path.join(settings.FILEPATH, 'corehq', 'pillows', 'mappings', 'domain_mapping.py') domainpillow = DomainPillow(create_index=False) #current index #check current index aliased_indices = domainpillow.check_alias() # current_index = '%s_%s' % (casepillow.es_index_prefix, casepillow.calc_meta()) current_index = domainpillow.es_index #regenerate the mapping dict m = DEFAULT_MAPPING_WRAPPER init_dict = { "cp_n_web_users": { "type": "long" }, "cp_n_active_cc_users": { "type": "long" }, "cp_n_cc_users": { "type": "long" }, "cp_n_active_cases": { "type": "long" }, "cp_n_cases": { "type": "long" }, "cp_n_forms": { "type": "long" }, "cp_first_form": type_full_date(), "cp_last_form": type_full_date(), "cp_is_active": { "type": "boolean" }, "cp_has_app": { "type": "boolean" }, } m['properties'] = dynamic.set_properties( self.doc_class, custom_types=domain_special_types, init_dict=init_dict) m['_meta'][ 'comment'] = "Autogenerated [%s] mapping from ptop_generate_mapping %s" % ( self.doc_class_str, datetime.utcnow().strftime('%m/%d/%Y')) domainpillow.default_mapping = m if hasattr(domainpillow, '_calc_meta'): delattr(domainpillow, '_calc_meta') output = [] output.append('DOMAIN_INDEX="%s_%s"' % (domainpillow.es_index_prefix, domainpillow.calc_meta())) output.append('DOMAIN_MAPPING=%s' % m) newcalc_index = "%s_%s" % (domainpillow.es_index_prefix, domainpillow.calc_meta()) print "Writing new domain index and mapping: %s" % output[0] with open(filepath, 'w') as outfile: outfile.write('\n'.join(output)) if newcalc_index not in aliased_indices and newcalc_index != current_index: sys.stderr.write( "\n\tWarning, current index %s is not aliased at the moment\n" % current_index) sys.stderr.write("\tCurrent live aliased index: %s\n\n" % (','.join(aliased_indices))) sys.stderr.write("File written to %s\n" % filepath)
def finish_handle(self): filepath = os.path.join(settings.FILEPATH, 'corehq', 'pillows', 'mappings', 'tc_sms_mapping.py') smspillow = TCSMSPillow(create_index=False) #current index #check current index aliased_indices = smspillow.check_alias() current_index = smspillow.es_index #regenerate the mapping dict m = DEFAULT_MAPPING_WRAPPER init_dict = { TC_STUB + "case_data": { "dynamic": False, "properties": { "case_id": { 'type': 'string' }, "case_type": { 'type': 'string' }, "response_state": { 'type': 'string' }, }, }, TC_STUB + "session_data": { "dynamic": False, "properties": { "session_id": { 'type': 'string' }, "case_type": { 'type': 'string' }, "response_state": { 'type': 'string' }, }, }, } m['properties'] = dynamic.set_properties(self.doc_class, init_dict=init_dict) m['_meta'][ 'comment'] = "Autogenerated [%s] mapping from ptop_generate_mapping %s" % ( self.doc_class_str, datetime.utcnow().strftime('%m/%d/%Y')) smspillow.default_mapping = m if hasattr(smspillow, '_calc_meta'): delattr(smspillow, '_calc_meta') output = [] output.append('TCSMS_INDEX="%s_%s"' % (smspillow.es_index_prefix, smspillow.calc_meta())) output.append('TCSMS_MAPPING=%s' % pprint.pformat(m)) newcalc_index = "%s_%s" % (smspillow.es_index_prefix, smspillow.calc_meta()) print "Writing new trialconnect sms index and mapping: %s" % output[0] with open(filepath, 'w') as outfile: outfile.write('\n'.join(output)) if newcalc_index not in aliased_indices and newcalc_index != current_index: sys.stderr.write( "\n\tWarning, current index %s is not aliased at the moment\n" % current_index) sys.stderr.write("\tCurrent live aliased index: %s\n\n" % (','.join(aliased_indices))) sys.stderr.write("File written to %s\n" % filepath)
def schedule_mapping_generator(): m = dynamic.DEFAULT_MAPPING_WRAPPER doc_class = CDotWeeklySchedule m['properties'] = dynamic.set_properties(doc_class) m['_meta']['created'] = "foo" return m