本文整理汇总了Java中javax.jcr.query.Row类的典型用法代码示例。如果您正苦于以下问题:Java Row类的具体用法?Java Row怎么用?Java Row使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Row类属于javax.jcr.query包,在下文中一共展示了Row类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: formatQueryResults
import javax.jcr.query.Row; //导入依赖的package包/类
public static String formatQueryResults(RowIterator it) throws RepositoryException {
String results="\n";
while (it.hasNext()) {
Row row = it.nextRow();
Value[] values=row.getValues();
String s="";
for (Value value:values) {
if (value!=null)
s+="| " + value.getString() + " ";
else
s+="| null ";
}
results+=s+"\n";
}
return results;
}
示例2: runJcrQuery
import javax.jcr.query.Row; //导入依赖的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: nextRow
import javax.jcr.query.Row; //导入依赖的package包/类
@Override
public Row nextRow() {
while (!rowIterators.get(currentIter).hasNext() && rowIterators.size() - 1 > currentIter) {
currentIter++;
}
return rowIterators.get(currentIter).nextRow();
}
示例4: getDetails
import javax.jcr.query.Row; //导入依赖的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>";
}
示例5: isTraversal
import javax.jcr.query.Row; //导入依赖的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 ");
}
示例6: populateStatisticsFromJcr
import javax.jcr.query.Row; //导入依赖的package包/类
private void populateStatisticsFromJcr( Session session, String repositoryId,
RepositoryStatistics repositoryStatistics )
throws MetadataRepositoryException
{
// TODO: these may be best as running totals, maintained by observations on the properties in JCR
try
{
QueryManager queryManager = session.getWorkspace().getQueryManager();
// TODO: JCR-SQL2 query will not complete on a large repo in Jackrabbit 2.2.0 - see JCR-2835
// Using the JCR-SQL2 variants gives
// "org.apache.lucene.search.BooleanQuery$TooManyClauses: maxClauseCount is set to 1024"
// String whereClause = "WHERE ISDESCENDANTNODE([/repositories/" + repositoryId + "/content])";
// Query query = queryManager.createQuery( "SELECT size FROM [archiva:artifact] " + whereClause,
// Query.JCR_SQL2 );
String whereClause = "WHERE jcr:path LIKE '/repositories/" + repositoryId + "/content/%'";
Query query = queryManager.createQuery( "SELECT size FROM archiva:artifact " + whereClause, Query.SQL );
QueryResult queryResult = query.execute();
Map<String, Integer> totalByType = new HashMap<>();
long totalSize = 0, totalArtifacts = 0;
for ( Row row : JcrUtils.getRows( queryResult ) )
{
Node n = row.getNode();
totalSize += row.getValue( "size" ).getLong();
String type;
if ( n.hasNode( MavenArtifactFacet.FACET_ID ) )
{
Node facetNode = n.getNode( MavenArtifactFacet.FACET_ID );
type = facetNode.getProperty( "type" ).getString();
}
else
{
type = "Other";
}
Integer prev = totalByType.get( type );
totalByType.put( type, prev != null ? prev + 1 : 1 );
totalArtifacts++;
}
repositoryStatistics.setTotalArtifactCount( totalArtifacts );
repositoryStatistics.setTotalArtifactFileSize( totalSize );
for ( Map.Entry<String, Integer> entry : totalByType.entrySet() )
{
repositoryStatistics.setTotalCountForType( entry.getKey(), entry.getValue() );
}
// The query ordering is a trick to ensure that the size is correct, otherwise due to lazy init it will be -1
// query = queryManager.createQuery( "SELECT * FROM [archiva:project] " + whereClause, Query.JCR_SQL2 );
query = queryManager.createQuery( "SELECT * FROM archiva:project " + whereClause + " ORDER BY jcr:score",
Query.SQL );
repositoryStatistics.setTotalProjectCount( query.execute().getRows().getSize() );
// query = queryManager.createQuery(
// "SELECT * FROM [archiva:namespace] " + whereClause + " AND namespace IS NOT NULL", Query.JCR_SQL2 );
query = queryManager.createQuery(
"SELECT * FROM archiva:namespace " + whereClause + " AND namespace IS NOT NULL ORDER BY jcr:score",
Query.SQL );
repositoryStatistics.setTotalGroupCount( query.execute().getRows().getSize() );
}
catch ( RepositoryException e )
{
throw new MetadataRepositoryException( e.getMessage(), e );
}
}
示例7: runJcrQuery
import javax.jcr.query.Row; //导入依赖的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;
}
示例8: populateStatistics
import javax.jcr.query.Row; //导入依赖的package包/类
@Override
public void populateStatistics( MetadataRepository repository, String repositoryId,
RepositoryStatistics repositoryStatistics )
throws MetadataRepositoryException
{
if ( !( repository instanceof JcrMetadataRepository ) )
{
throw new MetadataRepositoryException(
"The statistics population is only possible for JcrMetdataRepository implementations" );
}
Session session = (Session) repository.obtainAccess( Session.class );
// TODO: these may be best as running totals, maintained by observations on the properties in JCR
try
{
QueryManager queryManager = session.getWorkspace().getQueryManager();
// TODO: JCR-SQL2 query will not complete on a large repo in Jackrabbit 2.2.0 - see JCR-2835
// Using the JCR-SQL2 variants gives
// "org.apache.lucene.search.BooleanQuery$TooManyClauses: maxClauseCount is set to 1024"
// String whereClause = "WHERE ISDESCENDANTNODE([/repositories/" + repositoryId + "/content])";
// Query query = queryManager.createQuery( "SELECT size FROM [archiva:artifact] " + whereClause,
// Query.JCR_SQL2 );
String whereClause = "WHERE jcr:path LIKE '/repositories/" + repositoryId + "/content/%'";
Query query = queryManager.createQuery( "SELECT size FROM archiva:artifact " + whereClause, Query.SQL );
QueryResult queryResult = query.execute();
Map<String, Integer> totalByType = new HashMap<>();
long totalSize = 0, totalArtifacts = 0;
for ( Row row : JcrUtils.getRows( queryResult ) )
{
Node n = row.getNode();
totalSize += row.getValue( "size" ).getLong();
String type;
if ( n.hasNode( MavenArtifactFacet.FACET_ID ) )
{
Node facetNode = n.getNode( MavenArtifactFacet.FACET_ID );
type = facetNode.getProperty( "type" ).getString();
}
else
{
type = "Other";
}
Integer prev = totalByType.get( type );
totalByType.put( type, prev != null ? prev + 1 : 1 );
totalArtifacts++;
}
repositoryStatistics.setTotalArtifactCount( totalArtifacts );
repositoryStatistics.setTotalArtifactFileSize( totalSize );
for ( Map.Entry<String, Integer> entry : totalByType.entrySet() )
{
log.info( "Setting count for type: {} = {}", entry.getKey(), entry.getValue() );
repositoryStatistics.setTotalCountForType( entry.getKey(), entry.getValue() );
}
// The query ordering is a trick to ensure that the size is correct, otherwise due to lazy init it will be -1
// query = queryManager.createQuery( "SELECT * FROM [archiva:project] " + whereClause, Query.JCR_SQL2 );
query = queryManager.createQuery( "SELECT * FROM archiva:project " + whereClause + " ORDER BY jcr:score",
Query.SQL );
repositoryStatistics.setTotalProjectCount( query.execute().getRows().getSize() );
// query = queryManager.createQuery(
// "SELECT * FROM [archiva:namespace] " + whereClause + " AND namespace IS NOT NULL", Query.JCR_SQL2 );
query = queryManager.createQuery(
"SELECT * FROM archiva:namespace " + whereClause + " AND namespace IS NOT NULL ORDER BY jcr:score",
Query.SQL );
repositoryStatistics.setTotalGroupCount( query.execute().getRows().getSize() );
}
catch ( RepositoryException e )
{
throw new MetadataRepositoryException( e.getMessage(), e );
}
}
示例9: buildInventory
import javax.jcr.query.Row; //导入依赖的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);
}
示例10: nextRow
import javax.jcr.query.Row; //导入依赖的package包/类
public Row nextRow() {
return (Row) next();
}