Update of /cvsroot/wsmx/components/choreography/src/unittest/ie/deri/wsmx/choreography/unittest/main
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv4734/choreography/src/unittest/ie/deri/wsmx/choreography/unittest/main
Modified Files:
ChoreographyAndDiscoveryTest.java
Removed Files:
ChoreographyAndDiscoveryTestFast.java
ChoreographyAndDiscoveryTestFastNexcom.java
Log Message:
Removing obsolete tests.
--- ChoreographyAndDiscoveryTestFast.java DELETED ---
Index: ChoreographyAndDiscoveryTest.java
===================================================================
RCS file: /cvsroot/wsmx/components/choreography/src/unittest/ie/deri/wsmx/choreography/unittest/main/ChoreographyAndDiscoveryTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ChoreographyAndDiscoveryTest.java 14 Jun 2007 16:13:10 -0000 1.3
--- ChoreographyAndDiscoveryTest.java 7 Aug 2007 10:09:12 -0000 1.4
***************
*** 1,4 ****
! /*
! * Copyright (c) 2005 National University of Ireland, Galway
*
* This program is free software; you can redistribute it and/or modify
--- 1,4 ----
! /*serviceDiscovery
! * Copyright (c) 2007 National University of Ireland, Galway
*
* This program is free software; you can redistribute it and/or modify
***************
*** 24,46 ****
import ie.deri.wsmx.core.logging.CleanPatternLayout;
import ie.deri.wsmx.discovery.DiscoveryFramework;
import ie.deri.wsmx.mediation.hardwired.MoonDataMediator;
import ie.deri.wsmx.resourcemanager.inmemory.InMemoryRM;
import ie.deri.wsmx.scheduler.Environment;
- import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
- import java.io.FileReader;
import java.io.InputStream;
! import java.io.StringReader;
! import java.io.StringWriter;
import java.util.ArrayList;
! import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
- import java.util.Random;
import java.util.Set;
import junit.framework.TestCase;
--- 24,46 ----
import ie.deri.wsmx.core.logging.CleanPatternLayout;
import ie.deri.wsmx.discovery.DiscoveryFramework;
+ import ie.deri.wsmx.servicediscovery.ServiceDiscoveryFramework;
import ie.deri.wsmx.mediation.hardwired.MoonDataMediator;
import ie.deri.wsmx.resourcemanager.inmemory.InMemoryRM;
import ie.deri.wsmx.scheduler.Environment;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
! import java.text.SimpleDateFormat;
import java.util.ArrayList;
! import java.util.Calendar;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
+ import java.util.Map.Entry;
+
+ import javax.xml.ws.Endpoint;
import junit.framework.TestCase;
***************
*** 51,68 ****
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
! import org.deri.wsmo4j.io.parser.wsml.ParserImpl;
! import org.deri.wsmo4j.io.serializer.wsml.SerializerImpl;
import org.omwg.ontology.Instance;
import org.omwg.ontology.Ontology;
import org.omwg.ontology.Value;
-
import org.wsmo.common.Entity;
import org.wsmo.common.IRI;
import org.wsmo.common.Identifier;
- import org.wsmo.common.TopEntity;
- import org.wsmo.common.exception.InvalidModelException;
- import org.wsmo.common.exception.SynchronisationException;
import org.wsmo.execution.common.component.DataMediator;
import org.wsmo.execution.common.component.ChoreographyEngine.Direction;
import org.wsmo.execution.common.nonwsmo.grounding.EndpointGrounding;
import org.wsmo.execution.common.nonwsmo.grounding.WSDL1_1EndpointGrounding;
--- 51,74 ----
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
!
! import org.ipsuper.nexcom.services.CEOApprovalWebService;
! import org.ipsuper.nexcom.services.LegalDepartmentWebService;
! import org.ipsuper.nexcom.services.VoIPSEEEntryPoint;
! import org.ipsuper.nexcom.services.WholesaleSupplierWebService;
! import org.omwg.logicalexpression.AttributeValueMolecule;
! import org.omwg.logicalexpression.Molecule;
! import org.omwg.logicalexpression.terms.Term;
! import org.omwg.ontology.Concept;
import org.omwg.ontology.Instance;
import org.omwg.ontology.Ontology;
import org.omwg.ontology.Value;
import org.wsmo.common.Entity;
import org.wsmo.common.IRI;
import org.wsmo.common.Identifier;
import org.wsmo.execution.common.component.DataMediator;
import org.wsmo.execution.common.component.ChoreographyEngine.Direction;
+ import org.wsmo.execution.common.exception.ComponentException;
+ import org.wsmo.execution.common.nonwsmo.DiscoveryType;
+ import org.wsmo.execution.common.nonwsmo.ResponseModifierInterface;
import org.wsmo.execution.common.nonwsmo.grounding.EndpointGrounding;
import org.wsmo.execution.common.nonwsmo.grounding.WSDL1_1EndpointGrounding;
***************
*** 70,81 ****
import org.wsmo.factory.WsmoFactory;
import org.wsmo.service.Goal;
import org.wsmo.service.WebService;
import org.wsmo.service.signature.Grounding;
import org.wsmo.service.signature.WSDLGrounding;
! import org.wsmo.wsml.Parser;
! import org.wsmo.wsml.Serializer;
/* Main off-server test. Follows the bahaviour of WSMX in Server mode.
! * Easies testing and debuging process of WSMX components.
*/
--- 76,89 ----
import org.wsmo.factory.WsmoFactory;
import org.wsmo.service.Goal;
+ import org.wsmo.service.Interface;
import org.wsmo.service.WebService;
+ import org.wsmo.service.choreography.Choreography;
import org.wsmo.service.signature.Grounding;
+ import org.wsmo.service.signature.In;
import org.wsmo.service.signature.WSDLGrounding;
!
/* Main off-server test. Follows the bahaviour of WSMX in Server mode.
! * Facilitates testing and debugging process of WSMX components.
*/
***************
*** 85,95 ****
private Radex cEngine;
private CommunicationManager commManager;
! private DiscoveryFramework discovery;
! private InMemoryRM resourceManager;
private DataMediator dataMediator;
private WsmoFactory wsmoFactory;
- private Parser parser;
- private Serializer serializer;
- private Random random;
static {
--- 93,101 ----
private Radex cEngine;
private CommunicationManager commManager;
! private DiscoveryFramework webServiceDiscovery;
! private ServiceDiscoveryFramework serviceDiscovery;
private DataMediator dataMediator;
+ private InMemoryRM resourceManager;
private WsmoFactory wsmoFactory;
static {
***************
*** 97,101 ****
Logger.getRootLogger().removeAllAppenders();
BasicConfigurator.configure(new ConsoleAppender(layout));
- Logger.getRoot().setLevel(Level.INFO);
Logger.getLogger("org.deri").setLevel(Level.DEBUG);
Logger.getLogger("ie.deri").setLevel(Level.DEBUG);
--- 103,106 ----
***************
*** 123,132 ****
commManager = new CommunicationManager();
resourceManager = new InMemoryRM();
! discovery = new DiscoveryFramework();
dataMediator = new MoonDataMediator();
wsmoFactory = Factory.createWsmoFactory(null);
- parser = new ParserImpl(new HashMap<String, Object>());
- serializer = Factory.createSerializer(new HashMap<String, Object>());
- random = new Random();
super.setUp();
}
--- 128,135 ----
commManager = new CommunicationManager();
resourceManager = new InMemoryRM();
! webServiceDiscovery = new DiscoveryFramework();
! serviceDiscovery = new ServiceDiscoveryFramework();
dataMediator = new MoonDataMediator();
wsmoFactory = Factory.createWsmoFactory(null);
super.setUp();
}
***************
*** 134,138 ****
public List<WebService> runDiscovery(Goal goal){
try {
! List<WebService> discoveredWS = discovery.discover(goal);
return discoveredWS;
} catch (Exception e) {
--- 137,141 ----
public List<WebService> runDiscovery(Goal goal){
try {
! List<WebService> discoveredWS = webServiceDiscovery.discover(goal);
return discoveredWS;
} catch (Exception e) {
***************
*** 145,149 ****
! public String runChoreography(Goal goal, List<Entity> goalInstances, WebService webService){
try {
--- 148,152 ----
! public List<Entity> runChoreography(Goal goal, List<Entity> goalInstances, WebService webService, Interface inter){
try {
***************
*** 153,168 ****
try {
! cEngine.registerChoreography(goal);
} catch (Exception e){
//ignore
}
! cEngine.registerChoreography(webService);
! printOutInstances("\n---------- Updating CE ---REQ_TO_PROV--- "+cacheInstancesForProvider.size()+" instances-------------------", cacheInstancesForProvider);
! Map<Instance, Grounding> chorResp = cEngine.updateState(Direction.REQUESTER_TO_PROVIDER, new HashSet(cacheInstancesForProvider));
! logger.info("CE returned:" + chorResp);
//list of messages returned from the WSDL endpoints after the WSML lifting
- //assumption: last message on the list is the final one and it is returned from the ES
List<Entity> msgForRequester = new ArrayList<Entity>();
--- 156,170 ----
try {
! cEngine.registerChoreography(goal, null);
} catch (Exception e){
//ignore
}
! cEngine.registerChoreography(webService, inter);
! printOutInstances("\n\n\n---------- Updating CE ---REQ_TO_PROV--- "+cacheInstancesForProvider.size()+" instances-------------------", cacheInstancesForProvider);
! Map<Instance, ResponseModifierInterface> chorResp = cEngine.updateState(Direction.REQUESTER_TO_PROVIDER, new HashSet(cacheInstancesForProvider));
! logger.info("CE returned:" + Helper.printSet(chorResp.keySet()));
//list of messages returned from the WSDL endpoints after the WSML lifting
List<Entity> msgForRequester = new ArrayList<Entity>();
***************
*** 175,179 ****
List<Entity> localInsts = new ArrayList<Entity>();
localInsts.add(inst);
! WSDLGrounding grounding = (WSDLGrounding) chorResp.get(inst);
logger.debug("------Instance to send: " + inst.getIdentifier()+"--------");
--- 177,184 ----
List<Entity> localInsts = new ArrayList<Entity>();
localInsts.add(inst);
!
! ResponseModifierInterface responseModifier = chorResp.get(inst);
!
! WSDLGrounding grounding = (WSDLGrounding) responseModifier.getGrounding();
logger.debug("------Instance to send: " + inst.getIdentifier()+"--------");
***************
*** 181,188 ****
if (grounding!= null) {
// FIXME reliance on to string
! EndpointGrounding endpointGrounding = new WSDL1_1EndpointGrounding(grounding.getIRI().toString());
!
! logger.debug("Grounding: " + grounding);
! List<Entity> resp = commManager.syncInvoke(webService, localInsts, endpointGrounding, null);
instancesForRequester.addAll(resp);
msgForRequester.addAll(resp);
--- 186,216 ----
if (grounding!= null) {
// FIXME reliance on to string
! String groundingIRI = grounding.getIRI().toString();
! logger.debug("Grounding: >>>" + groundingIRI + "<<<");
! List<Entity> resp = null;
!
! resp = commManager.syncInvokeWS(webService, localInsts, groundingIRI);
!
! Set<Molecule> molecules = responseModifier.getMolecules();
!
! List<Instance> instances = null;
! List<AttributeValueMolecule> avms = new ArrayList<AttributeValueMolecule>();
! for (Molecule molecule : molecules) {
! if(molecule instanceof AttributeValueMolecule) {
! avms.add((AttributeValueMolecule) molecule);
! } else {
! Term concept = molecule.getRightParameter();
! instances = getInstancesForConcept(resp,concept);
! }
! }
! if(instances != null) {
! for (Instance instance : instances) {
! for (AttributeValueMolecule molecule : avms) {
! instance.addAttributeValue((Identifier)molecule.getAttribute(), (Value)molecule.getRightParameter());
! logger.info("Response instance "+ instance.getIdentifier() + "\n added " + molecule.getRightParameter());
! }
! }
! }
!
instancesForRequester.addAll(resp);
msgForRequester.addAll(resp);
***************
*** 194,197 ****
--- 222,229 ----
chorResp = cEngine.updateState(Direction.PROVIDER_TO_REQUESTER, new HashSet(instancesForRequester));
+ //check if in the endEtate
+ if (cEngine.isProviderChorInEndState())
+ break;
+
printOutInstances("\n---------- Updating CE ---REQ_TO_PROV--- "+cacheInstancesForProvider.size()+" instances-------------------", cacheInstancesForProvider);
chorResp = cEngine.updateState(Direction.REQUESTER_TO_PROVIDER, new HashSet(cacheInstancesForProvider));
***************
*** 199,204 ****
if ((chorResp == null) || (chorResp.size() == 0))
break;
! }
!
//delete goal and goal ontology
//clear goal ontology
--- 231,237 ----
if ((chorResp == null) || (chorResp.size() == 0))
break;
! else msgForRequester.clear();
!
! }
//delete goal and goal ontology
//clear goal ontology
***************
*** 220,256 ****
// goalOnto.removeOntology(goalOnto);
!
! //final response for the requester
! Instance finalInstance = (Instance) msgForRequester.get(msgForRequester.size()-1);
//create response choreography
! WsmoFactory wsmoFactory = Factory.createWsmoFactory(null);
! Ontology respOnto = wsmoFactory.createOntology(wsmoFactory.createIRI("http://wsmx.org//responseOntology"));
try {
! respOnto.addInstance(finalInstance);
! } catch (SynchronisationException e) {
! e.printStackTrace();
! } catch (InvalidModelException e) {
e.printStackTrace();
}
!
! StringBuffer sb = new StringBuffer();
! Serializer wsmlSerializer = new SerializerImpl(new HashMap());
! wsmlSerializer.serialize(new TopEntity[]{respOnto}, sb);
! String finalRespStr = sb.toString();
! logger.debug("Final response for the requester ------:" + finalRespStr +"-------");
!
! //clear response ontology
! for (Instance i : (Set<Instance>)respOnto.listInstances() ) {
! Map attr = i.listAttributeValues();
! Set<IRI> keys = attr.keySet();
!
! for (IRI iri : keys){
! Object values = attr.get(iri);
! i.removeAttributeValues(iri);
! }
! }
!
! return finalRespStr;
} catch (Exception e) {
--- 253,271 ----
// goalOnto.removeOntology(goalOnto);
! //
! // //final response for the requester
! // Instance finalInstance = (Instance) msgForRequester.get(msgForRequester.size()-1);
//create response choreography
! Ontology respOnto = wsmoFactory.createOntology(wsmoFactory.createIRI("http://wsmx.org//responseOntology"+Helper.getRandomLong()));
try {
! // for (Entity finalInstance : msgForRequester) {
! respOnto.addInstance((Instance)msgForRequester.get(msgForRequester.size()-1));
! // }
! } catch (Exception e) {
e.printStackTrace();
}
!
! return Helper.getInstances(respOnto);
} catch (Exception e) {
***************
*** 258,264 ****
}
! return null;
}
private void printOutInstances(String msg, List<Entity> instances){
logger.debug(msg);
--- 273,302 ----
}
! return new ArrayList<Entity>();
}
+ /**
+ * Find the instances corresponding to the specified concept in the response.
+ * @param resp A list of entities.
+ * @param concept The concept to look for.
+ * @return The list of instances.
+ */
+ private List<Instance> getInstancesForConcept(List<Entity> resp, Term concept) {
+ List<Instance> instances = new ArrayList<Instance>();
+ for (Entity entity : resp) {
+ if(entity instanceof Instance) {
+ Instance instance = (Instance) entity;
+ logger.info("INSTANCE " + instance.getIdentifier());
+ Set<Concept> concepts = instance.listConcepts();
+ for (Concept c : concepts) {
+ if(c.getIdentifier().toString().equals(concept.toString())) {
+ instances.add(instance);
+ }
+ }
+ }
+ }
+ return instances;
+ }
+
private void printOutInstances(String msg, List<Entity> instances){
logger.debug(msg);
***************
*** 266,270 ****
Instance i = (Instance) e;
! logger.debug(((Instance)e).getIdentifier().toString() + " memberOf " + i.listConcepts().toString());
}
}
--- 304,308 ----
Instance i = (Instance) e;
! logger.debug(((Instance)e).getIdentifier().toString() + " memberOf " + Helper.printSet(i.listConcepts()));
}
}
***************
*** 275,285 ****
Instance i = (Instance) e;
! logger.debug(((Instance)e).getIdentifier().toString() + " memberOf " + i.listConcepts().toString());
Map<Identifier,Set<Value>> attributes = i.listAttributeValues();
! for ( Identifier atrID : attributes.keySet()){
! Set<Value> v = attributes.get(atrID);
! logger.debug(" "+ atrID +" hasValue "+ v.toArray()[0].toString());
}
--- 313,323 ----
Instance i = (Instance) e;
! logger.debug(((Instance)e).getIdentifier().toString() + " memberOf " + Helper.printSet(i.listConcepts()));
Map<Identifier,Set<Value>> attributes = i.listAttributeValues();
! for ( Identifier atrIdent : attributes.keySet()){
! Set<Value> v = attributes.get(atrIdent);
! logger.debug(" "+ atrIdent +" hasValue "+ v.toArray()[0].toString());
}
***************
*** 287,293 ****
}
-
private Set<Entity> invokeRealWebService(WebService ws, Map<Instance, Grounding> chorResp) {
-
Set<Entity> resultInstances = new HashSet<Entity>();
--- 325,329 ----
***************
*** 315,331 ****
! public void testChoreographyAndDiscoveryRun() {
!
! //date and time DIP mediation
// String goalIRIStr = "http://deri.org/dip/goal/demoVTA2#GoalMediateTime2";
// String goalOntoIRIStr = "http://deri.org/dip/goal/demoVTA2#GoalMediateTime2Ontology";
!
//SWS-Challenge mediation scenario
String goalIRIStr = "http://www.wsmx.org/ontologies/rosetta/MoonGoal";
String goalOntoIRIStr = "http://www.wsmx.org/ontologies/rosetta/purchaseorderrequestInstances";
//SWS-Challenge instance discovery scenario
! // String goalIRIStr = "http://www.gsmo.org/dip/sws-challenge/GoalC2#GoalC2";
! // String goalOntoIRIStr = "http://www.gsmo.org/dip/sws-challenge/GoalC2#GoalRequest";
//Adina's travel DIP functional discovery examples
--- 351,384 ----
! public void testChoreographyAndDiscoveryRun() throws UnsupportedOperationException, ComponentException {
! Calendar calendar = Calendar.getInstance();
! SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss");
!
! Endpoint.publish("http://localhost:8001/VoIPProviders", new WholesaleSupplierWebService());
! Endpoint.publish("http://localhost:8001/VoIPSEEEntryPoint", new VoIPSEEEntryPoint());
! Endpoint.publish("http://localhost:8001/CEOApproval", new CEOApprovalWebService());
! Endpoint.publish("http://localhost:8001/LegalDepartment", new LegalDepartmentWebService());
!
! // JOptionPane.showMessageDialog( null, "Close Server");
!
! logger.info("STARTED AT " + sdf.format(calendar.getTime()));
!
! // date and time DIP mediation
// String goalIRIStr = "http://deri.org/dip/goal/demoVTA2#GoalMediateTime2";
// String goalOntoIRIStr = "http://deri.org/dip/goal/demoVTA2#GoalMediateTime2Ontology";
! // String wsIRIStr = "http://deri.org/demoVTA/WSMediateTime";
!
! // String goalIRIStr = "http://deri.org/dip/goal/demoVTA2#GoalMediateTime2";
! // String goalOntoIRIStr = "http://deri.org/dip/goal/demoVTA2#GoalMediateTime2Ontology";
! // String wsIRIStr = "http://deri.org/demoVTA/WSMediateTime";
!
//SWS-Challenge mediation scenario
String goalIRIStr = "http://www.wsmx.org/ontologies/rosetta/MoonGoal";
String goalOntoIRIStr = "http://www.wsmx.org/ontologies/rosetta/purchaseorderrequestInstances";
+ // String wsIRIStr = "http://www.example.org/ontologies/sws-challenge/MoonWS";
//SWS-Challenge instance discovery scenario
! // String goalIRIStr = "http://www.gsmo.org/dip/sws-challenge/GoalA2#GoalA2";
! // String goalOntoIRIStr = "http://www.gsmo.org/dip/sws-challenge/GoalA2#GoalRequest";
//Adina's travel DIP functional discovery examples
***************
*** 340,376 ****
// String goalOntoIRIStr = "file:///c:/WSMX/resources/qosdiscovery/ontologies/bankinter/Goals/GoalGetRecommendation.wsml#GoalRequest";
-
//SUPER pre-review service
- // String goalIRIStr = "http://www.wsmo.org/goal/goalGenerateURL#goalGenerateURL";
- // String goalOntoIRIStr = "http://www.wsmo.org/goal/goalGenerateURL#goalGenerateURLOntology";
-
// String goalIRIStr = "http://www.ip-super.org/ontologies/prereview#goalGetURL";
! // String goalOntoIRIStr = null;
try {
! Set<WebService> temp = Helper.getAllWebServices();
! discovery.addWebServices(new ArrayList<WebService>(Helper.getAllWebServices()));
!
Goal goal = resourceManager.retrieveGoal(wsmoFactory.createIRI(goalIRIStr));
! if (goalOntoIRIStr== null || goalOntoIRIStr.equals("")){
! //do discovery only
! List<WebService> discoveredWS = runDiscovery(goal);
! return;
! }
!
Ontology goalOnto = resourceManager.retrieveOntology(wsmoFactory.createIRI(goalOntoIRIStr));
!
! //do Data Mediation
Map<Entity, List<Entity>> mediatedData = dataMediator.mediate(goalOnto, null, (Set<Entity>)new HashSet<Entity>(Helper.getInstances(goalOnto)));
List<Entity> goalEntities = (List<Entity>)mediatedData.values().toArray()[0];
! List<WebService> discoveredWS = runDiscovery(goal);
! WebService webService = discoveredWS.get(0);
// WebService webService = resourceManager.retrieveWebService(wsmoFactory.createIRI(wsIRIStr));
! runChoreography(goal, goalEntities, webService);
} catch (Exception e) {
e.printStackTrace();
}
}
}
--- 393,578 ----
// String goalOntoIRIStr = "file:///c:/WSMX/resources/qosdiscovery/ontologies/bankinter/Goals/GoalGetRecommendation.wsml#GoalRequest";
//SUPER pre-review service
// String goalIRIStr = "http://www.ip-super.org/ontologies/prereview#goalGetURL";
! // String goalOntoIRIStr = "http://www.ip-super.org/ontologies/prereview#goalGetURLOntology";
!
! //SUPER review Nexcom service
! // String goalIRIStr = "http://www.super-ip.org/goals/nexcom/GoalWholesaleSupplier4#GoalWholesaleSupplier4";
! // String goalOntoIRIStr = "http://www.super-ip.org/goals/nexcom/GoalWholesaleSupplier4#GoalRequest";
! // String wsIRIStr = "http://www.super-ip.org/services/nexcom/WSWholesaleSupplier1#WSWholesaleSupplier1";
!
! // String goalIRIStr = "http://www.super-ip.org/goals/nexcom/GoalWholesaleSupplier#GoalWholesaleSupplier3749294752026241657";
! // String goalOntoIRIStr = "http://www.super-ip.org/goals/nexcom/GoalWholesaleSupplier#GoalRequest3749294752026241657";
!
! // String goalIRIStr = "http://www.super-ip.org/goals/nexcom/GoalWholesaleSupplier#GoalWholesaleSupplier3793135779940045455";
! // String goalOntoIRIStr = "http://www.super-ip.org/goals/nexcom/GoalWholesaleSupplier#GoalRequest3793135779940045455" ;
!
! //SWING use-case
! // String goalIRIStr = "http://www.example.org/TestCreateBothGoal_UoM";
! // String goalOntoIRIStr = "http://www.swing-project.org/ontologies/CreateBothMessageTestOntology2";
! // String wsIRIStr = "http://www.example.org/TestCreateBoth_UoM";
!
! long dt = System.currentTimeMillis();
try {
! // Set<WebService> temp = Helper.getAllWebServices();
! // discovery.addWebServices(new ArrayList<WebService>(Helper.getAllWebServices()));
! logger.info("+++ retrieve goal " +wsmoFactory.createIRI(goalIRIStr));
Goal goal = resourceManager.retrieveGoal(wsmoFactory.createIRI(goalIRIStr));
! // if (goalOntoIRIStr== null || goalOntoIRIStr.equals("")){
! // //do discovery only
! // List<WebService> discoveredWS = runDiscovery(goal);
! // return;
! // }
! logger.info("goal " + goal.getIdentifier());
! logger.info("+++ retrieve ontology " + wsmoFactory.createIRI(goalOntoIRIStr));
Ontology goalOnto = resourceManager.retrieveOntology(wsmoFactory.createIRI(goalOntoIRIStr));
! logger.info("onto " + goalOnto.getIdentifier());
! // //do Data Mediation
Map<Entity, List<Entity>> mediatedData = dataMediator.mediate(goalOnto, null, (Set<Entity>)new HashSet<Entity>(Helper.getInstances(goalOnto)));
List<Entity> goalEntities = (List<Entity>)mediatedData.values().toArray()[0];
+
+ int requiredDiscovery = DiscoveryType.getRequiredDiscoveryType(goal);
+ Set<WebService> searchSpace = resourceManager.retrieveWebServices(requiredDiscovery);
! logger.debug("----List of the services----");
! for (WebService ws: searchSpace){
! logger.debug(ws.getIdentifier().toString());
! }
!
! List<WebService> discoveredWSSimple = new ArrayList<WebService>();
! List<Map<WebService, List<Entity>>> discoveredWSComplex = new ArrayList<Map<WebService, List<Entity>>>();
! if (requiredDiscovery == DiscoveryType.SERVICE_INSTANCEBASED_COMPOSITION_DISCOVERY){
! discoveredWSComplex = serviceDiscovery.discoverServiceCompositon(goal, searchSpace);
! } else if (requiredDiscovery == DiscoveryType.SERVICE_INSTANCEBASED_DISCOVERY){
! discoveredWSSimple = serviceDiscovery.discoverService(goal, searchSpace);
! } else {
! webServiceDiscovery.addWebServices(new ArrayList<WebService>(searchSpace));
! discoveredWSSimple = webServiceDiscovery.discover(goal, searchSpace);
! //check if QoS
! if (requiredDiscovery == DiscoveryType.SERVICE_QOS_DISCOVERY){
! // discoveredWSSimple = serviceDiscovery.discoverService(goal, new HashSet<WebService>(discoveredWSSimple));
! discoveredWSSimple = serviceDiscovery.discoverService(goal, new HashSet<WebService>(searchSpace));
! }
! }
!
! WebService webService = discoveredWSSimple.get(0);
! // logger.info("+++ retrieve WS " +wsmoFactory.createIRI(wsIRIStr));
// WebService webService = resourceManager.retrieveWebService(wsmoFactory.createIRI(wsIRIStr));
! logger.info("ws " + webService.getIdentifier());
! // List<Entity> goalEntities = Helper.getInstances(goalOnto);
! logger.info("+++ run choreog instances:"+goalEntities.size());
! runChoreography(goal, goalEntities, webService, webService.listInterfaces().iterator().next());
! } catch (Exception e) {
! e.printStackTrace();
! }
!
! dt = System.currentTimeMillis() - dt;
! logger.debug("Time taken: "+dt+" ms.");
!
! calendar = Calendar.getInstance();
! logger.info("FINISHED AT " + sdf.format(calendar.getTime()));
! }
!
!
! public void no_testSWSChallengeNewExamples() {
! String goalStr = "GoalC1";
!
! String goalIRIStr = "http://www.wsmo.org/sws-challenge-composition/"+goalStr+"#"+goalStr;
! String goalOntoIRIStr = "http://www.wsmo.org/sws-challenge-composition/"+goalStr+"#GoalRequest";
!
! List<WebService> discoveredWSSimple = new ArrayList<WebService>();
! List<Map<WebService, List<Entity>>> discoveredWSComplex = new ArrayList<Map<WebService, List<Entity>>>();
!
! try {
! Goal goal = resourceManager.retrieveGoal(wsmoFactory.createIRI(goalIRIStr));
! logger.info("goal " + goal.getIdentifier());
!
! int requiredDiscovery = DiscoveryType.getRequiredDiscoveryType(goal);
! Set<WebService> searchSpace = resourceManager.retrieveWebServices(requiredDiscovery);
!
! logger.debug("----List of the services----");
! for (WebService ws: searchSpace){
! logger.debug(ws.getIdentifier().toString());
! }
!
! discoveredWSComplex = serviceDiscovery.discoverServiceCompositon(goal, searchSpace);
!
! List<Entity> overallResp = new ArrayList<Entity>();
! //get highest ranked WS
! Map<WebService, List<Entity>> map = discoveredWSComplex.get(0);
!
! logger.info("--Invoke:--");
! for (Entry<WebService, List<Entity>> entry: map.entrySet()){
! WebService ws = entry.getKey();
! List<Entity> instances = entry.getValue();
! for (Entity inst: instances) {
! List<Entity> goalInst = new ArrayList<Entity>();
! goalInst.add(inst);
! overallResp.addAll(runChoreography(goal, goalInst, ws, ws.listInterfaces().iterator().next()));
! }
! }
!
! Ontology respOnto = wsmoFactory.createOntology(wsmoFactory.createIRI("http://wsmx.org//responseOntology"+Helper.getRandomLong()));
! for (Entity e: overallResp){
! respOnto.addInstance((Instance)e);
! }
!
! logger.info(Helper.serializeTopEntity(respOnto));
!
} catch (Exception e) {
e.printStackTrace();
}
+
}
+ public void no_testSWSChallengeInvocationExamples() {
+ String goalStr = "GoalC4";
+
+ String goalIRIStr = "http://www.wsmo.org/sws-challenge-composition/"+goalStr+"#"+goalStr;
+
+ String wsIRIStr = "http://www.wsmo.org/sws-challenge-composition/WSHawker#WSHawker";
+ String goalOntoIRIStr = "http://www.wsmo.org/sws-challenge-composition/WSHawker#WSHawkerCapabilityOnto";
+
+ Goal goal = null;
+ WebService webService = null;
+ Ontology entOnto = null;
+
+ try {
+ goal = resourceManager.retrieveGoal(wsmoFactory.createIRI(goalIRIStr));
+ webService = resourceManager.retrieveWebService(wsmoFactory.createIRI(wsIRIStr));
+ entOnto = resourceManager.retrieveOntology(wsmoFactory.createIRI(goalOntoIRIStr));
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+
+ Entity ent = entOnto.findInstance((Identifier)wsmoFactory.createIRI("http://www.wsmo.org/sws-challenge-composition/WSHawker#macBook13"));
+
+ // runChoreography(goal, goalInstances, webService, Webs);
+
+ // interface contracting#WSMullerGetPriceInterface
+
+ Interface wsInterface = (Interface) webService.listInterfaces().iterator().next();
+
+ CommunicationManager cm = new CommunicationManager();
+ List<Entity> entities = new ArrayList<Entity>();
+ entities.add(ent);
+
+ Set<In> ins = ((Choreography) wsInterface.getChoreography()).getStateSignature().listInModes();
+
+ EndpointGrounding endpointGrounding = null;
+ for (In in : ins){
+ if ((in.getConcept().getIdentifier().toString().equals("http://www.wsmo.org/sws-challenge-composition/ProductOntology#ProductCategory"))
+ // || (in.getConcept().getIdentifier().toString().equals("http://www.gsmo.org/dip/sws-challenge/ShipmentOntologyProcess#PriceQuoteReq"))
+ ){
+ try {
+ Grounding grounding = in.getGrounding().iterator().next();
+ endpointGrounding = new WSDL1_1EndpointGrounding( ((WSDLGrounding)grounding).getIRI().toString());
+ cm.syncInvoke(webService, entities, endpointGrounding, null);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
}
--- ChoreographyAndDiscoveryTestFastNexcom.java DELETED ---
|