List of usage examples for org.apache.commons.collections OrderedMap entrySet
Set<Map.Entry<K, V>> entrySet();
From source file:com.jaspersoft.jasperserver.ws.axis2.repository.InputControlHandler.java
protected java.util.List getInputControlItems(InputControl control, String datasourceUri, RepositoryServiceContext serviceContext, Map params) throws JSException { ResourceReference fallbackDataSource = null; if (datasourceUri != null && datasourceUri.trim().length() > 0) { fallbackDataSource = new ResourceReference(datasourceUri); }/*from w w w. j a v a2 s. com*/ ResourceReference queryRef = control.getQuery(); String valueColumn = control.getQueryValueColumn(); String[] visibleColumns = control.getQueryVisibleColumns(); Map parameters = (params == null) ? new HashMap() : params; // TODO : read REPORT_MAX_COUNT from configuration parameters.put(JRParameter.REPORT_MAX_COUNT, new Integer(100000)); OrderedMap results = serviceContext.getEngine().executeQuery(null, queryRef, valueColumn, visibleColumns, fallbackDataSource, parameters); List rows; if (results == null || results.isEmpty()) { rows = new ArrayList(0); } else { rows = new ArrayList(results.size()); for (Iterator it = results.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); Object keyValue = entry.getKey(); String[] columnValues = (String[]) entry.getValue(); InputControlQueryDataRow ic = new InputControlQueryDataRow(); ic.setValue(keyValue); for (int i = 0; i < columnValues.length; i++) { String value = columnValues[i]; ic.getColumnValues().add((value != null) ? value : ""); } rows.add(ic); } } return rows; }
From source file:com.jaspersoft.jasperserver.remote.handlers.InputControlHandler.java
/** * execute a query against a named datasource to get the data for an * InputControl. Return a list of InputControlQueryDataRow * * @param control/* w w w.j a v a2s.c o m*/ * @param datasourceUri * @param params * @return * @throws ServiceException */ protected java.util.List getInputControlItems(InputControl control, String datasourceUri, Map params) throws ServiceException { ResourceReference fallbackDataSource = null; if (datasourceUri != null && datasourceUri.trim().length() > 0) { fallbackDataSource = new ResourceReference(datasourceUri); } ResourceReference queryRef = control.getQuery(); String valueColumn = control.getQueryValueColumn(); String[] visibleColumns = control.getQueryVisibleColumns(); Map parameters = (params == null) ? new HashMap() : params; // TODO : read REPORT_MAX_COUNT from configuration parameters.put(JRParameter.REPORT_MAX_COUNT, 100000); OrderedMap results = engineService.executeQuery(null, queryRef, valueColumn, visibleColumns, fallbackDataSource, parameters); List rows; if (results == null || results.isEmpty()) { rows = new ArrayList(0); } else { rows = new ArrayList(results.size()); for (Iterator it = results.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); Object keyValue = entry.getKey(); String[] columnValues = (String[]) entry.getValue(); InputControlQueryDataRow ic = new InputControlQueryDataRow(); ic.setValue(keyValue); for (int i = 0; i < columnValues.length; i++) { String value = columnValues[i]; ic.getColumnValues().add((value != null) ? value : ""); } rows.add(ic); } } return rows; }
From source file:org.geotools.xml.impl.SchemaIndexImpl.java
public XSDElementDeclaration getChildElement(XSDElementDeclaration parent, QName childName) { OrderedMap children = (OrderedMap) children(parent); XSDParticle particle = (XSDParticle) children.get(childName); if (particle != null) { XSDElementDeclaration child = (XSDElementDeclaration) particle.getContent(); if (child.isElementDeclarationReference()) { child = child.getResolvedElementDeclaration(); }/*from w w w . j a va 2 s . co m*/ return child; } if ("*".equals(childName.getNamespaceURI())) { //do a check just on local name ArrayList matches = new ArrayList(); for (Iterator e = children.entrySet().iterator(); e.hasNext();) { Map.Entry entry = (Map.Entry) e.next(); QName name = (QName) entry.getKey(); if (name.getLocalPart().equals(childName.getLocalPart())) { matches.add(entry.getValue()); } } if (matches.size() == 1) { particle = (XSDParticle) matches.get(0); XSDElementDeclaration child = (XSDElementDeclaration) particle.getContent(); if (child.isElementDeclarationReference()) { child = child.getResolvedElementDeclaration(); } return child; } } return null; }