forked from kbss-cvut/termit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enhancement kbss-cvut/termit-ui#530] Create DeleteChangeRecord class…
… and BeforeAssetDeleteEvent Created classes required for recording an asset removal, implemented dispatching asset delete event and logic for ChangeTracker handling the event.
- Loading branch information
Showing
8 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
src/main/java/cz/cvut/kbss/termit/event/BeforeAssetDeleteEvent.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,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<T extends Asset<?>> extends ApplicationEvent { | ||
final T asset; | ||
public BeforeAssetDeleteEvent(Object source, T asset) { | ||
super(source); | ||
this.asset = asset; | ||
} | ||
|
||
public T getAsset() { | ||
return asset; | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
src/main/java/cz/cvut/kbss/termit/model/changetracking/DeleteChangeRecord.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,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.OWLObjectProperty; | ||
import cz.cvut.kbss.jopa.model.annotations.ParticipationConstraints; | ||
import cz.cvut.kbss.jopa.vocabulary.DC; | ||
import cz.cvut.kbss.termit.model.Asset; | ||
import cz.cvut.kbss.termit.util.Vocabulary; | ||
import jakarta.annotation.Nonnull; | ||
|
||
import java.io.Serializable; | ||
import java.net.URI; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Represents a record of asset deletion. | ||
* @param <T> The label type, {@link String} or {@link MultilingualString} | ||
*/ | ||
//@OWLClass(iri = Vocabulary.s_c_smazani_entity) TODO: ontology for DeleteChangeRecord | ||
public class DeleteChangeRecord<T extends Serializable> extends AbstractChangeRecord { | ||
@ParticipationConstraints(nonEmpty = true) | ||
@OWLAnnotationProperty(iri = DC.Terms.TITLE) | ||
private T label; | ||
|
||
@OWLObjectProperty(iri = Vocabulary.s_p_je_pojmem_ze_slovniku) | ||
private URI vocabulary; | ||
|
||
public DeleteChangeRecord(Asset<T> changedEntity, URI vocabulary) { | ||
super(changedEntity); | ||
this.label = changedEntity.getLabel(); | ||
this.vocabulary = vocabulary; | ||
} | ||
|
||
public T getLabel() { | ||
return label; | ||
} | ||
|
||
public void setLabel(T 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) { | ||
return true; | ||
} | ||
if (!(o instanceof DeleteChangeRecord<?> that)) { | ||
return false; | ||
} | ||
if (!super.equals(o)) { | ||
return false; | ||
} | ||
return Objects.equals(label, that.label) && Objects.equals(vocabulary, that.vocabulary); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "DeleteChangeRecord{" + | ||
super.toString() + | ||
", label=" + label + | ||
(vocabulary != null ? ", vocabulary=" + vocabulary : "") + | ||
'}'; | ||
} | ||
|
||
@Override | ||
public int compareTo(@Nonnull AbstractChangeRecord o) { | ||
if (o instanceof UpdateChangeRecord) { | ||
return 1; | ||
} | ||
if (o instanceof PersistChangeRecord) { | ||
return 1; | ||
} | ||
return super.compareTo(o); | ||
} | ||
} |
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
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