DynamicQuery.PREDICATE_EQUALS);
params.add(param);
requiredCount++;
}
DynamicQuery checkParentKeyQry = new DynamicQuery();
checkParentKeyQry.append("select COUNT(t.entityKey) from Tmodel t").pad();
checkParentKeyQry.WHERE().pad().appendGroupedAnd(pubParam);
checkParentKeyQry.AND().pad().appendGroupedOr(params.toArray(new DynamicQuery.Parameter[0]));
Query qry = checkParentKeyQry.buildJPAQuery(em);
Number resultCount = (Number)qry.getSingleResult();
if (resultCount.longValue() != requiredCount)
return false;
}
else {
// If only two tokens, then a domain key generator is being checked. A domain key generator can only be registered if no other publishers
// own it. For example, if trying to register the uddi:domain:abc:123 key then uddi:domain cannot be owned by another publisher.
DynamicQuery.Parameter notPubParam = new DynamicQuery.Parameter("t.authorizedName",
getAuthorizedName(),
DynamicQuery.PREDICATE_NOTEQUALS);
DynamicQuery.Parameter keyParam = new DynamicQuery.Parameter("UPPER(t.entityKey)",
(domainPartition + KeyGenerator.PARTITION_SEPARATOR + KeyGenerator.KEYGENERATOR_SUFFIX).toUpperCase(),
DynamicQuery.PREDICATE_EQUALS);
DynamicQuery checkDomainKeyQry = new DynamicQuery();
checkDomainKeyQry.append("select t.entityKey from Tmodel t").pad();
checkDomainKeyQry.WHERE().pad().appendGroupedAnd(notPubParam, keyParam);
Query qry = checkDomainKeyQry.buildJPAQuery(em);
List<?> obj = qry.getResultList();
// If there are results then another publisher has the domain key and therefore the key generator is unavailable
if (obj != null && obj.size() > 0)
return false;
}