private JcrType getJcrType( int column ) { JcrType typeInfo = null; if (results instanceof org.modeshape.jcr.api.query.QueryResult) { final String typeName = ((org.modeshape.jcr.api.query.QueryResult)results).getColumnTypes()[column - 1]; typeInfo = JcrType.typeInfo(typeName); } /** * If no type is matched, then default to STRING */ return (typeInfo != null ? typeInfo : JcrType.typeInfo(DefaultDataTypes.STRING)); }
private JcrType getJcrType( int column ) { JcrType typeInfo = null; if (results instanceof org.modeshape.jcr.api.query.QueryResult) { final String typeName = ((org.modeshape.jcr.api.query.QueryResult)results).getColumnTypes()[column - 1]; typeInfo = JcrType.typeInfo(typeName); } /** * If no type is matched, then default to STRING */ return (typeInfo != null ? typeInfo : JcrType.typeInfo(DefaultDataTypes.STRING)); }
private void setColumns( QueryResult result, RestQueryResult restQueryResult, String[] columnNames ) { if (result instanceof org.modeshape.jcr.api.query.QueryResult) { org.modeshape.jcr.api.query.QueryResult modeShapeQueryResult = (org.modeshape.jcr.api.query.QueryResult)result; String[] columnTypes = modeShapeQueryResult.getColumnTypes(); for (int i = 0; i < columnNames.length; i++) { restQueryResult.addColumn(columnNames[i], columnTypes[i]); } } else { for (String columnName : columnNames) { restQueryResult.addColumn(columnName, UNKNOWN_TYPE); } } }
@Before public void beforeEach() throws Exception { MockitoAnnotations.initMocks(this); when(results.getColumnNames()).thenReturn(columnNames); when(results.getSelectorNames()).thenReturn(tableNames); when(extendedResults.getColumnNames()).thenReturn(columnNames); when(extendedResults.getSelectorNames()).thenReturn(tableNames); when(extendedResults.getColumnTypes()).thenReturn(typeNames); // Set up the node types ... addPropDefn("typeA", "propA", true); addPropDefn("typeA", "propC", false); addPropDefn("typeB", "propB", false); addPropDefn("typeA", "propE", false); // Set up the connection information ... when(info.getWorkspaceName()).thenReturn("workspaceName"); when(info.getRepositoryName()).thenReturn("repositoryName"); // Set up the mock connection ... when(connection.info()).thenReturn(info); // Set up the metadata objects ... metadata = new JcrResultSetMetaData(connection, results); extMetadata = new JcrResultSetMetaData(connection, extendedResults); }