git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vre-management/VREModeler@7786 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
55c38d9cb6
commit
03e94dfb1d
|
@ -16,16 +16,13 @@ import javax.xml.transform.dom.DOMSource;
|
||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
import javax.xml.xpath.XPath;
|
import javax.xml.xpath.XPath;
|
||||||
import javax.xml.xpath.XPathConstants;
|
import javax.xml.xpath.XPathConstants;
|
||||||
import javax.xml.xpath.XPathExpression;
|
|
||||||
import javax.xml.xpath.XPathFactory;
|
import javax.xml.xpath.XPathFactory;
|
||||||
|
|
||||||
import org.apache.axis.components.uuid.UUIDGen;
|
import org.apache.axis.components.uuid.UUIDGen;
|
||||||
import org.apache.axis.components.uuid.UUIDGenFactory;
|
import org.apache.axis.components.uuid.UUIDGenFactory;
|
||||||
import org.apache.axis.message.addressing.EndpointReferenceType;
|
import org.apache.axis.message.addressing.EndpointReferenceType;
|
||||||
import org.gcube.common.core.contexts.GHNContext;
|
import org.gcube.common.core.contexts.GHNContext;
|
||||||
import org.gcube.common.core.faults.GCUBEFault;
|
import org.gcube.common.core.faults.GCUBEFault;
|
||||||
import org.gcube.common.core.informationsystem.client.ISClient;
|
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.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;
|
||||||
|
@ -34,10 +31,8 @@ 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.GCUBEResource;
|
|
||||||
import org.gcube.common.core.resources.GCUBERunningInstance;
|
import org.gcube.common.core.resources.GCUBERunningInstance;
|
||||||
import org.gcube.common.core.resources.GCUBEService;
|
import org.gcube.common.core.resources.GCUBEService;
|
||||||
import org.gcube.common.core.scope.GCUBEScope;
|
import org.gcube.common.core.scope.GCUBEScope;
|
||||||
|
@ -56,8 +51,6 @@ import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
|
|
||||||
import com.sun.org.apache.bcel.internal.generic.NEW;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author lucio lelii CNR
|
* @author lucio lelii CNR
|
||||||
|
@ -65,8 +58,6 @@ import com.sun.org.apache.bcel.internal.generic.NEW;
|
||||||
*/
|
*/
|
||||||
public class IStoDBUtil {
|
public class IStoDBUtil {
|
||||||
|
|
||||||
//private static UUIDGen uuidMFGEN=UUIDGenFactory.getUUIDGen();
|
|
||||||
|
|
||||||
private static GCUBELog logger = new GCUBELog(IStoDBUtil.class.getName());
|
private static GCUBELog logger = new GCUBELog(IStoDBUtil.class.getName());
|
||||||
|
|
||||||
private static UUIDGen uuidMFGEN= UUIDGenFactory.getUUIDGen();
|
private static UUIDGen uuidMFGEN= UUIDGenFactory.getUUIDGen();
|
||||||
|
@ -117,82 +108,6 @@ public class IStoDBUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
private static String[] ParseTP(String[] tp){
|
|
||||||
//logger.debug("ParseTP start");
|
|
||||||
|
|
||||||
String[] schemaNameURI=tp[1].split("=");
|
|
||||||
String lng="anylanguage";
|
|
||||||
//logger.debug("MetadataFormatParsed: "+schemaNameURI[0]+ ", "+schemaNameURI[1]+", "+lng);
|
|
||||||
return new String[]{tp[0],schemaNameURI[0],schemaNameURI[1],lng};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static String ContainsControl(String[] item, ArrayList<String[]> container){
|
|
||||||
for(String[] cont: container){
|
|
||||||
//logger.debug("MDFormat: "+cont[1]+" "+cont[2]);
|
|
||||||
//logger.debug("MDFormat: confr "+cont[1]+" "+cont[2]);
|
|
||||||
if((cont[1].compareTo(item[1])==0) && (cont[2].compareTo(item[2])==0)) //&& ((cont[3].compareTo("anylanguage")==0) || cont[3].compareTo(item[3])==0)
|
|
||||||
return cont[0];
|
|
||||||
|
|
||||||
}
|
|
||||||
//logger.debug("MDFormat: not yet present");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
private static String[][] parseResults(String results, String tag) throws RemoteException{
|
|
||||||
|
|
||||||
ArrayList<String[]> returnedValues= new ArrayList<String[]>();
|
|
||||||
ArrayList<String> tempArray;
|
|
||||||
|
|
||||||
|
|
||||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
|
||||||
factory.setNamespaceAware(true);
|
|
||||||
|
|
||||||
DocumentBuilder builder;
|
|
||||||
try {
|
|
||||||
builder = factory.newDocumentBuilder();
|
|
||||||
|
|
||||||
|
|
||||||
StringReader reader = new StringReader(results);
|
|
||||||
InputSource source = new InputSource(reader);
|
|
||||||
Document domDoc;
|
|
||||||
domDoc = builder.parse(source);
|
|
||||||
Element child, subChild;
|
|
||||||
Element root= domDoc.getDocumentElement();
|
|
||||||
NodeList childRoot= root.getElementsByTagName(tag);
|
|
||||||
if (childRoot.getLength()==0) return null;
|
|
||||||
for (int i=0; i<childRoot.getLength(); i++)
|
|
||||||
{
|
|
||||||
String textValue=null;
|
|
||||||
child=(Element) childRoot.item(i);
|
|
||||||
NodeList subList= child.getChildNodes();
|
|
||||||
tempArray= new ArrayList<String>();
|
|
||||||
for (int k=0; k<subList.getLength(); k++)
|
|
||||||
{
|
|
||||||
if ((subList.item(k) instanceof Element) && (subList.item(k)!=null)){
|
|
||||||
//String tmp;
|
|
||||||
subChild= (Element) subList.item(k);
|
|
||||||
textValue=subChild.getTextContent().compareTo("")==0 ? "none" : subChild.getTextContent();
|
|
||||||
tempArray.add(textValue);
|
|
||||||
//logger.info("VDLMOdel : child "+tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
returnedValues.add(tempArray.toArray(new String[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
//logger.error("VDL Model Service: parsing results error");
|
|
||||||
throw new RemoteException(e.getMessage(),e);
|
|
||||||
}
|
|
||||||
return returnedValues.toArray(new String[0][0]);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
private static void insertCollection(GCUBEScope scope) throws GCUBEFault {
|
private static void insertCollection(GCUBEScope scope) throws GCUBEFault {
|
||||||
|
|
||||||
List<GCUBECollection> collectionList= null;
|
List<GCUBECollection> collectionList= null;
|
||||||
|
@ -261,7 +176,6 @@ public class IStoDBUtil {
|
||||||
List<MFRelationDerivate> derivateMetadataFormatList= new ArrayList<MFRelationDerivate>();
|
List<MFRelationDerivate> derivateMetadataFormatList= new ArrayList<MFRelationDerivate>();
|
||||||
for (GCUBEMCollection col: collectionList ){
|
for (GCUBEMCollection col: collectionList ){
|
||||||
row= new ArrayList<String>(4);
|
row= new ArrayList<String>(4);
|
||||||
|
|
||||||
row.add(col.getID());
|
row.add(col.getID());
|
||||||
row.add(col.getName());
|
row.add(col.getName());
|
||||||
row.add(col.getDescription());
|
row.add(col.getDescription());
|
||||||
|
@ -285,11 +199,7 @@ public class IStoDBUtil {
|
||||||
logger.error("Error in getMFDerivate"+e);
|
logger.error("Error in getMFDerivate"+e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
System.out.println(derivateMetadataFormatList.size());
|
|
||||||
//insert values in the database
|
//insert values in the database
|
||||||
DBInterface.connect();
|
DBInterface.connect();
|
||||||
DBInterface.InsertInto("mdcollection", values);
|
DBInterface.InsertInto("mdcollection", values);
|
||||||
|
@ -334,55 +244,42 @@ public class IStoDBUtil {
|
||||||
|
|
||||||
List<MFRelationDerivate> derivatedList= new ArrayList<MFRelationDerivate>();
|
List<MFRelationDerivate> derivatedList= new ArrayList<MFRelationDerivate>();
|
||||||
if (resList!=null && resList.length>0){
|
if (resList!=null && resList.length>0){
|
||||||
System.out.println("resList is not null");
|
|
||||||
XPath xpath= XPathFactory.newInstance().newXPath();
|
|
||||||
String schemaExpr="//TransformationProgram/Output[@name='TPOutput']/Schema/text()";
|
String schemaExpr="//TransformationProgram/Output[@name='TPOutput']/Schema/text()";
|
||||||
String languageExpr="//TransformationProgram/Output[@name='TPOutput']/Language[@isVariable='false']/text()";
|
String languageExpr="//TransformationProgram/Output[@name='TPOutput']/Language[@isVariable='false']/text()";
|
||||||
String typeExpr="//TransformationProgram/Output[@name='TPOutput']/Type/text()";
|
String typeExpr="//TransformationProgram/Output[@name='TPOutput']/Type/text()";
|
||||||
String tpIdExpr="/Resource/ID/text()";
|
String tpIdExpr="/Resource/ID/text()";
|
||||||
|
|
||||||
Document doc;
|
Document doc;
|
||||||
|
String tpId, transformationType,lng;
|
||||||
Transformer transformer = TransformerFactory.newInstance().newTransformer();
|
String[] schema;
|
||||||
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"yes");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NodeList set;
|
|
||||||
StreamResult sr;
|
|
||||||
String tpId;
|
|
||||||
for(String res: resList){
|
for(String res: resList){
|
||||||
doc= DocumentBuilderFactory.newInstance().newDocumentBuilder().parse( new InputSource(new StringReader(res)));
|
doc= DocumentBuilderFactory.newInstance().newDocumentBuilder().parse( new InputSource(new StringReader(res)));
|
||||||
|
//retrieving the TP type
|
||||||
|
transformationType=executeXpathOnDocument(typeExpr, doc).getWriter().toString();
|
||||||
|
if (transformationType.compareTo("collection")==0){
|
||||||
|
//retrieving the language
|
||||||
|
lng= executeXpathOnDocument(languageExpr, doc).getWriter().toString();
|
||||||
|
//retrieving the Transformation program ID
|
||||||
|
tpId= executeXpathOnDocument(tpIdExpr, doc).getWriter().toString();
|
||||||
|
//retrieving the schema
|
||||||
|
schema= executeXpathOnDocument(schemaExpr, doc).getWriter().toString().split("=");
|
||||||
|
|
||||||
set = (NodeList) xpath.evaluate(schemaExpr,doc, XPathConstants.NODESET);
|
//creating the new MDFormat
|
||||||
sr = new StreamResult(new StringWriter());
|
boolean isLngAny= false;
|
||||||
try {transformer.transform(new DOMSource(set.item(0)),sr);}catch(Exception ignore) {continue;}
|
|
||||||
if (sr.getWriter().toString().compareTo("collection")!=0){
|
|
||||||
|
|
||||||
set = (NodeList) xpath.evaluate(languageExpr,doc, XPathConstants.NODESET);
|
|
||||||
sr = new StreamResult(new StringWriter());
|
|
||||||
try {transformer.transform(new DOMSource(set.item(0)),sr);}catch(Exception ignore) {continue;}
|
|
||||||
String[] schemas= sr.getWriter().toString().split("=");
|
|
||||||
|
|
||||||
set = (NodeList) xpath.evaluate(tpIdExpr,doc, XPathConstants.NODESET);
|
|
||||||
sr = new StreamResult(new StringWriter());
|
|
||||||
try {transformer.transform(new DOMSource(set.item(0)),sr);}catch(Exception ignore) {continue;}
|
|
||||||
tpId= sr.getWriter().toString();
|
|
||||||
|
|
||||||
MetadataFormat mfTemp;
|
MetadataFormat mfTemp;
|
||||||
|
if (lng.compareTo("")==0){
|
||||||
|
mfTemp=new MetadataFormat(uuidMFGEN.nextUUID(), schema[0], new URI(schema[1]), MetadataFormat.ANY_LANGUAGE);
|
||||||
|
isLngAny=true;
|
||||||
|
}else
|
||||||
|
mfTemp=new MetadataFormat(uuidMFGEN.nextUUID(), schema[0], new URI(schema[1]), lng);
|
||||||
|
|
||||||
set = (NodeList) xpath.evaluate(typeExpr,doc, XPathConstants.NODESET);
|
//if the MDFromat already exists use its id else it uses the new ID
|
||||||
sr = new StreamResult(new StringWriter());
|
|
||||||
try {transformer.transform(new DOMSource(set.item(0)),sr);}catch(Exception ignore) {continue;}
|
|
||||||
if (sr.getWriter().toString().compareTo("")==0)
|
|
||||||
mfTemp=new MetadataFormat(uuidMFGEN.nextUUID(), schemas[0], new URI(schemas[1]), "any");
|
|
||||||
else
|
|
||||||
mfTemp=new MetadataFormat(uuidMFGEN.nextUUID(), schemas[0], new URI(schemas[1]), sr.getWriter().toString());
|
|
||||||
|
|
||||||
MFRelationDerivate mfRelTemp;
|
MFRelationDerivate mfRelTemp;
|
||||||
if (mdfList.contains(mfTemp))
|
MetadataFormat existingMetadataFormat;
|
||||||
mfRelTemp =new MFRelationDerivate(col.getID(), mdfList.get(mdfList.indexOf(mfTemp)).getId(), tpId );
|
if (mdfList.contains(mfTemp)){
|
||||||
else {
|
existingMetadataFormat= mdfList.get(mdfList.indexOf(mfTemp));
|
||||||
|
if (isLngAny) existingMetadataFormat.setLanguage(MetadataFormat.ANY_LANGUAGE);
|
||||||
|
mfRelTemp =new MFRelationDerivate(col.getID(), existingMetadataFormat.getId(), tpId );
|
||||||
|
}else {
|
||||||
mfRelTemp =new MFRelationDerivate(col.getID(), mfTemp.getId(), tpId );
|
mfRelTemp =new MFRelationDerivate(col.getID(), mfTemp.getId(), tpId );
|
||||||
mdfList.add(mfTemp);
|
mdfList.add(mfTemp);
|
||||||
}
|
}
|
||||||
|
@ -391,7 +288,7 @@ public class IStoDBUtil {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else System.out.println("resList is null");
|
}
|
||||||
return derivatedList;
|
return derivatedList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -557,180 +454,14 @@ public class IStoDBUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
private static StreamResult executeXpathOnDocument(String xpathString, Document doc) throws Exception{
|
||||||
public static void updateServices(EndpointReferenceType epr, ExtendedGSSCredential cred, String resourceID, int op) throws RemoteException {
|
Transformer transformer = TransformerFactory.newInstance().newTransformer();
|
||||||
switch (op){
|
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"yes");
|
||||||
case 0:
|
XPath xpath= XPathFactory.newInstance().newXPath();
|
||||||
{
|
NodeList set = (NodeList) xpath.evaluate(xpathString,doc, XPathConstants.NODESET);
|
||||||
String serviceUpdateQuery="for $SERVICE in collection(\"/db/Profiles/Service\")//Document/Data/child::*[local-name()='Profile']/DILIGENTResource where $SERVICE/UniqueID/string() eq '"+op+"' return <r><Id>{$SERVICE/UniqueID/string()}</Id><Name>{$SERVICE/Profile/Name/string()}</Name><Class>{$SERVICE/Profile/Class/string()}</Class></r>";
|
StreamResult sr = new StreamResult(new StringWriter());
|
||||||
String results=makeQueryDIS(epr, cred, serviceUpdateQuery);
|
try {transformer.transform(new DOMSource(set.item(0)),sr);}catch(Exception ignore) {}
|
||||||
String[][] resultsParsed= parseResults(results, "r");
|
return sr;
|
||||||
try{
|
|
||||||
DBInterface.connect();
|
|
||||||
DBInterface.InsertInto("relatedserviceid", resultsParsed, false);
|
|
||||||
}catch (SQLException e){//logger.error("error DB");
|
|
||||||
e.printStackTrace(); throw new RemoteException(e.getMessage(),e); }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
try{
|
|
||||||
DBInterface.connect();
|
|
||||||
DBInterface.ExecuteUpdate("Delete from relatedserviceid where id='"+resourceID+"'");
|
|
||||||
}catch (SQLException e){//logger.error("error DB");
|
|
||||||
e.printStackTrace(); throw new RemoteException(e.getMessage(),e); }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateCollection(EndpointReferenceType epr, ExtendedGSSCredential cred, String resourceID, int op) throws RemoteException {
|
|
||||||
switch (op){
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
String collectionQuery= "for $CollectionProfile in collection(\"/db/Profiles/Collection\")//Document/Data/child::*[local-name()='Profile']/DILIGENTResource where $CollectionProfile/Profile/IsUserCollection[string(@value) eq \"true\"] and $CollectionProfile/UniqueID/string() eq '"+resourceID+"' return <r><Id>{$CollectionProfile/UniqueID/string()}</Id><Name>{$CollectionProfile/Profile/Name/string()}</Name><Description>{$CollectionProfile/Profile/Description/string()}</Description><NumberOfMembers>{$CollectionProfile/Profile/NumberOfMembers/string()}</NumberOfMembers><CreationTime>{$CollectionProfile/Profile/CreationTime/string()}</CreationTime><LastUpdateTime>{$CollectionProfile/Profile/LastUpdateTime/string()}</LastUpdateTime></r>";
|
|
||||||
String results=makeQueryDIS(epr, cred, collectionQuery);
|
|
||||||
String[][] resultsParsed= parseResults(results, "r");
|
|
||||||
|
|
||||||
try{
|
|
||||||
DBInterface.connect();
|
|
||||||
DBInterface.InsertInto("collection", resultsParsed, false);
|
|
||||||
}catch (SQLException e){//logger.error("error updating collection on DB");
|
|
||||||
e.printStackTrace(); throw new RemoteException(e.getMessage(),e); }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
try{
|
|
||||||
DBInterface.connect();
|
|
||||||
DBInterface.ExecuteUpdate("Delete from collection where id='"+resourceID+"'");
|
|
||||||
}catch (SQLException e){//logger.error("error updating collection on DB");
|
|
||||||
e.printStackTrace(); throw new RemoteException(e.getMessage(),e); }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateDHN(EndpointReferenceType epr, ExtendedGSSCredential cred, String resourceID, int op) throws RemoteException {
|
|
||||||
switch (op){
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
String dhnQuery="for $DHN in collection(\"/db/Profiles/DHN\")//Document/Data/child::*[local-name()='Profile']/DILIGENTResource where ($DHN/Profile/DHNDescription/Type/string() eq 'Dynamic' or $DHN/Profile/DHNDescription/Type/string() eq 'SelfCleaning') and $DHN/UniqueID/string() eq '"+resourceID+"' return <r><Id>{$DHN/UniqueID/string()}</Id><Name>{$DHN/Profile/DHNDescription/Name/string()}</Name>" +
|
|
||||||
"<Security>{$DHN/Profile/DHNDescription/SecurityEnabled/string(@value)}</Security><UpTime>{$DHN/Profile/DHNDescription/Uptime/string()}</UpTime><VirtualAvailable>{$DHN/Profile/DHNDescription/MainMemory/string(@VirtualAvailable)}</VirtualAvailable><VirtualSize>{string($DHN/Profile/DHNDescription/MainMemory/string(@VirtualSize))}</VirtualSize>" +
|
|
||||||
"<LocalAvailableSpace>{$DHN/Profile/DHNDescription/LocalAvailableSpace/string()}</LocalAvailableSpace><Location>{$DHN/Profile/Site/Location/string()}</Location><Country>{$DHN/Profile/Site/Country/string()}</Country><Domain>{$DHN/Profile/Site/Domain/string()}</Domain></r>";
|
|
||||||
|
|
||||||
String results=makeQueryDIS(epr, cred, dhnQuery);
|
|
||||||
String[][] resultsDHNParsed= parseResults(results, "r");
|
|
||||||
ArrayList<String[]> DNHRelatedRIArray= new ArrayList<String[]>();
|
|
||||||
|
|
||||||
String RIQuery="for $RI in collection(\"/db/Profiles/RunningInstance\")//Document/Data/child::*[local-name()='Profile']/DILIGENTResource return <r><id>{$RI/UniqueID/string()}</id><name>{$RI/Profile/ServiceName/string()}</name></r>";
|
|
||||||
results=makeQueryDIS(epr, cred, RIQuery);
|
|
||||||
|
|
||||||
String[][] resultsRIParsed= parseResults(results, "r");
|
|
||||||
|
|
||||||
String[] riID;
|
|
||||||
/*
|
|
||||||
try {
|
|
||||||
riID=DISHLSClient.getRunningInstanceManager(cred,epr).getAllRunningInstancesOnDHN(resourceID, cred, epr);
|
|
||||||
} catch (DISHLSClientException e) {
|
|
||||||
//logger.error("VDLModel: Error initializing DB with DHN and RI (DISHLSClient error)");
|
|
||||||
throw new RemoteException("Error querying DIS-IP (DISHLSClient error)", e);
|
|
||||||
} catch (DISHLSCredentialException e) {
|
|
||||||
//logger.error("VDLModel: Error initializing DB with DHN and RI (Credential error)");
|
|
||||||
throw new RemoteException("Error querying DIS-IP (Credential error)", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//retreiving related RIID with DHNID
|
|
||||||
String[] temp;
|
|
||||||
|
|
||||||
for (String id: riID){
|
|
||||||
temp=new String[2];
|
|
||||||
temp[0]=resourceID;
|
|
||||||
temp[1]=id;
|
|
||||||
DNHRelatedRIArray.add(temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
try{
|
|
||||||
DBInterface.connect();
|
|
||||||
DBInterface.InsertInto("ghn", resultsDHNParsed, false);
|
|
||||||
DBInterface.InsertInto("runninginstance", resultsRIParsed, false);
|
|
||||||
DBInterface.InsertInto("ghnrelatedri", DNHRelatedRIArray.toArray(new String[0][0]), false);
|
|
||||||
}catch (SQLException e){//logger.error("error updating DHN on DB");
|
|
||||||
e.printStackTrace(); throw new RemoteException(e.getMessage(),e); }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
try{
|
|
||||||
DBInterface.connect();
|
|
||||||
DBInterface.ExecuteUpdate("Delete from dhn where id='"+resourceID+"'");
|
|
||||||
DBInterface.ExecuteUpdate("Delete from dhnrelatedri where DHNID='"+resourceID+"'");
|
|
||||||
}catch (SQLException e){//logger.error("error updating DHN on DB");
|
|
||||||
e.printStackTrace(); throw new RemoteException(e.getMessage(),e); }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateCS(EndpointReferenceType epr, ExtendedGSSCredential cred, String resourceID, int op) throws RemoteException {
|
|
||||||
switch (op){
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
String csQuery= "for $CS in collection(\"/db/Profiles/CS\")//Document/Data/child::*[local-name()='Profile']/DILIGENTResource where $CS/UniqueID/string() eq '"+resourceID+"' return <r><Id>{$CS/UniqueID/string()}</Id><Name>{$CS/Profile/ProcessName/string()}</Name><Description>{$CS/Profile/Description/string()}</Description></r>";
|
|
||||||
String results=makeQueryDIS(epr, cred, csQuery);
|
|
||||||
|
|
||||||
String[][] resultsParsed= parseResults(results, "r");
|
|
||||||
try{
|
|
||||||
DBInterface.connect();
|
|
||||||
DBInterface.InsertInto("cs", resultsParsed, false);
|
|
||||||
}catch (SQLException e){//logger.error("error updating CS on DB");
|
|
||||||
e.printStackTrace(); throw new RemoteException(e.getMessage(),e); }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
try{
|
|
||||||
DBInterface.connect();
|
|
||||||
DBInterface.ExecuteUpdate("Delete from cs where id='"+resourceID+"'");
|
|
||||||
}catch (SQLException e){//logger.error("error updating CS on DB");
|
|
||||||
e.printStackTrace(); throw new RemoteException(e.getMessage(),e); }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateRI(EndpointReferenceType epr, ExtendedGSSCredential cred, String resourceID, int op) throws RemoteException {
|
|
||||||
switch (op){
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
String RIQuery="for $RI in collection(\"/db/Profiles/RunningInstance\")//Document/Data/child::*[local-name()='Profile']/DILIGENTResource where $RI/UniqueID/string() eq '"+resourceID+"' return <r><id>{$RI/UniqueID/string()}</id><name>{$RI/Profile/ServiceName/string()}</name></r>";
|
|
||||||
String relatedDHNQuery="for $RI in collection(\"/db/Profiles/RunningInstance\")//Document/Data/child::*[local-name()='Profile']/DILIGENTResource where $RI/UniqueID/string() eq '"+resourceID+"' return <r><dhnRelated>{$RI/Profile/DHN/string(@UniqueID)}</dhnRelated><id>{$RI/UniqueID/string()}</id></r>";
|
|
||||||
String results=makeQueryDIS(epr, cred, RIQuery);
|
|
||||||
String resultsRelatedDhn=makeQueryDIS(epr, cred, relatedDHNQuery);
|
|
||||||
String[][] resultsRIParsed= parseResults(results, "r");
|
|
||||||
String[][] resultRelatedDhn= parseResults(resultsRelatedDhn, "r");
|
|
||||||
try{
|
|
||||||
DBInterface.connect();
|
|
||||||
DBInterface.InsertInto("runninginstance", resultsRIParsed, false);
|
|
||||||
DBInterface.InsertInto("dhnrelatedri", resultRelatedDhn, false);
|
|
||||||
}catch (SQLException e){//logger.error("error updating RI on DB");
|
|
||||||
e.printStackTrace(); throw new RemoteException(e.getMessage(),e); }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
try{
|
|
||||||
DBInterface.connect();
|
|
||||||
DBInterface.ExecuteUpdate("Delete from runninginstance where id='"+resourceID+"'");
|
|
||||||
DBInterface.ExecuteUpdate("Delete from dhnrelatedri where RIID='"+resourceID+"'");
|
|
||||||
}catch (SQLException e){//logger.error("error updating RI on DB");
|
|
||||||
e.printStackTrace(); throw new RemoteException(e.getMessage(),e); }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,6 @@ public class ModelFactoryService extends GCUBEStartupPortType{
|
||||||
ResultSet res=DBInterface.queryDB("Select VRE.epr from VRE where VRE.id='"+request+"';");
|
ResultSet res=DBInterface.queryDB("Select VRE.epr from VRE where VRE.id='"+request+"';");
|
||||||
EndpointReferenceType dlEpr;
|
EndpointReferenceType dlEpr;
|
||||||
|
|
||||||
|
|
||||||
if (res.next()){
|
if (res.next()){
|
||||||
StringReader stringReader = new StringReader(res.getString(1));
|
StringReader stringReader = new StringReader(res.getString(1));
|
||||||
InputSource inputSource = new InputSource(stringReader);
|
InputSource inputSource = new InputSource(stringReader);
|
||||||
|
|
|
@ -34,7 +34,7 @@ public abstract class MBrokerServiceHandler<T, P> extends GCUBEServiceHandler<GC
|
||||||
return this.parameter;
|
return this.parameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
protected void setReturnValue(T returnValue){
|
protected void setReturnValue(T returnValue){
|
||||||
this.returnValue= returnValue;
|
this.returnValue= returnValue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class MFRelationDerivate extends MFRelationNative {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getAsStringList(){
|
public List<String> getAsStringList(){
|
||||||
return Arrays.asList(new String[]{super.getMetadataCollectionId(), super.getMetadataFormatId(), this.getMetadataFormatId()});
|
return Arrays.asList(new String[]{super.getMetadataCollectionId(), super.getMetadataFormatId(), this.transformationProgramId});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.gcube.common.core.utils.logging.GCUBELog;
|
||||||
|
|
||||||
public class MetadataFormat implements Listable{
|
public class MetadataFormat implements Listable{
|
||||||
|
|
||||||
|
public final static String ANY_LANGUAGE="any";
|
||||||
private final static GCUBELog log= new GCUBELog(MetadataFormat.class.getName());
|
private final static GCUBELog log= new GCUBELog(MetadataFormat.class.getName());
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
|
@ -57,8 +57,10 @@ public class MetadataFormat implements Listable{
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o){
|
public boolean equals(Object o){
|
||||||
MetadataFormat mf = (MetadataFormat)o;
|
MetadataFormat mf = (MetadataFormat)o;
|
||||||
|
boolean languageControl= mf.getLanguage().compareTo(ANY_LANGUAGE)==0 || this.getLanguage().compareTo(ANY_LANGUAGE)==0 || this.getLanguage().compareTo(mf.getLanguage())==0;
|
||||||
|
|
||||||
return ((this.name.compareTo(mf.getName())==0) &&
|
return ((this.name.compareTo(mf.getName())==0) &&
|
||||||
(this.language.compareTo(mf.getLanguage())==0) &&
|
(languageControl) &&
|
||||||
(this.schemaURI.compareTo(mf.getSchemaURI())==0));
|
(this.schemaURI.compareTo(mf.getSchemaURI())==0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue