use of com.b2international.snowowl.core.api.IBranchPath in project snow-owl by b2ihealthcare.
the class CreateMergeRequestBuilder method doBuild.
@Override
protected Request<RepositoryContext, Merge> doBuild() {
final IBranchPath sourcePath = BranchPathUtils.createPath(source);
final IBranchPath targetPath = BranchPathUtils.createPath(target);
if (targetPath.getParent().equals(sourcePath)) {
return new BranchRebaseRequest(source, target, userId, commitComment, parentLockContext);
} else {
return new BranchMergeRequest(source, target, Collections3.toImmutableSet(exclusions), userId, commitComment, parentLockContext, squash);
}
}
use of com.b2international.snowowl.core.api.IBranchPath 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());
}
use of com.b2international.snowowl.core.api.IBranchPath in project snow-owl by b2ihealthcare.
the class SnomedExportApiTest method exportContentFromVersionFixerTask.
@Test
public void exportContentFromVersionFixerTask() throws Exception {
String codeSystemShortName = "SNOMEDCT-FIXERTASK";
createCodeSystem(branchPath, codeSystemShortName).statusCode(201);
// create a refset, a concept, and reference the concept from the refset
final String createdRefSetId = createNewRefSet(branchPath, SnomedRefSetType.SIMPLE);
final String createdConceptId = createNewConcept(branchPath, ROOT_CONCEPT);
final String memberId = createNewRefSetMember(branchPath, createdConceptId, createdRefSetId);
final String versionEffectiveTime = "20170301";
createVersion(codeSystemShortName, "v1", EffectiveTimes.parse(versionEffectiveTime, DateFormats.SHORT)).statusCode(201);
IBranchPath versionPath = BranchPathUtils.createPath(branchPath, "v1");
IBranchPath taskBranch = BranchPathUtils.createPath(versionPath, "Fix01");
// create fixer branch for version branch
branching.createBranch(taskBranch).statusCode(201);
// change an existing component
final String newEffectiveTime = "20170302";
updateRefSetMemberEffectiveTime(taskBranch, memberId, newEffectiveTime);
getComponent(taskBranch, SnomedComponentType.MEMBER, memberId).statusCode(200).body("effectiveTime", equalTo(newEffectiveTime)).body("released", equalTo(true));
// add a new component with the same effective time as the version branch
final String unpublishedMemberId = createNewRefSetMember(taskBranch, createdConceptId, createdRefSetId);
updateRefSetMemberEffectiveTime(taskBranch, unpublishedMemberId, versionEffectiveTime);
getComponent(taskBranch, SnomedComponentType.MEMBER, unpublishedMemberId).statusCode(200).body("effectiveTime", equalTo(versionEffectiveTime)).body("released", equalTo(true));
final Map<String, Object> config = ImmutableMap.<String, Object>builder().put("type", Rf2ReleaseType.SNAPSHOT.name()).put("startEffectiveTime", versionEffectiveTime).build();
final File exportArchive = doExport(taskBranch, config);
String refsetMemberLine = getComponentLine(List.<String>of(memberId, newEffectiveTime, "1", MODULE_SCT_CORE, createdRefSetId, createdConceptId));
String invalidRefsetMemberLine = getComponentLine(List.<String>of(memberId, versionEffectiveTime, "1", MODULE_SCT_CORE, createdRefSetId, createdConceptId));
String newRefsetMemberLine = getComponentLine(List.<String>of(unpublishedMemberId, versionEffectiveTime, "1", MODULE_SCT_CORE, createdRefSetId, createdConceptId));
final Multimap<String, Pair<Boolean, String>> fileToLinesMap = ArrayListMultimap.<String, Pair<Boolean, String>>create();
String refsetFileName = "der2_Refset_SimpleSnapshot";
fileToLinesMap.put(refsetFileName, Pair.of(true, refsetMemberLine));
fileToLinesMap.put(refsetFileName, Pair.of(true, newRefsetMemberLine));
fileToLinesMap.put(refsetFileName, Pair.of(false, invalidRefsetMemberLine));
assertArchiveContainsLines(exportArchive, fileToLinesMap);
}
use of com.b2international.snowowl.core.api.IBranchPath in project snow-owl by b2ihealthcare.
the class SnomedRelationshipApiTest method deleteRelationshipOnNestedBranch.
@Test
public void deleteRelationshipOnNestedBranch() {
String conceptId = createNewConcept(branchPath);
List<String> typeIds = newArrayList();
for (int i = 0; i < 10; i++) {
String typeId = createNewConcept(branchPath);
typeIds.add(typeId);
}
List<String> relationshipIds = newArrayList();
for (int i = 0; i < 10; i++) {
String relationshipId = createNewRelationship(branchPath, conceptId, typeIds.get(i), Concepts.NAMESPACE_ROOT);
relationshipIds.add(relationshipId);
}
IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
IBranchPath b = BranchPathUtils.createPath(a, "b");
branching.createBranchRecursively(b);
// New relationship on nested branch resets the concept's version to 1 again
createNewRelationship(b, conceptId, Concepts.PART_OF, Concepts.NAMESPACE_ROOT);
// Deleting a relationship from the middle should work
String relationshipToDeleteId = relationshipIds.remove(7);
deleteComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipToDeleteId, false).statusCode(204);
getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipToDeleteId).statusCode(404);
deleteComponent(b, SnomedComponentType.RELATIONSHIP, relationshipToDeleteId, false).statusCode(204);
getComponent(b, SnomedComponentType.RELATIONSHIP, relationshipToDeleteId).statusCode(404);
// All the remaining relationships should be visible
for (String relationshipId : relationshipIds) {
getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId).statusCode(200);
getComponent(b, SnomedComponentType.RELATIONSHIP, relationshipId).statusCode(200);
}
}
use of com.b2international.snowowl.core.api.IBranchPath in project snow-owl by b2ihealthcare.
the class SnomedExportApiTest method exportDeltaInDateRangeFromVersion.
@Test
public void exportDeltaInDateRangeFromVersion() throws Exception {
createCodeSystem(branchPath, "SNOMEDCT-DELTA").statusCode(201);
String statedRelationshipId = createNewRelationship(branchPath, Concepts.ROOT_CONCEPT, Concepts.PART_OF, Concepts.NAMESPACE_ROOT, Concepts.STATED_RELATIONSHIP);
String inferredRelationshipId = createNewRelationship(branchPath, Concepts.ROOT_CONCEPT, Concepts.PART_OF, Concepts.NAMESPACE_ROOT, Concepts.INFERRED_RELATIONSHIP);
String additionalRelationshipId = createNewRelationship(branchPath, Concepts.ROOT_CONCEPT, Concepts.PART_OF, Concepts.NAMESPACE_ROOT, Concepts.ADDITIONAL_RELATIONSHIP);
String versionEffectiveTime = "20170302";
createVersion("SNOMEDCT-DELTA", "v1", EffectiveTimes.parse(versionEffectiveTime, DateFormats.SHORT)).statusCode(201);
IBranchPath versionPath = BranchPathUtils.createPath(branchPath, "v1");
Map<String, ?> config = ImmutableMap.<String, Object>builder().put("type", Rf2ReleaseType.DELTA.name()).put("startEffectiveTime", versionEffectiveTime).put("endEffectiveTime", versionEffectiveTime).build();
File exportArchive = doExport(versionPath, config);
String statedLine = TAB_JOINER.join(statedRelationshipId, versionEffectiveTime, "1", Concepts.MODULE_SCT_CORE, Concepts.ROOT_CONCEPT, Concepts.NAMESPACE_ROOT, "0", Concepts.PART_OF, Concepts.STATED_RELATIONSHIP, Concepts.EXISTENTIAL_RESTRICTION_MODIFIER);
String inferredLine = TAB_JOINER.join(inferredRelationshipId, versionEffectiveTime, "1", Concepts.MODULE_SCT_CORE, Concepts.ROOT_CONCEPT, Concepts.NAMESPACE_ROOT, "0", Concepts.PART_OF, Concepts.INFERRED_RELATIONSHIP, Concepts.EXISTENTIAL_RESTRICTION_MODIFIER);
String additionalLine = TAB_JOINER.join(additionalRelationshipId, versionEffectiveTime, "1", Concepts.MODULE_SCT_CORE, Concepts.ROOT_CONCEPT, Concepts.NAMESPACE_ROOT, "0", Concepts.PART_OF, Concepts.ADDITIONAL_RELATIONSHIP, Concepts.EXISTENTIAL_RESTRICTION_MODIFIER);
Multimap<String, Pair<Boolean, String>> fileToLinesMap = ArrayListMultimap.<String, Pair<Boolean, String>>create();
fileToLinesMap.put("sct2_StatedRelationship", Pair.of(true, statedLine));
fileToLinesMap.put("sct2_StatedRelationship", Pair.of(false, inferredLine));
fileToLinesMap.put("sct2_StatedRelationship", Pair.of(false, additionalLine));
fileToLinesMap.put("sct2_Relationship", Pair.of(false, statedLine));
fileToLinesMap.put("sct2_Relationship", Pair.of(true, inferredLine));
fileToLinesMap.put("sct2_Relationship", Pair.of(true, additionalLine));
assertArchiveContainsLines(exportArchive, fileToLinesMap);
}
Aggregations