Search in sources :

Example 1 with CodeHelperInDto

use of org.jaffa.components.codehelper.dto.CodeHelperInDto in project jaffa-framework by jaffa-projects.

the class CallBackDropdownHelper method getOptions.

public CodeHelperOutElementDto getOptions(HttpServletRequest request, String returnField, String descField, String domainName, CriteriaElementDto[] criteriaFields) throws ApplicationExceptions, FrameworkException {
    CodeHelperOutElementDto m_dropDownCodes = null;
    ApplicationExceptions appExps = null;
    CodeHelperInDto input = null;
    System.out.println("Still alive1");
    if (m_codeHelperTx == null)
        m_codeHelperTx = (ICodeHelper) Factory.createObject(ICodeHelper.class);
    if (m_dropDownCodes == null) {
        if (input == null)
            input = new CodeHelperInDto();
        CodeHelperInElementDto codeHelperInElementDto = new CodeHelperInElementDto();
        codeHelperInElementDto.setCode("sort");
        codeHelperInElementDto.setDomainClassName(domainName);
        codeHelperInElementDto.setCodeFieldName(returnField);
        codeHelperInElementDto.setDescriptionFieldName(descField);
        for (int i = 0; i < criteriaFields.length; i++) {
            CriteriaElementDto criteriaField = criteriaFields[i];
            codeHelperInElementDto.addCriteriaField(criteriaField);
        }
        input.addCodeHelperInElementDto(codeHelperInElementDto);
    }
    // throw ApplicationExceptions, if any parsing errors occured
    if (appExps != null && appExps.size() > 0)
        throw appExps;
    // Get the Codes and populate the respective fields
    if (input != null) {
        System.out.println("Still alive2");
        input.setHeaderDto(getHeaderDto(request));
        System.out.println("Still alive3");
        CodeHelperOutDto output = m_codeHelperTx.getCodes(input);
        if (output != null && output.getCodeHelperOutElementDtoCount() > 0) {
            CodeHelperOutElementDto[] codeHelperOutElementDtos = output.getCodeHelperOutElementDtos();
            for (int i = 0; i < codeHelperOutElementDtos.length; i++) {
                CodeHelperOutElementDto codeHelperOutElementDto = codeHelperOutElementDtos[i];
                String code = codeHelperOutElementDto.getCode();
                if (code.equals("sort"))
                    m_dropDownCodes = codeHelperOutElementDto;
            }
        }
    }
    System.out.println("Still alive4");
    return m_dropDownCodes;
}
Also used : CodeHelperInDto(org.jaffa.components.codehelper.dto.CodeHelperInDto) ICodeHelper(org.jaffa.components.codehelper.ICodeHelper) CodeHelperInElementDto(org.jaffa.components.codehelper.dto.CodeHelperInElementDto) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) CriteriaElementDto(org.jaffa.components.codehelper.dto.CriteriaElementDto) CodeHelperOutDto(org.jaffa.components.codehelper.dto.CodeHelperOutDto) CodeHelperOutElementDto(org.jaffa.components.codehelper.dto.CodeHelperOutElementDto)

Example 2 with CodeHelperInDto

use of org.jaffa.components.codehelper.dto.CodeHelperInDto in project jaffa-framework by jaffa-projects.

the class CodeHelperTx method main.

/**
 * Test stub
 * @param args arguments
 */
public static void main(String[] args) {
    try {
        org.apache.log4j.BasicConfigurator.configure();
        CodeHelperTx tx = new CodeHelperTx();
        int testCode = 1;
        switch(testCode) {
            case 1:
                {
                    // test getCode
                    CodeHelperInDto in = new CodeHelperInDto();
                    CodeHelperInElementDto element1 = new CodeHelperInElementDto();
                    element1.setDomainClassName("org.example.applications.app1.modules.request.domain.ReqRemarks");
                    element1.setCodeFieldName("RequestId");
                    element1.setDescriptionFieldName("remarks");
                    // element1.addCriteriaField(new StringCriteriaField("RequestId", "In", new String[] {"REQ02658", "REQ02659", "REQ00645"}));
                    in.addCodeHelperInElementDto(element1);
                    tx.getCodes(in);
                }
                break;
        }
    } catch (ApplicationExceptions e) {
        for (Iterator itr = e.iterator(); itr.hasNext(); ) ((Exception) itr.next()).printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : CodeHelperInDto(org.jaffa.components.codehelper.dto.CodeHelperInDto) CodeHelperInElementDto(org.jaffa.components.codehelper.dto.CodeHelperInElementDto) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) Iterator(java.util.Iterator) FrameworkException(org.jaffa.exceptions.FrameworkException)

Example 3 with CodeHelperInDto

use of org.jaffa.components.codehelper.dto.CodeHelperInDto in project jaffa-framework by jaffa-projects.

the class TaskMaintenanceComponent method initDropDownCodes.

/**
 * This will retrieve the set of codes for dropdowns, if any are required
 * @throws ApplicationExceptions This will be thrown in case any invalid data has been set.
 * @throws FrameworkException Indicates some system error.
 */
protected void initDropDownCodes() throws ApplicationExceptions, FrameworkException {
    ApplicationExceptions appExps = null;
    CodeHelperInDto input = null;
    if (getBusinessObjectXML() != null && getTaskType() != null) {
        Task task = SchedulerConfiguration.getInstance().getTask(getTaskType());
        if (task != null && task.getDataBean() != null) {
            try {
                setBusinessObject(JAXBHelper.unmarshalPayload(getBusinessObjectXML(), task.getDataBean()));
            } catch (JAXBException e) {
                log.error("A task has not been configured for the dataBean " + task.getDataBean(), e);
                throw new JaffaSchedulerFrameworkException(JaffaSchedulerFrameworkException.MISSING_TASK_FOR_DATA_BEAN, new Object[] { task.getDataBean() }, e);
            } catch (ClassNotFoundException e) {
                log.error("A task has not been configured for the dataBean " + task.getDataBean(), e);
                throw new JaffaSchedulerFrameworkException(JaffaSchedulerFrameworkException.MISSING_TASK_FOR_DATA_BEAN, new Object[] { task.getDataBean() }, e);
            }
        }
    }
    // Initialize the taskType DropDown
    m_taskTypeCodes = new TreeSet<String>();
    if (getBusinessObject() != null) {
        try {
            Task task = SchedulerConfiguration.getInstance().getTaskByDataBean(getBusinessObject().getClass().getName());
            if (task != null)
                m_taskTypeCodes.add(task.getType());
        } catch (ClassNotFoundException e) {
            log.error("A task has not been configured for the dataBean " + getBusinessObject().getClass().getName(), e);
            throw new JaffaSchedulerFrameworkException(JaffaSchedulerFrameworkException.MISSING_TASK_FOR_DATA_BEAN, new Object[] { getBusinessObject().getClass().getName() }, e);
        }
    } else {
        Task[] tasks = SchedulerConfiguration.getInstance().getTasks();
        if (tasks != null) {
            for (Task task : tasks) {
                if (task.isAutoCreateDataBean() && SchedulerBrowser.hasBrowseTaskAccess(task.getType()))
                    m_taskTypeCodes.add(task.getType());
            }
        }
    }
}
Also used : CodeHelperInDto(org.jaffa.components.codehelper.dto.CodeHelperInDto) Task(org.jaffa.modules.scheduler.services.configdomain.Task) ScheduledTask(org.jaffa.modules.scheduler.services.ScheduledTask) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) JAXBException(javax.xml.bind.JAXBException) JaffaSchedulerFrameworkException(org.jaffa.modules.scheduler.services.JaffaSchedulerFrameworkException)

Aggregations

CodeHelperInDto (org.jaffa.components.codehelper.dto.CodeHelperInDto)3 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)3 CodeHelperInElementDto (org.jaffa.components.codehelper.dto.CodeHelperInElementDto)2 Iterator (java.util.Iterator)1 JAXBException (javax.xml.bind.JAXBException)1 ICodeHelper (org.jaffa.components.codehelper.ICodeHelper)1 CodeHelperOutDto (org.jaffa.components.codehelper.dto.CodeHelperOutDto)1 CodeHelperOutElementDto (org.jaffa.components.codehelper.dto.CodeHelperOutElementDto)1 CriteriaElementDto (org.jaffa.components.codehelper.dto.CriteriaElementDto)1 FrameworkException (org.jaffa.exceptions.FrameworkException)1 JaffaSchedulerFrameworkException (org.jaffa.modules.scheduler.services.JaffaSchedulerFrameworkException)1 ScheduledTask (org.jaffa.modules.scheduler.services.ScheduledTask)1 Task (org.jaffa.modules.scheduler.services.configdomain.Task)1