argos/dmp-migration-tool/web/src/main/java/eu/old/eudat/publicapi/migration/MigrationController.java

136 lines
4.7 KiB
Java

package eu.old.eudat.publicapi.migration;
import com.fasterxml.jackson.core.JsonProcessingException;
import eu.old.eudat.migration.*;
import io.swagger.annotations.Api;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
@Api(tags = "Migration")
@RestController
@CrossOrigin
@RequestMapping(value = {"/api/public/migration"})
public class MigrationController {
private final DmpMigrationService dmpMigrationService;
private final DataRepositoryMigrationService dataRepositoryMigrationService;
private final ExternalDatasetMigrationService externalDatasetMigrationService;
private final FunderMigrationService funderMigrationService;
private final GrantMigrationService grantMigrationService;
private final ProjectMigrationService projectMigrationService;
private final RegistryMigrationService registryMigrationService;
private final ResearcherMigrationService researcherMigrationService;
private final ServiceMigrationService serviceMigrationService;
private final OrganizationMigrationService organizationMigrationService;
public MigrationController(
DmpMigrationService dmpMigrationService,
DataRepositoryMigrationService dataRepositoryMigrationService,
ExternalDatasetMigrationService externalDatasetMigrationService,
FunderMigrationService funderMigrationService,
GrantMigrationService grantMigrationService,
ProjectMigrationService projectMigrationService,
RegistryMigrationService registryMigrationService,
ResearcherMigrationService researcherMigrationService,
ServiceMigrationService serviceMigrationService,
OrganizationMigrationService organizationMigrationService
) {
this.dmpMigrationService = dmpMigrationService;
this.dataRepositoryMigrationService = dataRepositoryMigrationService;
this.externalDatasetMigrationService = externalDatasetMigrationService;
this.funderMigrationService = funderMigrationService;
this.grantMigrationService = grantMigrationService;
this.projectMigrationService = projectMigrationService;
this.registryMigrationService = registryMigrationService;
this.researcherMigrationService = researcherMigrationService;
this.serviceMigrationService = serviceMigrationService;
this.organizationMigrationService = organizationMigrationService;
}
@GetMapping("dmps/migrate")
@Transactional
public String migrateDmps() throws JsonProcessingException {
return this.dmpMigrationService.migrate();
}
@GetMapping("organizations")
@Transactional
public boolean migrateOrganizations() {
this.organizationMigrationService.migrate();
return true;
}
@GetMapping("references")
@Transactional
public boolean migrateReferences() {
this.dataRepositoryMigrationService.migrate();
this.externalDatasetMigrationService.migrate();
this.funderMigrationService.migrate();
this.grantMigrationService.migrate();
this.organizationMigrationService.migrate();
this.projectMigrationService.migrate();
this.registryMigrationService.migrate();
this.researcherMigrationService.migrate();
this.serviceMigrationService.migrate();
return true;
}
@GetMapping("dataRepositories")
@Transactional
public boolean migrateDataRepositories() {
this.dataRepositoryMigrationService.migrate();
return true;
}
@GetMapping("externalDatasets")
@Transactional
public boolean migrateExternalDatasets() {
this.externalDatasetMigrationService.migrate();
return true;
}
@GetMapping("funders")
@Transactional
public boolean migrateFunders() {
this.funderMigrationService.migrate();
return true;
}
@GetMapping("grants")
@Transactional
public boolean migrateGrants() {
this.grantMigrationService.migrate();
return true;
}
@GetMapping("projects")
@Transactional
public boolean migrateProjects() {
this.projectMigrationService.migrate();
return true;
}
@GetMapping("registries")
@Transactional
public boolean migrateRegistries() {
this.registryMigrationService.migrate();
return true;
}
@GetMapping("researchers")
@Transactional
public boolean migrateResearchers() {
this.researcherMigrationService.migrate();
return true;
}
@GetMapping("services")
@Transactional
public boolean migrateServices() {
this.serviceMigrationService.migrate();
return true;
}
}