Package com.cfinkel.reports.exceptions

Examples of com.cfinkel.reports.exceptions.BadReportSyntaxException


        for (WhenElement whenElement : whenElements) {

            String parentValue  = whenElement.getParentValue();
            if (parentValue.equals("*")) {
                throw new BadReportSyntaxException("if dependent-input has 'when' value of *, cannot have other 'when elements");
            } else {
                // has static values: make sure parent value isn't already in there:
                if (whens.get(parentValue) != null)
                    throw new BadReportSyntaxException("dependent inputs already has parent value '" + parentValue + "'");
                When when = new When(whenElement,parentInput,report);
                whens.put(parentValue,when);
            }
        }
    }
View Full Code Here


        this.generatedQueryElement = generatedQueryElement;

        if (generatedQueryElement.getClazz() != null) {
            updateQueryGeneratorClass();
        } else {
            throw new BadReportSyntaxException("generated-query element must 'class' attribute");
        }
    }
View Full Code Here

        String className = generatedQueryElement.getClazz();
        try {
            Class clazz = AppData.getCustomClassLoader().loadClass(className);
            queryGenerator = (QueryGenerator) clazz.newInstance();
        } catch (InstantiationException e) {
            throw new BadReportSyntaxException("Class " + className + " cannot be abstract or interface.");
        } catch (IllegalAccessException e) {
            throw new BadReportSyntaxException("No access to class " + className);
        } catch (ClassNotFoundException e) {
            throw new BadReportSyntaxException("Can't find class " + className);
        }
    }
View Full Code Here

                } catch (ParseException e) {
                    log.error("This should never happen",e);
                }
            } catch (DataAccessException e) {
                log.error("Data access exception running query for input values",e);
                throw new BadReportSyntaxException(e.toString());
            }
            for (Object obj : data) {
                Map map = (Map)obj;
                Iterator it = map.values().iterator();
                String key = it.next().toString();
                String value = it.hasNext() ?  it.next().toString() : key;
                values.put(key,value);
            }
        }

        if (values.size() == 0) throw new  BadReportSyntaxException("No values for input " + baseInputElement.getName() +".");
    }
View Full Code Here

    private void populateInputs(PreparedQueryElement preparedQueryElement, Report report) throws BadReportSyntaxException {
        this.queryElement = preparedQueryElement;
        inputs = new ArrayList<Input>();
        for (String inputName : preparedQueryElement.getInputRef()) {
            Input input = report.getAllInputs().get(inputName);
            if (input == null) throw new BadReportSyntaxException("Input name " + inputName + " not found.");
            inputs.add(input);
        }

    }
View Full Code Here

        // todo: change this: check for validation
        this.hasValidation = false;
        // put this input into report:

        if (report.getAllInputs().get(inputElement.getName()) != null)
            throw new BadReportSyntaxException("There are more than one input named '" + inputElement.getName() + "'");
        report.getAllInputs().put(inputElement.getName(),this);

        this.inputElement = inputElement;
        this.dependents = new LinkedHashMap<String,Input>();
        this.report = report;

        for(DependentInputElement dependentInputElement : inputElement.getDependentInput()) {
            if (report.getAllInputs().get(dependentInputElement.getName()) != null)
                throw new BadReportSyntaxException("There are more than one dependentInput named '" + dependentInputElement.getName() + "'");
            Input dependentInput;
// if first "when" element is *, it has dynamic values
            if (dependentInputElement.getWhen().get(0).getParentValue().equals("*")) {
                dependentInput = new DependentInputWithDynamicValues(dependentInputElement,report,this,this.depth+1);
            } else {
View Full Code Here

        } else if (controlElement.getRadio() != null) {
            return Control.RADIO;
        } else {
            String message = "No proper control for this input.  This should never happen.";
            log.error(message);
            throw new BadReportSyntaxException(message);
        }

    }
View Full Code Here

            List data;
            try {
                try {
                    data = query.getData(inputs);
                } catch (ParseException e) {
                    throw new BadReportSyntaxException("Parse Exception getting data for dependent input " +
                            "when parent value has value '" + this.getWhenElement().getParentValue() + "'");
                }
            } catch (DataAccessException e) {
                log.error("data access exception running query",e);
                throw new BadReportSyntaxException(e.toString());
            }
            for (Object obj : data) {
                Map map = (Map)obj;
                Iterator it = map.values().iterator();
                String key = it.next().toString();
                String value = it.hasNext() ?  it.next().toString() : key;
                values.put(key,value);
            }
        }

        if (values.size() == 0) throw new  BadReportSyntaxException("No values for input " + this.parentInput.getName());
    }
View Full Code Here

            try {
                dataSource = AppData.addAndReturnDataSource(datasourceName);
            } catch (NamingException e) {
                String errorMessage = "Couldn't find JNDI value for datasource: " + datasourceName + ".  Didn't add datasource.";
                log.info(errorMessage,e);
                throw new BadReportSyntaxException(errorMessage);
            } catch (SQLException e) {
                String errorMessage = "SQL Exception - error";
                log.error(errorMessage,e);
                throw new RuntimeException(errorMessage,e);
            }
View Full Code Here

    }

    public DependentInputWithDynamicValues(DependentInputElement dependentInputElement, Report report, Input parentInput, int depth) throws BadReportSyntaxException {
        super(dependentInputElement,report, depth,parentInput);

        if (dependentInputElement.getWhen().size() > 1throw new BadReportSyntaxException("there must be only one 'when' element if it's value is '*'");
        // just get first when element:
        WhenElement whenElement = dependentInputElement.getWhen().get(0);
        this.description = whenElement.getDescription();
        this.datatype = whenElement.getDatatype();
        this.attributeValues = Input.getValuesFromAttribute(whenElement.getValues()  );

        defaultVal = getDefaultValue(whenElement.getDefault(),this.datatype);

        // grab query elements and control element from this crappy data structure:
        List<QueryElement> queryElements = new ArrayList<QueryElement>();
        for (Object object : whenElement.getControlAndQueryOrGeneratedQuery()) {
            if (object instanceof QueryElement) {
                queryElements.add((QueryElement)object);
            } else {
                controlElement = (ControlElement)object;
            }
        }

        if (queryElements.size() == 0) {
            throw new BadReportSyntaxException("there must be one query inside of a dependent input with dynamic values");
        }
        // only grab one query:
        query = QueryFactory.getQuery(queryElements.get(0),report);

        // set control attribute:
View Full Code Here

TOP

Related Classes of com.cfinkel.reports.exceptions.BadReportSyntaxException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.