autocloseable implemented and app.java creted for the standalone version
This commit is contained in:
parent
75052f92a9
commit
c275b14df5
|
@ -0,0 +1,41 @@
|
|||
package org.gcube.vremanagement;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class App {
|
||||
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(App.class);
|
||||
|
||||
private static String[] listVOs= {"D4Research","gCubeApps","FARM","ParthenosVO","OpenAIRE"};
|
||||
private static String scopeIn = "/d4science.research-infrastructures.eu";
|
||||
private static int skipLines = 3;
|
||||
private static String InCsvFile="VREDecommisioned-240326.csv";
|
||||
//Used for GooGle APis;
|
||||
|
||||
|
||||
public static void main (String[] args)
|
||||
{
|
||||
|
||||
try(VREQueryService updaterCSV = new VREQueryService(InCsvFile,skipLines);){
|
||||
|
||||
String voIn="D4Research";
|
||||
String vreName="FoodborneOutbreak";
|
||||
updaterCSV.getVREInfoFromClient(scopeIn,voIn, vreName);
|
||||
|
||||
logger.debug("Updating VREs in a LOCAL CSV file");
|
||||
updaterCSV.updateCSVformCSVList(scopeIn);
|
||||
logger.debug("Update CSV done");
|
||||
|
||||
logger.debug("Getting missing VRE in a LOCAL CSV file");
|
||||
updaterCSV.missingVREinCSV(scopeIn, listVOs);
|
||||
logger.debug("Missing CSV done");
|
||||
|
||||
}catch (IOException e)
|
||||
{e.printStackTrace();};
|
||||
|
||||
}
|
||||
}
|
|
@ -43,7 +43,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class VREQueryService {
|
||||
public class VREQueryService implements AutoCloseable{
|
||||
|
||||
private File fileCSV;
|
||||
private File outFileCSV;
|
||||
|
@ -65,7 +65,7 @@ public class VREQueryService {
|
|||
|
||||
|
||||
|
||||
public VREQueryService(String _InCsvPath, int _skipLines)
|
||||
public VREQueryService (String _InCsvPath, int _skipLines)
|
||||
{
|
||||
try {
|
||||
String filePath = "src/test/resources";
|
||||
|
@ -95,19 +95,15 @@ public class VREQueryService {
|
|||
|
||||
public static VREQueryService getInstance() { return new VREQueryService();};
|
||||
|
||||
|
||||
protected void finalize() throws Throwable
|
||||
|
||||
public void close() throws IOException
|
||||
{
|
||||
try {
|
||||
csvReader.close();
|
||||
}finally {
|
||||
super.finalize();
|
||||
}
|
||||
if(csvReader !=null) { csvReader.close();}
|
||||
if(csvWriter !=null) { csvWriter.close();}
|
||||
if(csvMissWriter !=null) {csvMissWriter.close();}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public List<Report> getReportVREs(String _scopeVO)
|
||||
{
|
||||
try {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.vremanagement;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.InputMismatchException;
|
||||
import java.util.Scanner;
|
||||
|
||||
|
@ -30,41 +31,59 @@ class CsvUpdateTest {
|
|||
|
||||
@Test
|
||||
void QueryClientVREInfoTest(){
|
||||
VREQueryService updaterCSV = new VREQueryService(InCsvFile,skipLines);
|
||||
|
||||
try(VREQueryService updaterCSV = new VREQueryService(InCsvFile,skipLines)){
|
||||
String voIn="D4Research";
|
||||
String vreName="FoodborneOutbreak";
|
||||
logger.debug("Checking information about the VRE "+vreName+" in the VO:"+voIn);
|
||||
updaterCSV.getVREInfoFromClient(scopeIn,voIn, vreName);
|
||||
}catch(IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void UpdateLocalCSVTest() {
|
||||
VREQueryService updaterCSV = new VREQueryService(InCsvFile,skipLines);
|
||||
try(VREQueryService updaterCSV = new VREQueryService(InCsvFile,skipLines)){
|
||||
logger.debug("Updating VREs in a LOCAL CSV file");
|
||||
updaterCSV.updateCSVformCSVList(scopeIn);
|
||||
logger.debug("Update CSV done");
|
||||
}catch(IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void MissingLocalCSVTest(){
|
||||
VREQueryService updaterCSV = new VREQueryService(InCsvFile,skipLines);
|
||||
try(VREQueryService updaterCSV = new VREQueryService(InCsvFile,skipLines)){
|
||||
logger.debug("Getting missing VRE in a LOCAL CSV file");
|
||||
updaterCSV.missingVREinCSV(scopeIn, listVOs);
|
||||
logger.debug("Missing CSV done");
|
||||
}catch(IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Disabled
|
||||
@Test
|
||||
void UpdateEndTimeVRETest(){
|
||||
|
||||
try(VREQueryService updaterCSV = new VREQueryService(InCsvFile,skipLines)){
|
||||
String voTimeIn="D4Research";
|
||||
String vreTimeName="FoodborneOutbreak";
|
||||
int yearIn=2024;
|
||||
int monthIn=2; //Months start from zero
|
||||
int dayIn=21;
|
||||
VREQueryService updaterCSV = new VREQueryService(InCsvFile,skipLines);
|
||||
|
||||
updaterCSV.updateEndTimeVRE(scopeIn, voTimeIn, vreTimeName, yearIn,monthIn, dayIn);
|
||||
}catch(IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,7 +129,7 @@ class CsvUpdateTest {
|
|||
int choice=0;
|
||||
|
||||
do {
|
||||
VREQueryService updaterCSV = new VREQueryService(InCsvFile,skipLines);
|
||||
try (VREQueryService updaterCSV = new VREQueryService(InCsvFile,skipLines)){
|
||||
|
||||
logger.debug("Menu:");
|
||||
logger.debug("1. Update VREs in a LOCAL CSV file");
|
||||
|
@ -121,7 +140,7 @@ class CsvUpdateTest {
|
|||
logger.debug("6. Update Missing VRES in a Remore Google Sheet");
|
||||
logger.debug("7. Exit");
|
||||
logger.debug("Choice:");
|
||||
try {
|
||||
|
||||
choice = scanner.nextInt();
|
||||
scanner.nextLine();
|
||||
|
||||
|
|
Loading…
Reference in New Issue