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.cfcore.v1_11.GenKbRam.GenKbRamGelInstructionTable.java

public void deleteGelInstruction(GenKbAuthorization Authorization, GenKbGelInstructionBuff Buff) {
    final String S_ProcName = "GenKbRamGelInstructionTable.deleteGelInstruction() ";
    GenKbGelInstructionPKey pkey = schema.getFactoryGelInstruction().newPKey();

    pkey.setClassCode(Buff.getClassCode());
    pkey.setRequiredCartridgeId(Buff.getRequiredCartridgeId());
    pkey.setRequiredGelInstId(schema.nextGelInstructionIdGen());
    GenKbGelInstructionBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                "deleteGelInstruction", "Existing record not found", "GelInstruction", pkey);
    }//from   www.  ja  v  a2 s  .co  m
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                "deleteGelInstruction", pkey);
    }
    GenKbGelInstructionByCartridgeIdxKey keyCartridgeIdx = schema.getFactoryGelInstruction()
            .newCartridgeIdxKey();
    keyCartridgeIdx.setRequiredCartridgeId(existing.getRequiredCartridgeId());

    GenKbGelInstructionByCallerIdxKey keyCallerIdx = schema.getFactoryGelInstruction().newCallerIdxKey();
    keyCallerIdx.setRequiredCartridgeId(existing.getRequiredCartridgeId());
    keyCallerIdx.setOptionalCallerId(existing.getOptionalCallerId());

    GenKbGelInstructionByPrevIdxKey keyPrevIdx = schema.getFactoryGelInstruction().newPrevIdxKey();
    keyPrevIdx.setRequiredCartridgeId(existing.getRequiredCartridgeId());
    keyPrevIdx.setOptionalPrevId(existing.getOptionalPrevId());

    GenKbGelInstructionByNextIdxKey keyNextIdx = schema.getFactoryGelInstruction().newNextIdxKey();
    keyNextIdx.setRequiredCartridgeId(existing.getRequiredCartridgeId());
    keyNextIdx.setOptionalNextId(existing.getOptionalNextId());

    // Validate reverse foreign keys

    if (schema.getTableGelExpansion().readDerivedByPIdx(Authorization, existing.getRequiredCartridgeId(),
            existing.getRequiredGelInstId()) != null) {
        throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(),
                "deleteGelInstruction", "Superclass", "SuperClass", "GelExpansion", pkey);
    }

    if (schema.getTableGelBuiltin().readDerivedByPIdx(Authorization, existing.getRequiredCartridgeId(),
            existing.getRequiredGelInstId()) != null) {
        throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(),
                "deleteGelInstruction", "Superclass", "SuperClass", "GelBuiltin", pkey);
    }

    if (schema.getTableGelSequence().readDerivedByPIdx(Authorization, existing.getRequiredCartridgeId(),
            existing.getRequiredGelInstId()) != null) {
        throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(),
                "deleteGelInstruction", "Superclass", "SuperClass", "GelSequence", pkey);
    }

    if (schema.getTableGelBoilerplate().readDerivedByPIdx(Authorization, existing.getRequiredCartridgeId(),
            existing.getRequiredGelInstId()) != null) {
        throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(),
                "deleteGelInstruction", "Superclass", "SuperClass", "GelBoilerplate", pkey);
    }

    if (schema.getTableGelReference().readDerivedByPIdx(Authorization, existing.getRequiredCartridgeId(),
            existing.getRequiredGelInstId()) != null) {
        throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(),
                "deleteGelInstruction", "Superclass", "SuperClass", "GelReference", pkey);
    }

    if (schema.getTableGelFormat().readDerivedByPIdx(Authorization, existing.getRequiredCartridgeId(),
            existing.getRequiredGelInstId()) != null) {
        throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(),
                "deleteGelInstruction", "Superclass", "SuperClass", "GelFormat", pkey);
    }

    if (schema.getTableGelIterator().readDerivedByPIdx(Authorization, existing.getRequiredCartridgeId(),
            existing.getRequiredGelInstId()) != null) {
        throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(),
                "deleteGelInstruction", "Superclass", "SuperClass", "GelIterator", pkey);
    }

    if (schema.getTableGelCounter().readDerivedByPIdx(Authorization, existing.getRequiredCartridgeId(),
            existing.getRequiredGelInstId()) != null) {
        throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(),
                "deleteGelInstruction", "Superclass", "SuperClass", "GelCounter", pkey);
    }

    if (schema.getTableGelPop().readDerivedByPIdx(Authorization, existing.getRequiredCartridgeId(),
            existing.getRequiredGelInstId()) != null) {
        throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(),
                "deleteGelInstruction", "Superclass", "SuperClass", "GelPop", pkey);
    }

    if (schema.getTableGelConstrain().readDerivedByPIdx(Authorization, existing.getRequiredCartridgeId(),
            existing.getRequiredGelInstId()) != null) {
        throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(),
                "deleteGelInstruction", "Superclass", "SuperClass", "GelConstrain", pkey);
    }

    if (schema.getTableGelSwitch().readDerivedByPIdx(Authorization, existing.getRequiredCartridgeId(),
            existing.getRequiredGelInstId()) != null) {
        throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(),
                "deleteGelInstruction", "Superclass", "SuperClass", "GelSwitch", pkey);
    }

    if (schema.getTableGelPrefixLine().readDerivedByPIdx(Authorization, existing.getRequiredCartridgeId(),
            existing.getRequiredGelInstId()) != null) {
        throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(),
                "deleteGelInstruction", "Superclass", "SuperClass", "GelPrefixLine", pkey);
    }

    // Delete is valid

    SortedMap<GenKbGelInstructionPKey, GenKbGelInstructionBuff> subdict;

    dictByPKey.remove(pkey);

    subdict = dictByCartridgeIdx.get(keyCartridgeIdx);
    subdict.remove(pkey);

    subdict = dictByCallerIdx.get(keyCallerIdx);
    subdict.remove(pkey);

    subdict = dictByPrevIdx.get(keyPrevIdx);
    subdict.remove(pkey);

    subdict = dictByNextIdx.get(keyNextIdx);
    subdict.remove(pkey);

}

From source file:net.sourceforge.msscodefactory.cfcore.v1_11.GenKbRam.GenKbRamGenItemTable.java

public void updateGenItem(GenKbAuthorization Authorization, GenKbGenItemBuff Buff) {
    GenKbGenItemPKey pkey = schema.getFactoryGenItem().newPKey();
    pkey.setClassCode(Buff.getClassCode());
    pkey.setRequiredCartridgeId(Buff.getRequiredCartridgeId());
    pkey.setRequiredItemId(Buff.getRequiredItemId());
    GenKbGenItemBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateGenItem",
                "Existing record not found", "GenItem", pkey);
    }// ww w  .j a v a  2s .  c o  m
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateGenItem",
                pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    GenKbGenItemByCartIdxKey existingKeyCartIdx = schema.getFactoryGenItem().newCartIdxKey();
    existingKeyCartIdx.setRequiredCartridgeId(existing.getRequiredCartridgeId());

    GenKbGenItemByCartIdxKey newKeyCartIdx = schema.getFactoryGenItem().newCartIdxKey();
    newKeyCartIdx.setRequiredCartridgeId(Buff.getRequiredCartridgeId());

    GenKbGenItemByRuleTypeIdxKey existingKeyRuleTypeIdx = schema.getFactoryGenItem().newRuleTypeIdxKey();
    existingKeyRuleTypeIdx.setRequiredRuleTypeId(existing.getRequiredRuleTypeId());

    GenKbGenItemByRuleTypeIdxKey newKeyRuleTypeIdx = schema.getFactoryGenItem().newRuleTypeIdxKey();
    newKeyRuleTypeIdx.setRequiredRuleTypeId(Buff.getRequiredRuleTypeId());

    GenKbGenItemByToolSetIdxKey existingKeyToolSetIdx = schema.getFactoryGenItem().newToolSetIdxKey();
    existingKeyToolSetIdx.setRequiredToolSetId(existing.getRequiredToolSetId());

    GenKbGenItemByToolSetIdxKey newKeyToolSetIdx = schema.getFactoryGenItem().newToolSetIdxKey();
    newKeyToolSetIdx.setRequiredToolSetId(Buff.getRequiredToolSetId());

    GenKbGenItemByScopeIdxKey existingKeyScopeIdx = schema.getFactoryGenItem().newScopeIdxKey();
    existingKeyScopeIdx.setOptionalScopeDefId(existing.getOptionalScopeDefId());

    GenKbGenItemByScopeIdxKey newKeyScopeIdx = schema.getFactoryGenItem().newScopeIdxKey();
    newKeyScopeIdx.setOptionalScopeDefId(Buff.getOptionalScopeDefId());

    GenKbGenItemByGenDefIdxKey existingKeyGenDefIdx = schema.getFactoryGenItem().newGenDefIdxKey();
    existingKeyGenDefIdx.setRequiredGenDefId(existing.getRequiredGenDefId());

    GenKbGenItemByGenDefIdxKey newKeyGenDefIdx = schema.getFactoryGenItem().newGenDefIdxKey();
    newKeyGenDefIdx.setRequiredGenDefId(Buff.getRequiredGenDefId());

    GenKbGenItemByAltIdxKey existingKeyAltIdx = schema.getFactoryGenItem().newAltIdxKey();
    existingKeyAltIdx.setRequiredName(existing.getRequiredName());
    existingKeyAltIdx.setRequiredToolSetId(existing.getRequiredToolSetId());
    existingKeyAltIdx.setOptionalScopeDefId(existing.getOptionalScopeDefId());
    existingKeyAltIdx.setRequiredGenDefId(existing.getRequiredGenDefId());

    GenKbGenItemByAltIdxKey newKeyAltIdx = schema.getFactoryGenItem().newAltIdxKey();
    newKeyAltIdx.setRequiredName(Buff.getRequiredName());
    newKeyAltIdx.setRequiredToolSetId(Buff.getRequiredToolSetId());
    newKeyAltIdx.setOptionalScopeDefId(Buff.getOptionalScopeDefId());
    newKeyAltIdx.setRequiredGenDefId(Buff.getRequiredGenDefId());

    GenKbGenItemByTSNameIdxKey existingKeyTSNameIdx = schema.getFactoryGenItem().newTSNameIdxKey();
    existingKeyTSNameIdx.setRequiredToolSetId(existing.getRequiredToolSetId());
    existingKeyTSNameIdx.setRequiredName(existing.getRequiredName());

    GenKbGenItemByTSNameIdxKey newKeyTSNameIdx = schema.getFactoryGenItem().newTSNameIdxKey();
    newKeyTSNameIdx.setRequiredToolSetId(Buff.getRequiredToolSetId());
    newKeyTSNameIdx.setRequiredName(Buff.getRequiredName());

    GenKbGenItemByProbeIdxKey existingKeyProbeIdx = schema.getFactoryGenItem().newProbeIdxKey();
    existingKeyProbeIdx.setOptionalProbeCartridgeId(existing.getOptionalProbeCartridgeId());
    existingKeyProbeIdx.setOptionalProbeGenItemId(existing.getOptionalProbeGenItemId());

    GenKbGenItemByProbeIdxKey newKeyProbeIdx = schema.getFactoryGenItem().newProbeIdxKey();
    newKeyProbeIdx.setOptionalProbeCartridgeId(Buff.getOptionalProbeCartridgeId());
    newKeyProbeIdx.setOptionalProbeGenItemId(Buff.getOptionalProbeGenItemId());

    // Check unique indexes

    if (!existingKeyAltIdx.equals(newKeyAltIdx)) {
        if (dictByAltIdx.containsKey(newKeyAltIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateGenItem", "GenItemAlt", newKeyAltIdx);
        }
    }

    // Validate foreign keys

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableRuleCart().readDerivedByIdIdx(Authorization,
                    Buff.getRequiredCartridgeId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateGenItem", "Container", "Cartridge", "RuleCart", null);
            }
        }
    }

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableRuleType().readDerivedByIdIdx(Authorization,
                    Buff.getRequiredRuleTypeId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateGenItem", "Lookup", "RuleType", "RuleType", null);
            }
        }
    }

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableToolSet().readDerivedByIdIdx(Authorization,
                    Buff.getRequiredToolSetId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateGenItem", "Lookup", "ToolSet", "ToolSet", null);
            }
        }
    }

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableDefClass().readDerivedByIdIdx(Authorization,
                    Buff.getRequiredGenDefId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateGenItem", "Lookup", "GenDef", "DefClass", null);
            }
        }
    }

    // Update is valid

    SortedMap<GenKbGenItemPKey, GenKbGenItemBuff> subdict;

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

    subdict = dictByCartIdx.get(existingKeyCartIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByCartIdx.containsKey(newKeyCartIdx)) {
        subdict = dictByCartIdx.get(newKeyCartIdx);
    } else {
        subdict = new TreeMap<GenKbGenItemPKey, GenKbGenItemBuff>();
        dictByCartIdx.put(newKeyCartIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByRuleTypeIdx.get(existingKeyRuleTypeIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByRuleTypeIdx.containsKey(newKeyRuleTypeIdx)) {
        subdict = dictByRuleTypeIdx.get(newKeyRuleTypeIdx);
    } else {
        subdict = new TreeMap<GenKbGenItemPKey, GenKbGenItemBuff>();
        dictByRuleTypeIdx.put(newKeyRuleTypeIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByToolSetIdx.get(existingKeyToolSetIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByToolSetIdx.containsKey(newKeyToolSetIdx)) {
        subdict = dictByToolSetIdx.get(newKeyToolSetIdx);
    } else {
        subdict = new TreeMap<GenKbGenItemPKey, GenKbGenItemBuff>();
        dictByToolSetIdx.put(newKeyToolSetIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByScopeIdx.get(existingKeyScopeIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByScopeIdx.containsKey(newKeyScopeIdx)) {
        subdict = dictByScopeIdx.get(newKeyScopeIdx);
    } else {
        subdict = new TreeMap<GenKbGenItemPKey, GenKbGenItemBuff>();
        dictByScopeIdx.put(newKeyScopeIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByGenDefIdx.get(existingKeyGenDefIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByGenDefIdx.containsKey(newKeyGenDefIdx)) {
        subdict = dictByGenDefIdx.get(newKeyGenDefIdx);
    } else {
        subdict = new TreeMap<GenKbGenItemPKey, GenKbGenItemBuff>();
        dictByGenDefIdx.put(newKeyGenDefIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByAltIdx.remove(existingKeyAltIdx);
    dictByAltIdx.put(newKeyAltIdx, Buff);

    subdict = dictByTSNameIdx.get(existingKeyTSNameIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByTSNameIdx.containsKey(newKeyTSNameIdx)) {
        subdict = dictByTSNameIdx.get(newKeyTSNameIdx);
    } else {
        subdict = new TreeMap<GenKbGenItemPKey, GenKbGenItemBuff>();
        dictByTSNameIdx.put(newKeyTSNameIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByProbeIdx.get(existingKeyProbeIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByProbeIdx.containsKey(newKeyProbeIdx)) {
        subdict = dictByProbeIdx.get(newKeyProbeIdx);
    } else {
        subdict = new TreeMap<GenKbGenItemPKey, GenKbGenItemBuff>();
        dictByProbeIdx.put(newKeyProbeIdx, subdict);
    }
    subdict.put(pkey, Buff);

}

From source file:net.sourceforge.msscodefactory.cfcore.v1_11.GenKbRam.GenKbRamGenItemTable.java

public void deleteGenItem(GenKbAuthorization Authorization, GenKbGenItemBuff Buff) {
    final String S_ProcName = "GenKbRamGenItemTable.deleteGenItem() ";
    GenKbGenItemPKey pkey = schema.getFactoryGenItem().newPKey();

    pkey.setClassCode(Buff.getClassCode());
    pkey.setRequiredCartridgeId(Buff.getRequiredCartridgeId());
    pkey.setRequiredItemId(schema.nextGenItemIdGen());
    GenKbGenItemBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "deleteGenItem",
                "Existing record not found", "GenItem", pkey);
    }// w  ww  .  java  2 s.co m
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteGenItem",
                pkey);
    }
    GenKbGenItemByCartIdxKey keyCartIdx = schema.getFactoryGenItem().newCartIdxKey();
    keyCartIdx.setRequiredCartridgeId(existing.getRequiredCartridgeId());

    GenKbGenItemByRuleTypeIdxKey keyRuleTypeIdx = schema.getFactoryGenItem().newRuleTypeIdxKey();
    keyRuleTypeIdx.setRequiredRuleTypeId(existing.getRequiredRuleTypeId());

    GenKbGenItemByToolSetIdxKey keyToolSetIdx = schema.getFactoryGenItem().newToolSetIdxKey();
    keyToolSetIdx.setRequiredToolSetId(existing.getRequiredToolSetId());

    GenKbGenItemByScopeIdxKey keyScopeIdx = schema.getFactoryGenItem().newScopeIdxKey();
    keyScopeIdx.setOptionalScopeDefId(existing.getOptionalScopeDefId());

    GenKbGenItemByGenDefIdxKey keyGenDefIdx = schema.getFactoryGenItem().newGenDefIdxKey();
    keyGenDefIdx.setRequiredGenDefId(existing.getRequiredGenDefId());

    GenKbGenItemByAltIdxKey keyAltIdx = schema.getFactoryGenItem().newAltIdxKey();
    keyAltIdx.setRequiredName(existing.getRequiredName());
    keyAltIdx.setRequiredToolSetId(existing.getRequiredToolSetId());
    keyAltIdx.setOptionalScopeDefId(existing.getOptionalScopeDefId());
    keyAltIdx.setRequiredGenDefId(existing.getRequiredGenDefId());

    GenKbGenItemByTSNameIdxKey keyTSNameIdx = schema.getFactoryGenItem().newTSNameIdxKey();
    keyTSNameIdx.setRequiredToolSetId(existing.getRequiredToolSetId());
    keyTSNameIdx.setRequiredName(existing.getRequiredName());

    GenKbGenItemByProbeIdxKey keyProbeIdx = schema.getFactoryGenItem().newProbeIdxKey();
    keyProbeIdx.setOptionalProbeCartridgeId(existing.getOptionalProbeCartridgeId());
    keyProbeIdx.setOptionalProbeGenItemId(existing.getOptionalProbeGenItemId());

    // Validate reverse foreign keys

    if (schema.getTableGenBind().readDerivedByItemIdIdx(Authorization, existing.getRequiredCartridgeId(),
            existing.getRequiredItemId()) != null) {
        throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteGenItem",
                "Superclass", "SuperClass", "GenBind", pkey);
    }

    if (schema.getTableGenIterator().readDerivedByItemIdIdx(Authorization, existing.getRequiredCartridgeId(),
            existing.getRequiredItemId()) != null) {
        throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteGenItem",
                "Superclass", "SuperClass", "GenIterator", pkey);
    }

    if (schema.getTableGenReference().readDerivedByItemIdIdx(Authorization, existing.getRequiredCartridgeId(),
            existing.getRequiredItemId()) != null) {
        throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteGenItem",
                "Superclass", "SuperClass", "GenReference", pkey);
    }

    if (schema.getTableGenRule().readDerivedByItemIdIdx(Authorization, existing.getRequiredCartridgeId(),
            existing.getRequiredItemId()) != null) {
        throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteGenItem",
                "Superclass", "SuperClass", "GenRule", pkey);
    }

    if (schema.getTableGelExecutable().readDerivedByGenItemIdx(Authorization, existing.getRequiredCartridgeId(),
            existing.getRequiredItemId()).length > 0) {
        throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteGenItem",
                "Container", "GenItem", "GelExecutable", pkey);
    }

    // Delete is valid

    SortedMap<GenKbGenItemPKey, GenKbGenItemBuff> subdict;

    dictByPKey.remove(pkey);

    subdict = dictByCartIdx.get(keyCartIdx);
    subdict.remove(pkey);

    subdict = dictByRuleTypeIdx.get(keyRuleTypeIdx);
    subdict.remove(pkey);

    subdict = dictByToolSetIdx.get(keyToolSetIdx);
    subdict.remove(pkey);

    subdict = dictByScopeIdx.get(keyScopeIdx);
    subdict.remove(pkey);

    subdict = dictByGenDefIdx.get(keyGenDefIdx);
    subdict.remove(pkey);

    dictByAltIdx.remove(keyAltIdx);

    subdict = dictByTSNameIdx.get(keyTSNameIdx);
    subdict.remove(pkey);

    subdict = dictByProbeIdx.get(keyProbeIdx);
    subdict.remove(pkey);

}

From source file:net.sourceforge.msscodefactory.cffreeswitch.v2_0.CFFswRam.CFFswRamTopDomainTable.java

public void updateTopDomain(CFFswAuthorization Authorization, CFFswTopDomainBuff Buff) {
    schema.getTableDomainBase().updateDomainBase(Authorization, Buff);
    CFFswDomainBasePKey pkey = schema.getFactoryDomainBase().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredId(Buff.getRequiredId());
    CFFswTopDomainBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateTopDomain",
                "Existing record not found", "TopDomain", pkey);
    }/*from  ww w. j  a va2s.c  o m*/
    CFFswTopDomainByTLDIdxKey existingKeyTLDIdx = schema.getFactoryTopDomain().newTLDIdxKey();
    existingKeyTLDIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyTLDIdx.setRequiredTLDId(existing.getRequiredTLDId());

    CFFswTopDomainByTLDIdxKey newKeyTLDIdx = schema.getFactoryTopDomain().newTLDIdxKey();
    newKeyTLDIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyTLDIdx.setRequiredTLDId(Buff.getRequiredTLDId());

    CFFswTopDomainByNameIdxKey existingKeyNameIdx = schema.getFactoryTopDomain().newNameIdxKey();
    existingKeyNameIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyNameIdx.setRequiredTLDId(existing.getRequiredTLDId());
    existingKeyNameIdx.setRequiredName(existing.getRequiredName());

    CFFswTopDomainByNameIdxKey newKeyNameIdx = schema.getFactoryTopDomain().newNameIdxKey();
    newKeyNameIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyNameIdx.setRequiredTLDId(Buff.getRequiredTLDId());
    newKeyNameIdx.setRequiredName(Buff.getRequiredName());

    // Check unique indexes

    if (!existingKeyNameIdx.equals(newKeyNameIdx)) {
        if (dictByNameIdx.containsKey(newKeyNameIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateTopDomain", "TopDomainNameIdx", newKeyNameIdx);
        }
    }

    // Validate foreign keys

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableDomainBase().readDerivedByIdIdx(Authorization,
                    Buff.getRequiredTenantId(), Buff.getRequiredId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateTopDomain", "Superclass", "SuperClass", "DomainBase", null);
            }
        }
    }

    {
        boolean allNull = true;

        if (allNull) {
            if (null == schema.getTableTld().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId(),
                    Buff.getRequiredTLDId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "updateTopDomain", "Container", "TLD", "Tld", null);
            }
        }
    }

    // Update is valid

    SortedMap<CFFswDomainBasePKey, CFFswTopDomainBuff> subdict;

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

    subdict = dictByTLDIdx.get(existingKeyTLDIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByTLDIdx.containsKey(newKeyTLDIdx)) {
        subdict = dictByTLDIdx.get(newKeyTLDIdx);
    } else {
        subdict = new TreeMap<CFFswDomainBasePKey, CFFswTopDomainBuff>();
        dictByTLDIdx.put(newKeyTLDIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByNameIdx.remove(existingKeyNameIdx);
    dictByNameIdx.put(newKeyNameIdx, Buff);

}

From source file:net.sourceforge.msscodefactory.cffreeswitch.v2_0.CFFswRam.CFFswRamTopDomainTable.java

public void deleteTopDomain(CFFswAuthorization Authorization, CFFswTopDomainBuff Buff) {
    final String S_ProcName = "CFFswRamTopDomainTable.deleteTopDomain() ";
    CFFswDomainBasePKey pkey = schema.getFactoryDomainBase().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredId(Buff.getRequiredId());
    CFFswTopDomainBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        return;//  www.  j  a  v a2  s  . c  o  m
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteTopDomain",
                pkey);
    }
    CFFswTopDomainByTLDIdxKey keyTLDIdx = schema.getFactoryTopDomain().newTLDIdxKey();
    keyTLDIdx.setRequiredTenantId(existing.getRequiredTenantId());
    keyTLDIdx.setRequiredTLDId(existing.getRequiredTLDId());

    CFFswTopDomainByNameIdxKey keyNameIdx = schema.getFactoryTopDomain().newNameIdxKey();
    keyNameIdx.setRequiredTenantId(existing.getRequiredTenantId());
    keyNameIdx.setRequiredTLDId(existing.getRequiredTLDId());
    keyNameIdx.setRequiredName(existing.getRequiredName());

    // Validate reverse foreign keys

    // Delete is valid

    schema.getTableDomain().deleteDomainBySubDomIdx(Authorization, Buff.getRequiredTenantId(),
            Buff.getRequiredId());
    schema.getTableTopProject().deleteTopProjectByDomainIdx(Authorization, Buff.getRequiredTenantId(),
            Buff.getRequiredId());
    SortedMap<CFFswDomainBasePKey, CFFswTopDomainBuff> subdict;

    dictByPKey.remove(pkey);

    subdict = dictByTLDIdx.get(keyTLDIdx);
    subdict.remove(pkey);

    dictByNameIdx.remove(keyNameIdx);

    schema.getTableDomainBase().deleteDomainBase(Authorization, Buff);
}

From source file:net.sourceforge.msscodefactory.cfgcash.v2_0.CFGCashRam.CFGCashRamSecGroupMemberTable.java

public void updateSecGroupMember(CFGCashAuthorization Authorization, CFGCashSecGroupMemberBuff Buff) {
    CFGCashSecGroupMemberPKey pkey = schema.getFactorySecGroupMember().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecGroupMemberId(Buff.getRequiredSecGroupMemberId());
    CFGCashSecGroupMemberBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                "updateSecGroupMember", "Existing record not found", "SecGroupMember", pkey);
    }// w ww . j ava2s  .  c om
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                "updateSecGroupMember", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFGCashSecGroupMemberByClusterIdxKey existingKeyClusterIdx = schema.getFactorySecGroupMember()
            .newClusterIdxKey();
    existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

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

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

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

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

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

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

    CFGCashSecGroupMemberByUUserIdxKey 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<CFGCashSecGroupMemberPKey, CFGCashSecGroupMemberBuff> 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<CFGCashSecGroupMemberPKey, CFGCashSecGroupMemberBuff>();
        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<CFGCashSecGroupMemberPKey, CFGCashSecGroupMemberBuff>();
        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<CFGCashSecGroupMemberPKey, CFGCashSecGroupMemberBuff>();
        dictByUserIdx.put(newKeyUserIdx, subdict);
    }
    subdict.put(pkey, Buff);

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

}

From source file:net.sourceforge.msscodefactory.cfgcash.v2_0.CFGCashRam.CFGCashRamSecGroupMemberTable.java

public void deleteSecGroupMember(CFGCashAuthorization Authorization, CFGCashSecGroupMemberBuff Buff) {
    final String S_ProcName = "CFGCashRamSecGroupMemberTable.deleteSecGroupMember() ";
    CFGCashSecGroupMemberPKey pkey = schema.getFactorySecGroupMember().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecGroupMemberId(Buff.getRequiredSecGroupMemberId());
    CFGCashSecGroupMemberBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        return;//from   w ww  . ja va2 s. c  o  m
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                "deleteSecGroupMember", pkey);
    }
    CFGCashSecGroupMemberByClusterIdxKey keyClusterIdx = schema.getFactorySecGroupMember().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFGCashSecGroupMemberByGroupIdxKey keyGroupIdx = schema.getFactorySecGroupMember().newGroupIdxKey();
    keyGroupIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());

    CFGCashSecGroupMemberByUserIdxKey keyUserIdx = schema.getFactorySecGroupMember().newUserIdxKey();
    keyUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId());

    CFGCashSecGroupMemberByUUserIdxKey keyUUserIdx = schema.getFactorySecGroupMember().newUUserIdxKey();
    keyUUserIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyUUserIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());
    keyUUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId());

    // Validate reverse foreign keys

    // Delete is valid

    SortedMap<CFGCashSecGroupMemberPKey, CFGCashSecGroupMemberBuff> subdict;

    dictByPKey.remove(pkey);

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

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

    subdict = dictByUserIdx.get(keyUserIdx);
    subdict.remove(pkey);

    dictByUUserIdx.remove(keyUUserIdx);

}

From source file:net.sourceforge.msscodefactory.cfgcash.v2_0.CFGCashRam.CFGCashRamServiceTable.java

public void updateService(CFGCashAuthorization Authorization, CFGCashServiceBuff Buff) {
    CFGCashServicePKey pkey = schema.getFactoryService().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredServiceId(Buff.getRequiredServiceId());
    CFGCashServiceBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateService",
                "Existing record not found", "Service", pkey);
    }/*  ww w .jav a  2 s.  co  m*/
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateService",
                pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFGCashServiceByClusterIdxKey existingKeyClusterIdx = schema.getFactoryService().newClusterIdxKey();
    existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFGCashServiceByClusterIdxKey newKeyClusterIdx = schema.getFactoryService().newClusterIdxKey();
    newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFGCashServiceByHostIdxKey existingKeyHostIdx = schema.getFactoryService().newHostIdxKey();
    existingKeyHostIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyHostIdx.setRequiredHostNodeId(existing.getRequiredHostNodeId());

    CFGCashServiceByHostIdxKey newKeyHostIdx = schema.getFactoryService().newHostIdxKey();
    newKeyHostIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyHostIdx.setRequiredHostNodeId(Buff.getRequiredHostNodeId());

    CFGCashServiceByTypeIdxKey existingKeyTypeIdx = schema.getFactoryService().newTypeIdxKey();
    existingKeyTypeIdx.setRequiredServiceTypeId(existing.getRequiredServiceTypeId());

    CFGCashServiceByTypeIdxKey newKeyTypeIdx = schema.getFactoryService().newTypeIdxKey();
    newKeyTypeIdx.setRequiredServiceTypeId(Buff.getRequiredServiceTypeId());

    CFGCashServiceByUTypeIdxKey existingKeyUTypeIdx = schema.getFactoryService().newUTypeIdxKey();
    existingKeyUTypeIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyUTypeIdx.setRequiredHostNodeId(existing.getRequiredHostNodeId());
    existingKeyUTypeIdx.setRequiredServiceTypeId(existing.getRequiredServiceTypeId());

    CFGCashServiceByUTypeIdxKey newKeyUTypeIdx = schema.getFactoryService().newUTypeIdxKey();
    newKeyUTypeIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyUTypeIdx.setRequiredHostNodeId(Buff.getRequiredHostNodeId());
    newKeyUTypeIdx.setRequiredServiceTypeId(Buff.getRequiredServiceTypeId());

    CFGCashServiceByUHostPortIdxKey existingKeyUHostPortIdx = schema.getFactoryService().newUHostPortIdxKey();
    existingKeyUHostPortIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyUHostPortIdx.setRequiredHostNodeId(existing.getRequiredHostNodeId());
    existingKeyUHostPortIdx.setRequiredHostPort(existing.getRequiredHostPort());

    CFGCashServiceByUHostPortIdxKey newKeyUHostPortIdx = schema.getFactoryService().newUHostPortIdxKey();
    newKeyUHostPortIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyUHostPortIdx.setRequiredHostNodeId(Buff.getRequiredHostNodeId());
    newKeyUHostPortIdx.setRequiredHostPort(Buff.getRequiredHostPort());

    // Check unique indexes

    if (!existingKeyUTypeIdx.equals(newKeyUTypeIdx)) {
        if (dictByUTypeIdx.containsKey(newKeyUTypeIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateService", "ServiceUTypeIdx", newKeyUTypeIdx);
        }
    }

    if (!existingKeyUHostPortIdx.equals(newKeyUHostPortIdx)) {
        if (dictByUHostPortIdx.containsKey(newKeyUHostPortIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateService", "ServiceUHostPort", newKeyUHostPortIdx);
        }
    }

    // Validate foreign keys

    {
        boolean allNull = true;

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

    // Update is valid

    SortedMap<CFGCashServicePKey, CFGCashServiceBuff> 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<CFGCashServicePKey, CFGCashServiceBuff>();
        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<CFGCashServicePKey, CFGCashServiceBuff>();
        dictByHostIdx.put(newKeyHostIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByTypeIdx.get(existingKeyTypeIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByTypeIdx.containsKey(newKeyTypeIdx)) {
        subdict = dictByTypeIdx.get(newKeyTypeIdx);
    } else {
        subdict = new TreeMap<CFGCashServicePKey, CFGCashServiceBuff>();
        dictByTypeIdx.put(newKeyTypeIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUTypeIdx.remove(existingKeyUTypeIdx);
    dictByUTypeIdx.put(newKeyUTypeIdx, Buff);

    dictByUHostPortIdx.remove(existingKeyUHostPortIdx);
    dictByUHostPortIdx.put(newKeyUHostPortIdx, Buff);

}

From source file:net.sourceforge.msscodefactory.cfgcash.v2_0.CFGCashRam.CFGCashRamServiceTable.java

public void deleteService(CFGCashAuthorization Authorization, CFGCashServiceBuff Buff) {
    final String S_ProcName = "CFGCashRamServiceTable.deleteService() ";
    CFGCashServicePKey pkey = schema.getFactoryService().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredServiceId(Buff.getRequiredServiceId());
    CFGCashServiceBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        return;//from w w  w  .j  a  va 2  s .c  o  m
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteService",
                pkey);
    }
    CFGCashServiceByClusterIdxKey keyClusterIdx = schema.getFactoryService().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

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

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

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

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

    // Validate reverse foreign keys

    // Delete is valid

    SortedMap<CFGCashServicePKey, CFGCashServiceBuff> 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.cfgcash.v2_0.CFGCashRam.CFGCashRamURLProtocolTable.java

public void updateURLProtocol(CFGCashAuthorization Authorization, CFGCashURLProtocolBuff Buff) {
    CFGCashURLProtocolPKey pkey = schema.getFactoryURLProtocol().newPKey();
    pkey.setRequiredURLProtocolId(Buff.getRequiredURLProtocolId());
    CFGCashURLProtocolBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateURLProtocol",
                "Existing record not found", "URLProtocol", pkey);
    }//w  ww.j  a v  a 2s .co m
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateURLProtocol",
                pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFGCashURLProtocolByUNameIdxKey existingKeyUNameIdx = schema.getFactoryURLProtocol().newUNameIdxKey();
    existingKeyUNameIdx.setRequiredName(existing.getRequiredName());

    CFGCashURLProtocolByUNameIdxKey newKeyUNameIdx = schema.getFactoryURLProtocol().newUNameIdxKey();
    newKeyUNameIdx.setRequiredName(Buff.getRequiredName());

    CFGCashURLProtocolByIsSecureIdxKey existingKeyIsSecureIdx = schema.getFactoryURLProtocol()
            .newIsSecureIdxKey();
    existingKeyIsSecureIdx.setRequiredIsSecure(existing.getRequiredIsSecure());

    CFGCashURLProtocolByIsSecureIdxKey newKeyIsSecureIdx = schema.getFactoryURLProtocol().newIsSecureIdxKey();
    newKeyIsSecureIdx.setRequiredIsSecure(Buff.getRequiredIsSecure());

    // Check unique indexes

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

    // Validate foreign keys

    // Update is valid

    SortedMap<CFGCashURLProtocolPKey, CFGCashURLProtocolBuff> subdict;

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

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

    subdict = dictByIsSecureIdx.get(existingKeyIsSecureIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByIsSecureIdx.containsKey(newKeyIsSecureIdx)) {
        subdict = dictByIsSecureIdx.get(newKeyIsSecureIdx);
    } else {
        subdict = new TreeMap<CFGCashURLProtocolPKey, CFGCashURLProtocolBuff>();
        dictByIsSecureIdx.put(newKeyIsSecureIdx, subdict);
    }
    subdict.put(pkey, Buff);

}