public class ContainingWorkspaceBridge implements FieldBridge {
@Override
public void set(String name, Object value, Document luceneDocument,
LuceneOptions luceneOptions) {
HDocument doc;
if (value instanceof HTextFlow) {
doc = ((HTextFlow) value).getDocument();
} else if (value instanceof HDocument) {
doc = (HDocument) value;
} else {
throw new IllegalArgumentException(
"ContainingWorkspaceBridge used on a non HDocument or HTextFlow type");
}
HProjectIteration iteration = doc.getProjectIteration();
HProject project = iteration.getProject();
addStringField(IndexFieldLabels.PROJECT_FIELD, project.getSlug(),
luceneDocument, luceneOptions);
addStringField(IndexFieldLabels.ITERATION_FIELD, iteration.getSlug(),
luceneDocument, luceneOptions);
addStringField(IndexFieldLabels.DOCUMENT_ID_FIELD, doc.getDocId(),
luceneDocument, luceneOptions);
}