Skip to content

Commit

Permalink
[Enhancement kbss-cvut/termit-ui#530] Remove vocabulary from DeleteCh…
Browse files Browse the repository at this point in the history
…angeRecord

The record is already saved in tha vocabulary context.
  • Loading branch information
lukaskabc committed Oct 27, 2024
1 parent c3e096d commit 40a8299
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
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.OWLObjectProperty;
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.net.URI;
import java.util.Objects;

/**
Expand All @@ -22,16 +20,12 @@ public class DeleteChangeRecord extends AbstractChangeRecord {
@OWLAnnotationProperty(iri = RDFS.LABEL)
private MultilingualString label;

@OWLObjectProperty(iri = Vocabulary.s_p_je_pojmem_ze_slovniku)
private URI vocabulary;

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

if (changedEntity.getLabel() instanceof String stringLabel) {
Expand All @@ -41,8 +35,6 @@ public DeleteChangeRecord(Asset<?> changedEntity, URI vocabulary) {
} else {
throw new IllegalArgumentException("Unsupported label type: " + changedEntity.getLabel().getClass());
}

this.vocabulary = vocabulary;
}

public DeleteChangeRecord() {
Expand All @@ -57,14 +49,6 @@ public void setLabel(MultilingualString label) {
this.label = label;
}

public URI getVocabulary() {
return vocabulary;
}

public void setVocabulary(URI vocabulary) {
this.vocabulary = vocabulary;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand All @@ -76,15 +60,14 @@ public boolean equals(Object o) {
if (!super.equals(o)) {
return false;
}
return Objects.equals(label, that.label) && Objects.equals(vocabulary, that.vocabulary);
return Objects.equals(label, that.label);
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void onBeforeAssetDeleteEvent(@Nonnull BeforeAssetDeleteEvent event) {
vocabulary = term.getVocabulary();
}

final AbstractChangeRecord changeRecord = new DeleteChangeRecord(asset, vocabulary);
final AbstractChangeRecord changeRecord = new DeleteChangeRecord(asset);
changeRecord.setAuthor(securityUtils.getCurrentUser().toUser());
changeRecord.setTimestamp(Utils.timestamp());

Expand Down

0 comments on commit 40a8299

Please sign in to comment.