Add querying use cases
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
qvalentin 2022-05-25 19:13:52 +02:00
parent fd4a2c0e83
commit 71b28222a7
8 changed files with 220 additions and 152 deletions

View file

@ -4,6 +4,7 @@ import category.CategoryName;
import link.LinkDto;
import link.LinkUrl;
import link.LinkUseCase;
import tag.TagName;
import user.Username;
import java.util.Set;
@ -11,19 +12,31 @@ import java.util.stream.Collectors;
public class LinkCliAdapter {
private final LinkUseCase linkUseCase;
private final LinkUseCase linkUseCase;
public LinkCliAdapter(LinkUseCase linkUseCase) {
this.linkUseCase = linkUseCase;
}
public LinkCliAdapter(LinkUseCase linkUseCase) {
this.linkUseCase = linkUseCase;
}
public void addLink(String url, Set<String> categoryNames, String creator) {
linkUseCase.addLink(new LinkUrl(url),
categoryNames.stream().map(CategoryName::new).collect(Collectors.toSet()),
new Username(creator));
}
public void addLink(String url, Set<String> categoryNames, String creator) {
linkUseCase.addLink(new LinkUrl(url),
categoryNames.stream().map(CategoryName::new).collect(Collectors.toSet()),
new Username(creator));
}
public Set<String> getLinks() {
return linkUseCase.getLinks().stream().map(LinkDto::toString).collect(Collectors.toSet());
}
public Set<String> getLinks() {
return linkUseCase.getLinks().stream().map(LinkDto::toString).collect(Collectors.toSet());
}
public Set<String> getLinksForCategory(String categoryName) {
return linkUseCase.getLinksForCategory(new CategoryName(categoryName)).stream().map(LinkDto::toString).collect(Collectors.toSet());
}
public Set<String> getLinksForTag(String tagName) {
return linkUseCase.getLinksForTag(new TagName(tagName)).stream().map(LinkDto::toString).collect(Collectors.toSet());
}
public Set<String> getLinksForUser(String userName) {
return linkUseCase.getLinksForUser(new Username(userName)).stream().map(LinkDto::toString).collect(Collectors.toSet());
}
}

View file

@ -4,16 +4,22 @@ import tag.CustomTagsUseCase;
import tag.TagName;
import tag.matcherImplementations.CustomTagMatcher;
import java.util.Set;
import java.util.stream.Collectors;
public class CustomTagsCliAdapter {
private final CustomTagsUseCase customTagsUseCase;
private final CustomTagsUseCase customTagsUseCase;
public CustomTagsCliAdapter(CustomTagsUseCase customTagsUseCase) {
this.customTagsUseCase = customTagsUseCase;
}
public CustomTagsCliAdapter(CustomTagsUseCase customTagsUseCase) {
this.customTagsUseCase = customTagsUseCase;
}
public void addCustomTagMatcher(String name, String regexString) {
customTagsUseCase.addCustomTagMatcher(new CustomTagMatcher(new TagName(name), regexString));
}
public void addCustomTagMatcher(String name, String regexString) {
customTagsUseCase.addCustomTagMatcher(new CustomTagMatcher(new TagName(name), regexString));
}
public Set<String> getAllTagNames() {
return customTagsUseCase.getAllTagNames().stream().map(TagName::toString).collect(Collectors.toSet());
}
}