java.lang.Object
it.uniroma2.art.semanticturkey.services.STServiceAdapter
it.uniroma2.art.semanticturkey.services.core.Alignment
All Implemented Interfaces:
NewerNewStyleService, STService

@STService public class Alignment extends STServiceAdapter
  • Field Details

    • logger

      protected static org.slf4j.Logger logger
    • exptManager

      @Autowired protected ExtensionPointManager exptManager
    • DEFAULT_ALINGNMENT_PAGE_SIZE

      public static final long DEFAULT_ALINGNMENT_PAGE_SIZE
      See Also:
  • Constructor Details

    • Alignment

      public Alignment()
  • Method Details

    • searchResources

      @STServiceOperation @Read @PreAuthorize("@auth.isAuthorized(\'rdf(resource, alignment)\', \'R\')") public Collection<AnnotatedValue<org.eclipse.rdf4j.model.Resource>> searchResources(org.eclipse.rdf4j.model.IRI inputRes, ResourcePosition resourcePosition, String[] rolesArray, @Optional List<SearchMode> searchModeList, Map<String,org.eclipse.rdf4j.model.IRI> langToLexModel) throws IllegalStateException, DatasetMetadataException
      Returns a list of Resoruces which are "similar" to the one in input. This service should be used to obtain a list of possible candidate for an alignment between a local resource and resources in a remote dataset
      Parameters:
      inputRes - the input resources from which to obtain the lexicalizations used in the search in the remote dataset
      resourcePosition - the remote dataset or a local project
      rolesArray - the roles to which the returned resources should belong to
      searchModeList - the optional list of searchMode that will be used in the search (is no value is passed, then 'contains' and 'fuzzy' are used)
      langToLexModel -
      Returns:
      the list of remote resources obtained from the search
      Throws:
      it.uniroma2.art.semanticturkey.mdr.core.MetadataRegistryStateException
      it.uniroma2.art.semanticturkey.mdr.core.NoSuchDatasetMetadataException
      STPropertyAccessException
      IllegalStateException
      DatasetMetadataException
    • searchResourcesForRemote

      public Collection<AnnotatedValue<org.eclipse.rdf4j.model.Resource>> searchResourcesForRemote(List<org.eclipse.rdf4j.model.Literal> labelsList, org.eclipse.rdf4j.repository.RepositoryConnection remoteConn, String[] rolesArray, List<SearchMode> searchModeList, Map<String,org.eclipse.rdf4j.model.IRI> langToLexModel, SearchStrategy regexSearchStrategy)
    • orderResultsFromSearch

      public Collection<AnnotatedValue<org.eclipse.rdf4j.model.Resource>> orderResultsFromSearch(Collection<AnnotatedValue<org.eclipse.rdf4j.model.Resource>> annList)
    • getMappingCount

      @STServiceOperation @Read @PreAuthorize("@auth.isAuthorized(\'rdf(resource, alignment)\', \'R\')") public Long getMappingCount(String targetUriPrefix, @Optional(defaultValue="") List<org.eclipse.rdf4j.model.IRI> mappingProperties, @Optional(defaultValue="false") boolean expressInPages, @Optional(defaultValue="50") long pageSize)
      Returns the number of available mappings
      Parameters:
      targetUriPrefix -
      mappingProperties -
      expressInPages - whether the count should be an absolute number or expressed as the number of pages
      pageSize - if less or equal to zero, then everything goes into one page
      Returns:
      Throws:
      ProjectInconsistentException
    • getMappings

      @STServiceOperation @Read @PreAuthorize("@auth.isAuthorized(\'rdf(resource, alignment)\', \'R\')") public Collection<org.apache.commons.lang3.tuple.Triple<org.eclipse.rdf4j.model.IRI,org.eclipse.rdf4j.model.IRI,org.eclipse.rdf4j.model.IRI>> getMappings(String targetUriPrefix, @Optional(defaultValue="0") int page, @Optional(defaultValue="50") int pageSize, @Optional(defaultValue="") List<org.eclipse.rdf4j.model.IRI> mappingProperties)
      Returns the available mappings
      Parameters:
      targetUriPrefix -
      page -
      pageSize -
      mappingProperties -
      Returns:
      Throws:
      ProjectInconsistentException
    • exportMappings

      @STServiceOperation @Read @PreAuthorize("@auth.isAuthorized(\'rdf(resource, alignment)\', \'R\')") public void exportMappings(jakarta.servlet.http.HttpServletResponse oRes, String targetUriPrefix, @Optional(defaultValue="") List<org.eclipse.rdf4j.model.IRI> mappingProperties, @Optional(defaultValue="TURTLE") org.eclipse.rdf4j.rio.RDFFormat format) throws IOException
      Throws:
      IOException
    • prepareMappingsQuery

      public static org.eclipse.rdf4j.query.GraphQuery prepareMappingsQuery(org.eclipse.rdf4j.repository.RepositoryConnection conn, Project project, List<org.eclipse.rdf4j.model.IRI> mappingProperties, @Nullable String targetUriPrefix)
    • addAlignment

      @STServiceOperation @Write @PreAuthorize("@auth.isAuthorized(\'rdf(\' +@auth.typeof(#sourceResource)+ \', alignment)\', \'C\')") public void addAlignment(org.eclipse.rdf4j.model.Resource sourceResource, org.eclipse.rdf4j.model.IRI predicate, org.eclipse.rdf4j.model.IRI targetResource)
      Adds the given alignment triple only if predicate is a valid alignment property
      Parameters:
      sourceResource -
      predicate -
      targetResource -
    • getMappingProperties

      @STServiceOperation @Read @PreAuthorize("@auth.isAuthorized(\'rdf(resource, alignment)\', \'R\')") public Collection<AnnotatedValue<org.eclipse.rdf4j.model.IRI>> getMappingProperties(RDFResourceRole role, @Optional(defaultValue="false") boolean allMappingProps)
      Returns the available alignment properties depending on the resource role to align (property, or concept, or class,...).
      Parameters:
      role - role of resource to align
      allMappingProps - if false returns just the mapping properties available for the current model type; if true returns all the mapping properties independently from the model type
      Returns:
      Throws:
      ProjectInconsistentException
    • loadAlignment

      @STServiceOperation(method=POST) @Read @PreAuthorize("@auth.isAuthorized(\'rdf(resource, alignment)\', \'R\')") public com.fasterxml.jackson.databind.JsonNode loadAlignment(org.springframework.web.multipart.MultipartFile inputFile, @Optional Project leftProject, @Optional Project rightProject) throws AlignmentInitializationException, IOException
      Loads an alignment file (that is compliant with AlignmentAPI format) and if one of the two aligned ontologies has the same baseURI of the current model, then return a response with its content.
      Parameters:
      inputFile -
      Returns:
      Throws:
      AlignmentInitializationException
      IOException
    • loadAlignmentHelper

      public com.fasterxml.jackson.databind.JsonNode loadAlignmentHelper(AlignmentModel alignModel, Project leftProject, Project rightProject) throws AlignmentInitializationException
      This method is responsible for the finalization of alignment load operations, irrespectively of the source of the alignment (e.g. file, GENOMA task, etc...)
      Parameters:
      alignModel -
      Returns:
      Throws:
      AlignmentInitializationException
    • listCells

      @STServiceOperation @Read @PreAuthorize("@auth.isAuthorized(\'rdf(resource, alignment)\', \'R\')") public com.fasterxml.jackson.databind.JsonNode listCells(@Optional(defaultValue="0") int pageIdx, @Optional(defaultValue="0") int range)
      Returns the cells of the alignment file. Handles the scalability returning a portion of cells if pageIdx and range are provided as parameters
      Parameters:
      pageIdx - index of the page in case
      range - alignment per page to show. If 0, returns all the alignments.
      Returns:
    • acceptAlignment

      @STServiceOperation @Read @PreAuthorize("@auth.isAuthorized(\'rdf(\' +@auth.typeof(#entity1)+ \', alignment)\', \'C\')") public com.fasterxml.jackson.databind.JsonNode acceptAlignment(org.eclipse.rdf4j.model.IRI entity1, org.eclipse.rdf4j.model.IRI entity2, String relation, @Optional RDFResourceRole entity1Role, @Optional org.eclipse.rdf4j.model.IRI forcedProperty, @Optional(defaultValue="false") boolean setAsDefault) throws ProjectAccessException, ProjectInexistentException, InvalidProjectNameException
      Accepts the alignment updating the alignment model
      Parameters:
      entity1 -
      entity2 -
      relation -
      Returns:
      Throws:
      ProjectAccessException
      ProjectInexistentException
      InvalidProjectNameException
    • acceptAllAlignment

      @STServiceOperation @Read @PreAuthorize("@auth.isAuthorized(\'rdf(resource, alignment)\', \'C\')") public com.fasterxml.jackson.databind.JsonNode acceptAllAlignment() throws ProjectAccessException, ProjectInexistentException, InvalidProjectNameException
      Accepts all the alignment updating the alignment model
      Returns:
      Throws:
      ProjectAccessException
      ProjectInexistentException
      InvalidProjectNameException
    • acceptAllAbove

      @STServiceOperation @Read @PreAuthorize("@auth.isAuthorized(\'rdf(resource, alignment)\', \'C\')") public com.fasterxml.jackson.databind.JsonNode acceptAllAbove(float threshold) throws ProjectAccessException, ProjectInexistentException, InvalidProjectNameException
      Accepts all the alignment with measure above the given threshold updating the alignment model. The response contains the description of all the cells affected by the accept
      Parameters:
      threshold -
      Returns:
      Throws:
      ProjectAccessException
      ProjectInexistentException
      InvalidProjectNameException
    • rejectAlignment

      @STServiceOperation @Read @PreAuthorize("@auth.isAuthorized(\'rdf(resource, alignment)\', \'\')") public com.fasterxml.jackson.databind.JsonNode rejectAlignment(org.eclipse.rdf4j.model.IRI entity1, org.eclipse.rdf4j.model.IRI entity2, String relation)
      Rejects the alignment
      Parameters:
      entity1 -
      entity2 -
      relation -
      Returns:
    • rejectAllAlignment

      @STServiceOperation @Read @PreAuthorize("@auth.isAuthorized(\'rdf(resource, alignment)\', \'\')") public com.fasterxml.jackson.databind.JsonNode rejectAllAlignment()
      Rejects all the alignments
      Returns:
    • rejectAllUnder

      @STServiceOperation @Read @PreAuthorize("@auth.isAuthorized(\'rdf(resource, alignment)\', \'\')") public com.fasterxml.jackson.databind.JsonNode rejectAllUnder(float threshold)
      Rejects all the alignments under the given threshold
      Parameters:
      threshold -
      Returns:
    • changeRelation

      @STServiceOperation @Read public com.fasterxml.jackson.databind.JsonNode changeRelation(org.eclipse.rdf4j.model.IRI entity1, org.eclipse.rdf4j.model.IRI entity2, String oldRelation, String newRelation)
      Change the relation of an alignment
      Parameters:
      entity1 -
      entity2 -
      oldRelation -
      Returns:
    • changeMappingProperty

      @STServiceOperation @Read @PreAuthorize("@auth.isAuthorized(\'rdf(resource, alignment)\', \'U\')") public com.fasterxml.jackson.databind.JsonNode changeMappingProperty(org.eclipse.rdf4j.model.IRI entity1, org.eclipse.rdf4j.model.IRI entity2, String relation, org.eclipse.rdf4j.model.IRI mappingProperty)
      Change the mapping property of an alignment
      Parameters:
      entity1 -
      entity2 -
      relation -
      mappingProperty -
      Returns:
    • applyValidation

      @STServiceOperation(method=POST) @Write @PreAuthorize("@auth.isAuthorized(\'rdf(resource, alignment)\', \'CUD\')") public com.fasterxml.jackson.databind.JsonNode applyValidation(@Optional(defaultValue="false") boolean deleteRejected)
      Adds the accepted alignment cell to the ontology model and delete the rejected ones (if previously added to the ontology)
      Parameters:
      deleteRejected - tells if remove the triples related to rejected alignments
      Returns:
    • applyValidationToEdoal

      @STServiceOperation(method=POST) @Write public void applyValidationToEdoal(@Optional(defaultValue="false") boolean deleteRejected)
      Adds the accepted alignment cell to the EDOAL model and delete the rejected ones (if previously added). Note: this service needs to be here and cannot be moved to Edoal class since I need to retrieve the alignment model from modelMap that is stored here
      Parameters:
      deleteRejected - tells if remove the linkset related to rejected alignments
    • exportAlignment

      @STServiceOperation @PreAuthorize("@auth.isAuthorized(\'rdf(resource, alignment)\', \'R\')") public void exportAlignment(jakarta.servlet.http.HttpServletResponse oRes) throws IOException
      Save the alignment with the performed changes and export as rdf file
      Parameters:
      oRes -
      Throws:
      IOException
    • getSuggestedProperties

      @STServiceOperation @Read @PreAuthorize("@auth.isAuthorized(\'rdf(resource, alignment)\', \'R\')") public Collection<AnnotatedValue<org.eclipse.rdf4j.model.IRI>> getSuggestedProperties(RDFResourceRole role, String relation)
      Return a list of mapping properties suggested for the given entity and the alignment relation
      Parameters:
      role -
      relation -
      Returns:
      Throws:
      InvalidAlignmentRelationException
      ProjectInconsistentException
    • getAvailableMappingProperties

      public static List<org.eclipse.rdf4j.model.IRI> getAvailableMappingProperties(RDFResourceRole role, org.eclipse.rdf4j.model.IRI model, boolean allMappingProps)
      Returns a list of mapping properties compliant to the given role
      Parameters:
      role -
      allMappingProps - if true, returns all the known mapping properties, if false filters out the properties not compatible with the resource and the project type
      Returns:
      Throws:
      ProjectInconsistentException
    • closeSession

      @STServiceOperation @Read public void closeSession()
      Remove the saved alignment from the session