This commit is contained in:
Lucio Lelii 2010-02-23 17:04:28 +00:00
parent 90393febbe
commit 419e4a1472
6 changed files with 68 additions and 8 deletions

View File

@ -27,6 +27,12 @@
value="UserProfile,Schemas Searchable Fields,MetadataXSLT,PresentationXSLT"
type="java.lang.String"
override="false" />
<environment
name="BaseRisForSelectableGHN"
value="ResultSetService,Search;Deployer,VREManagement;GHNManager,VREManagement"
type="java.lang.String"
override="false" />
</service>

View File

@ -37,7 +37,7 @@ public class ModelerService {
public static final String DEPLOYING="Deploying";
private static final GCUBELog logger = new GCUBELog(ModelerService.class.getName());
private static final GCUBELog logger = new GCUBELog(ModelerService.class);
protected ModelerResource getResource() throws ResourceException{
return (ModelerResource) ModelerContext.getPortTypeContext().getWSHome().find();
@ -133,6 +133,7 @@ public class ModelerService {
res= DBInterface.queryDB("select * from GHN ORDER BY GHN.host;");
ResultSet resRelated= DBInterface.queryDB("select ghnid, ISCANDIDATE from VRERELATEDGHN where VRERELATEDGHN.vreid='"+getResource().getId()+"';");
String candidatedGHN="";
while(resRelated.next()){
relatedGHN.add(resRelated.getString(1));
@ -140,7 +141,7 @@ public class ModelerService {
}
return XMLUtil.PrepareGHNsXML(res, relatedGHN,candidatedGHN);
}catch(Exception e) {
logger.error("VRE Model: error retreiving GHNs",e);
logger.error("VRE Modeler: error retreiving GHNs",e);
throw new GCUBEFault(e);}
}

View File

@ -19,6 +19,7 @@ import org.gcube.vremanagement.vremodeler.consumers.GenericResourceConsumer;
import org.gcube.vremanagement.vremodeler.consumers.MCollectionConsumer;
import org.gcube.vremanagement.vremodeler.consumers.RunningInstanceConsumer;
import org.gcube.vremanagement.vremodeler.db.IStoDBUtil;
import org.gcube.vremanagement.vremodeler.impl.util.ServicePair;
import org.gcube.vremanagement.vremodeler.resources.handlers.CollectionHandler;
import org.gcube.vremanagement.vremodeler.resources.handlers.FunctionalityHandler;
import org.gcube.vremanagement.vremodeler.resources.handlers.GHNHandler;
@ -40,6 +41,8 @@ public class ServiceContext extends GCUBEServiceContext{
private ArrayList<String> secondaryTypeGenericResourceRequired= new ArrayList<String>();
private ArrayList<ServicePair> baseServiceForGhn= new ArrayList<ServicePair>();
protected void onReady() throws Exception{
try{
logger.info("ready event invoked on " + this.getName());
@ -52,6 +55,13 @@ public class ServiceContext extends GCUBEServiceContext{
}
protected void intializeDB() throws Exception{
ArrayList<ServicePair> baseServiceGhn= new ArrayList<ServicePair>();
for (String gen:((String)this.getProperty("BaseRisForSelectableGHN", true)).split(";")){
String[] serviceString=gen.split(",");
new ServicePair(serviceString[0], serviceString[1]);
}
this.setBaseServiceForGhn(baseServiceGhn);
ISNotifier notifier= GHNContext.getImplementation(ISNotifier.class);
for (GCUBEScope scope : ServiceContext.getContext().getInstance().getScopes().values()){
ServiceContext.getContext().setScope(scope);
@ -109,4 +119,12 @@ public class ServiceContext extends GCUBEServiceContext{
String[] secondaryTypeGenericResourceRequired) {
Collections.addAll(this.secondaryTypeGenericResourceRequired,secondaryTypeGenericResourceRequired);
}
public ArrayList<ServicePair> getBaseServiceForGhn() {
return baseServiceForGhn;
}
public void setBaseServiceForGhn(ArrayList<ServicePair> baseServiceForGhn) {
this.baseServiceForGhn = baseServiceForGhn;
}
}

View File

@ -0,0 +1,25 @@
package org.gcube.vremanagement.vremodeler.impl.util;
public class ServicePair {
private String serviceClass;
private String serviceName;
public ServicePair(String serviceName, String serviceClass){
this.serviceClass= serviceClass;
this.serviceName= serviceName;
}
public String getServiceClass() {
return serviceClass;
}
public String getServiceName() {
return serviceName;
}
public boolean equals(Object o){
ServicePair servicePair= (ServicePair) o;
return this.serviceClass.compareTo(servicePair.getServiceClass())==0 && this.serviceName.compareTo(servicePair.getServiceName())==0;
}
}

View File

@ -3,6 +3,7 @@ package org.gcube.vremanagement.vremodeler.impl.util;
import java.io.StringWriter;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
@ -18,6 +19,7 @@ import javax.xml.transform.stream.StreamResult;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.db.DBInterface;
import org.gcube.vremanagement.vremodeler.impl.ModelerService;
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
import org.gcube.vremanagement.vremodeler.resources.MetadataFormat;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@ -53,7 +55,7 @@ public class XMLUtil {
}
Element root= doc.createElement("ResultSet");
SimpleDateFormat simpleDateFormat= new SimpleDateFormat("dd-MM-yyyy 'at' HH:mm z");
try{
while (res.next()){
Element collection = addElements(doc, "Collection",
@ -63,8 +65,9 @@ public class XMLUtil {
new Element[]{
createTextElement(doc, "Description",res.getString(3)),
createTextElement(doc, "NumberOfMembers",res.getString(4)),
createTextElement(doc, "CreationTime",res.getString(5)),
createTextElement(doc, "LastUpdateTime",res.getString(6))}),
createTextElement(doc, "CreationTime",simpleDateFormat.format(new Date(Long.parseLong(res.getString(5))))),
createTextElement(doc, "LastUpdateTime",simpleDateFormat.format(new Date(Long.parseLong(res.getString(6)))))
}),
createTextElement(doc, "Selected",relatedCollection.contains(res.getString(1)) ? "true" : "false") });
root.appendChild(collection);
}
@ -96,7 +99,10 @@ public class XMLUtil {
while (res.next()){
riRes= DBInterface.queryDB("select RI.id, RI.name, RI.class from RUNNINGINSTANCE as RI, GHNRELATEDRI as REL where REL.GHNID='"+res.getString("ID")+"' and REL.RIID=RI.ID");
Element risElement=doc.createElement("RunningInstances");
int risNum=0;
while (riRes.next()){
if (!ServiceContext.getContext().getBaseServiceForGhn().contains(new ServicePair(riRes.getString(2),riRes.getString(3))))
risNum++;
Element riElement=addElements(doc, "RunningInstance", new Element[]{
createTextElement(doc, "Name",riRes.getString(2)),
createTextElement(doc, "Class",riRes.getString(3))
@ -105,7 +111,7 @@ public class XMLUtil {
}
Element ghnEl = addElements(doc, "GHN", new Element[]{
createTextElement(doc, "ID",res.getString(1),new Couple<String, String>("VREManagerUse",(candidateGHN.compareTo(res.getString("ID"))==0?"true":"false"))),
createTextElement(doc, "ID",res.getString(1),new Couple<String, String>("selectable", risNum>0?"false":"true"),new Couple<String, String>("VREManagerUse",(candidateGHN.compareTo(res.getString("ID"))==0?"true":"false"))),
createTextElement(doc, "Host",res.getString(2)),
addElements(doc, "Info", new Element[]{
risElement,

View File

@ -46,7 +46,7 @@ public class ModelerTest {
msptp = GCUBERemotePortTypeContext.getProxy(msptp, GCUBEScope.getScope(args[0]));
System.out.println("creation requested");
VRERequest vreReq= new VRERequest();
vreReq.setStartTime(new Date().getTime());
vreReq.setEndTime(new Date().getTime());
@ -56,6 +56,10 @@ public class ModelerTest {
vreReq.setVREName("test");
msptp.setVREModel(vreReq);
System.out.println("first call done");
System.out.println(msptp.getGHNs(new VOID()));
/*
CollectionArray ca= new CollectionArray();
ca.setCollectionElement(new String[]{"e60f6340-e970-11dd-bb52-d1724dda0823"});
msptp.setCollection(ca);
@ -72,7 +76,7 @@ public class ModelerTest {
msptp.deployVRE(new VOID());
*/
}catch(Exception e){e.printStackTrace();}
}