当前位置: 首页>>代码示例>>Java>>正文


Java Row.getNode方法代码示例

本文整理汇总了Java中javax.jcr.query.Row.getNode方法的典型用法代码示例。如果您正苦于以下问题:Java Row.getNode方法的具体用法?Java Row.getNode怎么用?Java Row.getNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.jcr.query.Row的用法示例。


在下文中一共展示了Row.getNode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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;
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:40,代码来源:JcrMetadataRepository.java

示例2: 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 );
        }
    }
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:70,代码来源:DefaultRepositoryStatisticsManager.java

示例3: 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;
}
 
开发者ID:apache,项目名称:archiva,代码行数:45,代码来源:JcrMetadataRepository.java

示例4: 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 );
        }
    }
 
开发者ID:apache,项目名称:archiva,代码行数:78,代码来源:JcrMetadataRepository.java

示例5: 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);

}
 
开发者ID:bobpaulin,项目名称:sling-web-resource,代码行数:47,代码来源:WebResourceInventoryManagerImpl.java


注:本文中的javax.jcr.query.Row.getNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。