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;
}
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();
}
Aggregations