-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #237 from kbss-cvut/development
[2.18.0] Release
- Loading branch information
Showing
24 changed files
with
759 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
161 changes: 161 additions & 0 deletions
161
src/main/java/cz/cvut/kbss/termit/dto/search/FacetedSearchResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
package cz.cvut.kbss.termit.dto.search; | ||
|
||
import cz.cvut.kbss.jopa.model.MultilingualString; | ||
import cz.cvut.kbss.jopa.model.annotations.*; | ||
import cz.cvut.kbss.jopa.vocabulary.SKOS; | ||
import cz.cvut.kbss.termit.model.Asset; | ||
import cz.cvut.kbss.termit.model.util.HasTypes; | ||
import cz.cvut.kbss.termit.util.Utils; | ||
import cz.cvut.kbss.termit.util.Vocabulary; | ||
|
||
import java.net.URI; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
/** | ||
* Represents the result of a faceted term search. | ||
* <p> | ||
* Contains only basic SKOS properties. | ||
*/ | ||
@OWLClass(iri = SKOS.CONCEPT) | ||
public class FacetedSearchResult extends Asset<MultilingualString> implements HasTypes { | ||
|
||
@OWLAnnotationProperty(iri = SKOS.PREF_LABEL) | ||
private MultilingualString label; | ||
|
||
@OWLAnnotationProperty(iri = SKOS.DEFINITION) | ||
private MultilingualString definition; | ||
|
||
@OWLAnnotationProperty(iri = SKOS.ALT_LABEL) | ||
private Set<MultilingualString> altLabels; | ||
|
||
@OWLAnnotationProperty(iri = SKOS.HIDDEN_LABEL) | ||
private Set<MultilingualString> hiddenLabels; | ||
|
||
@OWLAnnotationProperty(iri = SKOS.SCOPE_NOTE) | ||
private MultilingualString description; | ||
|
||
@OWLDataProperty(iri = SKOS.NOTATION, simpleLiteral = true) | ||
private Set<String> notations; | ||
|
||
@OWLAnnotationProperty(iri = SKOS.EXAMPLE) | ||
private Set<MultilingualString> examples; | ||
|
||
@Inferred | ||
@OWLObjectProperty(iri = cz.cvut.kbss.termit.util.Vocabulary.s_p_je_pojmem_ze_slovniku) | ||
private URI vocabulary; | ||
|
||
@OWLDataProperty(iri = Vocabulary.s_p_je_draft) | ||
private Boolean draft; | ||
|
||
@Types | ||
private Set<String> types; | ||
|
||
@Override | ||
public MultilingualString getLabel() { | ||
return label; | ||
} | ||
|
||
@Override | ||
public void setLabel(MultilingualString label) { | ||
this.label = label; | ||
} | ||
|
||
public MultilingualString getDefinition() { | ||
return definition; | ||
} | ||
|
||
public void setDefinition(MultilingualString definition) { | ||
this.definition = definition; | ||
} | ||
|
||
public Set<MultilingualString> getAltLabels() { | ||
return altLabels; | ||
} | ||
|
||
public void setAltLabels(Set<MultilingualString> altLabels) { | ||
this.altLabels = altLabels; | ||
} | ||
|
||
public Set<MultilingualString> getHiddenLabels() { | ||
return hiddenLabels; | ||
} | ||
|
||
public void setHiddenLabels(Set<MultilingualString> hiddenLabels) { | ||
this.hiddenLabels = hiddenLabels; | ||
} | ||
|
||
public MultilingualString getDescription() { | ||
return description; | ||
} | ||
|
||
public void setDescription(MultilingualString description) { | ||
this.description = description; | ||
} | ||
|
||
public Set<String> getNotations() { | ||
return notations; | ||
} | ||
|
||
public void setNotations(Set<String> notations) { | ||
this.notations = notations; | ||
} | ||
|
||
public Set<MultilingualString> getExamples() { | ||
return examples; | ||
} | ||
|
||
public void setExamples(Set<MultilingualString> examples) { | ||
this.examples = examples; | ||
} | ||
|
||
public URI getVocabulary() { | ||
return vocabulary; | ||
} | ||
|
||
public void setVocabulary(URI vocabulary) { | ||
this.vocabulary = vocabulary; | ||
} | ||
|
||
public Boolean isDraft() { | ||
return draft == null || draft; | ||
} | ||
|
||
public void setDraft(Boolean draft) { | ||
this.draft = draft; | ||
} | ||
|
||
public Set<String> getTypes() { | ||
return types; | ||
} | ||
|
||
public void setTypes(Set<String> types) { | ||
this.types = types; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (!(o instanceof FacetedSearchResult)) { | ||
return false; | ||
} | ||
FacetedSearchResult that = (FacetedSearchResult) o; | ||
return Objects.equals(getUri(), that.getUri()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(getUri()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "FacetedSearchResult{" + | ||
getLabel() + ' ' + | ||
Utils.uriToString(getUri()) + | ||
", types=" + getTypes() + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/cz/cvut/kbss/termit/dto/search/MatchType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package cz.cvut.kbss.termit.dto.search; | ||
|
||
/** | ||
* Describes how the property value should be matched in the data. | ||
*/ | ||
public enum MatchType { | ||
/** | ||
* Matches resource identifier in the repository. | ||
*/ | ||
IRI, | ||
/** | ||
* Matches the specified value as a substring of the string representation of a property value in the repository. | ||
* | ||
* Note that this match is not case-sensitive. | ||
*/ | ||
SUBSTRING, | ||
/** | ||
* Matches the specified value exactly to the string representation of a property value in the repository. | ||
*/ | ||
EXACT_MATCH | ||
} |
96 changes: 96 additions & 0 deletions
96
src/main/java/cz/cvut/kbss/termit/dto/search/SearchParam.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package cz.cvut.kbss.termit.dto.search; | ||
|
||
import cz.cvut.kbss.termit.exception.ValidationException; | ||
import cz.cvut.kbss.termit.util.Utils; | ||
|
||
import java.net.URI; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
/** | ||
* Parameter of the faceted term search. | ||
*/ | ||
public class SearchParam { | ||
|
||
private URI property; | ||
|
||
private Set<String> value; | ||
|
||
private MatchType matchType = MatchType.EXACT_MATCH; | ||
|
||
public SearchParam() { | ||
} | ||
|
||
// For test purposes | ||
public SearchParam(URI property, Set<String> value, MatchType matchType) { | ||
this.property = Objects.requireNonNull(property); | ||
this.value = value; | ||
this.matchType = Objects.requireNonNull(matchType); | ||
} | ||
|
||
public URI getProperty() { | ||
return property; | ||
} | ||
|
||
public void setProperty(URI property) { | ||
this.property = property; | ||
} | ||
|
||
public Set<String> getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(Set<String> value) { | ||
this.value = value; | ||
} | ||
|
||
public MatchType getMatchType() { | ||
return matchType; | ||
} | ||
|
||
public void setMatchType(MatchType matchType) { | ||
this.matchType = matchType; | ||
} | ||
|
||
/** | ||
* Validates this search parameter. | ||
* <p> | ||
* This mainly means checking that the values correspond to the match type, e.g., that a single value is provided | ||
* for string-matching types. | ||
*/ | ||
public void validate() { | ||
if (Utils.emptyIfNull(value).isEmpty() || property == null) { | ||
throw new ValidationException("Must provide a property and value to search by!"); | ||
} | ||
if (matchType != MatchType.IRI && Utils.emptyIfNull(value).size() != 1) { | ||
throw new ValidationException("Exactly one value must be provided for match type " + matchType); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (!(o instanceof SearchParam)) { | ||
return false; | ||
} | ||
SearchParam that = (SearchParam) o; | ||
return Objects.equals(property, that.property) | ||
&& Objects.equals(value, that.value) && matchType == that.matchType; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(property, value, matchType); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "SearchParam{" + | ||
"property=" + Utils.uriToString(property) + | ||
", value='" + value + '\'' + | ||
", matchType=" + matchType + | ||
'}'; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/cz/cvut/kbss/termit/exception/UnsupportedSearchFacetException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package cz.cvut.kbss.termit.exception; | ||
|
||
/** | ||
* Indicates that an unsupported facet was provided to faceted search. | ||
*/ | ||
public class UnsupportedSearchFacetException extends TermItException { | ||
|
||
public UnsupportedSearchFacetException(String message) { | ||
super(message); | ||
} | ||
} |
Oops, something went wrong.