Example usage for java.util SortedMap put

List of usage examples for java.util SortedMap put

Introduction

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

Prototype

V put(K key, V value);

Source Link

Document

Associates the specified value with the specified key in this map (optional operation).

Usage

From source file:lti.LaunchRequest.java

public SortedMap<String, String> toSortedMap() {
    SortedMap<String, String> sm = new TreeMap<>();

    if (custom != null && !custom.isEmpty()) {
        Set<String> keys = custom.keySet();
        for (Map.Entry<String, String> entry : custom.entrySet()) {
            sm.put(entry.getKey(), entry.getValue());
        }/*from   w  ww. ja  v a  2 s.co  m*/
    }

    if (ext != null && !ext.isEmpty()) {
        Set<String> keys = ext.keySet();
        for (Map.Entry<String, String> entry : ext.entrySet()) {
            sm.put(entry.getKey(), entry.getValue());
        }
    }

    if (extra != null && !extra.isEmpty()) {
        Set<String> keys = extra.keySet();
        for (Map.Entry<String, String> entry : extra.entrySet()) {
            sm.put(entry.getKey(), entry.getValue());
        }
    }

    if (lti_message_type != null) {
        sm.put("lti_message_type", lti_message_type);
    }
    if (lti_version != null) {
        sm.put("lti_version", lti_version);
    }
    if (resource_link_id != null) {
        sm.put("resource_link_id", resource_link_id);
    }
    if (resource_link_title != null) {
        sm.put("resource_link_title", resource_link_title);
    }
    if (resource_link_description != null) {
        sm.put("resource_link_description", resource_link_description);
    }
    if (user_id != null) {
        sm.put("user_id", user_id);
    }
    if (user_image != null) {
        sm.put("user_image", user_image);
    }
    if (roles != null) {
        sm.put("roles", roles);
    }
    if (role_scope_mentor != null) {
        sm.put("role_scope_mentor", role_scope_mentor);
    }
    if (lis_person_name_given != null) {
        sm.put("lis_person_name_given", lis_person_name_given);
    }
    if (lis_person_name_family != null) {
        sm.put("lis_person_name_family", lis_person_name_family);
    }
    if (lis_person_name_full != null) {
        sm.put("lis_person_name_full", lis_person_name_full);
    }
    if (lis_person_contact_email_primary != null) {
        sm.put("lis_person_contact_email_primary", lis_person_contact_email_primary);
    }
    if (lis_outcome_service_url != null) {
        sm.put("lis_outcome_service_url", lis_outcome_service_url);
    }
    if (lis_result_sourcedid != null) {
        sm.put("lis_result_sourcedid", lis_result_sourcedid);
    }
    if (context_id != null) {
        sm.put("context_id", context_id);
    }
    if (context_type != null) {
        sm.put("context_type", context_type);
    }
    if (context_title != null) {
        sm.put("context_title", context_title);
    }
    if (context_label != null) {
        sm.put("context_label", context_label);
    }
    if (launch_presentation_locale != null) {
        sm.put("launch_presentation_locale", launch_presentation_locale);
    }
    if (launch_presentation_document_target != null) {
        sm.put("launch_presentation_document_target", launch_presentation_document_target);
    }
    if (launch_presentation_css_url != null) {
        sm.put("launch_presentation_css_url", launch_presentation_css_url);
    }
    if (launch_presentation_width != null) {
        sm.put("launch_presentation_width", launch_presentation_width);
    }
    if (launch_presentation_height != null) {
        sm.put("launch_presentation_height", launch_presentation_height);
    }
    if (launch_presentation_return_url != null) {
        sm.put("launch_presentation_return_url", launch_presentation_return_url);
    }
    if (tool_consumer_info_product_family_code != null) {
        sm.put("tool_consumer_info_product_family_code", tool_consumer_info_product_family_code);
    }
    if (tool_consumer_info_version != null) {
        sm.put("tool_consumer_info_version", tool_consumer_info_version);
    }
    if (tool_consumer_instance_guid != null) {
        sm.put("tool_consumer_instance_guid", tool_consumer_instance_guid);
    }
    if (tool_consumer_instance_name != null) {
        sm.put("tool_consumer_instance_name", tool_consumer_instance_name);
    }
    if (tool_consumer_instance_description != null) {
        sm.put("tool_consumer_instance_description", tool_consumer_instance_description);
    }
    if (tool_consumer_instance_url != null) {
        sm.put("tool_consumer_instance_url", tool_consumer_instance_url);
    }
    if (tool_consumer_instance_contact_email != null) {
        sm.put("tool_consumer_instance_contact_email", tool_consumer_instance_contact_email);
    }
    if (oauth_consumer_key != null) {
        sm.put("oauth_consumer_key", oauth_consumer_key);
    }
    if (oauth_signature_method != null) {
        sm.put("oauth_signature_method", oauth_signature_method);
    }
    if (oauth_timestamp != null) {
        sm.put("oauth_timestamp", oauth_timestamp);
    }
    if (oauth_nonce != null) {
        sm.put("oauth_nonce", oauth_nonce);
    }
    if (oauth_version != null) {
        sm.put("oauth_version", oauth_version);
    }
    if (oauth_signature != null) {
        sm.put("oauth_signature", oauth_signature);
    }
    if (oauth_callback != null) {
        sm.put("oauth_callback", oauth_callback);
    }

    return sm;
}

From source file:com.opengamma.integration.copier.portfolio.rowparser.JodaBeanRowParser.java

/**
 * Extract a map of column (field) names and types from the properties of the specified direct bean class.
 * Appropriate member classes (such as swap legs) are recursively traversed and their columns also extracted 
 * and added to the map./*  ww w  .j a va 2s  .c  o m*/
 * @param clazz   The bean type from which to extract properties
 * @param prefix  The class membership path traced from the top-level bean class to the current class
 * @return        A map of the column names and their types
 */
private SortedMap<String, Class<?>> recursiveGetColumnMap(Class<?> clazz, String prefix) {

    // Scan through and capture the list of relevant properties and their types
    SortedMap<String, Class<?>> columns = new TreeMap<String, Class<?>>();

    for (MetaProperty<?> metaProperty : JodaBeanUtils.metaBean(clazz).metaPropertyIterable()) {

        // Skip any undesired properties, process the rest
        if (!ignoreMetaProperty(metaProperty)) {

            // Add a column for the property (used either for the actual value
            // or for the class name in the case of a non-convertible bean
            columns.put(prefix + metaProperty.name(), metaProperty.propertyType());

            // If this is a bean without a converter recursively extract all 
            // columns for the metabean and all its subclasses
            if (isBean(metaProperty.propertyType()) && !isConvertible(metaProperty.propertyType())) {

                // This is the bean (might be an abstract class/subclassed)
                Class<? extends Bean> beanClass = metaProperty.propertyType().asSubclass(Bean.class);

                // Recursively extract this bean's properties
                columns.putAll(recursiveGetColumnMap(beanClass, prefix + metaProperty.name() + ":"));

                // Identify ALL subclasses of this bean and extract all their properties
                for (Class<?> subClass : getSubClasses(beanClass)) {
                    columns.putAll(recursiveGetColumnMap(subClass, prefix + metaProperty.name() + ":"));
                }
            }
        }
    }
    return columns;
}

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

public void createExtensionsConf(CFAstAuthorization Authorization, CFAstExtensionsConfBuff Buff) {
    schema.getTableConfigurationFile().createConfigurationFile(Authorization, Buff);
    CFAstConfigurationFilePKey pkey = schema.getFactoryConfigurationFile().newPKey();
    pkey.setClassCode(Buff.getClassCode());
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredId(Buff.getRequiredId());
    CFAstExtensionsConfByExtClusterIdxKey keyExtClusterIdx = schema.getFactoryExtensionsConf()
            .newExtClusterIdxKey();/*  ww  w  .  java 2  s.c  o m*/
    keyExtClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
        throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(),
                "createExtensionsConf", pkey);
    }

    // Validate foreign keys

    {
        boolean allNull = true;
        allNull = false;
        allNull = false;
        if (!allNull) {
            if (null == schema.getTableConfigurationFile().readDerivedByIdIdx(Authorization,
                    Buff.getRequiredClusterId(), Buff.getRequiredId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "createExtensionsConf", "Superclass", "SuperClass", "ConfigurationFile", null);
            }
        }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    SortedMap<CFAstConfigurationFilePKey, CFAstExtensionsConfBuff> subdictExtClusterIdx;
    if (dictByExtClusterIdx.containsKey(keyExtClusterIdx)) {
        subdictExtClusterIdx = dictByExtClusterIdx.get(keyExtClusterIdx);
    } else {
        subdictExtClusterIdx = new TreeMap<CFAstConfigurationFilePKey, CFAstExtensionsConfBuff>();
        dictByExtClusterIdx.put(keyExtClusterIdx, subdictExtClusterIdx);
    }
    subdictExtClusterIdx.put(pkey, Buff);

}

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

public void createAsteriskConf(CFAstAuthorization Authorization, CFAstAsteriskConfBuff Buff) {
    schema.getTableConfigurationFile().createConfigurationFile(Authorization, Buff);
    CFAstConfigurationFilePKey pkey = schema.getFactoryConfigurationFile().newPKey();
    pkey.setClassCode(Buff.getClassCode());
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredId(Buff.getRequiredId());
    CFAstAsteriskConfByConfClusterIdxKey keyConfClusterIdx = schema.getFactoryAsteriskConf()
            .newConfClusterIdxKey();/*from  www.  j  av  a  2 s.co  m*/
    keyConfClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
        throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createAsteriskConf",
                pkey);
    }

    // Validate foreign keys

    {
        boolean allNull = true;
        allNull = false;
        allNull = false;
        if (!allNull) {
            if (null == schema.getTableConfigurationFile().readDerivedByIdIdx(Authorization,
                    Buff.getRequiredClusterId(), Buff.getRequiredId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "createAsteriskConf", "Superclass", "SuperClass", "ConfigurationFile", null);
            }
        }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    SortedMap<CFAstConfigurationFilePKey, CFAstAsteriskConfBuff> subdictConfClusterIdx;
    if (dictByConfClusterIdx.containsKey(keyConfClusterIdx)) {
        subdictConfClusterIdx = dictByConfClusterIdx.get(keyConfClusterIdx);
    } else {
        subdictConfClusterIdx = new TreeMap<CFAstConfigurationFilePKey, CFAstAsteriskConfBuff>();
        dictByConfClusterIdx.put(keyConfClusterIdx, subdictConfClusterIdx);
    }
    subdictConfClusterIdx.put(pkey, Buff);

}

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

public void createMemo(CFAccAuthorization Authorization, CFAccMemoBuff Buff) {
    CFAccMemoPKey pkey = schema.getFactoryMemo().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredMemoId(((CFAccRamTenantTable) schema.getTableTenant()).nextMemoIdGen(Authorization,
            Buff.getRequiredTenantId()));
    Buff.setRequiredTenantId(pkey.getRequiredTenantId());
    Buff.setRequiredMemoId(pkey.getRequiredMemoId());
    CFAccMemoByTenantIdxKey keyTenantIdx = schema.getFactoryMemo().newTenantIdxKey();
    keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFAccMemoByMemoContactIdxKey keyMemoContactIdx = schema.getFactoryMemo().newMemoContactIdxKey();
    keyMemoContactIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    keyMemoContactIdx.setRequiredContactId(Buff.getRequiredContactId());

    CFAccMemoByUDescrIdxKey keyUDescrIdx = schema.getFactoryMemo().newUDescrIdxKey();
    keyUDescrIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    keyUDescrIdx.setRequiredContactId(Buff.getRequiredContactId());
    keyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
        throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createMemo", pkey);
    }/*from w  w w  . j a  va  2s. c o m*/

    if (dictByUDescrIdx.containsKey(keyUDescrIdx)) {
        throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createMemo",
                "MemoUDescrIdx", keyUDescrIdx);
    }

    // Validate foreign keys

    {
        boolean allNull = true;
        allNull = false;
        if (!allNull) {
            if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "createMemo", "Owner", "MemoTenant", "Tenant", null);
            }
        }
    }

    {
        boolean allNull = true;
        allNull = false;
        allNull = false;
        if (!allNull) {
            if (null == schema.getTableContact().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId(),
                    Buff.getRequiredContactId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "createMemo", "Container", "MemoContact", "Contact", null);
            }
        }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    SortedMap<CFAccMemoPKey, CFAccMemoBuff> subdictTenantIdx;
    if (dictByTenantIdx.containsKey(keyTenantIdx)) {
        subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx);
    } else {
        subdictTenantIdx = new TreeMap<CFAccMemoPKey, CFAccMemoBuff>();
        dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx);
    }
    subdictTenantIdx.put(pkey, Buff);

    SortedMap<CFAccMemoPKey, CFAccMemoBuff> subdictMemoContactIdx;
    if (dictByMemoContactIdx.containsKey(keyMemoContactIdx)) {
        subdictMemoContactIdx = dictByMemoContactIdx.get(keyMemoContactIdx);
    } else {
        subdictMemoContactIdx = new TreeMap<CFAccMemoPKey, CFAccMemoBuff>();
        dictByMemoContactIdx.put(keyMemoContactIdx, subdictMemoContactIdx);
    }
    subdictMemoContactIdx.put(pkey, Buff);

    dictByUDescrIdx.put(keyUDescrIdx, Buff);

}

From source file:net.sourceforge.fenixedu.presentationTier.Action.scientificCouncil.credits.ViewTeacherCreditsReportDispatchAction.java

private void setTotals(HttpServletRequest request, ExecutionYear untilExecutionYear,
        SortedMap<Department, Map<ExecutionYear, PeriodCreditsReportDTO>> departmentTotalCredits) {

    int totalTeachersSize = 0, totalCareerTeachersSize = 0, totalNotCareerTeachersSize = 0;
    SortedMap<ExecutionYear, GenericPair<Double, GenericPair<Double, Double>>> executionYearTotals = new TreeMap<ExecutionYear, GenericPair<Double, GenericPair<Double, Double>>>(
            ExecutionYear.COMPARATOR_BY_YEAR);
    for (Department department : departmentTotalCredits.keySet()) {
        for (ExecutionYear executionYear : departmentTotalCredits.get(department).keySet()) {
            if (!executionYearTotals.containsKey(executionYear)) {
                executionYearTotals.put(executionYear, new GenericPair(0.0, new GenericPair(0.0, 0.0)));
            }/* w ww .  j  a  v a  2  s  . c  om*/

            GenericPair genericPair = executionYearTotals.get(executionYear);
            genericPair.setLeft(round(departmentTotalCredits.get(department).get(executionYear).getCredits()
                    + executionYearTotals.get(executionYear).getLeft()));
            ((GenericPair) genericPair.getRight()).setLeft(round(
                    departmentTotalCredits.get(department).get(executionYear).getCareerCategoryTeacherCredits()
                            + executionYearTotals.get(executionYear).getRight().getLeft()));
            ((GenericPair) genericPair.getRight()).setRight(round(departmentTotalCredits.get(department)
                    .get(executionYear).getNotCareerCategoryTeacherCredits()
                    + executionYearTotals.get(executionYear).getRight().getRight()));

            if (executionYear.equals(untilExecutionYear)) {
                totalTeachersSize += departmentTotalCredits.get(department).get(executionYear)
                        .getTeachersSize();
                totalCareerTeachersSize += departmentTotalCredits.get(department).get(executionYear)
                        .getCareerTeachersSize();
                totalNotCareerTeachersSize += departmentTotalCredits.get(department).get(executionYear)
                        .getNotCareerTeachersSize();
            }
        }
    }

    request.setAttribute("totalCareerTeachersSize", totalCareerTeachersSize);
    request.setAttribute("totalNotCareerTeachersSize", totalNotCareerTeachersSize);
    request.setAttribute("totalCareerTeachersBalance",
            round(executionYearTotals.get(untilExecutionYear).getRight().getLeft() / totalCareerTeachersSize));
    request.setAttribute("totalNotCareerTeachersBalance", round(
            executionYearTotals.get(untilExecutionYear).getRight().getRight() / totalNotCareerTeachersSize));
    request.setAttribute("totalBalance",
            round(executionYearTotals.get(untilExecutionYear).getLeft() / totalTeachersSize));
    request.setAttribute("totalTeachersSize", totalTeachersSize);
    request.setAttribute("executionYearTotals", executionYearTotals);
}

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

public void createTenant(CFAccAuthorization Authorization, CFAccTenantBuff Buff) {
    CFAccTenantPKey pkey = schema.getFactoryTenant().newPKey();
    pkey.setRequiredId(schema.nextTenantIdGen());
    Buff.setRequiredId(pkey.getRequiredId());
    CFAccTenantByClusterIdxKey keyClusterIdx = schema.getFactoryTenant().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFAccTenantByUNameIdxKey keyUNameIdx = schema.getFactoryTenant().newUNameIdxKey();
    keyUNameIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyUNameIdx.setRequiredTenantName(Buff.getRequiredTenantName());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
        throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createTenant", pkey);
    }//from w  w  w . j  a va2  s  .c o m

    if (dictByUNameIdx.containsKey(keyUNameIdx)) {
        throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createTenant",
                "TenantUNameIdx", keyUNameIdx);
    }

    // Validate foreign keys

    {
        boolean allNull = true;
        allNull = false;
        if (!allNull) {
            if (null == schema.getTableCluster().readDerivedByIdIdx(Authorization,
                    Buff.getRequiredClusterId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "createTenant", "Container", "TenantCluster", "Cluster", null);
            }
        }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    SortedMap<CFAccTenantPKey, CFAccTenantBuff> subdictClusterIdx;
    if (dictByClusterIdx.containsKey(keyClusterIdx)) {
        subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx);
    } else {
        subdictClusterIdx = new TreeMap<CFAccTenantPKey, CFAccTenantBuff>();
        dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx);
    }
    subdictClusterIdx.put(pkey, Buff);

    dictByUNameIdx.put(keyUNameIdx, Buff);

}

From source file:de.appsolve.padelcampus.controller.events.EventsController.java

private ModelAndView getGroupGameView(Long eventId, Integer roundNumber) {
    Event event = eventDAO.findByIdFetchWithGames(eventId);
    if (event == null) {
        throw new ResourceNotFoundException();
    }// w w  w.  j a va2  s .c om
    ModelAndView mav = new ModelAndView("events/groupknockout/groupgames", "Model", event);

    event = eventDAO.findByIdFetchWithGames(eventId);
    SortedMap<Integer, List<Game>> groupGameMap = eventsUtil.getGroupGameMap(event, roundNumber);
    SortedMap<Integer, List<Game>> roundGameMap;

    if (roundNumber == null) {
        roundGameMap = eventsUtil.getRoundGameMap(event);
    } else {
        roundGameMap = eventsUtil.getRoundGameMap(event, roundNumber + 1);
    }

    //Group // Participant // Game // GameResult
    SortedMap<Integer, Map<Participant, Map<Game, String>>> groupParticipantGameResultMap = new TreeMap<>();

    Iterator<Map.Entry<Integer, List<Game>>> iterator = groupGameMap.entrySet().iterator();
    while (iterator.hasNext()) {
        Map.Entry<Integer, List<Game>> entry = iterator.next();
        Map<Participant, Map<Game, String>> participantGameResultMap = gameUtil
                .getParticipantGameResultMap(entry.getValue(), false);
        Integer group = entry.getKey();
        groupParticipantGameResultMap.put(group, participantGameResultMap);
    }
    mav.addObject("GroupParticipantGameResultMap", groupParticipantGameResultMap);
    mav.addObject("RoundGameMap", roundGameMap);
    mav.addObject("Round", roundNumber);
    mav.addObject("GameResultMap", gameUtil.getGameResultMap(event.getGames()));
    return mav;
}

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

public void createSecForm(CFCrmAuthorization Authorization, CFCrmSecFormBuff Buff) {
    CFCrmSecFormPKey pkey = schema.getFactorySecForm().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecFormId(((CFCrmRamClusterTable) schema.getTableCluster()).nextSecFormIdGen(Authorization,
            Buff.getRequiredClusterId()));
    Buff.setRequiredClusterId(pkey.getRequiredClusterId());
    Buff.setRequiredSecFormId(pkey.getRequiredSecFormId());
    CFCrmSecFormByClusterIdxKey keyClusterIdx = schema.getFactorySecForm().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFCrmSecFormBySecAppIdxKey keySecAppIdx = schema.getFactorySecForm().newSecAppIdxKey();
    keySecAppIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keySecAppIdx.setRequiredSecAppId(Buff.getRequiredSecAppId());

    CFCrmSecFormByUJEEServletIdxKey keyUJEEServletIdx = schema.getFactorySecForm().newUJEEServletIdxKey();
    keyUJEEServletIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyUJEEServletIdx.setRequiredSecAppId(Buff.getRequiredSecAppId());
    keyUJEEServletIdx.setRequiredJEEServletMapName(Buff.getRequiredJEEServletMapName());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
        throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createSecForm",
                pkey);/* w w w . ja  v  a2s .c o  m*/
    }

    if (dictByUJEEServletIdx.containsKey(keyUJEEServletIdx)) {
        throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createSecForm",
                "SecFormUJEEServletIdx", keyUJEEServletIdx);
    }

    // Validate foreign keys

    {
        boolean allNull = true;
        allNull = false;
        if (!allNull) {
            if (null == schema.getTableCluster().readDerivedByIdIdx(Authorization,
                    Buff.getRequiredClusterId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "createSecForm", "Owner", "SecFormCluster", "Cluster", null);
            }
        }
    }

    {
        boolean allNull = true;
        allNull = false;
        allNull = false;
        if (!allNull) {
            if (null == schema.getTableSecApp().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId(),
                    Buff.getRequiredSecAppId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "createSecForm", "Container", "SecFormApplication", "SecApp", null);
            }
        }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    SortedMap<CFCrmSecFormPKey, CFCrmSecFormBuff> subdictClusterIdx;
    if (dictByClusterIdx.containsKey(keyClusterIdx)) {
        subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx);
    } else {
        subdictClusterIdx = new TreeMap<CFCrmSecFormPKey, CFCrmSecFormBuff>();
        dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx);
    }
    subdictClusterIdx.put(pkey, Buff);

    SortedMap<CFCrmSecFormPKey, CFCrmSecFormBuff> subdictSecAppIdx;
    if (dictBySecAppIdx.containsKey(keySecAppIdx)) {
        subdictSecAppIdx = dictBySecAppIdx.get(keySecAppIdx);
    } else {
        subdictSecAppIdx = new TreeMap<CFCrmSecFormPKey, CFCrmSecFormBuff>();
        dictBySecAppIdx.put(keySecAppIdx, subdictSecAppIdx);
    }
    subdictSecAppIdx.put(pkey, Buff);

    dictByUJEEServletIdx.put(keyUJEEServletIdx, Buff);

}

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

public void updateTld(CFAccAuthorization Authorization, CFAccTldBuff Buff) {
    CFAccTldPKey pkey = schema.getFactoryTld().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredTLDId(Buff.getRequiredTLDId());
    CFAccTldBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
        throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateTld",
                "Existing record not found", "Tld", pkey);
    }//from ww w . j  av  a 2s.  c om
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
        throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateTld", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAccTldByTenantIdxKey existingKeyTenantIdx = schema.getFactoryTld().newTenantIdxKey();
    existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId());

    CFAccTldByTenantIdxKey newKeyTenantIdx = schema.getFactoryTld().newTenantIdxKey();
    newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFAccTldByNameIdxKey existingKeyNameIdx = schema.getFactoryTld().newNameIdxKey();
    existingKeyNameIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyNameIdx.setRequiredName(existing.getRequiredName());

    CFAccTldByNameIdxKey newKeyNameIdx = schema.getFactoryTld().newNameIdxKey();
    newKeyNameIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyNameIdx.setRequiredName(Buff.getRequiredName());

    // Check unique indexes

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

    // Validate foreign keys

    {
        boolean allNull = true;

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

    // Update is valid

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

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

}