public void setDomain(Domain domain) { this.domain = domain; if (domain != null) domain.setProperty(this); }
public RangeConfiguration(DataProperty property, ScalarFunction scalarFunction, Map<Locale, String> unitI18nMap) { this(); read(property, scalarFunction, unitI18nMap); }
public DomainConfiguration(DataProperty property) { this(); read(property); }
clear(); domainProperty = property; if (property != null) propertyId = property.getPropertyId(); if (domain == null) return; maxNumberOfIntervals = String.valueOf(domain.getMaxNumberOfIntervals()); if (domain instanceof LabelDomain) { LabelDomain labelDomain = (LabelDomain) domain; labelIntervalsToHideI18nMap = new HashMap<Locale,String>(labelDomain.getLabelIntervalsToHideI18nMap()); dateTamInterval = String.valueOf(dateDomain.getTamInterval()); Date minDate = dateDomain.getMinDate(); if (minDate != null) dateMinDate = dateFormat.format(minDate); Date maxDate = dateDomain.getMaxDate(); if (maxDate != null) dateMaxDate = dateFormat.format(maxDate); numericTamInterval = String.valueOf(numericDomain.getTamInterval()); Number minValue = numericDomain.getMinValue(); if (minValue != null) numericMinValue = numberFormat.format(minValue); else numericMinValue = null; Number maxValue = numericDomain.getMaxValue(); if (maxValue != null) numericMaxValue = numberFormat.format(maxValue); else numericMaxValue = null;
public String getDescription(Locale l) { DataFormatterRegistry dfr = DataFormatterRegistry.lookup(); DataProperty property = getDomain().getProperty(); if (property == null) return getLabel(); DataPropertyFormatter dpf = dfr.getPropertyFormatter(property.getPropertyId()); return dpf.formatValue(property, getLabel(), l); }
public List<Interval> cutIntervals(List<Interval> intervals) { List<Interval> results = new ArrayList<Interval>(); if (maxNumberOfIntervals < 1 || intervals.size() <= maxNumberOfIntervals) { return intervals; } // Leave out the intervals that exceed the maximum. for (int i = 0; i < maxNumberOfIntervals; i++) { results.add(intervals.get(i)); } // ... and group the rest in a new aggregated interval. CompositeInterval compositeInterval = new CompositeInterval(); ResourceBundle i18n = localeManager.getBundle("org.jboss.dashboard.displayer.messages", LocaleManager.currentLocale()); compositeInterval.setDescription(i18n.getString(AbstractDomain.I18N_PREFFIX + "finalInterval"), LocaleManager.currentLocale()); compositeInterval.setDomain(this); // Include the aggregated interval only if visible. if (!isIntervalHidden(compositeInterval)) { Set<Interval> otherIntervals = new HashSet<Interval>(); for (int i = maxNumberOfIntervals; i < intervals.size(); i++) otherIntervals.add(intervals.get(i)); compositeInterval.setIntervals(otherIntervals); results.add(compositeInterval); } return results; }
public int compareTo(Object o) { try { if (o == null) return 1; Interval other = (Interval) o; Locale locale = LocaleManager.currentLocale(); return getDescription(locale).compareTo(other.getDescription(locale)); } catch (ClassCastException e) { return 1; } } }
public List getValues(DataProperty p) { List results = new ArrayList(); List dvalues = domain.getProperty().getValues(); List pvalues = p.getValues(); for (int i = 0; i < pvalues.size(); i++) { Object dvalue = dvalues.get(i); Object pvalue = pvalues.get(i); if (this.contains(dvalue)) results.add(pvalue); } return results; }
return formatCollection(propertyId, ci.getIntervals(), ", ", null, null, l); return interval.getDescription(l);
public boolean isIntervalHidden(Interval interval) { // An interval is hidden if has been declared so for some locale. for (Locale locale : labelIntervalsToHideI18nMap.keySet()) { String descrsToHide = labelIntervalsToHideI18nMap.get(locale); if (StringUtils.isBlank(descrsToHide)) continue; String descr = interval.getDescription(locale); if (StringUtils.isBlank(descr)) continue; for (String intervalPattern : StringUtils.split(descrsToHide, ",")) { if (intervalPattern.indexOf("*") != -1) { // Wildcard comparison String target = StringUtils.replace(intervalPattern, wildcard, ""); if (intervalPattern.startsWith(wildcard) && intervalPattern.endsWith(wildcard) && descr.indexOf(target) != -1) return true; if (intervalPattern.endsWith(wildcard) && descr.startsWith(target)) return true; if (intervalPattern.startsWith(wildcard) && descr.endsWith(target)) return true; } else { // Match case comparison if (descr.equals(intervalPattern)) { return true; } } } } return false; }
public List<ScalarFunction> getScalarFunctionsSupported() { // This change allow you to restrict the scalar functions supported if (scalarFunctionsSupported != null) return scalarFunctionsSupported; List<ScalarFunction> supported = new ArrayList<ScalarFunction>(); ScalarFunction[] sfs = DataProviderServices.lookup().getScalarFunctionManager().getAllScalarFunctions(); for (ScalarFunction sf : sfs) { if (sf != null && isScalarFunctionSupported(sf)) supported.add(sf); } return supported; }
public boolean contains(Object value) { if (intervals.contains(value)) { return true; } for (Interval interval : intervals) { if (interval.contains(value)) { return true; } } return false; }
public Domain cloneDomain() { LabelDomain clone = (LabelDomain) super.cloneDomain(); clone.labelIntervals = null; clone.labelIntervalsToHideI18nMap = new HashMap<Locale, String>(labelIntervalsToHideI18nMap); return clone; }
public Class getPropertyClass(DataProperty property) { return property.getDomain().getValuesClass(); }
public void read(DataProperty range, ScalarFunction function, Map<Locale, String> unitI18n) { clear(); rangeProperty = range; if (range != null) propertyId = range.getPropertyId(); if (range != null) nameI18nMap.putAll(range.getNameI18nMap()); if (unitI18n != null) unitI18nMap.putAll(unitI18n); if (function != null) scalarFunctionCode = function.getCode(); } }
protected Double calculateScalar(Interval interval, DataProperty property, ScalarFunction function) { Collection values = interval.getValues(property); if (!CollectionUtils.exists(values, NON_NULL_ELEMENTS)) { return new Double(0); } else { double value = function.scalar(values); // Check constraints every time an scalar calculation is carried out. ProfilerHelper.checkRuntimeConstraints(); return new Double(value); } }
public void apply(DataProperty range) { Locale locale = LocaleManager.currentLocale(); if (propertyId != null) range.setPropertyId(propertyId); String name = getName(locale); if (name != null) range.setName(name, locale); }
public DataProperty cloneProperty() { try { AbstractDataProperty clone = (AbstractDataProperty) super.clone(); clone.setDomain(domain.cloneDomain()); clone.setNameI18nMap(new HashMap<Locale,String>()); Iterator it = nameI18nMap.keySet().iterator(); while (it.hasNext()) { Locale locale = (Locale) it.next(); String name = getName(locale); clone.setName(name, locale); } return clone; } catch (CloneNotSupportedException e) { e.printStackTrace(); return null; } } }
public boolean isScalarFunctionSupported(String functionCode) { ScalarFunction function = DataProviderServices.lookup().getScalarFunctionManager().getScalarFunctionByCode(functionCode); if (function == null) return false; return isScalarFunctionSupported(function); }