string QueryBuilder::query_insert_target(int base, string baseName, bool isTgtTypedef, string tgtName) { string query = "("+baseStr(base)+" where name=\"" +baseName + "\")"; query += " :< (create ("; //if (isTgtTypedef) query += TC_MDNT_NAME; else query += TC_MDN_NAME; query += (isTgtTypedef ? TC_MDNT_NAME : TC_MDN_NAME); query += " where name=\""+tgtName+"\") as target)"; return query; }
//FIXME: the first argument(strPayer) best is Enum type; std::string ConstructInsertSQLStatement(eActorType ePayer, float fMoney, bool bZYF, bool bHC, bool bDQ, bool bRev1, bool bRev2) { std::string strPayer = ConvertActorType(ePayer); std::string baseStr("insert into ConsumeCount(Payer,money,zhangyunfeng,huachen,dongqiang,name_reserve1,name_reserve2,recordTime) values("); baseStr = baseStr + "'" + strPayer + "'," + float2string(fMoney) + "," + boolean2string(bZYF) + "," + boolean2string(bHC) + "," + boolean2string(bDQ) + "," + boolean2string(bRev1) +"," + boolean2string(bRev2) + "," + "(select current_timestamp)" + ")"; return baseStr; }
string QueryBuilder::query_insert_subobj(int ownerBase, string ownerName, string subName) { string query = "(" + baseStr(ownerBase) + " where name=\""+ownerName+"\") :< "; query += "(subobject where name = \"" + subName +"\");"; return query; }
string QueryBuilder::query_insert_owner(string name, string ownerName, int ownerBase) { string query = "(subobject where name=\""+name+"\") :< "; query += "(create (" + baseStr(ownerBase)+" where name=\""+ownerName+"\") as owner);"; return query; }
GSExceptionRegenerator::GSExceptionRegenerator( UTIL_EXCEPTION_CONSTRUCTOR_ARGS_LIST) throw() : fileNameLiteral_(fileNameLiteral), functionNameLiteral_(functionNameLiteral), critical_(false) { util::Exception cause; util::Exception::DuplicatedLiteralFlags filteredFlags; const util::Exception::DuplicatedLiteralFlags baseFlags = util::Exception::LITERAL_ALL_DUPLICATED; NamedErrorCode filteredCode; const char8_t *extraMessage = NULL; if (causeInHandling != NULL) { NamedErrorCode causeCode; bool userOrSystemThrown = false; bool unexpectedType = false; try { throw; } catch (const UserException &e) { cause = e; userOrSystemThrown = true; causeCode = selectErrorCode(e.getNamedErrorCode(), GS_EXCEPTION_NAMED_CODE(GS_ERROR_CM_INTERNAL_ERROR)); filteredFlags = e.inheritLiteralFlags(baseFlags) | literalFlags; } catch (const SystemException &e) { cause = e; critical_ = true; userOrSystemThrown = true; causeCode = selectErrorCode(e.getNamedErrorCode(), GS_EXCEPTION_NAMED_CODE(GS_ERROR_CM_INTERNAL_ERROR)); filteredFlags = e.inheritLiteralFlags(baseFlags) | literalFlags; } catch (const util::PlatformException &e) { cause = e; causeCode = GS_EXCEPTION_NAMED_CODE(GS_ERROR_CM_PLATFORM_ERROR); filteredFlags = e.inheritLiteralFlags(baseFlags) | literalFlags; } catch (const util::UtilityException &e) { cause = e; switch (e.getErrorCode()) { case util::UtilityException::CODE_NO_MEMORY: causeCode = GS_EXCEPTION_NAMED_CODE(GS_ERROR_CM_NO_MEMORY); break; case util::UtilityException::CODE_MEMORY_LIMIT_EXCEEDED: causeCode = GS_EXCEPTION_NAMED_CODE(GS_ERROR_CM_MEMORY_LIMIT_EXCEEDED); break; case util::UtilityException::CODE_SIZE_LIMIT_EXCEEDED: causeCode = GS_EXCEPTION_NAMED_CODE(GS_ERROR_CM_SIZE_LIMIT_EXCEEDED); break; default: causeCode = GS_EXCEPTION_NAMED_CODE(GS_ERROR_CM_INTERNAL_ERROR); extraMessage = "Internal error by unexpected utility problem"; break; } filteredFlags = literalFlags; } catch (const util::Exception &e) { cause = e; if (e.getErrorCode() == 0) { critical_ = true; unexpectedType = true; causeCode = GS_EXCEPTION_NAMED_CODE(GS_ERROR_CM_INTERNAL_ERROR); filteredFlags = literalFlags; } else { causeCode = e.getNamedErrorCode(); filteredFlags = e.inheritLiteralFlags(baseFlags) | literalFlags; } } catch (const std::bad_alloc &) { causeCode = GS_EXCEPTION_NAMED_CODE(GS_ERROR_CM_NO_MEMORY); filteredFlags = literalFlags; } catch (...) { critical_ = true; unexpectedType = true; causeCode = GS_EXCEPTION_NAMED_CODE(GS_ERROR_CM_INTERNAL_ERROR); filteredFlags = literalFlags; } filteredCode = selectErrorCode(namedErrorCode, causeCode); if (userOrSystemThrown && causeCode.getCode() == GS_ERROR_CM_INTERNAL_ERROR && cause.getErrorCode() == GS_ERROR_DEFAULT) { extraMessage = "Internal error by empty error code"; } else if (unexpectedType) { extraMessage = "Internal error by unexpected exception type"; } } else { filteredCode = namedErrorCode; filteredFlags = literalFlags; } filteredCode = selectErrorCode( filteredCode, GS_EXCEPTION_NAMED_CODE(GS_ERROR_CM_INTERNAL_ERROR)); typedef util::NormalOStringStream StrStream; typedef util::Exception::NoThrowString<StrStream::allocator_type> SafeStr; StrStream baseStream; baseStream << cause.getField(util::Exception::FIELD_MESSAGE); SafeStr baseStr(baseStream); const char8_t *strPtr = baseStr.get(); const char8_t *baseMessage = (message != NULL && strlen(message) > 0) ? message : (strPtr == NULL || strlen(strPtr) > 0 ? strPtr : NULL); StrStream messageStream; if (extraMessage == NULL) { if (baseMessage != NULL) { messageStream << baseMessage; } } else { messageStream << extraMessage; if (baseMessage != NULL) { messageStream << " (reason=" << baseMessage << ")"; } } base_ = util::Exception(filteredCode, SafeStr(messageStream).get(), NULL, NULL, lineNumber, causeInHandling, typeNameLiteral, stackTraceMode, filteredFlags); }