use of org.nhindirect.config.store.Domain in project nhin-d by DirectProject.
the class DomainDaoImpl method getDomainByName.
/*
* (non-Javadoc)
*
* @see org.nhindirect.config.store.dao.DomainDao#getDomainByName(java.lang.String)
*/
@Transactional(readOnly = true)
public Domain getDomainByName(String name) {
if (log.isDebugEnabled())
log.debug("Enter");
Domain result = null;
if (name != null) {
Query select = entityManager.createQuery("SELECT DISTINCT d from Domain d WHERE UPPER(d.domainName) = ?1");
Query paramQuery = select.setParameter(1, name.toUpperCase(Locale.getDefault()));
if (paramQuery.getResultList().size() > 0)
result = (Domain) paramQuery.getSingleResult();
}
if (log.isDebugEnabled())
log.debug("Exit");
return result;
}
use of org.nhindirect.config.store.Domain in project nhin-d by DirectProject.
the class DomainDaoImpl method delete.
/*
* (non-Javadoc)
*
* @see org.nhindirect.config.store.dao.DomainDao#delete(java.lang.String)
*/
@Transactional(readOnly = false)
public void delete(Long anId) {
if (log.isDebugEnabled())
log.debug("Enter");
final Domain domain = getDomain(anId);
if (domain != null) {
disassociateTrustBundlesFromDomain(domain.getId());
removePolicyGroupFromDomain(domain.getId());
entityManager.remove(domain);
} else {
log.warn("No domain matching the id: " + anId + " found. Unable to delete.");
}
if (log.isDebugEnabled())
log.debug("Exit");
}
use of org.nhindirect.config.store.Domain in project nhin-d by DirectProject.
the class DomainDaoImpl method delete.
/*
* (non-Javadoc)
*
* @see org.nhindirect.config.store.dao.DomainDao#delete(java.lang.String)
*/
@Transactional(readOnly = false)
public void delete(String name) {
if (log.isDebugEnabled())
log.debug("Enter");
// delete addresses first if they exist
final Domain domain = getDomainByName(name);
if (domain != null) {
disassociateTrustBundlesFromDomain(domain.getId());
removePolicyGroupFromDomain(domain.getId());
entityManager.remove(domain);
} else {
log.warn("No domain matching the name: " + name + " found. Unable to delete.");
}
if (log.isDebugEnabled())
log.debug("Exit");
}
use of org.nhindirect.config.store.Domain in project nhin-d by DirectProject.
the class DomainDaoImpl method searchDomain.
/*
* (non-Javadoc)
*
* @see org.nhindirect.config.store.dao.DomainDao#searchDomain(java.lang.String, org.nhindirect.config.store.EntityStatus)
*/
@SuppressWarnings("unchecked")
@Transactional(readOnly = true)
public List<Domain> searchDomain(String name, EntityStatus status) {
if (log.isDebugEnabled())
log.debug("Enter");
List<Domain> result = null;
StringBuffer query = new StringBuffer("");
Query select = null;
if (name != null) {
String search = name.replace('*', '%').toUpperCase(Locale.getDefault());
search.replace('?', '_');
query.append("SELECT d from Domain d WHERE UPPER(d.domainName) LIKE ?1 ");
if (status != null) {
query.append("AND d.status = ?2");
select = entityManager.createQuery(query.toString());
select.setParameter(1, search);
select.setParameter(2, status);
} else {
select = entityManager.createQuery(query.toString());
select.setParameter(1, search);
}
} else {
if (status != null) {
query.append("SELECT d from Domain d WHERE d.status = ?1");
select = entityManager.createQuery(query.toString());
select.setParameter(1, status);
} else {
select = entityManager.createQuery("SELECT d from Domain d");
}
}
result = (List<Domain>) select.getResultList();
if (result == null) {
result = new ArrayList<Domain>();
}
if (log.isDebugEnabled())
log.debug("Exit");
return result;
}
use of org.nhindirect.config.store.Domain in project nhin-d by DirectProject.
the class CertPolicyDaoImpl method disassociatePolicyGroupsFromDomain.
@Override
@Transactional(readOnly = false)
public void disassociatePolicyGroupsFromDomain(long domainId) throws ConfigurationStoreException {
validateState();
// make sure the domain exists
final Domain domain = domainDao.getDomain(domainId);
if (domain == null)
throw new ConfigurationStoreException("Domain with id " + domainId + " does not exist");
try {
final Query delete = entityManager.createQuery("DELETE from CertPolicyGroupDomainReltn cpr where cpr.domain = ?1");
delete.setParameter(1, domain);
delete.executeUpdate();
entityManager.flush();
} catch (Exception e) {
throw new ConfigurationStoreException("Failed to dissaccociate group policies from domain id ." + domainId, e);
}
}
Aggregations