List of usage examples for java.util SortedMap put
V put(K key, V value);
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamContactTagTable.java
public void createContactTag(CFAccAuthorization Authorization, CFAccContactTagBuff Buff) { CFAccContactTagPKey pkey = schema.getFactoryContactTag().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredContactId(Buff.getRequiredContactId()); pkey.setRequiredTagId(Buff.getRequiredTagId()); Buff.setRequiredTenantId(pkey.getRequiredTenantId()); Buff.setRequiredContactId(pkey.getRequiredContactId()); Buff.setRequiredTagId(pkey.getRequiredTagId()); CFAccContactTagByTenantIdxKey keyTenantIdx = schema.getFactoryContactTag().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId()); CFAccContactTagByContactIdxKey keyContactIdx = schema.getFactoryContactTag().newContactIdxKey(); keyContactIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyContactIdx.setRequiredContactId(Buff.getRequiredContactId()); CFAccContactTagByTagIdxKey keyTagIdx = schema.getFactoryContactTag().newTagIdxKey(); keyTagIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyTagIdx.setRequiredTagId(Buff.getRequiredTagId()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createContactTag", pkey);/*from w ww . j a v a2 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(), "createContactTag", "Owner", "ContactTagTenant", "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(), "createContactTag", "Container", "ContactTagContact", "Contact", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); SortedMap<CFAccContactTagPKey, CFAccContactTagBuff> subdictTenantIdx; if (dictByTenantIdx.containsKey(keyTenantIdx)) { subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx); } else { subdictTenantIdx = new TreeMap<CFAccContactTagPKey, CFAccContactTagBuff>(); dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx); } subdictTenantIdx.put(pkey, Buff); SortedMap<CFAccContactTagPKey, CFAccContactTagBuff> subdictContactIdx; if (dictByContactIdx.containsKey(keyContactIdx)) { subdictContactIdx = dictByContactIdx.get(keyContactIdx); } else { subdictContactIdx = new TreeMap<CFAccContactTagPKey, CFAccContactTagBuff>(); dictByContactIdx.put(keyContactIdx, subdictContactIdx); } subdictContactIdx.put(pkey, Buff); SortedMap<CFAccContactTagPKey, CFAccContactTagBuff> subdictTagIdx; if (dictByTagIdx.containsKey(keyTagIdx)) { subdictTagIdx = dictByTagIdx.get(keyTagIdx); } else { subdictTagIdx = new TreeMap<CFAccContactTagPKey, CFAccContactTagBuff>(); dictByTagIdx.put(keyTagIdx, subdictTagIdx); } subdictTagIdx.put(pkey, Buff); }
From source file:guru.nidi.languager.PropertiesFinder.java
public SortedMap<String, Message> findProperties() throws IOException { SortedMap<String, Message> messages = new TreeMap<>(); PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); for (String propertyLocation : propertyLocations) { Resource[] resources = resolver.getResources(propertyLocation + "*" + PROPERTIES); for (Resource resource : resources) { String lang = resource.getFilename(); lang = lang.substring(Math.max(0, lang.length() - 20), lang.length() - PROPERTIES.length()); int pos = lang.indexOf('_'); if (pos < 0) { lang = ""; } else { lang = lang.substring(pos + 1); }/* www . j a v a2 s. co m*/ Properties props = new Properties(); props.load(resource.getInputStream()); for (String name : props.stringPropertyNames()) { Message message = messages.get(name); if (message == null) { message = new Message(name, FOUND, null); messages.put(name, message); } message.addValue(lang, props.getProperty(name)); } } } return messages; }
From source file:com.hp.hpl.jena.n3.N3JenaWriterPP.java
@Override protected ClosableIterator<Property> preparePropertiesForSubject(Resource r) { Set<Property> seen = new HashSet<>(); boolean hasTypes = false; SortedMap<String, Property> tmp1 = new TreeMap<>(); SortedMap<String, Property> tmp2 = new TreeMap<>(); StmtIterator sIter = r.listProperties(); for (; sIter.hasNext();) { Property p = sIter.nextStatement().getPredicate(); if (seen.contains(p)) continue; seen.add(p);//from w w w. jav a 2 s . c o m if (p.equals(RDF.type)) { hasTypes = true; continue; } if (p.getURI().startsWith(RDF.getURI()) || p.getURI().startsWith(RDFS.getURI())) { tmp1.put(p.getURI(), p); continue; } tmp2.put(p.getURI(), p); } sIter.close(); ExtendedIterator<Property> eIter = null; if (hasTypes) eIter = new SingletonIterator<>(RDF.type); ExtendedIterator<Property> eIter2 = WrappedIterator.create(tmp1.values().iterator()); eIter = (eIter == null) ? eIter2 : eIter.andThen(eIter2); eIter2 = WrappedIterator.create(tmp2.values().iterator()); eIter = (eIter == null) ? eIter2 : eIter.andThen(eIter2); return eIter; }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamAccountContactTable.java
public void createAccountContact(CFAccAuthorization Authorization, CFAccAccountContactBuff Buff) { CFAccAccountContactPKey pkey = schema.getFactoryAccountContact().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredAccountId(Buff.getRequiredAccountId()); Buff.setRequiredTenantId(pkey.getRequiredTenantId()); Buff.setRequiredAccountId(pkey.getRequiredAccountId()); CFAccAccountContactByTenantIdxKey keyTenantIdx = schema.getFactoryAccountContact().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId()); CFAccAccountContactByCtctLstIdxKey keyCtctLstIdx = schema.getFactoryAccountContact().newCtctLstIdxKey(); keyCtctLstIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyCtctLstIdx.setRequiredContactListId(Buff.getRequiredContactListId()); CFAccAccountContactByCtctIdxKey keyCtctIdx = schema.getFactoryAccountContact().newCtctIdxKey(); keyCtctIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyCtctIdx.setRequiredContactId(Buff.getRequiredContactId()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createAccountContact", pkey); }/*from w w w. ja v a 2 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(), "createAccountContact", "Owner", "Tenant", "Tenant", null); } } } { boolean allNull = true; allNull = false; allNull = false; if (!allNull) { if (null == schema.getTableAccount().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId(), Buff.getRequiredAccountId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createAccountContact", "Container", "Account", "Account", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); SortedMap<CFAccAccountContactPKey, CFAccAccountContactBuff> subdictTenantIdx; if (dictByTenantIdx.containsKey(keyTenantIdx)) { subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx); } else { subdictTenantIdx = new TreeMap<CFAccAccountContactPKey, CFAccAccountContactBuff>(); dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx); } subdictTenantIdx.put(pkey, Buff); SortedMap<CFAccAccountContactPKey, CFAccAccountContactBuff> subdictCtctLstIdx; if (dictByCtctLstIdx.containsKey(keyCtctLstIdx)) { subdictCtctLstIdx = dictByCtctLstIdx.get(keyCtctLstIdx); } else { subdictCtctLstIdx = new TreeMap<CFAccAccountContactPKey, CFAccAccountContactBuff>(); dictByCtctLstIdx.put(keyCtctLstIdx, subdictCtctLstIdx); } subdictCtctLstIdx.put(pkey, Buff); SortedMap<CFAccAccountContactPKey, CFAccAccountContactBuff> subdictCtctIdx; if (dictByCtctIdx.containsKey(keyCtctIdx)) { subdictCtctIdx = dictByCtctIdx.get(keyCtctIdx); } else { subdictCtctIdx = new TreeMap<CFAccAccountContactPKey, CFAccAccountContactBuff>(); dictByCtctIdx.put(keyCtctIdx, subdictCtctIdx); } subdictCtctIdx.put(pkey, Buff); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamAttachmentTagTable.java
public void createAttachmentTag(CFAccAuthorization Authorization, CFAccAttachmentTagBuff Buff) { CFAccAttachmentTagPKey pkey = schema.getFactoryAttachmentTag().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredAttachmentId(Buff.getRequiredAttachmentId()); pkey.setRequiredTagId(Buff.getRequiredTagId()); Buff.setRequiredTenantId(pkey.getRequiredTenantId()); Buff.setRequiredAttachmentId(pkey.getRequiredAttachmentId()); Buff.setRequiredTagId(pkey.getRequiredTagId()); CFAccAttachmentTagByTenantIdxKey keyTenantIdx = schema.getFactoryAttachmentTag().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId()); CFAccAttachmentTagByAttIdxKey keyAttIdx = schema.getFactoryAttachmentTag().newAttIdxKey(); keyAttIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyAttIdx.setRequiredAttachmentId(Buff.getRequiredAttachmentId()); CFAccAttachmentTagByTagIdxKey keyTagIdx = schema.getFactoryAttachmentTag().newTagIdxKey(); keyTagIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyTagIdx.setRequiredTagId(Buff.getRequiredTagId()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createAttachmentTag", pkey);//from ww w. ja v a 2 s . c o m } // Validate foreign keys { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createAttachmentTag", "Owner", "AttachmentTagTenant", "Tenant", null); } } } { boolean allNull = true; allNull = false; allNull = false; if (!allNull) { if (null == schema.getTableAttachment().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId(), Buff.getRequiredAttachmentId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createAttachmentTag", "Container", "AttachmentTagAttachment", "Attachment", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); SortedMap<CFAccAttachmentTagPKey, CFAccAttachmentTagBuff> subdictTenantIdx; if (dictByTenantIdx.containsKey(keyTenantIdx)) { subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx); } else { subdictTenantIdx = new TreeMap<CFAccAttachmentTagPKey, CFAccAttachmentTagBuff>(); dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx); } subdictTenantIdx.put(pkey, Buff); SortedMap<CFAccAttachmentTagPKey, CFAccAttachmentTagBuff> subdictAttIdx; if (dictByAttIdx.containsKey(keyAttIdx)) { subdictAttIdx = dictByAttIdx.get(keyAttIdx); } else { subdictAttIdx = new TreeMap<CFAccAttachmentTagPKey, CFAccAttachmentTagBuff>(); dictByAttIdx.put(keyAttIdx, subdictAttIdx); } subdictAttIdx.put(pkey, Buff); SortedMap<CFAccAttachmentTagPKey, CFAccAttachmentTagBuff> subdictTagIdx; if (dictByTagIdx.containsKey(keyTagIdx)) { subdictTagIdx = dictByTagIdx.get(keyTagIdx); } else { subdictTagIdx = new TreeMap<CFAccAttachmentTagPKey, CFAccAttachmentTagBuff>(); dictByTagIdx.put(keyTagIdx, subdictTagIdx); } subdictTagIdx.put(pkey, Buff); }
From source file:com.facebook.presto.execution.resourceGroups.TestResourceGroups.java
@Test(timeOut = 10_000) public void testPriorityScheduling() { RootInternalResourceGroup root = new RootInternalResourceGroup("root", (group, export) -> { }, directExecutor());//from ww w .j ava 2s . com root.setSoftMemoryLimit(new DataSize(1, MEGABYTE)); root.setMaxQueuedQueries(100); // Start with zero capacity, so that nothing starts running until we've added all the queries root.setMaxRunningQueries(0); root.setSchedulingPolicy(QUERY_PRIORITY); InternalResourceGroup group1 = root.getOrCreateSubGroup("1"); group1.setSoftMemoryLimit(new DataSize(1, MEGABYTE)); group1.setMaxQueuedQueries(100); group1.setMaxRunningQueries(1); InternalResourceGroup group2 = root.getOrCreateSubGroup("2"); group2.setSoftMemoryLimit(new DataSize(1, MEGABYTE)); group2.setMaxQueuedQueries(100); group2.setMaxRunningQueries(1); SortedMap<Integer, MockQueryExecution> queries = new TreeMap<>(); Random random = new Random(); for (int i = 0; i < 100; i++) { int priority; do { priority = random.nextInt(1_000_000) + 1; } while (queries.containsKey(priority)); MockQueryExecution query = new MockQueryExecution(0, "query_id", priority); if (random.nextBoolean()) { group1.run(query); } else { group2.run(query); } queries.put(priority, query); } root.setMaxRunningQueries(1); List<MockQueryExecution> orderedQueries = new ArrayList<>(queries.values()); reverse(orderedQueries); for (MockQueryExecution query : orderedQueries) { root.processQueuedQueries(); assertEquals(query.getState(), RUNNING); query.complete(); } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgRspnHandler.CFAccXMsgRspnAccountEntryRecHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {//from w w w.j a v a 2s . c om // Common XML Attributes String attrId = null; String attrRevision = null; // AccountEntry Attributes String attrTenantId = null; String attrAccountId = null; String attrEntryId = null; String attrSplitEntryId = null; String attrEntryStamp = null; String attrDescription = null; String attrTransferTenantId = null; String attrTransferAccountId = null; String attrDebitCurrencyId = null; String attrDebit = null; String attrCreditCurrencyId = null; String attrCredit = null; String attrConvertedCurrencyId = null; String attrConvertedAmount = null; String attrBalanceCurrencyId = null; String attrBalance = 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("AccountEntry"); 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("AccountId")) { if (attrAccountId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrAccountId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("EntryId")) { if (attrEntryId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrEntryId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("SplitEntryId")) { if (attrSplitEntryId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrSplitEntryId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("EntryStamp")) { if (attrEntryStamp != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrEntryStamp = 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("TransferTenantId")) { if (attrTransferTenantId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTransferTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TransferAccountId")) { if (attrTransferAccountId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTransferAccountId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("DebitCurrencyId")) { if (attrDebitCurrencyId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDebitCurrencyId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Debit")) { if (attrDebit != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDebit = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CreditCurrencyId")) { if (attrCreditCurrencyId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCreditCurrencyId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Credit")) { if (attrCredit != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCredit = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ConvertedCurrencyId")) { if (attrConvertedCurrencyId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrConvertedCurrencyId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ConvertedAmount")) { if (attrConvertedAmount != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrConvertedAmount = attrs.getValue(idxAttr); } else if (attrLocalName.equals("BalanceCurrencyId")) { if (attrBalanceCurrencyId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrBalanceCurrencyId = 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("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 ((attrAccountId == null) || (attrAccountId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "AccountId"); } if ((attrEntryId == null) || (attrEntryId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "EntryId"); } if ((attrEntryStamp == null) || (attrEntryStamp.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "EntryStamp"); } if (attrDescription == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Description"); } if ((attrConvertedCurrencyId == null) || (attrConvertedCurrencyId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ConvertedCurrencyId"); } if ((attrConvertedAmount == null) || (attrConvertedAmount.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ConvertedAmount"); } if ((attrBalanceCurrencyId == null) || (attrBalanceCurrencyId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "BalanceCurrencyId"); } 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 natAccountId = Long.parseLong(attrAccountId); UUID natEntryId = UUID.fromString(attrEntryId); UUID natSplitEntryId; if ((attrSplitEntryId == null) || (attrSplitEntryId.length() <= 0)) { natSplitEntryId = null; } else { natSplitEntryId = UUID.fromString(attrSplitEntryId); } Calendar natEntryStamp; try { natEntryStamp = CFLibXmlUtil.parseTimestamp(attrEntryStamp); } catch (RuntimeException e) { throw CFLib.getDefaultExceptionFactory().newInvalidArgumentException(getClass(), S_ProcName, 0, "EntryStamp", attrEntryStamp, e); } String natDescription = attrDescription; Long natTransferTenantId; if ((attrTransferTenantId == null) || (attrTransferTenantId.length() <= 0)) { natTransferTenantId = null; } else { natTransferTenantId = new Long(Long.parseLong(attrTransferTenantId)); } Long natTransferAccountId; if ((attrTransferAccountId == null) || (attrTransferAccountId.length() <= 0)) { natTransferAccountId = null; } else { natTransferAccountId = new Long(Long.parseLong(attrTransferAccountId)); } Short natDebitCurrencyId; if ((attrDebitCurrencyId == null) || (attrDebitCurrencyId.length() <= 0)) { natDebitCurrencyId = null; } else { natDebitCurrencyId = new Short(Short.parseShort(attrDebitCurrencyId)); } BigDecimal natDebit; if ((attrDebit == null) || (attrDebit.length() <= 0)) { natDebit = null; } else { natDebit = new BigDecimal(attrDebit); } Short natCreditCurrencyId; if ((attrCreditCurrencyId == null) || (attrCreditCurrencyId.length() <= 0)) { natCreditCurrencyId = null; } else { natCreditCurrencyId = new Short(Short.parseShort(attrCreditCurrencyId)); } BigDecimal natCredit; if ((attrCredit == null) || (attrCredit.length() <= 0)) { natCredit = null; } else { natCredit = new BigDecimal(attrCredit); } short natConvertedCurrencyId = Short.parseShort(attrConvertedCurrencyId); BigDecimal natConvertedAmount = new BigDecimal(attrConvertedAmount); short natBalanceCurrencyId = Short.parseShort(attrBalanceCurrencyId); BigDecimal natBalance = new BigDecimal(attrBalance); 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 ICFAccAccountEntryObj obj = schemaObj.getAccountEntryTableObj().newInstance(); CFAccAccountEntryBuff dataBuff = obj.getAccountEntryBuff(); dataBuff.setRequiredTenantId(natTenantId); dataBuff.setRequiredAccountId(natAccountId); dataBuff.setRequiredEntryId(natEntryId); dataBuff.setOptionalSplitEntryId(natSplitEntryId); dataBuff.setRequiredEntryStamp(natEntryStamp); dataBuff.setRequiredDescription(natDescription); dataBuff.setOptionalTransferTenantId(natTransferTenantId); dataBuff.setOptionalTransferAccountId(natTransferAccountId); dataBuff.setOptionalDebitCurrencyId(natDebitCurrencyId); dataBuff.setOptionalDebit(natDebit); dataBuff.setOptionalCreditCurrencyId(natCreditCurrencyId); dataBuff.setOptionalCredit(natCredit); dataBuff.setRequiredConvertedCurrencyId(natConvertedCurrencyId); dataBuff.setRequiredConvertedAmount(natConvertedAmount); dataBuff.setRequiredBalanceCurrencyId(natBalanceCurrencyId); dataBuff.setRequiredBalance(natBalance); 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<CFAccAccountEntryPKey, ICFAccAccountEntryObj> sortedMap = (SortedMap<CFAccAccountEntryPKey, ICFAccAccountEntryObj>) xmsgRspnHandler .getSortedMapOfObjects(); ICFAccAccountEntryObj realized = (ICFAccAccountEntryObj) 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:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamAccountTable.java
public void createAccount(CFAccAuthorization Authorization, CFAccAccountBuff Buff) { CFAccAccountPKey pkey = schema.getFactoryAccount().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredId(schema.nextAccountIdGen()); Buff.setRequiredTenantId(pkey.getRequiredTenantId()); Buff.setRequiredId(pkey.getRequiredId()); CFAccAccountByUCodeIdxKey keyUCodeIdx = schema.getFactoryAccount().newUCodeIdxKey(); keyUCodeIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyUCodeIdx.setRequiredAccountCode(Buff.getRequiredAccountCode()); CFAccAccountByTenantIdxKey keyTenantIdx = schema.getFactoryAccount().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId()); CFAccAccountByRollupAcctIdxKey keyRollupAcctIdx = schema.getFactoryAccount().newRollupAcctIdxKey(); keyRollupAcctIdx.setOptionalRollupTenantId(Buff.getOptionalRollupTenantId()); keyRollupAcctIdx.setOptionalRollupAccountId(Buff.getOptionalRollupAccountId()); CFAccAccountByCcyIdxKey keyCcyIdx = schema.getFactoryAccount().newCcyIdxKey(); keyCcyIdx.setRequiredCurrencyId(Buff.getRequiredCurrencyId()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createAccount", pkey);/* w w w .jav a 2s . c o m*/ } if (dictByUCodeIdx.containsKey(keyUCodeIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createAccount", "AccountUCodeIdx", keyUCodeIdx); } // Validate foreign keys { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createAccount", "Container", "Tenant", "Tenant", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); dictByUCodeIdx.put(keyUCodeIdx, Buff); SortedMap<CFAccAccountPKey, CFAccAccountBuff> subdictTenantIdx; if (dictByTenantIdx.containsKey(keyTenantIdx)) { subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx); } else { subdictTenantIdx = new TreeMap<CFAccAccountPKey, CFAccAccountBuff>(); dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx); } subdictTenantIdx.put(pkey, Buff); SortedMap<CFAccAccountPKey, CFAccAccountBuff> subdictRollupAcctIdx; if (dictByRollupAcctIdx.containsKey(keyRollupAcctIdx)) { subdictRollupAcctIdx = dictByRollupAcctIdx.get(keyRollupAcctIdx); } else { subdictRollupAcctIdx = new TreeMap<CFAccAccountPKey, CFAccAccountBuff>(); dictByRollupAcctIdx.put(keyRollupAcctIdx, subdictRollupAcctIdx); } subdictRollupAcctIdx.put(pkey, Buff); SortedMap<CFAccAccountPKey, CFAccAccountBuff> subdictCcyIdx; if (dictByCcyIdx.containsKey(keyCcyIdx)) { subdictCcyIdx = dictByCcyIdx.get(keyCcyIdx); } else { subdictCcyIdx = new TreeMap<CFAccAccountPKey, CFAccAccountBuff>(); dictByCcyIdx.put(keyCcyIdx, subdictCcyIdx); } subdictCcyIdx.put(pkey, Buff); }
From source file:net.sourceforge.msscodefactory.cfgcash.v2_0.CFGCashXMsgRspnHandler.CFGCashXMsgRspnAccountEntryRecHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/* w w w.ja v a2 s . co m*/ // Common XML Attributes String attrId = null; String attrRevision = null; // AccountEntry Attributes String attrTenantId = null; String attrAccountId = null; String attrEntryId = null; String attrSplitEntryId = null; String attrEntryStamp = null; String attrDescription = null; String attrTransferTenantId = null; String attrTransferAccountId = null; String attrDebitCurrencyId = null; String attrDebit = null; String attrCreditCurrencyId = null; String attrCredit = null; String attrConvertedCurrencyId = null; String attrConvertedAmount = null; String attrBalanceCurrencyId = null; String attrBalance = 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("AccountEntry"); 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("AccountId")) { if (attrAccountId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrAccountId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("EntryId")) { if (attrEntryId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrEntryId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("SplitEntryId")) { if (attrSplitEntryId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrSplitEntryId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("EntryStamp")) { if (attrEntryStamp != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrEntryStamp = 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("TransferTenantId")) { if (attrTransferTenantId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTransferTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TransferAccountId")) { if (attrTransferAccountId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTransferAccountId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("DebitCurrencyId")) { if (attrDebitCurrencyId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDebitCurrencyId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Debit")) { if (attrDebit != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDebit = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CreditCurrencyId")) { if (attrCreditCurrencyId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCreditCurrencyId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Credit")) { if (attrCredit != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCredit = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ConvertedCurrencyId")) { if (attrConvertedCurrencyId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrConvertedCurrencyId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ConvertedAmount")) { if (attrConvertedAmount != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrConvertedAmount = attrs.getValue(idxAttr); } else if (attrLocalName.equals("BalanceCurrencyId")) { if (attrBalanceCurrencyId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrBalanceCurrencyId = 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("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 ((attrAccountId == null) || (attrAccountId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "AccountId"); } if ((attrEntryId == null) || (attrEntryId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "EntryId"); } if ((attrEntryStamp == null) || (attrEntryStamp.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "EntryStamp"); } if (attrDescription == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Description"); } if ((attrConvertedCurrencyId == null) || (attrConvertedCurrencyId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ConvertedCurrencyId"); } if ((attrConvertedAmount == null) || (attrConvertedAmount.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ConvertedAmount"); } if ((attrBalanceCurrencyId == null) || (attrBalanceCurrencyId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "BalanceCurrencyId"); } 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 natAccountId = Long.parseLong(attrAccountId); UUID natEntryId = UUID.fromString(attrEntryId); UUID natSplitEntryId; if ((attrSplitEntryId == null) || (attrSplitEntryId.length() <= 0)) { natSplitEntryId = null; } else { natSplitEntryId = UUID.fromString(attrSplitEntryId); } Calendar natEntryStamp; try { natEntryStamp = CFLibXmlUtil.parseTimestamp(attrEntryStamp); } catch (RuntimeException e) { throw CFLib.getDefaultExceptionFactory().newInvalidArgumentException(getClass(), S_ProcName, 0, "EntryStamp", attrEntryStamp, e); } String natDescription = attrDescription; Long natTransferTenantId; if ((attrTransferTenantId == null) || (attrTransferTenantId.length() <= 0)) { natTransferTenantId = null; } else { natTransferTenantId = new Long(Long.parseLong(attrTransferTenantId)); } Long natTransferAccountId; if ((attrTransferAccountId == null) || (attrTransferAccountId.length() <= 0)) { natTransferAccountId = null; } else { natTransferAccountId = new Long(Long.parseLong(attrTransferAccountId)); } Short natDebitCurrencyId; if ((attrDebitCurrencyId == null) || (attrDebitCurrencyId.length() <= 0)) { natDebitCurrencyId = null; } else { natDebitCurrencyId = new Short(Short.parseShort(attrDebitCurrencyId)); } BigDecimal natDebit; if ((attrDebit == null) || (attrDebit.length() <= 0)) { natDebit = null; } else { natDebit = new BigDecimal(attrDebit); } Short natCreditCurrencyId; if ((attrCreditCurrencyId == null) || (attrCreditCurrencyId.length() <= 0)) { natCreditCurrencyId = null; } else { natCreditCurrencyId = new Short(Short.parseShort(attrCreditCurrencyId)); } BigDecimal natCredit; if ((attrCredit == null) || (attrCredit.length() <= 0)) { natCredit = null; } else { natCredit = new BigDecimal(attrCredit); } short natConvertedCurrencyId = Short.parseShort(attrConvertedCurrencyId); BigDecimal natConvertedAmount = new BigDecimal(attrConvertedAmount); short natBalanceCurrencyId = Short.parseShort(attrBalanceCurrencyId); BigDecimal natBalance = new BigDecimal(attrBalance); 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 ICFGCashAccountEntryObj obj = schemaObj.getAccountEntryTableObj().newInstance(); CFGCashAccountEntryBuff dataBuff = obj.getAccountEntryBuff(); dataBuff.setRequiredTenantId(natTenantId); dataBuff.setRequiredAccountId(natAccountId); dataBuff.setRequiredEntryId(natEntryId); dataBuff.setOptionalSplitEntryId(natSplitEntryId); dataBuff.setRequiredEntryStamp(natEntryStamp); dataBuff.setRequiredDescription(natDescription); dataBuff.setOptionalTransferTenantId(natTransferTenantId); dataBuff.setOptionalTransferAccountId(natTransferAccountId); dataBuff.setOptionalDebitCurrencyId(natDebitCurrencyId); dataBuff.setOptionalDebit(natDebit); dataBuff.setOptionalCreditCurrencyId(natCreditCurrencyId); dataBuff.setOptionalCredit(natCredit); dataBuff.setRequiredConvertedCurrencyId(natConvertedCurrencyId); dataBuff.setRequiredConvertedAmount(natConvertedAmount); dataBuff.setRequiredBalanceCurrencyId(natBalanceCurrencyId); dataBuff.setRequiredBalance(natBalance); 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<CFGCashAccountEntryPKey, ICFGCashAccountEntryObj> sortedMap = (SortedMap<CFGCashAccountEntryPKey, ICFGCashAccountEntryObj>) xmsgRspnHandler .getSortedMapOfObjects(); ICFGCashAccountEntryObj realized = (ICFGCashAccountEntryObj) 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:marytts.language.de.JPhonemiser.java
public void shutdown() { if (logUnknownFileName != null || logEnglishFileName != null) { try {/*from w w w .ja v a 2s. c o m*/ /* print unknown words */ //open file PrintWriter logUnknown = new PrintWriter( new OutputStreamWriter(new FileOutputStream(logUnknownFileName), "UTF-8")); //sort the words Set<String> unknownWords = unknown2Frequency.keySet(); SortedMap<Integer, List<String>> freq2Unknown = new TreeMap<Integer, List<String>>(); for (String nextUnknown : unknownWords) { int nextFreq = unknown2Frequency.get(nextUnknown); //logUnknown.println(nextFreq+" "+nextUnknown); if (freq2Unknown.containsKey(nextFreq)) { List<String> unknowns = freq2Unknown.get(nextFreq); unknowns.add(nextUnknown); } else { List<String> unknowns = new ArrayList<String>(); unknowns.add(nextUnknown); freq2Unknown.put(nextFreq, unknowns); } } //print the words for (int nextFreq : freq2Unknown.keySet()) { List<String> unknowns = freq2Unknown.get(nextFreq); for (int i = 0; i < unknowns.size(); i++) { String unknownWord = (String) unknowns.get(i); logUnknown.println(nextFreq + " " + unknownWord); } } //close file logUnknown.flush(); logUnknown.close(); /* print english words */ //open the file PrintWriter logEnglish = new PrintWriter( new OutputStreamWriter(new FileOutputStream(logEnglishFileName), "UTF-8")); //sort the words SortedMap<Integer, List<String>> freq2English = new TreeMap<Integer, List<String>>(); for (String nextEnglish : english2Frequency.keySet()) { int nextFreq = english2Frequency.get(nextEnglish); if (freq2English.containsKey(nextFreq)) { List<String> englishWords = freq2English.get(nextFreq); englishWords.add(nextEnglish); } else { List<String> englishWords = new ArrayList<String>(); englishWords.add(nextEnglish); freq2English.put(nextFreq, englishWords); } } //print the words for (int nextFreq : freq2English.keySet()) { List<String> englishWords = freq2English.get(nextFreq); for (int i = 0; i < englishWords.size(); i++) { logEnglish.println(nextFreq + " " + englishWords.get(i)); } } //close file logEnglish.flush(); logEnglish.close(); } catch (Exception e) { logger.info("Error printing log files for english and unknown words", e); } } }