diff --git a/src/main/java/edu/stanford/protege/webprotegeeventshistory/config/ObjectMapperConfiguration.java b/src/main/java/edu/stanford/protege/webprotegeeventshistory/config/ObjectMapperConfiguration.java index 32c4f6c..59dcfd6 100644 --- a/src/main/java/edu/stanford/protege/webprotegeeventshistory/config/ObjectMapperConfiguration.java +++ b/src/main/java/edu/stanford/protege/webprotegeeventshistory/config/ObjectMapperConfiguration.java @@ -17,8 +17,8 @@ import edu.stanford.protege.webprotege.projectsettings.ProjectSettingsChangedEvent; import edu.stanford.protege.webprotege.tag.*; import edu.stanford.protege.webprotege.watches.*; -import edu.stanford.protege.webprotegeeventshistory.config.events.ProjectLinearizationChangedEvent; -import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.events.*; +import edu.stanford.protege.webprotegeeventshistory.config.events.UpdateUiHistoryEvent; +import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.events.NewRevisionsEvent; import org.semanticweb.owlapi.model.*; import org.springframework.context.annotation.*; import uk.ac.manchester.cs.owl.owlapi.*; @@ -30,303 +30,303 @@ public class ObjectMapperConfiguration { @Bean public ObjectMapper objectMapper() { - OWLDataFactory dataFactory = new OWLDataFactoryImpl(); + OWLDataFactory dataFactory = new OWLDataFactoryImpl(); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.setDefaultPrettyPrinter(new DefaultPrettyPrinter()); - mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); - mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); - mapper.registerModule(new JavaTimeModule()); - mapper.registerModule(new Jdk8Module()); - mapper.registerModule(new GuavaModule()); - SimpleModule module = new SimpleModule(); + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.setDefaultPrettyPrinter(new DefaultPrettyPrinter()); + mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); + mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); + mapper.registerModule(new JavaTimeModule()); + mapper.registerModule(new Jdk8Module()); + mapper.registerModule(new GuavaModule()); + SimpleModule module = new SimpleModule(); - module.addSerializer(new EntityTypeSerializer()); - module.addDeserializer(EntityType.class, new EntityTypeDeserializer()); + module.addSerializer(new EntityTypeSerializer()); + module.addDeserializer(EntityType.class, new EntityTypeDeserializer()); - module.setMixInAnnotation(OWLAnnotation.class, OWLAnnotationMixin.class); - module.setMixInAnnotation(OWLAnnotationImpl.class, OWLAnnotationImplMixin.class); + module.setMixInAnnotation(OWLAnnotation.class, OWLAnnotationMixin.class); + module.setMixInAnnotation(OWLAnnotationImpl.class, OWLAnnotationImplMixin.class); - module.addSerializer(OWLLiteral.class, new OWLLiteralSerializer()); - module.addDeserializer(OWLLiteral.class, new OWLLiteralDeserializer(dataFactory)); + module.addSerializer(OWLLiteral.class, new OWLLiteralSerializer()); + module.addDeserializer(OWLLiteral.class, new OWLLiteralDeserializer(dataFactory)); - module.setMixInAnnotation(OWLOntologyID.class, OWLOntologyIDMixin.class); + module.setMixInAnnotation(OWLOntologyID.class, OWLOntologyIDMixin.class); - module.setMixInAnnotation(NodeID.class, NodeIDMixin.class); + module.setMixInAnnotation(NodeID.class, NodeIDMixin.class); - module.addSerializer(AxiomType.class, new AxiomTypeSerializer()); - module.addDeserializer(AxiomType.class, new AxiomTypeDeserializer()); + module.addSerializer(AxiomType.class, new AxiomTypeSerializer()); + module.addDeserializer(AxiomType.class, new AxiomTypeDeserializer()); - module.setMixInAnnotation(OWLAxiom.class, OWLAxiomMixin.class); + module.setMixInAnnotation(OWLAxiom.class, OWLAxiomMixin.class); - module.setMixInAnnotation(OWLSubClassOfAxiom.class, OWLSubClassOfAxiomMixin.class); - module.setMixInAnnotation(OWLSubClassOfAxiomImpl.class, OWLSubClassOfAxiomImplMixin.class); + module.setMixInAnnotation(OWLSubClassOfAxiom.class, OWLSubClassOfAxiomMixin.class); + module.setMixInAnnotation(OWLSubClassOfAxiomImpl.class, OWLSubClassOfAxiomImplMixin.class); - module.setMixInAnnotation(OWLEquivalentClassesAxiom.class, OWLEquivalentClassesAxiomMixin.class); - module.setMixInAnnotation(OWLEquivalentClassesAxiomImpl.class, OWLEquivalentClassesAxiomImplMixin.class); + module.setMixInAnnotation(OWLEquivalentClassesAxiom.class, OWLEquivalentClassesAxiomMixin.class); + module.setMixInAnnotation(OWLEquivalentClassesAxiomImpl.class, OWLEquivalentClassesAxiomImplMixin.class); - module.setMixInAnnotation(OWLDisjointClassesAxiom.class, OWLDisjointClassesAxiomMixin.class); - module.setMixInAnnotation(OWLDisjointClassesAxiomImpl.class, OWLDisjointClassesAxiomImplMixin.class); + module.setMixInAnnotation(OWLDisjointClassesAxiom.class, OWLDisjointClassesAxiomMixin.class); + module.setMixInAnnotation(OWLDisjointClassesAxiomImpl.class, OWLDisjointClassesAxiomImplMixin.class); - module.setMixInAnnotation(OWLDisjointUnionAxiom.class, OWLDisjointUnionAxiomMixin.class); - module.setMixInAnnotation(OWLDisjointUnionAxiomImpl.class, OWLDisjointUnionAxiomImplMixin.class); + module.setMixInAnnotation(OWLDisjointUnionAxiom.class, OWLDisjointUnionAxiomMixin.class); + module.setMixInAnnotation(OWLDisjointUnionAxiomImpl.class, OWLDisjointUnionAxiomImplMixin.class); - module.setMixInAnnotation(OWLAnnotationAssertionAxiom.class, OWLAnnotationAssertionAxiomMixin.class); - module.setMixInAnnotation(OWLAnnotationAssertionAxiomImpl.class, OWLAnnotationAssertionAxiomImplMixin.class); + module.setMixInAnnotation(OWLAnnotationAssertionAxiom.class, OWLAnnotationAssertionAxiomMixin.class); + module.setMixInAnnotation(OWLAnnotationAssertionAxiomImpl.class, OWLAnnotationAssertionAxiomImplMixin.class); - module.setMixInAnnotation(OWLClassAssertionAxiom.class, OWLClassAssertionAxiomMixin.class); - module.setMixInAnnotation(OWLClassAssertionAxiomImpl.class, OWLClassAssertionAxiomImplMixin.class); + module.setMixInAnnotation(OWLClassAssertionAxiom.class, OWLClassAssertionAxiomMixin.class); + module.setMixInAnnotation(OWLClassAssertionAxiomImpl.class, OWLClassAssertionAxiomImplMixin.class); - module.setMixInAnnotation(OWLDeclarationAxiom.class, OWLDeclarationAxiomMixin.class); - module.setMixInAnnotation(OWLDeclarationAxiomImpl.class, OWLDeclarationAxiomImplMixin.class); + module.setMixInAnnotation(OWLDeclarationAxiom.class, OWLDeclarationAxiomMixin.class); + module.setMixInAnnotation(OWLDeclarationAxiomImpl.class, OWLDeclarationAxiomImplMixin.class); - module.setMixInAnnotation(OWLObjectPropertyAssertionAxiom.class, OWLObjectPropertyAssertionAxiomMixin.class); - module.setMixInAnnotation(OWLObjectPropertyAssertionAxiomImpl.class, OWLObjectPropertyAssertionAxiomImplMixin.class); + module.setMixInAnnotation(OWLObjectPropertyAssertionAxiom.class, OWLObjectPropertyAssertionAxiomMixin.class); + module.setMixInAnnotation(OWLObjectPropertyAssertionAxiomImpl.class, OWLObjectPropertyAssertionAxiomImplMixin.class); - module.setMixInAnnotation(OWLNegativeObjectPropertyAssertionAxiom.class, OWLNegativeObjectPropertyAssertionAxiomMixin.class); - module.setMixInAnnotation(OWLNegativeObjectPropertyAssertionAxiomImpl.class, OWLNegativeObjectPropertyAssertionAxiomImplMixin.class); + module.setMixInAnnotation(OWLNegativeObjectPropertyAssertionAxiom.class, OWLNegativeObjectPropertyAssertionAxiomMixin.class); + module.setMixInAnnotation(OWLNegativeObjectPropertyAssertionAxiomImpl.class, OWLNegativeObjectPropertyAssertionAxiomImplMixin.class); - module.setMixInAnnotation(OWLDataPropertyAssertionAxiom.class, OWLDataPropertyAssertionAxiomMixin.class); - module.setMixInAnnotation(OWLDataPropertyAssertionAxiomImpl.class, OWLDataPropertyAssertionAxiomImplMixin.class); + module.setMixInAnnotation(OWLDataPropertyAssertionAxiom.class, OWLDataPropertyAssertionAxiomMixin.class); + module.setMixInAnnotation(OWLDataPropertyAssertionAxiomImpl.class, OWLDataPropertyAssertionAxiomImplMixin.class); - module.setMixInAnnotation(OWLNegativeDataPropertyAssertionAxiom.class, OWLNegativeDataPropertyAssertionAxiomMixin.class); - module.setMixInAnnotation(OWLNegativeDataPropertyAssertionAxiomImpl.class, OWLNegativeDataPropertyAssertionAxiomImplMixin.class); + module.setMixInAnnotation(OWLNegativeDataPropertyAssertionAxiom.class, OWLNegativeDataPropertyAssertionAxiomMixin.class); + module.setMixInAnnotation(OWLNegativeDataPropertyAssertionAxiomImpl.class, OWLNegativeDataPropertyAssertionAxiomImplMixin.class); - module.setMixInAnnotation(OWLSubObjectPropertyOfAxiom.class, OWLSubObjectPropertyOfAxiomMixin.class); - module.setMixInAnnotation(OWLSubObjectPropertyOfAxiomImpl.class, OWLSubObjectPropertyOfAxiomImplMixin.class); + module.setMixInAnnotation(OWLSubObjectPropertyOfAxiom.class, OWLSubObjectPropertyOfAxiomMixin.class); + module.setMixInAnnotation(OWLSubObjectPropertyOfAxiomImpl.class, OWLSubObjectPropertyOfAxiomImplMixin.class); - module.setMixInAnnotation(OWLSubDataPropertyOfAxiom.class, OWLSubDataPropertyOfAxiomMixin.class); - module.setMixInAnnotation(OWLSubDataPropertyOfAxiomImpl.class, OWLSubDataPropertyOfAxiomImplMixin.class); + module.setMixInAnnotation(OWLSubDataPropertyOfAxiom.class, OWLSubDataPropertyOfAxiomMixin.class); + module.setMixInAnnotation(OWLSubDataPropertyOfAxiomImpl.class, OWLSubDataPropertyOfAxiomImplMixin.class); - module.setMixInAnnotation(OWLSubAnnotationPropertyOfAxiom.class, OWLSubAnnotationPropertyOfAxiomMixin.class); - module.setMixInAnnotation(OWLSubAnnotationPropertyOfAxiomImpl.class, OWLSubAnnotationPropertyOfAxiomImplMixin.class); + module.setMixInAnnotation(OWLSubAnnotationPropertyOfAxiom.class, OWLSubAnnotationPropertyOfAxiomMixin.class); + module.setMixInAnnotation(OWLSubAnnotationPropertyOfAxiomImpl.class, OWLSubAnnotationPropertyOfAxiomImplMixin.class); - module.setMixInAnnotation(OWLFunctionalObjectPropertyAxiom.class, OWLFunctionalObjectPropertyAxiomMixin.class); - module.setMixInAnnotation(OWLFunctionalObjectPropertyAxiomImpl.class, OWLFunctionalObjectPropertyAxiomImplMixin.class); + module.setMixInAnnotation(OWLFunctionalObjectPropertyAxiom.class, OWLFunctionalObjectPropertyAxiomMixin.class); + module.setMixInAnnotation(OWLFunctionalObjectPropertyAxiomImpl.class, OWLFunctionalObjectPropertyAxiomImplMixin.class); - module.setMixInAnnotation(OWLFunctionalDataPropertyAxiom.class, OWLFunctionalDataPropertyAxiomMixin.class); - module.setMixInAnnotation(OWLFunctionalDataPropertyAxiomImpl.class, OWLFunctionalDataPropertyAxiomImplMixin.class); + module.setMixInAnnotation(OWLFunctionalDataPropertyAxiom.class, OWLFunctionalDataPropertyAxiomMixin.class); + module.setMixInAnnotation(OWLFunctionalDataPropertyAxiomImpl.class, OWLFunctionalDataPropertyAxiomImplMixin.class); - module.setMixInAnnotation(OWLInverseFunctionalObjectPropertyAxiom.class, OWLInverseFunctionalObjectPropertyAxiomMixin.class); - module.setMixInAnnotation(OWLInverseFunctionalObjectPropertyAxiomImpl.class, OWLInverseFunctionalObjectPropertyAxiomImplMixin.class); + module.setMixInAnnotation(OWLInverseFunctionalObjectPropertyAxiom.class, OWLInverseFunctionalObjectPropertyAxiomMixin.class); + module.setMixInAnnotation(OWLInverseFunctionalObjectPropertyAxiomImpl.class, OWLInverseFunctionalObjectPropertyAxiomImplMixin.class); - module.setMixInAnnotation(OWLAsymmetricObjectPropertyAxiom.class, OWLAsymmetricObjectPropertyAxiomMixin.class); - module.setMixInAnnotation(OWLAsymmetricObjectPropertyAxiomImpl.class, OWLAsymmetricObjectPropertyAxiomImplMixin.class); + module.setMixInAnnotation(OWLAsymmetricObjectPropertyAxiom.class, OWLAsymmetricObjectPropertyAxiomMixin.class); + module.setMixInAnnotation(OWLAsymmetricObjectPropertyAxiomImpl.class, OWLAsymmetricObjectPropertyAxiomImplMixin.class); - module.setMixInAnnotation(OWLSymmetricObjectPropertyAxiom.class, OWLSymmetricObjectPropertyAxiomMixin.class); - module.setMixInAnnotation(OWLSymmetricObjectPropertyAxiomImpl.class, OWLSymmetricObjectPropertyAxiomImplMixin.class); + module.setMixInAnnotation(OWLSymmetricObjectPropertyAxiom.class, OWLSymmetricObjectPropertyAxiomMixin.class); + module.setMixInAnnotation(OWLSymmetricObjectPropertyAxiomImpl.class, OWLSymmetricObjectPropertyAxiomImplMixin.class); - module.setMixInAnnotation(OWLTransitiveObjectPropertyAxiom.class, OWLTransitiveObjectPropertyAxiomMixin.class); - module.setMixInAnnotation(OWLTransitiveObjectPropertyAxiomImpl.class, OWLTransitiveObjectPropertyAxiomImplMixin.class); + module.setMixInAnnotation(OWLTransitiveObjectPropertyAxiom.class, OWLTransitiveObjectPropertyAxiomMixin.class); + module.setMixInAnnotation(OWLTransitiveObjectPropertyAxiomImpl.class, OWLTransitiveObjectPropertyAxiomImplMixin.class); - module.setMixInAnnotation(OWLIrreflexiveObjectPropertyAxiom.class, OWLIrreflexiveObjectPropertyAxiomMixin.class); - module.setMixInAnnotation(OWLIrreflexiveObjectPropertyAxiomImpl.class, OWLIrreflexiveObjectPropertyAxiomImplMixin.class); + module.setMixInAnnotation(OWLIrreflexiveObjectPropertyAxiom.class, OWLIrreflexiveObjectPropertyAxiomMixin.class); + module.setMixInAnnotation(OWLIrreflexiveObjectPropertyAxiomImpl.class, OWLIrreflexiveObjectPropertyAxiomImplMixin.class); - module.setMixInAnnotation(OWLSameIndividualAxiom.class, OWLSameIndividualAxiomMixin.class); - module.setMixInAnnotation(OWLSameIndividualAxiomImpl.class, OWLSameIndividualAxiomImplMixin.class); + module.setMixInAnnotation(OWLSameIndividualAxiom.class, OWLSameIndividualAxiomMixin.class); + module.setMixInAnnotation(OWLSameIndividualAxiomImpl.class, OWLSameIndividualAxiomImplMixin.class); - module.setMixInAnnotation(OWLDifferentIndividualsAxiom.class, OWLDifferentIndividualsAxiomMixin.class); - module.setMixInAnnotation(OWLDifferentIndividualsAxiomImpl.class, OWLDifferentIndividualsAxiomImplMixin.class); + module.setMixInAnnotation(OWLDifferentIndividualsAxiom.class, OWLDifferentIndividualsAxiomMixin.class); + module.setMixInAnnotation(OWLDifferentIndividualsAxiomImpl.class, OWLDifferentIndividualsAxiomImplMixin.class); - module.setMixInAnnotation(OWLDisjointObjectPropertiesAxiom.class, OWLDisjointObjectPropertiesAxiomMixin.class); - module.setMixInAnnotation(OWLDisjointObjectPropertiesAxiomImpl.class, OWLDisjointObjectPropertiesAxiomImplMixin.class); + module.setMixInAnnotation(OWLDisjointObjectPropertiesAxiom.class, OWLDisjointObjectPropertiesAxiomMixin.class); + module.setMixInAnnotation(OWLDisjointObjectPropertiesAxiomImpl.class, OWLDisjointObjectPropertiesAxiomImplMixin.class); - module.setMixInAnnotation(OWLEquivalentObjectPropertiesAxiom.class, OWLEquivalentObjectPropertiesAxiomMixin.class); - module.setMixInAnnotation(OWLEquivalentObjectPropertiesAxiomImpl.class, OWLEquivalentObjectPropertiesAxiomImplMixin.class); + module.setMixInAnnotation(OWLEquivalentObjectPropertiesAxiom.class, OWLEquivalentObjectPropertiesAxiomMixin.class); + module.setMixInAnnotation(OWLEquivalentObjectPropertiesAxiomImpl.class, OWLEquivalentObjectPropertiesAxiomImplMixin.class); - module.setMixInAnnotation(OWLInverseObjectPropertiesAxiom.class, OWLInverseObjectPropertiesAxiomMixin.class); - module.setMixInAnnotation(OWLInverseObjectPropertiesAxiomImpl.class, OWLInverseObjectPropertiesAxiomImplMixin.class); + module.setMixInAnnotation(OWLInverseObjectPropertiesAxiom.class, OWLInverseObjectPropertiesAxiomMixin.class); + module.setMixInAnnotation(OWLInverseObjectPropertiesAxiomImpl.class, OWLInverseObjectPropertiesAxiomImplMixin.class); - module.setMixInAnnotation(OWLDisjointDataPropertiesAxiom.class, OWLDisjointDataPropertiesAxiomMixin.class); - module.setMixInAnnotation(OWLDisjointDataPropertiesAxiomImpl.class, OWLDisjointDataPropertiesAxiomImplMixin.class); + module.setMixInAnnotation(OWLDisjointDataPropertiesAxiom.class, OWLDisjointDataPropertiesAxiomMixin.class); + module.setMixInAnnotation(OWLDisjointDataPropertiesAxiomImpl.class, OWLDisjointDataPropertiesAxiomImplMixin.class); - module.setMixInAnnotation(OWLEquivalentDataPropertiesAxiom.class, OWLEquivalentDataPropertiesAxiomMixin.class); - module.setMixInAnnotation(OWLEquivalentDataPropertiesAxiomImpl.class, OWLEquivalentDataPropertiesAxiomImplMixin.class); + module.setMixInAnnotation(OWLEquivalentDataPropertiesAxiom.class, OWLEquivalentDataPropertiesAxiomMixin.class); + module.setMixInAnnotation(OWLEquivalentDataPropertiesAxiomImpl.class, OWLEquivalentDataPropertiesAxiomImplMixin.class); - module.setMixInAnnotation(OWLObjectPropertyRangeAxiom.class, OWLObjectPropertyRangeAxiomMixin.class); - module.setMixInAnnotation(OWLObjectPropertyRangeAxiomImpl.class, OWLObjectPropertyRangeAxiomImplMixin.class); + module.setMixInAnnotation(OWLObjectPropertyRangeAxiom.class, OWLObjectPropertyRangeAxiomMixin.class); + module.setMixInAnnotation(OWLObjectPropertyRangeAxiomImpl.class, OWLObjectPropertyRangeAxiomImplMixin.class); - module.setMixInAnnotation(OWLObjectPropertyDomainAxiom.class, OWLObjectPropertyDomainAxiomMixin.class); - module.setMixInAnnotation(OWLObjectPropertyDomainAxiomImpl.class, OWLObjectPropertyDomainAxiomImplMixin.class); + module.setMixInAnnotation(OWLObjectPropertyDomainAxiom.class, OWLObjectPropertyDomainAxiomMixin.class); + module.setMixInAnnotation(OWLObjectPropertyDomainAxiomImpl.class, OWLObjectPropertyDomainAxiomImplMixin.class); - module.setMixInAnnotation(OWLDataPropertyRangeAxiom.class, OWLDataPropertyRangeAxiomMixin.class); - module.setMixInAnnotation(OWLDataPropertyRangeAxiomImpl.class, OWLDataPropertyRangeAxiomImplMixin.class); + module.setMixInAnnotation(OWLDataPropertyRangeAxiom.class, OWLDataPropertyRangeAxiomMixin.class); + module.setMixInAnnotation(OWLDataPropertyRangeAxiomImpl.class, OWLDataPropertyRangeAxiomImplMixin.class); - module.setMixInAnnotation(OWLDataPropertyDomainAxiom.class, OWLDataPropertyDomainAxiomMixin.class); - module.setMixInAnnotation(OWLDataPropertyDomainAxiomImpl.class, OWLDataPropertyDomainAxiomImplMixin.class); + module.setMixInAnnotation(OWLDataPropertyDomainAxiom.class, OWLDataPropertyDomainAxiomMixin.class); + module.setMixInAnnotation(OWLDataPropertyDomainAxiomImpl.class, OWLDataPropertyDomainAxiomImplMixin.class); - module.setMixInAnnotation(OWLAnnotationPropertyDomainAxiom.class, OWLAnnotationPropertyDomainAxiomMixin.class); - module.setMixInAnnotation(OWLAnnotationPropertyDomainAxiomImpl.class, OWLAnnotationPropertyDomainAxiomImplMixin.class); + module.setMixInAnnotation(OWLAnnotationPropertyDomainAxiom.class, OWLAnnotationPropertyDomainAxiomMixin.class); + module.setMixInAnnotation(OWLAnnotationPropertyDomainAxiomImpl.class, OWLAnnotationPropertyDomainAxiomImplMixin.class); - module.setMixInAnnotation(OWLAnnotationPropertyRangeAxiom.class, OWLAnnotationPropertyRangeAxiomMixin.class); - module.setMixInAnnotation(OWLAnnotationPropertyRangeAxiomImpl.class, OWLAnnotationPropertyRangeAxiomImplMixin.class); + module.setMixInAnnotation(OWLAnnotationPropertyRangeAxiom.class, OWLAnnotationPropertyRangeAxiomMixin.class); + module.setMixInAnnotation(OWLAnnotationPropertyRangeAxiomImpl.class, OWLAnnotationPropertyRangeAxiomImplMixin.class); - module.setMixInAnnotation(OWLDatatypeDefinitionAxiom.class, OWLDatatypeDefinitionAxiomMixin.class); - module.setMixInAnnotation(OWLDatatypeDefinitionAxiomImpl.class, OWLDatatypeDefinitionAxiomImplMixin.class); + module.setMixInAnnotation(OWLDatatypeDefinitionAxiom.class, OWLDatatypeDefinitionAxiomMixin.class); + module.setMixInAnnotation(OWLDatatypeDefinitionAxiomImpl.class, OWLDatatypeDefinitionAxiomImplMixin.class); - module.setMixInAnnotation(OWLHasKeyAxiom.class, OWLHasKeyAxiomMixin.class); - module.setMixInAnnotation(OWLHasKeyAxiomImpl.class, OWLHasKeyAxiomImplMixin.class); + module.setMixInAnnotation(OWLHasKeyAxiom.class, OWLHasKeyAxiomMixin.class); + module.setMixInAnnotation(OWLHasKeyAxiomImpl.class, OWLHasKeyAxiomImplMixin.class); - module.setMixInAnnotation(OWLDataPropertyExpression.class, OWLDataPropertyExpressionMixin.class); + module.setMixInAnnotation(OWLDataPropertyExpression.class, OWLDataPropertyExpressionMixin.class); - module.setMixInAnnotation(OWLPropertyExpression.class, OWLPropertyExpressionMixin.class); - module.setMixInAnnotation(OWLObjectPropertyExpression.class, OWLObjectPropertyExpressionMixin.class); - module.setMixInAnnotation(OWLObjectInverseOf.class, OWLObjectInverseOfMixin.class); - module.setMixInAnnotation(OWLObjectInverseOfImpl.class, OWLObjectInverseOfMixinImpl.class); + module.setMixInAnnotation(OWLPropertyExpression.class, OWLPropertyExpressionMixin.class); + module.setMixInAnnotation(OWLObjectPropertyExpression.class, OWLObjectPropertyExpressionMixin.class); + module.setMixInAnnotation(OWLObjectInverseOf.class, OWLObjectInverseOfMixin.class); + module.setMixInAnnotation(OWLObjectInverseOfImpl.class, OWLObjectInverseOfMixinImpl.class); - module.setMixInAnnotation(OWLDataRange.class, OWLDataRangeMixin.class); + module.setMixInAnnotation(OWLDataRange.class, OWLDataRangeMixin.class); - module.setMixInAnnotation(OWLEntity.class, OWLEntityMixin.class); - // We need this to support legacy representation of entities that use "type" instead of "@type" - // for the field name that identifies the type id - module.addDeserializer(OWLEntity.class, new OWLEntityDeserializer<>(dataFactory)); + module.setMixInAnnotation(OWLEntity.class, OWLEntityMixin.class); + // We need this to support legacy representation of entities that use "type" instead of "@type" + // for the field name that identifies the type id + module.addDeserializer(OWLEntity.class, new OWLEntityDeserializer<>(dataFactory)); - module.setMixInAnnotation(OWLClass.class, OWLClassMixin.class); - module.addDeserializer(OWLClassImpl.class, new OWLEntityDeserializer<>(dataFactory, EntityType.CLASS)); + module.setMixInAnnotation(OWLClass.class, OWLClassMixin.class); + module.addDeserializer(OWLClassImpl.class, new OWLEntityDeserializer<>(dataFactory, EntityType.CLASS)); - module.setMixInAnnotation(OWLDatatype.class, OWLDatatypeMixin.class); - module.addDeserializer(OWLDatatypeImpl.class, new OWLEntityDeserializer<>(dataFactory, EntityType.DATATYPE)); + module.setMixInAnnotation(OWLDatatype.class, OWLDatatypeMixin.class); + module.addDeserializer(OWLDatatypeImpl.class, new OWLEntityDeserializer<>(dataFactory, EntityType.DATATYPE)); - module.setMixInAnnotation(OWLProperty.class, OWLPropertyMixIn.class); - module.addDeserializer(OWLProperty.class, new OWLEntityDeserializer<>(dataFactory)); + module.setMixInAnnotation(OWLProperty.class, OWLPropertyMixIn.class); + module.addDeserializer(OWLProperty.class, new OWLEntityDeserializer<>(dataFactory)); - module.setMixInAnnotation(OWLObjectProperty.class, OWLObjectPropertyMixin.class); - module.addDeserializer(OWLObjectPropertyImpl.class, new OWLEntityDeserializer<>(dataFactory, EntityType.OBJECT_PROPERTY)); + module.setMixInAnnotation(OWLObjectProperty.class, OWLObjectPropertyMixin.class); + module.addDeserializer(OWLObjectPropertyImpl.class, new OWLEntityDeserializer<>(dataFactory, EntityType.OBJECT_PROPERTY)); - module.setMixInAnnotation(OWLDataProperty.class, OWLDataPropertyMixin.class); - module.addDeserializer(OWLDataPropertyImpl.class, new OWLEntityDeserializer<>(dataFactory, EntityType.DATA_PROPERTY)); + module.setMixInAnnotation(OWLDataProperty.class, OWLDataPropertyMixin.class); + module.addDeserializer(OWLDataPropertyImpl.class, new OWLEntityDeserializer<>(dataFactory, EntityType.DATA_PROPERTY)); // - module.setMixInAnnotation(OWLAnnotationProperty.class, OWLAnnotationPropertyMixin.class); - module.addDeserializer(OWLAnnotationPropertyImpl.class, new OWLEntityDeserializer<>(dataFactory, EntityType.ANNOTATION_PROPERTY)); + module.setMixInAnnotation(OWLAnnotationProperty.class, OWLAnnotationPropertyMixin.class); + module.addDeserializer(OWLAnnotationPropertyImpl.class, new OWLEntityDeserializer<>(dataFactory, EntityType.ANNOTATION_PROPERTY)); - module.setMixInAnnotation(OWLIndividual.class, OWLIndividualMixin.class); + module.setMixInAnnotation(OWLIndividual.class, OWLIndividualMixin.class); - module.setMixInAnnotation(OWLNamedIndividual.class, OWLNamedIndividualMixin.class); - module.addDeserializer(OWLNamedIndividualImpl.class, new OWLEntityDeserializer<>(dataFactory, EntityType.NAMED_INDIVIDUAL)); + module.setMixInAnnotation(OWLNamedIndividual.class, OWLNamedIndividualMixin.class); + module.addDeserializer(OWLNamedIndividualImpl.class, new OWLEntityDeserializer<>(dataFactory, EntityType.NAMED_INDIVIDUAL)); - module.setMixInAnnotation(OWLAnonymousIndividual.class, OWLAnonymousIndividualMixin.class); - module.setMixInAnnotation(OWLAnonymousIndividualImpl.class, OWLAnonymousIndividualImplMixin.class); + module.setMixInAnnotation(OWLAnonymousIndividual.class, OWLAnonymousIndividualMixin.class); + module.setMixInAnnotation(OWLAnonymousIndividualImpl.class, OWLAnonymousIndividualImplMixin.class); - module.setMixInAnnotation(OWLObjectInverseOf.class, OWLObjectInverseOfMixin.class); - module.setMixInAnnotation(OWLObjectInverseOfImpl.class, OWLObjectInverseOfMixin.class); + module.setMixInAnnotation(OWLObjectInverseOf.class, OWLObjectInverseOfMixin.class); + module.setMixInAnnotation(OWLObjectInverseOfImpl.class, OWLObjectInverseOfMixin.class); - module.setMixInAnnotation(OWLClassExpression.class, OWLClassExpressionMixin.class); + module.setMixInAnnotation(OWLClassExpression.class, OWLClassExpressionMixin.class); - module.setMixInAnnotation(OWLObjectSomeValuesFrom.class, OWLObjectSomeValuesFromMixin.class); - module.setMixInAnnotation(OWLObjectSomeValuesFromImpl.class, OWLObjectSomeValuesFromImplMixin.class); + module.setMixInAnnotation(OWLObjectSomeValuesFrom.class, OWLObjectSomeValuesFromMixin.class); + module.setMixInAnnotation(OWLObjectSomeValuesFromImpl.class, OWLObjectSomeValuesFromImplMixin.class); - module.setMixInAnnotation(OWLObjectAllValuesFrom.class, OWLObjectAllValuesFromMixin.class); - module.setMixInAnnotation(OWLObjectAllValuesFromImpl.class, OWLObjectAllValuesFromImplMixin.class); + module.setMixInAnnotation(OWLObjectAllValuesFrom.class, OWLObjectAllValuesFromMixin.class); + module.setMixInAnnotation(OWLObjectAllValuesFromImpl.class, OWLObjectAllValuesFromImplMixin.class); - module.setMixInAnnotation(OWLObjectMinCardinality.class, OWLObjectMinCardinalityMixin.class); - module.setMixInAnnotation(OWLObjectMinCardinalityImpl.class, OWLObjectMinCardinalityImplMixin.class); + module.setMixInAnnotation(OWLObjectMinCardinality.class, OWLObjectMinCardinalityMixin.class); + module.setMixInAnnotation(OWLObjectMinCardinalityImpl.class, OWLObjectMinCardinalityImplMixin.class); - module.setMixInAnnotation(OWLObjectHasValue.class, OWLObjectHasValueMixin.class); - module.setMixInAnnotation(OWLObjectHasValueImpl.class, OWLObjectHasValueImplMixin.class); + module.setMixInAnnotation(OWLObjectHasValue.class, OWLObjectHasValueMixin.class); + module.setMixInAnnotation(OWLObjectHasValueImpl.class, OWLObjectHasValueImplMixin.class); - module.setMixInAnnotation(OWLDataSomeValuesFrom.class, OWLDataSomeValuesFromMixin.class); - module.setMixInAnnotation(OWLDataSomeValuesFromImpl.class, OWLDataSomeValuesFromImplMixin.class); + module.setMixInAnnotation(OWLDataSomeValuesFrom.class, OWLDataSomeValuesFromMixin.class); + module.setMixInAnnotation(OWLDataSomeValuesFromImpl.class, OWLDataSomeValuesFromImplMixin.class); - module.setMixInAnnotation(OWLDataAllValuesFrom.class, OWLDataAllValuesFromMixin.class); - module.setMixInAnnotation(OWLDataAllValuesFromImpl.class, OWLDataAllValuesFromImplMixin.class); + module.setMixInAnnotation(OWLDataAllValuesFrom.class, OWLDataAllValuesFromMixin.class); + module.setMixInAnnotation(OWLDataAllValuesFromImpl.class, OWLDataAllValuesFromImplMixin.class); - module.setMixInAnnotation(OWLDataHasValue.class, OWLDataHasValueMixin.class); - module.setMixInAnnotation(OWLDataHasValueImpl.class, OWLDataHasValueImplMixin.class); + module.setMixInAnnotation(OWLDataHasValue.class, OWLDataHasValueMixin.class); + module.setMixInAnnotation(OWLDataHasValueImpl.class, OWLDataHasValueImplMixin.class); - module.setMixInAnnotation(OWLDataMinCardinality.class, OWLDataMinCardinalityMixin.class); - module.setMixInAnnotation(OWLDataMinCardinalityImpl.class, OWLDataMinCardinalityImplMixin.class); + module.setMixInAnnotation(OWLDataMinCardinality.class, OWLDataMinCardinalityMixin.class); + module.setMixInAnnotation(OWLDataMinCardinalityImpl.class, OWLDataMinCardinalityImplMixin.class); - module.setMixInAnnotation(OWLDataMaxCardinality.class, OWLDataMaxCardinalityMixin.class); - module.setMixInAnnotation(OWLDataMaxCardinalityImpl.class, OWLDataMaxCardinalityImplMixin.class); + module.setMixInAnnotation(OWLDataMaxCardinality.class, OWLDataMaxCardinalityMixin.class); + module.setMixInAnnotation(OWLDataMaxCardinalityImpl.class, OWLDataMaxCardinalityImplMixin.class); - module.setMixInAnnotation(OWLDataExactCardinality.class, OWLDataExactCardinalityMixin.class); - module.setMixInAnnotation(OWLDataExactCardinalityImpl.class, OWLDataExactCardinalityImplMixin.class); + module.setMixInAnnotation(OWLDataExactCardinality.class, OWLDataExactCardinalityMixin.class); + module.setMixInAnnotation(OWLDataExactCardinalityImpl.class, OWLDataExactCardinalityImplMixin.class); - module.setMixInAnnotation(OWLObjectMinCardinality.class, OWLObjectMinCardinalityMixin.class); - module.setMixInAnnotation(OWLObjectMinCardinalityImpl.class, OWLObjectMinCardinalityImplMixin.class); + module.setMixInAnnotation(OWLObjectMinCardinality.class, OWLObjectMinCardinalityMixin.class); + module.setMixInAnnotation(OWLObjectMinCardinalityImpl.class, OWLObjectMinCardinalityImplMixin.class); - module.setMixInAnnotation(OWLObjectMaxCardinality.class, OWLObjectMaxCardinalityMixin.class); - module.setMixInAnnotation(OWLObjectMaxCardinalityImpl.class, OWLObjectMaxCardinalityImplMixin.class); + module.setMixInAnnotation(OWLObjectMaxCardinality.class, OWLObjectMaxCardinalityMixin.class); + module.setMixInAnnotation(OWLObjectMaxCardinalityImpl.class, OWLObjectMaxCardinalityImplMixin.class); - module.setMixInAnnotation(OWLObjectExactCardinality.class, OWLObjectExactCardinalityMixin.class); - module.setMixInAnnotation(OWLObjectExactCardinalityImpl.class, OWLObjectExactCardinalityImplMixin.class); + module.setMixInAnnotation(OWLObjectExactCardinality.class, OWLObjectExactCardinalityMixin.class); + module.setMixInAnnotation(OWLObjectExactCardinalityImpl.class, OWLObjectExactCardinalityImplMixin.class); - module.setMixInAnnotation(OWLObjectHasSelf.class, OWLObjectHasSelfMixin.class); - module.setMixInAnnotation(OWLObjectHasSelfImpl.class, OWLObjectHasSelfImplMixin.class); + module.setMixInAnnotation(OWLObjectHasSelf.class, OWLObjectHasSelfMixin.class); + module.setMixInAnnotation(OWLObjectHasSelfImpl.class, OWLObjectHasSelfImplMixin.class); - module.setMixInAnnotation(OWLObjectIntersectionOf.class, OWLObjectIntersectionOfMixin.class); - module.setMixInAnnotation(OWLObjectIntersectionOfImpl.class, OWLObjectIntersectionOfImplMixin.class); + module.setMixInAnnotation(OWLObjectIntersectionOf.class, OWLObjectIntersectionOfMixin.class); + module.setMixInAnnotation(OWLObjectIntersectionOfImpl.class, OWLObjectIntersectionOfImplMixin.class); - module.setMixInAnnotation(OWLObjectUnionOf.class, OWLObjectUnionOfMixin.class); - module.setMixInAnnotation(OWLObjectUnionOfImpl.class, OWLObjectUnionOfImplMixin.class); + module.setMixInAnnotation(OWLObjectUnionOf.class, OWLObjectUnionOfMixin.class); + module.setMixInAnnotation(OWLObjectUnionOfImpl.class, OWLObjectUnionOfImplMixin.class); - module.setMixInAnnotation(OWLObjectComplementOf.class, OWLObjectComplementOfMixin.class); - module.setMixInAnnotation(OWLObjectComplementOfImpl.class, OWLObjectComplementOfImplMixin.class); + module.setMixInAnnotation(OWLObjectComplementOf.class, OWLObjectComplementOfMixin.class); + module.setMixInAnnotation(OWLObjectComplementOfImpl.class, OWLObjectComplementOfImplMixin.class); - module.setMixInAnnotation(OWLObjectOneOf.class, OWLObjectOneOfMixin.class); - module.setMixInAnnotation(OWLObjectOneOfImpl.class, OWLObjectOneOfImplMixin.class); + module.setMixInAnnotation(OWLObjectOneOf.class, OWLObjectOneOfMixin.class); + module.setMixInAnnotation(OWLObjectOneOfImpl.class, OWLObjectOneOfImplMixin.class); - module.setMixInAnnotation(OWLDataIntersectionOf.class, OWLDataIntersectionOfMixin.class); - module.setMixInAnnotation(OWLDataIntersectionOfImpl.class, OWLDataIntersectionOfImplMixin.class); + module.setMixInAnnotation(OWLDataIntersectionOf.class, OWLDataIntersectionOfMixin.class); + module.setMixInAnnotation(OWLDataIntersectionOfImpl.class, OWLDataIntersectionOfImplMixin.class); - module.setMixInAnnotation(OWLDataUnionOf.class, OWLDataUnionOfMixin.class); - module.setMixInAnnotation(OWLDataUnionOfImpl.class, OWLDataUnionOfImplMixin.class); + module.setMixInAnnotation(OWLDataUnionOf.class, OWLDataUnionOfMixin.class); + module.setMixInAnnotation(OWLDataUnionOfImpl.class, OWLDataUnionOfImplMixin.class); - module.setMixInAnnotation(OWLDataComplementOf.class, OWLDataComplementOfMixin.class); - module.setMixInAnnotation(OWLDataComplementOfImpl.class, OWLDataComplementOfImplMixin.class); + module.setMixInAnnotation(OWLDataComplementOf.class, OWLDataComplementOfMixin.class); + module.setMixInAnnotation(OWLDataComplementOfImpl.class, OWLDataComplementOfImplMixin.class); - module.setMixInAnnotation(OWLDataOneOf.class, OWLDataOneOfMixin.class); - module.setMixInAnnotation(OWLDataOneOfImpl.class, OWLDataOneOfImplMixin.class); + module.setMixInAnnotation(OWLDataOneOf.class, OWLDataOneOfMixin.class); + module.setMixInAnnotation(OWLDataOneOfImpl.class, OWLDataOneOfImplMixin.class); - module.setMixInAnnotation(OWLDatatypeRestriction.class, OWLDatatypeRestrictionMixin.class); - module.setMixInAnnotation(OWLDatatypeRestrictionImpl.class, OWLDatatypeRestrictionImplMixin.class); + module.setMixInAnnotation(OWLDatatypeRestriction.class, OWLDatatypeRestrictionMixin.class); + module.setMixInAnnotation(OWLDatatypeRestrictionImpl.class, OWLDatatypeRestrictionImplMixin.class); - module.setMixInAnnotation(OWLFacetRestriction.class, OWLFacetRestrictionMixin.class); - module.setMixInAnnotation(OWLFacetRestrictionImpl.class, OWLFacetRestrictionImplMixin.class); + module.setMixInAnnotation(OWLFacetRestriction.class, OWLFacetRestrictionMixin.class); + module.setMixInAnnotation(OWLFacetRestrictionImpl.class, OWLFacetRestrictionImplMixin.class); - module.setMixInAnnotation(OWLLiteral.class, OWLLiteralMixin.class); + module.setMixInAnnotation(OWLLiteral.class, OWLLiteralMixin.class); - module.setMixInAnnotation(IRI.class, IRIMixin.class); + module.setMixInAnnotation(IRI.class, IRIMixin.class); - mapper.addHandler(new MissingTypeIdDeserializationProblemHandler()); - module.registerSubtypes( - BrowserTextChangedEvent.class, - ClassFrameChangedEvent.class, - DataPropertyFrameChangedEvent.class, - DatatypeFrameChangedEvent.class, - NamedIndividualFrameChangedEvent.class, - ObjectPropertyFrameChangedEvent.class, - EntityDeprecationStatusChangedEvent.class, - AnnotationPropertyFrameChangedEvent.class, - LargeNumberOfChangesEvent.class, - OntologyBrowserTextChangedEvent.class, - PermissionsChangedEvent.class, - ProjectChangedEvent.class, - ProjectLinearizationChangedEvent.class, - NewRevisionsEvent.class, - ProjectMovedToTrashEvent.class, - OntologyChangedEvent.class, - ProjectRemovedFromTrashEvent.class, - EntityHierarchyChangedEvent.class, - CommentPostedEvent.class, - CommentUpdatedEvent.class, - DiscussionThreadCreatedEvent.class, - DiscussionThreadStatusChangedEvent.class, - DisplayNameSettingsChangedEvent.class, - ProjectSettingsChangedEvent.class, - EntityTagsChangedEvent.class, - ProjectTagsChangedEvent.class, - WatchAddedEvent.class, - WatchRemovedEvent.class); + mapper.addHandler(new MissingTypeIdDeserializationProblemHandler()); + module.registerSubtypes( + BrowserTextChangedEvent.class, + ClassFrameChangedEvent.class, + DataPropertyFrameChangedEvent.class, + DatatypeFrameChangedEvent.class, + NamedIndividualFrameChangedEvent.class, + ObjectPropertyFrameChangedEvent.class, + EntityDeprecationStatusChangedEvent.class, + AnnotationPropertyFrameChangedEvent.class, + LargeNumberOfChangesEvent.class, + OntologyBrowserTextChangedEvent.class, + PermissionsChangedEvent.class, + ProjectChangedEvent.class, + UpdateUiHistoryEvent.class, + NewRevisionsEvent.class, + ProjectMovedToTrashEvent.class, + OntologyChangedEvent.class, + ProjectRemovedFromTrashEvent.class, + EntityHierarchyChangedEvent.class, + CommentPostedEvent.class, + CommentUpdatedEvent.class, + DiscussionThreadCreatedEvent.class, + DiscussionThreadStatusChangedEvent.class, + DisplayNameSettingsChangedEvent.class, + ProjectSettingsChangedEvent.class, + EntityTagsChangedEvent.class, + ProjectTagsChangedEvent.class, + WatchAddedEvent.class, + WatchRemovedEvent.class); - mapper.registerModule(module); + mapper.registerModule(module); - return mapper; + return mapper; } diff --git a/src/main/java/edu/stanford/protege/webprotegeeventshistory/config/events/ProjectLinearizationChangedEvent.java b/src/main/java/edu/stanford/protege/webprotegeeventshistory/config/events/ProjectLinearizationChangedEvent.java deleted file mode 100644 index d318253..0000000 --- a/src/main/java/edu/stanford/protege/webprotegeeventshistory/config/events/ProjectLinearizationChangedEvent.java +++ /dev/null @@ -1,23 +0,0 @@ -package edu.stanford.protege.webprotegeeventshistory.config.events; - -import com.fasterxml.jackson.annotation.JsonTypeName; -import edu.stanford.protege.webprotege.common.*; - -@JsonTypeName(ProjectLinearizationChangedEvent.CHANNEL) -public record ProjectLinearizationChangedEvent(EventId eventId, - ProjectId projectId) implements ProjectEvent { - public static final String CHANNEL = "webprotege.linearization.ProjectLinearizationChangedEvent"; - - public String getChannel() { - return CHANNEL; - } - - public EventId eventId() { - return this.eventId; - } - - public ProjectId projectId() { - return this.projectId; - } - -} diff --git a/src/main/java/edu/stanford/protege/webprotegeeventshistory/config/events/UpdateUiHistoryEvent.java b/src/main/java/edu/stanford/protege/webprotegeeventshistory/config/events/UpdateUiHistoryEvent.java new file mode 100644 index 0000000..a18a917 --- /dev/null +++ b/src/main/java/edu/stanford/protege/webprotegeeventshistory/config/events/UpdateUiHistoryEvent.java @@ -0,0 +1,68 @@ +package edu.stanford.protege.webprotegeeventshistory.config.events; + +import com.fasterxml.jackson.annotation.*; +import com.google.common.base.Objects; +import edu.stanford.protege.webprotege.common.*; + +import java.util.Set; + +@JsonTypeName(UpdateUiHistoryEvent.CHANNEL) +public record UpdateUiHistoryEvent(EventId eventId, + ProjectId projectId, + Set affectedEntityIris) implements ProjectEvent { + + @JsonCreator + public static UpdateUiHistoryEvent create(@JsonProperty("eventId") EventId eventId, + @JsonProperty("projectId") ProjectId projectId, + @JsonProperty("afectedEntityIris") Set afectedEntityIris + ) { + return new UpdateUiHistoryEvent(eventId, projectId, afectedEntityIris); + } + + public static final String CHANNEL = "webprotege.events.projects.uiHistory.UpdateUiHistoryEvent"; + + @JsonProperty("projectId") + public ProjectId projectId() { + return this.projectId; + } + + @Override + @JsonProperty("eventId") + public EventId eventId() { + return eventId; + } + + @Override + @JsonProperty("afectedEntityIris") + public Set affectedEntityIris() { + return affectedEntityIris; + } + + @Override + public String getChannel() { + return CHANNEL; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + UpdateUiHistoryEvent that = (UpdateUiHistoryEvent) o; + return Objects.equal(eventId, that.eventId) && Objects.equal(projectId, that.projectId) && Objects.equal(affectedEntityIris, that.affectedEntityIris); + } + + @Override + public int hashCode() { + return Objects.hashCode(eventId, projectId, affectedEntityIris); + } + + @Override + public String toString() { + return "UpdateUiHistoryEvent{" + + "eventId=" + eventId + + ", projectId=" + projectId + + ", subjects=" + affectedEntityIris + + '}'; + } + +} diff --git a/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/events/NewRevisionsEvent.java b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/events/NewRevisionsEvent.java index f782ddb..8fbf41c 100644 --- a/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/events/NewRevisionsEvent.java +++ b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/events/NewRevisionsEvent.java @@ -1,11 +1,10 @@ package edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.events; -import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.*; import edu.stanford.protege.webprotege.common.*; import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.dto.ProjectChangeForEntity; -import jakarta.validation.constraints.NotNull; -import java.util.*; +import java.util.Set; import static edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.events.NewRevisionsEvent.CHANNEL; @@ -18,23 +17,27 @@ public record NewRevisionsEvent( ) implements ProjectEvent { public final static String CHANNEL = "webprotege.events.projects.uiHistory.NewRevisionsEvent"; - public static NewRevisionsEvent create(EventId eventId, - ProjectId projectId, - Set changes) { + @JsonCreator + public static NewRevisionsEvent create(@JsonProperty("eventId") EventId eventId, + @JsonProperty("projectId") ProjectId projectId, + @JsonProperty("changes") Set changes) { return new NewRevisionsEvent(eventId, projectId, changes); } @Override + @JsonProperty("eventId") public ProjectId projectId() { return projectId; } @Override + @JsonProperty("projectId") public EventId eventId() { return eventId; } - public Set getProjectChanges() { + @JsonProperty("changes") + public Set changes() { return changes; } diff --git a/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/handlers/NewRevisionsEventHandler.java b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/handlers/NewRevisionsEventHandler.java index e3c6125..86fb6f0 100644 --- a/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/handlers/NewRevisionsEventHandler.java +++ b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/handlers/NewRevisionsEventHandler.java @@ -1,19 +1,26 @@ package edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.handlers; +import edu.stanford.protege.webprotege.common.EventId; import edu.stanford.protege.webprotege.ipc.EventHandler; +import edu.stanford.protege.webprotegeeventshistory.config.events.UpdateUiHistoryEvent; import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.events.NewRevisionsEvent; import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.services.NewRevisionsEventService; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Component; import javax.annotation.Nonnull; +import java.util.*; @Component public class NewRevisionsEventHandler implements EventHandler { - private final NewRevisionsEventService linRevisionsEventService; + private final NewRevisionsEventService newRevisionsEventService; + private final ApplicationEventPublisher eventPublisher; - public NewRevisionsEventHandler(NewRevisionsEventService linRevisionsEventService) { - this.linRevisionsEventService = linRevisionsEventService; + public NewRevisionsEventHandler(NewRevisionsEventService newRevisionsEventService, + ApplicationEventPublisher eventPublisher) { + this.newRevisionsEventService = newRevisionsEventService; + this.eventPublisher = eventPublisher; } @Nonnull @@ -35,6 +42,12 @@ public Class getEventClass() { @Override public void handleEvent(NewRevisionsEvent event) { - linRevisionsEventService.registerEvent(event); + newRevisionsEventService.registerEvent(event); + Set entitySubjects = new HashSet<>(); + event.changes().forEach(change -> { + entitySubjects.add(change.whoficEntityIri()); + }); + + eventPublisher.publishEvent(UpdateUiHistoryEvent.create(EventId.generate(), event.projectId(), entitySubjects)); } } diff --git a/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/NewRevisionsEventServiceImpl.java b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/NewRevisionsEventServiceImpl.java index aad56d4..89c7a95 100644 --- a/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/NewRevisionsEventServiceImpl.java +++ b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/NewRevisionsEventServiceImpl.java @@ -3,6 +3,7 @@ import edu.stanford.protege.webprotege.change.ProjectChange; import edu.stanford.protege.webprotege.common.Page; import edu.stanford.protege.webprotege.common.*; +import edu.stanford.protege.webprotegeeventshistory.config.events.UpdateUiHistoryEvent; import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.events.*; import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.mappers.*; import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.repositories.RevisionsEventRepository; @@ -32,8 +33,8 @@ public NewRevisionsEventServiceImpl(RevisionsEventRepository repository, } @Override - public void registerEvent(NewRevisionsEvent newLinRevEvent) { - List revisionsEvents = revisionEventMapper.mapNewRevisionsEventToRevisionsEvents(newLinRevEvent); + public void registerEvent(NewRevisionsEvent newRevEvent) { + List revisionsEvents = revisionEventMapper.mapNewRevisionsEventToRevisionsEvents(newRevEvent); repository.saveAll(revisionsEvents); } @@ -60,15 +61,16 @@ public Page fetchPaginatedProjectChanges(ProjectId projectId, Opt Pageable pageable = PageRequest.of(pageNumber - 1, pageSize, Sort.by(Sort.Direction.DESC, TIMESTAMP)); org.springframework.data.domain.Page revisionsEventPage = repository.findAll(example, pageable); + if (revisionsEventPage.getTotalElements() == 0) { + return Page.emptyPage(); + } List changes = revisionsEventPage.get() .map(revisionsEvent -> projectChangeMapper.mapProjectChangeDocumentToProjectChange(revisionsEvent.projectChange())) .toList(); - int pageCount = revisionsEventPage.getTotalPages() == 0 ? 1 : revisionsEventPage.getTotalPages(); - //Page number from ui is starting from 1 //PageRequest from spring-data is starting from 0 - return Page.create(pageNumber, pageCount, changes, revisionsEventPage.getTotalElements()); + return Page.create(pageNumber, revisionsEventPage.getTotalPages(), changes, revisionsEventPage.getTotalElements()); } } diff --git a/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/ProjectChangeDispatcher.java b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/ProjectChangeDispatcher.java new file mode 100644 index 0000000..f28c388 --- /dev/null +++ b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/ProjectChangeDispatcher.java @@ -0,0 +1,7 @@ +package edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.services; + +import edu.stanford.protege.webprotege.common.*; + +public interface ProjectChangeDispatcher { + void dispatchEvent(ProjectId projectId, ProjectEvent event); +} diff --git a/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/ProjectChangeDispatcherImpl.java b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/ProjectChangeDispatcherImpl.java new file mode 100644 index 0000000..53768b7 --- /dev/null +++ b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/ProjectChangeDispatcherImpl.java @@ -0,0 +1,24 @@ +package edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.services; + +import edu.stanford.protege.webprotege.common.*; +import edu.stanford.protege.webprotege.ipc.EventDispatcher; +import edu.stanford.protege.webprotegeeventshistory.dto.PackagedProjectChangeEvent; +import org.springframework.stereotype.*; + +import java.util.List; + +@Component +public class ProjectChangeDispatcherImpl implements ProjectChangeDispatcher { + + private final EventDispatcher eventDispatcher; + + public ProjectChangeDispatcherImpl(EventDispatcher eventDispatcher) { + this.eventDispatcher = eventDispatcher; + } + + @Override + public void dispatchEvent(ProjectId projectId, ProjectEvent event) { + var packagedProjectChange = new PackagedProjectChangeEvent(projectId, EventId.generate(), List.of(event)); + eventDispatcher.dispatchEvent(packagedProjectChange); + } +} diff --git a/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/ProjectChangeService.java b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/ProjectChangeService.java new file mode 100644 index 0000000..7bf5575 --- /dev/null +++ b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/ProjectChangeService.java @@ -0,0 +1,7 @@ +package edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.services; + +import edu.stanford.protege.webprotege.common.*; + +public interface ProjectChangeService { + void emitProjectChange(ProjectId projectId, ProjectEvent event); +} diff --git a/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/ProjectChangeServiceImpl.java b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/ProjectChangeServiceImpl.java new file mode 100644 index 0000000..d6ce17f --- /dev/null +++ b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/ProjectChangeServiceImpl.java @@ -0,0 +1,29 @@ +package edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.services; + +import edu.stanford.protege.webprotege.common.*; +import edu.stanford.protege.webprotegeeventshistory.config.events.UpdateUiHistoryEvent; +import org.springframework.context.event.EventListener; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +@Service +public class ProjectChangeServiceImpl implements ProjectChangeService { + + private final ProjectChangeDispatcher changeDispatcher; + + public ProjectChangeServiceImpl(ProjectChangeDispatcher changeDispatcher) { + this.changeDispatcher = changeDispatcher; + } + + @Async + @EventListener + public void handleUiHistoryEvent(UpdateUiHistoryEvent event) { + // Emit the project change when the event is handled + emitProjectChange(event.projectId(), UpdateUiHistoryEvent.create(EventId.generate(), event.projectId(), event.affectedEntityIris())); + } + + @Override + public void emitProjectChange(ProjectId projectId, ProjectEvent event) { + this.changeDispatcher.dispatchEvent(projectId, event); + } +}