public void createISOLanguage( CFSecurityAuthorization Authorization, CFSecurityISOLanguageBuff Buff) { final String S_ProcName = "createISOLanguage"; CFSecurityISOLanguagePKey pkey = schema.getFactoryISOLanguage().newPKey(); pkey.setRequiredISOLanguageId(schema.nextISOLanguageIdGen()); Buff.setRequiredISOLanguageId(pkey.getRequiredISOLanguageId()); CFSecurityISOLanguageByCode3IdxKey keyCode3Idx = schema.getFactoryISOLanguage().newCode3IdxKey(); keyCode3Idx.setRequiredISO6392Code(Buff.getRequiredISO6392Code()); CFSecurityISOLanguageByCode2IdxKey keyCode2Idx = schema.getFactoryISOLanguage().newCode2IdxKey(); keyCode2Idx.setOptionalISO6391Code(Buff.getOptionalISO6391Code()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory() .newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey); } if (dictByCode3Idx.containsKey(keyCode3Idx)) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, "ISOLanguage6392Idx", keyCode3Idx); } // Validate foreign keys // Proceed with adding the new record dictByPKey.put(pkey, Buff); dictByCode3Idx.put(keyCode3Idx, Buff); Map<CFSecurityISOLanguagePKey, CFSecurityISOLanguageBuff> subdictCode2Idx; if (dictByCode2Idx.containsKey(keyCode2Idx)) { subdictCode2Idx = dictByCode2Idx.get(keyCode2Idx); } else { subdictCode2Idx = new HashMap<CFSecurityISOLanguagePKey, CFSecurityISOLanguageBuff>(); dictByCode2Idx.put(keyCode2Idx, subdictCode2Idx); } subdictCode2Idx.put(pkey, Buff); }
public void deleteISOLanguage( CFSecurityAuthorization Authorization, CFSecurityISOLanguageBuff Buff) { final String S_ProcName = "CFInternetRamISOLanguageTable.deleteISOLanguage() "; CFSecurityISOLanguagePKey pkey = schema.getFactoryISOLanguage().newPKey(); pkey.setRequiredISOLanguageId(Buff.getRequiredISOLanguageId()); CFSecurityISOLanguageBuff existing = dictByPKey.get(pkey); if (existing == null) { return; } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "deleteISOLanguage", pkey); } CFSecurityISOLanguageByCode3IdxKey keyCode3Idx = schema.getFactoryISOLanguage().newCode3IdxKey(); keyCode3Idx.setRequiredISO6392Code(existing.getRequiredISO6392Code()); CFSecurityISOLanguageByCode2IdxKey keyCode2Idx = schema.getFactoryISOLanguage().newCode2IdxKey(); keyCode2Idx.setOptionalISO6391Code(existing.getOptionalISO6391Code()); // Validate reverse foreign keys // Delete is valid schema .getTableISOCountryLanguage() .deleteISOCountryLanguageByLanguageIdx(Authorization, Buff.getRequiredISOLanguageId()); Map<CFSecurityISOLanguagePKey, CFSecurityISOLanguageBuff> subdict; dictByPKey.remove(pkey); dictByCode3Idx.remove(keyCode3Idx); subdict = dictByCode2Idx.get(keyCode2Idx); subdict.remove(pkey); }
public void updateISOLanguage( CFSecurityAuthorization Authorization, CFSecurityISOLanguageBuff Buff) { CFSecurityISOLanguagePKey pkey = schema.getFactoryISOLanguage().newPKey(); pkey.setRequiredISOLanguageId(Buff.getRequiredISOLanguageId()); CFSecurityISOLanguageBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory() .newStaleCacheDetectedException( getClass(), "updateISOLanguage", "Existing record not found", "ISOLanguage", pkey); } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "updateISOLanguage", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); CFSecurityISOLanguageByCode3IdxKey existingKeyCode3Idx = schema.getFactoryISOLanguage().newCode3IdxKey(); existingKeyCode3Idx.setRequiredISO6392Code(existing.getRequiredISO6392Code()); CFSecurityISOLanguageByCode3IdxKey newKeyCode3Idx = schema.getFactoryISOLanguage().newCode3IdxKey(); newKeyCode3Idx.setRequiredISO6392Code(Buff.getRequiredISO6392Code()); CFSecurityISOLanguageByCode2IdxKey existingKeyCode2Idx = schema.getFactoryISOLanguage().newCode2IdxKey(); existingKeyCode2Idx.setOptionalISO6391Code(existing.getOptionalISO6391Code()); CFSecurityISOLanguageByCode2IdxKey newKeyCode2Idx = schema.getFactoryISOLanguage().newCode2IdxKey(); newKeyCode2Idx.setOptionalISO6391Code(Buff.getOptionalISO6391Code()); // Check unique indexes if (!existingKeyCode3Idx.equals(newKeyCode3Idx)) { if (dictByCode3Idx.containsKey(newKeyCode3Idx)) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), "updateISOLanguage", "ISOLanguage6392Idx", newKeyCode3Idx); } } // Validate foreign keys // Update is valid Map<CFSecurityISOLanguagePKey, CFSecurityISOLanguageBuff> subdict; dictByPKey.remove(pkey); dictByPKey.put(pkey, Buff); dictByCode3Idx.remove(existingKeyCode3Idx); dictByCode3Idx.put(newKeyCode3Idx, Buff); subdict = dictByCode2Idx.get(existingKeyCode2Idx); if (subdict != null) { subdict.remove(pkey); } if (dictByCode2Idx.containsKey(newKeyCode2Idx)) { subdict = dictByCode2Idx.get(newKeyCode2Idx); } else { subdict = new HashMap<CFSecurityISOLanguagePKey, CFSecurityISOLanguageBuff>(); dictByCode2Idx.put(newKeyCode2Idx, subdict); } subdict.put(pkey, Buff); }
public void updateISOLanguage( CFSecurityAuthorization Authorization, CFSecurityISOLanguageBuff Buff) { final String S_ProcName = "updateISOLanguage"; if ("ISLN".equals(Buff.getClassCode()) && (!schema.isSystemUser(Authorization))) { throw CFLib.getDefaultExceptionFactory() .newRuntimeException( getClass(), S_ProcName, "Permission denied -- only system user can modify ISOLanguage data"); } ResultSet resultSet = null; try { short ISOLanguageId = Buff.getRequiredISOLanguageId(); String ISO6392Code = Buff.getRequiredISO6392Code(); String ISO6391Code = Buff.getOptionalISO6391Code(); String EnglishName = Buff.getRequiredEnglishName(); int Revision = Buff.getRequiredRevision(); Connection cnx = schema.getCnx(); final String sql = "CALL sp_update_iso_lang( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtUpdateByPKey == null) { stmtUpdateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtUpdateByPKey.setLong( argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setString( argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtUpdateByPKey.setString( argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtUpdateByPKey.setLong( argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setLong( argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtUpdateByPKey.setString(argIdx++, "ISLN"); stmtUpdateByPKey.setShort(argIdx++, ISOLanguageId); stmtUpdateByPKey.setString(argIdx++, ISO6392Code); if (ISO6391Code != null) { stmtUpdateByPKey.setString(argIdx++, ISO6391Code); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } stmtUpdateByPKey.setString(argIdx++, EnglishName); stmtUpdateByPKey.setInt(argIdx++, Revision); resultSet = stmtUpdateByPKey.executeQuery(); if (resultSet.next()) { CFSecurityISOLanguageBuff updatedBuff = unpackISOLanguageResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory() .newRuntimeException( getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredISO6392Code(updatedBuff.getRequiredISO6392Code()); Buff.setOptionalISO6391Code(updatedBuff.getOptionalISO6391Code()); Buff.setRequiredEnglishName(updatedBuff.getRequiredEnglishName()); Buff.setRequiredRevision(updatedBuff.getRequiredRevision()); } else { throw CFLib.getDefaultExceptionFactory() .newRuntimeException( getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }