use of org.nhindirect.config.store.Anchor in project nhin-d by DirectProject.
the class AnchorServiceImpl method getIncomingAnchors.
/*
* (non-Javadoc)
*
* @see org.nhindirect.config.service.AnchorService#getIncomingAnchors(java.lang.String, org.nhindirect.config.service.impl.CertificateGetOptions)
*/
public Collection<Anchor> getIncomingAnchors(String owner, CertificateGetOptions options) throws ConfigurationServiceException {
Collection<Anchor> anchors = getAnchorsForOwner(owner, options);
if (anchors == null || anchors.size() == 0)
return Collections.emptyList();
Collection<Anchor> retList = new ArrayList<Anchor>();
for (Anchor anchor : anchors) if (anchor.isIncoming())
retList.add(anchor);
return retList;
}
use of org.nhindirect.config.store.Anchor in project nhin-d by DirectProject.
the class ConfigurationServiceTest method testAddAnchors.
/**
* Test the addAnchors method.
*/
public void testAddAnchors() throws Exception {
final AnchorService anchorService = context.mock(AnchorService.class);
final Collection<Anchor> collection = Arrays.asList(new Anchor());
context.checking(new Expectations() {
{
oneOf(anchorService).addAnchors(collection);
}
});
ConfigurationServiceImpl service = new ConfigurationServiceImpl();
service.setAnchorSvc(anchorService);
try {
service.addAnchors(collection);
} catch (Exception e) {
fail("Exception thrown");
}
}
use of org.nhindirect.config.store.Anchor in project nhin-d by DirectProject.
the class AnchorDaoImpl method list.
/*
* (non-Javadoc)
*
* @see org.nhindirect.config.store.dao.AnchorDao#list(java.util.List)
*/
@SuppressWarnings("unchecked")
@Transactional(readOnly = true)
public List<Anchor> list(List<String> owners) {
if (log.isDebugEnabled())
log.debug("Enter");
if (owners == null || owners.size() == 0)
return listAll();
List<Anchor> result = Collections.emptyList();
Query select = null;
StringBuffer nameList = new StringBuffer("(");
for (String owner : owners) {
if (nameList.length() > 1) {
nameList.append(", ");
}
nameList.append("'").append(owner.toUpperCase(Locale.getDefault())).append("'");
}
nameList.append(")");
String query = "SELECT a from Anchor a WHERE UPPER(a.owner) IN " + nameList.toString();
select = entityManager.createQuery(query);
@SuppressWarnings("rawtypes") List rs = select.getResultList();
if (rs != null && (rs.size() != 0) && (rs.get(0) instanceof Anchor)) {
result = (List<Anchor>) rs;
}
if (log.isDebugEnabled())
log.debug("Exit");
return result;
}
use of org.nhindirect.config.store.Anchor in project nhin-d by DirectProject.
the class AnchorDaoImpl method listByIds.
@SuppressWarnings("unchecked")
@Transactional(readOnly = true)
public List<Anchor> listByIds(List<Long> anchorIds) {
if (log.isDebugEnabled())
log.debug("Enter");
if (anchorIds == null || anchorIds.size() == 0)
return Collections.emptyList();
List<Anchor> result = Collections.emptyList();
Query select = null;
StringBuffer ids = new StringBuffer("(");
for (Long id : anchorIds) {
if (ids.length() > 1) {
ids.append(", ");
}
ids.append(id);
}
ids.append(")");
String query = "SELECT a from Anchor a WHERE a.id IN " + ids.toString();
select = entityManager.createQuery(query);
@SuppressWarnings("rawtypes") List rs = select.getResultList();
if (rs != null && (rs.size() != 0) && (rs.get(0) instanceof Anchor)) {
result = (List<Anchor>) rs;
}
if (log.isDebugEnabled())
log.debug("Exit");
return result;
}
Aggregations