use of org.nhindirect.config.store.CertPolicyGroupReltn in project nhin-d by DirectProject.
the class CertPolicyDaoImpl method getPolicyGroupDomainReltns.
@SuppressWarnings("unchecked")
@Override
@Transactional(readOnly = true)
public Collection<CertPolicyGroupDomainReltn> getPolicyGroupDomainReltns() throws ConfigurationStoreException {
validateState();
try {
final Query select = entityManager.createQuery("SELECT cpdr from CertPolicyGroupDomainReltn cpdr");
final Collection<CertPolicyGroupDomainReltn> rs = select.getResultList();
if (rs.size() == 0)
return Collections.emptyList();
for (CertPolicyGroupDomainReltn reltn : rs) {
if (!reltn.getCertPolicyGroup().getCertPolicyGroupReltn().isEmpty())
for (CertPolicyGroupReltn groupReltn : reltn.getCertPolicyGroup().getCertPolicyGroupReltn()) groupReltn.getCertPolicy().getPolicyData();
}
return rs;
} catch (Exception e) {
throw new ConfigurationStoreException("Failed to execute certificate policy DAO query.", e);
}
}
use of org.nhindirect.config.store.CertPolicyGroupReltn in project nhin-d by DirectProject.
the class CertPolicyDaoImpl method addPolicyUseToGroup.
@Override
@Transactional(readOnly = false)
public void addPolicyUseToGroup(long groupId, long policyId, CertPolicyUse policyUse, boolean incoming, boolean outgoing) throws ConfigurationStoreException {
validateState();
// make sure the policy exists
final CertPolicyGroup policyGroup = this.getPolicyGroupById(groupId);
if (policyGroup == null)
throw new ConfigurationStoreException("Policy group with id " + groupId + " does not exist");
// make sure the policy exists
final CertPolicy policy = this.getPolicyById(policyId);
if (policy == null)
throw new ConfigurationStoreException("Policy with id " + policyId + " does not exist");
try {
final CertPolicyGroupReltn reltn = new CertPolicyGroupReltn();
reltn.setCertPolicy(policy);
reltn.setCertPolicyGroup(policyGroup);
reltn.setPolicyUse(policyUse);
reltn.setIncoming(incoming);
reltn.setOutgoing(outgoing);
policyGroup.getCertPolicyGroupReltn().add(reltn);
entityManager.persist(policyGroup);
entityManager.flush();
} catch (Exception e) {
throw new ConfigurationStoreException("Failed to add policy use to policy group.", e);
}
}
use of org.nhindirect.config.store.CertPolicyGroupReltn 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;
}
Aggregations