Skip to content

Commit

Permalink
Merge pull request #237 from kbss-cvut/development
Browse files Browse the repository at this point in the history
[2.18.0] Release
  • Loading branch information
ledsoft authored Jun 29, 2023
2 parents bcab0f0 + a36a287 commit 5232f3b
Show file tree
Hide file tree
Showing 24 changed files with 759 additions and 94 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ ij_any_array_initializer_wrap = normal
ij_any_align_multiline_array_initializer_expression = true
ij_java_annotation_parameter_wrap = normal
ij_java_align_multiline_annotation_parameters = true
ij_java_class_count_to_use_import_on_demand = 100
ij_java_names_count_to_use_import_on_demand = 100
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,14 @@ This section briefly lists the main technologies and principles used (or planned

- Spring Boot 2, Spring Framework 5, Spring Security, Spring Data (paging, filtering)
- Jackson 2.13
- [JB4JSON-LD](https://github.com/kbss-cvut/jb4jsonld-jackson)* - Java - JSON-LD (de)serialization library
- [JB4JSON-LD](https://github.com/kbss-cvut/jb4jsonld-jackson) - Java - JSON-LD (de)serialization library
- [JOPA](https://github.com/kbss-cvut/jopa) - persistence library for the Semantic Web
- JUnit 5* (RT used 4), Mockito 4* (RT used 1), Hamcrest 2* (RT used 1)
- Servlet API 4* (RT used 3.0.1)
- JSON Web Tokens* (CSRF protection not necessary for JWT)
- JUnit 5 (RT used 4), Mockito 4 (RT used 1), Hamcrest 2 (RT used 1)
- Servlet API 4 (RT used 3.0.1)
- JSON Web Tokens (CSRF protection not necessary for JWT)
- SLF4J + Logback
- CORS* (for separate frontend)
- Java bean validation (JSR 380)*

_* Technology not used in [INBAS RT](https://github.com/kbss-cvut/reporting-tool)_
- CORS (for separate frontend)
- Java bean validation (JSR 380)


## Ontology
Expand All @@ -63,21 +61,24 @@ the [JavaMelody Spring Boot Starter docs](https://github.com/javamelody/javamelo

## Documentation

TermIt REST API is tentatively documented on [SwaggerHub](https://app.swaggerhub.com/apis/ledvima1/TermIt/) under the
appropriate version.
TermIt REST API is available for each instance via [Swagger UI](https://swagger.io/tools/swagger-ui/). It is accessible
at `http://SERVER_URL/PATH/swagger-ui/index.html`, where `SERVER_URL` is the URL of the server at which TermIt backend
is running and `PATH` is the context path. A link to the API documentation is also available in the footer of the TermIt UI.

Build configuration and deployment is described in [setup.md](doc/setup.md).

## Dockerization
## Docker

The docker image of TermIt backend can be built by
The Docker image of TermIt backend alone can be built by
`docker build -t termit-server .`

Then, TermIt can be run and exposed at the port 8080 as
`sudo docker run -e REPOSITORY_URL=<GRAPHDB_REPOSITORY_URL> -p 8080:8080 termit-server`

An optional argument is `<GRAPHDB_REPOSITORY_URL>` pointing to the RDF4J/GraphDB repository.

TermIt Docker images are also build and published to [DockerHub](https://hub.docker.com/r/kbsscvut/termit).

## Links

- [TermIt UI](https://github.com/kbss-cvut/termit-ui) - repository with TermIt frontend source code
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parent>

<artifactId>termit</artifactId>
<version>2.17.0</version>
<version>2.18.0</version>
<name>TermIt</name>
<description>Terminology manager based on Semantic Web technologies.</description>
<packaging>${packaging}</packaging>
Expand Down
161 changes: 161 additions & 0 deletions src/main/java/cz/cvut/kbss/termit/dto/search/FacetedSearchResult.java
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() +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
* You should have received a copy of the GNU General Public License along with this program. If not, see
* <https://www.gnu.org/licenses/>.
*/
package cz.cvut.kbss.termit.dto;
package cz.cvut.kbss.termit.dto.search;

import cz.cvut.kbss.jopa.model.annotations.*;
import cz.cvut.kbss.jopa.vocabulary.RDFS;
import cz.cvut.kbss.termit.model.util.HasIdentifier;
import cz.cvut.kbss.termit.model.util.HasTypes;
import cz.cvut.kbss.termit.util.Vocabulary;

Expand All @@ -38,7 +39,7 @@
type = String.class),
@VariableResult(name = "score", type = Double.class)
})})
public class FullTextSearchResult implements HasTypes, Serializable {
public class FullTextSearchResult implements HasIdentifier, HasTypes, Serializable {

@Id
private URI uri;
Expand Down Expand Up @@ -80,10 +81,12 @@ public FullTextSearchResult(URI uri, String label, URI vocabulary, Boolean draft
this.score = score;
}

@Override
public URI getUri() {
return uri;
}

@Override
public void setUri(URI uri) {
this.uri = uri;
}
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/cz/cvut/kbss/termit/dto/search/MatchType.java
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 src/main/java/cz/cvut/kbss/termit/dto/search/SearchParam.java
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 +
'}';
}
}
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);
}
}
Loading

0 comments on commit 5232f3b

Please sign in to comment.