當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。