Class Alignment
java.lang.Object
it.uniroma2.art.semanticturkey.services.STServiceAdapter
it.uniroma2.art.semanticturkey.services.core.Alignment
- All Implemented Interfaces:
NewerNewStyleService
,STService
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
protected ExtensionPointManager
protected static org.slf4j.Logger
Fields inherited from class it.uniroma2.art.semanticturkey.services.STServiceAdapter
applicationEventPublisher, cfManager, stServiceContext
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.fasterxml.jackson.databind.JsonNode
acceptAlignment
(org.eclipse.rdf4j.model.IRI entity1, org.eclipse.rdf4j.model.IRI entity2, String relation, RDFResourceRole entity1Role, org.eclipse.rdf4j.model.IRI forcedProperty, boolean setAsDefault) Accepts the alignment updating the alignment modelcom.fasterxml.jackson.databind.JsonNode
acceptAllAbove
(float threshold) Accepts all the alignment with measure above the given threshold updating the alignment model.com.fasterxml.jackson.databind.JsonNode
Accepts all the alignment updating the alignment modelvoid
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 propertycom.fasterxml.jackson.databind.JsonNode
applyValidation
(boolean deleteRejected) Adds the accepted alignment cell to the ontology model and delete the rejected ones (if previously added to the ontology)void
applyValidationToEdoal
(boolean deleteRejected) Adds the accepted alignment cell to the EDOAL model and delete the rejected ones (if previously added).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 alignmentcom.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 alignmentvoid
Remove the saved alignment from the sessionvoid
exportAlignment
(jakarta.servlet.http.HttpServletResponse oRes) Save the alignment with the performed changes and export as rdf filevoid
exportMappings
(jakarta.servlet.http.HttpServletResponse oRes, String targetUriPrefix, List<org.eclipse.rdf4j.model.IRI> mappingProperties, org.eclipse.rdf4j.rio.RDFFormat format) Collection<org.apache.commons.lang3.tuple.Triple<org.eclipse.rdf4j.model.IRI,
org.eclipse.rdf4j.model.IRI, org.eclipse.rdf4j.model.IRI>> filterMappings
(String targetUriPrefix, List<org.eclipse.rdf4j.model.IRI> mappingProperties, String searchString, boolean useLexicalizations, boolean useLocalName, boolean useURI, SearchMode searchMode, boolean useNotes, List<String> langs, String sortByLang, boolean includeLocales, boolean searchInRDFSLabel, boolean searchInSKOSLabel, boolean searchInSKOSXLLabel, boolean searchInOntolex) 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 rolegetMappingCount
(String targetUriPrefix, List<org.eclipse.rdf4j.model.IRI> mappingProperties, boolean includeSubProperties, boolean expressInPages, long pageSize) Returns the number of available mappingsCollection<AnnotatedValue<org.eclipse.rdf4j.model.IRI>>
getMappingProperties
(RDFResourceRole role, boolean allMappingProps) Returns the available alignment properties depending on the resource role to align (property, or concept, or class,...).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, int page, int pageSize, List<org.eclipse.rdf4j.model.IRI> mappingProperties, boolean includeSubProperties, String sortByLang) Returns the available mappingsCollection<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 relationcom.fasterxml.jackson.databind.JsonNode
listCells
(int pageIdx, int range) Returns the cells of the alignment file.com.fasterxml.jackson.databind.JsonNode
loadAlignment
(org.springframework.web.multipart.MultipartFile inputFile, Project leftProject, Project rightProject) 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.com.fasterxml.jackson.databind.JsonNode
loadAlignmentHelper
(AlignmentModel alignModel, Project leftProject, Project rightProject) This method is responsible for the finalization of alignment load operations, irrespectively of the source of the alignment (e.g. file, GENOMA task, etc...)Collection<AnnotatedValue<org.eclipse.rdf4j.model.Resource>>
orderResultsFromSearch
(Collection<AnnotatedValue<org.eclipse.rdf4j.model.Resource>> annList) static org.eclipse.rdf4j.query.GraphQuery
prepareMappingsQuery
(org.eclipse.rdf4j.repository.RepositoryConnection conn, Project project, List<org.eclipse.rdf4j.model.IRI> mappingProperties, String targetUriPrefix) com.fasterxml.jackson.databind.JsonNode
rejectAlignment
(org.eclipse.rdf4j.model.IRI entity1, org.eclipse.rdf4j.model.IRI entity2, String relation) Rejects the alignmentcom.fasterxml.jackson.databind.JsonNode
Rejects all the alignmentscom.fasterxml.jackson.databind.JsonNode
rejectAllUnder
(float threshold) Rejects all the alignments under the given thresholdCollection<AnnotatedValue<org.eclipse.rdf4j.model.Resource>>
searchResources
(org.eclipse.rdf4j.model.IRI inputRes, ResourcePosition resourcePosition, String[] rolesArray, List<SearchMode> searchModeList, Map<String, org.eclipse.rdf4j.model.IRI> langToLexModel) Returns a list of Resoruces which are "similar" to the one in input.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) Methods inherited from class it.uniroma2.art.semanticturkey.services.STServiceAdapter
addValue, checkNotLocallyDefined, createQueryBuilder, generateIRI, generateNatureSPARQLSelectPart, generateNatureSPARQLWherePart, generateResourceWithCustomConstructor, getCodaLexModeForSearchFromLexicalizationModel, getDeleteGraph, getGraphFromNature, getInitializedCodaCore, getManagedConnection, getMetadataGraph, getOptionalProject, getPlatformTransactionManager, getProject, getRepository, getRoleFromNature, getUserNamedGraphs, getWorkingGraph, instantiateSearchStrategy, instantiateSearchStrategy, parseReference, publishResourceDeleted, publishResourceDeleted, removeReifiedValue, retrieveResources, shutDownCodaCore, updateTriplePredicate
-
Field Details
-
logger
protected static org.slf4j.Logger logger -
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, DatasetMetadataExceptionReturns 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 datasetresourcePosition
- the remote dataset or a local projectrolesArray
- the roles to which the returned resources should belong tosearchModeList
- 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="true") boolean includeSubProperties, @Optional(defaultValue="false") boolean expressInPages, @Optional(defaultValue="50") long pageSize) Returns the number of available mappings- Parameters:
targetUriPrefix
-mappingProperties
-includeSubProperties
- if specified, the mappings are determined taking into account subproperties of the mapping propertiesexpressInPages
- whether the count should be an absolute number or expressed as the number of pagespageSize
- 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, getMappingsorg.eclipse.rdf4j.model.IRI>> (String targetUriPrefix, @Optional(defaultValue="0") int page, @Optional(defaultValue="50") int pageSize, @Optional(defaultValue="") List<org.eclipse.rdf4j.model.IRI> mappingProperties, @Optional(defaultValue="true") boolean includeSubProperties, @Optional String sortByLang) Returns the available mappings- Parameters:
targetUriPrefix
-page
-pageSize
-mappingProperties
-includeSubProperties
- if specified, the mappings are determined taking into account subproperties of the mapping propertiessortByLang
- if specified, the returned mappings are sorted according the rendering of the source entity in the specified language- Returns:
- Throws:
ProjectInconsistentException
-
filterMappings
@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, filterMappingsorg.eclipse.rdf4j.model.IRI>> (String targetUriPrefix, @Optional(defaultValue="") List<org.eclipse.rdf4j.model.IRI> mappingProperties, @Optional String searchString, @Optional(defaultValue="true") boolean useLexicalizations, @Optional(defaultValue="false") boolean useLocalName, @Optional(defaultValue="false") boolean useURI, SearchMode searchMode, @Optional(defaultValue="false") boolean useNotes, @Optional List<String> langs, @Optional String sortByLang, @Optional(defaultValue="false") boolean includeLocales, @Optional(defaultValue="false") boolean searchInRDFSLabel, @Optional(defaultValue="false") boolean searchInSKOSLabel, @Optional(defaultValue="false") boolean searchInSKOSXLLabel, @Optional(defaultValue="false") boolean searchInOntolex) throws SearchStatusException, STPropertyAccessException -
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
-
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 alignallMappingProps
- 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 ifpageIdx
andrange
are provided as parameters- Parameters:
pageIdx
- index of the page in caserange
- 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, InvalidProjectNameExceptionAccepts 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
Remove the saved alignment from the session
-