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.CFAccRamContactTagTable.java

public void updateContactTag(CFAccAuthorization Authorization, CFAccContactTagBuff Buff) {
    CFAccContactTagPKey pkey = schema.getFactoryContactTag().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredContactId(Buff.getRequiredContactId());
    pkey.setRequiredTagId(Buff.getRequiredTagId());
    CFAccContactTagBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateContactTag",
                "Existing record not found", "ContactTag", pkey);
    }//  ww  w.jav a2s . c o m
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateContactTag",
                pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAccContactTagByTenantIdxKey existingKeyTenantIdx = schema.getFactoryContactTag().newTenantIdxKey();
    existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId());

    CFAccContactTagByTenantIdxKey newKeyTenantIdx = schema.getFactoryContactTag().newTenantIdxKey();
    newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFAccContactTagByContactIdxKey existingKeyContactIdx = schema.getFactoryContactTag().newContactIdxKey();
    existingKeyContactIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyContactIdx.setRequiredContactId(existing.getRequiredContactId());

    CFAccContactTagByContactIdxKey newKeyContactIdx = schema.getFactoryContactTag().newContactIdxKey();
    newKeyContactIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyContactIdx.setRequiredContactId(Buff.getRequiredContactId());

    CFAccContactTagByTagIdxKey existingKeyTagIdx = schema.getFactoryContactTag().newTagIdxKey();
    existingKeyTagIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyTagIdx.setRequiredTagId(existing.getRequiredTagId());

    CFAccContactTagByTagIdxKey newKeyTagIdx = schema.getFactoryContactTag().newTagIdxKey();
    newKeyTagIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyTagIdx.setRequiredTagId(Buff.getRequiredTagId());

    // Check unique indexes

    // Validate foreign keys

    {
        boolean allNull = true;

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

    {
        boolean allNull = true;

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

    // Update is valid

    SortedMap<CFAccContactTagPKey, CFAccContactTagBuff> 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<CFAccContactTagPKey, CFAccContactTagBuff>();
        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<CFAccContactTagPKey, CFAccContactTagBuff>();
        dictByContactIdx.put(newKeyContactIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByTagIdx.get(existingKeyTagIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByTagIdx.containsKey(newKeyTagIdx)) {
        subdict = dictByTagIdx.get(newKeyTagIdx);
    } else {
        subdict = new TreeMap<CFAccContactTagPKey, CFAccContactTagBuff>();
        dictByTagIdx.put(newKeyTagIdx, subdict);
    }
    subdict.put(pkey, Buff);

}

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

public void deleteService(CFAccAuthorization Authorization, CFAccServiceBuff Buff) {
    final String S_ProcName = "CFAccRamServiceTable.deleteService() ";
    CFAccServicePKey pkey = schema.getFactoryService().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredServiceId(Buff.getRequiredServiceId());
    CFAccServiceBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        return;//from w w w  .  j a  va2s  .  co m
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteService",
                pkey);
    }
    CFAccServiceByClusterIdxKey keyClusterIdx = schema.getFactoryService().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFAccServiceByHostIdxKey keyHostIdx = schema.getFactoryService().newHostIdxKey();
    keyHostIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyHostIdx.setRequiredHostNodeId(existing.getRequiredHostNodeId());

    CFAccServiceByTypeIdxKey keyTypeIdx = schema.getFactoryService().newTypeIdxKey();
    keyTypeIdx.setRequiredServiceTypeId(existing.getRequiredServiceTypeId());

    CFAccServiceByUTypeIdxKey keyUTypeIdx = schema.getFactoryService().newUTypeIdxKey();
    keyUTypeIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyUTypeIdx.setRequiredHostNodeId(existing.getRequiredHostNodeId());
    keyUTypeIdx.setRequiredServiceTypeId(existing.getRequiredServiceTypeId());

    CFAccServiceByUHostPortIdxKey keyUHostPortIdx = schema.getFactoryService().newUHostPortIdxKey();
    keyUHostPortIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyUHostPortIdx.setRequiredHostNodeId(existing.getRequiredHostNodeId());
    keyUHostPortIdx.setRequiredHostPort(existing.getRequiredHostPort());

    // Validate reverse foreign keys

    // Delete is valid

    SortedMap<CFAccServicePKey, CFAccServiceBuff> subdict;

    dictByPKey.remove(pkey);

    subdict = dictByClusterIdx.get(keyClusterIdx);
    subdict.remove(pkey);

    subdict = dictByHostIdx.get(keyHostIdx);
    subdict.remove(pkey);

    subdict = dictByTypeIdx.get(keyTypeIdx);
    subdict.remove(pkey);

    dictByUTypeIdx.remove(keyUTypeIdx);

    dictByUHostPortIdx.remove(keyUHostPortIdx);

}

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

public void deleteService(CFAstAuthorization Authorization, CFAstServiceBuff Buff) {
    final String S_ProcName = "CFAstRamServiceTable.deleteService() ";
    CFAstServicePKey pkey = schema.getFactoryService().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredServiceId(Buff.getRequiredServiceId());
    CFAstServiceBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        return;//from   w  w w . j  a  va  2  s.c om
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteService",
                pkey);
    }
    CFAstServiceByClusterIdxKey keyClusterIdx = schema.getFactoryService().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFAstServiceByHostIdxKey keyHostIdx = schema.getFactoryService().newHostIdxKey();
    keyHostIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyHostIdx.setRequiredHostNodeId(existing.getRequiredHostNodeId());

    CFAstServiceByTypeIdxKey keyTypeIdx = schema.getFactoryService().newTypeIdxKey();
    keyTypeIdx.setRequiredServiceTypeId(existing.getRequiredServiceTypeId());

    CFAstServiceByUTypeIdxKey keyUTypeIdx = schema.getFactoryService().newUTypeIdxKey();
    keyUTypeIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyUTypeIdx.setRequiredHostNodeId(existing.getRequiredHostNodeId());
    keyUTypeIdx.setRequiredServiceTypeId(existing.getRequiredServiceTypeId());

    CFAstServiceByUHostPortIdxKey keyUHostPortIdx = schema.getFactoryService().newUHostPortIdxKey();
    keyUHostPortIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyUHostPortIdx.setRequiredHostNodeId(existing.getRequiredHostNodeId());
    keyUHostPortIdx.setRequiredHostPort(existing.getRequiredHostPort());

    // Validate reverse foreign keys

    // Delete is valid

    SortedMap<CFAstServicePKey, CFAstServiceBuff> subdict;

    dictByPKey.remove(pkey);

    subdict = dictByClusterIdx.get(keyClusterIdx);
    subdict.remove(pkey);

    subdict = dictByHostIdx.get(keyHostIdx);
    subdict.remove(pkey);

    subdict = dictByTypeIdx.get(keyTypeIdx);
    subdict.remove(pkey);

    dictByUTypeIdx.remove(keyUTypeIdx);

    dictByUHostPortIdx.remove(keyUHostPortIdx);

}

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

public void updateAccountContact(CFAccAuthorization Authorization, CFAccAccountContactBuff Buff) {
    CFAccAccountContactPKey pkey = schema.getFactoryAccountContact().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredAccountId(Buff.getRequiredAccountId());
    CFAccAccountContactBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                "updateAccountContact", "Existing record not found", "AccountContact", pkey);
    }//from  w  w w  .j a v a  2 s.  c om
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                "updateAccountContact", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAccAccountContactByTenantIdxKey existingKeyTenantIdx = schema.getFactoryAccountContact()
            .newTenantIdxKey();
    existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId());

    CFAccAccountContactByTenantIdxKey newKeyTenantIdx = schema.getFactoryAccountContact().newTenantIdxKey();
    newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFAccAccountContactByCtctLstIdxKey existingKeyCtctLstIdx = schema.getFactoryAccountContact()
            .newCtctLstIdxKey();
    existingKeyCtctLstIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyCtctLstIdx.setRequiredContactListId(existing.getRequiredContactListId());

    CFAccAccountContactByCtctLstIdxKey newKeyCtctLstIdx = schema.getFactoryAccountContact().newCtctLstIdxKey();
    newKeyCtctLstIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyCtctLstIdx.setRequiredContactListId(Buff.getRequiredContactListId());

    CFAccAccountContactByCtctIdxKey existingKeyCtctIdx = schema.getFactoryAccountContact().newCtctIdxKey();
    existingKeyCtctIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyCtctIdx.setRequiredContactId(existing.getRequiredContactId());

    CFAccAccountContactByCtctIdxKey newKeyCtctIdx = schema.getFactoryAccountContact().newCtctIdxKey();
    newKeyCtctIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyCtctIdx.setRequiredContactId(Buff.getRequiredContactId());

    // Check unique indexes

    // Validate foreign keys

    {
        boolean allNull = true;

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

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableAccount().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId(),
                    Buff.getRequiredAccountId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateAccountContact", "Container", "Account", "Account", null);
            }
        }
    }

    // Update is valid

    SortedMap<CFAccAccountContactPKey, CFAccAccountContactBuff> 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<CFAccAccountContactPKey, CFAccAccountContactBuff>();
        dictByTenantIdx.put(newKeyTenantIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByCtctLstIdx.get(existingKeyCtctLstIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByCtctLstIdx.containsKey(newKeyCtctLstIdx)) {
        subdict = dictByCtctLstIdx.get(newKeyCtctLstIdx);
    } else {
        subdict = new TreeMap<CFAccAccountContactPKey, CFAccAccountContactBuff>();
        dictByCtctLstIdx.put(newKeyCtctLstIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByCtctIdx.get(existingKeyCtctIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByCtctIdx.containsKey(newKeyCtctIdx)) {
        subdict = dictByCtctIdx.get(newKeyCtctIdx);
    } else {
        subdict = new TreeMap<CFAccAccountContactPKey, CFAccAccountContactBuff>();
        dictByCtctIdx.put(newKeyCtctIdx, subdict);
    }
    subdict.put(pkey, Buff);

}

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

public void updateAttachmentTag(CFAccAuthorization Authorization, CFAccAttachmentTagBuff Buff) {
    CFAccAttachmentTagPKey pkey = schema.getFactoryAttachmentTag().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredAttachmentId(Buff.getRequiredAttachmentId());
    pkey.setRequiredTagId(Buff.getRequiredTagId());
    CFAccAttachmentTagBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                "updateAttachmentTag", "Existing record not found", "AttachmentTag", pkey);
    }/*from   ww w.ja v  a2  s .  c  o m*/
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                "updateAttachmentTag", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAccAttachmentTagByTenantIdxKey existingKeyTenantIdx = schema.getFactoryAttachmentTag().newTenantIdxKey();
    existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId());

    CFAccAttachmentTagByTenantIdxKey newKeyTenantIdx = schema.getFactoryAttachmentTag().newTenantIdxKey();
    newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFAccAttachmentTagByAttIdxKey existingKeyAttIdx = schema.getFactoryAttachmentTag().newAttIdxKey();
    existingKeyAttIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyAttIdx.setRequiredAttachmentId(existing.getRequiredAttachmentId());

    CFAccAttachmentTagByAttIdxKey newKeyAttIdx = schema.getFactoryAttachmentTag().newAttIdxKey();
    newKeyAttIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyAttIdx.setRequiredAttachmentId(Buff.getRequiredAttachmentId());

    CFAccAttachmentTagByTagIdxKey existingKeyTagIdx = schema.getFactoryAttachmentTag().newTagIdxKey();
    existingKeyTagIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyTagIdx.setRequiredTagId(existing.getRequiredTagId());

    CFAccAttachmentTagByTagIdxKey newKeyTagIdx = schema.getFactoryAttachmentTag().newTagIdxKey();
    newKeyTagIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyTagIdx.setRequiredTagId(Buff.getRequiredTagId());

    // Check unique indexes

    // Validate foreign keys

    {
        boolean allNull = true;

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

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableAttachment().readDerivedByIdIdx(Authorization,
                    Buff.getRequiredTenantId(), Buff.getRequiredAttachmentId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateAttachmentTag", "Container", "AttachmentTagAttachment", "Attachment", null);
            }
        }
    }

    // Update is valid

    SortedMap<CFAccAttachmentTagPKey, CFAccAttachmentTagBuff> 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<CFAccAttachmentTagPKey, CFAccAttachmentTagBuff>();
        dictByTenantIdx.put(newKeyTenantIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByAttIdx.get(existingKeyAttIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByAttIdx.containsKey(newKeyAttIdx)) {
        subdict = dictByAttIdx.get(newKeyAttIdx);
    } else {
        subdict = new TreeMap<CFAccAttachmentTagPKey, CFAccAttachmentTagBuff>();
        dictByAttIdx.put(newKeyAttIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByTagIdx.get(existingKeyTagIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByTagIdx.containsKey(newKeyTagIdx)) {
        subdict = dictByTagIdx.get(newKeyTagIdx);
    } else {
        subdict = new TreeMap<CFAccAttachmentTagPKey, CFAccAttachmentTagBuff>();
        dictByTagIdx.put(newKeyTagIdx, subdict);
    }
    subdict.put(pkey, Buff);

}

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

public void updatePhone(CFAccAuthorization Authorization, CFAccPhoneBuff Buff) {
    CFAccPhonePKey pkey = schema.getFactoryPhone().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredPhoneId(Buff.getRequiredPhoneId());
    CFAccPhoneBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updatePhone",
                "Existing record not found", "Phone", pkey);
    }//from   w w  w  .  ja v  a2  s  .  c o  m
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updatePhone", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAccPhoneByTenantIdxKey existingKeyTenantIdx = schema.getFactoryPhone().newTenantIdxKey();
    existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId());

    CFAccPhoneByTenantIdxKey newKeyTenantIdx = schema.getFactoryPhone().newTenantIdxKey();
    newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFAccPhoneByContactIdxKey existingKeyContactIdx = schema.getFactoryPhone().newContactIdxKey();
    existingKeyContactIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyContactIdx.setRequiredContactId(existing.getRequiredContactId());

    CFAccPhoneByContactIdxKey newKeyContactIdx = schema.getFactoryPhone().newContactIdxKey();
    newKeyContactIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyContactIdx.setRequiredContactId(Buff.getRequiredContactId());

    CFAccPhoneByUDescrIdxKey existingKeyUDescrIdx = schema.getFactoryPhone().newUDescrIdxKey();
    existingKeyUDescrIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyUDescrIdx.setRequiredContactId(existing.getRequiredContactId());
    existingKeyUDescrIdx.setRequiredDescription(existing.getRequiredDescription());

    CFAccPhoneByUDescrIdxKey newKeyUDescrIdx = schema.getFactoryPhone().newUDescrIdxKey();
    newKeyUDescrIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyUDescrIdx.setRequiredContactId(Buff.getRequiredContactId());
    newKeyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription());

    CFAccPhoneByUPhoneNumberIdxKey existingKeyUPhoneNumberIdx = schema.getFactoryPhone()
            .newUPhoneNumberIdxKey();
    existingKeyUPhoneNumberIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyUPhoneNumberIdx.setRequiredContactId(existing.getRequiredContactId());
    existingKeyUPhoneNumberIdx.setRequiredPhoneNumber(existing.getRequiredPhoneNumber());

    CFAccPhoneByUPhoneNumberIdxKey newKeyUPhoneNumberIdx = schema.getFactoryPhone().newUPhoneNumberIdxKey();
    newKeyUPhoneNumberIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyUPhoneNumberIdx.setRequiredContactId(Buff.getRequiredContactId());
    newKeyUPhoneNumberIdx.setRequiredPhoneNumber(Buff.getRequiredPhoneNumber());

    // Check unique indexes

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

    if (!existingKeyUPhoneNumberIdx.equals(newKeyUPhoneNumberIdx)) {
        if (dictByUPhoneNumberIdx.containsKey(newKeyUPhoneNumberIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "updatePhone",
                    "PhoneUPhoneNumberIdx", newKeyUPhoneNumberIdx);
        }
    }

    // Validate foreign keys

    {
        boolean allNull = true;

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

    {
        boolean allNull = true;

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

    // Update is valid

    SortedMap<CFAccPhonePKey, CFAccPhoneBuff> 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<CFAccPhonePKey, CFAccPhoneBuff>();
        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<CFAccPhonePKey, CFAccPhoneBuff>();
        dictByContactIdx.put(newKeyContactIdx, subdict);
    }
    subdict.put(pkey, Buff);

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

    dictByUPhoneNumberIdx.remove(existingKeyUPhoneNumberIdx);
    dictByUPhoneNumberIdx.put(newKeyUPhoneNumberIdx, Buff);

}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrmRam.CFCrmRamSecGroupFormTable.java

public void deleteSecGroupForm(CFCrmAuthorization Authorization, CFCrmSecGroupFormBuff Buff) {
    final String S_ProcName = "CFCrmRamSecGroupFormTable.deleteSecGroupForm() ";
    CFCrmSecGroupFormPKey pkey = schema.getFactorySecGroupForm().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecGroupFormId(Buff.getRequiredSecGroupFormId());
    CFCrmSecGroupFormBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        return;/*from w  w w.  ja  v  a2s  .  c o m*/
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteSecGroupForm",
                pkey);
    }
    CFCrmSecGroupFormByClusterIdxKey keyClusterIdx = schema.getFactorySecGroupForm().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFCrmSecGroupFormByGroupIdxKey keyGroupIdx = schema.getFactorySecGroupForm().newGroupIdxKey();
    keyGroupIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());

    CFCrmSecGroupFormByAppIdxKey keyAppIdx = schema.getFactorySecGroupForm().newAppIdxKey();
    keyAppIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyAppIdx.setRequiredSecAppId(existing.getRequiredSecAppId());

    CFCrmSecGroupFormByFormIdxKey keyFormIdx = schema.getFactorySecGroupForm().newFormIdxKey();
    keyFormIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyFormIdx.setRequiredSecFormId(existing.getRequiredSecFormId());

    CFCrmSecGroupFormByUFormIdxKey keyUFormIdx = schema.getFactorySecGroupForm().newUFormIdxKey();
    keyUFormIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyUFormIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());
    keyUFormIdx.setRequiredSecFormId(existing.getRequiredSecFormId());

    // Validate reverse foreign keys

    // Delete is valid

    SortedMap<CFCrmSecGroupFormPKey, CFCrmSecGroupFormBuff> subdict;

    dictByPKey.remove(pkey);

    subdict = dictByClusterIdx.get(keyClusterIdx);
    subdict.remove(pkey);

    subdict = dictByGroupIdx.get(keyGroupIdx);
    subdict.remove(pkey);

    subdict = dictByAppIdx.get(keyAppIdx);
    subdict.remove(pkey);

    subdict = dictByFormIdx.get(keyFormIdx);
    subdict.remove(pkey);

    dictByUFormIdx.remove(keyUFormIdx);

}

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

public void updateAddress(CFAccAuthorization Authorization, CFAccAddressBuff Buff) {
    CFAccAddressPKey pkey = schema.getFactoryAddress().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredAddressId(Buff.getRequiredAddressId());
    CFAccAddressBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateAddress",
                "Existing record not found", "Address", pkey);
    }/*from  ww w .  j av a  2  s  .c o m*/
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateAddress",
                pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAccAddressByTenantIdxKey existingKeyTenantIdx = schema.getFactoryAddress().newTenantIdxKey();
    existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId());

    CFAccAddressByTenantIdxKey newKeyTenantIdx = schema.getFactoryAddress().newTenantIdxKey();
    newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFAccAddressByContactIdxKey existingKeyContactIdx = schema.getFactoryAddress().newContactIdxKey();
    existingKeyContactIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyContactIdx.setRequiredContactId(existing.getRequiredContactId());

    CFAccAddressByContactIdxKey newKeyContactIdx = schema.getFactoryAddress().newContactIdxKey();
    newKeyContactIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyContactIdx.setRequiredContactId(Buff.getRequiredContactId());

    CFAccAddressByUDescrIdxKey existingKeyUDescrIdx = schema.getFactoryAddress().newUDescrIdxKey();
    existingKeyUDescrIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyUDescrIdx.setRequiredContactId(existing.getRequiredContactId());
    existingKeyUDescrIdx.setRequiredDescription(existing.getRequiredDescription());

    CFAccAddressByUDescrIdxKey newKeyUDescrIdx = schema.getFactoryAddress().newUDescrIdxKey();
    newKeyUDescrIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyUDescrIdx.setRequiredContactId(Buff.getRequiredContactId());
    newKeyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription());

    CFAccAddressByCountryIdxKey existingKeyCountryIdx = schema.getFactoryAddress().newCountryIdxKey();
    existingKeyCountryIdx.setOptionalCountryId(existing.getOptionalCountryId());

    CFAccAddressByCountryIdxKey newKeyCountryIdx = schema.getFactoryAddress().newCountryIdxKey();
    newKeyCountryIdx.setOptionalCountryId(Buff.getOptionalCountryId());

    // Check unique indexes

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

    // Validate foreign keys

    {
        boolean allNull = true;

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

    {
        boolean allNull = true;

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

    // Update is valid

    SortedMap<CFAccAddressPKey, CFAccAddressBuff> 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<CFAccAddressPKey, CFAccAddressBuff>();
        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<CFAccAddressPKey, CFAccAddressBuff>();
        dictByContactIdx.put(newKeyContactIdx, subdict);
    }
    subdict.put(pkey, Buff);

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

    subdict = dictByCountryIdx.get(existingKeyCountryIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByCountryIdx.containsKey(newKeyCountryIdx)) {
        subdict = dictByCountryIdx.get(newKeyCountryIdx);
    } else {
        subdict = new TreeMap<CFAccAddressPKey, CFAccAddressBuff>();
        dictByCountryIdx.put(newKeyCountryIdx, subdict);
    }
    subdict.put(pkey, Buff);

}

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

public void deleteSecGroupForm(CFAccAuthorization Authorization, CFAccSecGroupFormBuff Buff) {
    final String S_ProcName = "CFAccRamSecGroupFormTable.deleteSecGroupForm() ";
    CFAccSecGroupFormPKey pkey = schema.getFactorySecGroupForm().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecGroupFormId(Buff.getRequiredSecGroupFormId());
    CFAccSecGroupFormBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        return;/*from w  w  w  .j  av a2  s  .c o  m*/
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteSecGroupForm",
                pkey);
    }
    CFAccSecGroupFormByClusterIdxKey keyClusterIdx = schema.getFactorySecGroupForm().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFAccSecGroupFormByGroupIdxKey keyGroupIdx = schema.getFactorySecGroupForm().newGroupIdxKey();
    keyGroupIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());

    CFAccSecGroupFormByAppIdxKey keyAppIdx = schema.getFactorySecGroupForm().newAppIdxKey();
    keyAppIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyAppIdx.setRequiredSecAppId(existing.getRequiredSecAppId());

    CFAccSecGroupFormByFormIdxKey keyFormIdx = schema.getFactorySecGroupForm().newFormIdxKey();
    keyFormIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyFormIdx.setRequiredSecFormId(existing.getRequiredSecFormId());

    CFAccSecGroupFormByUFormIdxKey keyUFormIdx = schema.getFactorySecGroupForm().newUFormIdxKey();
    keyUFormIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyUFormIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());
    keyUFormIdx.setRequiredSecFormId(existing.getRequiredSecFormId());

    // Validate reverse foreign keys

    // Delete is valid

    SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff> subdict;

    dictByPKey.remove(pkey);

    subdict = dictByClusterIdx.get(keyClusterIdx);
    subdict.remove(pkey);

    subdict = dictByGroupIdx.get(keyGroupIdx);
    subdict.remove(pkey);

    subdict = dictByAppIdx.get(keyAppIdx);
    subdict.remove(pkey);

    subdict = dictByFormIdx.get(keyFormIdx);
    subdict.remove(pkey);

    dictByUFormIdx.remove(keyUFormIdx);

}

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

public void deleteSecGroupForm(CFAstAuthorization Authorization, CFAstSecGroupFormBuff Buff) {
    final String S_ProcName = "CFAstRamSecGroupFormTable.deleteSecGroupForm() ";
    CFAstSecGroupFormPKey pkey = schema.getFactorySecGroupForm().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecGroupFormId(Buff.getRequiredSecGroupFormId());
    CFAstSecGroupFormBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        return;//from   w  w  w. j av a 2s  . c  o  m
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteSecGroupForm",
                pkey);
    }
    CFAstSecGroupFormByClusterIdxKey keyClusterIdx = schema.getFactorySecGroupForm().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFAstSecGroupFormByGroupIdxKey keyGroupIdx = schema.getFactorySecGroupForm().newGroupIdxKey();
    keyGroupIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());

    CFAstSecGroupFormByAppIdxKey keyAppIdx = schema.getFactorySecGroupForm().newAppIdxKey();
    keyAppIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyAppIdx.setRequiredSecAppId(existing.getRequiredSecAppId());

    CFAstSecGroupFormByFormIdxKey keyFormIdx = schema.getFactorySecGroupForm().newFormIdxKey();
    keyFormIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyFormIdx.setRequiredSecFormId(existing.getRequiredSecFormId());

    CFAstSecGroupFormByUFormIdxKey keyUFormIdx = schema.getFactorySecGroupForm().newUFormIdxKey();
    keyUFormIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyUFormIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());
    keyUFormIdx.setRequiredSecFormId(existing.getRequiredSecFormId());

    // Validate reverse foreign keys

    // Delete is valid

    SortedMap<CFAstSecGroupFormPKey, CFAstSecGroupFormBuff> subdict;

    dictByPKey.remove(pkey);

    subdict = dictByClusterIdx.get(keyClusterIdx);
    subdict.remove(pkey);

    subdict = dictByGroupIdx.get(keyGroupIdx);
    subdict.remove(pkey);

    subdict = dictByAppIdx.get(keyAppIdx);
    subdict.remove(pkey);

    subdict = dictByFormIdx.get(keyFormIdx);
    subdict.remove(pkey);

    dictByUFormIdx.remove(keyUFormIdx);

}