use of org.jaffa.components.codehelper.dto.CodeHelperOutCodeDto in project jaffa-framework by jaffa-projects.
the class CodeHelperTx method processInputElement.
private CodeHelperOutElementDto processInputElement(UOW uow, CodeHelperInElementDto inputElement) throws ApplicationExceptions, FrameworkException {
Criteria c = new Criteria();
c.setTable(inputElement.getDomainClassName());
if (inputElement.getCriteriaFieldCount() > 0) {
CriteriaElementDto[] criteriaFields = inputElement.getCriteriaFields();
for (int i = 0; i < criteriaFields.length; i++) {
CriteriaElementDto criteriaField = criteriaFields[i];
addCriteria(criteriaField, c);
}
}
c.addOrderBy(inputElement.getCodeFieldName(), Criteria.ORDER_BY_ASC);
Iterator i = uow.query(c).iterator();
CodeHelperOutElementDto outputElement = new CodeHelperOutElementDto();
outputElement.setCode(inputElement.getCode());
outputElement.setDomainClassName(inputElement.getDomainClassName());
try {
while (i.hasNext()) {
Object domainObject = i.next();
Object code = BeanHelper.getField(domainObject, inputElement.getCodeFieldName());
Object description = BeanHelper.getField(domainObject, inputElement.getDescriptionFieldName());
CodeHelperOutCodeDto codeDto = new CodeHelperOutCodeDto();
codeDto.setCode(code);
codeDto.setDescription(formatDescription(inputElement, code, description));
outputElement.addCodeHelperOutCodeDto(codeDto);
}
} catch (NoSuchMethodException e) {
String str = "The CodeHelperTx could not introspect the Domain Class " + inputElement.getDomainClassName() + " for the code/description field";
log.warn(str, e);
}
return outputElement;
}
use of org.jaffa.components.codehelper.dto.CodeHelperOutCodeDto in project jaffa-framework by jaffa-projects.
the class FinderComponent2 method initializeSavedQueries.
private void initializeSavedQueries() {
/*
* Read the stored queries and and create a codeHelperOutElementDto so
* that this can be used as the options to a dropdown
*/
// Get the saved Queries
IContextManager contextManager = ContextManagerFactory.instance();
QuerySaver querySaver = new QuerySaver(contextManager);
Map savedQueries = querySaver.getSavedQueryList(getComponentDefinition().getComponentName());
String defaultQueryId = querySaver.getDefaultQueryId(getComponentDefinition().getComponentName());
m_queryIdCodes = new CodeHelperOutElementDto();
if (savedQueries.size() > 0) {
// Create the codeHelperOutElementDto by iterating over the key maps
Iterator savedQueriesIterator = savedQueries.keySet().iterator();
while (savedQueriesIterator.hasNext()) {
String element = (String) savedQueriesIterator.next();
log.info("Adding " + element + " to Saved Queries");
CodeHelperOutCodeDto codeHelperOutCodeDto = new CodeHelperOutCodeDto();
codeHelperOutCodeDto.setCode(element);
if (defaultQueryId != null && element.equals(defaultQueryId)) {
codeHelperOutCodeDto.setDescription("** " + savedQueries.get(element) + " **");
} else {
codeHelperOutCodeDto.setDescription(savedQueries.get(element));
}
m_queryIdCodes.addCodeHelperOutCodeDto(codeHelperOutCodeDto);
}
} else {
log.info("No Queries to add to Saved Queries");
CodeHelperOutCodeDto codeHelperOutCodeDto = new CodeHelperOutCodeDto();
codeHelperOutCodeDto.setCode("");
codeHelperOutCodeDto.setDescription(MessageHelper.findMessage("label.Jaffa.Finder.NoSavedQueries", null));
m_queryIdCodes.addCodeHelperOutCodeDto(codeHelperOutCodeDto);
}
}
use of org.jaffa.components.codehelper.dto.CodeHelperOutCodeDto in project jaffa-framework by jaffa-projects.
the class FinderForm method getSavedQueryIdWM.
/**
* Getter for property savedQueryId. This is invoked by the custom tag, when the jsp is rendered, to get the current value.
* @return Value of property savedQueryId.
*/
public DropDownModel getSavedQueryIdWM() {
DropDownModel w_savedQueryId = (DropDownModel) getWidgetCache().getModel("savedQueryId");
if (w_savedQueryId == null) {
w_savedQueryId = new DropDownModel((getSavedQueryId() != null ? "" + getSavedQueryId() : ""));
CodeHelperOutElementDto dto = ((FinderComponent2) getComponent()).getSavedQueryIdCodes();
if (dto != null && dto.getCodeHelperOutCodeDtoCount() > 0) {
CodeHelperOutCodeDto[] codes = dto.getCodeHelperOutCodeDtos();
for (int i = 0; i < codes.length; i++) {
CodeHelperOutCodeDto code = codes[i];
w_savedQueryId.addOption(Formatter.format(code.getDescription()), Formatter.format(code.getCode()));
}
}
getWidgetCache().addModel("savedQueryId", w_savedQueryId);
}
return w_savedQueryId;
}
Aggregations