boolean selectSet) throws Exception {
// go through each query element: use the mapping fields
// to translate the names
for (Iterator<QueryElement> i = elemSet.iterator(); i.hasNext();) {
QueryElement elem = i.next();
if (elem.getRole().equals(XMLQueryHelper.ROLE_ELEMNAME)) {
// do the translation
String elemValue = elem.getValue();
MappingField fld = this.mapping.getFieldByName(elemValue);
// make sure fld is not null
if (fld == null) {
continue;
}
// make sure scope is null, or if it's not null, then it's
// FieldScope.QUERY
if (fld.getScope() != null
&& fld.getScope().equals(FieldScope.RETURN)) {
// skip
continue;
}
// check to see if it has a dbname attr, if not, then the name
// stays
// the same
String newFldName = fld.getLocalName();
elem.setValue(newFldName);
// now translate the domain vocab if there are translate funcs
// present and this isn't the select set
if (!selectSet && fld.getFuncs() != null
&& fld.getFuncs().size() > 0) {
// the next query element should be
// XMLQueryHelper.ROLE_LITERAL
if (!i.hasNext())
break;
QueryElement litElem = i.next();
if (!litElem.getRole().equals(XMLQueryHelper.ROLE_LITERAL)) {
throw new Exception("next query element not "
+ XMLQueryHelper.ROLE_LITERAL + "! role is "
+ litElem.getRole() + " instead!");
}
for (Iterator<MappingFunc> j = fld.getFuncs().iterator(); j
.hasNext();) {
MappingFunc func = j.next();
CDEValue origVal = new CDEValue(fld.getName(),
litElem.getValue());
CDEValue newVal = func.inverseTranslate(origVal);
litElem.setValue(newVal.getVal());
}
}
}