2017-10-30 14:31:46 +01:00
|
|
|
package org.gcube.informationsystem.resourceregistry;
|
|
|
|
|
2019-02-05 15:25:45 +01:00
|
|
|
import java.io.IOException;
|
2019-01-17 15:37:25 +01:00
|
|
|
|
2019-10-25 17:45:16 +02:00
|
|
|
import org.gcube.informationsystem.context.impl.entities.ContextImpl;
|
|
|
|
import org.gcube.informationsystem.context.reference.entities.Context;
|
2019-02-05 15:25:45 +01:00
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
2019-10-18 11:57:14 +02:00
|
|
|
import org.gcube.informationsystem.resourceregistry.dbinitialization.DatabaseEnvironment;
|
2019-11-05 18:39:35 +01:00
|
|
|
import org.gcube.informationsystem.resourceregistry.instances.context.entities.ContextManagement;
|
2019-02-06 10:14:05 +01:00
|
|
|
import org.gcube.informationsystem.utils.ISMapper;
|
|
|
|
import org.gcube.informationsystem.utils.discovery.ISMDiscovery;
|
2017-10-30 14:31:46 +01:00
|
|
|
import org.junit.Test;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
2019-10-18 11:57:14 +02:00
|
|
|
public class DataBaseCreator extends ContextTest {
|
2017-12-18 12:25:19 +01:00
|
|
|
|
2017-10-30 14:31:46 +01:00
|
|
|
private static Logger logger = LoggerFactory.getLogger(ISMDiscovery.class);
|
|
|
|
|
|
|
|
@Test
|
2017-12-18 12:25:19 +01:00
|
|
|
public void createDatabase() throws Exception {
|
2019-10-30 09:58:18 +01:00
|
|
|
logger.debug("Goint to create DB");
|
2019-10-18 11:57:14 +02:00
|
|
|
String db = DatabaseEnvironment.DB_URI;
|
2019-10-30 09:58:18 +01:00
|
|
|
logger.debug("{} created", db);
|
2017-10-30 14:31:46 +01:00
|
|
|
}
|
|
|
|
|
2019-02-05 15:25:45 +01:00
|
|
|
|
2019-10-30 09:58:18 +01:00
|
|
|
|
2019-02-05 15:25:45 +01:00
|
|
|
protected Context create(Context context) throws ResourceRegistryException, IOException {
|
|
|
|
ContextManagement contextManagement = new ContextManagement();
|
2019-02-13 12:25:56 +01:00
|
|
|
contextManagement.setJson(ISMapper.marshal(context));
|
2019-02-05 15:25:45 +01:00
|
|
|
String contextString = contextManagement.create();
|
|
|
|
logger.info("Created {}", contextString);
|
|
|
|
Context c = ISMapper.unmarshal(Context.class, contextString);
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
// @Test
|
|
|
|
public void createDevContext() throws Exception {
|
|
|
|
Context gcube = new ContextImpl("gcube");
|
|
|
|
gcube = create(gcube);
|
|
|
|
|
|
|
|
Context devsec = new ContextImpl("devsec");
|
|
|
|
devsec.setParent(gcube);
|
|
|
|
devsec = create(devsec);
|
|
|
|
|
|
|
|
Context devVRE = new ContextImpl("devVRE");
|
|
|
|
devVRE.setParent(devsec);
|
|
|
|
devVRE = create(devVRE);
|
|
|
|
|
|
|
|
Context devNext = new ContextImpl("devNext");
|
|
|
|
devNext.setParent(gcube);
|
|
|
|
devNext = create(devNext);
|
|
|
|
|
|
|
|
Context nextNext = new ContextImpl("NextNext");
|
|
|
|
nextNext.setParent(devNext);
|
|
|
|
nextNext = create(nextNext);
|
|
|
|
|
2019-02-15 18:13:13 +01:00
|
|
|
/*
|
2019-02-05 15:25:45 +01:00
|
|
|
Context preprod = new ContextImpl("preprod");
|
|
|
|
preprod.setParent(gcube);
|
|
|
|
preprod = create(preprod);
|
|
|
|
|
|
|
|
Context preVRE = new ContextImpl("preVRE");
|
|
|
|
preVRE.setParent(preprod);
|
|
|
|
preVRE = create(preVRE);
|
2019-02-15 18:13:13 +01:00
|
|
|
*/
|
2019-02-05 15:25:45 +01:00
|
|
|
}
|
|
|
|
|
2017-10-30 14:31:46 +01:00
|
|
|
}
|