Skip to content

Commit

Permalink
chore: remove software code (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
bathienle authored Nov 22, 2024
1 parent 3429ea0 commit 0e2f260
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class RestProjectController extends RestCytomineController {
private final CurrentUserService currentUserService;

private final CurrentRoleService currentRoleService;

private final OntologyRepository ontologyRepository;
private final SecUserService secUserService;

Expand Down Expand Up @@ -138,7 +138,6 @@ public ResponseEntity<String> delete(@PathVariable String id, @RequestParam(requ
public ResponseEntity<String> lastAction(
@PathVariable Long id,
@PathVariable Long max

) {
log.debug("REST request to list last project actions");
Project project = projectRepository.findById(id)
Expand All @@ -153,24 +152,10 @@ public ResponseEntity<String> listLastOpened(
@RequestParam(required = false, defaultValue = "0") Long max
) {
log.debug("REST request to list last opened");

return responseSuccess(projectService.listLastOpened((User) currentUserService.getCurrentUser(), max));
}

// TODO:
// /**
// * List all project available for this user, that can use a software
// */
// @GetMapping("/software/{id}/project.json")
// public ResponseEntity<String> listBySoftware(
// @PathVariable Long id
// ) {
// log.debug("REST request to list last project actions");
// Project project = projectRepository.findById(id)
// .orElseThrow(() -> new ObjectNotFoundException("Project", id));
// return responseSuccess(projectService.listBySoftware(project));
// }

/**
* List all project available for this user, that use a ontology
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,6 @@ public ResponseEntity<String> statAnnotationActionsEvolution(
return responseSuccess(statsService.statAnnotationActionsEvolution(project, daysRange, startDate, endDate, accumulate, type));
}




@GetMapping("/stats/all.json")
public ResponseEntity<String> allGlobalStats() {
securityACLService.checkAdmin(currentUserService.getCurrentUser());
Expand All @@ -347,11 +344,7 @@ public ResponseEntity<String> allGlobalStats() {
result.put("jobAnnotations", statsService.total(AlgoAnnotation.class));
result.put("terms", statsService.total(Term.class));
result.put("ontologies", statsService.total(Ontology.class));
//TODO
// result.put("softwares", statsService.total(Software.class));
// result.put("jobs", statsService.total(Job.class));

return responseSuccess(result);
}

}
8 changes: 0 additions & 8 deletions src/main/java/be/cytomine/service/project/ProjectService.java
Original file line number Diff line number Diff line change
Expand Up @@ -570,20 +570,13 @@ public List<JsonObject> findCommandHistory(List<Project> projects, Long user, Lo
return data;
}



public List<Project> listByOntology(Ontology ontology) {
if (currentRoleService.isAdminByNow(currentUserService.getCurrentUser())) {
return projectRepository.findAllByOntology(ontology);
}
return projectRepository.findAllProjectForUserByOntology(currentUserService.getCurrentUsername(),ontology);
}

// List<Software> listBySoftware(Software software) {
// // TODO:
// throw new RuntimeException("TODO");
// }

public List<CommandHistory> lastAction(Project project, int max) {
securityACLService.check(project, READ);
return commandHistoryRepository.findAllByProject(project, PageRequest.of(0, max, Sort.by("created").descending()));
Expand Down Expand Up @@ -1014,7 +1007,6 @@ public void deleteDependencies(CytomineDomain domain, Transaction transaction, T
deleteDependentImageInstance((Project) domain, transaction, task);
deleteDependentRepresentativeUser((Project) domain, transaction, task);
deleteDependentMetadata(domain, transaction, task);
//TODO: only that? software project? ...
}

private void deleteDependentRepresentativeUser(Project domain, Transaction transaction, Task task) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,64 +550,6 @@ public void list_user_annotation_with_pagination() throws Exception {
.andReturn();
}




@Disabled("Disabled until Software package is up!")
@Test
void list_user_annotation_with_suggested_term() {
Assertions.fail("todo after job/algoannot/...");

//
// //create annotation
// AnnotationTerm annotationTerm = BasicInstanceBuilder.getAnnotationTerm()
// annotationTerm.term = BasicInstanceBuilder.getTerm()
// BasicInstanceBuilder.saveDomain(annotationTerm)
// UserAnnotation annotation = annotationTerm.userAnnotation
//
// //create job
// UserJob userJob = BasicInstanceBuilder.getUserJob(annotation.project)
// Job job = userJob.job
//
// //create suggest with different term
// AlgoAnnotationTerm suggest = BasicInstanceBuilder.getAlgoAnnotationTerm(job,annotation,userJob)
// suggest.term = BasicInstanceBuilder.getAnotherBasicTerm()
// BasicInstanceBuilder.saveDomain(suggest)
//
// println "project=${annotation.project.id}"
// println "a.term=${annotation.terms().collect{it.id}.join(",")}"
// println "at.term=${suggest.term.id}"
// println "job=${job.id}"
// println "user=${UserJob.findByJob(job).id}"
//
// def result = AnnotationDomainAPI.listByProjectAndTermWithSuggest(annotation.project.id, annotationTerm.term.id, suggest.term.id, UserJob.findByJob(job).id,Infos.SUPERADMINLOGIN, Infos.SUPERADMINPASSWORD)
// assert 200 == result.code
// def json = JSON.parse(result.data)
// assert json.collection instanceof JSONArray
// assert AnnotationDomainAPI.containsInJSONList(annotation.id,json)
//
// //create annotation
// AnnotationTerm annotationTerm2 = BasicInstanceBuilder.getAnnotationTerm()
// annotationTerm2.userAnnotation = BasicInstanceBuilder.getUserAnnotationNotExist(annotationTerm2.container(),true)
// annotationTerm2.term = BasicInstanceBuilder.getTerm()
// BasicInstanceBuilder.saveDomain(annotationTerm2)
// UserAnnotation annotation2 = annotationTerm2.userAnnotation
//
// //create suggest with same term
// AlgoAnnotationTerm suggest2 = BasicInstanceBuilder.getAlgoAnnotationTerm(job,annotation2,userJob)
// suggest2.term = BasicInstanceBuilder.getTerm()
// BasicInstanceBuilder.saveDomain(suggest)
//
// //We are looking for a different term => annotation shouldn't be in result
// result = AnnotationDomainAPI.listByProjectAndTermWithSuggest(annotation2.project.id, annotationTerm2.term.id, suggest.term.id, job.id,Infos.SUPERADMINLOGIN, Infos.SUPERADMINPASSWORD)
// assert 200 == result.code
// json = JSON.parse(result.data)
// assert json.collection instanceof JSONArray
// assert !AnnotationDomainAPI.containsInJSONList(annotation2.id,json)
}



@Test
@Transactional
public void list_user_annotation_without_term() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -891,35 +891,6 @@ public void list_by_ontology_that_does_not_exist() throws Exception {

}


@Disabled("implement when software package is done")
@Test
@Transactional
public void list_by_software() throws Exception {
// Project project = builder.given_a_project();
// builder.addUserToProject(project, builder.given_superadmin().getUsername());
//
//
// restProjectControllerMockMvc.perform(get("/api/software/{id}/project.json", project.getsoftware().getId()))
// .andDo(print())
// .andExpect(status().isOk())
// .andExpect(jsonPath("$.collection[0].id").value(project.getId()));

}

@Disabled("implement when software package is done")
@Test
@Transactional
public void list_by_software_that_does_not_exist() throws Exception {
// Project project = builder.given_a_project();
// builder.addUserToProject(project, builder.given_superadmin().getUsername());
// restProjectControllerMockMvc.perform(get("/api/software/{id}/project.json", 0L))
// .andDo(print())
// .andExpect(status().isNotFound());

}


@Test
@Transactional
public void list_by_user() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,13 +559,6 @@ public void classic_project_with_image_as_project_manager(){
expectOK(() -> imageInstanceService.delete(image, null, null, false));
}

@Disabled("wait for software package")
@Test
@WithMockUser(username = USER_ACL_ADMIN)
public void classic_project_with_job_data(){
Assertions.fail("todo");
}

@Test
@WithMockUser(username = USER_ACL_ADMIN)
public void restricted_project_scenario_for_admin(){
Expand Down Expand Up @@ -914,13 +907,6 @@ public void restricted_project_with_image_as_project_manager(){
expectOK(() -> imageInstanceService.delete(image, null, null, false));
}

@Disabled("wait for software package")
@Test
@WithMockUser(username = SUPERADMIN)
public void testRestrictedProjectWithJobData() {
Assertions.fail("todo");
}

@Test
@WithMockUser(username = USER_ACL_ADMIN)
public void readonly_project_scenario_for_admin(){
Expand Down Expand Up @@ -1274,14 +1260,6 @@ public void read_only_project_with_image_as_project_manager(){
expectOK(() -> imageInstanceService.delete(image, null, null, false));
}

@Disabled("wait for software package")
@Test
@WithMockUser(username = SUPERADMIN)
void testReadOnlyProjectWithJobData() {
Assertions.fail("todo");

}

private Map<String, Object> initProjectDataSet(Project project){

Map<String, Object> result = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,12 +679,6 @@ void find_project_creator() {
assertThat(secUserService.findCreator(projectWhereUserIsManager)).contains(user);
}

@Disabled("software package")
@Test
void list_project_users_show_userjob() {

}

@Test
void list_ontology_users() {
User user = builder.given_superadmin();
Expand Down Expand Up @@ -723,11 +717,6 @@ void list_all_project_users() {
.contains(user);
}

@Disabled("software package")
@Test
void list_all_project_users_with_user_job() {
}

@Test
void lock_user() {
User user = builder.given_a_user();
Expand Down Expand Up @@ -1203,14 +1192,6 @@ void delete_user_create_with_service_with_dependency() {
assertThat(commandResponse.getStatus()).isEqualTo(200);
}



@Disabled("software package")
@Test
void delete_user_job_with_dependency() {

}

@Test
void add_user_to_project() {
User user = builder.given_a_user();
Expand Down

0 comments on commit 0e2f260

Please sign in to comment.