Search in sources :

Example 6 with RevisionBranch

use of com.b2international.index.revision.RevisionBranch in project snow-owl by b2ihealthcare.

the class CodeSystemConverter method expandExtensionOfBranchState.

private void expandExtensionOfBranchState(List<CodeSystem> results) {
    if (!expand().containsKey(CodeSystem.Expand.EXTENSION_OF_BRANCH_INFO)) {
        return;
    }
    // extensionOf branches are the parent branches of the CodeSystem, so simple branch state calculation is enough
    BaseRevisionBranching branching = context().service(BaseRevisionBranching.class);
    for (CodeSystem result : results) {
        RevisionBranch branch = branching.getBranch(result.getBranchPath());
        BranchState branchState = branching.getBranchState(branch);
        result.setExtensionOfBranchInfo(new BranchInfo(branch.getPath(), branchState, branch.getBaseTimestamp(), branch.getHeadTimestamp()));
    }
}
Also used : RevisionBranch(com.b2international.index.revision.RevisionBranch) BranchInfo(com.b2international.snowowl.core.branch.BranchInfo) BranchState(com.b2international.index.revision.RevisionBranch.BranchState) BaseRevisionBranching(com.b2international.index.revision.BaseRevisionBranching)

Example 7 with RevisionBranch

use of com.b2international.index.revision.RevisionBranch in project snow-owl by b2ihealthcare.

the class LocksCommand method parseLockTarget.

private static DatastoreLockTarget parseLockTarget(final String lockTargetOrAll) {
    if (ALL.equalsIgnoreCase(lockTargetOrAll)) {
        return DatastoreLockTarget.ALL;
    }
    final String repositoryId;
    final String path;
    String[] parts = lockTargetOrAll.split(":");
    if (parts.length == 2) {
        repositoryId = parts[0];
        path = parts[1];
    } else if (parts.length == 1) {
        repositoryId = parts[0];
        path = null;
    } else {
        return null;
    }
    final RepositoryManager repositoryManager = ApplicationContext.getInstance().getService(RepositoryManager.class);
    final Repository repository = repositoryManager.get(repositoryId);
    if (null == repository) {
        return null;
    }
    if (Strings.isNullOrEmpty(path)) {
        return new DatastoreLockTarget(repositoryId, null);
    }
    final IBranchPath branchPath = BranchPathUtils.createPath(path);
    // assuming active connection manager service here
    RevisionBranch branch = repository.service(BaseRevisionBranching.class).getBranch(path);
    if (null == branch) {
        return null;
    }
    return new DatastoreLockTarget(repositoryId, branchPath.getPath());
}
Also used : Repository(com.b2international.snowowl.core.Repository) RevisionBranch(com.b2international.index.revision.RevisionBranch) RepositoryManager(com.b2international.snowowl.core.RepositoryManager) DatastoreLockTarget(com.b2international.snowowl.core.internal.locks.DatastoreLockTarget) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) BaseRevisionBranching(com.b2international.index.revision.BaseRevisionBranching)

Aggregations

RevisionBranch (com.b2international.index.revision.RevisionBranch)7 BaseRevisionBranching (com.b2international.index.revision.BaseRevisionBranching)6 BranchState (com.b2international.index.revision.RevisionBranch.BranchState)3 RepositoryManager (com.b2international.snowowl.core.RepositoryManager)2 BranchInfo (com.b2international.snowowl.core.branch.BranchInfo)2 NotFoundException (com.b2international.commons.exceptions.NotFoundException)1 ExtendedLocale (com.b2international.commons.http.ExtendedLocale)1 Options (com.b2international.commons.options.Options)1 RevisionSegment (com.b2international.index.revision.RevisionSegment)1 Repository (com.b2international.snowowl.core.Repository)1 ResourceURI (com.b2international.snowowl.core.ResourceURI)1 IBranchPath (com.b2international.snowowl.core.api.IBranchPath)1 RepositoryContext (com.b2international.snowowl.core.domain.RepositoryContext)1 ResourceDocument (com.b2international.snowowl.core.internal.ResourceDocument)1 DatastoreLockTarget (com.b2international.snowowl.core.internal.locks.DatastoreLockTarget)1 BaseResourceConverter (com.b2international.snowowl.core.request.BaseResourceConverter)1 ResourceRequests (com.b2international.snowowl.core.request.ResourceRequests)1 ResourceURIPathResolver (com.b2international.snowowl.core.uri.ResourceURIPathResolver)1 Version (com.b2international.snowowl.core.version.Version)1 Versions (com.b2international.snowowl.core.version.Versions)1