Search in sources :

Example 16 with Anchor

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;
}
Also used : Anchor(org.nhindirect.config.store.Anchor) ArrayList(java.util.ArrayList)

Example 17 with Anchor

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");
    }
}
Also used : Expectations(org.jmock.Expectations) Anchor(org.nhindirect.config.store.Anchor) ConfigurationServiceImpl(org.nhindirect.config.service.impl.ConfigurationServiceImpl)

Example 18 with Anchor

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;
}
Also used : Anchor(org.nhindirect.config.store.Anchor) Query(javax.persistence.Query) ArrayList(java.util.ArrayList) List(java.util.List) Transactional(org.springframework.transaction.annotation.Transactional)

Example 19 with Anchor

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;
}
Also used : Anchor(org.nhindirect.config.store.Anchor) Query(javax.persistence.Query) ArrayList(java.util.ArrayList) List(java.util.List) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Anchor (org.nhindirect.config.store.Anchor)19 AnchorDao (org.nhindirect.config.store.dao.AnchorDao)10 ArrayList (java.util.ArrayList)9 Expectations (org.jmock.Expectations)9 AnchorServiceImpl (org.nhindirect.config.service.impl.AnchorServiceImpl)8 CertificateGetOptions (org.nhindirect.config.service.impl.CertificateGetOptions)6 Transactional (org.springframework.transaction.annotation.Transactional)5 List (java.util.List)3 Query (javax.persistence.Query)3 Address (org.nhindirect.config.store.Address)2 CertPolicy (org.nhindirect.config.store.CertPolicy)2 CertPolicyGroup (org.nhindirect.config.store.CertPolicyGroup)2 Certificate (org.nhindirect.config.store.Certificate)2 DNSRecord (org.nhindirect.config.store.DNSRecord)2 Domain (org.nhindirect.config.store.Domain)2 Setting (org.nhindirect.config.store.Setting)2 TrustBundle (org.nhindirect.config.store.TrustBundle)2 AddressDao (org.nhindirect.config.store.dao.AddressDao)2 CertPolicyDao (org.nhindirect.config.store.dao.CertPolicyDao)2 CertificateDao (org.nhindirect.config.store.dao.CertificateDao)2