本文整理汇总了Java中javax.jcr.query.QueryResult.getRows方法的典型用法代码示例。如果您正苦于以下问题:Java QueryResult.getRows方法的具体用法?Java QueryResult.getRows怎么用?Java QueryResult.getRows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jcr.query.QueryResult
的用法示例。
在下文中一共展示了QueryResult.getRows方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRepositorySize
import javax.jcr.query.QueryResult; //导入方法依赖的package包/类
/**
* @param repository the repository
* @return a double of the size of the fedora:datastream binary content
* @throws RepositoryException if repository exception occurred
*/
public static long getRepositorySize(final Repository repository)
throws RepositoryException {
final Session session = repository.login();
try {
long sum = 0;
final QueryManager queryManager =
session.getWorkspace().getQueryManager();
final String querystring =
"SELECT [" + CONTENT_SIZE + "] FROM [" +
FEDORA_BINARY + "]";
final QueryResult queryResults =
queryManager.createQuery(querystring, JCR_SQL2).execute();
for (final RowIterator rows = queryResults.getRows(); rows.hasNext(); ) {
final Value value =
rows.nextRow().getValue(CONTENT_SIZE);
sum += value.getLong();
}
return sum;
} finally {
session.logout();
}
}
示例2: runJcrQuery
import javax.jcr.query.QueryResult; //导入方法依赖的package包/类
private List<ArtifactMetadata> runJcrQuery( String repositoryId, String q, Map<String, String> bindings )
throws MetadataRepositoryException
{
List<ArtifactMetadata> artifacts;
if ( repositoryId != null )
{
q += " AND ISDESCENDANTNODE(artifact,'/" + getRepositoryContentPath( repositoryId ) + "')";
}
log.info( "Running JCR Query: {}", q );
try
{
Query query = getJcrSession().getWorkspace().getQueryManager().createQuery( q, Query.JCR_SQL2 );
ValueFactory valueFactory = getJcrSession().getValueFactory();
for ( Entry<String, String> entry : bindings.entrySet() )
{
query.bindValue( entry.getKey(), valueFactory.createValue( entry.getValue() ) );
}
long start = Calendar.getInstance().getTimeInMillis();
QueryResult result = query.execute();
long end = Calendar.getInstance().getTimeInMillis();
log.info( "JCR Query ran in {} milliseconds: {}", end - start , q );
artifacts = new ArrayList<>();
RowIterator rows = result.getRows();
while ( rows.hasNext() )
{
Row row = rows.nextRow();
Node node = row.getNode( "artifact" );
artifacts.add( getArtifactFromNode( repositoryId, node ) );
}
}
catch ( RepositoryException e )
{
throw new MetadataRepositoryException( e.getMessage(), e );
}
return artifacts;
}
示例3: getDetails
import javax.jcr.query.QueryResult; //导入方法依赖的package包/类
@Override
public String getDetails() throws ReportException {
Map<String, String> details = new LinkedHashMap<String, String>();
details.put("Language", config.getQueryLanguage());
details.put("Page", Integer.toString(page));
details.put("Page Size", Integer.toString(config.getPageSize()));
details.put("Query", statement);
try {
final QueryManager queryManager = request.getResourceResolver().adaptTo(Session.class).getWorkspace()
.getQueryManager();
final Query query = queryManager.createQuery("explain " + statement, config.getQueryLanguage());
final QueryResult queryResult = query.execute();
final RowIterator rows = queryResult.getRows();
while (rows.hasNext()) {
final Row row = rows.nextRow();
String[] cols = queryResult.getColumnNames();
Value[] values = row.getValues();
for (int i = 0; i < cols.length; i++) {
details.put(cols[i], values[i].getString());
}
}
} catch (RepositoryException re) {
log.error("Exception getting details", re);
throw new ReportException("Exception getting details", re);
}
StringBuilder sb = new StringBuilder();
for (Entry<String, String> entry : details.entrySet()) {
sb.append("<dt>" + StringEscapeUtils.escapeHtml(entry.getKey()) + "</dt>");
sb.append("<dd>" + StringEscapeUtils.escapeHtml(entry.getValue()) + "</dd>");
}
return "<dl>" + sb.toString() + "</dl>";
}
示例4: isTraversal
import javax.jcr.query.QueryResult; //导入方法依赖的package包/类
@Override
public boolean isTraversal(ResourceResolver resourceResolver, String language, String statement) throws RepositoryException {
final QueryManager queryManager = resourceResolver.adaptTo(Session.class).getWorkspace().getQueryManager();
final Query query = queryManager.createQuery("explain " + statement, language);
final QueryResult queryResult = query.execute();
final RowIterator rows = queryResult.getRows();
final Row firstRow = rows.nextRow();
final String plan = firstRow.getValue("plan").getString();
return StringUtils.contains(plan, " /* traverse ");
}
示例5: queryBySQLRow
import javax.jcr.query.QueryResult; //导入方法依赖的package包/类
public static RowIterator queryBySQLRow(Session session, String query) throws RepositoryException {
QueryManager qm = session.getWorkspace().getQueryManager();
Query q = qm.createQuery(query, Query.JCR_SQL2);
QueryResult result = q.execute();
RowIterator it = result.getRows();
return it;
}
示例6: runJcrQuery
import javax.jcr.query.QueryResult; //导入方法依赖的package包/类
private List<ArtifactMetadata> runJcrQuery( String repositoryId, String q, Map<String, String> bindings )
throws MetadataRepositoryException
{
List<ArtifactMetadata> artifacts;
if ( repositoryId != null )
{
q += " AND ISDESCENDANTNODE(artifact,'/" + getRepositoryContentPath( repositoryId ) + "')";
}
log.info( "Running JCR Query: {}", q );
try
{
Query query = getJcrSession().getWorkspace().getQueryManager().createQuery( q, Query.JCR_SQL2 );
ValueFactory valueFactory = getJcrSession().getValueFactory();
for ( Entry<String, String> entry : bindings.entrySet() )
{
query.bindValue( entry.getKey(), valueFactory.createValue( entry.getValue() ) );
}
long start = Calendar.getInstance().getTimeInMillis();
QueryResult result = query.execute();
long end = Calendar.getInstance().getTimeInMillis();
log.info( "JCR Query ran in {} milliseconds: {}", end - start, q );
artifacts = new ArrayList<>();
RowIterator rows = result.getRows();
while ( rows.hasNext() )
{
Row row = rows.nextRow();
Node node = row.getNode( "artifact" );
artifacts.add( getArtifactFromNode( repositoryId, node ) );
}
}
catch ( RepositoryException e )
{
throw new MetadataRepositoryException( e.getMessage(), e );
}
log.info( "Artifacts found {}", artifacts.size() );
for ( ArtifactMetadata meta : artifacts )
{
log.info( "Artifact: " + meta.getVersion() + " " + meta.getFacetList() );
}
return artifacts;
}
示例7: buildInventory
import javax.jcr.query.QueryResult; //导入方法依赖的package包/类
private void buildInventory(String webResourceGroupName)
throws RepositoryException {
log.info("Creating Inventory for Web Resource Group: "
+ webResourceGroupName);
QueryResult result = getWebResourceGroupQueryResults(adminSession,
webResourceGroupName);
RowIterator rowIterator = result.getRows();
while (rowIterator.hasNext()) {
Row currentRow = rowIterator.nextRow();
Node currentFileNode = currentRow.getNode("nt:file");
String currentPath = currentFileNode.getPath();
String currentExtention = JCRUtils
.getNodeExtension(currentFileNode);
if (!(currentExtention.equals("js") || currentExtention
.equals("css"))) {
updateWebResourceExtensionInventory(currentPath,
currentFileNode);
}
}
log.info("Created Inventory for Web Resource Group: "
+ webResourceGroupName);
if (log.isDebugEnabled()
&& MapUtils.isNotEmpty(webResourceExtentionInventoryMap
.get(webResourceGroupName))) {
for (Entry<String, List<String>> extentionListEntry : webResourceExtentionInventoryMap
.get(webResourceGroupName).entrySet()) {
log.debug("Extension: " + extentionListEntry.getKey()
+ " Items: " + extentionListEntry.getValue());
}
}
Dictionary<String, Object> properties = new Hashtable<String, Object>();
properties.put("paths",
Collections.singletonList(webResourceNamePathMap
.get(webResourceGroupName)));
org.osgi.service.event.Event compileEvent = new org.osgi.service.event.Event(
WebResourceInventoryManager.COMPILE_EVENT, properties);
eventAdmin.postEvent(compileEvent);
}