package org.jboss.metadata;
import java.util.ArrayList;
import java.util.Iterator;
import org.w3c.dom.Element;
import org.jboss.deployment.DeploymentException;
public class QueryMetaData extends MetaData {
public final static String REMOTE = "Remote";
public final static String LOCAL = "Local";
private String description;
private String methodName;
private ArrayList methodParams;
private String resultTypeMapping;
private String ejbQl;
public QueryMetaData () {
methodParams = new ArrayList();
}
public String getDescription() {
return description;
}
public String getMethodName() {
return methodName;
}
public Iterator getMethodParams() {
return methodParams.iterator();
}
public String getResultTypeMapping() {
return resultTypeMapping;
}
public String getEjbQl() {
return ejbQl;
}
public void importEjbJarXml(Element element) throws DeploymentException {
description = getOptionalChildContent(element, "description");
Element queryMethod = getUniqueChild(element, "query-method");
methodName = getUniqueChildContent(queryMethod, "method-name");
Element methodParamsElement =
getUniqueChild(queryMethod, "method-params");
Iterator iterator =
getChildrenByTagName(methodParamsElement, "method-param");
while (iterator.hasNext()) {
final String param = getElementContent((Element)iterator.next());
if(param == null || param.trim().length() == 0)
{
throw new DeploymentException("method-param tag has no value for method: " + methodName);
}
methodParams.add(param);
}
resultTypeMapping =
getOptionalChildContent(element, "result-type-mapping");
if(resultTypeMapping == null || LOCAL.equals(resultTypeMapping)) {
resultTypeMapping = LOCAL;
} else if(REMOTE.equals(resultTypeMapping)) {
resultTypeMapping = REMOTE;
} else {
throw new DeploymentException("result-type-mapping must be '" +
REMOTE + "' or '" + LOCAL + "', if specified");
}
ejbQl = getElementContent(getUniqueChild(element, "ejb-ql"));
}
}