| <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>FindEntityByPublisherQuery.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">jUDDI Core Services</a> > <a href="index.source.html" class="el_package">org.apache.juddi.query</a> > <span class="el_source">FindEntityByPublisherQuery.java</span></div><h1>FindEntityByPublisherQuery.java</h1><pre class="source lang-java linenums">/* |
| * Copyright 2001-2008 The Apache Software Foundation. |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| * |
| */ |
| |
| package org.apache.juddi.query; |
| |
| import java.util.List; |
| import javax.persistence.EntityManager; |
| |
| import org.apache.juddi.query.util.DynamicQuery; |
| import org.apache.juddi.query.util.FindQualifiers; |
| import org.apache.juddi.model.UddiEntityPublisher; |
| |
| /** |
| * Returns the list of "entity" keys possessing the publisher Id in the passed in UddiEntityPublisher |
| * Output is restricted by list of "entity" keys passed in. If null, all entities are searched. |
| * Output is produced by building the appropriate JPA query based on input and find qualifiers. |
| * |
| * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a> |
| */ |
| public class FindEntityByPublisherQuery extends EntityQuery { |
| |
| public static final String AUTHORIZED_NAME_FIELD = "authorizedName"; |
| |
| private final String entityName; |
| private final String entityAlias; |
| private final String keyName; |
| private final String selectSQL; |
| private String signaturePresent; |
| |
| <span class="fc" id="L44"> public FindEntityByPublisherQuery(String entityName, String entityAlias, String keyName, String signaturePresent) {</span> |
| <span class="fc" id="L45"> this.entityName = entityName;</span> |
| <span class="fc" id="L46"> this.entityAlias = entityAlias;</span> |
| <span class="fc" id="L47"> this.keyName = keyName;</span> |
| <span class="fc" id="L48"> this.signaturePresent = signaturePresent;</span> |
| |
| <span class="fc" id="L50"> StringBuilder sql = new StringBuilder(200);</span> |
| <span class="fc" id="L51"> sql.append("select distinct ").append(entityAlias).append(".").append(keyName).append(" from ").append(entityName).append(" ").append(entityAlias).append(" ");</span> |
| <span class="fc" id="L52"> selectSQL = sql.toString();</span> |
| <span class="fc" id="L53"> }</span> |
| |
| public String getEntityName() { |
| <span class="nc" id="L56"> return entityName;</span> |
| } |
| |
| public String getEntityAlias() { |
| <span class="nc" id="L60"> return entityAlias;</span> |
| } |
| |
| public String getKeyName() { |
| <span class="nc" id="L64"> return keyName;</span> |
| } |
| |
| public String getSelectSQL() { |
| <span class="nc" id="L68"> return selectSQL;</span> |
| } |
| |
| public String getSignaturePresent() { |
| <span class="nc" id="L72"> return signaturePresent;</span> |
| } |
| |
| public void setSignaturePresent(String signaturePresent) { |
| <span class="nc" id="L76"> this.signaturePresent = signaturePresent;</span> |
| <span class="nc" id="L77"> }</span> |
| |
| |
| public List<?> select(EntityManager em, FindQualifiers fq, UddiEntityPublisher publisher, List<?> keysIn, DynamicQuery.Parameter... restrictions) { |
| // If keysIn is not null and empty, then search is over. |
| <span class="pc bpc" id="L82" title="3 of 4 branches missed."> if ((keysIn != null) && (keysIn.size() == 0))</span> |
| <span class="nc" id="L83"> return keysIn;</span> |
| |
| <span class="pc bpc" id="L85" title="1 of 2 branches missed."> if (publisher == null)</span> |
| <span class="nc" id="L86"> return keysIn;</span> |
| |
| <span class="fc" id="L88"> DynamicQuery dynamicQry = new DynamicQuery(selectSQL);</span> |
| <span class="fc" id="L89"> appendConditions(dynamicQry, fq, publisher);</span> |
| <span class="pc bpc" id="L90" title="2 of 4 branches missed."> if (restrictions != null && restrictions.length > 0)</span> |
| <span class="nc" id="L91"> dynamicQry.AND().pad().appendGroupedAnd(restrictions);</span> |
| |
| <span class="fc" id="L93"> return getQueryResult(em, dynamicQry, keysIn, entityAlias + "." + keyName);</span> |
| } |
| |
| /* |
| * Appends the conditions to the query based on the publisher id |
| */ |
| public void appendConditions(DynamicQuery qry, FindQualifiers fq, UddiEntityPublisher publisher) { |
| <span class="fc" id="L100"> qry.WHERE().pad();</span> |
| <span class="pc bpc" id="L101" title="3 of 4 branches missed."> if (fq!=null && fq.isSignaturePresent()) {</span> |
| <span class="nc" id="L102"> qry.pad().openParen().pad().append(getSignaturePresent()).pad().closeParen().pad().AND();</span> |
| } |
| <span class="fc" id="L104"> qry.appendGroupedAnd(new DynamicQuery.Parameter(entityAlias + "." + AUTHORIZED_NAME_FIELD, publisher.getAuthorizedName(), DynamicQuery.PREDICATE_EQUALS));</span> |
| <span class="fc" id="L105"> }</span> |
| |
| |
| } |
| </pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.7.9.201702052155</span></div></body></html> |