List of usage examples for java.util SortedMap put
V put(K key, V value);
From source file:net.sourceforge.msscodefactory.cfgcash.v2_0.CFGCashXMsgRspnHandler.CFGCashXMsgRspnAttachmentRecHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {// w w w .j a va 2 s . com // Common XML Attributes String attrId = null; String attrRevision = null; // Attachment Attributes String attrTenantId = null; String attrAttachmentId = null; String attrContactId = null; String attrDescription = null; String attrMimeTypeId = null; String attrAttachment = null; String attrCreatedAt = null; String attrCreatedBy = null; String attrUpdatedAt = null; String attrUpdatedBy = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("Attachment"); CFGCashXMsgRspnHandler xmsgRspnHandler = (CFGCashXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFGCashSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Extract Attributes numAttrs = attrs.getLength(); for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) { attrLocalName = attrs.getLocalName(idxAttr); if (attrLocalName.equals("Id")) { if (attrId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Revision")) { if (attrRevision != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRevision = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CreatedAt")) { if (attrCreatedAt != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCreatedAt = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CreatedBy")) { if (attrCreatedBy != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCreatedBy = attrs.getValue(idxAttr); } else if (attrLocalName.equals("UpdatedAt")) { if (attrUpdatedAt != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrUpdatedAt = attrs.getValue(idxAttr); } else if (attrLocalName.equals("UpdatedBy")) { if (attrUpdatedBy != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrUpdatedBy = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TenantId")) { if (attrTenantId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("AttachmentId")) { if (attrAttachmentId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrAttachmentId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ContactId")) { if (attrContactId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrContactId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Description")) { if (attrDescription != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDescription = attrs.getValue(idxAttr); } else if (attrLocalName.equals("MimeTypeId")) { if (attrMimeTypeId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrMimeTypeId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Attachment")) { if (attrAttachment != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrAttachment = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values if ((attrTenantId == null) || (attrTenantId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "TenantId"); } if ((attrAttachmentId == null) || (attrAttachmentId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "AttachmentId"); } if ((attrContactId == null) || (attrContactId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ContactId"); } if (attrDescription == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Description"); } if (attrAttachment == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Attachment"); } // Save named attributes to context CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext(); // Convert string attributes to native Java types long natTenantId = Long.parseLong(attrTenantId); long natAttachmentId = Long.parseLong(attrAttachmentId); long natContactId = Long.parseLong(attrContactId); String natDescription = attrDescription; Integer natMimeTypeId; if ((attrMimeTypeId == null) || (attrMimeTypeId.length() <= 0)) { natMimeTypeId = null; } else { natMimeTypeId = new Integer(Integer.parseInt(attrMimeTypeId)); } String natAttachment = attrAttachment; int natRevision = Integer.parseInt(attrRevision); UUID createdBy = null; if (attrCreatedBy != null) { createdBy = UUID.fromString(attrCreatedBy); } Calendar createdAt = null; if (attrCreatedAt != null) { createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt); } UUID updatedBy = null; if (attrUpdatedBy != null) { updatedBy = UUID.fromString(attrUpdatedBy); } Calendar updatedAt = null; if (attrUpdatedAt != null) { updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt); } // Get the parent context CFLibXmlCoreContext parentContext = curContext.getPrevContext(); // Instantiate a buffer for the parsed information ICFGCashAttachmentObj obj = schemaObj.getAttachmentTableObj().newInstance(); CFGCashAttachmentBuff dataBuff = obj.getAttachmentBuff(); dataBuff.setRequiredTenantId(natTenantId); dataBuff.setRequiredAttachmentId(natAttachmentId); dataBuff.setRequiredContactId(natContactId); dataBuff.setRequiredDescription(natDescription); dataBuff.setOptionalMimeTypeId(natMimeTypeId); dataBuff.setRequiredAttachment(natAttachment); dataBuff.setRequiredRevision(natRevision); if (createdBy != null) { dataBuff.setCreatedByUserId(createdBy); } if (createdAt != null) { dataBuff.setCreatedAt(createdAt); } if (updatedBy != null) { dataBuff.setUpdatedByUserId(updatedBy); } if (updatedAt != null) { dataBuff.setUpdatedAt(updatedAt); } obj.copyBuffToPKey(); SortedMap<CFGCashAttachmentPKey, ICFGCashAttachmentObj> sortedMap = (SortedMap<CFGCashAttachmentPKey, ICFGCashAttachmentObj>) xmsgRspnHandler .getSortedMapOfObjects(); ICFGCashAttachmentObj realized = (ICFGCashAttachmentObj) obj.realize(); xmsgRspnHandler.setLastObjectProcessed(realized); if (sortedMap != null) { sortedMap.put(realized.getPKey(), realized); } } catch (RuntimeException e) { throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew " + e.getClass().getName() + " - " + e.getMessage(), e); } catch (Error e) { throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew " + e.getClass().getName() + " - " + e.getMessage(), e); } }
From source file:com.aurel.track.fieldType.runtime.matchers.converter.CompositSelectMatcherConverter.java
/** * Convert a string to object value// w ww. java 2s . c om * By changing the matcherID for a field expression locally * (not after submitting a form). The reason for this is to maintain the existing * value if the new matcher is "compatible" with the old matcher * @param valueString * @param locale * @param matcherRelation * @return */ @Override public Object fromValueString(String valueString, Locale locale, Integer matcherRelation) { SortedMap<Integer, Object> actualValuesMap = null; if (matcherRelation != null) { switch (matcherRelation.intValue()) { case MatchRelations.EQUAL: case MatchRelations.NOT_EQUAL: case MatchRelations.PARTIAL_MATCH: case MatchRelations.PARTIAL_NOTMATCH: if (valueString != null && !"".equals(valueString)) { actualValuesMap = new TreeMap<Integer, Object>(); String[] parts = valueString.split(","); for (int i = 0; i < parts.length; i++) { try { actualValuesMap.put(Integer.valueOf(i + 1), new Integer[] { Integer.valueOf(parts[i]) }); } catch (Exception e) { LOGGER.warn("Converting the " + i + 1 + "th part to Integer from value string failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } } } } return actualValuesMap; }
From source file:de.micromata.genome.gwiki.plugin.rogmp3_1_0.Mp3Db.java
public SortedMap<String, Integer> getComposersCountries() { SortedMap<String, Integer> ret = new TreeMap<String, Integer>(); for (String[] comp : composers.table) { Composer cp = new Composer(this, comp); String rcountry = cp.get(Composer.COUNTRY); List<String> ccl = Arrays.asList(StringUtils.split(rcountry, ";")); for (String country : ccl) { Integer c = ret.get(country); if (c == null) { ret.put(country, 1); } else { ret.put(country, c + 1); }/* w ww . j av a2s .c o m*/ } } return ret; }
From source file:net.sourceforge.msscodefactory.cfcore.v1_11.GenKbRam.GenKbRamSecGroupTable.java
public void createSecGroup(GenKbAuthorization Authorization, GenKbSecGroupBuff Buff) { GenKbSecGroupPKey pkey = schema.getFactorySecGroup().newPKey(); pkey.setRequiredSecGroupId(schema.nextSecGroupIdGen()); Buff.setRequiredSecGroupId(pkey.getRequiredSecGroupId()); GenKbSecGroupByClusterIdxKey keyClusterIdx = schema.getFactorySecGroup().newClusterIdxKey(); keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); GenKbSecGroupByUNameIdxKey keyUNameIdx = schema.getFactorySecGroup().newUNameIdxKey(); keyUNameIdx.setRequiredClusterId(Buff.getRequiredClusterId()); keyUNameIdx.setRequiredName(Buff.getRequiredName()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createSecGroup", pkey);/*ww w .jav a 2 s .co m*/ } if (dictByUNameIdx.containsKey(keyUNameIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createSecGroup", "SecGroupUNameIdx", keyUNameIdx); } // Validate foreign keys { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema.getTableCluster().readDerivedByPIdx(Authorization, Buff.getRequiredClusterId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createSecGroup", "Container", "SecGroupCluster", "Cluster", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); SortedMap<GenKbSecGroupPKey, GenKbSecGroupBuff> subdictClusterIdx; if (dictByClusterIdx.containsKey(keyClusterIdx)) { subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx); } else { subdictClusterIdx = new TreeMap<GenKbSecGroupPKey, GenKbSecGroupBuff>(); dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx); } subdictClusterIdx.put(pkey, Buff); dictByUNameIdx.put(keyUNameIdx, Buff); }
From source file:be.shad.tsqb.test.SelectTests.java
private void selectMapsDtoTest(boolean aliases) { TestDataCreator creator = new TestDataCreator(getSessionFactory()); creator.createTestPerson(creator.createTestTown(), "Josh"); ((TypeSafeRootQueryInternal) query).getProjections().setIncludeAliases(aliases); Person person = query.from(Person.class); MapsDto dtoPx = query.select(MapsDto.class); Map<String, Object> genericMapPx = dtoPx.getNestedMaps().getGenericMap(); CustomMap<String, Object> customMapPx = dtoPx.getNestedMaps().getCustomMap(); SortedMap<String, Object> sortedMapPx = dtoPx.getSortedMap(); genericMapPx.put("person.value", person.getName()); customMapPx.put("person.object", person); sortedMapPx.put("person.transformed", query.select(String.class, person.getName(), new SelectionValueTransformer<String, String>() { @Override//from ww w . java 2 s . com public String convert(String name) throws SelectionValueTransformerException { return "###" + name + "###"; } })); // subselect map Map<String, Object> merge1 = query.selectMergeValues(dtoPx, new MapSelectionMerger<MapsDto, String, Object>() { @Override public void mergeMapIntoResult(MapsDto partialResult, Map<String, Object> map) { partialResult.getSortedMap().put("thepersonid", map.get("person.id")); } }); merge1.put("person.id", person.getId()); if (aliases) { validate("select hobj1.name as nestedMaps_genericMap_person_value, " + "hobj1 as nestedMaps_customMap_person_object, " + "hobj1.name as sortedMap_person_transformed, " + "hobj1.id as g1__person_id " + "from Person hobj1"); } else { validate("select hobj1.name, hobj1, hobj1.name, hobj1.id from Person hobj1"); } assertTrue(MapsDto.class.isAssignableFrom(doQueryResult.get(0).getClass())); MapsDto result = (MapsDto) doQueryResult.get(0); Map<String, Object> genericMap = result.getNestedMaps().getGenericMap(); CustomMap<String, Object> customMap = result.getNestedMaps().getCustomMap(); SortedMap<String, Object> sortedMap = result.getSortedMap(); assertEquals("Josh", genericMap.get("person.value")); assertEquals("###Josh###", sortedMap.get("person.transformed")); assertTrue(Person.class.isAssignableFrom(customMap.get("person.object").getClass())); assertNotNull(sortedMap.get("thepersonid")); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgRspnHandler.CFAccXMsgRspnAccountRecHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/*from ww w. j a v a2 s . c o m*/ // Common XML Attributes String attrId = null; String attrRevision = null; // Account Attributes String attrTenantId = null; String attrAccountCode = null; String attrDescription = null; String attrCurrencyId = null; String attrBalance = null; String attrRollupTenantId = null; String attrRollupAccountId = null; String attrCreatedAt = null; String attrCreatedBy = null; String attrUpdatedAt = null; String attrUpdatedBy = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("Account"); CFAccXMsgRspnHandler xmsgRspnHandler = (CFAccXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFAccSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Extract Attributes numAttrs = attrs.getLength(); for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) { attrLocalName = attrs.getLocalName(idxAttr); if (attrLocalName.equals("Id")) { if (attrId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Revision")) { if (attrRevision != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRevision = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CreatedAt")) { if (attrCreatedAt != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCreatedAt = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CreatedBy")) { if (attrCreatedBy != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCreatedBy = attrs.getValue(idxAttr); } else if (attrLocalName.equals("UpdatedAt")) { if (attrUpdatedAt != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrUpdatedAt = attrs.getValue(idxAttr); } else if (attrLocalName.equals("UpdatedBy")) { if (attrUpdatedBy != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrUpdatedBy = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TenantId")) { if (attrTenantId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("AccountCode")) { if (attrAccountCode != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrAccountCode = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Description")) { if (attrDescription != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDescription = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CurrencyId")) { if (attrCurrencyId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCurrencyId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Balance")) { if (attrBalance != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrBalance = attrs.getValue(idxAttr); } else if (attrLocalName.equals("RollupTenantId")) { if (attrRollupTenantId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRollupTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("RollupAccountId")) { if (attrRollupAccountId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRollupAccountId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values if ((attrTenantId == null) || (attrTenantId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "TenantId"); } if ((attrId == null) || (attrId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Id"); } if (attrAccountCode == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "AccountCode"); } if (attrDescription == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Description"); } if ((attrCurrencyId == null) || (attrCurrencyId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "CurrencyId"); } if ((attrBalance == null) || (attrBalance.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Balance"); } // Save named attributes to context CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext(); // Convert string attributes to native Java types long natTenantId = Long.parseLong(attrTenantId); long natId = Long.parseLong(attrId); String natAccountCode = attrAccountCode; String natDescription = attrDescription; short natCurrencyId = Short.parseShort(attrCurrencyId); BigDecimal natBalance = new BigDecimal(attrBalance); Long natRollupTenantId; if ((attrRollupTenantId == null) || (attrRollupTenantId.length() <= 0)) { natRollupTenantId = null; } else { natRollupTenantId = new Long(Long.parseLong(attrRollupTenantId)); } Long natRollupAccountId; if ((attrRollupAccountId == null) || (attrRollupAccountId.length() <= 0)) { natRollupAccountId = null; } else { natRollupAccountId = new Long(Long.parseLong(attrRollupAccountId)); } int natRevision = Integer.parseInt(attrRevision); UUID createdBy = null; if (attrCreatedBy != null) { createdBy = UUID.fromString(attrCreatedBy); } Calendar createdAt = null; if (attrCreatedAt != null) { createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt); } UUID updatedBy = null; if (attrUpdatedBy != null) { updatedBy = UUID.fromString(attrUpdatedBy); } Calendar updatedAt = null; if (attrUpdatedAt != null) { updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt); } // Get the parent context CFLibXmlCoreContext parentContext = curContext.getPrevContext(); // Instantiate a buffer for the parsed information ICFAccAccountObj obj = schemaObj.getAccountTableObj().newInstance(); CFAccAccountBuff dataBuff = obj.getAccountBuff(); dataBuff.setRequiredTenantId(natTenantId); dataBuff.setRequiredId(natId); dataBuff.setRequiredAccountCode(natAccountCode); dataBuff.setRequiredDescription(natDescription); dataBuff.setRequiredCurrencyId(natCurrencyId); dataBuff.setRequiredBalance(natBalance); dataBuff.setOptionalRollupTenantId(natRollupTenantId); dataBuff.setOptionalRollupAccountId(natRollupAccountId); dataBuff.setRequiredRevision(natRevision); if (createdBy != null) { dataBuff.setCreatedByUserId(createdBy); } if (createdAt != null) { dataBuff.setCreatedAt(createdAt); } if (updatedBy != null) { dataBuff.setUpdatedByUserId(updatedBy); } if (updatedAt != null) { dataBuff.setUpdatedAt(updatedAt); } obj.copyBuffToPKey(); SortedMap<CFAccAccountPKey, ICFAccAccountObj> sortedMap = (SortedMap<CFAccAccountPKey, ICFAccAccountObj>) xmsgRspnHandler .getSortedMapOfObjects(); ICFAccAccountObj realized = (ICFAccAccountObj) obj.realize(); xmsgRspnHandler.setLastObjectProcessed(realized); if (sortedMap != null) { sortedMap.put(realized.getPKey(), realized); } } catch (RuntimeException e) { throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew " + e.getClass().getName() + " - " + e.getMessage(), e); } catch (Error e) { throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew " + e.getClass().getName() + " - " + e.getMessage(), e); } }
From source file:edu.brown.benchmark.BenchmarkResults.java
BenchmarkResults copy() { BenchmarkResults clone = new BenchmarkResults(m_pollIntervalInMillis, m_durationInMillis, m_clientCount); clone.m_basePartitions.putHistogram(m_basePartitions); clone.m_errors.addAll(m_errors);/* ww w . java 2 s. com*/ clone.m_transactionNames.addAll(m_transactionNames); clone.completedIntervals = this.completedIntervals; clone.clientResultCount.putHistogram(this.clientResultCount); for (Entry<String, SortedMap<String, List<Result>>> entry : m_data.entrySet()) { SortedMap<String, List<Result>> txnsForClient = new TreeMap<String, List<Result>>(); for (Entry<String, List<Result>> entry2 : entry.getValue().entrySet()) { ArrayList<Result> newResults = new ArrayList<Result>(); for (Result r : entry2.getValue()) newResults.add(r); txnsForClient.put(entry2.getKey(), newResults); } clone.m_data.put(entry.getKey(), txnsForClient); } return clone; }
From source file:fr.mycellar.interfaces.web.services.nav.NavigationWebService.java
@PostConstruct public void build() { ResourceBundle resourceBundle = ResourceBundle.getBundle("Menu", Locale.FRENCH); List<IDescriptor> descriptors = descriptorServiceFacade.getDescriptors(); SortedMap<Integer, NavDescriptor> menuPages = new TreeMap<Integer, NavDescriptor>(); for (IDescriptor descriptor : descriptors) { if (descriptor instanceof IMenuDescriptor) { IMenuDescriptor menuDescriptor = ((IMenuDescriptor) descriptor); if (menuDescriptor.getParentKey() != null) { NavHeaderDescriptor header = getHeader(resourceBundle.getString(menuDescriptor.getParentKey()), menuPages);/* www . j a va2 s . com*/ if (header == null) { header = new NavHeaderDescriptor(resourceBundle.getString(menuDescriptor.getParentKey()), menuDescriptor.getIcon()); menuPages.put(menuDescriptor.getWeight(), header); } header.addPage(menuDescriptor.getWeight(), new NavPageDescriptor(menuDescriptor.getRoute(), resourceBundle.getString(menuDescriptor.getTitleKey()), menuDescriptor.getIcon())); } else { menuPages.put(menuDescriptor.getWeight(), new NavPageDescriptor(menuDescriptor.getRoute(), resourceBundle.getString(menuDescriptor.getTitleKey()), menuDescriptor.getIcon())); } } } menu = new ArrayList<NavDescriptor>(menuPages.values()); }
From source file:net.sourceforge.msscodefactory.cfgcash.v2_0.CFGCashXMsgRspnHandler.CFGCashXMsgRspnAccountRecHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/*from w w w . j a v a2 s . co m*/ // Common XML Attributes String attrId = null; String attrRevision = null; // Account Attributes String attrTenantId = null; String attrAccountCode = null; String attrDescription = null; String attrCurrencyId = null; String attrBalance = null; String attrRollupTenantId = null; String attrRollupAccountId = null; String attrCreatedAt = null; String attrCreatedBy = null; String attrUpdatedAt = null; String attrUpdatedBy = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("Account"); CFGCashXMsgRspnHandler xmsgRspnHandler = (CFGCashXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFGCashSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Extract Attributes numAttrs = attrs.getLength(); for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) { attrLocalName = attrs.getLocalName(idxAttr); if (attrLocalName.equals("Id")) { if (attrId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Revision")) { if (attrRevision != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRevision = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CreatedAt")) { if (attrCreatedAt != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCreatedAt = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CreatedBy")) { if (attrCreatedBy != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCreatedBy = attrs.getValue(idxAttr); } else if (attrLocalName.equals("UpdatedAt")) { if (attrUpdatedAt != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrUpdatedAt = attrs.getValue(idxAttr); } else if (attrLocalName.equals("UpdatedBy")) { if (attrUpdatedBy != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrUpdatedBy = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TenantId")) { if (attrTenantId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("AccountCode")) { if (attrAccountCode != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrAccountCode = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Description")) { if (attrDescription != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDescription = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CurrencyId")) { if (attrCurrencyId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCurrencyId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Balance")) { if (attrBalance != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrBalance = attrs.getValue(idxAttr); } else if (attrLocalName.equals("RollupTenantId")) { if (attrRollupTenantId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRollupTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("RollupAccountId")) { if (attrRollupAccountId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRollupAccountId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values if ((attrTenantId == null) || (attrTenantId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "TenantId"); } if ((attrId == null) || (attrId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Id"); } if (attrAccountCode == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "AccountCode"); } if (attrDescription == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Description"); } if ((attrCurrencyId == null) || (attrCurrencyId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "CurrencyId"); } if ((attrBalance == null) || (attrBalance.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Balance"); } // Save named attributes to context CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext(); // Convert string attributes to native Java types long natTenantId = Long.parseLong(attrTenantId); long natId = Long.parseLong(attrId); String natAccountCode = attrAccountCode; String natDescription = attrDescription; short natCurrencyId = Short.parseShort(attrCurrencyId); BigDecimal natBalance = new BigDecimal(attrBalance); Long natRollupTenantId; if ((attrRollupTenantId == null) || (attrRollupTenantId.length() <= 0)) { natRollupTenantId = null; } else { natRollupTenantId = new Long(Long.parseLong(attrRollupTenantId)); } Long natRollupAccountId; if ((attrRollupAccountId == null) || (attrRollupAccountId.length() <= 0)) { natRollupAccountId = null; } else { natRollupAccountId = new Long(Long.parseLong(attrRollupAccountId)); } int natRevision = Integer.parseInt(attrRevision); UUID createdBy = null; if (attrCreatedBy != null) { createdBy = UUID.fromString(attrCreatedBy); } Calendar createdAt = null; if (attrCreatedAt != null) { createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt); } UUID updatedBy = null; if (attrUpdatedBy != null) { updatedBy = UUID.fromString(attrUpdatedBy); } Calendar updatedAt = null; if (attrUpdatedAt != null) { updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt); } // Get the parent context CFLibXmlCoreContext parentContext = curContext.getPrevContext(); // Instantiate a buffer for the parsed information ICFGCashAccountObj obj = schemaObj.getAccountTableObj().newInstance(); CFGCashAccountBuff dataBuff = obj.getAccountBuff(); dataBuff.setRequiredTenantId(natTenantId); dataBuff.setRequiredId(natId); dataBuff.setRequiredAccountCode(natAccountCode); dataBuff.setRequiredDescription(natDescription); dataBuff.setRequiredCurrencyId(natCurrencyId); dataBuff.setRequiredBalance(natBalance); dataBuff.setOptionalRollupTenantId(natRollupTenantId); dataBuff.setOptionalRollupAccountId(natRollupAccountId); dataBuff.setRequiredRevision(natRevision); if (createdBy != null) { dataBuff.setCreatedByUserId(createdBy); } if (createdAt != null) { dataBuff.setCreatedAt(createdAt); } if (updatedBy != null) { dataBuff.setUpdatedByUserId(updatedBy); } if (updatedAt != null) { dataBuff.setUpdatedAt(updatedAt); } obj.copyBuffToPKey(); SortedMap<CFGCashAccountPKey, ICFGCashAccountObj> sortedMap = (SortedMap<CFGCashAccountPKey, ICFGCashAccountObj>) xmsgRspnHandler .getSortedMapOfObjects(); ICFGCashAccountObj realized = (ICFGCashAccountObj) obj.realize(); xmsgRspnHandler.setLastObjectProcessed(realized); if (sortedMap != null) { sortedMap.put(realized.getPKey(), realized); } } catch (RuntimeException e) { throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew " + e.getClass().getName() + " - " + e.getMessage(), e); } catch (Error e) { throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew " + e.getClass().getName() + " - " + e.getMessage(), e); } }
From source file:com.revetkn.ios.analyzer.ArtworkAnalyzer.java
protected void detectImageMetrics(ApplicationArtwork applicationArtwork) throws IOException { SortedMap<File, ImageMetrics> allImageFilesWithMetrics = new TreeMap<File, ImageMetrics>(); double sizeOfAllImagesFilesInBytes = 0; for (File imageFile : applicationArtwork.getAllImageFiles()) { byte[] imageData = readFileToByteArray(imageFile); sizeOfAllImagesFilesInBytes += imageData.length; allImageFilesWithMetrics.put(imageFile, ImageUtilities.extractImageMetrics(imageData)); }/*from w ww . j a va 2s .c o m*/ applicationArtwork.setAllImageFilesWithMetrics(allImageFilesWithMetrics); applicationArtwork.setSizeOfAllImagesFilesInBytes(sizeOfAllImagesFilesInBytes); }