git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vre-management/VREModeler@7643 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
91fe21c2c2
commit
9f15d6c7af
|
@ -1,19 +1,22 @@
|
|||
package org.gcube.vremanagement.vremodeler.db;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.rmi.RemoteException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
/*import org.apache.axis.components.uuid.UUIDGen;
|
||||
import org.apache.axis.components.uuid.UUIDGenFactory;*/
|
||||
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathExpression;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import org.apache.axis.components.uuid.UUIDGen;
|
||||
import org.apache.axis.components.uuid.UUIDGenFactory;
|
||||
import org.apache.axis.message.addressing.EndpointReferenceType;
|
||||
import org.gcube.common.core.contexts.GHNContext;
|
||||
import org.gcube.common.core.faults.GCUBEFault;
|
||||
import org.gcube.common.core.informationsystem.client.ISClient;
|
||||
import org.gcube.common.core.informationsystem.client.XMLResult;
|
||||
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.GCUBEGHNQuery;
|
||||
|
@ -22,21 +25,34 @@ import org.gcube.common.core.informationsystem.client.queries.GCUBERIQuery;
|
|||
import org.gcube.common.core.informationsystem.client.queries.GCUBEServiceQuery;
|
||||
import org.gcube.common.core.resources.GCUBECS;
|
||||
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.GCUBEMCollection;
|
||||
import org.gcube.common.core.resources.GCUBEResource;
|
||||
import org.gcube.common.core.resources.GCUBERunningInstance;
|
||||
import org.gcube.common.core.resources.GCUBEService;
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
import org.gcube.common.core.utils.handlers.GCUBEServiceClientImpl;
|
||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
import org.gcube.common.vremanagement.ghnmanager.impl.contexts.ServiceContext;
|
||||
import org.gcube.metadatamanagement.metadatabroker.stubs.FindPossibleTransformationPrograms;
|
||||
import org.gcube.metadatamanagement.metadatabroker.stubs.FindPossibleTransformationProgramsResponse;
|
||||
import org.gcube.metadatamanagement.metadatabroker.stubs.MetadataBrokerFormat;
|
||||
import org.gcube.metadatamanagement.metadatabroker.stubs.MetadataBrokerPortType;
|
||||
import org.gcube.vremanagement.vremodeler.impl.util.MBrokerServiceHandler;
|
||||
import org.gcube.vremanagement.vremodeler.impl.util.MFRelationDerivate;
|
||||
import org.gcube.vremanagement.vremodeler.impl.util.MFRelationNative;
|
||||
import org.gcube.vremanagement.vremodeler.impl.util.MetadataFormat;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import com.sun.org.apache.bcel.internal.generic.NEW;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lucio lelii CNR
|
||||
*
|
||||
*/
|
||||
public static class IStoDBUtil {
|
||||
public class IStoDBUtil {
|
||||
|
||||
//private static UUIDGen uuidMFGEN=UUIDGenFactory.getUUIDGen();
|
||||
|
||||
|
@ -244,13 +260,20 @@ public static class IStoDBUtil {
|
|||
//adding the native metadataformat
|
||||
uuid=uuidMFGEN.nextUUID();
|
||||
mf= new MetadataFormat(uuid, col.getMetaFormat().getName(), col.getMetaFormat().getSchemaURI(), col.getMetaFormat().getLanguage());
|
||||
System.out.println(uuid+ " "+mf.getName() + " "+mf.getSchemaURI()+" "+mf.getLanguage()+" ");
|
||||
logger.trace(uuid+ " "+mf.getName() + " "+mf.getSchemaURI()+" "+mf.getLanguage()+" ");
|
||||
|
||||
if (!metadataFormatList.contains(mf)){
|
||||
metadataFormatList.add(mf);
|
||||
nativeMetadataFormatList.add(new MFRelationNative(col.getID(), mf.getId() ));
|
||||
}else nativeMetadataFormatList.add(new MFRelationNative(col.getID(), metadataFormatList.get(metadataFormatList.indexOf(mf)).getId()));
|
||||
|
||||
try {
|
||||
ServiceContext.getContext().setScope(scope);
|
||||
getMFDerivate(metadataFormatList, col);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error in getMFDerivate");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -269,8 +292,60 @@ public static class IStoDBUtil {
|
|||
|
||||
}
|
||||
|
||||
private static retriveTPResource(){
|
||||
private static List<MFRelationDerivate> getMFDerivate(List<MetadataFormat> mdfList, GCUBEMCollection col ) throws Exception{
|
||||
|
||||
MBrokerServiceHandler<List<GCUBEGenericResource>, MetadataFormat> sHandler= new MBrokerServiceHandler<List<GCUBEGenericResource>,MetadataFormat >(){
|
||||
|
||||
@Override
|
||||
protected List<GCUBEGenericResource> makeCall(MetadataBrokerPortType mbportType) throws Exception {
|
||||
FindPossibleTransformationPrograms fptp= new FindPossibleTransformationPrograms();
|
||||
MetadataBrokerFormat mbInFormat= new MetadataBrokerFormat();
|
||||
mbInFormat.setType("collection");
|
||||
mbInFormat.setLanguage(getParameter().getLanguage());
|
||||
mbInFormat.setSchema(getParameter().getName()+"="+getParameter().getSchemaURI().toString());
|
||||
fptp.setInputFormat(mbInFormat);
|
||||
|
||||
MetadataBrokerFormat mbOutFormat= new MetadataBrokerFormat();
|
||||
mbOutFormat.setType("collection");
|
||||
fptp.setOutputFormat(mbOutFormat);
|
||||
|
||||
List<GCUBEGenericResource> genericRes= new ArrayList<GCUBEGenericResource>();
|
||||
GCUBEGenericResource gen;
|
||||
if (mbportType==null) System.out.println("the MetadataBroker portType is null");
|
||||
|
||||
FindPossibleTransformationProgramsResponse tpRes= mbportType.findPossibleTransformationPrograms(fptp);
|
||||
if (tpRes==null){
|
||||
System.out.println("the result is null");
|
||||
return new ArrayList<GCUBEGenericResource>();
|
||||
}
|
||||
String[] tpArray = tpRes.getTransformationProgram();
|
||||
if (tpArray== null){
|
||||
System.out.println("the array is null");
|
||||
return new ArrayList<GCUBEGenericResource>();
|
||||
}
|
||||
|
||||
for (String res:tpArray){
|
||||
gen= GHNContext.getImplementation(GCUBEGenericResource.class);
|
||||
gen.load(new StringReader(res));
|
||||
genericRes.add(gen);
|
||||
}
|
||||
return genericRes;
|
||||
}
|
||||
};
|
||||
sHandler.setHandled(new GCUBEServiceClientImpl());
|
||||
sHandler.setParameter(mdfList.get(mdfList.size()-1));
|
||||
sHandler.run();
|
||||
List<GCUBEGenericResource> resList=sHandler.getReturnValue();
|
||||
|
||||
XPathFactory factory = XPathFactory.newInstance();
|
||||
XPath xpath= factory.newXPath();
|
||||
XPathExpression schemaExpr=xpath.compile("/TransformationProgram/Output[@Name='TPOutput']/Schema/text()");
|
||||
XPathExpression languageExpr=xpath.compile("/TransformationProgram/Output[@Name='TPOutput']/Language[@isVariable]/text()");
|
||||
for(GCUBEGenericResource res: resList){
|
||||
System.out.println(schemaExpr.evaluate(new InputSource(new StringReader(res.getBody()))));
|
||||
System.out.println(languageExpr.evaluate(new InputSource(new StringReader(res.getBody()))));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.gcube.common.core.porttypes.GCUBEStartupPortType;
|
|||
import org.gcube.common.core.types.VOID;
|
||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
import org.gcube.vremanagement.vremodeler.db.DBInterface;
|
||||
import org.gcube.vremanagement.vremodeler.impl.util.XMLUtil;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.GetExistingNamesResponseMessage;
|
||||
import org.globus.wsrf.encoding.ObjectDeserializer;
|
||||
import org.globus.wsrf.tests.basic.CreateResource;
|
||||
|
|
|
@ -17,7 +17,6 @@ import org.gcube.common.core.informationsystem.client.AtomicCondition;
|
|||
import org.gcube.common.core.informationsystem.client.ISClient;
|
||||
import org.gcube.common.core.informationsystem.client.queries.GCUBERIQuery;
|
||||
import org.gcube.common.core.resources.GCUBECollection;
|
||||
import org.gcube.common.core.resources.GCUBEMCollection;
|
||||
import org.gcube.common.core.resources.GCUBERunningInstance;
|
||||
import org.gcube.common.core.resources.impl.kxml.KGCUBEResource;
|
||||
import org.gcube.common.core.types.VOID;
|
||||
|
@ -26,10 +25,10 @@ import org.gcube.vremanagement.vremanager.stubs.vremanager.AddResourcesParameter
|
|||
import org.gcube.vremanagement.vremanager.stubs.vremanager.ResourceItem;
|
||||
import org.gcube.vremanagement.vremanager.stubs.vremanager.ResourceList;
|
||||
import org.gcube.vremanagement.vremanager.stubs.vremanager.ScopeOption;
|
||||
import org.gcube.vremanagement.vremanager.stubs.vremanager.ServiceItem;
|
||||
import org.gcube.vremanagement.vremanager.stubs.vremanager.VREManagerPortType;
|
||||
import org.gcube.vremanagement.vremanager.stubs.vremanager.service.VREManagerServiceAddressingLocator;
|
||||
import org.gcube.vremanagement.vremodeler.db.DBInterface;
|
||||
import org.gcube.vremanagement.vremodeler.impl.util.XMLUtil;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.CollectionArray;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.FunctionalityIDArray;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.GHNArray;
|
||||
|
@ -509,7 +508,7 @@ public class ModelerService {
|
|||
ResultSet resGenericInfo=DBInterface.queryDB("select * from VRE where VRE.id='"+resourceID+"'; ");
|
||||
|
||||
if (!resGenericInfo.next()) throw new GCUBEFault("The VRE with ID "+resourceID+" cannot be retrieved");
|
||||
//TODO: set properties values
|
||||
|
||||
ops=new OptionsParameters();
|
||||
ScopeOption[] scopeOptionList= new ScopeOption[6];
|
||||
ScopeOption soDesigner= new ScopeOption();
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.gcube.vremanagement.vremodeler.impl;
|
||||
|
||||
import org.gcube.common.core.contexts.GCUBEServiceContext;
|
||||
import org.gcube.vremanagement.vremodeler.db.DBInterface;
|
||||
import org.gcube.vremanagement.vremodeler.db.IStoDBUtil;
|
||||
|
||||
public class ServiceContext extends GCUBEServiceContext{
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package org.gcube.vremanagement.vremodeler.impl.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.axis.message.addressing.EndpointReferenceType;
|
||||
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
|
||||
import org.gcube.common.core.contexts.GHNContext;
|
||||
import org.gcube.common.core.informationsystem.client.AtomicCondition;
|
||||
import org.gcube.common.core.informationsystem.client.ISClient;
|
||||
import org.gcube.common.core.informationsystem.client.queries.GCUBERIQuery;
|
||||
import org.gcube.common.core.resources.GCUBERunningInstance;
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
import org.gcube.common.core.utils.handlers.GCUBEServiceClient;
|
||||
import org.gcube.common.core.utils.handlers.GCUBEServiceHandler;
|
||||
import org.gcube.common.vremanagement.ghnmanager.impl.contexts.ServiceContext;
|
||||
import org.gcube.metadatamanagement.metadatabroker.stubs.MetadataBrokerPortType;
|
||||
import org.gcube.metadatamanagement.metadatabroker.stubs.service.MetadataBrokerServiceAddressingLocator;
|
||||
|
||||
public abstract class MBrokerServiceHandler<T, P> extends GCUBEServiceHandler<GCUBEServiceClient> {
|
||||
|
||||
private T returnValue= null;
|
||||
|
||||
private P parameter= null;
|
||||
|
||||
public T getReturnValue(){
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
public void setParameter(P param){
|
||||
this.parameter= param;
|
||||
}
|
||||
|
||||
protected P getParameter(){
|
||||
return this.parameter;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
protected void setReturnValue(T returnValue){
|
||||
this.returnValue= returnValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<EndpointReferenceType> findInstances() throws Exception {
|
||||
ISClient client = GHNContext.getImplementation(ISClient.class);
|
||||
GCUBERIQuery query = client.getQuery(GCUBERIQuery.class);
|
||||
query.addAtomicConditions(new AtomicCondition("//ServiceName","MetadataBroker"));
|
||||
List<EndpointReferenceType> eprs = new ArrayList<EndpointReferenceType>();
|
||||
for (GCUBERunningInstance instance : client.execute(query, ServiceContext.getContext().getScope()))
|
||||
eprs.add(instance.getAccessPoint().getEndpoint("gcube/metadatamanagement/MetadataBroker"));
|
||||
return eprs;
|
||||
|
||||
}
|
||||
|
||||
protected abstract T makeCall(MetadataBrokerPortType mbportType) throws Exception;
|
||||
|
||||
|
||||
|
||||
protected void interact(EndpointReferenceType arg0) throws Exception{
|
||||
MetadataBrokerServiceAddressingLocator mbsal= new MetadataBrokerServiceAddressingLocator();
|
||||
|
||||
MetadataBrokerPortType mbpt= mbsal.getMetadataBrokerPortTypePort(arg0);
|
||||
mbpt = GCUBERemotePortTypeContext.getProxy(mbpt,ServiceContext.getContext().getScope());
|
||||
this.setReturnValue(this.makeCall(mbpt));
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.vremanagement.vremodeler.impl;
|
||||
package org.gcube.vremanagement.vremodeler.impl.util;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
@ -6,10 +6,9 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
import org.gcube.vremanagement.vremodeler.db.DBInterface;
|
||||
import org.gcube.vremanagement.vremodeler.impl.ModelerService;
|
||||
|
||||
|
||||
|
||||
|
@ -29,7 +28,7 @@ public class XMLUtil {
|
|||
* @param res
|
||||
* @return String
|
||||
*/
|
||||
protected static String PrepareCollectionXML(ResultSet res, ArrayList<String> relatedCollection){
|
||||
public static String PrepareCollectionXML(ResultSet res, ArrayList<String> relatedCollection){
|
||||
StringBuilder temp= new StringBuilder();
|
||||
String selectedString="false";
|
||||
temp.append("<ResultSet>");
|
||||
|
@ -63,7 +62,7 @@ public class XMLUtil {
|
|||
}
|
||||
|
||||
|
||||
protected static String PrepareGHNsXML(ResultSet res, ArrayList<String> relatedGHNs){
|
||||
public static String PrepareGHNsXML(ResultSet res, ArrayList<String> relatedGHNs){
|
||||
StringBuilder temp = new StringBuilder(),
|
||||
runningInstancesString ;
|
||||
ResultSet riRes;
|
||||
|
@ -122,7 +121,7 @@ public class XMLUtil {
|
|||
* @param res
|
||||
* @return
|
||||
*/
|
||||
protected static String PrepareMCFormatXML(ResultSet resNative, ResultSet resDerivable, ResultSet allMF, Hashtable<String, ArrayList<String>> selectedMetadata){
|
||||
public static String PrepareMCFormatXML(ResultSet resNative, ResultSet resDerivable, ResultSet allMF, Hashtable<String, ArrayList<String>> selectedMetadata){
|
||||
|
||||
Hashtable<String, ArrayList<String>> MDFHash= new Hashtable<String, ArrayList<String>>();
|
||||
StringBuilder temp;
|
||||
|
@ -244,7 +243,7 @@ public class XMLUtil {
|
|||
* @param resDerivable
|
||||
* @return
|
||||
*/
|
||||
protected static String PrepareQualityXML(){
|
||||
public static String PrepareQualityXML(){
|
||||
StringBuilder qualityString=new StringBuilder();
|
||||
qualityString.append("<ResultSet>");
|
||||
qualityString.append("<Quality><DisplayName>Response Time</DisplayName><Description>This quality parameter indicates the importance of response time (i.e., the delay from a function request to the reception of the response) ");
|
||||
|
@ -272,7 +271,7 @@ public class XMLUtil {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
protected static String PrepareFunctionalityXML(ResultSet res, ArrayList<Integer> selectedFunct, ArrayList<String> selectedCS){
|
||||
public static String PrepareFunctionalityXML(ResultSet res, ArrayList<Integer> selectedFunct, ArrayList<String> selectedCS){
|
||||
StringBuilder toReturn=new StringBuilder();
|
||||
toReturn.append("<Resultset>");
|
||||
try {
|
||||
|
@ -357,7 +356,7 @@ public class XMLUtil {
|
|||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected static String PrepareVREModelXML(ResultSet res) throws Exception{
|
||||
public static String PrepareVREModelXML(ResultSet res) throws Exception{
|
||||
|
||||
StringBuilder toReturn=new StringBuilder();
|
||||
|
||||
|
@ -386,7 +385,7 @@ public class XMLUtil {
|
|||
}
|
||||
|
||||
|
||||
protected static String PrepareAllVREsXML(ResultSet res) throws Exception{
|
||||
public static String PrepareAllVREsXML(ResultSet res) throws Exception{
|
||||
StringBuilder toReturn=new StringBuilder();
|
||||
toReturn.append("<ResultSet>");
|
||||
while (res.next()){
|
||||
|
@ -405,4 +404,5 @@ public class XMLUtil {
|
|||
return toReturn.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue