001: /*
002: * Copyright 2004 Outerthought bvba and Schaubroeck nv
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.outerj.daisy.query;
017:
018: import org.outerj.daisy.repository.*;
019: import org.outerj.daisy.repository.namespace.Namespace;
020: import org.outerj.daisy.repository.namespace.NamespaceNotFoundException;
021: import org.outerj.daisy.repository.commonimpl.DocId;
022: import org.outerj.daisy.repository.variant.Branch;
023: import org.outerj.daisy.repository.variant.Language;
024: import org.outerj.daisy.repository.schema.FieldType;
025: import org.outerj.daisy.repository.schema.DocumentType;
026: import org.outerj.daisy.repository.schema.PartType;
027:
028: public class ExtQueryContext implements QueryContext {
029: private final Repository repository;
030:
031: public ExtQueryContext(Repository repository) {
032: this .repository = repository;
033: }
034:
035: public Document getDocument(VariantKey variantKey)
036: throws RepositoryException {
037: return repository.getDocument(variantKey, false);
038: }
039:
040: public FieldType getFieldTypeByName(String name)
041: throws RepositoryException {
042: return repository.getRepositorySchema().getFieldTypeByName(
043: name, false);
044: }
045:
046: public PartType getPartTypeByName(String name)
047: throws RepositoryException {
048: return repository.getRepositorySchema().getPartTypeByName(name,
049: false);
050: }
051:
052: public DocumentType getDocumentTypeByName(String name)
053: throws RepositoryException {
054: return repository.getRepositorySchema().getDocumentTypeByName(
055: name, false);
056: }
057:
058: public DocumentCollection getCollection(String name)
059: throws RepositoryException {
060: return repository.getCollectionManager().getCollection(name,
061: false);
062: }
063:
064: public DocumentType getDocumentTypeById(long id)
065: throws RepositoryException {
066: return repository.getRepositorySchema().getDocumentTypeById(id,
067: false);
068: }
069:
070: public String getUserDisplayName(long userId)
071: throws RepositoryException {
072: return repository.getUserManager().getUserDisplayName(userId);
073: }
074:
075: public long getUserId(String login) throws RepositoryException {
076: return repository.getUserManager().getUserId(login);
077: }
078:
079: public long getUserId() {
080: return repository.getUserId();
081: }
082:
083: public String getUserLogin(long userId) throws RepositoryException {
084: return repository.getUserManager().getUserLogin(userId);
085: }
086:
087: public Branch getBranchByName(String name)
088: throws RepositoryException {
089: return repository.getVariantManager().getBranch(name, false);
090: }
091:
092: public Language getLanguageByName(String name)
093: throws RepositoryException {
094: return repository.getVariantManager().getLanguage(name, false);
095: }
096:
097: public Branch getBranch(long branchId) throws RepositoryException {
098: return repository.getVariantManager()
099: .getBranch(branchId, false);
100: }
101:
102: public Branch getBranch(String branchIdOrName)
103: throws RepositoryException {
104: return repository.getVariantManager().getBranch(branchIdOrName,
105: false);
106: }
107:
108: public Language getLanguage(long languageId)
109: throws RepositoryException {
110: return repository.getVariantManager().getLanguage(languageId,
111: false);
112: }
113:
114: public Language getLanguage(String languageIdOrName)
115: throws RepositoryException {
116: return repository.getVariantManager().getLanguage(
117: languageIdOrName, false);
118: }
119:
120: public DocId parseDocId(String documentId) {
121: return DocId.parseDocId(documentId, repository);
122: }
123:
124: public Namespace getNamespace(String namespaceName)
125: throws NamespaceNotFoundException {
126: return repository.getNamespaceManager().getNamespace(
127: namespaceName);
128: }
129:
130: public String getRepositoryNamespace() {
131: return repository.getNamespace();
132: }
133: }
|