Skip to content

Commit

Permalink
Merge pull request #321 from kbss-cvut/development
Browse files Browse the repository at this point in the history
[3.4.0] Release
  • Loading branch information
ledsoft authored Dec 3, 2024
2 parents c2f32e0 + c1efa5e commit d3ef655
Show file tree
Hide file tree
Showing 72 changed files with 2,283 additions and 460 deletions.
1 change: 1 addition & 0 deletions doc/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ by the application:
* `lucene` - decides whether Lucene text indexing is enabled and should be used in full text search queries.
* `admin-registration-only` - decides whether new users can be registered only by application admin, or whether anyone can register.
* `no-cache` - disables Ehcache, which is used to cache lists of resources and vocabularies for faster retrieval, and persistence cache.
* `development` - indicates that the application is running is development. This, for example, means that mail server does not need to be configured.

The `lucene` Spring profile is activated automatically by the `graphdb` Maven. `admin-registration-only` and `no-cache` have to be added
either in `application.yml` directly, or one can pass the parameter to Maven build, e.g.:
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.4</version>
<version>3.3.5</version>
</parent>

<artifactId>termit</artifactId>
<version>3.3.0</version>
<version>3.4.0</version>
<name>TermIt</name>
<description>Terminology manager based on Semantic Web technologies.</description>
<packaging>${packaging}</packaging>
Expand All @@ -31,7 +31,7 @@
<org.apache.tika.tika-core.version>3.0.0</org.apache.tika.tika-core.version>
<org.mapstruct.version>1.6.2</org.mapstruct.version>
<org.springdoc.version>2.6.0</org.springdoc.version>
<cz.cvut.kbss.jopa.version>2.1.0</cz.cvut.kbss.jopa.version>
<cz.cvut.kbss.jopa.version>2.2.0</cz.cvut.kbss.jopa.version>
<cz.cvut.kbss.jsonld.version>0.15.0</cz.cvut.kbss.jsonld.version>

<!-- Default value for deployment type property which should otherwise specified on command line -->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package cz.cvut.kbss.termit.dto.filter;

import com.fasterxml.jackson.annotation.JsonIgnore;
import cz.cvut.kbss.termit.util.Utils;

import java.net.URI;
import java.util.Objects;

/**
* Represents parameters for filtering vocabulary content changes.
*/
public class ChangeRecordFilterDto {
private String assetLabel = "";
private String changedAttributeName = "";
private String authorName = "";
private URI changeType = null;

public ChangeRecordFilterDto() {
}

public ChangeRecordFilterDto(String changedAttributeName, String authorName, URI changeType) {
this.changedAttributeName = changedAttributeName;
this.authorName = authorName;
this.changeType = changeType;
}

public ChangeRecordFilterDto(String assetLabel, String changedAttributeName, String authorName, URI changeType) {
this.assetLabel = assetLabel;
this.changedAttributeName = changedAttributeName;
this.authorName = authorName;
this.changeType = changeType;
}

public String getAssetLabel() {
return assetLabel;
}

public void setAssetLabel(String assetLabel) {
this.assetLabel = assetLabel;
}

public String getChangedAttributeName() {
return changedAttributeName;
}

public void setChangedAttributeName(String changedAttributeName) {
this.changedAttributeName = changedAttributeName;
}

public String getAuthorName() {
return authorName;
}

public void setAuthorName(String authorName) {
this.authorName = authorName;
}

public URI getChangeType() {
return changeType;
}

public void setChangeType(URI changeType) {
this.changeType = changeType;
}

/**
* @return true when all attributes are empty or null
*/
@JsonIgnore
public boolean isEmpty() {
return Utils.isBlank(assetLabel) &&
Utils.isBlank(changedAttributeName) &&
Utils.isBlank(authorName) &&
changeType == null;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ChangeRecordFilterDto that)) return false;
return Objects.equals(assetLabel, that.assetLabel) &&
Objects.equals(changedAttributeName, that.changedAttributeName) &&
Objects.equals(authorName, that.authorName) &&
Objects.equals(changeType, that.changeType);
}

@Override
public int hashCode() {
return Objects.hash(assetLabel, changedAttributeName, authorName, changeType);
}


/**
* Constants for the Open API documentation of the REST API.
*/
public static final class ApiDoc {
public static final String TERM_NAME_DESCRIPTION = "Name of the term used for filtering.";
public static final String CHANGE_TYPE_DESCRIPTION = "Type of the change used for filtering.";
public static final String AUTHOR_NAME_DESCRIPTION = "Name of the author of the change used for filtering.";
public static final String CHANGED_ATTRIBUTE_DESCRIPTION = "Name of the changed attribute used for filtering.";

private ApiDoc() {
throw new AssertionError();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cz.cvut.kbss.termit.event;

import cz.cvut.kbss.termit.model.Asset;
import org.springframework.context.ApplicationEvent;

/**
* Event published before an asset is deleted.
*/
public class BeforeAssetDeleteEvent extends ApplicationEvent {
final Asset<?> asset;
public BeforeAssetDeleteEvent(Object source, Asset<?> asset) {
super(source);
this.asset = asset;
}

public Asset<?> getAsset() {
return asset;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package cz.cvut.kbss.termit.exception;

import cz.cvut.kbss.termit.model.Asset;
import cz.cvut.kbss.termit.model.resource.File;

/**
* Indicates that a language is not supported by the text analysis service.
*/
public class UnsupportedTextAnalysisLanguageException extends TermItException {

public UnsupportedTextAnalysisLanguageException(String message, Asset<?> asset) {
super(message, asset instanceof File ? "error.annotation.file.unsupportedLanguage" : "error.annotation.term.unsupportedLanguage");
}
}
22 changes: 19 additions & 3 deletions src/main/java/cz/cvut/kbss/termit/model/TextAnalysisRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
*/
package cz.cvut.kbss.termit.model;

import cz.cvut.kbss.jopa.model.annotations.OWLAnnotationProperty;
import cz.cvut.kbss.jopa.model.annotations.OWLClass;
import cz.cvut.kbss.jopa.model.annotations.OWLDataProperty;
import cz.cvut.kbss.jopa.model.annotations.OWLObjectProperty;
import cz.cvut.kbss.jopa.model.annotations.ParticipationConstraints;
import cz.cvut.kbss.jopa.vocabulary.DC;
import cz.cvut.kbss.termit.model.resource.Resource;
import cz.cvut.kbss.termit.util.Vocabulary;

Expand All @@ -44,12 +46,16 @@ public class TextAnalysisRecord extends AbstractEntity {
@OWLObjectProperty(iri = Vocabulary.s_p_ma_slovnik_pro_analyzu)
private Set<URI> vocabularies;

@OWLAnnotationProperty(iri = DC.Terms.LANGUAGE, simpleLiteral = true)
private String language;

public TextAnalysisRecord() {
}

public TextAnalysisRecord(Instant date, Resource analyzedResource) {
public TextAnalysisRecord(Instant date, Resource analyzedResource, String language) {
this.date = date;
this.analyzedResource = analyzedResource;
this.language = language;
}

public Instant getDate() {
Expand All @@ -76,6 +82,14 @@ public void setVocabularies(Set<URI> vocabularies) {
this.vocabularies = vocabularies;
}

public String getLanguage() {
return language;
}

public void setLanguage(String language) {
this.language = language;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand All @@ -86,12 +100,13 @@ public boolean equals(Object o) {
}
return Objects.equals(date, that.date) &&
Objects.equals(analyzedResource, that.analyzedResource) &&
Objects.equals(vocabularies, that.vocabularies);
Objects.equals(vocabularies, that.vocabularies) &&
Objects.equals(language, that.language);
}

@Override
public int hashCode() {
return Objects.hash(date, analyzedResource, vocabularies);
return Objects.hash(date, analyzedResource, vocabularies, language);
}

@Override
Expand All @@ -100,6 +115,7 @@ public String toString() {
"date=" + date +
",analyzedResource=" + analyzedResource +
",vocabularies=" + vocabularies +
", language=" + language +
"}";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package cz.cvut.kbss.termit.model.changetracking;

import cz.cvut.kbss.jopa.model.MultilingualString;
import cz.cvut.kbss.jopa.model.annotations.OWLAnnotationProperty;
import cz.cvut.kbss.jopa.model.annotations.OWLClass;
import cz.cvut.kbss.jopa.model.annotations.ParticipationConstraints;
import cz.cvut.kbss.jopa.vocabulary.RDFS;
import cz.cvut.kbss.termit.model.Asset;
import cz.cvut.kbss.termit.util.Vocabulary;
import jakarta.annotation.Nonnull;

import java.util.Objects;

/**
* Represents a record of asset deletion.
*/
@OWLClass(iri = Vocabulary.s_c_smazani_entity)
public class DeleteChangeRecord extends AbstractChangeRecord {
@ParticipationConstraints(nonEmpty = true)
@OWLAnnotationProperty(iri = RDFS.LABEL)
private MultilingualString label;

/**
* Creates a new instance.
* @param changedEntity the changed asset
* @throws IllegalArgumentException If the label type is not String or MultilingualString
*/
public DeleteChangeRecord(Asset<?> changedEntity) {
super(changedEntity);

if (changedEntity.getLabel() instanceof String stringLabel) {
this.label = MultilingualString.create(stringLabel, null);
} else if (changedEntity.getLabel() instanceof MultilingualString multilingualLabel) {
this.label = multilingualLabel;
} else {
throw new IllegalArgumentException("Unsupported label type: " + changedEntity.getLabel().getClass());
}
}

public DeleteChangeRecord() {
super();
}

public MultilingualString getLabel() {
return label;
}

public void setLabel(MultilingualString label) {
this.label = label;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof DeleteChangeRecord that)) {
return false;
}
if (!super.equals(o)) {
return false;
}
return Objects.equals(label, that.label);
}

@Override
public String toString() {
return "DeleteChangeRecord{" +
super.toString() +
", label=" + label +
'}';
}

@Override
public int compareTo(@Nonnull AbstractChangeRecord o) {
if (o instanceof UpdateChangeRecord) {
return 1;
}
if (o instanceof PersistChangeRecord) {
return 1;
}
return super.compareTo(o);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public int compareTo(@Nonnull AbstractChangeRecord o) {
if (o instanceof UpdateChangeRecord) {
return -1;
}
if (o instanceof DeleteChangeRecord) {
return -1;
}
return super.compareTo(o);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ public int compareTo(@Nonnull AbstractChangeRecord o) {
if (o instanceof PersistChangeRecord) {
return 1;
}
if (o instanceof DeleteChangeRecord) {
return -1;
}
return super.compareTo(o);
}
}
Loading

0 comments on commit d3ef655

Please sign in to comment.