Package org.jboss.dashboard.provider

Examples of org.jboss.dashboard.provider.DataProperty


            Iterator it = getDashboard().getDataProviders().iterator();
            while (it.hasNext()) {
                DataProvider dataProvider = (DataProvider) it.next();
                DataProperty[] properties = dataProvider.getDataSet().getProperties();
                for (int i = 0; i < properties.length; i++) {
                    DataProperty property = properties[i];
                    results.add(new DashboardFilterProperty(property, this));
                }
            }
        } catch (Exception e) {
            log.error("Cannot get data provider results.", e);
View Full Code Here


    /**
     * Get the class for a given property.
     */
    public Class getPropertyClass(String propertyId) {
        DataPropertyFormatter dpf = DataFormatterRegistry.lookup().getPropertyFormatter(propertyId);
        DataProperty property = dashboard.getDataPropertyById(propertyId);
        if (property != null) return dpf.getPropertyClass(property);
        return getStaticPropertyClass(propertyId);
    }
View Full Code Here

    }

    protected Object getPropertyValue(String propertyId, Object obj) {
        try {
            Object[] instance = (Object[]) obj;
            DataProperty property = dashboard.getDataPropertyById(propertyId);
            int column = property.getDataSet().getPropertyColumn(property);
            return instance[column];              
        } catch (ClassCastException e) {
            return null;
        }
    }
View Full Code Here

        while (dashboard != null) {
            Iterator it = dashboard.getDataProviders().iterator();
            while (it.hasNext()) {
                DataProvider provider = (DataProvider) it.next();
                try {
                    DataProperty p = provider.getDataSet().getPropertyById(propertyId);
                    if (p != null) return p;
                } catch (Exception e) {
                    log.error("Dashboard provider dataset load: " + provider.getCode(), e);
                    continue;
                }
View Full Code Here

        this.label = label;
    }

    public String getDescription(Locale l) {
        DataFormatterRegistry dfr = DataFormatterRegistry.lookup();
        DataProperty property = getDomain().getProperty();
        if (property == null) return label;

        DataPropertyFormatter dpf = dfr.getPropertyFormatter(property.getPropertyId());
        return dpf.formatValue(property, label, l);
    }
View Full Code Here

    }

    public int getPropertyColumn(DataProperty p) {
        if (p == null) return -1;
        for (int column = 0; column < properties.length; column++) {
            DataProperty property = properties[column];
            if (property.equals(p)) return column;
        }
        return -1;
    }
View Full Code Here

    }

    public DataProperty getPropertyById(String id){
        if (id == null) return null;
        for (int i = 0; properties != null && i < properties.length; i++) {
            DataProperty property = properties[i];
            if (property.getPropertyId().equalsIgnoreCase(id)) return property;
        }
        return null;
    }
View Full Code Here

    public DataSet groupBy(DataProperty groupByProperty, List<DataProperty> groupByProps, List<String> functionCodes) {
        // Create the dataset instance.
        DefaultDataSet groupByDataSet = new DefaultDataSet(null);
        groupByDataSet.setPropertySize(groupByProps.size());
        DataProperty pivotProp = null;
        for (int i = 0; i < groupByProps.size(); i++) {
            DataProperty grProp = groupByProps.get(i).cloneProperty();
            groupByDataSet.addProperty(grProp, i);
            if (pivotProp == null && grProp.equals(groupByProperty)) pivotProp = grProp;
        }

        // Populate the dataset with the calculations.
        // For each group by interval add a row to the data set.
        Predicate nonNullElements = new Predicate() { public boolean evaluate(Object o) { return o != null; }};
        Interval[] groupByIntervals = groupByProperty.getDomain().getIntervals();
        for (int i=0; i<groupByIntervals.length; i++) {
            Interval groupByInterval = groupByIntervals[i];

            // For each data set property calculate its grouped interval value.
            for (int j=0; j<groupByProps.size(); j++) {

                // The row value for the group by column is the own interval instance.
                DataProperty grProp = groupByDataSet.getProperties()[j];
                String grFunctionCode = functionCodes.get(j);
                if (grProp == pivotProp) {
                    groupByDataSet.addRowValue(j, groupByInterval);
                }
                // The value for the other columns is a scalar function applied over the column values belonging to the interval.
                else {
                    DataProperty dataSetProp = getPropertyById(grProp.getPropertyId());
                    Collection dataSetValues = groupByInterval.getValues(dataSetProp);
                    if (!CollectionUtils.exists(dataSetValues, nonNullElements)) {
                        // If all the interval elements to group are null then set 0.
                        groupByDataSet.addRowValue(j, new Double(0));
                    } else {
                        ScalarFunctionManager scalarFunctionManager = DataProviderServices.lookup().getScalarFunctionManager();
                        ScalarFunction grFunction = scalarFunctionManager.getScalarFunctionByCode(grFunctionCode);
                        double value = grFunction.scalar(dataSetValues);
                        groupByDataSet.addRowValue(j, new Double(value));
                    }
                }
            }
        }
        // After ending the group by calculations and populate the data set, set the domains.
        DataProperty[] groupByProperties = groupByDataSet.getProperties();
        for (int i = 0; i < groupByProperties.length; i++) {
            DataProperty byProperty = groupByProperties[i];
            if (byProperty.equals(groupByProperty)) byProperty.setDomain(new LabelDomain());
            else byProperty.setDomain(new NumericDomain());
        }
        return groupByDataSet;
    }
View Full Code Here

        printIndent(out, indent++);
        out.println("<dataproperties>");

        DataProperty[] properties = getProperties();
        for (int i = 0; i < properties.length; i++) {
            DataProperty property = properties[i];
            printIndent(out, indent++);
            out.println("<dataproperty id=\"" + StringEscapeUtils.escapeXml(property.getPropertyId()) + "\">");
            printIndent(out, indent);
            Domain domain = property.getDomain();
            String convertedFromNumeric = "";
            if (domain instanceof LabelDomain && ((LabelDomain)domain).isConvertedFromNumeric()) convertedFromNumeric = " convertedFromNumeric=\"true\" ";
            out.println("<domain" + convertedFromNumeric + ">" + StringEscapeUtils.escapeXml(property.getDomain().getClass().getName()) + "</domain>");
            Map names = property.getNameI18nMap();
            if (names != null) {
                Iterator it = names.keySet().iterator();
                while (it.hasNext()) {
                    Locale locale = (Locale) it.next();
                    printIndent(out, indent);
View Full Code Here

    public void parseXMLProperties(NodeList nodes) throws Exception {
        for (int x = 0; x < nodes.getLength(); x++) {
            Node node = nodes.item(x);
            if (node.getNodeName().equals("dataproperty")) {
                String idDataProperty = StringEscapeUtils.unescapeXml(node.getAttributes().getNamedItem("id").getNodeValue());
                DataProperty property = getPropertyById(idDataProperty);
                if (property == null) continue; // Be aware of deleted properties.

                NodeList dataProperties = node.getChildNodes();
                for (int y = 0; y < dataProperties.getLength(); y++) {
                    Node dataProperty = dataProperties.item(y);
                    if (dataProperty.getNodeName().equals("domain")) {
                        Domain domain = (Domain) Class.forName(StringEscapeUtils.unescapeXml(dataProperty.getFirstChild().getNodeValue())).newInstance();
                        if (dataProperty.getAttributes().getNamedItem("convertedFromNumeric") != null) ((LabelDomain) domain).setConvertedFromNumeric(true);
                        property.setDomain(domain);
                    }
                    if (dataProperty.getNodeName().equals("name")) {
                        String lang = dataProperty.getAttributes().getNamedItem("language").getNodeValue();
                        String desc = StringEscapeUtils.unescapeXml(dataProperty.getFirstChild().getNodeValue());
                        property.setName(desc, new Locale(lang));
                    }
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.jboss.dashboard.provider.DataProperty

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.