Skip to content

Commit

Permalink
fix delleted term listing
Browse files Browse the repository at this point in the history
  • Loading branch information
geektortoise committed Oct 19, 2020
1 parent 2197d6b commit b309245
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions grails-app/domain/be/cytomine/ontology/Ontology.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Ontology extends CytomineDomain implements Serializable {
* @return Term list
*/
def terms() {
Term.findAllByOntology(this)
Term.findAllByOntologyAndDeletedIsNull(this)
}

/**
Expand All @@ -99,7 +99,7 @@ class Ontology extends CytomineDomain implements Serializable {
if(!parent) {
return []
} else {
return Term.executeQuery('SELECT term FROM Term as term WHERE ontology = :ontology AND term.id NOT IN (SELECT DISTINCT rel.term1.id FROM RelationTerm as rel, Term as t WHERE rel.relation = :relation AND t.ontology = :ontology AND t.id=rel.term1.id)',['ontology':this,'relation':parent])
return Term.executeQuery('SELECT term FROM Term as term WHERE ontology = :ontology AND deleted IS NULL AND term.id NOT IN (SELECT DISTINCT rel.term1.id FROM RelationTerm as rel, Term as t WHERE rel.relation = :relation AND t.ontology = :ontology AND t.id=rel.term1.id)',['ontology':this,'relation':parent])
}
}

Expand Down
27 changes: 27 additions & 0 deletions test/functional/be/cytomine/TermTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,19 @@ class TermTests {

void testListOntologyTermByOntologyWithCredential() {
Ontology ontology = BasicInstanceBuilder.getOntology()
def term = BasicInstanceBuilder.getTermNotExist(ontology, true)
def result = TermAPI.listByOntology(ontology.id, Infos.SUPERADMINLOGIN, Infos.SUPERADMINPASSWORD)
assert 200 == result.code
def json = JSON.parse(result.data)
assert json.collection instanceof JSONArray
int size = json.collection.size()
result = TermAPI.delete(term.id, Infos.SUPERADMINLOGIN, Infos.SUPERADMINPASSWORD)
assert 200 == result.code
result = TermAPI.listByOntology(ontology.id, Infos.SUPERADMINLOGIN, Infos.SUPERADMINPASSWORD)
assert 200 == result.code
json = JSON.parse(result.data)
assert json.collection instanceof JSONArray
assert size == json.collection.size()+1
}

void testListTermOntologyByOntologyWithOntologyNotExist() {
Expand All @@ -53,10 +62,19 @@ class TermTests {

void testListOntologyTermByProjectWithCredential() {
Project project = BasicInstanceBuilder.getProject()
def term = BasicInstanceBuilder.getTermNotExist(project.ontology, true)
def result = TermAPI.listByProject(project.id, Infos.SUPERADMINLOGIN, Infos.SUPERADMINPASSWORD)
assert 200 == result.code
def json = JSON.parse(result.data)
assert json.collection instanceof JSONArray
int size = json.collection.size()
result = TermAPI.delete(term.id, Infos.SUPERADMINLOGIN, Infos.SUPERADMINPASSWORD)
assert 200 == result.code
result = TermAPI.listByProject(project.id, Infos.SUPERADMINLOGIN, Infos.SUPERADMINPASSWORD)
assert 200 == result.code
json = JSON.parse(result.data)
assert json.collection instanceof JSONArray
assert size == json.collection.size()+1
}

void testListTermOntologyByProjectWithProjectNotExist() {
Expand All @@ -66,10 +84,19 @@ class TermTests {


void testListTermWithCredential() {
def term = BasicInstanceBuilder.getTermNotExist(BasicInstanceBuilder.getOntology(), true)
def result = TermAPI.list(Infos.SUPERADMINLOGIN, Infos.SUPERADMINPASSWORD)
assert 200 == result.code
def json = JSON.parse(result.data)
assert json.collection instanceof JSONArray
int size = json.collection.size()
result = TermAPI.delete(term.id, Infos.SUPERADMINLOGIN, Infos.SUPERADMINPASSWORD)
assert 200 == result.code
result = TermAPI.list(Infos.SUPERADMINLOGIN, Infos.SUPERADMINPASSWORD)
assert 200 == result.code
json = JSON.parse(result.data)
assert json.collection instanceof JSONArray
assert size == json.collection.size()+1
}

void testShowTermWithCredential() {
Expand Down

0 comments on commit b309245

Please sign in to comment.