List of usage examples for java.util SortedMap put
V put(K key, V value);
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam.CFAstRamTldTable.java
public void updateTld(CFAstAuthorization Authorization, CFAstTldBuff Buff) { CFAstTldPKey pkey = schema.getFactoryTld().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredTLDId(Buff.getRequiredTLDId()); CFAstTldBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateTld", "Existing record not found", "Tld", pkey); }//from www . ja v a2 s. c om if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateTld", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); CFAstTldByTenantIdxKey existingKeyTenantIdx = schema.getFactoryTld().newTenantIdxKey(); existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId()); CFAstTldByTenantIdxKey newKeyTenantIdx = schema.getFactoryTld().newTenantIdxKey(); newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId()); CFAstTldByNameIdxKey existingKeyNameIdx = schema.getFactoryTld().newNameIdxKey(); existingKeyNameIdx.setRequiredTenantId(existing.getRequiredTenantId()); existingKeyNameIdx.setRequiredName(existing.getRequiredName()); CFAstTldByNameIdxKey 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<CFAstTldPKey, CFAstTldBuff> 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<CFAstTldPKey, CFAstTldBuff>(); dictByTenantIdx.put(newKeyTenantIdx, subdict); } subdict.put(pkey, Buff); dictByNameIdx.remove(existingKeyNameIdx); dictByNameIdx.put(newKeyNameIdx, Buff); }
From source file:com.aurel.track.fieldType.runtime.custom.select.CustomSelectSimpleRT.java
/** * Loads the datasource and value for configuring the field change * @param workflowContext/*from ww w .j a v a 2s . co m*/ * @param fieldChangeValue * @param parameterCode * @param personBean * @param locale */ @Override public void loadFieldChangeDatasourceAndValue(WorkflowContext workflowContext, FieldChangeValue fieldChangeValue, Integer parameterCode, TPersonBean personBean, Locale locale) { TFieldConfigBean configItem = (TFieldConfigBean) FieldConfigItemFacade.getInstance().getValidConfigDirect( workflowContext.getItemTypeID(), workflowContext.getProjectTypeID(), workflowContext.getProjectID(), fieldChangeValue.getFieldID()); if (configItem == null) { configItem = (TFieldConfigBean) FieldConfigItemFacade.getInstance().getValidConfigFallback( workflowContext.getItemTypeID(), workflowContext.getProjectTypeID(), workflowContext.getProjectID(), fieldChangeValue.getFieldID()); } List<ILabelBean> dataSource = null; if (configItem != null) { dataSource = loadList(configItem.getObjectID(), locale); } Object actualValue = fieldChangeValue.getValue(); if (parameterCode == null) { //dataSourceMap.put(listID, optionList); fieldChangeValue.setPossibleValues(dataSource); //not a composite select //for multiple select there is no need to preselect some value Integer[] actualIntArrValue = (Integer[]) actualValue; actualIntArrValue = super.getBulkSelectValue(null, fieldChangeValue.getFieldID(), parameterCode, actualIntArrValue, (List) dataSource); fieldChangeValue.setValue(actualIntArrValue); } else { //first part of a composite part SortedMap<Integer, List<IBeanID>> listDatasourceMap = (SortedMap<Integer, List<IBeanID>>) fieldChangeValue .getPossibleValues(); //Map<Integer, List<IBeanID>> listDatasourceMap = new TreeMap<Integer, List<IBeanID>>(); //dataSourceMap.put(listID, listDatasourceMap); listDatasourceMap.put(parameterCode, (List) dataSource); SortedMap<Integer, Integer[]> actualValueMap = (SortedMap<Integer, Integer[]>) fieldChangeValue .getValue(); Integer[] actualIntArrValue = null; if (actualValueMap == null) { //no submitted value (by first rendering null anyway) actualValueMap = new TreeMap<Integer, Integer[]>(); fieldChangeValue.setValue(actualValueMap); //valueMap.put(listID, actualValueMap); } else { //submitted value: get to see whether it is still valid actualIntArrValue = actualValueMap.get(parameterCode); } actualValueMap.put(parameterCode, getBulkSelectValue(null, fieldChangeValue.getFieldID(), parameterCode, actualIntArrValue, (List) dataSource)); } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamDomainBaseTable.java
public void updateDomainBase(CFAccAuthorization Authorization, CFAccDomainBaseBuff Buff) { CFAccDomainBasePKey pkey = schema.getFactoryDomainBase().newPKey(); pkey.setClassCode(Buff.getClassCode()); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredId(Buff.getRequiredId()); CFAccDomainBaseBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateDomainBase", "Existing record not found", "DomainBase", pkey); }/*from www. j ava2 s . co m*/ if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateDomainBase", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); CFAccDomainBaseByTenantIdxKey existingKeyTenantIdx = schema.getFactoryDomainBase().newTenantIdxKey(); existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId()); CFAccDomainBaseByTenantIdxKey newKeyTenantIdx = schema.getFactoryDomainBase().newTenantIdxKey(); newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId()); // Check unique indexes // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateDomainBase", "Owner", "Tenant", "Tenant", null); } } } // Update is valid SortedMap<CFAccDomainBasePKey, CFAccDomainBaseBuff> 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<CFAccDomainBasePKey, CFAccDomainBaseBuff>(); dictByTenantIdx.put(newKeyTenantIdx, subdict); } subdict.put(pkey, Buff); }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam.CFAstRamDomainBaseTable.java
public void updateDomainBase(CFAstAuthorization Authorization, CFAstDomainBaseBuff Buff) { CFAstDomainBasePKey pkey = schema.getFactoryDomainBase().newPKey(); pkey.setClassCode(Buff.getClassCode()); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredId(Buff.getRequiredId()); CFAstDomainBaseBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateDomainBase", "Existing record not found", "DomainBase", pkey); }// w w w . j a v a 2 s . com if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateDomainBase", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); CFAstDomainBaseByTenantIdxKey existingKeyTenantIdx = schema.getFactoryDomainBase().newTenantIdxKey(); existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId()); CFAstDomainBaseByTenantIdxKey newKeyTenantIdx = schema.getFactoryDomainBase().newTenantIdxKey(); newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId()); // Check unique indexes // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateDomainBase", "Owner", "Tenant", "Tenant", null); } } } // Update is valid SortedMap<CFAstDomainBasePKey, CFAstDomainBaseBuff> 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<CFAstDomainBasePKey, CFAstDomainBaseBuff>(); dictByTenantIdx.put(newKeyTenantIdx, subdict); } subdict.put(pkey, Buff); }
From source file:org.lmnl.xml.XMLImportHandlerTest.java
@Test public void showTextContents() throws IOException { final String resource = "george-algabal-tei.xml"; //final String resource = "homer-iliad-tei.xml"; final Text source = source(resource); final Text document = document(resource); final int textLength = textRepository.length(document); assertTrue(textLength > 0);//from ww w .ja v a 2s . c o m if (LOG.isDebugEnabled()) { final SortedMap<String, Annotation> annotations = Maps.newTreeMap(); for (Annotation annotation : annotationRepository.find(document)) { final Object data = annotation.getData(); if (data == null || !Map.class.isAssignableFrom(data.getClass())) { LOG.debug(annotation + " has no attributes"); continue; } @SuppressWarnings("unchecked") final Map<QName, String> attrs = (Map<QName, String>) data; final String nodePath = attrs.get(XMLParser.NODE_PATH_NAME); if (nodePath == null) { LOG.debug(annotation + " has no XML node path"); continue; } if (annotations.containsKey(nodePath)) { LOG.debug(nodePath + " already assigned to " + annotations.get(nodePath)); } annotations.put(nodePath, annotation); } for (Map.Entry<String, Annotation> annotation : annotations.entrySet()) { LOG.debug(annotation.getKey() + " ==> " + annotation.getValue()); } if (LOG.isDebugEnabled()) { textRepository.read(document, new TextContentReader() { public void read(Reader content, int contentLength) throws IOException { LOG.debug(CharStreams.toString(content)); } }); } final List<Range> textRanges = Lists.newArrayList(); final List<Range> sourceRanges = Lists.newArrayList(); for (Annotation offset : annotationRepository.find(document, OFFSET_DELTA_NAME)) { textRanges.add(offset.getRange()); sourceRanges.add((Range) offset.getData()); } final SortedMap<Range, String> texts = textRepository.bulkRead(document, Sets.newTreeSet(textRanges)); final SortedMap<Range, String> sources = textRepository.bulkRead(source, Sets.newTreeSet(sourceRanges)); final Iterator<Range> sourceRangesIt = sourceRanges.iterator(); for (Range textRange : textRanges) { if (!sourceRangesIt.hasNext()) { break; } final Range sourceRange = sourceRangesIt.next(); //LOG.debug(textRange + " ==> " + sourceRange); LOG.debug(texts.get(textRange) + " ==> " + sources.get(sourceRange)); } } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamTagTable.java
public void updateTag(CFAccAuthorization Authorization, CFAccTagBuff Buff) { CFAccTagPKey pkey = schema.getFactoryTag().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredId(Buff.getRequiredId()); CFAccTagBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateTag", "Existing record not found", "Tag", pkey); }/*from www . j a v a 2s . co m*/ if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateTag", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); CFAccTagByTenantIdxKey existingKeyTenantIdx = schema.getFactoryTag().newTenantIdxKey(); existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId()); CFAccTagByTenantIdxKey newKeyTenantIdx = schema.getFactoryTag().newTenantIdxKey(); newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId()); CFAccTagByNameIdxKey existingKeyNameIdx = schema.getFactoryTag().newNameIdxKey(); existingKeyNameIdx.setRequiredTenantId(existing.getRequiredTenantId()); existingKeyNameIdx.setRequiredName(existing.getRequiredName()); CFAccTagByNameIdxKey newKeyNameIdx = schema.getFactoryTag().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(), "updateTag", "TagNameIdx", newKeyNameIdx); } } // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateTag", "Container", "TagTenant", "Tenant", null); } } } // Update is valid SortedMap<CFAccTagPKey, CFAccTagBuff> 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<CFAccTagPKey, CFAccTagBuff>(); dictByTenantIdx.put(newKeyTenantIdx, subdict); } subdict.put(pkey, Buff); dictByNameIdx.remove(existingKeyNameIdx); dictByNameIdx.put(newKeyNameIdx, Buff); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamSecFormTable.java
public void createSecForm(CFAccAuthorization Authorization, CFAccSecFormBuff Buff) { CFAccSecFormPKey pkey = schema.getFactorySecForm().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecFormId(((CFAccRamClusterTable) schema.getTableCluster()).nextSecFormIdGen(Authorization, Buff.getRequiredClusterId())); Buff.setRequiredClusterId(pkey.getRequiredClusterId()); Buff.setRequiredSecFormId(pkey.getRequiredSecFormId()); CFAccSecFormByClusterIdxKey keyClusterIdx = schema.getFactorySecForm().newClusterIdxKey(); keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); CFAccSecFormBySecAppIdxKey keySecAppIdx = schema.getFactorySecForm().newSecAppIdxKey(); keySecAppIdx.setRequiredClusterId(Buff.getRequiredClusterId()); keySecAppIdx.setRequiredSecAppId(Buff.getRequiredSecAppId()); CFAccSecFormByUJEEServletIdxKey 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);/*from w w w. ja v a 2 s .com*/ } 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<CFAccSecFormPKey, CFAccSecFormBuff> subdictClusterIdx; if (dictByClusterIdx.containsKey(keyClusterIdx)) { subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx); } else { subdictClusterIdx = new TreeMap<CFAccSecFormPKey, CFAccSecFormBuff>(); dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx); } subdictClusterIdx.put(pkey, Buff); SortedMap<CFAccSecFormPKey, CFAccSecFormBuff> subdictSecAppIdx; if (dictBySecAppIdx.containsKey(keySecAppIdx)) { subdictSecAppIdx = dictBySecAppIdx.get(keySecAppIdx); } else { subdictSecAppIdx = new TreeMap<CFAccSecFormPKey, CFAccSecFormBuff>(); dictBySecAppIdx.put(keySecAppIdx, subdictSecAppIdx); } subdictSecAppIdx.put(pkey, Buff); dictByUJEEServletIdx.put(keyUJEEServletIdx, Buff); }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam.CFAstRamSecFormTable.java
public void createSecForm(CFAstAuthorization Authorization, CFAstSecFormBuff Buff) { CFAstSecFormPKey pkey = schema.getFactorySecForm().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecFormId(((CFAstRamClusterTable) schema.getTableCluster()).nextSecFormIdGen(Authorization, Buff.getRequiredClusterId())); Buff.setRequiredClusterId(pkey.getRequiredClusterId()); Buff.setRequiredSecFormId(pkey.getRequiredSecFormId()); CFAstSecFormByClusterIdxKey keyClusterIdx = schema.getFactorySecForm().newClusterIdxKey(); keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); CFAstSecFormBySecAppIdxKey keySecAppIdx = schema.getFactorySecForm().newSecAppIdxKey(); keySecAppIdx.setRequiredClusterId(Buff.getRequiredClusterId()); keySecAppIdx.setRequiredSecAppId(Buff.getRequiredSecAppId()); CFAstSecFormByUJEEServletIdxKey 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 . j a va 2s . 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<CFAstSecFormPKey, CFAstSecFormBuff> subdictClusterIdx; if (dictByClusterIdx.containsKey(keyClusterIdx)) { subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx); } else { subdictClusterIdx = new TreeMap<CFAstSecFormPKey, CFAstSecFormBuff>(); dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx); } subdictClusterIdx.put(pkey, Buff); SortedMap<CFAstSecFormPKey, CFAstSecFormBuff> subdictSecAppIdx; if (dictBySecAppIdx.containsKey(keySecAppIdx)) { subdictSecAppIdx = dictBySecAppIdx.get(keySecAppIdx); } else { subdictSecAppIdx = new TreeMap<CFAstSecFormPKey, CFAstSecFormBuff>(); dictBySecAppIdx.put(keySecAppIdx, subdictSecAppIdx); } subdictSecAppIdx.put(pkey, Buff); dictByUJEEServletIdx.put(keyUJEEServletIdx, Buff); }
From source file:com.jnj.b2b.core.search.solrfacetsearch.provider.impl.FirstVariantCategoryNameListValueProvider.java
/** * Add first level category from {@code variant} to {@code categoryValues}. If there is already a first level * category with higher precedence, nothing is added. * * @param categoryValues// w ww . j a v a 2 s . c o m * The map to be populated. * @param variant * The variant that contains the categories. */ protected void addCategories( final SortedMap<VariantValueCategoryModel, GenericVariantProductModel> categoryValues, final GenericVariantProductModel variant) { final List<VariantValueCategoryModel> currentCategoryValues = getVariantList(variant); if (!currentCategoryValues.isEmpty()) { boolean addCurrent = false; // if there is already a similar entry, check if current variant has higher priority final GenericVariantProductModel oldVariant = categoryValues.get(currentCategoryValues.get(0)); if (oldVariant != null) { final List<VariantValueCategoryModel> oldCategoryValues = getVariantList(oldVariant); if (!oldCategoryValues.isEmpty()) { addCurrent = isCurrentListPrecedent(currentCategoryValues, oldCategoryValues); } } else { addCurrent = true; } if (addCurrent) { categoryValues.put(currentCategoryValues.get(0), variant); } } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamMemoTagTable.java
public void createMemoTag(CFAccAuthorization Authorization, CFAccMemoTagBuff Buff) { CFAccMemoTagPKey pkey = schema.getFactoryMemoTag().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredMemoId(Buff.getRequiredMemoId()); pkey.setRequiredTagId(Buff.getRequiredTagId()); Buff.setRequiredTenantId(pkey.getRequiredTenantId()); Buff.setRequiredMemoId(pkey.getRequiredMemoId()); Buff.setRequiredTagId(pkey.getRequiredTagId()); CFAccMemoTagByTenantIdxKey keyTenantIdx = schema.getFactoryMemoTag().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId()); CFAccMemoTagByMemoIdxKey keyMemoIdx = schema.getFactoryMemoTag().newMemoIdxKey(); keyMemoIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyMemoIdx.setRequiredMemoId(Buff.getRequiredMemoId()); CFAccMemoTagByTagIdxKey keyTagIdx = schema.getFactoryMemoTag().newTagIdxKey(); keyTagIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyTagIdx.setRequiredTagId(Buff.getRequiredTagId()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createMemoTag", pkey);/*from w ww . ja va2 s . c om*/ } // Validate foreign keys { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createMemoTag", "Owner", "MemoTagTenant", "Tenant", null); } } } { boolean allNull = true; allNull = false; allNull = false; if (!allNull) { if (null == schema.getTableMemo().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId(), Buff.getRequiredMemoId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createMemoTag", "Container", "MemoTagMemo", "Memo", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); SortedMap<CFAccMemoTagPKey, CFAccMemoTagBuff> subdictTenantIdx; if (dictByTenantIdx.containsKey(keyTenantIdx)) { subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx); } else { subdictTenantIdx = new TreeMap<CFAccMemoTagPKey, CFAccMemoTagBuff>(); dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx); } subdictTenantIdx.put(pkey, Buff); SortedMap<CFAccMemoTagPKey, CFAccMemoTagBuff> subdictMemoIdx; if (dictByMemoIdx.containsKey(keyMemoIdx)) { subdictMemoIdx = dictByMemoIdx.get(keyMemoIdx); } else { subdictMemoIdx = new TreeMap<CFAccMemoTagPKey, CFAccMemoTagBuff>(); dictByMemoIdx.put(keyMemoIdx, subdictMemoIdx); } subdictMemoIdx.put(pkey, Buff); SortedMap<CFAccMemoTagPKey, CFAccMemoTagBuff> subdictTagIdx; if (dictByTagIdx.containsKey(keyTagIdx)) { subdictTagIdx = dictByTagIdx.get(keyTagIdx); } else { subdictTagIdx = new TreeMap<CFAccMemoTagPKey, CFAccMemoTagBuff>(); dictByTagIdx.put(keyTagIdx, subdictTagIdx); } subdictTagIdx.put(pkey, Buff); }