This commit is contained in:
Lucio Lelii 2008-12-13 18:36:56 +00:00
parent 8c9328e299
commit 55c38d9cb6
2 changed files with 73 additions and 69 deletions

View File

@ -289,8 +289,8 @@ public class IStoDBUtil {
}
//insert the values in the database
System.out.println(derivateMetadataFormatList.size());
//insert values in the database
DBInterface.connect();
DBInterface.InsertInto("mdcollection", values);
DBInterface.insertIntoListable("mdformat", metadataFormatList );
@ -315,16 +315,15 @@ public class IStoDBUtil {
FindPossibleTransformationPrograms fptp= new FindPossibleTransformationPrograms();
MetadataBrokerFormat mbInFormat= new MetadataBrokerFormat();
mbInFormat.setType("collection");
mbInFormat.setLanguage(getParameter().getLanguage());
mbInFormat.setSchema(getParameter().getName()+"="+getParameter().getSchemaURI().toString());
String lng=getParameter().getLanguage();
mbInFormat.setLanguage(lng);
String schema=getParameter().getName()+"="+getParameter().getSchemaURI().toString();
mbInFormat.setSchema(schema);
fptp.setInputFormat(mbInFormat);
MetadataBrokerFormat mbOutFormat= new MetadataBrokerFormat();
mbOutFormat.setType("collection");
fptp.setOutputFormat(mbOutFormat);
fptp.setOutputFormat(null);
FindPossibleTransformationProgramsResponse tpRes= mbportType.findPossibleTransformationPrograms(fptp);
return tpRes.getTransformationProgram();
String[] toReturn= tpRes.getTransformationProgram();
return toReturn;
}
};
@ -333,62 +332,66 @@ public class IStoDBUtil {
sHandler.run();
String[] resList=sHandler.getReturnValue();
XPath xpath= XPathFactory.newInstance().newXPath();
String schemaExpr="//TransformationProgram/Output[@name='TPOutput']/Schema/text()";
String languageExpr="//TransformationProgram/Output[@name='TPOutput']/Language[@isVariable='false']/text()";
String typeExpr="//TransformationProgram/Output[@name='TPOutput']/Type/text()";
String tpIdExpr="/Resource/ID/text()";
Document doc;
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"yes");
List<MFRelationDerivate> derivatedList= new ArrayList<MFRelationDerivate>();
NodeList set;
StreamResult sr;
String tpId;
for(String res: resList){
doc= DocumentBuilderFactory.newInstance().newDocumentBuilder().parse( new InputSource(new StringReader(res)));
set = (NodeList) xpath.evaluate(schemaExpr,doc, XPathConstants.NODESET);
sr = new StreamResult(new StringWriter());
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);
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 languageExpr="//TransformationProgram/Output[@name='TPOutput']/Language[@isVariable='false']/text()";
String typeExpr="//TransformationProgram/Output[@name='TPOutput']/Type/text()";
String tpIdExpr="/Resource/ID/text()";
Document doc;
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"yes");
NodeList set;
StreamResult sr;
String tpId;
for(String res: resList){
doc= DocumentBuilderFactory.newInstance().newDocumentBuilder().parse( new InputSource(new StringReader(res)));
set = (NodeList) xpath.evaluate(schemaExpr,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;
set = (NodeList) xpath.evaluate(typeExpr,doc, XPathConstants.NODESET);
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;
if (mdfList.contains(mfTemp))
mfRelTemp =new MFRelationDerivate(col.getID(), mdfList.get(mdfList.indexOf(mfTemp)).getId(), tpId );
else {
mfRelTemp =new MFRelationDerivate(col.getID(), mfTemp.getId(), tpId );
mdfList.add(mfTemp);
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;
set = (NodeList) xpath.evaluate(typeExpr,doc, XPathConstants.NODESET);
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;
if (mdfList.contains(mfTemp))
mfRelTemp =new MFRelationDerivate(col.getID(), mdfList.get(mdfList.indexOf(mfTemp)).getId(), tpId );
else {
mfRelTemp =new MFRelationDerivate(col.getID(), mfTemp.getId(), tpId );
mdfList.add(mfTemp);
}
derivatedList.add(mfRelTemp);
}
derivatedList.add(mfRelTemp);
}
}
}else System.out.println("resList is null");
return derivatedList;
}

View File

@ -10,7 +10,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.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;
@ -19,9 +18,9 @@ import org.gcube.metadatamanagement.metadatabroker.stubs.service.MetadataBrokerS
public abstract class MBrokerServiceHandler<T, P> extends GCUBEServiceHandler<GCUBEServiceClient> {
private T returnValue= null;
private T returnValue;
private P parameter= null;
private P parameter;
public T getReturnValue(){
return returnValue;
@ -57,10 +56,12 @@ public abstract class MBrokerServiceHandler<T, P> extends GCUBEServiceHandler<GC
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));
MetadataBrokerPortType mbpt= null;
try{
MetadataBrokerServiceAddressingLocator mbsal= new MetadataBrokerServiceAddressingLocator();
mbpt= mbsal.getMetadataBrokerPortTypePort(arg0);
mbpt = GCUBERemotePortTypeContext.getProxy(mbpt,ServiceContext.getContext().getScope());
this.setReturnValue(this.makeCall(mbpt));
}catch(Exception e){throw e;}
}
}