def update_OCCI_kind_descriptions(self, new_data, db_data): """ Updates the OCCI kind description which OCCI_ID is equal to OCCI_ID contained in new_data Args: @param new_data: Data containing the OCCI ID of the kind and the new OCCI kind description @param db_data: Categories already contained in the database """ to_update = list() resp_code = return_code["OK"] for desc in new_data: occi_id = joker.get_description_id(desc) # Step[1]: Extract the old document old_doc = joker.extract_doc(occi_id, db_data) if old_doc is not None: # Step[2]: Update kind OCCI description problems, occi_description = joker.update_occi_category_description(old_doc["OCCI_Description"], desc) # Step[3]: Detect if there is problems if problems is True: message = "Kind OCCI description " + occi_id + " has not been totally updated." logger.error("===== Kind OCCI description update:" + message + " =====") return list(), return_code["Bad Request"] else: message = "Kind OCCI description " + occi_id + " has been updated successfully" old_doc["OCCI_Description"] = occi_description # Step[4]: If no problem, just append the doc to the to_update list to_update.append(old_doc) logger.debug("===== Update kind OCCI description : " + message + " =====") else: message = "Kind document " + occi_id + " couldn't be found " logger.error("===== Update kind OCCI description : " + message + " =====") return list(), return_code["Not Found"] return to_update, resp_code
def update_OCCI_kind_descriptions(self, new_data, db_data): """ Updates the OCCI kind description which OCCI_ID is equal to OCCI_ID contained in new_data Args: @param new_data: Data containing the OCCI ID of the kind and the new OCCI kind description @param db_data: Categories already contained in the database """ to_update = list() resp_code = return_code['OK'] for desc in new_data: occi_id = joker.get_description_id(desc) #Step[1]: Extract the old document old_doc = joker.extract_doc(occi_id, db_data) if old_doc is not None: #Step[2]: Update kind OCCI description problems, occi_description = joker.update_occi_category_description(old_doc['OCCI_Description'], desc) #Step[3]: Detect if there is problems if problems is True: message = "Kind OCCI description " + occi_id + " has not been totally updated." logger.error("===== Kind OCCI description update:" + message + " =====") return list(), return_code['Bad Request'] else: message = "Kind OCCI description " + occi_id + " has been updated successfully" old_doc['OCCI_Description'] = occi_description #Step[4]: If no problem, just append the doc to the to_update list to_update.append(old_doc) logger.debug("===== Update kind OCCI description : " + message + " =====") else: message = "Kind document " + occi_id + " couldn\'t be found " logger.error("===== Update kind OCCI description : " + message + " =====") return list(), return_code['Not Found'] return to_update, resp_code
def update_OCCI_action_descriptions(self, new_data, db_data): """ Updates the OCCI description field of the action which document OCCI_ID is equal to OCCI_ID contained in data Args: @param new_data: Data containing the OCCI ID of the action and the new OCCI action description @param db_data: Data already contained in the database """ to_update = list() resp_code = return_code['OK'] for desc in new_data: #Step[1]: Extract the action document occi_id = joker.get_description_id(desc) old_doc = joker.extract_doc(occi_id, db_data) if old_doc is not None: #Step[2]: Update the Action OCCI description problems, occi_description = joker.update_occi_category_description( old_doc['OCCI_Description'], desc) if problems is True: message = "Action OCCI description " + occi_id + " has not been totally updated." logger.error("===== Update_OCCI_action_description: " + message + " =====") return list(), return_code['Bad Request'] else: message = "Action OCCI description " + occi_id + " has been updated successfully" old_doc['OCCI_Description'] = occi_description to_update.append(old_doc) logger.debug("===== Update_OCCI_action_description: " + message + " =====") else: message = "Action document " + occi_id + " couldn\'t be found " logger.error("===== Update_OCCI_action_description: " + message + " =====") return list(), return_code['Not Found'] #Step[3]: Return the collection of documents to update return to_update, resp_code
def update_OCCI_kind_descriptions(self, new_data, db_data): """ Updates the OCCI description field of the kind which document OCCI_ID is equal to OCCI_ID contained in data (Should only be done by the creator of the kind document) Args: @param new_data: Data containing the OCCI ID of the kind and the new OCCI kind description @param db_data: Categories already contained in the database """ to_update = list() resp_code = return_code['OK'] for desc in new_data: occi_id = joker.get_description_id(desc) old_doc = joker.extract_doc(occi_id, db_data) if old_doc is not None: problems, occi_description = joker.update_occi_category_description(old_doc['OCCI_Description'], desc) if problems is True: message = "Kind OCCI description " + occi_id + " has not been totally updated." logger.error("===== Kind OCCI description update:" + message + " =====") return list(), return_code['Bad Request'] else: message = "Kind OCCI description " + occi_id + " has been updated successfully" old_doc['OCCI_Description'] = occi_description to_update.append(old_doc) logger.debug("===== Update kind OCCI description : " + message + " =====") else: message = "Kind document " + occi_id + " couldn\'t be found " logger.error("===== Update kind OCCI description : " + message + " =====") return list(), return_code['Not Found'] return to_update, resp_code
def update_kind_providers(self, new_data, db_data): """ Updates the kind provider field which document OCCI_ID is equal to OCCI_ID contained in data Args: @param new_data: Data containing the OCCI ID of the kind and the new kind provider description @param db_data: Categories already contained in the database """ to_update = list() resp_code = return_code["OK"] for desc in new_data: # Step[1]: Extract the old document occi_id = desc["OCCI_ID"] old_doc = joker.extract_doc(occi_id, db_data) if old_doc is not None: # Step[2]: Update the kind provider provider_description, problems = doc_Joker.update_kind_provider(old_doc["Provider"], desc["Provider"]) if problems is True: message = "Kind provider description " + occi_id + " has not been totally updated." logger.error("===== Kind provider description update " + message + " =====") return list(), return_code["Bad Request"] else: message = "Kind provider description " + occi_id + " has been updated successfully" old_doc["Provider"] = provider_description # Step[3]: if OK, append the kind doc to the to_update list to_update.append(old_doc) logger.debug("===== Update kind provider description : " + message + " =====") else: message = "Kind document " + occi_id + " couldn't be found " logger.error("===== Update kind provider des : " + message + " =====") return list(), return_code["Not Found"] return to_update, resp_code
def update_OCCI_mixin_descriptions(self, new_data, db_data): """ Updates the OCCI description field of the mixin which document OCCI_ID is equal to OCCI_ID contained in data Args: @param new_data: Data containing the OCCI ID of the mixin and the new OCCI mixin description @param db_data: Data already contained in the database """ to_update = list() resp_code = return_code['OK'] for desc in new_data: #Step[1]: Extract the old document occi_id = joker.get_description_id(desc) old_doc = joker.extract_doc(occi_id, db_data) if old_doc is not None: #Step[2]: Update OCCI mixin description problems, occi_description = joker.update_occi_category_description(old_doc['OCCI_Description'], desc) if problems is True: message = "Mixin OCCI description " + occi_id + " has not been totally updated." logger.error("===== update_OCCI_mixin_descriptions: " + message + " ===== ") return list(), return_code['Bad Request'] else: #Step[3]: If OK, append the mixin doc to the to_update list message = "Mixin OCCI description " + occi_id + " has been updated successfully" old_doc['OCCI_Description'] = occi_description to_update.append(old_doc) logger.debug("===== update_OCCI_mixin_descriptions: " + message + " ===== ") else: message = "Mixin document " + occi_id + " couldn\'t be found " logger.error("===== update_OCCI_mixin_descriptions: " + message + " ===== ") return list(), return_code['Not Found'] return to_update, resp_code
def update_kind_providers(self, new_data, db_data): """ Updates the kind provider field which document OCCI_ID is equal to OCCI_ID contained in data Args: @param new_data: Data containing the OCCI ID of the kind and the new kind provider description @param db_data: Categories already contained in the database """ to_update = list() resp_code = return_code['OK'] for desc in new_data: #Step[1]: Extract the old document occi_id = desc['OCCI_ID'] old_doc = joker.extract_doc(occi_id, db_data) if old_doc is not None: #Step[2]: Update the kind provider provider_description, problems = doc_Joker.update_kind_provider(old_doc['Provider'], desc['Provider']) if problems is True: message = "Kind provider description " + occi_id + " has not been totally updated." logger.error("===== Kind provider description update " + message + " =====") return list(), return_code['Bad Request'] else: message = "Kind provider description " + occi_id + " has been updated successfully" old_doc['Provider'] = provider_description #Step[3]: if OK, append the kind doc to the to_update list to_update.append(old_doc) logger.debug("===== Update kind provider description : " + message + " =====") else: message = "Kind document " + occi_id + " couldn\'t be found " logger.error("===== Update kind provider des : " + message + " =====") return list(), return_code['Not Found'] return to_update, resp_code