Example usage for java.util SortedMap remove

List of usage examples for java.util SortedMap remove

Introduction

In this page you can find the example usage for java.util SortedMap remove.

Prototype

V remove(Object key);

Source Link

Document

Removes the mapping for a key from this map if it is present (optional operation).

Usage

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamContactURLTable.java

public void updateContactURL(CFAccAuthorization Authorization, CFAccContactURLBuff Buff) {
    CFAccContactURLPKey pkey = schema.getFactoryContactURL().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredContactURLId(Buff.getRequiredContactURLId());
    CFAccContactURLBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateContactURL",
                "Existing record not found", "ContactURL", pkey);
    }//  w ww.j a va  2s.  com
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateContactURL",
                pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAccContactURLByTenantIdxKey existingKeyTenantIdx = schema.getFactoryContactURL().newTenantIdxKey();
    existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId());

    CFAccContactURLByTenantIdxKey newKeyTenantIdx = schema.getFactoryContactURL().newTenantIdxKey();
    newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFAccContactURLByContactIdxKey existingKeyContactIdx = schema.getFactoryContactURL().newContactIdxKey();
    existingKeyContactIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyContactIdx.setRequiredContactId(existing.getRequiredContactId());

    CFAccContactURLByContactIdxKey newKeyContactIdx = schema.getFactoryContactURL().newContactIdxKey();
    newKeyContactIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyContactIdx.setRequiredContactId(Buff.getRequiredContactId());

    CFAccContactURLByProtocolIdxKey existingKeyProtocolIdx = schema.getFactoryContactURL().newProtocolIdxKey();
    existingKeyProtocolIdx.setOptionalURLProtocolId(existing.getOptionalURLProtocolId());

    CFAccContactURLByProtocolIdxKey newKeyProtocolIdx = schema.getFactoryContactURL().newProtocolIdxKey();
    newKeyProtocolIdx.setOptionalURLProtocolId(Buff.getOptionalURLProtocolId());

    CFAccContactURLByUNameIdxKey existingKeyUNameIdx = schema.getFactoryContactURL().newUNameIdxKey();
    existingKeyUNameIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyUNameIdx.setRequiredContactId(existing.getRequiredContactId());
    existingKeyUNameIdx.setRequiredName(existing.getRequiredName());

    CFAccContactURLByUNameIdxKey newKeyUNameIdx = schema.getFactoryContactURL().newUNameIdxKey();
    newKeyUNameIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyUNameIdx.setRequiredContactId(Buff.getRequiredContactId());
    newKeyUNameIdx.setRequiredName(Buff.getRequiredName());

    // Check unique indexes

    if (!existingKeyUNameIdx.equals(newKeyUNameIdx)) {
        if (dictByUNameIdx.containsKey(newKeyUNameIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateContactURL", "ContactURLUNameIdx", newKeyUNameIdx);
        }
    }

    // Validate foreign keys

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateContactURL", "Owner", "ContactURLTenant", "Tenant", null);
            }
        }
    }

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableContact().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId(),
                    Buff.getRequiredContactId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateContactURL", "Container", "Contact", "Contact", null);
            }
        }
    }

    // Update is valid

    SortedMap<CFAccContactURLPKey, CFAccContactURLBuff> subdict;

    dictByPKey.remove(pkey);
    dictByPKey.put(pkey, Buff);

    subdict = dictByTenantIdx.get(existingKeyTenantIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByTenantIdx.containsKey(newKeyTenantIdx)) {
        subdict = dictByTenantIdx.get(newKeyTenantIdx);
    } else {
        subdict = new TreeMap<CFAccContactURLPKey, CFAccContactURLBuff>();
        dictByTenantIdx.put(newKeyTenantIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByContactIdx.get(existingKeyContactIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByContactIdx.containsKey(newKeyContactIdx)) {
        subdict = dictByContactIdx.get(newKeyContactIdx);
    } else {
        subdict = new TreeMap<CFAccContactURLPKey, CFAccContactURLBuff>();
        dictByContactIdx.put(newKeyContactIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByProtocolIdx.get(existingKeyProtocolIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByProtocolIdx.containsKey(newKeyProtocolIdx)) {
        subdict = dictByProtocolIdx.get(newKeyProtocolIdx);
    } else {
        subdict = new TreeMap<CFAccContactURLPKey, CFAccContactURLBuff>();
        dictByProtocolIdx.put(newKeyProtocolIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUNameIdx.remove(existingKeyUNameIdx);
    dictByUNameIdx.put(newKeyUNameIdx, Buff);

}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamAttachmentTable.java

public void updateAttachment(CFAccAuthorization Authorization, CFAccAttachmentBuff Buff) {
    CFAccAttachmentPKey pkey = schema.getFactoryAttachment().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredAttachmentId(Buff.getRequiredAttachmentId());
    CFAccAttachmentBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateAttachment",
                "Existing record not found", "Attachment", pkey);
    }/*from w  w w. j  a v a2  s .c om*/
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateAttachment",
                pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAccAttachmentByTenantIdxKey existingKeyTenantIdx = schema.getFactoryAttachment().newTenantIdxKey();
    existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId());

    CFAccAttachmentByTenantIdxKey newKeyTenantIdx = schema.getFactoryAttachment().newTenantIdxKey();
    newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFAccAttachmentByContactIdxKey existingKeyContactIdx = schema.getFactoryAttachment().newContactIdxKey();
    existingKeyContactIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyContactIdx.setRequiredContactId(existing.getRequiredContactId());

    CFAccAttachmentByContactIdxKey newKeyContactIdx = schema.getFactoryAttachment().newContactIdxKey();
    newKeyContactIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyContactIdx.setRequiredContactId(Buff.getRequiredContactId());

    CFAccAttachmentByUDescrIdxKey existingKeyUDescrIdx = schema.getFactoryAttachment().newUDescrIdxKey();
    existingKeyUDescrIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyUDescrIdx.setRequiredContactId(existing.getRequiredContactId());
    existingKeyUDescrIdx.setRequiredDescription(existing.getRequiredDescription());

    CFAccAttachmentByUDescrIdxKey newKeyUDescrIdx = schema.getFactoryAttachment().newUDescrIdxKey();
    newKeyUDescrIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyUDescrIdx.setRequiredContactId(Buff.getRequiredContactId());
    newKeyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription());

    CFAccAttachmentByMimeTypeIdxKey existingKeyMimeTypeIdx = schema.getFactoryAttachment().newMimeTypeIdxKey();
    existingKeyMimeTypeIdx.setOptionalMimeTypeId(existing.getOptionalMimeTypeId());

    CFAccAttachmentByMimeTypeIdxKey newKeyMimeTypeIdx = schema.getFactoryAttachment().newMimeTypeIdxKey();
    newKeyMimeTypeIdx.setOptionalMimeTypeId(Buff.getOptionalMimeTypeId());

    // Check unique indexes

    if (!existingKeyUDescrIdx.equals(newKeyUDescrIdx)) {
        if (dictByUDescrIdx.containsKey(newKeyUDescrIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateAttachment", "AttachmentUDescrIdx", newKeyUDescrIdx);
        }
    }

    // Validate foreign keys

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateAttachment", "Owner", "AttachmentTenant", "Tenant", null);
            }
        }
    }

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableContact().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId(),
                    Buff.getRequiredContactId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateAttachment", "Container", "AttachmentContact", "Contact", null);
            }
        }
    }

    // Update is valid

    SortedMap<CFAccAttachmentPKey, CFAccAttachmentBuff> subdict;

    dictByPKey.remove(pkey);
    dictByPKey.put(pkey, Buff);

    subdict = dictByTenantIdx.get(existingKeyTenantIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByTenantIdx.containsKey(newKeyTenantIdx)) {
        subdict = dictByTenantIdx.get(newKeyTenantIdx);
    } else {
        subdict = new TreeMap<CFAccAttachmentPKey, CFAccAttachmentBuff>();
        dictByTenantIdx.put(newKeyTenantIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByContactIdx.get(existingKeyContactIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByContactIdx.containsKey(newKeyContactIdx)) {
        subdict = dictByContactIdx.get(newKeyContactIdx);
    } else {
        subdict = new TreeMap<CFAccAttachmentPKey, CFAccAttachmentBuff>();
        dictByContactIdx.put(newKeyContactIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUDescrIdx.remove(existingKeyUDescrIdx);
    dictByUDescrIdx.put(newKeyUDescrIdx, Buff);

    subdict = dictByMimeTypeIdx.get(existingKeyMimeTypeIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByMimeTypeIdx.containsKey(newKeyMimeTypeIdx)) {
        subdict = dictByMimeTypeIdx.get(newKeyMimeTypeIdx);
    } else {
        subdict = new TreeMap<CFAccAttachmentPKey, CFAccAttachmentBuff>();
        dictByMimeTypeIdx.put(newKeyMimeTypeIdx, subdict);
    }
    subdict.put(pkey, Buff);

}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamContactTable.java

public void updateContact(CFAccAuthorization Authorization, CFAccContactBuff Buff) {
    CFAccContactPKey pkey = schema.getFactoryContact().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredContactId(Buff.getRequiredContactId());
    CFAccContactBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateContact",
                "Existing record not found", "Contact", pkey);
    }/*  w  ww  .j ava  2s .c  o m*/
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateContact",
                pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAccContactByContTentIdxKey existingKeyContTentIdx = schema.getFactoryContact().newContTentIdxKey();
    existingKeyContTentIdx.setRequiredTenantId(existing.getRequiredTenantId());

    CFAccContactByContTentIdxKey newKeyContTentIdx = schema.getFactoryContact().newContTentIdxKey();
    newKeyContTentIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFAccContactByContListIdxKey existingKeyContListIdx = schema.getFactoryContact().newContListIdxKey();
    existingKeyContListIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyContListIdx.setRequiredContactListId(existing.getRequiredContactListId());

    CFAccContactByContListIdxKey newKeyContListIdx = schema.getFactoryContact().newContListIdxKey();
    newKeyContListIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyContListIdx.setRequiredContactListId(Buff.getRequiredContactListId());

    CFAccContactByFullNameIdxKey existingKeyFullNameIdx = schema.getFactoryContact().newFullNameIdxKey();
    existingKeyFullNameIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyFullNameIdx.setRequiredContactListId(existing.getRequiredContactListId());
    existingKeyFullNameIdx.setRequiredFullName(existing.getRequiredFullName());

    CFAccContactByFullNameIdxKey newKeyFullNameIdx = schema.getFactoryContact().newFullNameIdxKey();
    newKeyFullNameIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyFullNameIdx.setRequiredContactListId(Buff.getRequiredContactListId());
    newKeyFullNameIdx.setRequiredFullName(Buff.getRequiredFullName());

    CFAccContactByTimezoneIdxKey existingKeyTimezoneIdx = schema.getFactoryContact().newTimezoneIdxKey();
    existingKeyTimezoneIdx.setOptionalISOTimezoneId(existing.getOptionalISOTimezoneId());

    CFAccContactByTimezoneIdxKey newKeyTimezoneIdx = schema.getFactoryContact().newTimezoneIdxKey();
    newKeyTimezoneIdx.setOptionalISOTimezoneId(Buff.getOptionalISOTimezoneId());

    // Check unique indexes

    if (!existingKeyFullNameIdx.equals(newKeyFullNameIdx)) {
        if (dictByFullNameIdx.containsKey(newKeyFullNameIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateContact", "ContactUFullNameIdx", newKeyFullNameIdx);
        }
    }

    // Validate foreign keys

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateContact", "Owner", "ContactTenant", "Tenant", null);
            }
        }
    }

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableContactList().readDerivedByIdIdx(Authorization,
                    Buff.getRequiredTenantId(), Buff.getRequiredContactListId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateContact", "Container", "ContactList", "ContactList", null);
            }
        }
    }

    // Update is valid

    SortedMap<CFAccContactPKey, CFAccContactBuff> subdict;

    dictByPKey.remove(pkey);
    dictByPKey.put(pkey, Buff);

    subdict = dictByContTentIdx.get(existingKeyContTentIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByContTentIdx.containsKey(newKeyContTentIdx)) {
        subdict = dictByContTentIdx.get(newKeyContTentIdx);
    } else {
        subdict = new TreeMap<CFAccContactPKey, CFAccContactBuff>();
        dictByContTentIdx.put(newKeyContTentIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByContListIdx.get(existingKeyContListIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByContListIdx.containsKey(newKeyContListIdx)) {
        subdict = dictByContListIdx.get(newKeyContListIdx);
    } else {
        subdict = new TreeMap<CFAccContactPKey, CFAccContactBuff>();
        dictByContListIdx.put(newKeyContListIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByFullNameIdx.remove(existingKeyFullNameIdx);
    dictByFullNameIdx.put(newKeyFullNameIdx, Buff);

    subdict = dictByTimezoneIdx.get(existingKeyTimezoneIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByTimezoneIdx.containsKey(newKeyTimezoneIdx)) {
        subdict = dictByTimezoneIdx.get(newKeyTimezoneIdx);
    } else {
        subdict = new TreeMap<CFAccContactPKey, CFAccContactBuff>();
        dictByTimezoneIdx.put(newKeyTimezoneIdx, subdict);
    }
    subdict.put(pkey, Buff);

}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam.CFAstRamConfigurationFileTable.java

public void updateConfigurationFile(CFAstAuthorization Authorization, CFAstConfigurationFileBuff Buff) {
    CFAstConfigurationFilePKey pkey = schema.getFactoryConfigurationFile().newPKey();
    pkey.setClassCode(Buff.getClassCode());
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredId(Buff.getRequiredId());
    CFAstConfigurationFileBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                "updateConfigurationFile", "Existing record not found", "ConfigurationFile", pkey);
    }/*ww w .  j  a v a2  s  .c o m*/
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                "updateConfigurationFile", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAstConfigurationFileByClusterIdxKey existingKeyClusterIdx = schema.getFactoryConfigurationFile()
            .newClusterIdxKey();
    existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFAstConfigurationFileByClusterIdxKey newKeyClusterIdx = schema.getFactoryConfigurationFile()
            .newClusterIdxKey();
    newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFAstConfigurationFileByHostIdxKey existingKeyHostIdx = schema.getFactoryConfigurationFile()
            .newHostIdxKey();
    existingKeyHostIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyHostIdx.setRequiredHostNodeId(existing.getRequiredHostNodeId());

    CFAstConfigurationFileByHostIdxKey newKeyHostIdx = schema.getFactoryConfigurationFile().newHostIdxKey();
    newKeyHostIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyHostIdx.setRequiredHostNodeId(Buff.getRequiredHostNodeId());

    CFAstConfigurationFileByUNameIdxKey existingKeyUNameIdx = schema.getFactoryConfigurationFile()
            .newUNameIdxKey();
    existingKeyUNameIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyUNameIdx.setRequiredHostNodeId(existing.getRequiredHostNodeId());
    existingKeyUNameIdx.setRequiredFileFullName(existing.getRequiredFileFullName());

    CFAstConfigurationFileByUNameIdxKey newKeyUNameIdx = schema.getFactoryConfigurationFile().newUNameIdxKey();
    newKeyUNameIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyUNameIdx.setRequiredHostNodeId(Buff.getRequiredHostNodeId());
    newKeyUNameIdx.setRequiredFileFullName(Buff.getRequiredFileFullName());

    // Check unique indexes

    if (!existingKeyUNameIdx.equals(newKeyUNameIdx)) {
        if (dictByUNameIdx.containsKey(newKeyUNameIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateConfigurationFile", "ConfigurationFileNameIdx", newKeyUNameIdx);
        }
    }

    // Validate foreign keys

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableCluster().readDerivedByIdIdx(Authorization,
                    Buff.getRequiredClusterId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateConfigurationFile", "Owner", "Cluster", "Cluster", null);
            }
        }
    }

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableHostNode().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId(),
                    Buff.getRequiredHostNodeId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateConfigurationFile", "Container", "HostNode", "HostNode", null);
            }
        }
    }

    // Update is valid

    SortedMap<CFAstConfigurationFilePKey, CFAstConfigurationFileBuff> subdict;

    dictByPKey.remove(pkey);
    dictByPKey.put(pkey, Buff);

    subdict = dictByClusterIdx.get(existingKeyClusterIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByClusterIdx.containsKey(newKeyClusterIdx)) {
        subdict = dictByClusterIdx.get(newKeyClusterIdx);
    } else {
        subdict = new TreeMap<CFAstConfigurationFilePKey, CFAstConfigurationFileBuff>();
        dictByClusterIdx.put(newKeyClusterIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByHostIdx.get(existingKeyHostIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByHostIdx.containsKey(newKeyHostIdx)) {
        subdict = dictByHostIdx.get(newKeyHostIdx);
    } else {
        subdict = new TreeMap<CFAstConfigurationFilePKey, CFAstConfigurationFileBuff>();
        dictByHostIdx.put(newKeyHostIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUNameIdx.remove(existingKeyUNameIdx);
    dictByUNameIdx.put(newKeyUNameIdx, Buff);

}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamAccountConfigTable.java

public void deleteAccountConfig(CFAccAuthorization Authorization, CFAccAccountConfigBuff Buff) {
    final String S_ProcName = "CFAccRamAccountConfigTable.deleteAccountConfig() ";
    CFAccAccountConfigPKey pkey = schema.getFactoryAccountConfig().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    CFAccAccountConfigBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        return;/* ww w. j a  v a  2 s  . c  om*/
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                "deleteAccountConfig", pkey);
    }
    CFAccAccountConfigByTenantIdxKey keyTenantIdx = schema.getFactoryAccountConfig().newTenantIdxKey();
    keyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId());

    CFAccAccountConfigByDefCcyIdxKey keyDefCcyIdx = schema.getFactoryAccountConfig().newDefCcyIdxKey();
    keyDefCcyIdx.setRequiredDefaultCurrencyId(existing.getRequiredDefaultCurrencyId());

    CFAccAccountConfigByCustCtcLstIdxKey keyCustCtcLstIdx = schema.getFactoryAccountConfig()
            .newCustCtcLstIdxKey();
    keyCustCtcLstIdx.setOptionalCustContactListTenantId(existing.getOptionalCustContactListTenantId());
    keyCustCtcLstIdx.setOptionalCustContactListId(existing.getOptionalCustContactListId());

    CFAccAccountConfigByEmpCtcLstIdxKey keyEmpCtcLstIdx = schema.getFactoryAccountConfig().newEmpCtcLstIdxKey();
    keyEmpCtcLstIdx.setOptionalEmpContactListTenantId(existing.getOptionalEmpContactListTenantId());
    keyEmpCtcLstIdx.setOptionalEmpContactListId(existing.getOptionalEmpContactListId());

    CFAccAccountConfigByVendCtcLstIdxKey keyVendCtcLstIdx = schema.getFactoryAccountConfig()
            .newVendCtcLstIdxKey();
    keyVendCtcLstIdx.setOptionalVendContactListTenantId(existing.getOptionalVendContactListTenantId());
    keyVendCtcLstIdx.setOptionalVendContactListId(existing.getOptionalVendContactListId());

    // Validate reverse foreign keys

    // Delete is valid

    SortedMap<CFAccAccountConfigPKey, CFAccAccountConfigBuff> subdict;

    dictByPKey.remove(pkey);

    subdict = dictByTenantIdx.get(keyTenantIdx);
    subdict.remove(pkey);

    subdict = dictByDefCcyIdx.get(keyDefCcyIdx);
    subdict.remove(pkey);

    subdict = dictByCustCtcLstIdx.get(keyCustCtcLstIdx);
    subdict.remove(pkey);

    subdict = dictByEmpCtcLstIdx.get(keyEmpCtcLstIdx);
    subdict.remove(pkey);

    subdict = dictByVendCtcLstIdx.get(keyVendCtcLstIdx);
    subdict.remove(pkey);

}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamTSecGroupMemberTable.java

public void updateTSecGroupMember(CFAccAuthorization Authorization, CFAccTSecGroupMemberBuff Buff) {
    CFAccTSecGroupMemberPKey pkey = schema.getFactoryTSecGroupMember().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredTSecGroupMemberId(Buff.getRequiredTSecGroupMemberId());
    CFAccTSecGroupMemberBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                "updateTSecGroupMember", "Existing record not found", "TSecGroupMember", pkey);
    }//w ww.jav a 2s .  com
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                "updateTSecGroupMember", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAccTSecGroupMemberByTenantIdxKey existingKeyTenantIdx = schema.getFactoryTSecGroupMember()
            .newTenantIdxKey();
    existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId());

    CFAccTSecGroupMemberByTenantIdxKey newKeyTenantIdx = schema.getFactoryTSecGroupMember().newTenantIdxKey();
    newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFAccTSecGroupMemberByGroupIdxKey existingKeyGroupIdx = schema.getFactoryTSecGroupMember().newGroupIdxKey();
    existingKeyGroupIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyGroupIdx.setRequiredTSecGroupId(existing.getRequiredTSecGroupId());

    CFAccTSecGroupMemberByGroupIdxKey newKeyGroupIdx = schema.getFactoryTSecGroupMember().newGroupIdxKey();
    newKeyGroupIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyGroupIdx.setRequiredTSecGroupId(Buff.getRequiredTSecGroupId());

    CFAccTSecGroupMemberByUserIdxKey existingKeyUserIdx = schema.getFactoryTSecGroupMember().newUserIdxKey();
    existingKeyUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId());

    CFAccTSecGroupMemberByUserIdxKey newKeyUserIdx = schema.getFactoryTSecGroupMember().newUserIdxKey();
    newKeyUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());

    CFAccTSecGroupMemberByUUserIdxKey existingKeyUUserIdx = schema.getFactoryTSecGroupMember().newUUserIdxKey();
    existingKeyUUserIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyUUserIdx.setRequiredTSecGroupId(existing.getRequiredTSecGroupId());
    existingKeyUUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId());

    CFAccTSecGroupMemberByUUserIdxKey newKeyUUserIdx = schema.getFactoryTSecGroupMember().newUUserIdxKey();
    newKeyUUserIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyUUserIdx.setRequiredTSecGroupId(Buff.getRequiredTSecGroupId());
    newKeyUUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());

    // Check unique indexes

    if (!existingKeyUUserIdx.equals(newKeyUUserIdx)) {
        if (dictByUUserIdx.containsKey(newKeyUUserIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateTSecGroupMember", "TSecGroupMemberUUserIdx", newKeyUUserIdx);
        }
    }

    // Validate foreign keys

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateTSecGroupMember", "Owner", "TSecGroupMemberTenant", "Tenant", null);
            }
        }
    }

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableTSecGroup().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId(),
                    Buff.getRequiredTSecGroupId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateTSecGroupMember", "Container", "TSecGroupMemberGroup", "TSecGroup", null);
            }
        }
    }

    // Update is valid

    SortedMap<CFAccTSecGroupMemberPKey, CFAccTSecGroupMemberBuff> subdict;

    dictByPKey.remove(pkey);
    dictByPKey.put(pkey, Buff);

    subdict = dictByTenantIdx.get(existingKeyTenantIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByTenantIdx.containsKey(newKeyTenantIdx)) {
        subdict = dictByTenantIdx.get(newKeyTenantIdx);
    } else {
        subdict = new TreeMap<CFAccTSecGroupMemberPKey, CFAccTSecGroupMemberBuff>();
        dictByTenantIdx.put(newKeyTenantIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByGroupIdx.get(existingKeyGroupIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByGroupIdx.containsKey(newKeyGroupIdx)) {
        subdict = dictByGroupIdx.get(newKeyGroupIdx);
    } else {
        subdict = new TreeMap<CFAccTSecGroupMemberPKey, CFAccTSecGroupMemberBuff>();
        dictByGroupIdx.put(newKeyGroupIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByUserIdx.get(existingKeyUserIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByUserIdx.containsKey(newKeyUserIdx)) {
        subdict = dictByUserIdx.get(newKeyUserIdx);
    } else {
        subdict = new TreeMap<CFAccTSecGroupMemberPKey, CFAccTSecGroupMemberBuff>();
        dictByUserIdx.put(newKeyUserIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUUserIdx.remove(existingKeyUUserIdx);
    dictByUUserIdx.put(newKeyUUserIdx, Buff);

}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam.CFAstRamTSecGroupMemberTable.java

public void updateTSecGroupMember(CFAstAuthorization Authorization, CFAstTSecGroupMemberBuff Buff) {
    CFAstTSecGroupMemberPKey pkey = schema.getFactoryTSecGroupMember().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredTSecGroupMemberId(Buff.getRequiredTSecGroupMemberId());
    CFAstTSecGroupMemberBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                "updateTSecGroupMember", "Existing record not found", "TSecGroupMember", pkey);
    }/*  w  w w.  j  a  v  a 2  s .  c  o  m*/
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                "updateTSecGroupMember", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAstTSecGroupMemberByTenantIdxKey existingKeyTenantIdx = schema.getFactoryTSecGroupMember()
            .newTenantIdxKey();
    existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId());

    CFAstTSecGroupMemberByTenantIdxKey newKeyTenantIdx = schema.getFactoryTSecGroupMember().newTenantIdxKey();
    newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFAstTSecGroupMemberByGroupIdxKey existingKeyGroupIdx = schema.getFactoryTSecGroupMember().newGroupIdxKey();
    existingKeyGroupIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyGroupIdx.setRequiredTSecGroupId(existing.getRequiredTSecGroupId());

    CFAstTSecGroupMemberByGroupIdxKey newKeyGroupIdx = schema.getFactoryTSecGroupMember().newGroupIdxKey();
    newKeyGroupIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyGroupIdx.setRequiredTSecGroupId(Buff.getRequiredTSecGroupId());

    CFAstTSecGroupMemberByUserIdxKey existingKeyUserIdx = schema.getFactoryTSecGroupMember().newUserIdxKey();
    existingKeyUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId());

    CFAstTSecGroupMemberByUserIdxKey newKeyUserIdx = schema.getFactoryTSecGroupMember().newUserIdxKey();
    newKeyUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());

    CFAstTSecGroupMemberByUUserIdxKey existingKeyUUserIdx = schema.getFactoryTSecGroupMember().newUUserIdxKey();
    existingKeyUUserIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyUUserIdx.setRequiredTSecGroupId(existing.getRequiredTSecGroupId());
    existingKeyUUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId());

    CFAstTSecGroupMemberByUUserIdxKey newKeyUUserIdx = schema.getFactoryTSecGroupMember().newUUserIdxKey();
    newKeyUUserIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyUUserIdx.setRequiredTSecGroupId(Buff.getRequiredTSecGroupId());
    newKeyUUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());

    // Check unique indexes

    if (!existingKeyUUserIdx.equals(newKeyUUserIdx)) {
        if (dictByUUserIdx.containsKey(newKeyUUserIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateTSecGroupMember", "TSecGroupMemberUUserIdx", newKeyUUserIdx);
        }
    }

    // Validate foreign keys

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateTSecGroupMember", "Owner", "TSecGroupMemberTenant", "Tenant", null);
            }
        }
    }

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableTSecGroup().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId(),
                    Buff.getRequiredTSecGroupId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateTSecGroupMember", "Container", "TSecGroupMemberGroup", "TSecGroup", null);
            }
        }
    }

    // Update is valid

    SortedMap<CFAstTSecGroupMemberPKey, CFAstTSecGroupMemberBuff> subdict;

    dictByPKey.remove(pkey);
    dictByPKey.put(pkey, Buff);

    subdict = dictByTenantIdx.get(existingKeyTenantIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByTenantIdx.containsKey(newKeyTenantIdx)) {
        subdict = dictByTenantIdx.get(newKeyTenantIdx);
    } else {
        subdict = new TreeMap<CFAstTSecGroupMemberPKey, CFAstTSecGroupMemberBuff>();
        dictByTenantIdx.put(newKeyTenantIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByGroupIdx.get(existingKeyGroupIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByGroupIdx.containsKey(newKeyGroupIdx)) {
        subdict = dictByGroupIdx.get(newKeyGroupIdx);
    } else {
        subdict = new TreeMap<CFAstTSecGroupMemberPKey, CFAstTSecGroupMemberBuff>();
        dictByGroupIdx.put(newKeyGroupIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByUserIdx.get(existingKeyUserIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByUserIdx.containsKey(newKeyUserIdx)) {
        subdict = dictByUserIdx.get(newKeyUserIdx);
    } else {
        subdict = new TreeMap<CFAstTSecGroupMemberPKey, CFAstTSecGroupMemberBuff>();
        dictByUserIdx.put(newKeyUserIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUUserIdx.remove(existingKeyUUserIdx);
    dictByUUserIdx.put(newKeyUUserIdx, Buff);

}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamSecGroupMemberTable.java

public void updateSecGroupMember(CFAccAuthorization Authorization, CFAccSecGroupMemberBuff Buff) {
    CFAccSecGroupMemberPKey pkey = schema.getFactorySecGroupMember().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecGroupMemberId(Buff.getRequiredSecGroupMemberId());
    CFAccSecGroupMemberBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                "updateSecGroupMember", "Existing record not found", "SecGroupMember", pkey);
    }//  www.  j av a  2  s.  c  o  m
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                "updateSecGroupMember", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAccSecGroupMemberByClusterIdxKey existingKeyClusterIdx = schema.getFactorySecGroupMember()
            .newClusterIdxKey();
    existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFAccSecGroupMemberByClusterIdxKey newKeyClusterIdx = schema.getFactorySecGroupMember().newClusterIdxKey();
    newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFAccSecGroupMemberByGroupIdxKey existingKeyGroupIdx = schema.getFactorySecGroupMember().newGroupIdxKey();
    existingKeyGroupIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());

    CFAccSecGroupMemberByGroupIdxKey newKeyGroupIdx = schema.getFactorySecGroupMember().newGroupIdxKey();
    newKeyGroupIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());

    CFAccSecGroupMemberByUserIdxKey existingKeyUserIdx = schema.getFactorySecGroupMember().newUserIdxKey();
    existingKeyUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId());

    CFAccSecGroupMemberByUserIdxKey newKeyUserIdx = schema.getFactorySecGroupMember().newUserIdxKey();
    newKeyUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());

    CFAccSecGroupMemberByUUserIdxKey existingKeyUUserIdx = schema.getFactorySecGroupMember().newUUserIdxKey();
    existingKeyUUserIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyUUserIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());
    existingKeyUUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId());

    CFAccSecGroupMemberByUUserIdxKey newKeyUUserIdx = schema.getFactorySecGroupMember().newUUserIdxKey();
    newKeyUUserIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyUUserIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());
    newKeyUUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());

    // Check unique indexes

    if (!existingKeyUUserIdx.equals(newKeyUUserIdx)) {
        if (dictByUUserIdx.containsKey(newKeyUUserIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateSecGroupMember", "SecGroupMemberUUserIdx", newKeyUUserIdx);
        }
    }

    // Validate foreign keys

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableCluster().readDerivedByIdIdx(Authorization,
                    Buff.getRequiredClusterId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateSecGroupMember", "Owner", "SecGroupMemberCluster", "Cluster", null);
            }
        }
    }

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableSecGroup().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId(),
                    Buff.getRequiredSecGroupId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateSecGroupMember", "Container", "SecGroupMemberGroup", "SecGroup", null);
            }
        }
    }

    // Update is valid

    SortedMap<CFAccSecGroupMemberPKey, CFAccSecGroupMemberBuff> subdict;

    dictByPKey.remove(pkey);
    dictByPKey.put(pkey, Buff);

    subdict = dictByClusterIdx.get(existingKeyClusterIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByClusterIdx.containsKey(newKeyClusterIdx)) {
        subdict = dictByClusterIdx.get(newKeyClusterIdx);
    } else {
        subdict = new TreeMap<CFAccSecGroupMemberPKey, CFAccSecGroupMemberBuff>();
        dictByClusterIdx.put(newKeyClusterIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByGroupIdx.get(existingKeyGroupIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByGroupIdx.containsKey(newKeyGroupIdx)) {
        subdict = dictByGroupIdx.get(newKeyGroupIdx);
    } else {
        subdict = new TreeMap<CFAccSecGroupMemberPKey, CFAccSecGroupMemberBuff>();
        dictByGroupIdx.put(newKeyGroupIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByUserIdx.get(existingKeyUserIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByUserIdx.containsKey(newKeyUserIdx)) {
        subdict = dictByUserIdx.get(newKeyUserIdx);
    } else {
        subdict = new TreeMap<CFAccSecGroupMemberPKey, CFAccSecGroupMemberBuff>();
        dictByUserIdx.put(newKeyUserIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUUserIdx.remove(existingKeyUUserIdx);
    dictByUUserIdx.put(newKeyUUserIdx, Buff);

}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam.CFAstRamSecGroupMemberTable.java

public void updateSecGroupMember(CFAstAuthorization Authorization, CFAstSecGroupMemberBuff Buff) {
    CFAstSecGroupMemberPKey pkey = schema.getFactorySecGroupMember().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecGroupMemberId(Buff.getRequiredSecGroupMemberId());
    CFAstSecGroupMemberBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                "updateSecGroupMember", "Existing record not found", "SecGroupMember", pkey);
    }//from www. j ava  2  s.c o  m
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                "updateSecGroupMember", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAstSecGroupMemberByClusterIdxKey existingKeyClusterIdx = schema.getFactorySecGroupMember()
            .newClusterIdxKey();
    existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFAstSecGroupMemberByClusterIdxKey newKeyClusterIdx = schema.getFactorySecGroupMember().newClusterIdxKey();
    newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFAstSecGroupMemberByGroupIdxKey existingKeyGroupIdx = schema.getFactorySecGroupMember().newGroupIdxKey();
    existingKeyGroupIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());

    CFAstSecGroupMemberByGroupIdxKey newKeyGroupIdx = schema.getFactorySecGroupMember().newGroupIdxKey();
    newKeyGroupIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());

    CFAstSecGroupMemberByUserIdxKey existingKeyUserIdx = schema.getFactorySecGroupMember().newUserIdxKey();
    existingKeyUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId());

    CFAstSecGroupMemberByUserIdxKey newKeyUserIdx = schema.getFactorySecGroupMember().newUserIdxKey();
    newKeyUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());

    CFAstSecGroupMemberByUUserIdxKey existingKeyUUserIdx = schema.getFactorySecGroupMember().newUUserIdxKey();
    existingKeyUUserIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyUUserIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());
    existingKeyUUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId());

    CFAstSecGroupMemberByUUserIdxKey newKeyUUserIdx = schema.getFactorySecGroupMember().newUUserIdxKey();
    newKeyUUserIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyUUserIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());
    newKeyUUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());

    // Check unique indexes

    if (!existingKeyUUserIdx.equals(newKeyUUserIdx)) {
        if (dictByUUserIdx.containsKey(newKeyUUserIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateSecGroupMember", "SecGroupMemberUUserIdx", newKeyUUserIdx);
        }
    }

    // Validate foreign keys

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableCluster().readDerivedByIdIdx(Authorization,
                    Buff.getRequiredClusterId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateSecGroupMember", "Owner", "SecGroupMemberCluster", "Cluster", null);
            }
        }
    }

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableSecGroup().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId(),
                    Buff.getRequiredSecGroupId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateSecGroupMember", "Container", "SecGroupMemberGroup", "SecGroup", null);
            }
        }
    }

    // Update is valid

    SortedMap<CFAstSecGroupMemberPKey, CFAstSecGroupMemberBuff> subdict;

    dictByPKey.remove(pkey);
    dictByPKey.put(pkey, Buff);

    subdict = dictByClusterIdx.get(existingKeyClusterIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByClusterIdx.containsKey(newKeyClusterIdx)) {
        subdict = dictByClusterIdx.get(newKeyClusterIdx);
    } else {
        subdict = new TreeMap<CFAstSecGroupMemberPKey, CFAstSecGroupMemberBuff>();
        dictByClusterIdx.put(newKeyClusterIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByGroupIdx.get(existingKeyGroupIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByGroupIdx.containsKey(newKeyGroupIdx)) {
        subdict = dictByGroupIdx.get(newKeyGroupIdx);
    } else {
        subdict = new TreeMap<CFAstSecGroupMemberPKey, CFAstSecGroupMemberBuff>();
        dictByGroupIdx.put(newKeyGroupIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByUserIdx.get(existingKeyUserIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByUserIdx.containsKey(newKeyUserIdx)) {
        subdict = dictByUserIdx.get(newKeyUserIdx);
    } else {
        subdict = new TreeMap<CFAstSecGroupMemberPKey, CFAstSecGroupMemberBuff>();
        dictByUserIdx.put(newKeyUserIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUUserIdx.remove(existingKeyUUserIdx);
    dictByUUserIdx.put(newKeyUUserIdx, Buff);

}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamAccountTable.java

public void updateAccount(CFAccAuthorization Authorization, CFAccAccountBuff Buff) {
    CFAccAccountPKey pkey = schema.getFactoryAccount().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredId(Buff.getRequiredId());
    CFAccAccountBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateAccount",
                "Existing record not found", "Account", pkey);
    }/*from  w w w  .  j ava  2 s  .  c  o  m*/
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateAccount",
                pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAccAccountByUCodeIdxKey existingKeyUCodeIdx = schema.getFactoryAccount().newUCodeIdxKey();
    existingKeyUCodeIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyUCodeIdx.setRequiredAccountCode(existing.getRequiredAccountCode());

    CFAccAccountByUCodeIdxKey newKeyUCodeIdx = schema.getFactoryAccount().newUCodeIdxKey();
    newKeyUCodeIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyUCodeIdx.setRequiredAccountCode(Buff.getRequiredAccountCode());

    CFAccAccountByTenantIdxKey existingKeyTenantIdx = schema.getFactoryAccount().newTenantIdxKey();
    existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId());

    CFAccAccountByTenantIdxKey newKeyTenantIdx = schema.getFactoryAccount().newTenantIdxKey();
    newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFAccAccountByRollupAcctIdxKey existingKeyRollupAcctIdx = schema.getFactoryAccount().newRollupAcctIdxKey();
    existingKeyRollupAcctIdx.setOptionalRollupTenantId(existing.getOptionalRollupTenantId());
    existingKeyRollupAcctIdx.setOptionalRollupAccountId(existing.getOptionalRollupAccountId());

    CFAccAccountByRollupAcctIdxKey newKeyRollupAcctIdx = schema.getFactoryAccount().newRollupAcctIdxKey();
    newKeyRollupAcctIdx.setOptionalRollupTenantId(Buff.getOptionalRollupTenantId());
    newKeyRollupAcctIdx.setOptionalRollupAccountId(Buff.getOptionalRollupAccountId());

    CFAccAccountByCcyIdxKey existingKeyCcyIdx = schema.getFactoryAccount().newCcyIdxKey();
    existingKeyCcyIdx.setRequiredCurrencyId(existing.getRequiredCurrencyId());

    CFAccAccountByCcyIdxKey newKeyCcyIdx = schema.getFactoryAccount().newCcyIdxKey();
    newKeyCcyIdx.setRequiredCurrencyId(Buff.getRequiredCurrencyId());

    // Check unique indexes

    if (!existingKeyUCodeIdx.equals(newKeyUCodeIdx)) {
        if (dictByUCodeIdx.containsKey(newKeyUCodeIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateAccount", "AccountUCodeIdx", newKeyUCodeIdx);
        }
    }

    // Validate foreign keys

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateAccount", "Container", "Tenant", "Tenant", null);
            }
        }
    }

    // Update is valid

    SortedMap<CFAccAccountPKey, CFAccAccountBuff> subdict;

    dictByPKey.remove(pkey);
    dictByPKey.put(pkey, Buff);

    dictByUCodeIdx.remove(existingKeyUCodeIdx);
    dictByUCodeIdx.put(newKeyUCodeIdx, Buff);

    subdict = dictByTenantIdx.get(existingKeyTenantIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByTenantIdx.containsKey(newKeyTenantIdx)) {
        subdict = dictByTenantIdx.get(newKeyTenantIdx);
    } else {
        subdict = new TreeMap<CFAccAccountPKey, CFAccAccountBuff>();
        dictByTenantIdx.put(newKeyTenantIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByRollupAcctIdx.get(existingKeyRollupAcctIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByRollupAcctIdx.containsKey(newKeyRollupAcctIdx)) {
        subdict = dictByRollupAcctIdx.get(newKeyRollupAcctIdx);
    } else {
        subdict = new TreeMap<CFAccAccountPKey, CFAccAccountBuff>();
        dictByRollupAcctIdx.put(newKeyRollupAcctIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByCcyIdx.get(existingKeyCcyIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByCcyIdx.containsKey(newKeyCcyIdx)) {
        subdict = dictByCcyIdx.get(newKeyCcyIdx);
    } else {
        subdict = new TreeMap<CFAccAccountPKey, CFAccAccountBuff>();
        dictByCcyIdx.put(newKeyCcyIdx, subdict);
    }
    subdict.put(pkey, Buff);

}