List of usage examples for java.util SortedMap put
V put(K key, V value);
From source file:de.ingrid.admin.controller.GeneralController.java
private final SortedMap<String, List<Provider>> createPartnerProviderMap(final List<Partner> partners, final List<Provider> providers) { final SortedMap<String, List<Provider>> map = new TreeMap<String, List<Provider>>(); for (final Partner pa : partners) { final List<Provider> list = new ArrayList<Provider>(); final Iterator<Provider> it = providers.iterator(); final String shortName = pa.getShortName().substring(0, 2); while (it.hasNext()) { final Provider pr = it.next(); if (pr.getShortName().startsWith(shortName)) { list.add(pr);//w w w . j a v a2s .c o m it.remove(); } } map.put(pa.getShortName(), list); } return map; }
From source file:net.sourceforge.msscodefactory.cfcore.v1_11.GenKbRam.GenKbRamISOCurrencyTable.java
public void updateISOCurrency(GenKbAuthorization Authorization, GenKbISOCurrencyBuff Buff) { GenKbISOCurrencyPKey pkey = schema.getFactoryISOCurrency().newPKey(); pkey.setRequiredId(Buff.getRequiredId()); GenKbISOCurrencyBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateISOCurrency", "Existing record not found", "ISOCurrency", pkey); }//from ww w . j a v a 2 s . c o m if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateISOCurrency", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); GenKbISOCurrencyByCcyCdIdxKey existingKeyCcyCdIdx = schema.getFactoryISOCurrency().newCcyCdIdxKey(); existingKeyCcyCdIdx.setRequiredISOCode(existing.getRequiredISOCode()); GenKbISOCurrencyByCcyCdIdxKey newKeyCcyCdIdx = schema.getFactoryISOCurrency().newCcyCdIdxKey(); newKeyCcyCdIdx.setRequiredISOCode(Buff.getRequiredISOCode()); // Check unique indexes // Validate foreign keys // Update is valid SortedMap<GenKbISOCurrencyPKey, GenKbISOCurrencyBuff> subdict; dictByPKey.remove(pkey); dictByPKey.put(pkey, Buff); subdict = dictByCcyCdIdx.get(existingKeyCcyCdIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByCcyCdIdx.containsKey(newKeyCcyCdIdx)) { subdict = dictByCcyCdIdx.get(newKeyCcyCdIdx); } else { subdict = new TreeMap<GenKbISOCurrencyPKey, GenKbISOCurrencyBuff>(); dictByCcyCdIdx.put(newKeyCcyCdIdx, subdict); } subdict.put(pkey, Buff); }
From source file:es.onebox.rest.utils.service.QueryService.java
/** * This method generates the string to be signed based on the following rules: * * - Add the request method + \n//from w w w. j a v a 2 s . c o m * - Add the timestamp + \n * - Add the request URI * - For each request parameter ordered alphabetically: * - First parameter delimiter ? * - Other parameters separated by & * - Name of the parameter * - Add = sign * - value of the parameter * * For example: * * Given a GET request with timestamp = 1316430943576 and uri = /uri_path/ejemplo with parameters, * Bc = 'Prueba1' * Aa = 'Prueba2' * bc = 'aPrueba3' * z1 = 'prueba4' * * The String to sign is: * * GET\n1316430943576\n/uri_path/ejemplo?amp;Aa=Prueba2&bc=aPrueba3&Bc=Prueba1&z1=prueba4 * * @param uri * @param method * @param timestamp * @return * @throws SignatureException */ private String getStringToSign(URI uri, String method, long timestamp, QueryForm queryForm) throws SignatureException { SortedMap<String, String> sortedMap = new TreeMap<String, String>(); // Assuming GET. It actually processes URL parameters for all Method types if (uri.getRawQuery() != null) { StringTokenizer tokenizer = null; try { tokenizer = new StringTokenizer(URLDecoder.decode(uri.getRawQuery(), UTF_8), AMPERSAND); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } while (tokenizer.hasMoreElements()) { String token = tokenizer.nextToken(); sortedMap.put(token.split(PARAM_NAME_VALUE_SEPARATOR)[0].toLowerCase() + token.split(PARAM_NAME_VALUE_SEPARATOR)[1], token); } } // If POST process parameter map if (method.equals(HttpMethod.POST.name())) { for (String key : ((Set<String>) ((MultiMap) queryForm.getFormParameters()).keySet())) { for (String valor : ((List<String>) ((MultiMap) queryForm.getFormParameters()).get(key))) { sortedMap.put(key.toLowerCase() + PARAM_NAME_VALUE_SEPARATOR + valor, key + PARAM_NAME_VALUE_SEPARATOR + valor); } } } // Generating String to sign StringBuilder stringToSign = new StringBuilder(); stringToSign.append(method); stringToSign.append(HMAC_FIELD_SEPARATOR).append(timestamp); stringToSign.append(HMAC_FIELD_SEPARATOR).append(uri.getPath()); boolean firstParam = true; for (String param : sortedMap.values()) { if (firstParam) { stringToSign.append(URI_PARAMETERS_SEPARATOR).append(param); firstParam = false; } else { stringToSign.append(PARAMETERS_SEPARATOR).append(param); } } return stringToSign.toString(); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamSecAppTable.java
public void createSecApp(CFAccAuthorization Authorization, CFAccSecAppBuff Buff) { CFAccSecAppPKey pkey = schema.getFactorySecApp().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecAppId(((CFAccRamClusterTable) schema.getTableCluster()).nextSecAppIdGen(Authorization, Buff.getRequiredClusterId())); Buff.setRequiredClusterId(pkey.getRequiredClusterId()); Buff.setRequiredSecAppId(pkey.getRequiredSecAppId()); CFAccSecAppByClusterIdxKey keyClusterIdx = schema.getFactorySecApp().newClusterIdxKey(); keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); CFAccSecAppByUJEEMountIdxKey keyUJEEMountIdx = schema.getFactorySecApp().newUJEEMountIdxKey(); keyUJEEMountIdx.setRequiredClusterId(Buff.getRequiredClusterId()); keyUJEEMountIdx.setRequiredJEEMountName(Buff.getRequiredJEEMountName()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createSecApp", pkey); }/*w w w. jav a 2 s . c o m*/ if (dictByUJEEMountIdx.containsKey(keyUJEEMountIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createSecApp", "SecAppUJEEMountIdx", keyUJEEMountIdx); } // Validate foreign keys { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema.getTableCluster().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createSecApp", "Container", "SecAppCluster", "Cluster", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); SortedMap<CFAccSecAppPKey, CFAccSecAppBuff> subdictClusterIdx; if (dictByClusterIdx.containsKey(keyClusterIdx)) { subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx); } else { subdictClusterIdx = new TreeMap<CFAccSecAppPKey, CFAccSecAppBuff>(); dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx); } subdictClusterIdx.put(pkey, Buff); dictByUJEEMountIdx.put(keyUJEEMountIdx, Buff); }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam.CFAstRamSecAppTable.java
public void createSecApp(CFAstAuthorization Authorization, CFAstSecAppBuff Buff) { CFAstSecAppPKey pkey = schema.getFactorySecApp().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecAppId(((CFAstRamClusterTable) schema.getTableCluster()).nextSecAppIdGen(Authorization, Buff.getRequiredClusterId())); Buff.setRequiredClusterId(pkey.getRequiredClusterId()); Buff.setRequiredSecAppId(pkey.getRequiredSecAppId()); CFAstSecAppByClusterIdxKey keyClusterIdx = schema.getFactorySecApp().newClusterIdxKey(); keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); CFAstSecAppByUJEEMountIdxKey keyUJEEMountIdx = schema.getFactorySecApp().newUJEEMountIdxKey(); keyUJEEMountIdx.setRequiredClusterId(Buff.getRequiredClusterId()); keyUJEEMountIdx.setRequiredJEEMountName(Buff.getRequiredJEEMountName()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createSecApp", pkey); }//from w w w . j av a 2s. c o m if (dictByUJEEMountIdx.containsKey(keyUJEEMountIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createSecApp", "SecAppUJEEMountIdx", keyUJEEMountIdx); } // Validate foreign keys { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema.getTableCluster().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createSecApp", "Container", "SecAppCluster", "Cluster", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); SortedMap<CFAstSecAppPKey, CFAstSecAppBuff> subdictClusterIdx; if (dictByClusterIdx.containsKey(keyClusterIdx)) { subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx); } else { subdictClusterIdx = new TreeMap<CFAstSecAppPKey, CFAstSecAppBuff>(); dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx); } subdictClusterIdx.put(pkey, Buff); dictByUJEEMountIdx.put(keyUJEEMountIdx, Buff); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamTSecGroupTable.java
public void createTSecGroup(CFAccAuthorization Authorization, CFAccTSecGroupBuff Buff) { CFAccTSecGroupPKey pkey = schema.getFactoryTSecGroup().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredTSecGroupId(((CFAccRamTenantTable) schema.getTableTenant()) .nextTSecGroupIdGen(Authorization, Buff.getRequiredTenantId())); Buff.setRequiredTenantId(pkey.getRequiredTenantId()); Buff.setRequiredTSecGroupId(pkey.getRequiredTSecGroupId()); CFAccTSecGroupByTenantIdxKey keyTenantIdx = schema.getFactoryTSecGroup().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId()); CFAccTSecGroupByUNameIdxKey keyUNameIdx = schema.getFactoryTSecGroup().newUNameIdxKey(); keyUNameIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyUNameIdx.setRequiredName(Buff.getRequiredName()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createTSecGroup", pkey);/*from w ww .j ava 2 s .c om*/ } if (dictByUNameIdx.containsKey(keyUNameIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createTSecGroup", "TSecGroupUNameIdx", keyUNameIdx); } // Validate foreign keys { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createTSecGroup", "Container", "TSecGroupTenant", "Tenant", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); SortedMap<CFAccTSecGroupPKey, CFAccTSecGroupBuff> subdictTenantIdx; if (dictByTenantIdx.containsKey(keyTenantIdx)) { subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx); } else { subdictTenantIdx = new TreeMap<CFAccTSecGroupPKey, CFAccTSecGroupBuff>(); dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx); } subdictTenantIdx.put(pkey, Buff); dictByUNameIdx.put(keyUNameIdx, Buff); }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam.CFAstRamTSecGroupTable.java
public void createTSecGroup(CFAstAuthorization Authorization, CFAstTSecGroupBuff Buff) { CFAstTSecGroupPKey pkey = schema.getFactoryTSecGroup().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredTSecGroupId(((CFAstRamTenantTable) schema.getTableTenant()) .nextTSecGroupIdGen(Authorization, Buff.getRequiredTenantId())); Buff.setRequiredTenantId(pkey.getRequiredTenantId()); Buff.setRequiredTSecGroupId(pkey.getRequiredTSecGroupId()); CFAstTSecGroupByTenantIdxKey keyTenantIdx = schema.getFactoryTSecGroup().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId()); CFAstTSecGroupByUNameIdxKey keyUNameIdx = schema.getFactoryTSecGroup().newUNameIdxKey(); keyUNameIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyUNameIdx.setRequiredName(Buff.getRequiredName()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createTSecGroup", pkey);/*from w w w .j a va 2 s . com*/ } if (dictByUNameIdx.containsKey(keyUNameIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createTSecGroup", "TSecGroupUNameIdx", keyUNameIdx); } // Validate foreign keys { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createTSecGroup", "Container", "TSecGroupTenant", "Tenant", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); SortedMap<CFAstTSecGroupPKey, CFAstTSecGroupBuff> subdictTenantIdx; if (dictByTenantIdx.containsKey(keyTenantIdx)) { subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx); } else { subdictTenantIdx = new TreeMap<CFAstTSecGroupPKey, CFAstTSecGroupBuff>(); dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx); } subdictTenantIdx.put(pkey, Buff); dictByUNameIdx.put(keyUNameIdx, Buff); }
From source file:net.sourceforge.msscodefactory.cfinternet.v2_0.CFInternetRam.CFInternetRamSecAppTable.java
public void createSecApp(CFInternetAuthorization Authorization, CFInternetSecAppBuff Buff) { CFInternetSecAppPKey pkey = schema.getFactorySecApp().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecAppId(((CFInternetRamClusterTable) schema.getTableCluster()) .nextSecAppIdGen(Authorization, Buff.getRequiredClusterId())); Buff.setRequiredClusterId(pkey.getRequiredClusterId()); Buff.setRequiredSecAppId(pkey.getRequiredSecAppId()); CFInternetSecAppByClusterIdxKey keyClusterIdx = schema.getFactorySecApp().newClusterIdxKey(); keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); CFInternetSecAppByUJEEMountIdxKey keyUJEEMountIdx = schema.getFactorySecApp().newUJEEMountIdxKey(); keyUJEEMountIdx.setRequiredClusterId(Buff.getRequiredClusterId()); keyUJEEMountIdx.setRequiredJEEMountName(Buff.getRequiredJEEMountName()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createSecApp", pkey); }/*from w w w . j a va 2 s . com*/ if (dictByUJEEMountIdx.containsKey(keyUJEEMountIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createSecApp", "SecAppUJEEMountIdx", keyUJEEMountIdx); } // Validate foreign keys { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema.getTableCluster().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createSecApp", "Container", "SecAppCluster", "Cluster", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); SortedMap<CFInternetSecAppPKey, CFInternetSecAppBuff> subdictClusterIdx; if (dictByClusterIdx.containsKey(keyClusterIdx)) { subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx); } else { subdictClusterIdx = new TreeMap<CFInternetSecAppPKey, CFInternetSecAppBuff>(); dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx); } subdictClusterIdx.put(pkey, Buff); dictByUJEEMountIdx.put(keyUJEEMountIdx, Buff); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgRspnHandler.CFAccXMsgRspnAccountConfigRecHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/*www . ja v a 2 s . c o m*/ // Common XML Attributes String attrId = null; String attrRevision = null; // AccountConfig Attributes String attrTenantId = null; String attrDefaultCurrencyId = null; String attrCustContactListTenantId = null; String attrCustContactListId = null; String attrEmpContactListTenantId = null; String attrEmpContactListId = null; String attrVendContactListTenantId = null; String attrVendContactListId = 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("AccountConfig"); 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("DefaultCurrencyId")) { if (attrDefaultCurrencyId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDefaultCurrencyId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CustContactListTenantId")) { if (attrCustContactListTenantId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCustContactListTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CustContactListId")) { if (attrCustContactListId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCustContactListId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("EmpContactListTenantId")) { if (attrEmpContactListTenantId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrEmpContactListTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("EmpContactListId")) { if (attrEmpContactListId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrEmpContactListId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("VendContactListTenantId")) { if (attrVendContactListTenantId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrVendContactListTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("VendContactListId")) { if (attrVendContactListId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrVendContactListId = 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 ((attrDefaultCurrencyId == null) || (attrDefaultCurrencyId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "DefaultCurrencyId"); } // Save named attributes to context CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext(); // Convert string attributes to native Java types long natTenantId = Long.parseLong(attrTenantId); short natDefaultCurrencyId = Short.parseShort(attrDefaultCurrencyId); Long natCustContactListTenantId; if ((attrCustContactListTenantId == null) || (attrCustContactListTenantId.length() <= 0)) { natCustContactListTenantId = null; } else { natCustContactListTenantId = new Long(Long.parseLong(attrCustContactListTenantId)); } Long natCustContactListId; if ((attrCustContactListId == null) || (attrCustContactListId.length() <= 0)) { natCustContactListId = null; } else { natCustContactListId = new Long(Long.parseLong(attrCustContactListId)); } Long natEmpContactListTenantId; if ((attrEmpContactListTenantId == null) || (attrEmpContactListTenantId.length() <= 0)) { natEmpContactListTenantId = null; } else { natEmpContactListTenantId = new Long(Long.parseLong(attrEmpContactListTenantId)); } Long natEmpContactListId; if ((attrEmpContactListId == null) || (attrEmpContactListId.length() <= 0)) { natEmpContactListId = null; } else { natEmpContactListId = new Long(Long.parseLong(attrEmpContactListId)); } Long natVendContactListTenantId; if ((attrVendContactListTenantId == null) || (attrVendContactListTenantId.length() <= 0)) { natVendContactListTenantId = null; } else { natVendContactListTenantId = new Long(Long.parseLong(attrVendContactListTenantId)); } Long natVendContactListId; if ((attrVendContactListId == null) || (attrVendContactListId.length() <= 0)) { natVendContactListId = null; } else { natVendContactListId = new Long(Long.parseLong(attrVendContactListId)); } 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 ICFAccAccountConfigObj obj = schemaObj.getAccountConfigTableObj().newInstance(); CFAccAccountConfigBuff dataBuff = obj.getAccountConfigBuff(); dataBuff.setRequiredTenantId(natTenantId); dataBuff.setRequiredDefaultCurrencyId(natDefaultCurrencyId); dataBuff.setOptionalCustContactListTenantId(natCustContactListTenantId); dataBuff.setOptionalCustContactListId(natCustContactListId); dataBuff.setOptionalEmpContactListTenantId(natEmpContactListTenantId); dataBuff.setOptionalEmpContactListId(natEmpContactListId); dataBuff.setOptionalVendContactListTenantId(natVendContactListTenantId); dataBuff.setOptionalVendContactListId(natVendContactListId); 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<CFAccAccountConfigPKey, ICFAccAccountConfigObj> sortedMap = (SortedMap<CFAccAccountConfigPKey, ICFAccAccountConfigObj>) xmsgRspnHandler .getSortedMapOfObjects(); ICFAccAccountConfigObj realized = (ICFAccAccountConfigObj) 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.exchange.excel.ExcelFieldMatchBL.java
/** * Returns the first row headers (field names) mapped to the column indexes * @return Map<ColumnNumber, ColumnHeader> *///from ww w.ja va 2s .c o m static SortedMap<Integer, String> getFirstRowHeaders(Workbook hSSFWorkbook, Integer sheetID) { SortedMap<Integer, String> firstRowMap = new TreeMap<Integer, String>(); if (hSSFWorkbook == null || sheetID == null) { return firstRowMap; } //first search for duplicate columns Set<String> sameColumnNames = new HashSet<String>(); Set<String> columnNames = new HashSet<String>(); Sheet sheet = hSSFWorkbook.getSheetAt(sheetID.intValue()); Row firstRow = sheet.getRow(0); if (firstRow != null) { for (Cell cell : firstRow) { String columnHeader = ExcelImportBL.getStringCellValue(cell); if (columnHeader != null && !"".equals(columnHeader)) { if (columnNames.contains(columnHeader)) { sameColumnNames.add(columnHeader); } else { columnNames.add(columnHeader); } } } } sheet = hSSFWorkbook.getSheetAt(sheetID.intValue()); firstRow = sheet.getRow(0); if (firstRow != null) { for (Cell cell : firstRow) { String columnHeader = ExcelImportBL.getStringCellValue(cell); if (columnHeader != null && !"".equals(columnHeader)) { if (sameColumnNames.contains(columnHeader)) { //for duplicate columns add also the column index columnHeader += " (" + cell.getColumnIndex() + ")"; } firstRowMap.put(Integer.valueOf(cell.getColumnIndex()), columnHeader); } } } return firstRowMap; }