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


Java SearchObjectType类代码示例

本文整理汇总了Java中com.gitblit.Constants.SearchObjectType的典型用法代码示例。如果您正苦于以下问题:Java SearchObjectType类的具体用法?Java SearchObjectType怎么用?Java SearchObjectType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: deleteBlob

import com.gitblit.Constants.SearchObjectType; //导入依赖的package包/类
/**
 * Delete a blob from the specified branch of the repository index.
 * 
 * @param repositoryName
 * @param branch
 * @param path
 * @throws Exception
 * @return true, if deleted, false if no record was deleted
 */
public boolean deleteBlob(String repositoryName, String branch, String path) throws Exception {
	String pattern = MessageFormat.format("{0}:'{'0} AND {1}:\"'{'1'}'\" AND {2}:\"'{'2'}'\"", FIELD_OBJECT_TYPE, FIELD_BRANCH, FIELD_PATH);
	String q = MessageFormat.format(pattern, SearchObjectType.blob.name(), branch, path);

	BooleanQuery query = new BooleanQuery();
	StandardAnalyzer analyzer = new StandardAnalyzer();
	QueryParser qp = new QueryParser(FIELD_SUMMARY, analyzer);
	query.add(qp.parse(q), Occur.MUST);

	IndexWriter writer = getIndexWriter(repositoryName);
	int numDocsBefore = writer.numDocs();
	writer.deleteDocuments(query);
	writer.commit();
	int numDocsAfter = writer.numDocs();
	if (numDocsBefore == numDocsAfter) {
		logger.debug(MessageFormat.format("no records found to delete {0}", query.toString()));
		return false;
	} else {
		logger.debug(MessageFormat.format("deleted {0} records with {1}", numDocsBefore - numDocsAfter, query.toString()));
		return true;
	}
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:32,代码来源:LuceneService.java

示例2: createSearchResult

import com.gitblit.Constants.SearchObjectType; //导入依赖的package包/类
private SearchResult createSearchResult(Document doc, float score, int hitId, int totalHits) throws ParseException {
	SearchResult result = new SearchResult();
	result.hitId = hitId;
	result.totalHits = totalHits;
	result.score = score;
	result.date = DateTools.stringToDate(doc.get(FIELD_DATE));
	result.summary = doc.get(FIELD_SUMMARY);
	result.author = doc.get(FIELD_AUTHOR);
	result.committer = doc.get(FIELD_COMMITTER);
	result.type = SearchObjectType.fromName(doc.get(FIELD_OBJECT_TYPE));
	result.branch = doc.get(FIELD_BRANCH);
	result.commitId = doc.get(FIELD_COMMIT);
	result.path = doc.get(FIELD_PATH);
	if (doc.get(FIELD_TAG) != null) {
		result.tags = StringUtils.getStringsFromValue(doc.get(FIELD_TAG));
	}
	return result;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:19,代码来源:LuceneService.java

示例3: deleteIssue

import com.gitblit.Constants.SearchObjectType; //导入依赖的package包/类
/**
 * Delete an issue from the repository index.
 * 
 * @param repositoryName
 * @param issueId
 * @throws Exception
 * @return true, if deleted, false if no record was deleted
 */
private boolean deleteIssue(String repositoryName, String issueId) throws Exception {
	BooleanQuery query = new BooleanQuery();
	Term objectTerm = new Term(FIELD_OBJECT_TYPE, SearchObjectType.issue.name());
	query.add(new TermQuery(objectTerm), Occur.MUST);
	Term issueidTerm = new Term(FIELD_ISSUE, issueId);
	query.add(new TermQuery(issueidTerm), Occur.MUST);
	
	IndexWriter writer = getIndexWriter(repositoryName);
	int numDocsBefore = writer.numDocs();
	writer.deleteDocuments(query);
	writer.commit();
	int numDocsAfter = writer.numDocs();
	if (numDocsBefore == numDocsAfter) {
		logger.debug(MessageFormat.format("no records found to delete {0}", query.toString()));
		return false;
	} else {
		logger.debug(MessageFormat.format("deleted {0} records with {1}", numDocsBefore - numDocsAfter, query.toString()));
		return true;
	}
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:29,代码来源:LuceneExecutor.java

示例4: deleteBlob

import com.gitblit.Constants.SearchObjectType; //导入依赖的package包/类
/**
 * Delete a blob from the specified branch of the repository index.
 * 
 * @param repositoryName
 * @param branch
 * @param path
 * @throws Exception
 * @return true, if deleted, false if no record was deleted
 */
public boolean deleteBlob(String repositoryName, String branch, String path) throws Exception {
	String pattern = MessageFormat.format("{0}:'{'0} AND {1}:\"'{'1'}'\" AND {2}:\"'{'2'}'\"", FIELD_OBJECT_TYPE, FIELD_BRANCH, FIELD_PATH);
	String q = MessageFormat.format(pattern, SearchObjectType.blob.name(), branch, path);
	
	BooleanQuery query = new BooleanQuery();
	StandardAnalyzer analyzer = new StandardAnalyzer(LUCENE_VERSION);
	QueryParser qp = new QueryParser(LUCENE_VERSION, FIELD_SUMMARY, analyzer);
	query.add(qp.parse(q), Occur.MUST);

	IndexWriter writer = getIndexWriter(repositoryName);
	int numDocsBefore = writer.numDocs();
	writer.deleteDocuments(query);		
	writer.commit();
	int numDocsAfter = writer.numDocs();
	if (numDocsBefore == numDocsAfter) {
		logger.debug(MessageFormat.format("no records found to delete {0}", query.toString()));
		return false;
	} else {
		logger.debug(MessageFormat.format("deleted {0} records with {1}", numDocsBefore - numDocsAfter, query.toString()));
		return true;
	}
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:32,代码来源:LuceneExecutor.java

示例5: createDocument

import com.gitblit.Constants.SearchObjectType; //导入依赖的package包/类
/**
 * Creates a Lucene document from an issue.
 * 
 * @param issue
 * @return a Lucene document
 */
private Document createDocument(IssueModel issue) {
	Document doc = new Document();
	doc.add(new Field(FIELD_OBJECT_TYPE, SearchObjectType.issue.name(), Store.YES,
			Field.Index.NOT_ANALYZED));
	doc.add(new Field(FIELD_ISSUE, issue.id, Store.YES, Index.ANALYZED));
	doc.add(new Field(FIELD_BRANCH, IssueUtils.GB_ISSUES, Store.YES, Index.ANALYZED));
	doc.add(new Field(FIELD_DATE, DateTools.dateToString(issue.created, Resolution.MINUTE),
			Store.YES, Field.Index.NO));
	doc.add(new Field(FIELD_AUTHOR, issue.reporter, Store.YES, Index.ANALYZED));
	List<String> attachments = new ArrayList<String>();
	for (Attachment attachment : issue.getAttachments()) {
		attachments.add(attachment.name.toLowerCase());
	}
	doc.add(new Field(FIELD_ATTACHMENT, StringUtils.flattenStrings(attachments), Store.YES,
			Index.ANALYZED));
	doc.add(new Field(FIELD_SUMMARY, issue.summary, Store.YES, Index.ANALYZED));
	doc.add(new Field(FIELD_CONTENT, issue.toString(), Store.YES, Index.ANALYZED));
	doc.add(new Field(FIELD_LABEL, StringUtils.flattenStrings(issue.getLabels()), Store.YES,
			Index.ANALYZED));
	return doc;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:28,代码来源:LuceneExecutor.java

示例6: createSearchResult

import com.gitblit.Constants.SearchObjectType; //导入依赖的package包/类
private SearchResult createSearchResult(Document doc, float score, int hitId, int totalHits) throws ParseException {
	SearchResult result = new SearchResult();
	result.hitId = hitId;
	result.totalHits = totalHits;
	result.score = score;
	result.date = DateTools.stringToDate(doc.get(FIELD_DATE));
	result.summary = doc.get(FIELD_SUMMARY);		
	result.author = doc.get(FIELD_AUTHOR);
	result.committer = doc.get(FIELD_COMMITTER);
	result.type = SearchObjectType.fromName(doc.get(FIELD_OBJECT_TYPE));
	result.branch = doc.get(FIELD_BRANCH);
	result.commitId = doc.get(FIELD_COMMIT);
	result.issueId = doc.get(FIELD_ISSUE);
	result.path = doc.get(FIELD_PATH);
	if (doc.get(FIELD_TAG) != null) {
		result.tags = StringUtils.getStringsFromValue(doc.get(FIELD_TAG));
	}
	if (doc.get(FIELD_LABEL) != null) {
		result.labels = StringUtils.getStringsFromValue(doc.get(FIELD_LABEL));
	}
	return result;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:23,代码来源:LuceneExecutor.java

示例7: createDocument

import com.gitblit.Constants.SearchObjectType; //导入依赖的package包/类
/**
 * Creates a Lucene document for a commit
 * 
 * @param commit
 * @param tags
 * @return a Lucene document
 */
private Document createDocument(RevCommit commit, List<String> tags) {
	Document doc = new Document();
	doc.add(new Field(FIELD_OBJECT_TYPE, SearchObjectType.commit.name(), StringField.TYPE_STORED));
	doc.add(new Field(FIELD_COMMIT, commit.getName(), TextField.TYPE_STORED));
	doc.add(new Field(FIELD_DATE, DateTools.timeToString(commit.getCommitTime() * 1000L, Resolution.MINUTE), StringField.TYPE_STORED));
	doc.add(new Field(FIELD_AUTHOR, getAuthor(commit), TextField.TYPE_STORED));
	doc.add(new Field(FIELD_COMMITTER, getCommitter(commit), TextField.TYPE_STORED));
	doc.add(new Field(FIELD_SUMMARY, commit.getShortMessage(), TextField.TYPE_STORED));
	doc.add(new Field(FIELD_CONTENT, commit.getFullMessage(), TextField.TYPE_STORED));
	if (!ArrayUtils.isEmpty(tags)) {
		doc.add(new Field(FIELD_TAG, StringUtils.flattenStrings(tags), TextField.TYPE_STORED));
	}
	return doc;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:22,代码来源:LuceneService.java


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