List of usage examples for org.apache.ibatis.session SqlSession selectOne
<T> T selectOne(String statement, Object parameter);
From source file:org.restcomm.connect.dao.mybatis.MybatisExtensionsConfigurationDao.java
License:Open Source License
@Override public ExtensionConfiguration getAccountExtensionConfiguration(String accountSid, String extensionSid) { final SqlSession session = sessions.openSession(); ExtensionConfiguration extensionConfiguration = null; try {/*from w ww . ja va 2 s . c o m*/ Map<String, Object> params = new HashMap<String, Object>(); params.put("account_sid", accountSid.toString()); params.put("extension_sid", extensionSid.toString()); final Map<String, Object> result = session.selectOne(namespace + "getAccountExtensionConfiguration", params); if (result != null) { extensionConfiguration = toAccountsExtensionConfiguration(result); } return extensionConfiguration; } finally { session.close(); } }
From source file:org.restcomm.connect.dao.mybatis.MybatisGeolocationDao.java
License:Open Source License
private Geolocation getGeolocation(final String selector, final String parameter) { final SqlSession session = sessions.openSession(); try {/* www .j av a 2s . c om*/ final Map<String, Object> result = session.selectOne(selector, parameter); if (result != null) { return toGeolocation(result); } else { return null; } } finally { session.close(); } }
From source file:org.restcomm.connect.dao.mybatis.MybatisIncomingPhoneNumbersDao.java
License:Open Source License
private IncomingPhoneNumber getIncomingPhoneNumber(final String selector, Object parameter) { final SqlSession session = sessions.openSession(); String inboundPhoneNumber = null; try {/* w ww.j av a 2 s . c o m*/ final Map<String, Object> result = session.selectOne(namespace + selector, parameter); if (result != null) { return toIncomingPhoneNumber(result); } //check if there is a Regex match only if parameter is a String aka phone Number listPhones = getIncomingPhoneNumbersRegex(); if (listPhones != null && listPhones.size() > 0) { inboundPhoneNumber = ((String) parameter).replace("+1", ""); if (inboundPhoneNumber.matches("[\\d,*,#,+]+")) { return checkIncomingPhoneNumberRegexMatch(selector, inboundPhoneNumber); } } } finally { session.close(); } return null; }
From source file:org.restcomm.connect.dao.mybatis.MybatisIncomingPhoneNumbersDao.java
License:Open Source License
public IncomingPhoneNumber checkIncomingPhoneNumberRegexMatch(String selector, String inboundPhoneNumber) { final SqlSession session = sessions.openSession(); String phoneRegexPattern = null; try {//from w w w .ja va 2s . co m if (logger.isInfoEnabled()) { final String msg = String.format( "Found %d Regex IncomingPhone numbers. Will try to match a REGEX for incoming phone number for phoneNumber : %s", listPhones.size(), inboundPhoneNumber); logger.info(msg); } for (IncomingPhoneNumber listPhone : listPhones) { if (listPhone.getPhoneNumber().startsWith("+")) { phoneRegexPattern = listPhone.getPhoneNumber().replace("+", "/+"); } else if (listPhone.getPhoneNumber().startsWith("*")) { phoneRegexPattern = listPhone.getPhoneNumber().replace("*", "/*"); } else { phoneRegexPattern = listPhone.getPhoneNumber(); } Pattern p = Pattern.compile(phoneRegexPattern); Matcher m = p.matcher(inboundPhoneNumber); if (m.find()) { final Map<String, Object> resultRestcommRegexHostedNumber = session .selectOne(namespace + selector, phoneRegexPattern); if (resultRestcommRegexHostedNumber != null) { if (logger.isInfoEnabled()) { String msg = String.format("Pattern \"%s\" matched the phone number \"%s\"", phoneRegexPattern, inboundPhoneNumber); logger.info(msg); } return toIncomingPhoneNumber(resultRestcommRegexHostedNumber); } else { if (logger.isInfoEnabled()) { String msg = String.format("Regex \"%s\" cannot be matched for phone number \"%s\"", phoneRegexPattern, inboundPhoneNumber); logger.info(msg); } } } else { if (logger.isInfoEnabled()) { String msg = String.format("Regex \"%s\" cannot be matched for phone number \"%s\"", phoneRegexPattern, inboundPhoneNumber); logger.info(msg); } } } logger.info( "No matching phone number found, make sure your Restcomm Regex phone number is correctly defined"); } catch (Exception e) { if (logger.isDebugEnabled()) { String msg = String.format( "Exception while trying to match for a REGEX for incoming phone number %s, exception: %s", inboundPhoneNumber, e); logger.debug(msg); } } finally { session.close(); } return null; }
From source file:org.restcomm.connect.dao.mybatis.MybatisInstanceIdDao.java
License:Open Source License
@Override public InstanceId getInstanceIdByHost(String host) { final SqlSession session = sessions.openSession(); try {/*ww w . j av a 2s . c o m*/ final Map<String, Object> result = session.selectOne(namespace + "getInstanceIdByHost", host); if (result != null) { return toInstanceId(result); } else { return null; } } catch (Exception e) { session.close(); return getInstanceId(); } finally { session.close(); } }
From source file:org.restcomm.connect.dao.mybatis.MybatisMediaServerDao.java
License:Open Source License
@Override public MediaServerEntity getMediaServer(String msId) { final SqlSession session = sessions.openSession(); try {/*from w ww . j a va 2s. c o m*/ final Map<String, Object> result = session.selectOne(namespace + "getMediaServer", msId); if (result != null) { return toMediaServer(result); } else { return null; } } finally { session.close(); } }
From source file:org.restcomm.connect.dao.mybatis.MybatisNotificationsDao.java
License:Open Source License
@Override public Integer getTotalNotification(NotificationFilter filter) { final SqlSession session = sessions.openSession(); try {/*from w w w . ja v a 2 s .c o m*/ final Integer total = session.selectOne(namespace + "getTotalNotificationByUsingFilters", filter); return total; } finally { session.close(); } }
From source file:org.restcomm.connect.dao.mybatis.MybatisOrganizationDao.java
License:Open Source License
@Override public Organization getOrganization(Sid sid) { final SqlSession session = sessions.openSession(); try {//from www . j a v a2 s.c o m final Map<String, Object> result = session.selectOne(namespace + "getOrganization", sid.toString()); if (result != null) { return toOrganization(result); } else { return null; } } finally { session.close(); } }
From source file:org.restcomm.connect.dao.mybatis.MybatisOrganizationDao.java
License:Open Source License
@Override public Organization getOrganizationByDomainName(String domainName) { final SqlSession session = sessions.openSession(); try {/*from w ww . j a v a 2s . c o m*/ final Map<String, Object> result = session.selectOne(namespace + "getOrganizationByDomainName", domainName); if (result != null) { return toOrganization(result); } else { return null; } } finally { session.close(); } }
From source file:org.restcomm.connect.dao.mybatis.MybatisProfileAssociationsDao.java
License:Open Source License
@Override public ProfileAssociation getProfileAssociationByTargetSid(String targetSid) { final SqlSession session = sessions.openSession(); try {/*from w ww . j ava2 s . c o m*/ final Map<String, Object> result = session.selectOne(namespace + "getProfileAssociationByTargetSid", targetSid); if (result != null) { return toProfileAssociation(result); } else { return null; } } finally { session.close(); } }