Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Termit-UI #423 remove unused terms #240

Merged
merged 4 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Then, TermIt can be run and exposed at the port 8080 as

An optional argument is `<GRAPHDB_REPOSITORY_URL>` pointing to the RDF4J/GraphDB repository.

TermIt Docker images are also build and published to [DockerHub](https://hub.docker.com/r/kbsscvut/termit).
TermIt Docker images are also published to [DockerHub](https://hub.docker.com/r/kbsscvut/termit).

## Links

Expand Down

This file was deleted.

16 changes: 0 additions & 16 deletions src/main/java/cz/cvut/kbss/termit/rest/TermController.java
Original file line number Diff line number Diff line change
Expand Up @@ -395,22 +395,6 @@ public void removeTerm(
LOG.debug("Term {} removed.", termUri);
}

@Operation(security = {@SecurityRequirement(name = "bearer-key")},
description = "Gets terms from the vocabulary with the specified identifier that are not used in any document of definition")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "Unused terms."),
@ApiResponse(responseCode = "404", description = "Vocabulary not found.")
})
@GetMapping(value = "/vocabularies/{localName}/unused-terms",
produces = {MediaType.APPLICATION_JSON_VALUE, JsonLd.MEDIA_TYPE})
public List<URI> getUnusedTermsInVocabulary(
@Parameter(description = ApiDoc.ID_LOCAL_NAME_DESCRIPTION, example = ApiDoc.ID_LOCAL_NAME_EXAMPLE)
@PathVariable String localName,
@Parameter(description = ApiDoc.ID_NAMESPACE_DESCRIPTION, example = ApiDoc.ID_NAMESPACE_EXAMPLE)
@RequestParam(name = QueryParams.NAMESPACE, required = false) Optional<String> namespace) {
return termService.getUnusedTermsInVocabulary(getVocabulary(getVocabularyUri(namespace, localName)));
}

@Operation(security = {@SecurityRequirement(name = "bearer-key")},
description = "Gets sub-terms of the term with the specified local name in the vocabulary with the specified identifier")
@ApiResponses({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import cz.cvut.kbss.termit.exception.AnnotationGenerationException;
import cz.cvut.kbss.termit.exception.AssetRemovalException;
import cz.cvut.kbss.termit.exception.AuthorizationException;
import cz.cvut.kbss.termit.exception.DisabledOperationException;
import cz.cvut.kbss.termit.exception.InvalidLanguageConstantException;
import cz.cvut.kbss.termit.exception.InvalidParameterException;
import cz.cvut.kbss.termit.exception.InvalidTermStateException;
Expand Down Expand Up @@ -159,13 +158,6 @@ public ResponseEntity<ErrorInfo> unsupportedAssetOperationException(HttpServletR
return new ResponseEntity<>(errorInfo(request, e), HttpStatus.CONFLICT);
}

@ExceptionHandler(DisabledOperationException.class)
public ResponseEntity<ErrorInfo> disabledOperationException(HttpServletRequest request,
DisabledOperationException e) {
logException(e);
return new ResponseEntity<>(errorInfo(request, e), HttpStatus.CONFLICT);
}

@ExceptionHandler(VocabularyImportException.class)
public ResponseEntity<ErrorInfo> vocabularyImportException(HttpServletRequest request,
VocabularyImportException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,16 +526,6 @@ private void checkForInvalidTerminalStateAssignment(Term term, URI state) {
}
}

/**
* Gets terms not occurring in any resources or other terms definitions.
*
* @return List of term identifiers
*/
public List<URI> getUnusedTermsInVocabulary(Vocabulary vocabulary) {
Objects.requireNonNull(vocabulary);
return repositoryService.getUnusedTermsInVocabulary(vocabulary);
}

@Override
public List<AbstractChangeRecord> getChanges(Term term) {
Objects.requireNonNull(term);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import cz.cvut.kbss.termit.dto.assignment.TermOccurrences;
import cz.cvut.kbss.termit.dto.listing.TermDto;
import cz.cvut.kbss.termit.exception.AssetRemovalException;
import cz.cvut.kbss.termit.exception.DisabledOperationException;
import cz.cvut.kbss.termit.exception.UnsupportedOperationException;
import cz.cvut.kbss.termit.model.Term;
import cz.cvut.kbss.termit.model.Vocabulary;
Expand Down Expand Up @@ -367,16 +366,6 @@ public List<TermOccurrence> getDefinitionallyRelatedOf(Term instance) {
return termOccurrenceDao.findAllDefinitionalOf(instance);
}

/**
* Gets all unused (unassigned to, neither occurring in a resource) terms in the given vocabulary
*
* @param vocabulary - IRI of the vocabulary in which the terms are
* @return List of definitionally related terms of the specified term
*/
public List<URI> getUnusedTermsInVocabulary(Vocabulary vocabulary) {
throw new DisabledOperationException("This method is disabled, not working correctly.");
}

/**
* Removes a term if it: - does not have children, - is not related to any resource, - is not related to any term
* occurrences.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import java.util.stream.Stream;

import static cz.cvut.kbss.termit.environment.Generator.generateTermWithId;
import static cz.cvut.kbss.termit.environment.Generator.generateVocabulary;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.lessThan;
Expand Down Expand Up @@ -340,16 +339,6 @@ void updateInvokesTextAnalysisOnUpdatedTerm() {
verify(textAnalysisService).analyzeTermDefinition(toUpdate, toUpdate.getVocabulary());
}

@Test
void getUnusedTermsReturnsUnusedTermsInVocabulary() {
final List<URI> terms = Collections.singletonList(Generator.generateUri());
final Vocabulary vocabulary = generateVocabulary();
when(termRepositoryService.getUnusedTermsInVocabulary(vocabulary)).thenReturn(terms);
final List<URI> result = sut.getUnusedTermsInVocabulary(vocabulary);
assertEquals(terms, result);
verify(termRepositoryService).getUnusedTermsInVocabulary(vocabulary);
}

@Test
void setTermDefinitionSourceSetsTermOnDefinitionAndPersistsIt() {
final Term term = Generator.generateTermWithId();
Expand Down
Loading