ref 18964: Create a Generic Resource to record Dismissed VREs
https://support.d4science.org/issues/18964 Create a library to support the resource access
This commit is contained in:
parent
1a131e5d6b
commit
cef8050d0c
|
@ -10,7 +10,7 @@ import java.util.LinkedHashMap;
|
|||
*/
|
||||
public class Gateway implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2238683459962419017L;
|
||||
private static final long serialVersionUID = -7369449849642474360L;
|
||||
private String scope;
|
||||
private String name;
|
||||
private String description;
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.LinkedHashMap;
|
|||
*/
|
||||
public class VO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2238683459962419017L;
|
||||
private static final long serialVersionUID = 3227628150807395623L;
|
||||
private String scope;
|
||||
private String name;
|
||||
private String description;
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.ArrayList;
|
|||
*/
|
||||
public class VRE implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2238683459962419017L;
|
||||
private static final long serialVersionUID = 8250701755399181125L;
|
||||
private String scope;
|
||||
private String name;
|
||||
private String description;
|
||||
|
|
|
@ -7,6 +7,8 @@ import java.io.File;
|
|||
import java.io.StringWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
|
@ -81,17 +83,161 @@ public class DetachedREsTest extends TestCase {
|
|||
blueBridgeProject.setStartDate(new GregorianCalendar(2018, GregorianCalendar.FEBRUARY, 10).getTime());
|
||||
blueBridgeProject.setEndDate(new GregorianCalendar(2020, GregorianCalendar.JANUARY, 1).getTime());
|
||||
blueBridgeProject.setCatalogUrl("http://service.d4science.org/catalogurl");
|
||||
blueBridgeProject
|
||||
.setManagers(new ArrayList<String>(Arrays.asList("Leonardo Candela", "Pasquale Pagano")));
|
||||
|
||||
LinkedHashMap<String,VREJAXB> vres = new LinkedHashMap<>();
|
||||
vres.put("/d4science.research-infrastructures.eu/gcubeApps/BlueBridgeProject",blueBridgeProject);
|
||||
LinkedHashMap<String, VREJAXB> vres = new LinkedHashMap<>();
|
||||
vres.put("/d4science.research-infrastructures.eu/gcubeApps/BlueBridgeProject", blueBridgeProject);
|
||||
gCubeApps.setVres(vres);
|
||||
|
||||
LinkedHashMap<String,VOJAXB> vos = new LinkedHashMap<>();
|
||||
vos.put("/d4science.research-infrastructures.eu/gCubeApps",gCubeApps);
|
||||
LinkedHashMap<String, VOJAXB> vos = new LinkedHashMap<>();
|
||||
vos.put("/d4science.research-infrastructures.eu/gCubeApps", gCubeApps);
|
||||
blueBridgeGateway.setVos(vos);
|
||||
|
||||
LinkedHashMap<String,GatewayJAXB> gateways = new LinkedHashMap<>();
|
||||
gateways.put("-1",blueBridgeGateway);
|
||||
LinkedHashMap<String, GatewayJAXB> gateways = new LinkedHashMap<>();
|
||||
gateways.put("-1", blueBridgeGateway);
|
||||
|
||||
DetachedREsJAXB detachedREs = new DetachedREsJAXB();
|
||||
detachedREs.setEnabled(true);
|
||||
detachedREs.setGateways(gateways);
|
||||
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance(DetachedREsJAXB.class);
|
||||
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
|
||||
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
|
||||
|
||||
// Print XML String to Console
|
||||
StringWriter sw = new StringWriter();
|
||||
|
||||
// Write XML to StringWriter
|
||||
jaxbMarshaller.marshal(detachedREs, sw);
|
||||
|
||||
// Verify XML Content
|
||||
String xmlContent = sw.toString();
|
||||
logger.debug(xmlContent);
|
||||
|
||||
logger.info("Check Unmarshalling");
|
||||
Path path = Files.createTempFile("DetachedREsData", ".xml");
|
||||
File file = path.toFile();
|
||||
jaxbMarshaller.marshal(detachedREs, file);
|
||||
|
||||
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
|
||||
DetachedREsJAXB configUnmarshalled = (DetachedREsJAXB) jaxbUnmarshaller.unmarshal(file);
|
||||
logger.debug("DetachedREs unmarshallded: " + configUnmarshalled);
|
||||
file.delete();
|
||||
logger.info("Success!");
|
||||
assertTrue(true);
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getLocalizedMessage(), e);
|
||||
assertTrue("Error in DetachedREs Marshal!", false);
|
||||
}
|
||||
} else {
|
||||
logger.debug("Test Disabled");
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDetachedREsMarshallerProd() {
|
||||
if (Constants.TEST_ENABLE) {
|
||||
logger.debug("Test Enabled");
|
||||
|
||||
try {
|
||||
logger.info("Check Marshalling");
|
||||
|
||||
GatewayJAXB blueBridgeGateway = new GatewayJAXB();
|
||||
blueBridgeGateway.setScope("-1");
|
||||
blueBridgeGateway.setName("BlueBridge Gateway");
|
||||
|
||||
// gCubeApps
|
||||
final String GCUBEAPPS = "gCubeApps";
|
||||
VOJAXB gCubeApps = new VOJAXB();
|
||||
gCubeApps.setScope("/d4science.research-infrastructures.eu/" + GCUBEAPPS);
|
||||
gCubeApps.setName(GCUBEAPPS);
|
||||
|
||||
LinkedHashMap<String, VREJAXB> gCubeAppsVREs = new LinkedHashMap<>();
|
||||
|
||||
String[] gCubeAppsVREsArray = { "AquacultureTrainingLab", "BlueBRIDGE-PSC", "BlueBridgeProject",
|
||||
"CES_TCRE", "ICES_DALSA", "ICES_DASC", "ICES_FIACO", "ICES_StockAssessmentAdvanced",
|
||||
"ICES_TCSSM", "iSearch", "SIASPA" };
|
||||
|
||||
for (String vre : gCubeAppsVREsArray) {
|
||||
VREJAXB gCubeAppsVREJAXB = new VREJAXB();
|
||||
gCubeAppsVREJAXB.setScope("/d4science.research-infrastructures.eu/" + GCUBEAPPS + "/" + vre);
|
||||
gCubeAppsVREJAXB.setName(new String(vre).replace("_", ""));
|
||||
gCubeAppsVREJAXB.setStartDate(new GregorianCalendar(2018, GregorianCalendar.JANUARY, 1).getTime());
|
||||
gCubeAppsVREJAXB.setEndDate(new GregorianCalendar(2020, GregorianCalendar.MARCH, 3).getTime());
|
||||
gCubeAppsVREJAXB.setCatalogUrl("http://data.d4science.org/ctlg/"+vre);
|
||||
gCubeAppsVREJAXB
|
||||
.setManagers(new ArrayList<String>(Arrays.asList("Leonardo Candela", "Pasquale Pagano")));
|
||||
gCubeAppsVREs.put("/d4science.research-infrastructures.eu/" + GCUBEAPPS + "/" + vre,
|
||||
gCubeAppsVREJAXB);
|
||||
}
|
||||
gCubeApps.setVres(gCubeAppsVREs);
|
||||
|
||||
// FARM
|
||||
final String FARM = "FARM";
|
||||
VOJAXB farm = new VOJAXB();
|
||||
farm.setScope("/d4science.research-infrastructures.eu/" + FARM);
|
||||
farm.setName(FARM);
|
||||
|
||||
LinkedHashMap<String, VREJAXB> farmVREs = new LinkedHashMap<>();
|
||||
|
||||
String[] farmVREsArray = { "AlieiaVRE", "Aquabiotech", "ARDAG_Aquaculture", "EllinikaPsariaVRE",
|
||||
"ForkysVRE", "GALAXIDI", "iLKNAK_Aquaculture", "KIMAGRO_Fishfarming", "MARKELLOS_Aquaculture",
|
||||
"NHREUS_Aquaculture", "STRATOS_AQUACULTURES", "SustainableBlueEconomy", "TBTI_VRE" };
|
||||
|
||||
for (String vre : farmVREsArray) {
|
||||
VREJAXB farmVREJAXB = new VREJAXB();
|
||||
farmVREJAXB.setScope("/d4science.research-infrastructures.eu/" + FARM + "/" + vre);
|
||||
farmVREJAXB.setName(new String(vre).replace("_", ""));
|
||||
farmVREJAXB.setStartDate(new GregorianCalendar(2018, GregorianCalendar.JANUARY, 1).getTime());
|
||||
farmVREJAXB.setEndDate(new GregorianCalendar(2020, GregorianCalendar.MARCH, 3).getTime());
|
||||
farmVREJAXB.setCatalogUrl("http://data.d4science.org/ctlg/"+vre);
|
||||
farmVREJAXB
|
||||
.setManagers(new ArrayList<String>(Arrays.asList("Leonardo Candela", "Pasquale Pagano")));
|
||||
farmVREs.put("/d4science.research-infrastructures.eu/" + FARM + "/" + vre, farmVREJAXB);
|
||||
}
|
||||
farm.setVres(farmVREs);
|
||||
|
||||
// D4Research
|
||||
final String D4RESEARCH = "D4Research";
|
||||
VOJAXB d4Research = new VOJAXB();
|
||||
d4Research.setScope("/d4science.research-infrastructures.eu/" + D4RESEARCH);
|
||||
|
||||
d4Research.setName(D4RESEARCH);
|
||||
|
||||
LinkedHashMap<String, VREJAXB> d4ResearchVREs = new LinkedHashMap<>();
|
||||
|
||||
String[] d4ResearchVREsArray = { "Blue-Datathon", "BlueBRIDGEReview", "DRuMFISH",
|
||||
"ICES_AbundanceEstimationFromAcoustic", "ICES_BNetworkAnalysis", "ICES_FIACO2017",
|
||||
"ICES_IntroStockAssessment", "ICES_IntroToREnv", "ICES_LogbookData", "ICES_MSE", "ICES_MSY",
|
||||
"InfraTraining" };
|
||||
|
||||
for (String vre : d4ResearchVREsArray) {
|
||||
VREJAXB d4ResearchVREJAXB = new VREJAXB();
|
||||
d4ResearchVREJAXB.setScope("/d4science.research-infrastructures.eu/" + D4RESEARCH + "/" + vre);
|
||||
d4ResearchVREJAXB.setName(new String(vre).replace("_", ""));
|
||||
d4ResearchVREJAXB.setStartDate(new GregorianCalendar(2018, GregorianCalendar.JANUARY, 1).getTime());
|
||||
d4ResearchVREJAXB.setEndDate(new GregorianCalendar(2020, GregorianCalendar.MARCH, 3).getTime());
|
||||
d4ResearchVREJAXB.setCatalogUrl("http://data.d4science.org/ctlg/"+vre);
|
||||
d4ResearchVREJAXB
|
||||
.setManagers(new ArrayList<String>(Arrays.asList("Leonardo Candela", "Pasquale Pagano")));
|
||||
d4ResearchVREs.put("/d4science.research-infrastructures.eu/" + D4RESEARCH + "/" + vre,
|
||||
d4ResearchVREJAXB);
|
||||
}
|
||||
d4Research.setVres(d4ResearchVREs);
|
||||
|
||||
// Gateway
|
||||
LinkedHashMap<String, VOJAXB> vos = new LinkedHashMap<>();
|
||||
vos.put("/d4science.research-infrastructures.eu/" + D4RESEARCH, d4Research);
|
||||
vos.put("/d4science.research-infrastructures.eu/" + FARM, farm);
|
||||
vos.put("/d4science.research-infrastructures.eu/" + GCUBEAPPS, gCubeApps);
|
||||
|
||||
blueBridgeGateway.setVos(vos);
|
||||
|
||||
LinkedHashMap<String, GatewayJAXB> gateways = new LinkedHashMap<>();
|
||||
gateways.put("-1", blueBridgeGateway);
|
||||
|
||||
DetachedREsJAXB detachedREs = new DetachedREsJAXB();
|
||||
detachedREs.setEnabled(true);
|
||||
|
|
Loading…
Reference in New Issue