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

public void updateTSecGroupInclude(CFAccAuthorization Authorization, CFAccTSecGroupIncludeBuff Buff) {
    CFAccTSecGroupIncludePKey pkey = schema.getFactoryTSecGroupInclude().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredTSecGroupIncludeId(Buff.getRequiredTSecGroupIncludeId());
    CFAccTSecGroupIncludeBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                "updateTSecGroupInclude", "Existing record not found", "TSecGroupInclude", pkey);
    }// ww w. j  ava2s.  c  om
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                "updateTSecGroupInclude", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAccTSecGroupIncludeByTenantIdxKey existingKeyTenantIdx = schema.getFactoryTSecGroupInclude()
            .newTenantIdxKey();
    existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId());

    CFAccTSecGroupIncludeByTenantIdxKey newKeyTenantIdx = schema.getFactoryTSecGroupInclude().newTenantIdxKey();
    newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFAccTSecGroupIncludeByGroupIdxKey existingKeyGroupIdx = schema.getFactoryTSecGroupInclude()
            .newGroupIdxKey();
    existingKeyGroupIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyGroupIdx.setRequiredTSecGroupId(existing.getRequiredTSecGroupId());

    CFAccTSecGroupIncludeByGroupIdxKey newKeyGroupIdx = schema.getFactoryTSecGroupInclude().newGroupIdxKey();
    newKeyGroupIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyGroupIdx.setRequiredTSecGroupId(Buff.getRequiredTSecGroupId());

    CFAccTSecGroupIncludeByIncludeIdxKey existingKeyIncludeIdx = schema.getFactoryTSecGroupInclude()
            .newIncludeIdxKey();
    existingKeyIncludeIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId());

    CFAccTSecGroupIncludeByIncludeIdxKey newKeyIncludeIdx = schema.getFactoryTSecGroupInclude()
            .newIncludeIdxKey();
    newKeyIncludeIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId());

    CFAccTSecGroupIncludeByUIncludeIdxKey existingKeyUIncludeIdx = schema.getFactoryTSecGroupInclude()
            .newUIncludeIdxKey();
    existingKeyUIncludeIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyUIncludeIdx.setRequiredTSecGroupId(existing.getRequiredTSecGroupId());
    existingKeyUIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId());

    CFAccTSecGroupIncludeByUIncludeIdxKey newKeyUIncludeIdx = schema.getFactoryTSecGroupInclude()
            .newUIncludeIdxKey();
    newKeyUIncludeIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyUIncludeIdx.setRequiredTSecGroupId(Buff.getRequiredTSecGroupId());
    newKeyUIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId());

    // Check unique indexes

    if (!existingKeyUIncludeIdx.equals(newKeyUIncludeIdx)) {
        if (dictByUIncludeIdx.containsKey(newKeyUIncludeIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateTSecGroupInclude", "TSecGroupIncludeUIncludeIdx", newKeyUIncludeIdx);
        }
    }

    // Validate foreign keys

    {
        boolean allNull = true;

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

    {
        boolean allNull = true;

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

    // Update is valid

    SortedMap<CFAccTSecGroupIncludePKey, CFAccTSecGroupIncludeBuff> 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<CFAccTSecGroupIncludePKey, CFAccTSecGroupIncludeBuff>();
        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<CFAccTSecGroupIncludePKey, CFAccTSecGroupIncludeBuff>();
        dictByGroupIdx.put(newKeyGroupIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByIncludeIdx.get(existingKeyIncludeIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByIncludeIdx.containsKey(newKeyIncludeIdx)) {
        subdict = dictByIncludeIdx.get(newKeyIncludeIdx);
    } else {
        subdict = new TreeMap<CFAccTSecGroupIncludePKey, CFAccTSecGroupIncludeBuff>();
        dictByIncludeIdx.put(newKeyIncludeIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUIncludeIdx.remove(existingKeyUIncludeIdx);
    dictByUIncludeIdx.put(newKeyUIncludeIdx, Buff);

}

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

public void updateTSecGroupInclude(CFAstAuthorization Authorization, CFAstTSecGroupIncludeBuff Buff) {
    CFAstTSecGroupIncludePKey pkey = schema.getFactoryTSecGroupInclude().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredTSecGroupIncludeId(Buff.getRequiredTSecGroupIncludeId());
    CFAstTSecGroupIncludeBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                "updateTSecGroupInclude", "Existing record not found", "TSecGroupInclude", pkey);
    }/*from  w  w w. j a v a  2  s.c om*/
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                "updateTSecGroupInclude", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAstTSecGroupIncludeByTenantIdxKey existingKeyTenantIdx = schema.getFactoryTSecGroupInclude()
            .newTenantIdxKey();
    existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId());

    CFAstTSecGroupIncludeByTenantIdxKey newKeyTenantIdx = schema.getFactoryTSecGroupInclude().newTenantIdxKey();
    newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFAstTSecGroupIncludeByGroupIdxKey existingKeyGroupIdx = schema.getFactoryTSecGroupInclude()
            .newGroupIdxKey();
    existingKeyGroupIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyGroupIdx.setRequiredTSecGroupId(existing.getRequiredTSecGroupId());

    CFAstTSecGroupIncludeByGroupIdxKey newKeyGroupIdx = schema.getFactoryTSecGroupInclude().newGroupIdxKey();
    newKeyGroupIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyGroupIdx.setRequiredTSecGroupId(Buff.getRequiredTSecGroupId());

    CFAstTSecGroupIncludeByIncludeIdxKey existingKeyIncludeIdx = schema.getFactoryTSecGroupInclude()
            .newIncludeIdxKey();
    existingKeyIncludeIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId());

    CFAstTSecGroupIncludeByIncludeIdxKey newKeyIncludeIdx = schema.getFactoryTSecGroupInclude()
            .newIncludeIdxKey();
    newKeyIncludeIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId());

    CFAstTSecGroupIncludeByUIncludeIdxKey existingKeyUIncludeIdx = schema.getFactoryTSecGroupInclude()
            .newUIncludeIdxKey();
    existingKeyUIncludeIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyUIncludeIdx.setRequiredTSecGroupId(existing.getRequiredTSecGroupId());
    existingKeyUIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId());

    CFAstTSecGroupIncludeByUIncludeIdxKey newKeyUIncludeIdx = schema.getFactoryTSecGroupInclude()
            .newUIncludeIdxKey();
    newKeyUIncludeIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyUIncludeIdx.setRequiredTSecGroupId(Buff.getRequiredTSecGroupId());
    newKeyUIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId());

    // Check unique indexes

    if (!existingKeyUIncludeIdx.equals(newKeyUIncludeIdx)) {
        if (dictByUIncludeIdx.containsKey(newKeyUIncludeIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateTSecGroupInclude", "TSecGroupIncludeUIncludeIdx", newKeyUIncludeIdx);
        }
    }

    // Validate foreign keys

    {
        boolean allNull = true;

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

    {
        boolean allNull = true;

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

    // Update is valid

    SortedMap<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff> 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<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff>();
        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<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff>();
        dictByGroupIdx.put(newKeyGroupIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByIncludeIdx.get(existingKeyIncludeIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByIncludeIdx.containsKey(newKeyIncludeIdx)) {
        subdict = dictByIncludeIdx.get(newKeyIncludeIdx);
    } else {
        subdict = new TreeMap<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff>();
        dictByIncludeIdx.put(newKeyIncludeIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUIncludeIdx.remove(existingKeyUIncludeIdx);
    dictByUIncludeIdx.put(newKeyUIncludeIdx, Buff);

}

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

public void updateSecGroupInclude(CFAccAuthorization Authorization, CFAccSecGroupIncludeBuff Buff) {
    CFAccSecGroupIncludePKey pkey = schema.getFactorySecGroupInclude().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecGroupIncludeId(Buff.getRequiredSecGroupIncludeId());
    CFAccSecGroupIncludeBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                "updateSecGroupInclude", "Existing record not found", "SecGroupInclude", pkey);
    }/*from w ww .ja v a2  s . co m*/
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                "updateSecGroupInclude", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAccSecGroupIncludeByClusterIdxKey existingKeyClusterIdx = schema.getFactorySecGroupInclude()
            .newClusterIdxKey();
    existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFAccSecGroupIncludeByClusterIdxKey newKeyClusterIdx = schema.getFactorySecGroupInclude()
            .newClusterIdxKey();
    newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFAccSecGroupIncludeByGroupIdxKey existingKeyGroupIdx = schema.getFactorySecGroupInclude().newGroupIdxKey();
    existingKeyGroupIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());

    CFAccSecGroupIncludeByGroupIdxKey newKeyGroupIdx = schema.getFactorySecGroupInclude().newGroupIdxKey();
    newKeyGroupIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());

    CFAccSecGroupIncludeByIncludeIdxKey existingKeyIncludeIdx = schema.getFactorySecGroupInclude()
            .newIncludeIdxKey();
    existingKeyIncludeIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId());

    CFAccSecGroupIncludeByIncludeIdxKey newKeyIncludeIdx = schema.getFactorySecGroupInclude()
            .newIncludeIdxKey();
    newKeyIncludeIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId());

    CFAccSecGroupIncludeByUIncludeIdxKey existingKeyUIncludeIdx = schema.getFactorySecGroupInclude()
            .newUIncludeIdxKey();
    existingKeyUIncludeIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyUIncludeIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());
    existingKeyUIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId());

    CFAccSecGroupIncludeByUIncludeIdxKey newKeyUIncludeIdx = schema.getFactorySecGroupInclude()
            .newUIncludeIdxKey();
    newKeyUIncludeIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyUIncludeIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());
    newKeyUIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId());

    // Check unique indexes

    if (!existingKeyUIncludeIdx.equals(newKeyUIncludeIdx)) {
        if (dictByUIncludeIdx.containsKey(newKeyUIncludeIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateSecGroupInclude", "SecGroupIncludeUIncludeIdx", newKeyUIncludeIdx);
        }
    }

    // Validate foreign keys

    {
        boolean allNull = true;

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

    {
        boolean allNull = true;

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

    // Update is valid

    SortedMap<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff> 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<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff>();
        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<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff>();
        dictByGroupIdx.put(newKeyGroupIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByIncludeIdx.get(existingKeyIncludeIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByIncludeIdx.containsKey(newKeyIncludeIdx)) {
        subdict = dictByIncludeIdx.get(newKeyIncludeIdx);
    } else {
        subdict = new TreeMap<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff>();
        dictByIncludeIdx.put(newKeyIncludeIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUIncludeIdx.remove(existingKeyUIncludeIdx);
    dictByUIncludeIdx.put(newKeyUIncludeIdx, Buff);

}

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

public void updateSecGroupInclude(CFAstAuthorization Authorization, CFAstSecGroupIncludeBuff Buff) {
    CFAstSecGroupIncludePKey pkey = schema.getFactorySecGroupInclude().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecGroupIncludeId(Buff.getRequiredSecGroupIncludeId());
    CFAstSecGroupIncludeBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                "updateSecGroupInclude", "Existing record not found", "SecGroupInclude", pkey);
    }//from w ww .ja v  a 2 s  .  co m
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                "updateSecGroupInclude", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAstSecGroupIncludeByClusterIdxKey existingKeyClusterIdx = schema.getFactorySecGroupInclude()
            .newClusterIdxKey();
    existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFAstSecGroupIncludeByClusterIdxKey newKeyClusterIdx = schema.getFactorySecGroupInclude()
            .newClusterIdxKey();
    newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFAstSecGroupIncludeByGroupIdxKey existingKeyGroupIdx = schema.getFactorySecGroupInclude().newGroupIdxKey();
    existingKeyGroupIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());

    CFAstSecGroupIncludeByGroupIdxKey newKeyGroupIdx = schema.getFactorySecGroupInclude().newGroupIdxKey();
    newKeyGroupIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());

    CFAstSecGroupIncludeByIncludeIdxKey existingKeyIncludeIdx = schema.getFactorySecGroupInclude()
            .newIncludeIdxKey();
    existingKeyIncludeIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId());

    CFAstSecGroupIncludeByIncludeIdxKey newKeyIncludeIdx = schema.getFactorySecGroupInclude()
            .newIncludeIdxKey();
    newKeyIncludeIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId());

    CFAstSecGroupIncludeByUIncludeIdxKey existingKeyUIncludeIdx = schema.getFactorySecGroupInclude()
            .newUIncludeIdxKey();
    existingKeyUIncludeIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyUIncludeIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());
    existingKeyUIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId());

    CFAstSecGroupIncludeByUIncludeIdxKey newKeyUIncludeIdx = schema.getFactorySecGroupInclude()
            .newUIncludeIdxKey();
    newKeyUIncludeIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyUIncludeIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());
    newKeyUIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId());

    // Check unique indexes

    if (!existingKeyUIncludeIdx.equals(newKeyUIncludeIdx)) {
        if (dictByUIncludeIdx.containsKey(newKeyUIncludeIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateSecGroupInclude", "SecGroupIncludeUIncludeIdx", newKeyUIncludeIdx);
        }
    }

    // Validate foreign keys

    {
        boolean allNull = true;

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

    {
        boolean allNull = true;

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

    // Update is valid

    SortedMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff> 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<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff>();
        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<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff>();
        dictByGroupIdx.put(newKeyGroupIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByIncludeIdx.get(existingKeyIncludeIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByIncludeIdx.containsKey(newKeyIncludeIdx)) {
        subdict = dictByIncludeIdx.get(newKeyIncludeIdx);
    } else {
        subdict = new TreeMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff>();
        dictByIncludeIdx.put(newKeyIncludeIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUIncludeIdx.remove(existingKeyUIncludeIdx);
    dictByUIncludeIdx.put(newKeyUIncludeIdx, Buff);

}

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

public void updateService(CFAccAuthorization Authorization, CFAccServiceBuff Buff) {
    CFAccServicePKey pkey = schema.getFactoryService().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredServiceId(Buff.getRequiredServiceId());
    CFAccServiceBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateService",
                "Existing record not found", "Service", pkey);
    }//from  w  ww. ja  va  2  s. co m
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateService",
                pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAccServiceByClusterIdxKey existingKeyClusterIdx = schema.getFactoryService().newClusterIdxKey();
    existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

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

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

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

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

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

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

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

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

    CFAccServiceByUHostPortIdxKey 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<CFAccServicePKey, CFAccServiceBuff> 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<CFAccServicePKey, CFAccServiceBuff>();
        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<CFAccServicePKey, CFAccServiceBuff>();
        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<CFAccServicePKey, CFAccServiceBuff>();
        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.cfasterisk.v2_0.CFAstRam.CFAstRamServiceTable.java

public void updateService(CFAstAuthorization Authorization, CFAstServiceBuff Buff) {
    CFAstServicePKey pkey = schema.getFactoryService().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredServiceId(Buff.getRequiredServiceId());
    CFAstServiceBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateService",
                "Existing record not found", "Service", pkey);
    }//from  ww w . j  a v a  2s. c  om
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateService",
                pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAstServiceByClusterIdxKey existingKeyClusterIdx = schema.getFactoryService().newClusterIdxKey();
    existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

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

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

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

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

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

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

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

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

    CFAstServiceByUHostPortIdxKey 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<CFAstServicePKey, CFAstServiceBuff> 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<CFAstServicePKey, CFAstServiceBuff>();
        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<CFAstServicePKey, CFAstServiceBuff>();
        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<CFAstServicePKey, CFAstServiceBuff>();
        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.cfcrm.v2_0.CFCrmRam.CFCrmRamSecGroupFormTable.java

public void updateSecGroupForm(CFCrmAuthorization Authorization, CFCrmSecGroupFormBuff Buff) {
    CFCrmSecGroupFormPKey pkey = schema.getFactorySecGroupForm().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecGroupFormId(Buff.getRequiredSecGroupFormId());
    CFCrmSecGroupFormBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                "updateSecGroupForm", "Existing record not found", "SecGroupForm", pkey);
    }/*w w  w .  j  a v a  2  s  .co  m*/
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateSecGroupForm",
                pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFCrmSecGroupFormByClusterIdxKey existingKeyClusterIdx = schema.getFactorySecGroupForm().newClusterIdxKey();
    existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFCrmSecGroupFormByClusterIdxKey newKeyClusterIdx = schema.getFactorySecGroupForm().newClusterIdxKey();
    newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

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

    CFCrmSecGroupFormByGroupIdxKey newKeyGroupIdx = schema.getFactorySecGroupForm().newGroupIdxKey();
    newKeyGroupIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());

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

    CFCrmSecGroupFormByAppIdxKey newKeyAppIdx = schema.getFactorySecGroupForm().newAppIdxKey();
    newKeyAppIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyAppIdx.setRequiredSecAppId(Buff.getRequiredSecAppId());

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

    CFCrmSecGroupFormByFormIdxKey newKeyFormIdx = schema.getFactorySecGroupForm().newFormIdxKey();
    newKeyFormIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyFormIdx.setRequiredSecFormId(Buff.getRequiredSecFormId());

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

    CFCrmSecGroupFormByUFormIdxKey newKeyUFormIdx = schema.getFactorySecGroupForm().newUFormIdxKey();
    newKeyUFormIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyUFormIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());
    newKeyUFormIdx.setRequiredSecFormId(Buff.getRequiredSecFormId());

    // Check unique indexes

    if (!existingKeyUFormIdx.equals(newKeyUFormIdx)) {
        if (dictByUFormIdx.containsKey(newKeyUFormIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateSecGroupForm", "SecGroupFormUFormIdx", newKeyUFormIdx);
        }
    }

    // Validate foreign keys

    {
        boolean allNull = true;

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

    {
        boolean allNull = true;

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

    // Update is valid

    SortedMap<CFCrmSecGroupFormPKey, CFCrmSecGroupFormBuff> 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<CFCrmSecGroupFormPKey, CFCrmSecGroupFormBuff>();
        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<CFCrmSecGroupFormPKey, CFCrmSecGroupFormBuff>();
        dictByGroupIdx.put(newKeyGroupIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByAppIdx.get(existingKeyAppIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByAppIdx.containsKey(newKeyAppIdx)) {
        subdict = dictByAppIdx.get(newKeyAppIdx);
    } else {
        subdict = new TreeMap<CFCrmSecGroupFormPKey, CFCrmSecGroupFormBuff>();
        dictByAppIdx.put(newKeyAppIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByFormIdx.get(existingKeyFormIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByFormIdx.containsKey(newKeyFormIdx)) {
        subdict = dictByFormIdx.get(newKeyFormIdx);
    } else {
        subdict = new TreeMap<CFCrmSecGroupFormPKey, CFCrmSecGroupFormBuff>();
        dictByFormIdx.put(newKeyFormIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUFormIdx.remove(existingKeyUFormIdx);
    dictByUFormIdx.put(newKeyUFormIdx, Buff);

}

From source file:com.illustrationfinder.process.post.HtmlPostProcessor.java

@Override
public List<String> generateKeywords() {
    // TODO If two words are always close to each other, they should be considered as an expression and managed like one word
    if (this.url == null)
        return null;

    try {/*from w ww.  ja  v a 2 s . co m*/
        // Retrieve the document and store it temporary
        try (final InputStream stream = this.url.openStream()) {
            final String rawText = IOUtils.toString(stream);

            // Retrieve useful HTML data
            final Document document = Jsoup.parse(rawText);

            String htmlTitle = document.title();
            String htmlKeywords = document.select("meta[name=keywords]").text();
            String htmlDescription = document.select("meta[name=description]").text();

            // Extract the content of the raw text
            String content = ArticleExtractor.getInstance().getText(rawText);

            // Now we apply a simple algorithm to get keywords
            //  1) We remove all punctuation marks from the title
            //  2) We remove all words with less than 4 characters
            //  3) We remove excessive spacing and tabulations

            htmlTitle = htmlTitle.toLowerCase();
            htmlTitle = htmlTitle.replaceAll(PUNCTUATION_REGEX, "");
            htmlTitle = htmlTitle.replaceAll(WORD_WITH_LESS_THAN_4_CHARACTERS_REGEX, "");
            htmlTitle = htmlTitle.replaceAll(EXCESSIVE_SPACING_REGEX, " ");

            final List<String> keywords = new ArrayList<>();
            final List<String> keywordsList = Arrays.asList(htmlTitle.split(" "));
            for (String tmp : keywordsList) {
                if (tmp.length() >= MINIMUM_WORD_LENGTH) {
                    keywords.add(tmp);
                }
            }

            // If there is enough keywords, we return
            if (keywords.size() >= MINIMUM_KEYWORDS_COUNT) {
                return keywords;
            } else {
                // Otherwise, we look for more keywords from the text by taking the more frequent words
                content = content.toLowerCase();
                content = content.replaceAll(PUNCTUATION_REGEX, "");
                content = content.replaceAll(WORD_WITH_LESS_THAN_4_CHARACTERS_REGEX, "");
                content = content.replaceAll(EXCESSIVE_SPACING_REGEX, " ");

                final Map<String, Integer> frequencies = new HashMap<>();
                final String[] words = content.split(" ");

                // Count word frequencies
                for (final String word : words) {
                    if (frequencies.containsKey(word)) {
                        frequencies.put(word, frequencies.get(word) + 1);
                    } else {
                        frequencies.put(word, 1);
                    }
                }

                // Sort the words per frequency
                final SortedMap<Integer, HashSet<String>> sortedWords = new TreeMap<>();

                for (Map.Entry<String, Integer> entry : frequencies.entrySet()) {
                    if (sortedWords.containsKey(entry.getValue())) {
                        sortedWords.get(entry.getValue()).add(entry.getKey());
                    } else {
                        final HashSet<String> set = new HashSet<>();
                        set.add(entry.getKey());
                        sortedWords.put(entry.getValue(), set);
                    }
                }

                // Add the most frequent words until we reach the minimu keywords count
                while (keywords.size() < MINIMUM_KEYWORDS_COUNT) {
                    final HashSet<String> set = sortedWords.get(sortedWords.lastKey());
                    final String keyword = set.iterator().next();

                    set.remove(keyword);
                    if (set.size() == 0) {
                        sortedWords.remove(sortedWords.lastKey());
                    }

                    if (keyword.length() > MINIMUM_WORD_LENGTH) {
                        keywords.add(keyword);
                    }
                }

                return keywords;
            }
        }
    } catch (BoilerpipeProcessingException e) {
        // TODO
        e.printStackTrace();
    } catch (IOException e) {
        // TODO
        e.printStackTrace();
    }

    return null;
}

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

public void updateSecGroupForm(CFAccAuthorization Authorization, CFAccSecGroupFormBuff Buff) {
    CFAccSecGroupFormPKey pkey = schema.getFactorySecGroupForm().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecGroupFormId(Buff.getRequiredSecGroupFormId());
    CFAccSecGroupFormBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                "updateSecGroupForm", "Existing record not found", "SecGroupForm", pkey);
    }//from w w w .j ava 2  s .c  o m
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateSecGroupForm",
                pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAccSecGroupFormByClusterIdxKey existingKeyClusterIdx = schema.getFactorySecGroupForm().newClusterIdxKey();
    existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFAccSecGroupFormByClusterIdxKey newKeyClusterIdx = schema.getFactorySecGroupForm().newClusterIdxKey();
    newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

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

    CFAccSecGroupFormByGroupIdxKey newKeyGroupIdx = schema.getFactorySecGroupForm().newGroupIdxKey();
    newKeyGroupIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());

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

    CFAccSecGroupFormByAppIdxKey newKeyAppIdx = schema.getFactorySecGroupForm().newAppIdxKey();
    newKeyAppIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyAppIdx.setRequiredSecAppId(Buff.getRequiredSecAppId());

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

    CFAccSecGroupFormByFormIdxKey newKeyFormIdx = schema.getFactorySecGroupForm().newFormIdxKey();
    newKeyFormIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyFormIdx.setRequiredSecFormId(Buff.getRequiredSecFormId());

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

    CFAccSecGroupFormByUFormIdxKey newKeyUFormIdx = schema.getFactorySecGroupForm().newUFormIdxKey();
    newKeyUFormIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyUFormIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());
    newKeyUFormIdx.setRequiredSecFormId(Buff.getRequiredSecFormId());

    // Check unique indexes

    if (!existingKeyUFormIdx.equals(newKeyUFormIdx)) {
        if (dictByUFormIdx.containsKey(newKeyUFormIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateSecGroupForm", "SecGroupFormUFormIdx", newKeyUFormIdx);
        }
    }

    // Validate foreign keys

    {
        boolean allNull = true;

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

    {
        boolean allNull = true;

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

    // Update is valid

    SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff> 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<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff>();
        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<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff>();
        dictByGroupIdx.put(newKeyGroupIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByAppIdx.get(existingKeyAppIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByAppIdx.containsKey(newKeyAppIdx)) {
        subdict = dictByAppIdx.get(newKeyAppIdx);
    } else {
        subdict = new TreeMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff>();
        dictByAppIdx.put(newKeyAppIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByFormIdx.get(existingKeyFormIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByFormIdx.containsKey(newKeyFormIdx)) {
        subdict = dictByFormIdx.get(newKeyFormIdx);
    } else {
        subdict = new TreeMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff>();
        dictByFormIdx.put(newKeyFormIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUFormIdx.remove(existingKeyUFormIdx);
    dictByUFormIdx.put(newKeyUFormIdx, Buff);

}

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

public void updateSecGroupForm(CFAstAuthorization Authorization, CFAstSecGroupFormBuff Buff) {
    CFAstSecGroupFormPKey pkey = schema.getFactorySecGroupForm().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecGroupFormId(Buff.getRequiredSecGroupFormId());
    CFAstSecGroupFormBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                "updateSecGroupForm", "Existing record not found", "SecGroupForm", pkey);
    }// w  w w. j a v  a2  s  . com
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateSecGroupForm",
                pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAstSecGroupFormByClusterIdxKey existingKeyClusterIdx = schema.getFactorySecGroupForm().newClusterIdxKey();
    existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFAstSecGroupFormByClusterIdxKey newKeyClusterIdx = schema.getFactorySecGroupForm().newClusterIdxKey();
    newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

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

    CFAstSecGroupFormByGroupIdxKey newKeyGroupIdx = schema.getFactorySecGroupForm().newGroupIdxKey();
    newKeyGroupIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());

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

    CFAstSecGroupFormByAppIdxKey newKeyAppIdx = schema.getFactorySecGroupForm().newAppIdxKey();
    newKeyAppIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyAppIdx.setRequiredSecAppId(Buff.getRequiredSecAppId());

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

    CFAstSecGroupFormByFormIdxKey newKeyFormIdx = schema.getFactorySecGroupForm().newFormIdxKey();
    newKeyFormIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyFormIdx.setRequiredSecFormId(Buff.getRequiredSecFormId());

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

    CFAstSecGroupFormByUFormIdxKey newKeyUFormIdx = schema.getFactorySecGroupForm().newUFormIdxKey();
    newKeyUFormIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyUFormIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());
    newKeyUFormIdx.setRequiredSecFormId(Buff.getRequiredSecFormId());

    // Check unique indexes

    if (!existingKeyUFormIdx.equals(newKeyUFormIdx)) {
        if (dictByUFormIdx.containsKey(newKeyUFormIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "updateSecGroupForm", "SecGroupFormUFormIdx", newKeyUFormIdx);
        }
    }

    // Validate foreign keys

    {
        boolean allNull = true;

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

    {
        boolean allNull = true;

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

    // Update is valid

    SortedMap<CFAstSecGroupFormPKey, CFAstSecGroupFormBuff> 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<CFAstSecGroupFormPKey, CFAstSecGroupFormBuff>();
        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<CFAstSecGroupFormPKey, CFAstSecGroupFormBuff>();
        dictByGroupIdx.put(newKeyGroupIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByAppIdx.get(existingKeyAppIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByAppIdx.containsKey(newKeyAppIdx)) {
        subdict = dictByAppIdx.get(newKeyAppIdx);
    } else {
        subdict = new TreeMap<CFAstSecGroupFormPKey, CFAstSecGroupFormBuff>();
        dictByAppIdx.put(newKeyAppIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByFormIdx.get(existingKeyFormIdx);
    if (subdict != null) {
        subdict.remove(pkey);
    }
    if (dictByFormIdx.containsKey(newKeyFormIdx)) {
        subdict = dictByFormIdx.get(newKeyFormIdx);
    } else {
        subdict = new TreeMap<CFAstSecGroupFormPKey, CFAstSecGroupFormBuff>();
        dictByFormIdx.put(newKeyFormIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUFormIdx.remove(existingKeyUFormIdx);
    dictByUFormIdx.put(newKeyUFormIdx, Buff);

}