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


Java Query.bindValue方法代码示例

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


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

示例1: queryForVanityUrlNode

import javax.jcr.query.Query; //导入方法依赖的package包/类
/**
 * Query for a vanity url node.
 *
 * @param vanityUrl vanity url from request
 * @param siteName  site name from aggegation state
 * @return first vanity url node of result or null, if nothing found
 */
public Node queryForVanityUrlNode(final String vanityUrl, final String siteName) {
    Node node = null;

    try {
        Session jcrSession = MgnlContext.getJCRSession(VanityUrlModule.WORKSPACE);
        QueryManager queryManager = jcrSession.getWorkspace().getQueryManager();
        Query query = queryManager.createQuery(QUERY, JCR_SQL2);
        query.bindValue(PN_VANITY_URL, new StringValue(vanityUrl));
        query.bindValue(PN_SITE, new StringValue(siteName));
        QueryResult queryResult = query.execute();
        NodeIterator nodes = queryResult.getNodes();
        if (nodes.hasNext()) {
            node = nodes.nextNode();
        }
    } catch (RepositoryException e) {
        LOGGER.error("Error message.", e);
    }

    return node;
}
 
开发者ID:aperto,项目名称:magnolia-vanity-url,代码行数:28,代码来源:VanityUrlService.java

示例2: getWebResourceGroupQueryResults

import javax.jcr.query.Query; //导入方法依赖的package包/类
/**
 * 
 * Runs Query for Web Resource Nodes in a given group
 * 
 * @param session
 * @param webResourceGroupName
 * @return
 * @throws RepositoryException
 */
protected QueryResult getWebResourceGroupQueryResults(Session session,
		String webResourceGroupName) throws RepositoryException {
	Query query = session
			.getWorkspace()
			.getQueryManager()
			.createQuery(
					"SELECT * FROM [nt:file] INNER JOIN [webresource:WebResourceGroup] as webResourceGroupSet ON ISDESCENDANTNODE([nt:file], webResourceGroupSet) WHERE webResourceGroupSet.[webresource:name] = $webResourceName",
					Query.JCR_SQL2);

	query.bindValue("webResourceName", session.getValueFactory()
			.createValue(webResourceGroupName));

	QueryResult queryResult = query.execute();
	return queryResult;
}
 
开发者ID:bobpaulin,项目名称:sling-web-resource,代码行数:25,代码来源:WebResourceInventoryManagerImpl.java

示例3: getArtifactsByChecksum

import javax.jcr.query.Query; //导入方法依赖的package包/类
@Override
public List<ArtifactMetadata> getArtifactsByChecksum( String repositoryId, String checksum )
    throws MetadataRepositoryException
{
    List<ArtifactMetadata> artifacts;

    String q = getArtifactQuery( repositoryId ) + " AND ([sha1] = $checksum OR [md5] = $checksum)";

    try
    {
        Query query = getJcrSession().getWorkspace().getQueryManager().createQuery( q, Query.JCR_SQL2 );
        ValueFactory valueFactory = getJcrSession().getValueFactory();
        query.bindValue( "checksum", valueFactory.createValue( checksum ) );
        QueryResult result = query.execute();

        artifacts = new ArrayList<>();
        for ( Node n : JcrUtils.getNodes( result ) )
        {
            artifacts.add( getArtifactFromNode( repositoryId, n ) );
        }
    }
    catch ( RepositoryException e )
    {
        throw new MetadataRepositoryException( e.getMessage(), e );
    }
    return artifacts;
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:28,代码来源:JcrMetadataRepository.java

示例4: runJcrQuery

import javax.jcr.query.Query; //导入方法依赖的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

示例5: getWebResourceCachedInventoryPaths

import javax.jcr.query.Query; //导入方法依赖的package包/类
public Map<String, List<String>> getWebResourceCachedInventoryPaths(
		Session session, String webResourceGroupName)
		throws RepositoryException {
	Map<String, List<String>> result = new HashMap<String, List<String>>();
	Query query = session
			.getWorkspace()
			.getQueryManager()
			.createQuery(
					"SELECT * FROM [webresource:WebResourceGroup] as webResourceGroupSet WHERE webResourceGroupSet.[webresource:name] = $webResourceName",
					Query.JCR_SQL2);

	query.bindValue("webResourceName", session.getValueFactory()
			.createValue(webResourceGroupName));

	QueryResult queryResult = query.execute();

	NodeIterator queryIt = queryResult.getNodes();
	if (queryIt.hasNext()) {
		WebResourceGroup webResourceGroup = new WebResourceGroup(
				queryIt.nextNode());

		result.putAll(webResourceGroup.getInventory());

	}

	return result;

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

示例6: getArtifactsByDateRange

import javax.jcr.query.Query; //导入方法依赖的package包/类
@Override
public List<ArtifactMetadata> getArtifactsByDateRange( String repoId, Date startTime, Date endTime )
    throws MetadataRepositoryException
{
    List<ArtifactMetadata> artifacts;

    String q = getArtifactQuery( repoId );

    if ( startTime != null )
    {
        q += " AND [whenGathered] >= $start";
    }
    if ( endTime != null )
    {
        q += " AND [whenGathered] <= $end";
    }

    try
    {
        Query query = getJcrSession().getWorkspace().getQueryManager().createQuery( q, Query.JCR_SQL2 );
        ValueFactory valueFactory = getJcrSession().getValueFactory();
        if ( startTime != null )
        {
            query.bindValue( "start", valueFactory.createValue( createCalendar( startTime ) ) );
        }
        if ( endTime != null )
        {
            query.bindValue( "end", valueFactory.createValue( createCalendar( endTime ) ) );
        }
        QueryResult result = query.execute();

        artifacts = new ArrayList<>();
        for ( Node n : JcrUtils.getNodes( result ) )
        {
            artifacts.add( getArtifactFromNode( repoId, n ) );
        }
    }
    catch ( RepositoryException e )
    {
        throw new MetadataRepositoryException( e.getMessage(), e );
    }
    return artifacts;
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:44,代码来源:JcrMetadataRepository.java

示例7: runJcrQuery

import javax.jcr.query.Query; //导入方法依赖的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


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