git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vre-management/VREModeler@9685 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
f70d0d974f
commit
49a5ef53b6
|
@ -26,11 +26,13 @@ import org.gcube.common.core.informationsystem.client.ISClient;
|
||||||
import org.gcube.common.core.informationsystem.client.queries.GCUBECSQuery;
|
import org.gcube.common.core.informationsystem.client.queries.GCUBECSQuery;
|
||||||
import org.gcube.common.core.informationsystem.client.queries.GCUBECollectionQuery;
|
import org.gcube.common.core.informationsystem.client.queries.GCUBECollectionQuery;
|
||||||
import org.gcube.common.core.informationsystem.client.queries.GCUBEGHNQuery;
|
import org.gcube.common.core.informationsystem.client.queries.GCUBEGHNQuery;
|
||||||
|
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericResourceQuery;
|
||||||
import org.gcube.common.core.informationsystem.client.queries.GCUBEMCollectionQuery;
|
import org.gcube.common.core.informationsystem.client.queries.GCUBEMCollectionQuery;
|
||||||
import org.gcube.common.core.informationsystem.client.queries.GCUBERIQuery;
|
import org.gcube.common.core.informationsystem.client.queries.GCUBERIQuery;
|
||||||
import org.gcube.common.core.informationsystem.client.queries.GCUBEServiceQuery;
|
import org.gcube.common.core.informationsystem.client.queries.GCUBEServiceQuery;
|
||||||
import org.gcube.common.core.resources.GCUBECS;
|
import org.gcube.common.core.resources.GCUBECS;
|
||||||
import org.gcube.common.core.resources.GCUBECollection;
|
import org.gcube.common.core.resources.GCUBECollection;
|
||||||
|
import org.gcube.common.core.resources.GCUBEGenericResource;
|
||||||
import org.gcube.common.core.resources.GCUBEHostingNode;
|
import org.gcube.common.core.resources.GCUBEHostingNode;
|
||||||
import org.gcube.common.core.resources.GCUBEMCollection;
|
import org.gcube.common.core.resources.GCUBEMCollection;
|
||||||
import org.gcube.common.core.resources.GCUBERunningInstance;
|
import org.gcube.common.core.resources.GCUBERunningInstance;
|
||||||
|
@ -76,11 +78,13 @@ public class IStoDBUtil {
|
||||||
logger.debug("initialization: collection");
|
logger.debug("initialization: collection");
|
||||||
insertMetadataCollection(scope);
|
insertMetadataCollection(scope);
|
||||||
logger.debug("initialization: metadata");
|
logger.debug("initialization: metadata");
|
||||||
insertCS(scope);
|
//insertCS(scope);
|
||||||
logger.debug("initialization: CS");
|
//logger.debug("initialization: CS");
|
||||||
//insertServices(scope);
|
//insertServices(scope);
|
||||||
insertGHN(scope);
|
insertGHN(scope);
|
||||||
logger.debug("initialization: GHN");
|
logger.debug("initialization: GHN");
|
||||||
|
insertNeededResources(scope);
|
||||||
|
logger.debug("initialization: Needed Resources");
|
||||||
logger.info("Database Initialized!!");
|
logger.info("Database Initialized!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,12 +108,42 @@ public class IStoDBUtil {
|
||||||
DBInterface.deleteAll("runninginstance");
|
DBInterface.deleteAll("runninginstance");
|
||||||
DBInterface.deleteAll("ghnrelatedri");
|
DBInterface.deleteAll("ghnrelatedri");
|
||||||
DBInterface.deleteAll("cs");
|
DBInterface.deleteAll("cs");
|
||||||
|
DBInterface.deleteAll("NEEDEDRESOURCES");
|
||||||
}catch (SQLException e){logger.error("error cleaning sqlDB");
|
}catch (SQLException e){logger.error("error cleaning sqlDB");
|
||||||
e.printStackTrace(); throw new GCUBEFault(e); }
|
e.printStackTrace(); throw new GCUBEFault(e); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void insertNeededResources(GCUBEScope scope) throws GCUBEFault{
|
||||||
|
List<GCUBEGenericResource> genericResourcesList= null;
|
||||||
|
try{
|
||||||
|
if (queryClient==null) queryClient= GHNContext.getImplementation(ISClient.class);
|
||||||
|
GCUBEGenericResourceQuery query= queryClient.getQuery(GCUBEGenericResourceQuery.class);
|
||||||
|
query.addGenericCondition("$result/Profile/SecondType/string() eq 'UserProfile' or $result/Profile/SecondType/string() eq 'Schemas Searchable Fields' or $result/Profile/SecondType/string() eq 'MetadataXSLT' or $result/Profile/SecondType/string() eq 'PresentationXSLT'");
|
||||||
|
genericResourcesList= queryClient.execute(query, scope);
|
||||||
|
}catch(Exception e ){logger.error("Error queryng IS"); throw new GCUBEFault(e); }
|
||||||
|
|
||||||
|
|
||||||
|
//NEEDEDRESOURCES(ID, TYPE)
|
||||||
|
List<List<String>> values = new ArrayList<List<String>>(genericResourcesList.size());
|
||||||
|
List<String> row;
|
||||||
|
for (GCUBEGenericResource gen :genericResourcesList){
|
||||||
|
row= new ArrayList<String>(2);
|
||||||
|
row.add(gen.getID());
|
||||||
|
row.add(gen.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
|
DBInterface.connect();
|
||||||
|
DBInterface.InsertInto("NEEDEDRESOURCES", values);
|
||||||
|
}catch (SQLException e){
|
||||||
|
logger.error("VDLModel: DB error "+e.getMessage());
|
||||||
|
throw new GCUBEFault(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void insertCollection(GCUBEScope scope) throws GCUBEFault {
|
private static void insertCollection(GCUBEScope scope) throws GCUBEFault {
|
||||||
|
|
||||||
List<GCUBECollection> collectionList= null;
|
List<GCUBECollection> collectionList= null;
|
||||||
|
|
|
@ -295,6 +295,21 @@ public class DeployVRE extends Thread{
|
||||||
genResItem.setType(GCUBEGenericResource.TYPE);
|
genResItem.setType(GCUBEGenericResource.TYPE);
|
||||||
resItemList.add(genResItem);
|
resItemList.add(genResItem);
|
||||||
|
|
||||||
|
//adding the other needed resources
|
||||||
|
try{
|
||||||
|
ResourceItem resItem;
|
||||||
|
ResultSet neededRes =DBInterface.queryDB("select n.id, n.type from NEEDEDRESOURCES AS n;");
|
||||||
|
while (neededRes.next()){
|
||||||
|
resItem= new ResourceItem();
|
||||||
|
resItem.setID(neededRes.getString(1));
|
||||||
|
resItem.setType(neededRes.getString(2));
|
||||||
|
resItemList.add(resItem);
|
||||||
|
}
|
||||||
|
}catch(SQLException sqle){
|
||||||
|
sqle.printStackTrace();
|
||||||
|
logger.error("Error contacting HSQLDB "+sqle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
rl.setResource(resItemList.toArray(new ResourceItem[0]));
|
rl.setResource(resItemList.toArray(new ResourceItem[0]));
|
||||||
arp.setResources(rl);
|
arp.setResources(rl);
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.gcube.common.core.informationsystem.client.ISClient;
|
||||||
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericResourceQuery;
|
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericResourceQuery;
|
||||||
import org.gcube.common.core.informationsystem.publisher.ISPublisher;
|
import org.gcube.common.core.informationsystem.publisher.ISPublisher;
|
||||||
import org.gcube.common.core.resources.GCUBEGenericResource;
|
import org.gcube.common.core.resources.GCUBEGenericResource;
|
||||||
|
import org.gcube.common.core.scope.GCUBEScope;
|
||||||
import org.gcube.vremanagement.vremodeler.db.DBInterface;
|
import org.gcube.vremanagement.vremodeler.db.DBInterface;
|
||||||
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
|
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
@ -54,7 +55,7 @@ public class CollectionResourceCreation {
|
||||||
res.load(new StringReader(this.transformCollectionResource()));
|
res.load(new StringReader(this.transformCollectionResource()));
|
||||||
ISPublisher pub= GHNContext.getImplementation(ISPublisher.class);
|
ISPublisher pub= GHNContext.getImplementation(ISPublisher.class);
|
||||||
res.setID("");
|
res.setID("");
|
||||||
res.load(new StringReader(pub.registerGCUBEResource(res, ServiceContext.getContext().getScope(), ServiceContext.getContext())));
|
res.load(new StringReader(pub.registerGCUBEResource(res, GCUBEScope.getScope(ServiceContext.getContext().getScope()+"/"+this.vreName), ServiceContext.getContext())));
|
||||||
this.createdResourceId= res.getID();
|
this.createdResourceId= res.getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import org.gcube.common.core.contexts.GHNContext;
|
import org.gcube.common.core.contexts.GHNContext;
|
||||||
import org.gcube.common.core.informationsystem.publisher.ISPublisher;
|
import org.gcube.common.core.informationsystem.publisher.ISPublisher;
|
||||||
import org.gcube.common.core.resources.GCUBEGenericResource;
|
import org.gcube.common.core.resources.GCUBEGenericResource;
|
||||||
|
import org.gcube.common.core.scope.GCUBEScope;
|
||||||
import org.gcube.vremanagement.vremodeler.db.DBInterface;
|
import org.gcube.vremanagement.vremodeler.db.DBInterface;
|
||||||
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
|
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
|
||||||
import org.gcube.vremanagement.vremodeler.impl.util.XMLUtil;
|
import org.gcube.vremanagement.vremodeler.impl.util.XMLUtil;
|
||||||
|
@ -37,7 +38,7 @@ public class LayoutCreation {
|
||||||
resource.setName("Layout_"+splitScope[1]+"_"+splitScope[2]+"_"+this.vreName);
|
resource.setName("Layout_"+splitScope[1]+"_"+splitScope[2]+"_"+this.vreName);
|
||||||
resource.setSecondaryType("VRE");
|
resource.setSecondaryType("VRE");
|
||||||
ISPublisher publisher= GHNContext.getImplementation(ISPublisher.class);
|
ISPublisher publisher= GHNContext.getImplementation(ISPublisher.class);
|
||||||
resource.load(new StringReader(publisher.registerGCUBEResource(resource, ServiceContext.getContext().getScope(), ServiceContext.getContext())));
|
resource.load(new StringReader(publisher.registerGCUBEResource(resource, GCUBEScope.getScope(ServiceContext.getContext().getScope()+"/"+this.vreName), ServiceContext.getContext())));
|
||||||
this.createdResourceId= resource.getID();
|
this.createdResourceId= resource.getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue