Search in sources :

Example 1 with CodeHelperOutCodeDto

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;
}
Also used : CriteriaElementDto(org.jaffa.components.codehelper.dto.CriteriaElementDto) CodeHelperOutCodeDto(org.jaffa.components.codehelper.dto.CodeHelperOutCodeDto) Iterator(java.util.Iterator) CodeHelperOutElementDto(org.jaffa.components.codehelper.dto.CodeHelperOutElementDto) AtomicCriteria(org.jaffa.persistence.AtomicCriteria) Criteria(org.jaffa.persistence.Criteria)

Example 2 with CodeHelperOutCodeDto

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);
    }
}
Also used : CodeHelperOutCodeDto(org.jaffa.components.codehelper.dto.CodeHelperOutCodeDto) CodeHelperOutElementDto(org.jaffa.components.codehelper.dto.CodeHelperOutElementDto) IContextManager(org.jaffa.session.IContextManager)

Example 3 with 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;
}
Also used : CodeHelperOutCodeDto(org.jaffa.components.codehelper.dto.CodeHelperOutCodeDto) DropDownModel(org.jaffa.presentation.portlet.widgets.model.DropDownModel) CodeHelperOutElementDto(org.jaffa.components.codehelper.dto.CodeHelperOutElementDto)

Aggregations

CodeHelperOutCodeDto (org.jaffa.components.codehelper.dto.CodeHelperOutCodeDto)3 CodeHelperOutElementDto (org.jaffa.components.codehelper.dto.CodeHelperOutElementDto)3 Iterator (java.util.Iterator)1 CriteriaElementDto (org.jaffa.components.codehelper.dto.CriteriaElementDto)1 AtomicCriteria (org.jaffa.persistence.AtomicCriteria)1 Criteria (org.jaffa.persistence.Criteria)1 DropDownModel (org.jaffa.presentation.portlet.widgets.model.DropDownModel)1 IContextManager (org.jaffa.session.IContextManager)1