Search in sources :

Example 31 with Domain

use of org.nhindirect.config.store.Domain in project nhin-d by DirectProject.

the class CertPolicyDaoImpl method getPolicyGroupsByDomain.

@SuppressWarnings("unchecked")
@Override
@Transactional(readOnly = true)
public Collection<CertPolicyGroupDomainReltn> getPolicyGroupsByDomain(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");
    Collection<CertPolicyGroupDomainReltn> retVal = null;
    try {
        final Query select = entityManager.createQuery("SELECT cpr from CertPolicyGroupDomainReltn cpr where cpr.domain = ?1");
        select.setParameter(1, domain);
        retVal = (Collection<CertPolicyGroupDomainReltn>) select.getResultList();
        if (retVal.size() == 0)
            return Collections.emptyList();
        for (CertPolicyGroupDomainReltn reltn : retVal) {
            if (!reltn.getCertPolicyGroup().getCertPolicyGroupReltn().isEmpty())
                for (CertPolicyGroupReltn groupReltn : reltn.getCertPolicyGroup().getCertPolicyGroupReltn()) groupReltn.getCertPolicy().getPolicyData();
        }
    } catch (Exception e) {
        throw new ConfigurationStoreException("Failed to execute policy group to domain relation DAO query.", e);
    }
    return retVal;
}
Also used : CertPolicyGroupReltn(org.nhindirect.config.store.CertPolicyGroupReltn) CertPolicyGroupDomainReltn(org.nhindirect.config.store.CertPolicyGroupDomainReltn) Query(javax.persistence.Query) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) Domain(org.nhindirect.config.store.Domain) NoResultException(javax.persistence.NoResultException) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 32 with Domain

use of org.nhindirect.config.store.Domain in project nhin-d by DirectProject.

the class MainController method buildResponse.

/**
	 * This method takes a List of domain objects and turns them into a JSON response object
	 * that the jQuery datatable can consume.
	 * @param results
	 * @return
	 */
private String buildResponse(List<Domain> domains) {
    if (log.isDebugEnabled())
        log.debug("Enter");
    StringBuffer result = new StringBuffer("{  \"Echo\":");
    result.append(domains.size()).append(",  \"iTotalRecords\": ").append(domains.size()).append(",  \"iTotalDisplayRecords\": ").append(domains.size()).append("  \"aaData\": [");
    boolean first = true;
    for (Domain domain : domains) {
        if (!first) {
            result.append(", ");
            first = false;
        }
        result.append("[").append(xformToJSON(String.valueOf(domain.getId()), false)).append(xformToJSON(domain.getDomainName(), false)).append(xformToJSON(String.valueOf(domain.getPostMasterEmail()), false)).append(xformToJSON(domain.getStatus().toString(), true)).append("] ");
    }
    result.append("] }");
    if (log.isDebugEnabled())
        log.debug("Exit: " + result.toString());
    return result.toString();
}
Also used : Domain(org.nhindirect.config.store.Domain)

Aggregations

Domain (org.nhindirect.config.store.Domain)32 Transactional (org.springframework.transaction.annotation.Transactional)14 Query (javax.persistence.Query)10 Expectations (org.jmock.Expectations)10 ConfigurationStoreException (org.nhindirect.config.store.ConfigurationStoreException)10 TrustBundle (org.nhindirect.config.store.TrustBundle)9 NoResultException (javax.persistence.NoResultException)8 TrustBundleDomainReltn (org.nhindirect.config.store.TrustBundleDomainReltn)8 DomainDao (org.nhindirect.config.store.dao.DomainDao)7 ApplicationContext (org.springframework.context.ApplicationContext)7 File (java.io.File)5 DomainServiceImpl (org.nhindirect.config.service.impl.DomainServiceImpl)5 Address (org.nhindirect.config.store.Address)5 ArrayList (java.util.ArrayList)4 ConfigurationServiceImpl (org.nhindirect.config.service.impl.ConfigurationServiceImpl)4 CertPolicyGroup (org.nhindirect.config.store.CertPolicyGroup)4 CertPolicyGroupDomainReltn (org.nhindirect.config.store.CertPolicyGroupDomainReltn)3 AddressDao (org.nhindirect.config.store.dao.AddressDao)3 List (java.util.List)2 Anchor (org.nhindirect.config.store.Anchor)2